On base 627ecf5, MentorSessionModel.swift conflated "a scope request is pending" with "which piece it targets". The pending state was pendingScopePieceTitle: String? (base :284) — optionality did double duty:
both deferral branches assigned it (pendingScopePieceTitle = pieceTitle, base :588 streaming, :596 replay-in-flight), and
the drain guarded guard let title = pendingScopePieceTitle else { return } (base :1107).
So a nil-target scope request (the writer leaves the piece mid-stream or mid-replay — New Post, unsaved draft, external guest, nothing open) deferred correctly, but at turn/replay end the drain's guard let read "no pending request" and returned without touching activeEntry — the old piece's conversation stayed live under a nothing-open context. All four drain sites were affected (sendPrompt, runOneShot, replay success, replay catch — all funnel through firePendingScopeIfRequested). Independently reproduced pre-fix by argus with an extracted-method Swift harness ("after deferred nil scope active=old expected=nil", audit 2026-11-09).
Fix
Separate pending-ness from target optionality — PendingScope enum (none / scope(String?)), Museion/MentorSessionModel.swift:287-295:
both deferral branches now store .scope(pieceTitle) — nil rides as an explicit clear target (:595, :603);
the immediate path resets .none (:606);
the drain pattern-matches case let .scope(title) (:1115-1117) so a nil target drains through scopeHostedSession(toOpenPieceTitle: nil) → SessionRoster.hostedSessionId returns nil for a nil title (:180-183) → the roster guard finds no host → activeEntry = nil (:613-616). Titled deferrals and the immediate path are unchanged; MentorPaneView untouched.
8531d79 test(session): pin deferred nil scope lost at stream and replay drain (RED, first commit)
836da58 fix(session): drain a deferred nil scope as an explicit clear
Two new pins in MuseionTests/SessionScopeTests.swift over the in-process ScriptedEngines rig (#178 seam): (a) nil scope deferred behind a streaming turn clears hosting at turn end (stopStreaming drains), (b) nil scope deferred behind a held replay clears hosting after the replay activates the entry (releaseHeldLoad drains). Ordering note verified in review: in the replay success handler the drain's Task cannot run before the synchronous claimActive completes, so the clear is deterministic, not a transient.
RED at 8531d79 (base + tests): xcodebuild … build-for-testing → ** TEST BUILD SUCCEEDED **; … -only-testing:MuseionTests/SessionScopeTests test-without-building → xcresult executed 4 / passed 2 / failed 2 — exactly the two new pins failed at ~5.57 s (bounded-poll deadline), pre-existing suite tests passed.
GREEN at 836da58: same two commands → ** TEST BUILD SUCCEEDED ** / ** TEST EXECUTE SUCCEEDED **; SessionScopeTests executed 4 / passed 4 / failed 0.
Full unit suite at 836da58 (-only-testing:MuseionTests test-without-building): executed 653 / passed 653 / failed 0 / skipped 0 (xcresult summary + 653 per-case pass lines in the log).
Mergeability: git merge-tree --write-tree 627ecf5 836da58 exit 0 — clean at trunk SHA 627ecf515e89977b831cc2606435877b9d60196e (re-fetched at PR creation; branch is a pure fast-forward of it).
Implementer pre-runs (same commits, ~1 h earlier) corroborate every number above.
Unverified / disclosed (keyed by slug)
museion/deferred-empty-piece-scope-lost — UI suite NOT run to completion at either seat: the UITests-Runner fails at init ("Timed out while enabling automation mode", AGENTS.md #134 machine-state class, needs reboot; zero UI cases executed). Unit suite is the gate per dispatch. The review seat also hit hosted-runner session-handshake hangs unrelated to this branch (cleared by a testmanagerd restart); disclosed for the morning reader, not a branch defect.
museion/deferred-empty-piece-scope-lost — GitNexus pre-edit impact (CRITICAL, acknowledged) and post-edit detect-changes (2 files / 10 symbols / 6 flows, changed symbols = PendingScope + the two functions + tests) are implementer-attested from the implementer worktree; the review seat clone carries no GitNexus index, so they were not re-run. The textual diff independently confirms the 2-file footprint.
No issue number exists for this finding — slug is the key (no Fixes #N footer by design).
Concurrent branch fix/postsmodel-write-rail (brief-14, ticket #179) is in flight on different files (PostsModel/PostsPaneView vs MentorSessionModel/SessionScopeTests here) — zero overlap, this PR is independent of it.
[Generated by AI]
## Finding — museion/deferred-empty-piece-scope-lost (severity: medium, #176 regression class)
On base `627ecf5`, `MentorSessionModel.swift` conflated "a scope request is pending" with "which piece it targets". The pending state was `pendingScopePieceTitle: String?` (base :284) — optionality did double duty:
- both deferral branches assigned it (`pendingScopePieceTitle = pieceTitle`, base :588 streaming, :596 replay-in-flight), and
- the drain guarded `guard let title = pendingScopePieceTitle else { return }` (base :1107).
So a **nil-target** scope request (the writer leaves the piece mid-stream or mid-replay — New Post, unsaved draft, external guest, nothing open) deferred correctly, but at turn/replay end the drain's `guard let` read "no pending request" and returned without touching `activeEntry` — the old piece's conversation stayed live under a nothing-open context. All four drain sites were affected (sendPrompt, runOneShot, replay success, replay catch — all funnel through `firePendingScopeIfRequested`). Independently reproduced pre-fix by argus with an extracted-method Swift harness ("after deferred nil scope active=old expected=nil", audit 2026-11-09).
## Fix
Separate pending-ness from target optionality — `PendingScope` enum (`none` / `scope(String?)`), `Museion/MentorSessionModel.swift:287-295`:
- both deferral branches now store `.scope(pieceTitle)` — nil rides as an explicit clear target (:595, :603);
- the immediate path resets `.none` (:606);
- the drain pattern-matches `case let .scope(title)` (:1115-1117) so a nil target drains through `scopeHostedSession(toOpenPieceTitle: nil)` → `SessionRoster.hostedSessionId` returns nil for a nil title (:180-183) → the roster guard finds no host → `activeEntry = nil` (:613-616). Titled deferrals and the immediate path are unchanged; MentorPaneView untouched.
Commits (off `627ecf5`, merge-base = trunk tip, verified `git merge-tree` clean):
- `8531d79` test(session): pin deferred nil scope lost at stream and replay drain (RED, first commit)
- `836da58` fix(session): drain a deferred nil scope as an explicit clear
Two new pins in `MuseionTests/SessionScopeTests.swift` over the in-process `ScriptedEngines` rig (#178 seam): (a) nil scope deferred behind a streaming turn clears hosting at turn end (`stopStreaming` drains), (b) nil scope deferred behind a held replay clears hosting after the replay activates the entry (`releaseHeldLoad` drains). Ordering note verified in review: in the replay success handler the drain's `Task` cannot run before the synchronous `claimActive` completes, so the clear is deterministic, not a transient.
## Verification (review seat re-runs, 2026-11-10 ~02:44 CET, seat clone at trunk-pinned 836da58)
- RED at `8531d79` (base + tests): `xcodebuild … build-for-testing` → `** TEST BUILD SUCCEEDED **`; `… -only-testing:MuseionTests/SessionScopeTests test-without-building` → xcresult executed 4 / passed 2 / failed 2 — exactly the two new pins failed at ~5.57 s (bounded-poll deadline), pre-existing suite tests passed.
- GREEN at `836da58`: same two commands → `** TEST BUILD SUCCEEDED **` / `** TEST EXECUTE SUCCEEDED **`; SessionScopeTests executed 4 / passed 4 / failed 0.
- Full unit suite at `836da58` (`-only-testing:MuseionTests test-without-building`): executed 653 / passed 653 / failed 0 / skipped 0 (xcresult summary + 653 per-case pass lines in the log).
- Lint at `836da58`: `swiftformat --lint .` → 0/133 files, exit 0; `swiftlint .` → exit 0 (279 pre-existing warnings).
- Mergeability: `git merge-tree --write-tree 627ecf5 836da58` exit 0 — clean at trunk SHA `627ecf515e89977b831cc2606435877b9d60196e` (re-fetched at PR creation; branch is a pure fast-forward of it).
Implementer pre-runs (same commits, ~1 h earlier) corroborate every number above.
## Unverified / disclosed (keyed by slug)
- museion/deferred-empty-piece-scope-lost — UI suite NOT run to completion at either seat: the UITests-Runner fails at init ("Timed out while enabling automation mode", AGENTS.md #134 machine-state class, needs reboot; zero UI cases executed). Unit suite is the gate per dispatch. The review seat also hit hosted-runner session-handshake hangs unrelated to this branch (cleared by a testmanagerd restart); disclosed for the morning reader, not a branch defect.
- museion/deferred-empty-piece-scope-lost — GitNexus pre-edit impact (CRITICAL, acknowledged) and post-edit `detect-changes` (2 files / 10 symbols / 6 flows, changed symbols = PendingScope + the two functions + tests) are implementer-attested from the implementer worktree; the review seat clone carries no GitNexus index, so they were not re-run. The textual diff independently confirms the 2-file footprint.
- No issue number exists for this finding — slug is the key (no `Fixes #N` footer by design).
- Concurrent branch `fix/postsmodel-write-rail` (brief-14, ticket #179) is in flight on different files (PostsModel/PostsPaneView vs MentorSessionModel/SessionScopeTests here) — zero overlap, this PR is independent of it.
[Generated by AI]
Leaving the piece mid-stream (New Post over a streaming reply) or
mid-replay defers a nil scope request like any switch, but the drain
guards on the optional title — an explicit nil target (clear) is
indistinguishable from no pending request, so activeEntry survives on
the old piece under a nothing-open context.
Two RED pins over the scripted rig: hangOnPrompt (stream parks, cancel
ends it, drain at sendPrompt turn end) and loadReplayHold (replay parks,
releaseHeldLoad completes it, drain at resume). Both fail on this base:
executed 4 / passed 2 / failed 2 (the two new pins).
pendingScopePieceTitle: String? conflated 'no pending request' with a
pending request whose target is nil (the writer left the piece — New
Post, unsaved draft, external guest, nothing open). Both deferral
branches stored the target and the drain guarded on the optional, so a
deferred nil target was silently dropped: at turn end (sendPrompt,
runOneShot) or replay completion (resumeSession) the old piece's
activeEntry survived under a nothing-open context, contrary to the
scope contract (#176 class).
Pending-ness now rides PendingScope (none | scope(String?)) — a nil
target drains through scopeHostedSession like any titled target and
clears activeEntry. Titled deferrals and the immediate path are
unchanged.
Verified: SessionScopeTests 4/4 green (both RED pins now green in
45 ms — the clear lands at the drain, not a deadline); full unit bundle
653/653 green; swiftformat 0 files; swiftlint exit 0 (two pre-existing
warnings in MentorSessionModel.swift, unchanged kind).
Three-reviewer fanout over PR #184's deferred nil-scope fix:
- pin the titled drain's APPLY half (unpinned suite-wide) over a new
hangOnPromptLoad rig mode (prompt parks, load answers);
flip-verified against a nil-only drain guard
- cut the dead Equatable on PendingScope (converged finding)
- name the same-turn pendingRestart ceiling on the drain: respawn's
.starting window drops the consumed scope; consume-at-apply is the
upgrade path (follow-up ticket)
- changelog + devlog for the PR; AGENTS.md rails refreshed
Suite 654 executed / 0 failed; swiftformat clean; swiftlint
unchanged (both warnings pre-exist on main).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Finding — museion/deferred-empty-piece-scope-lost (severity: medium, #176 regression class)
On base
627ecf5,MentorSessionModel.swiftconflated "a scope request is pending" with "which piece it targets". The pending state waspendingScopePieceTitle: String?(base :284) — optionality did double duty:pendingScopePieceTitle = pieceTitle, base :588 streaming, :596 replay-in-flight), andguard let title = pendingScopePieceTitle else { return }(base :1107).So a nil-target scope request (the writer leaves the piece mid-stream or mid-replay — New Post, unsaved draft, external guest, nothing open) deferred correctly, but at turn/replay end the drain's
guard letread "no pending request" and returned without touchingactiveEntry— the old piece's conversation stayed live under a nothing-open context. All four drain sites were affected (sendPrompt, runOneShot, replay success, replay catch — all funnel throughfirePendingScopeIfRequested). Independently reproduced pre-fix by argus with an extracted-method Swift harness ("after deferred nil scope active=old expected=nil", audit 2026-11-09).Fix
Separate pending-ness from target optionality —
PendingScopeenum (none/scope(String?)),Museion/MentorSessionModel.swift:287-295:.scope(pieceTitle)— nil rides as an explicit clear target (:595, :603);.none(:606);case let .scope(title)(:1115-1117) so a nil target drains throughscopeHostedSession(toOpenPieceTitle: nil)→SessionRoster.hostedSessionIdreturns nil for a nil title (:180-183) → the roster guard finds no host →activeEntry = nil(:613-616). Titled deferrals and the immediate path are unchanged; MentorPaneView untouched.Commits (off
627ecf5, merge-base = trunk tip, verifiedgit merge-treeclean):8531d79test(session): pin deferred nil scope lost at stream and replay drain (RED, first commit)836da58fix(session): drain a deferred nil scope as an explicit clearTwo new pins in
MuseionTests/SessionScopeTests.swiftover the in-processScriptedEnginesrig (#178 seam): (a) nil scope deferred behind a streaming turn clears hosting at turn end (stopStreamingdrains), (b) nil scope deferred behind a held replay clears hosting after the replay activates the entry (releaseHeldLoaddrains). Ordering note verified in review: in the replay success handler the drain'sTaskcannot run before the synchronousclaimActivecompletes, so the clear is deterministic, not a transient.Verification (review seat re-runs, 2026-11-10 ~02:44 CET, seat clone at trunk-pinned
836da58)8531d79(base + tests):xcodebuild … build-for-testing→** TEST BUILD SUCCEEDED **;… -only-testing:MuseionTests/SessionScopeTests test-without-building→ xcresult executed 4 / passed 2 / failed 2 — exactly the two new pins failed at ~5.57 s (bounded-poll deadline), pre-existing suite tests passed.836da58: same two commands →** TEST BUILD SUCCEEDED **/** TEST EXECUTE SUCCEEDED **; SessionScopeTests executed 4 / passed 4 / failed 0.836da58(-only-testing:MuseionTests test-without-building): executed 653 / passed 653 / failed 0 / skipped 0 (xcresult summary + 653 per-case pass lines in the log).836da58:swiftformat --lint .→ 0/133 files, exit 0;swiftlint .→ exit 0 (279 pre-existing warnings).git merge-tree --write-tree 627ecf5 836da58exit 0 — clean at trunk SHA627ecf515e89977b831cc2606435877b9d60196e(re-fetched at PR creation; branch is a pure fast-forward of it).Implementer pre-runs (same commits, ~1 h earlier) corroborate every number above.
Unverified / disclosed (keyed by slug)
detect-changes(2 files / 10 symbols / 6 flows, changed symbols = PendingScope + the two functions + tests) are implementer-attested from the implementer worktree; the review seat clone carries no GitNexus index, so they were not re-run. The textual diff independently confirms the 2-file footprint.Fixes #Nfooter by design).fix/postsmodel-write-rail(brief-14, ticket #179) is in flight on different files (PostsModel/PostsPaneView vs MentorSessionModel/SessionScopeTests here) — zero overlap, this PR is independent of it.[Generated by AI]
3193714a61toa3ef007562