fix(session): drain a deferred nil scope as an explicit clear [museion/deferred-empty-piece-scope-lost] #184
No files matched your search
@@ -208,6 +208,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
|
||||
<!-- write-log: window-start -->
|
||||
| Date | Log |
|
||||
|------|-----|
|
||||
| 2026-11-10 | [20261110-pr184-deferred-empty-piece-scope-lost-audit_log.md](docs/devlog/20261110-pr184-deferred-empty-piece-scope-lost-audit_log.md) |
|
||||
| 2026-11-10 | [20261110-issue182-profilelayout-config-set-rail_log.md](docs/devlog/20261110-issue182-profilelayout-config-set-rail_log.md) |
|
||||
| 2026-11-10 | [20261110-issue181-provider-descriptor-pass-readiness_log.md](docs/devlog/20261110-issue181-provider-descriptor-pass-readiness_log.md) |
|
||||
| 2026-11-10 | [20261110-issue180-postfrontmatter-codec-one-readwrite-engine_log.md](docs/devlog/20261110-issue180-postfrontmatter-codec-one-readwrite-engine_log.md) |
|
||||
@@ -217,6 +218,4 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
|
||||
| 2026-11-09 | [20261109-issue183-shrink-agentsmd_log.md](docs/devlog/20261109-issue183-shrink-agentsmd_log.md) |
|
||||
| 2026-11-05 | [20261105-issue175-nous-portal-provider_log.md](docs/devlog/20261105-issue175-nous-portal-provider_log.md) |
|
||||
| 2026-11-05 | [20261105-issue171-default-home-icloud-pin-once-legacy-guard_log.md](docs/devlog/20261105-issue171-default-home-icloud-pin-once-legacy-guard_log.md) |
|
||||
| 2026-11-04 | [20261104-issue158-wayfinder-map-cold-turkey-closed_log.md](docs/devlog/20261104-issue158-wayfinder-map-cold-turkey-closed_log.md) |
|
||||
| 2026-11-04 | [20261104-issue166-preset-chips-cold-turkey-arm-bar_log.md](docs/devlog/20261104-issue166-preset-chips-cold-turkey-arm-bar_log.md) |
|
||||
<!-- write-log: window-end -->
|
||||
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- **session:** a deferred nil scope drains as an explicit clear (PR #184, finding class #176) — `pendingScopePieceTitle: String?` let "a scope request is pending" and "which piece it targets" ride the same optionality, so a nil-target request (the writer leaves the piece mid-stream or mid-replay: New Post, unsaved draft, external guest, nothing open) deferred correctly but at drain time read as "no pending request" and returned without touching `activeEntry` — the old piece's conversation stayed live under a nothing-open context, at all four drain sites. Pending-ness now rides `PendingScope` (`.none` | `.scope(String?)`): a nil target is an explicit clear everywhere it drains. Finish-audit fanout (3 reviewers): dead `Equatable` cut, the same-turn `pendingRestart` ceiling documented at the drain (the scope is lost in respawn's `.starting` window — consume-at-apply is the upgrade path), and the titled-apply half pinned for the first time over a new `hangOnPromptLoad` rig mode (prompt parks, load answers; flip-verified). Suite 654 (PR #184)
|
||||
|
||||
### Changed
|
||||
|
||||
- **home:** Fresh installs default to iCloud (#171, resolution of #170/map #167 — plain build slice for #145) — with no stored Home override, launch resolves once and PINS the winner so the Home never silently moves: a legacy `~/Documents/Museion` directory wins (existing Homes migrate manually, never silently; a stray plain file is not a Home and falls through), else `<CloudDocs>/Museion` when iCloud Drive is present (dynamically resolved unprefixed `Library/Mobile Documents/com~apple~CloudDocs` path, plain FileManager probing — no ubiquity entitlements per ADR-0009), else the silent Documents fallback. No dialog, no rail pill — Settings just shows the resolved path. Repoint-only stands (ADR-0004), zero mover code. The probe/defaults seam is injectable and default constructions under hosted tests neither probe nor pin — the runner app's real iCloud state and defaults are never touched. +9 tests incl. the flip-verified CloudDocs spelling pin and the non-destructive hosted no-write guard. Suite 628 (issue #171)
|
||||
|
||||
@@ -280,8 +280,15 @@ final class MentorSessionModel {
|
||||
/// Owner ruling (2026-11-07): an open-piece switch that arrived while a
|
||||
/// turn or pass streamed — fires at turn end
|
||||
/// (firePendingScopeIfRequested); an in-flight transcript is never
|
||||
/// torn down mid-stream.
|
||||
private var pendingScopePieceTitle: String?
|
||||
/// torn down mid-stream. Pending-ness rides the enum, NEVER the
|
||||
/// target's optionality: a nil target is an explicit clear (nothing
|
||||
/// open hosts nothing), not "no pending request".
|
||||
private enum PendingScope {
|
||||
case none
|
||||
case scope(String?)
|
||||
}
|
||||
|
||||
private var pendingScope: PendingScope = .none
|
||||
/// #137: per-pass readiness — refreshed at pane entry (re-entry
|
||||
/// re-fires the pane's .task — the key-added-in-Settings re-enable
|
||||
/// path). #181: computed in the PassReadiness module over the provider
|
||||
@@ -589,7 +596,7 @@ final class MentorSessionModel {
|
||||
func scopeHostedSession(toOpenPieceTitle pieceTitle: String?) async {
|
||||
guard phase.isReady else { return }
|
||||
guard !isStreaming else {
|
||||
pendingScopePieceTitle = pieceTitle
|
||||
pendingScope = .scope(pieceTitle)
|
||||
return
|
||||
}
|
||||
// Finish-audit: a replay in flight defers the switch too — the
|
||||
@@ -597,10 +604,10 @@ final class MentorSessionModel {
|
||||
// "Resume refused" row into the transcript (the replay's
|
||||
// completion re-fires the pending scope).
|
||||
guard replayingSessionId == nil else {
|
||||
pendingScopePieceTitle = pieceTitle
|
||||
pendingScope = .scope(pieceTitle)
|
||||
return
|
||||
}
|
||||
pendingScopePieceTitle = nil
|
||||
pendingScope = .none
|
||||
let target = SessionRoster.hostedSessionId(forOpenPieceTitle: pieceTitle, in: roster)
|
||||
guard activeEntry?.sessionId != target else { return }
|
||||
guard let entry = roster.first(where: { $0.sessionId == target }) else {
|
||||
@@ -1064,9 +1071,15 @@ extension MentorSessionModel {
|
||||
/// Owner ruling (2026-11-07): a deferred open-piece switch fires at turn
|
||||
/// end — from BOTH turn-end defers (chat sendPrompt and the pass run),
|
||||
/// after `isStreaming` cleared, so the scope rail re-evaluates for real.
|
||||
/// A deferred nil target drains too — it is an explicit clear, so the
|
||||
/// old piece's hosting must not survive the drain. Ceiling: a
|
||||
/// same-turn pendingRestart drains first and respawn's `.starting`
|
||||
/// window makes the scope Task no-op AFTER consumption — the scope
|
||||
/// is lost (pre-existing rail shape, titled and nil alike;
|
||||
/// ponytail: consume-at-apply is the upgrade path).
|
||||
private func firePendingScopeIfRequested() {
|
||||
guard let title = pendingScopePieceTitle else { return }
|
||||
pendingScopePieceTitle = nil
|
||||
guard case let .scope(title) = pendingScope else { return }
|
||||
pendingScope = .none
|
||||
Task { await scopeHostedSession(toOpenPieceTitle: title) }
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Conventions every suite follows. Per-suite pin inventories are NOT kept here —
|
||||
- One runnable check per non-trivial fact: the smallest test that fails if the logic breaks. No fixtures or per-function suites unless asked.
|
||||
- Never touch the real machine: throwaway Homes in temp dirs (`makeHome`, `storeHome`, `makeModelHome`, `makeSessionHome`, `importHome`); every `ProfileProvisioner.perform` call injects `masterRoot` (the default writes the REAL Application Support); keychain tests inject their OWN account slot (a live production token is never read, replaced, or deleted); roster/defaults under hosted tests redirect to temp or assert `.standard` byte-unchanged; `psScan` is stubbed (a dev machine may run the real engine).
|
||||
- Shared helpers are `internal` in the founding file. When a suite crosses a file-length or type-body ceiling, split the new pins into their own file and keep the helpers where they are (PostStorePassTests, MicropubModelTests, MCPToolsPromoteTests, SettingsModelWritePathTests precedents).
|
||||
- Engine tests run IN-PROCESS at the `EngineTransport` seam (#178): `ScriptedEngine.swift` holds the scripted adapter (mode strings mirroring the retired zsh fake: full/crashAfterHandshake/hangOnPrompt/cancelOnPrompt/refuseOnPrompt/noStopReason/strayResearchOnPrompt/loadReplay*/strictMcp), the shared payloads (`ScriptedPayloads`), and the rig roots — build rigs there, never duplicate. Spawn observables: the rig's spawned-profiles record (which engine ran), transport identity (`mentor.host.chat`/`oneShot`) where pid pins used to live, `isClosed` for reaped. Child processes appear in EXACTLY ONE suite — `EngineSmokeTests`, one real-process wire smoke per LLM Surface (chat/pass1/pass2, ADR-0014) over the zsh fake (`makeFakeACP`/`acpTempDir`, defined in ACPClientTests.swift, kept as the wire fixture). The fake-`hermes` CLI harness (ProfileProvisioner/Backup suites) still speaks real `Process` with base64 payloads, `<name>-spawn-log`, `<name>-prompt-log`, and `defer` teardown at rig creation.
|
||||
- Engine tests run IN-PROCESS at the `EngineTransport` seam (#178): `ScriptedEngine.swift` holds the scripted adapter (mode strings mirroring the retired zsh fake: full/crashAfterHandshake/hangOnPrompt/hangOnPromptLoad/cancelOnPrompt/refuseOnPrompt/noStopReason/strayResearchOnPrompt/loadReplay*/strictMcp), the shared payloads (`ScriptedPayloads`), and the rig roots — build rigs there, never duplicate. Spawn observables: the rig's spawned-profiles record (which engine ran), transport identity (`mentor.host.chat`/`oneShot`) where pid pins used to live, `isClosed` for reaped. Child processes appear in EXACTLY ONE suite — `EngineSmokeTests`, one real-process wire smoke per LLM Surface (chat/pass1/pass2, ADR-0014) over the zsh fake (`makeFakeACP`/`acpTempDir`, defined in ACPClientTests.swift, kept as the wire fixture). The fake-`hermes` CLI harness (ProfileProvisioner/Backup suites) still speaks real `Process` with base64 payloads, `<name>-spawn-log`, `<name>-prompt-log`, and `defer` teardown at rig creation.
|
||||
- Waiting: bounded poll loops, each arming its OWN deadline; poll for the watcher rescan after disk writes. Lock/goal machine tests pass `spawnsTicker: false` — the real 1 s ticker could complete a met goal before an injected tick (the #30/#147 flake family).
|
||||
- Suite-name filters (`-only-testing:MuseionTests/<Suite>`) do not run free functions — pin things as suite members.
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ final class ScriptedEngine: EngineTransport, @unchecked Sendable {
|
||||
self.onStderrLine?("cancel received")
|
||||
// #124: the cancel-acknowledging hold — the real engine answers
|
||||
// its hanging prompt the moment session/cancel arrives.
|
||||
guard self.mode == "hangOnPrompt", let id = self.heldPromptID,
|
||||
guard self.mode.hasPrefix("hangOnPrompt"), let id = self.heldPromptID,
|
||||
let continuation = self.parked.removeValue(forKey: id) else { return }
|
||||
self.heldPromptID = nil
|
||||
continuation.resume(returning: .object(["stopReason": .string("cancelled")]))
|
||||
@@ -357,7 +357,7 @@ extension ScriptedEngine {
|
||||
return
|
||||
}
|
||||
toolCall(sid, title: "submit_fix_cards", rawInput: ScriptedPayloads.fixCard)
|
||||
if mode == "hangOnPrompt" {
|
||||
if mode.hasPrefix("hangOnPrompt") {
|
||||
park(id: id, continuation: continuation)
|
||||
heldPromptID = id
|
||||
return
|
||||
@@ -370,7 +370,7 @@ extension ScriptedEngine {
|
||||
params: JSONValue?,
|
||||
continuation: CheckedContinuation<JSONValue?, any Error>,
|
||||
) {
|
||||
guard mode.hasPrefix("loadReplay") else {
|
||||
guard mode.hasPrefix("loadReplay") || mode == "hangOnPromptLoad" else {
|
||||
park(id: id, continuation: continuation) // the zsh never answers
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
// newest-first) pinned here: match, no-match, and title-with-no-roster.
|
||||
// #178: the defer pin runs IN-PROCESS over a ScriptedEngines rig at the
|
||||
// EngineTransport seam — no child process.
|
||||
// deferred-empty-piece-scope-lost: the DEFERRED nil-target pins — leaving
|
||||
// the piece mid-stream or mid-replay must CLEAR the hosting at drain
|
||||
// time (nil is an explicit clear target, not "no pending request").
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -91,4 +94,156 @@ struct SessionScopeTests {
|
||||
// swapped behind the replay.
|
||||
#expect(model.activeEntry?.sessionId == activeBefore)
|
||||
}
|
||||
|
||||
/// deferred-empty-piece-scope-lost (a): a nil scope request (the writer
|
||||
/// left the piece — New Post, unsaved draft, external guest, nothing
|
||||
/// open) arriving while a turn STREAMS defers like any switch, and the
|
||||
/// drain at turn end must CLEAR the hosting — the old piece's
|
||||
/// conversation may not survive under a nothing-open context. Pinned
|
||||
/// over the scripted rig's `hangOnPrompt` mode parking the turn;
|
||||
/// `stopStreaming` ends it (the sendPrompt drain fires).
|
||||
@MainActor
|
||||
@Test func `deferred nil scope during a stream clears hosting at turn end`() async throws {
|
||||
let rosterDir = acpTempDir("scope-nil-stream")
|
||||
let engines = ScriptedEngines(mode: "hangOnPrompt")
|
||||
let model = engines.makeMentor(rosterDirectory: rosterDir)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession() // empty roster — creates the default session, completes
|
||||
guard case .ready = model.phase else {
|
||||
Issue.record("expected ready, got \(model.phase)")
|
||||
return
|
||||
}
|
||||
guard await model.newSession(name: "On A", pieceTitle: "Piece A") != nil else {
|
||||
Issue.record("session creation refused")
|
||||
return
|
||||
}
|
||||
// The turn parks mid-stream (hangOnPrompt) — isStreaming holds.
|
||||
_ = Task { await model.sendPrompt("hold this") }
|
||||
var streaming = false
|
||||
for _ in 0 ..< 250 where !streaming {
|
||||
streaming = model.isStreaming
|
||||
if !streaming {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(streaming)
|
||||
// The writer leaves the piece mid-stream — the clear defers to turn
|
||||
// end; the in-flight transcript stays up.
|
||||
await model.scopeHostedSession(toOpenPieceTitle: nil)
|
||||
#expect(model.activeEntry?.pieceTitle == "Piece A")
|
||||
// Cancel ends the turn — the deferred clear must land now.
|
||||
model.stopStreaming()
|
||||
var cleared = false
|
||||
for _ in 0 ..< 250 where !cleared {
|
||||
cleared = !model.isStreaming && model.activeEntry == nil
|
||||
if !cleared {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(cleared)
|
||||
}
|
||||
|
||||
/// The titled twin of (a), pinning the drain's APPLY half — no test
|
||||
/// anywhere drove a deferred NON-nil switch to its applied state (the
|
||||
/// replay-deferral pin never releases its hold; the nil pins activate
|
||||
/// nothing). Same rig shape over the `hangOnPromptLoad` mode (prompt
|
||||
/// parks, load answers): stopStreaming ends the turn, the drain must
|
||||
/// activate the target piece's session.
|
||||
@MainActor
|
||||
@Test func `deferred titled scope during a stream applies at turn end`() async throws {
|
||||
let rosterDir = acpTempDir("scope-titled-stream")
|
||||
let engines = ScriptedEngines(mode: "hangOnPromptLoad")
|
||||
let model = engines.makeMentor(rosterDirectory: rosterDir)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession() // empty roster — creates the default session, completes
|
||||
guard case .ready = model.phase else {
|
||||
Issue.record("expected ready, got \(model.phase)")
|
||||
return
|
||||
}
|
||||
// B first, then A — A is the active surface (newest), B the target.
|
||||
guard await model.newSession(name: "On B", pieceTitle: "Piece B") != nil,
|
||||
await model.newSession(name: "On A", pieceTitle: "Piece A") != nil
|
||||
else {
|
||||
Issue.record("session creation refused")
|
||||
return
|
||||
}
|
||||
#expect(model.activeEntry?.pieceTitle == "Piece A")
|
||||
// The turn parks mid-stream (hangOnPrompt) — isStreaming holds.
|
||||
_ = Task { await model.sendPrompt("hold this") }
|
||||
var streaming = false
|
||||
for _ in 0 ..< 250 where !streaming {
|
||||
streaming = model.isStreaming
|
||||
if !streaming {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(streaming)
|
||||
// The writer switches to B mid-stream — the switch defers to
|
||||
// turn end; A stays the pane's surface.
|
||||
await model.scopeHostedSession(toOpenPieceTitle: "Piece B")
|
||||
#expect(model.activeEntry?.pieceTitle == "Piece A")
|
||||
// Cancel ends the turn — the deferred switch must apply now.
|
||||
model.stopStreaming()
|
||||
var applied = false
|
||||
for _ in 0 ..< 250 where !applied {
|
||||
applied = !model.isStreaming && model.activeEntry?.pieceTitle == "Piece B"
|
||||
if !applied {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(applied)
|
||||
}
|
||||
|
||||
/// deferred-empty-piece-scope-lost (b): the same nil-scope loss when the
|
||||
/// request arrives while a session/load REPLAYS — the replay's
|
||||
/// completion drains the pending scope; the explicit nil target must
|
||||
/// clear the hosting the replay just activated, or the old piece's
|
||||
/// conversation survives under a nothing-open context. Pinned over the
|
||||
/// scripted rig's `loadReplayHold` mode parking the replay;
|
||||
/// `releaseHeldLoad()` completes it (the resume drain fires).
|
||||
@MainActor
|
||||
@Test func `deferred nil scope behind a replay clears hosting at replay end`() async throws {
|
||||
let rosterDir = acpTempDir("scope-nil-replay")
|
||||
let engines = ScriptedEngines(mode: "loadReplayHold")
|
||||
let model = engines.makeMentor(rosterDirectory: rosterDir)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession() // empty roster — creates the default session, completes
|
||||
guard case .ready = model.phase else {
|
||||
Issue.record("expected ready, got \(model.phase)")
|
||||
return
|
||||
}
|
||||
// Two rostered pieces through the real flow; B's session is active.
|
||||
guard await model.newSession(name: "On A", pieceTitle: "Piece A") != nil,
|
||||
await model.newSession(name: "On B", pieceTitle: "Piece B") != nil
|
||||
else {
|
||||
Issue.record("session creation refused")
|
||||
return
|
||||
}
|
||||
let entryA = try #require(model.roster.first { $0.pieceTitle == "Piece A" })
|
||||
// Park A's replay behind the hold — the load sits in flight, the
|
||||
// slot stays taken, and B remains the pane's surface.
|
||||
_ = Task { await model.resumeSession(entryA) }
|
||||
var held = false
|
||||
for _ in 0 ..< 250 where !held {
|
||||
held = model.stderrTail.contains { $0.contains("hold-load") }
|
||||
if !held {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(held)
|
||||
// The writer leaves the piece while the replay streams into A's
|
||||
// store — the clear defers behind the replay.
|
||||
await model.scopeHostedSession(toOpenPieceTitle: nil)
|
||||
// Release: the replay completes and activates A, then the deferred
|
||||
// nil scope must clear the hosting.
|
||||
engines.releaseHeldLoad()
|
||||
var cleared = false
|
||||
for _ in 0 ..< 250 where !cleared {
|
||||
cleared = model.activeEntry == nil
|
||||
if !cleared {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
}
|
||||
#expect(cleared)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
# PR #184 finish-audit — deferred nil scope drains as an explicit clear
|
||||
|
||||
> **Date:** 2026-11-10
|
||||
> **Type:** issue
|
||||
> **Reference:** PR #184 `fix/deferred-empty-piece-scope-lost` (finding class #176)
|
||||
|
||||
## Goal
|
||||
|
||||
Run the finish-audit reviewer fanout (ponytail / security / general) over PR #184 — `fix(session): drain a deferred nil scope as an explicit clear`, 2 commits ahead of `origin/main` touching `Museion/MentorSessionModel.swift` and `MuseionTests/SessionScopeTests.swift` — then fix what the reviewers flagged.
|
||||
|
||||
## What Was Done
|
||||
|
||||
- Resolved the audit scope mechanically: branch `fix/deferred-empty-piece-scope-lost`, commits 836da58 (fix) + 8531d79 (pin), clean tree, no untracked files. Baseline gates before dispatch: `build-for-testing` green, full unit suite 653/653 (xcresult executed count), swiftformat clean, swiftlint warnings at `MentorSessionModel.swift:158/:192` verified pre-existing on main.
|
||||
- Dispatched the three reviewers in one parallel batch with resolved facts + exclusion list (enum shape settled, pendingRestart sibling pattern, poll-loop conventions, pre-existing lint warnings).
|
||||
- Applied audit fixes on the PR branch (working tree, uncommitted):
|
||||
- Cut the dead `: Equatable` conformance from `PendingScope` (converged finding — ponytail + general independently; only `guard case let` reads, no `==` anywhere).
|
||||
- Ceiling comment on `firePendingScopeIfRequested` naming the restart race and its consume-at-apply upgrade path (see Decisions).
|
||||
- New pin `deferred titled scope during a stream applies at turn end` — the drain's APPLY half for a NON-nil target was unpinned suite-wide (the replay-deferral pin never releases its hold; the nil pins activate nothing).
|
||||
- New rig mode `hangOnPromptLoad` in `ScriptedEngine` (prompt parks + `session/load` answers) — required by the pin: titled apply rides `resumeSession`, and no existing mode parked a prompt while answering a load.
|
||||
- Flip-verified the new pin: weakened the drain guard to `title == nil` → exactly the titled pin failed (5.4 s poll timeout), both nil pins passed; restored, re-ran green.
|
||||
- Final gate after all fixes: swiftformat clean, lint exit 0 (same two pre-existing warnings), full unit suite **654 executed / 0 failed**.
|
||||
|
||||
## Decisions & Rationale
|
||||
|
||||
| Decision | Rationale |
|
||||
|----------|-----------|
|
||||
| Restart race DEFERRED with a ceiling comment, not fixed in-audit | General reviewer's MEDIUM verified real: a same-turn `pendingRestart` + `pendingScope` makes both turn-end defers spawn sibling Tasks; `respawn()` sets `phase = .starting` before its `await startChat()` suspension, the scope Task then no-ops on the `isReady` guard with the pending already consumed → scope lost, respawn's rail re-activates the old entry. But the reviewer's sketched remediation (re-fire at respawn completion) is provably a no-op — `pendingScope = .none` runs before the drop. A correct fix needs consume-at-apply semantics, which changes the documented "not-ready direct call is a no-op" contract (a not-ready call would arm a stale pending that fires at the next drain). Design change with its own hazard → follow-up ticket, not an audit patch. |
|
||||
| Rig extension (`hangOnPromptLoad`) over test contortion | The alternative was a two-hold release dance in `loadReplayHold` (release, wait, release again) — brittle and unreadable. One mode string, three one-line branch widenings, existing modes byte-identical (`hasPrefix` keeps `hangOnPrompt` semantics unchanged). |
|
||||
| Security INFO-1/INFO-2: no action | Both display-only, both pre-existing shapes (owner ruling 2026-11-07 semantics; replay-slot design #137/#178). The PR strictly improves both (the nil clear was lost permanently pre-fix). |
|
||||
| Reviewer call-site count corrected | 4 drain call sites (:538, :573, :827, :978) + the definition — the dispatch's "five" phrasing miscounted; the general reviewer's grep is right. |
|
||||
|
||||
## Gotchas & Fixes
|
||||
|
||||
| Problem | Root Cause | Fix |
|
||||
|---------|------------|-----|
|
||||
| New titled pin failed its first green run ("Expectation failed: applied", 5.4 s) | The rig's `load` parks `session/load` forever in every mode except `loadReplay*` ("the zsh never answers") — the drain's `resumeSession(B)` never returned within the poll. Diagnosed by pulling `failureText` from the xcresult, not re-running. | Added the `hangOnPromptLoad` rig mode. |
|
||||
| Reviewer's proposed remediation didn't survive scrutiny | The re-fire sketch ignores that `pendingScope = .none` (:1117) precedes the Task creation (:1118) — consumption happens before the not-ready drop. | Timeline analysis in the parent; deferred the real fix rather than landing a plausible-looking no-op. |
|
||||
|
||||
## Files Changed
|
||||
|
||||
| File | Change Summary |
|
||||
|------|---------------|
|
||||
| `Museion/MentorSessionModel.swift` | Cut dead `Equatable` on `PendingScope`; ceiling comment on `firePendingScopeIfRequested` (restart race, consume-at-apply upgrade path) |
|
||||
| `MuseionTests/ScriptedEngine.swift` | New `hangOnPromptLoad` mode — prompt parks (cancel releases), load answers with the replay shape |
|
||||
| `MuseionTests/SessionScopeTests.swift` | New pin: deferred titled scope applies at turn end |
|
||||
| `MuseionTests/AGENTS.md` | Mode-string list gains `hangOnPromptLoad` |
|
||||
|
||||
## Open Items & Next Steps
|
||||
|
||||
- [ ] Follow-up ticket: same-turn `pendingRestart` + `pendingScope` loses the scope at the restart window (titled and nil alike; consume-at-apply is the upgrade path). Ceiling comment already in code.
|
||||
- [ ] Titled-defer APPLY behind the REPLAY drain (:538) is still unpinned (stream drain :827 now is).
|
||||
- [ ] Working-tree fixes are uncommitted — PR #184 needs the audit diff committed and pushed (owner authorization required).
|
||||
|
||||
---
|
||||
|
||||
*Log written by write-log skill*
|
||||
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
|
||||
<!-- write-log: full-index -->
|
||||
| Date | Type | File | Summary |
|
||||
|------|------|------|---------|
|
||||
| 2026-11-10 | issue | [20261110-pr184-deferred-empty-piece-scope-lost-audit_log.md](20261110-pr184-deferred-empty-piece-scope-lost-audit_log.md) | PR #184 finish-audit: dead Equatable cut, restart-race ceiling named, titled-apply pin + hangOnPromptLoad rig mode |
|
||||
| 2026-11-10 | issue | [20261110-issue182-profilelayout-config-set-rail_log.md](20261110-issue182-profilelayout-config-set-rail_log.md) | ProfileLayout owns every profile path; HermesConfigRail owns the config-set CLI contract; audited, 684 green (#182) |
|
||||
| 2026-11-10 | issue | [20261110-issue181-provider-descriptor-pass-readiness_log.md](20261110-issue181-provider-descriptor-pass-readiness_log.md) | Provider facts one table on the enum; one credential rail serves probe + readiness; readiness module; shared run guard (#181) |
|
||||
| 2026-11-10 | issue | [20261110-issue180-postfrontmatter-codec-one-readwrite-engine_log.md](20261110-issue180-postfrontmatter-codec-one-readwrite-engine_log.md) | One PostFrontmatter codec: lenient read + three byte-identical write postures, named eligibility predicates both gates consume |
|
||||
|
||||
Reference in new issue
Block a user