test(mentor): cancel-ack fake + deferred teardown
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
The fake ACP engine's hangOnPrompt mode slept oblivious to session/cancel, so a cancelled turn was only observable through teardown and the pass bar's Cancel rail was never individually discriminated. hangOnPrompt now holds the turn reading: session/cancel answers the hanging prompt with stopReason "cancelled" (the real engine's contract); stdin EOF without a cancel answers end_turn so the child exits. New pin 'cancelling a held pass ends the turn cancelled with no advance' (RED->GREEN; bounded polls, so an emptied cancelPass fails the pin instead of hanging the suite). Every fake-spawning test (27 rigs across ACPClientTests + PassRunTests) tears down via defer at rig creation — a cancelled or interrupted test cannot leak the child; trailing happy-path teardowns removed, mechanism/bound teardowns kept and commented. Harness docs updated to match; 316 tests green. Closes #124
This commit is contained in:
1 parent
4d33676a08
commit
154bb8a114
6 files changed
+191
-34
No files matched your search
@@ -132,7 +132,7 @@ Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/do
|
||||
<!-- gitnexus:start -->
|
||||
# GitNexus — Code Intelligence
|
||||
|
||||
This project is indexed by GitNexus as **museion** (3880 symbols, 12452 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
||||
This project is indexed by GitNexus as **museion** (3889 symbols, 12468 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
||||
|
||||
> Index stale? Run `node .gitnexus/run.cjs analyze` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? `npx gitnexus analyze` (npm 11 crash → `npm i -g gitnexus`; #1939).
|
||||
|
||||
@@ -180,6 +180,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
|
||||
<!-- write-log: window-start -->
|
||||
| Date | Log |
|
||||
|------|-----|
|
||||
| 2026-10-20 | [20261020-issue124-cancel-ack-fake-deferred-teardown_log.md](docs/devlog/20261020-issue124-cancel-ack-fake-deferred-teardown_log.md) |
|
||||
| 2026-10-20 | [20261020-issue25-apply-skip-fix-cards-trust-ui_log.md](docs/devlog/20261020-issue25-apply-skip-fix-cards-trust-ui_log.md) |
|
||||
| 2026-10-20 | [20261020-issue24-pass-guard-matrix_log.md](docs/devlog/20261020-issue24-pass-guard-matrix_log.md) |
|
||||
| 2026-10-20 | [20261020-issue23-museion-tools-mcp-server-dogfood-hardening_log.md](docs/devlog/20261020-issue23-museion-tools-mcp-server-dogfood-hardening_log.md) |
|
||||
@@ -188,5 +189,4 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
|
||||
| 2026-10-16 | [20261016-issue114-convert-to-post_log.md](docs/devlog/20261016-issue114-convert-to-post_log.md) |
|
||||
| 2026-10-16 | [20261016-issue112-outline-interaction-ii_log.md](docs/devlog/20261016-issue112-outline-interaction-ii_log.md) |
|
||||
| 2026-10-15 | [20261015-issue111-outline-guard_log.md](docs/devlog/20261015-issue111-outline-guard_log.md) |
|
||||
| 2026-10-15 | [20261015-issue109-outline-type-outliner_log.md](docs/devlog/20261015-issue109-outline-type-outliner_log.md) |
|
||||
| 2026-10-13 | [20261013-issue108-library-ui-archive-audits_log.md](docs/devlog/20261013-issue108-library-ui-archive-audits_log.md) |<!-- write-log: window-end -->
|
||||
| 2026-10-15 | [20261015-issue109-outline-type-outliner_log.md](docs/devlog/20261015-issue109-outline-type-outliner_log.md) |<!-- write-log: window-end -->
|
||||
@@ -7,23 +7,37 @@
|
||||
// fake-binary Process pattern from EngineGateTests). Exercises the client
|
||||
// and model against the real Process path: handshake, prompt + streamed
|
||||
// updates + fix-card tool call, crash, teardown.
|
||||
// #124: hangOnPrompt now acknowledges session/cancel (stopReason
|
||||
// "cancelled") — a sleep-oblivious hold can't pin the Cancel rail.
|
||||
//
|
||||
|
||||
// swiftlint:disable file_length
|
||||
// One file: the shared fake harness (makeFakeACP/acpTempDir — other test
|
||||
// files build rigs on it) + the client/model suites that pin its contract.
|
||||
|
||||
import Foundation
|
||||
@testable import Museion
|
||||
import Testing
|
||||
|
||||
// MARK: - Fake ACP server + helpers
|
||||
|
||||
// swiftlint:disable function_body_length
|
||||
/// Builds a fake engine binary that speaks enough ACP for the M0 client.
|
||||
/// `mode`: `full` answers everything; `crashAfterHandshake` exits 1 right
|
||||
/// after answering initialize; `hangOnPrompt` sleeps 30 s inside prompt;
|
||||
/// `cancelOnPrompt` streams one chunk then answers stopReason "cancelled";
|
||||
/// `refuseOnPrompt` answers stopReason "refusal" (no chunks).
|
||||
/// after answering initialize; `hangOnPrompt` streams, then HOLDS the turn
|
||||
/// open reading — session/cancel answers the hanging prompt with stopReason
|
||||
/// "cancelled" (the real engine's contract, #124), stdin EOF without a
|
||||
/// cancel (teardown) answers end_turn, and during the hold ONLY
|
||||
/// session/cancel is answered — any other request waits until teardown;
|
||||
/// `cancelOnPrompt` streams one chunk then answers stopReason "cancelled"
|
||||
/// with no cancel needed; `refuseOnPrompt` answers stopReason "refusal" (no
|
||||
/// chunks).
|
||||
/// The mode travels in a file next to the fake (self-locating — race-free
|
||||
/// under parallel suites, same convention as ProfileProvisionerTests).
|
||||
/// The fix-card payload travels base64-encoded so shell quoting can't break.
|
||||
/// Internal (not private) so later test files can reuse the fake (#24).
|
||||
/// One contiguous zsh program — splitting the script string would break the
|
||||
/// wire-line inspectability the script's own comment pins.
|
||||
func makeFakeACP(at dir: String, name: String = "hermes-acp", mode: String = "full") -> String {
|
||||
let path = (dir as NSString).appendingPathComponent(name)
|
||||
let modeFile = (dir as NSString).appendingPathComponent("\(name)-mode")
|
||||
@@ -65,7 +79,18 @@ func makeFakeACP(at dir: String, name: String = "hermes-acp", mode: String = "fu
|
||||
echo $notify'{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"mentor."},"messageId":"m1"}}}'
|
||||
echo $notify'{"sessionUpdate":"tool_call","toolCallId":"tc1","title":"submit_fix_cards","rawInput":'"$card"'}}}'
|
||||
if [[ "$mode" == "hangOnPrompt" ]]; then
|
||||
sleep 30
|
||||
# #124: the cancel-acknowledging hold — the real engine answers its
|
||||
# hanging prompt with stopReason "cancelled" the moment session/cancel
|
||||
# arrives; a sleep-oblivious fake can't pin the Cancel rail. EOF with
|
||||
# no cancel (teardown closed stdin) ends the turn so the child exits.
|
||||
while IFS= read -r held; do
|
||||
[[ -z "$held" ]] && continue
|
||||
hm=$(print -r -- "$held" | /usr/bin/python3 -c 'import json,sys; print(json.load(sys.stdin).get("method",""))')
|
||||
if [[ "$hm" == "session/cancel" ]]; then
|
||||
echo $framing"$rid",'"result":{"stopReason":"cancelled"}}'
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo $framing"$rid",'"result":{"stopReason":"end_turn"}}'
|
||||
elif [[ "$method" == "session/cancel" ]]; then
|
||||
@@ -81,6 +106,8 @@ func makeFakeACP(at dir: String, name: String = "hermes-acp", mode: String = "fu
|
||||
return path
|
||||
}
|
||||
|
||||
// swiftlint:enable function_body_length
|
||||
|
||||
/// The fix-card payload for the fake's tool call, base64-encoded so shell
|
||||
/// quoting can never break the wire JSON. The REAL submit_fix_cards
|
||||
/// argument shape (snake_case, anchor as object) — pins the nested parse;
|
||||
@@ -139,19 +166,20 @@ struct ACPClientTests {
|
||||
@Test func `handshake returns agent version`() async throws {
|
||||
let fake = makeFakeACP(at: acpTempDir("handshake"))
|
||||
let client = ACPEngineClient(binaryPath: fake)
|
||||
defer { client.close() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
try client.start { _, _ in }
|
||||
let result = try await client.request("initialize", params: .object([
|
||||
"protocolVersion": .number(1),
|
||||
"clientCapabilities": .object([:]),
|
||||
"clientInfo": .object(["name": .string("Museion"), "title": .string("Museion"), "version": .string("0.1")]),
|
||||
]))
|
||||
client.close()
|
||||
#expect(result?.objectValue?["agentInfo"]?.objectValue?["version"]?.stringValue == "9.9.9")
|
||||
}
|
||||
|
||||
@Test func `crash after handshake fires onCrash`() async throws {
|
||||
let fake = makeFakeACP(at: acpTempDir("crash"), mode: "crashAfterHandshake")
|
||||
let client = ACPEngineClient(binaryPath: fake)
|
||||
defer { client.close() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
try client.start { _, _ in }
|
||||
// Hook FIRST, then trigger: the fake exits right after answering
|
||||
// initialize, so the crash can beat a hook attached after the request.
|
||||
@@ -160,15 +188,15 @@ struct ACPClientTests {
|
||||
_ = try? await client.request("initialize", params: nil)
|
||||
try? await Task.sleep(for: .milliseconds(500))
|
||||
}
|
||||
client.close()
|
||||
}
|
||||
|
||||
@Test func `cancel is fire-and-forget`() async throws {
|
||||
let fake = makeFakeACP(at: acpTempDir("cancel"), mode: "hangOnPrompt")
|
||||
let client = ACPEngineClient(binaryPath: fake)
|
||||
defer { client.close() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
try client.start { _, _ in }
|
||||
_ = try? await client.request("session/new", params: .object(["cwd": .string("/tmp")]))
|
||||
// Prompt hangs (sleep 30) — drive it in the background, then cancel.
|
||||
// The prompt holds — drive it in the background, then cancel.
|
||||
let promptTask = Task { try? await client.request("session/prompt", params: .object([
|
||||
"sessionId": .string("sess-1"),
|
||||
"prompt": .array([.object(["type": .string("text"), "text": .string("hello")])]),
|
||||
@@ -176,7 +204,7 @@ struct ACPClientTests {
|
||||
try await Task.sleep(for: .milliseconds(300))
|
||||
client.notify("session/cancel", params: .object(["sessionId": .string("sess-1")]))
|
||||
try await Task.sleep(for: .milliseconds(200))
|
||||
client.close() // also resumes the hung prompt task with an error
|
||||
client.close() // bound only — the fake answers the prompt on cancel
|
||||
_ = await promptTask.value
|
||||
// ponytail: reaching here without deadlock IS the cancel test — a
|
||||
// notification produces no response and the client never waits for one.
|
||||
@@ -186,6 +214,7 @@ struct ACPClientTests {
|
||||
@Test func `teardown kills a hung child and fails pending requests`() async throws {
|
||||
let fake = makeFakeACP(at: acpTempDir("teardown"), mode: "hangOnPrompt")
|
||||
let client = ACPEngineClient(binaryPath: fake)
|
||||
defer { client.close() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
try client.start { _, _ in }
|
||||
_ = try? await client.request("session/new", params: .object(["cwd": .string("/tmp")]))
|
||||
let promptTask = Task { try? await client.request("session/prompt", params: .object([
|
||||
@@ -215,6 +244,7 @@ struct ACPClientTests {
|
||||
@Test func `sendPrompt returns ended end_turn and streams text`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-ended"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
let outcome = await model.sendPrompt("hello mentor")
|
||||
#expect(outcome == .ended(stopReason: "end_turn"))
|
||||
@@ -225,13 +255,13 @@ struct ACPClientTests {
|
||||
return false
|
||||
}
|
||||
#expect(streamed)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `labeled prompt renders the label not the wire stub`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-label"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
// The pass orchestrator sends a long wire stub; only the label may land.
|
||||
await model.sendPrompt("STUB-WIRE-PROMPT that must never surface", label: "Pass 1 · My Post")
|
||||
@@ -243,17 +273,16 @@ struct ACPClientTests {
|
||||
}
|
||||
#expect(texts.contains("Pass 1 · My Post"))
|
||||
#expect(!texts.contains { $0.contains("STUB-WIRE-PROMPT") })
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `cancelled stopReason maps to TurnOutcome cancelled`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-cancel"), mode: "cancelOnPrompt")
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
let outcome = await model.sendPrompt("hello mentor")
|
||||
#expect(outcome == .cancelled)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
/// Review pin: a prompt response without stopReason is NOT a completed
|
||||
@@ -262,10 +291,10 @@ struct ACPClientTests {
|
||||
@Test func `missing stopReason maps to failed`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-nostop"), mode: "noStopReason")
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
let outcome = await model.sendPrompt("hello mentor")
|
||||
#expect(outcome == .failed)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
/// #23 dogfood regression pin: session/prompt's response arrives when the
|
||||
@@ -291,6 +320,7 @@ struct ACPClientTests {
|
||||
@Test func `refusal maps to ended refusal and still renders the refusal row`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-refusal"), mode: "refuseOnPrompt")
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
let outcome = await model.sendPrompt("hello mentor")
|
||||
#expect(outcome == .ended(stopReason: "refusal"))
|
||||
@@ -301,13 +331,13 @@ struct ACPClientTests {
|
||||
return false
|
||||
}
|
||||
#expect(refused)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `thought chunks land in a collapsed thought row not the critique`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("thought-lane"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
// The fake streams a thought chunk BEFORE the message chunks — the
|
||||
// live shape of a pass turn (long thinking, then the critique).
|
||||
@@ -334,13 +364,13 @@ struct ACPClientTests {
|
||||
}
|
||||
return false
|
||||
})
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `transport failure mid-turn maps to TurnOutcome failed`() async throws {
|
||||
let fake = makeFakeACP(at: acpTempDir("outcome-failed"), mode: "hangOnPrompt")
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
// Deterministic transport failure through the model: hangOnPrompt keeps
|
||||
// the turn pending, then shutdown() closes the client — the in-flight
|
||||
@@ -363,6 +393,7 @@ struct ACPClientTests {
|
||||
@Test func `model handshake renders version and streams fix card`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("model"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
await model.openSession()
|
||||
guard case let .ready(sessionId) = model.phase else {
|
||||
Issue.record("expected ready, got \(model.phase)")
|
||||
@@ -385,13 +416,13 @@ struct ACPClientTests {
|
||||
return false
|
||||
}
|
||||
#expect(hasText)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `model surfaces advisory version drift note`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("drift"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
// Running 9.9.9 vs recorded 0.20.6 → the advisory note fires, never blocks.
|
||||
model.recordedVersionProvider = { "0.20.6" }
|
||||
await model.openSession()
|
||||
@@ -401,13 +432,13 @@ struct ACPClientTests {
|
||||
}
|
||||
#expect(model.versionNote?.contains("9.9.9") == true)
|
||||
#expect(model.versionNote?.contains("0.20.6") == true)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `build metadata does not fabricate version drift`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("metadata-drift"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
// The gate records the derived version; the handshake answers the base —
|
||||
// same engine, strings differ only in +build metadata → no note.
|
||||
model.recordedVersionProvider = { "9.9.9+2177.g735e426" }
|
||||
@@ -417,7 +448,6 @@ struct ACPClientTests {
|
||||
return
|
||||
}
|
||||
#expect(model.versionNote == nil)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -432,13 +462,13 @@ struct ACPClientTests {
|
||||
@Test func `session new against strict mcpServers schema reaches ready`() async {
|
||||
let fake = makeStrictFakeACP(at: acpTempDir("strict"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
guard case let .ready(sessionId) = model.phase else {
|
||||
Issue.record("expected ready against strict engine, got \(model.phase); stderr: \(model.stderrTail)")
|
||||
return
|
||||
}
|
||||
#expect(sessionId == "sess-1")
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -446,6 +476,7 @@ struct ACPClientTests {
|
||||
let dir = acpTempDir("restart")
|
||||
let crashing = makeFakeACP(at: dir, name: "hermes-acp-crash", mode: "crashAfterHandshake")
|
||||
let model = MentorSessionModel(binaryPath: crashing)
|
||||
defer { model.shutdown() }
|
||||
await model.openSession()
|
||||
for _ in 0 ..< 100 {
|
||||
if case .crashed = model.phase {
|
||||
@@ -461,11 +492,10 @@ struct ACPClientTests {
|
||||
// restart recovery (the pane's Restart button drives model.restart()).
|
||||
let healthy = makeFakeACP(at: dir, name: "hermes-acp-ok")
|
||||
let model2 = MentorSessionModel(binaryPath: healthy)
|
||||
defer { model2.shutdown() }
|
||||
await model2.openSession()
|
||||
guard case .ready = model2.phase else {
|
||||
Issue.record("expected ready on healthy engine, got \(model2.phase)")
|
||||
return
|
||||
}
|
||||
model.shutdown()
|
||||
model2.shutdown()
|
||||
}
|
||||
@@ -18,14 +18,14 @@ Owned by the root AGENTS.md contract.
|
||||
|
||||
- Non-trivial logic leaves one runnable check behind: the smallest test that fails if the logic breaks. No fixtures or per-function suites unless asked.
|
||||
- `EngineGateTests.swift` builds fake `hermes` shell scripts in temp dirs and runs them through the real `Process` path — copy that pattern for any future child-process testing.
|
||||
- `ACPClientTests.swift` extends it into a full fake ACP *server*: a zsh script speaking real NDJSON JSON-RPC over stdio (`makeFakeACP`), with a per-binary mode file (`crashAfterHandshake`, `hangOnPrompt`, `cancelOnPrompt` — one chunk then stopReason cancelled, `refuseOnPrompt` — refusal, no chunks; default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON. `makeFakeACP` + `acpTempDir` are internal (shared-helper convention) for reuse by later test files (#24); `makeStrictFakeACP` stays private. The full mode streams a `agent_thought_chunk` before the message chunks — pinning the #24 dogfood thought lane (thinking lands in a collapsed `.thought` row, never in the critique text). Crash assertions use Swift Testing's `confirmation` (hook the callback BEFORE triggering the crash). `makeStrictFakeACP` (same file) guards `session/new` the way adapter ≥0.21.5 does — rejecting a missing `mcpServers` with `-32602` — pinning the wire contract the lenient fake can't catch. #24 turn-outcome seam tests live INSIDE the suite — suite-name filters (`-only-testing:MuseionTests/ACPClientTests`) do not run free functions: ended/cancelled/failed mapping, labeled prompt renders the label not the wire stub.
|
||||
- `ACPClientTests.swift` extends it into a full fake ACP *server*: a zsh script speaking real NDJSON JSON-RPC over stdio (`makeFakeACP`), with a per-binary mode file (`crashAfterHandshake`, `hangOnPrompt` — streams then holds the turn reading, `cancelOnPrompt` — one chunk then stopReason cancelled, `noStopReason` — prompt result without stopReason, `refuseOnPrompt` — refusal, no chunks; default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON. `makeFakeACP` + `acpTempDir` are internal (shared-helper convention) for reuse by later test files (#24); `makeStrictFakeACP` stays private. **#124:** `hangOnPrompt` is the cancel-acknowledging hold — while the turn is held the fake keeps reading; `session/cancel` answers the held prompt `stopReason "cancelled"` (the real engine's contract), stdin EOF without a cancel (teardown) answers end_turn so the child exits; during the hold ONLY `session/cancel` is answered — any other request waits until teardown. Every fake-spawning test tears down via `defer` at rig creation (`client.close()`/`model.shutdown()`, both idempotent) — a cancelled or interrupted test cannot leak the child; explicit mid-test teardown remains only where it IS the mechanism or a regression bound. The full mode streams a `agent_thought_chunk` before the message chunks — pinning the #24 dogfood thought lane (thinking lands in a collapsed `.thought` row, never in the critique text). Crash assertions use Swift Testing's `confirmation` (hook the callback BEFORE triggering the crash). `makeStrictFakeACP` (same file) guards `session/new` the way adapter ≥0.21.5 does — rejecting a missing `mcpServers` with `-32602` — pinning the wire contract the lenient fake can't catch. #24 turn-outcome seam tests live INSIDE the suite — suite-name filters (`-only-testing:MuseionTests/ACPClientTests`) do not run free functions: ended/cancelled/failed mapping, labeled prompt renders the label not the wire stub.
|
||||
- `ProfileProvisionerTests.swift` extends it: the fake creates the profile at `<binaryDir>/profiles/<name>` (self-locating, race-free under parallel tests); payload dirs are built at runtime; the bundled-payload test asserts manifest ↔ payload correspondence. **#23:** the fake also speaks `-p museion mcp list`/`mcp add` (marker file = already registered, invocation log for the exact add command line, one stdin line read, `mcp-add-fails` reject knob); registration tests pin fresh-add-exact-command, already-registered skip, probe-failure → `.failed(.register)`. #48 failure-path tests live in `ProfileProvisionerFailureTests.swift` (own file — Not-Now defer + re-fail, `registration only via the mcp add cli rail never hand-written yaml` (config.yaml byte-identity through failed + nil-skip + CLI-registering passes — the #44 invariant as amended by #23), state.json engine-gate-only, copy-phase catch branch, path-traversal rejection, orphaned-temp sweep). Shared helpers (`makeFakeHermes`, `makePayload`, `defaultSkills`, `provTempDir`) are internal in `ProfileProvisionerTests.swift`. `ProfileBackupTests.swift` (own helpers `backupTempDir`/`makeProfileFixture`) injects profile/backups roots, a fixed clock, and a `psScan` stub — a dev machine may run the real engine, so the ps scan is never trusted in tests.
|
||||
- `PostLibraryTests.swift` (#17, #107) — throwaway Homes via `makeHome`/`writePiece`/`writePost` in temp dirs: bare corpus posts (First Draft/writer defaults), lenient + quoted frontmatter (`pass_state`/`origin`/`type`), two-level scan across `projects/<name>/<id>/` + `archive/<name>/<id>/` (project/isArchived stamped, noise at both levels), lazy folders / hidden dirs / symlinks not surfacing, localizedStandardCompare title sort, `untitled` edges (blank, marker-only, unterminated frontmatter), leading-blank-line frontmatter, default Home = `~/Documents/Museion`.
|
||||
- `PostStoreTests.swift` (#18, #107) — write side via `storeHome`/`readPost` (same temp-dir pattern): slug algorithm cases (diacritics, CJK, cap, punctuation-only → untitled), lazy first write into `projects/<name>/<id>/` + #59 stamp (type first) round-trip through `Post.scan`, untitled fallback, case-insensitive collision suffixes over the GLOBAL slug space (projects + archive; archived slugs never reused), `writeNew(project:)` routing, rename (retitle + move within the same project, archived stays archived, insert-title path, same-slug retitle-only, collision -2), trash removes from projects/ and archive/, overwrite preservation + bare-post normalization, `readBody` stripping, blocked-project failure path, writeNew outline stamping (#109: `type: outline` first line, `projects/<project>/<id>/post.md` placement, scan round-trip; default `.post` pinned). **#114:** convert round-trip — verbatim keeps the body + flips type (scan reads post, stamp values kept), ladder shape, vanished-piece throw, archived piece converts in place (stays under `archive/`). **#108:** project moves — `readPiece(home:root:project:id:)` path-aware helper; move (byte-identity, same-project no-op), archive/restore round-trip, archived-move refusal, `unarchiveProject` fresh + merge cases (dot-entries skipped), `createProject` validation matrix (duplicate case-insensitive + NFD twin, empty/slash/dot/`:` rejected), hidden user folders survive unarchive (source removed only when emptied), `unarchiveProject` model test (dirty open piece flushes before the move). **Fold pin:** decomposed-jamo folder on disk vs a precomposed title → `-2` (Swift `==`/Set already fold canonical equivalence — the premise asserts byte inequality; `folded` is the explicit, tested contract). **#24 (S3.1) pass substrate:** `snapshotPass` (body verbatim under `passes/pass-1.md`, no frontmatter; re-run overwrites = latest per type; pass-1/pass-2 coexist; vanished id throws), `advancePassState` (First Draft + pass1 → Pass-1 Done with origin/type/body byte-preserved through the stamp round-trip; First Draft + pass2 → Pass-2 Done order-free; Pass-2 Done + pass1 stays put — monotonic, never regresses; re-run idempotent; vanished id throws), `PassContext` stub shape (pass name + level, piece path, research line only when hasResearch, fix-card reminder) + `estimateTokens` (stub+body chars/4 rounded up, expected derived independently in the test).
|
||||
- `MCPToolsTests.swift` + `MCPServerWireTests.swift` (#23, S2.4) — the museion-tools store + wire: anchor matrix (exact substring, occurrence 2-of-2 valid / 3-of-2 stale / vanished quote / empty quote → stale), submit round-trip (snake_case card file in `<piece>/cards/`, stale lands flagged, vanished piece + malformed card throw), scan newest-first + junk skip, learnings per content type (learnings/posts|outlines) + missing dir → empty; the wire tests drive `MCPServer.run(lines:write:)` in-process — initialize protocolVersion echo, notifications silent, both tools with typed schemas, a full submit round-trip through real JSON-RPC lines, isError tool failures, -32601/-32700. **#25 slice 1 pins:** the ten-card pass ceiling (12-card submit → the ranked head P1–P10 lands, the malformed 12th never errors the call), rank stamped in submit order + pre-schema card decodes rank nil, `appliedText` (nth-occurrence replacement, empty fix cuts, beyond-count/vanished/empty quote + demonstration lane → nil), `close` (same file rewritten with the status flipped, all other fields intact, scan sees it, foreign id throws); **#25 wire pin:** an 11-card submit through the wire lands 10 on disk and the reply JSON carries `dropped_over_ceiling` == 1.
|
||||
- `FixCardApplyTests.swift` (#25, S3.2/S3.3) — the apply/skip/done lifecycle over `makeModelHome` + direct `FixCardStore.submit` seeding, scenario header first: apply on an open piece with a dirty buffer (flush-first, disk + card agree, saveState saved, `loadGeneration` moved — the `adoptText` rail), stale anchor at apply (.stale, post.md byte-identical, the card flags itself stale and stays open), demonstration card refused, unanswered #67 conflict refused (disk untouched), skip/done flip only the status (poll for the watcher rescan), and the store addenda pins (scan sorts submittedAt DESC → rank ASC with a slug-order-divergent batch + newest-submit-first; `close`'s anchorStatus refresh/preserve).
|
||||
- `PostsModelTests.swift` (#108 audits, #109) — the model-layer lifecycle the store tests can't see, via `makeModelHome` (direct `@MainActor` model over a temp home): archive-open-piece clears selection+session, moveToProject reopens the session at the new `folderURL`, restore reopens off the archive path, New Project's draft lands in the named project, abandoning a draft for an external file drops `pendingProject`, unarchive of a dirty open piece flushes before the folder move, `moveTargets` lists empty projects from disk (default included); #109: `newOutline()` stages a `"- "`/`.outline` draft (selected project targeting waits for the bind rescan, default-project fallback), `saveDraft` of it materializes with `type: outline` and opens the session. **#111 (S7):** the guard lifecycle — mixed outline fires + holds (no session, file untouched), prose answer opens with the routing override + an edit/flush cycle drops nothing, outline answer = consented drop on save, cancel re-guards on next open, clean outline/prose pieces open untouched, reselect of the open guarded piece is a no-op, a draft staged during the ask displaces it and survives the answer, guard fires from the scan-known type too (poll-loop rescan wait); `writeMixedOutline` is one `writeNew` call. **#114 (S4):** convert lifecycle — the open outline piece converts and REOPENS routed prose (`proseOverridePostID` set, disk `type: post`, ladder applied); an unopened piece converts without touching the open session or selection; `verbatim convert flips the posts list after the rescan` (the live-report regression pin). **#114 audit pins:** dirty-session flushes before the transform, staging warns from `session.text` (piece open) vs disk (closed), Headings aborts when the body went lossy behind an unwarned ask (and the warned-consent path proceeds), unanswered #67 conflict aborts (alert stays answerable), failed flush aborts (piece vanished), convert dismisses a held #111 guard ask as a cancel. **#23:** the card-lifecycle pins — cards pre-seeded via a direct `FixCardStore.submit` surface after select, a card landing on disk AFTER open grows the list through the watcher-driven rescan (poll pattern, no reselect), closing the piece (newPost) clears to [], archive-open path covered.
|
||||
- `PassRunTests.swift` (#24, S3.1) — the pass orchestration over the REAL client + fake ACP path, via `makePassRig` (temp home + bound `PostsModel` + `MentorSessionModel` over `makeFakeACP`, reusing the now-internal ACPClientTests helpers): end-to-end run (pre-pass snapshot in `passes/pass-1.md`, disk stamp `Pass-1 Done`, label row "Pass 1 · <title>" renders, the wire stub never lands in the transcript, library regroups after the rescan — poll pattern), cancelled (`cancelOnPrompt`) and refused (`refuseOnPrompt`) turns never advance (the snapshot still lands — pre-pass is unconditional), a staged draft refuses with `lastError` and writes nothing, **the full guard matrix (#24 close-out): a second `runPass` while one streams refuses with "already running" and `cancelPass` ends the held turn through shutdown teardown (state stays First Draft — `hangOnPrompt` holds the turn open; the UI's Cancel rail is exercised directly), a pass while the mentor streams a chat turn refuses "mid-reply" (nothing on disk — the guard fires before the snapshot), a pass against a never-opened engine refuses "isn't ready"**, a dirty session flushes BEFORE the snapshot (snapshot + disk both carry the edit), and Pass 2 runs straight from First Draft (order-free, monotonic).
|
||||
- `PassRunTests.swift` (#24, S3.1) — the pass orchestration over the REAL client + fake ACP path, via `makePassRig` (temp home + bound `PostsModel` + `MentorSessionModel` over `makeFakeACP`, reusing the now-internal ACPClientTests helpers): end-to-end run (pre-pass snapshot in `passes/pass-1.md`, disk stamp `Pass-1 Done`, label row "Pass 1 · <title>" renders, the wire stub never lands in the transcript, library regroups after the rescan — poll pattern), cancelled (`cancelOnPrompt`) and refused (`refuseOnPrompt`) turns never advance (the snapshot still lands — pre-pass is unconditional), a staged draft refuses with `lastError` and writes nothing, **the full guard matrix (#24 close-out): a second `runPass` while one streams refuses with "already running" and `cancelPass` ends the held turn (state stays First Draft — `hangOnPrompt` holds the turn open; the UI's Cancel rail is exercised directly, the trailing `mentor.shutdown()` a regression bound only), a pass while the mentor streams a chat turn refuses "mid-reply" (nothing on disk — the guard fires before the snapshot), a pass against a never-opened engine refuses "isn't ready"**, a dirty session flushes BEFORE the snapshot (snapshot + disk both carry the edit), and Pass 2 runs straight from First Draft (order-free, monotonic). **#124:** the Cancel rail individually pinned — `cancelling a held pass ends the turn cancelled with no advance` (the cancel-acknowledging fake answers the held prompt, bounded polls, no teardown assist — the pin fails if `cancelPass`'s body is emptied); every rig test tears down via `defer { mentor.shutdown() }` at rig creation.
|
||||
- `EditorSessionTests.swift` (#19) — session mechanics via `makeSessionHome`/`seedPost`: debounce → flush + sidecar round-trip, clean-flush no-op + ⌘S immediate, #67 conflict (echo suppressed, Yes-reload, No-keep-local → overwrite), write failure → `.failed` + retry.
|
||||
- `ReadingPresenterTests.swift` (#76, ADR-0011) — apex HTML pipeline coverage with inline fixture strings: chunker sentinel stamping, stamper attribute rewrite (multi-digit), `blocks(for:)` line↔range map (monotonic, 1-based lines, exact chunk offsets — the click→edit map), pipeline tests running the REAL bundled apex binary (headings/inline marks, `1. 1. 1.` renumber via native `<ol>`, mixed-lists stay split, table/quote/fence/link/HR constructs with exact `data-source-line` stamps, base64 image embed against `spike/prose`, native footnotes), fallback = escaped source, stylesheet carries the slot CSS vars.
|
||||
- `ProsePresenterTests.swift` (#77) — editing-surface parity pinned: heading ladder sizes (30/22/19/17-bold), half-height blanks (9pt), quote secondary-ink + indent, fence interior mono-14, inline traits (bold/italic/code/link underline + dimmed marks), CSS-1.8 leading calibration tolerance, CommonMark intraword-underscore rule, reattribute with fence-state retrofit.
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// #24 (S3.1): the pass orchestration — PostsModel.runPass over the real
|
||||
// client + fake ACP server (ACPClientTests' fake, PostsModelTests' temp-home
|
||||
// model). Pre-pass snapshot before the engine sees the text, Pass State
|
||||
// advancing only on a completed turn, order-free.
|
||||
// advancing only on a completed turn, order-free. #124: teardown defers at
|
||||
// rig creation — the fake child dies with the test however it exits.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -36,6 +37,7 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
|
||||
@Test @MainActor func `runPass snapshots streams and advances pass state`() async throws {
|
||||
let (model, home, mentor) = try makePassRig()
|
||||
defer { mentor.shutdown() } // #124: at rig creation — the child dies with the test, however it exits
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Pass Piece\n\nThe body under pass.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -62,11 +64,11 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
#expect(model.posts.first(where: { $0.id == post.id })?.passState == .pass1Done)
|
||||
mentor.shutdown()
|
||||
}
|
||||
|
||||
@Test @MainActor func `cancelled pass does not advance`() async throws {
|
||||
let (model, home, mentor) = try makePassRig(mode: "cancelOnPrompt")
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Cancel Me\n\nStill first draft.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -80,11 +82,11 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
let onDisk = try String(contentsOf: piece.appendingPathComponent("post.md"), encoding: .utf8)
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
#expect(model.runningPass == nil)
|
||||
mentor.shutdown()
|
||||
}
|
||||
|
||||
@Test @MainActor func `refused pass does not advance`() async throws {
|
||||
let (model, home, mentor) = try makePassRig(mode: "refuseOnPrompt")
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Refused\n\nAlso first draft.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -96,11 +98,11 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
)
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
#expect(model.runningPass == nil)
|
||||
mentor.shutdown()
|
||||
}
|
||||
|
||||
@Test @MainActor func `runPass requires an open saved post`() async throws {
|
||||
let (model, home, mentor) = try makePassRig()
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
model.newPost() // draft staged — no folder exists
|
||||
|
||||
@@ -109,11 +111,11 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
#expect(model.lastError?.contains("post") == true)
|
||||
// Nothing landed on disk — the draft never even materialized a folder.
|
||||
#expect(!FileManager.default.fileExists(atPath: home.appendingPathComponent("projects/posts").path))
|
||||
mentor.shutdown()
|
||||
}
|
||||
|
||||
@Test @MainActor func `second pass while one runs refuses and cancel ends it`() async throws {
|
||||
let (model, home, mentor) = try makePassRig(mode: "hangOnPrompt")
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Held\n\nMid-pass.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -128,7 +130,7 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
#expect(model.lastError?.contains("already running") == true)
|
||||
|
||||
model.cancelPass(mentor: mentor) // the pass bar's Cancel rail
|
||||
mentor.shutdown() // the hung fake ignores cancel; teardown frees the turn
|
||||
mentor.shutdown() // bound only — the cancel-acknowledging fake ends the turn on the notification
|
||||
_ = await first.value
|
||||
#expect(model.runningPass == nil)
|
||||
|
||||
@@ -138,8 +140,39 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
}
|
||||
|
||||
@Test @MainActor func `cancelling a held pass ends the turn cancelled with no advance`() async throws {
|
||||
let (model, home, mentor) = try makePassRig(mode: "hangOnPrompt")
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Held\n\nCancel me.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
|
||||
let run = Task { await model.runPass(.pass1, home: home, mentor: mentor) }
|
||||
for _ in 0 ..< 250 where model.runningPass == nil {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
#expect(model.runningPass == .pass1)
|
||||
|
||||
model.cancelPass(mentor: mentor) // the pass bar's Cancel rail — no teardown assist
|
||||
// #124: the cancel-acknowledging fake answers the held prompt, the turn
|
||||
// ends cancelled, runningPass clears. Bounded poll — an emptied Cancel
|
||||
// handler fails here instead of hanging the suite.
|
||||
for _ in 0 ..< 250 where model.runningPass != nil {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
#expect(model.runningPass == nil)
|
||||
mentor.shutdown() // frees the turn if the rail regressed — bounds the await
|
||||
_ = await run.value
|
||||
|
||||
let onDisk = try String(
|
||||
contentsOf: home.appendingPathComponent("projects/posts/\(post.id)/post.md"), encoding: .utf8,
|
||||
)
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
}
|
||||
|
||||
@Test @MainActor func `pass refuses while the mentor is mid-reply`() async throws {
|
||||
let (model, home, mentor) = try makePassRig(mode: "hangOnPrompt")
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Busy\n\nMentor chatting.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -156,12 +189,13 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
#expect(!FileManager.default.fileExists(
|
||||
atPath: home.appendingPathComponent("projects/posts/\(post.id)/passes").path,
|
||||
))
|
||||
mentor.shutdown()
|
||||
mentor.shutdown() // frees the held chat turn — bounds the await below
|
||||
_ = await chat.value
|
||||
}
|
||||
|
||||
@Test @MainActor func `pass refuses when the engine is not ready`() async throws {
|
||||
let (model, home, mentor) = try makePassRig() // never opened — engine idle
|
||||
defer { mentor.shutdown() }
|
||||
let post = try PostStore.writeNew(body: "# Cold\n\nNo engine yet.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
|
||||
@@ -175,6 +209,7 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
|
||||
@Test @MainActor func `dirty session flushes before the snapshot`() async throws {
|
||||
let (model, home, mentor) = try makePassRig()
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Flush First\n\nOriginal.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -187,11 +222,11 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
#expect(snapshot.contains("Edited on the way."))
|
||||
let onDisk = try String(contentsOf: piece.appendingPathComponent("post.md"), encoding: .utf8)
|
||||
#expect(onDisk.contains("Edited on the way."))
|
||||
mentor.shutdown()
|
||||
}
|
||||
|
||||
@Test @MainActor func `pass runs in any order from first draft`() async throws {
|
||||
let (model, home, mentor) = try makePassRig()
|
||||
defer { mentor.shutdown() }
|
||||
await mentor.openSession()
|
||||
let post = try PostStore.writeNew(body: "# Free Order\n\nStraight to two.", home: home)
|
||||
model.select(post.id, home: home)
|
||||
@@ -202,5 +237,4 @@ private func textRows(of model: MentorSessionModel) -> [String] {
|
||||
contentsOf: home.appendingPathComponent("projects/posts/\(post.id)/post.md"), encoding: .utf8,
|
||||
)
|
||||
#expect(onDisk.contains("pass_state: Pass-2 Done"))
|
||||
mentor.shutdown()
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
# Mentor ACP test-harness hardening: cancel-acknowledging fake + deferred teardown
|
||||
|
||||
> **Date:** 2026-10-20
|
||||
> **Type:** issue
|
||||
> **Reference:** https://git.babylondreams.de/AlexKucera/Museion/issues/124
|
||||
|
||||
## Goal
|
||||
|
||||
Issue #124, deferred from the #24 close-out audit: two hardening pieces for
|
||||
the mentor's ACP test harness. (1) A cancel-acknowledging fake engine mode —
|
||||
the fake ignored `session/cancel`, so tests that cancelled a turn only
|
||||
observed the outcome through teardown and the pass bar's Cancel rail was
|
||||
never individually discriminated. (2) Deferred teardown as the harness
|
||||
convention — tests called shutdown at the end of the happy path, so a
|
||||
cancelled or interrupted test leaked a sleeping fake child for its 30 s hang
|
||||
window. Scope: the ACP fake harness + pass-run suite; provisioning fakes
|
||||
unaffected.
|
||||
|
||||
## What Was Done
|
||||
|
||||
- `makeFakeACP`'s `hangOnPrompt` mode upgraded from `sleep 30` to a
|
||||
cancel-acknowledging hold: after streaming, the fake keeps reading; the
|
||||
moment `session/cancel` arrives it answers the hanging `session/prompt`
|
||||
with `stopReason "cancelled"` (the real engine's contract); stdin EOF
|
||||
without a cancel (teardown) falls through to the existing `end_turn` echo
|
||||
so the child exits instead of sleeping out a window. Standalone-verified
|
||||
in zsh before touching the Swift file (cancel → cancelled with the pending
|
||||
rid; EOF → end_turn, exit 0).
|
||||
- New pin test in PassRunTests: `cancelling a held pass ends the turn
|
||||
cancelled with no advance` — RED→GREEN demonstrated (old fake: poll
|
||||
exhausts, 315 pass / 1 fail; new fake: green). Bounded polls mean an
|
||||
emptied `cancelPass` fails the `#expect` after 5 s instead of hanging the
|
||||
suite; the explicit `mentor.shutdown()` before `await run.value` is the
|
||||
commented failure bound.
|
||||
- Deferred teardown at rig creation across every fake-spawning test: 17 rigs
|
||||
in ACPClientTests (`defer { client.close() }` / `defer { model.shutdown() }`
|
||||
— both verified idempotent and nil-safe pre-start), 10 rigs in PassRunTests
|
||||
(`defer { mentor.shutdown() }`). Twelve happy-path-only trailing teardown
|
||||
calls deleted; six mid-test teardowns kept where they ARE the mechanism or
|
||||
a documented regression bound.
|
||||
- Docs: MuseionTests/AGENTS.md — both file bullets rewritten (hangOnPrompt's
|
||||
new semantics incl. the only-cancel-is-answered-during-hold clause, the
|
||||
defer-at-rig-creation convention, the new pin, `noStopReason` added to the
|
||||
mode list, stale "through shutdown teardown" wording fixed). Two swiftlint
|
||||
pragmas (file_length on ACPClientTests.swift, function_body_length wrap
|
||||
around makeFakeACP) with inline rationale.
|
||||
- Verification: unit suite 316/316 (three runs: RED, GREEN, final-state),
|
||||
full scheme incl. UI 317/317, SwiftFormat 0 changes, SwiftLint 0
|
||||
violations on touched files. SwiftFairy audit + two-axis code-review
|
||||
(Standards/Spec) + finish-audit fanout (ponytail/security/general) all
|
||||
clean; the one accepted audit fix (doc clause on dropped requests during
|
||||
the hold) landed.
|
||||
|
||||
## Decisions & Rationale
|
||||
|
||||
| Decision | Rationale |
|
||||
|----------|-----------|
|
||||
| Upgrade `hangOnPrompt` in place instead of a new mode name | The acceptance criterion is behavioral; no test needs the old cancel-oblivious hold, so a parallel mode would be dead code. Spec reviewer adjudicated this satisfies "new fake mode". |
|
||||
| Inner read loop instead of `sleep 30` + timeout | EOF-on-teardown already bounds the child's life; a timer would be extra machinery for a case the defer convention removes. |
|
||||
| Bounded poll + explicit shutdown bound in the pin | An emptied `cancelPass` must FAIL the pin, not hang the suite; the poll exhausts in 5 s and the shutdown frees the turn so the await completes and the test reports the failure. |
|
||||
| Keep 6 mid-test teardown calls | Each is the test's subject (teardown-kills, transport-failure) or a commented regression bound (fire-and-forget, second-pass, mid-reply, pin) — per the convention this change itself documents. |
|
||||
| swiftlint pragmas instead of splitting the harness file | One file / one contiguous zsh script is the documented harness contract (wire-line inspectability, shared-helper home); splitting to satisfy line counts is ceremony. |
|
||||
| Consciously NOT done: python-sniff dedupe in the fake, poll-budget unification (100 vs 250), `Task.sleep(for:)` style migration, client-seam cancel assertion in fire-and-forget | All match pre-existing file idiom or duplicate end-to-end coverage already pinned in PassRunTests; each is a drive-by refactor outside #124. The client-seam assert is parked: add only if that test ever regresses confusingly. |
|
||||
|
||||
## Gotchas & Fixes
|
||||
|
||||
| Problem | Root Cause | Fix |
|
||||
|---------|------------|-----|
|
||||
| `git diff` output mangled (per-hunk `@@` with prefixed markers, no `+++` lines) | Repo git routes diff through a custom wrapper; `-c diff.external=` does not bypass it | `git show HEAD:<file>` + plain `diff -u --label a/... --label b/...` into a scratch file; handed that file to review children |
|
||||
| `write_file` with a relative path landed in the terminal's scratch cwd | Terminal cwd persists across calls; relative paths resolve against it | Rewrote with the absolute repo path; deleted the stray scratch copy |
|
||||
| swiftlint `orphaned_doc_comment` after adding pragmas | A `//` line (even a `swiftlint:disable:next` directive) between a `///` block and its declaration orphans the doc comment | Wrapped instead: `// swiftlint:disable function_body_length` before the doc block, `// swiftlint:enable` after the closing brace — doc stays adjacent to the func |
|
||||
| `gitnexus detect-changes` CLI errored ("Multiple repositories indexed") | The local backend needs the repo label | `--repo museion` |
|
||||
|
||||
## Files Changed
|
||||
|
||||
| File | Change Summary |
|
||||
|------|----------------|
|
||||
| `MuseionTests/ACPClientTests.swift` | hangOnPrompt cancel-acknowledging hold; defer teardown ×17 rigs; doc comments + mode list; 2 swiftlint pragmas; 6 trailing teardowns removed |
|
||||
| `MuseionTests/PassRunTests.swift` | New Cancel-rail pin test; defer teardown ×10 rigs; 4 trailing teardowns removed; stale comments updated |
|
||||
| `MuseionTests/AGENTS.md` | Both bullets rewritten: fake contract, defer convention, pin; `noStopReason` added to mode list |
|
||||
| `AGENTS.md` | GitNexus index-counter refresh (3889/12468) — tool-written, not hand-edited |
|
||||
|
||||
## Open Items & Next Steps
|
||||
|
||||
- [ ] Deferred: client-seam cancelled-resolution assertion in `cancel is
|
||||
fire-and-forget` (covered end-to-end by the PassRunTests pin; add only if
|
||||
that test regresses confusingly)
|
||||
- [ ] None — issue #124 acceptance criteria all met; suite green; audit clean
|
||||
|
||||
---
|
||||
|
||||
*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-10-20 | issue | [20261020-issue124-cancel-ack-fake-deferred-teardown_log.md](20261020-issue124-cancel-ack-fake-deferred-teardown_log.md) | #124 cancel-acknowledging hangOnPrompt fake, Cancel-rail pin (RED→GREEN), defer-at-rig-creation teardown ×27 rigs — 316 tests green |
|
||||
| 2026-10-20 | issue | [20261020-issue25-apply-skip-fix-cards-trust-ui_log.md](20261020-issue25-apply-skip-fix-cards-trust-ui_log.md) | #25 Apply/Skip Fix Cards: ranked ≤10 ceiling, adoptText apply rail, blocking ask, audit fanout with 11 fixes — 316 tests green |
|
||||
| 2026-10-20 | issue | [20261020-issue24-pass-guard-matrix_log.md](20261020-issue24-pass-guard-matrix_log.md) | #24 close-out: verified against landed #23, pinned the full runPass guard matrix + cancelPass, finish-audit fanout — 299 tests green |
|
||||
| 2026-10-20 | issue | [20261020-issue23-museion-tools-mcp-server-dogfood-hardening_log.md](20261020-issue23-museion-tools-mcp-server-dogfood-hardening_log.md) | #23 museion-tools MCP server + fix-card store, Fix Cards palette, dogfood fixes (prompt timeout, persona, debug filter), 3-reviewer audit round — 296 tests green |
|
||||
|
||||
Reference in new issue
Block a user