test(session): finish-audit closeout for #184
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
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).
This commit is contained in:
1 parent
836da5833d
commit
3193714a61
8 files changed
+127
-12
No files matched your search
@@ -143,6 +143,57 @@ struct SessionScopeTests {
|
||||
#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
|
||||
|
||||
Reference in new issue
Block a user