docs: brief-27 session log, INDEX row, changelog entry
CI / ci (pull_request) Canceled after 0s
CI / ci (push) Canceled after 0s

Docs-only (code identical to the fix commit 89cd377, where the
697/697 suite ran): devlog carries the site-class enumeration with
disproofs, the decisions table, and the gates; CHANGELOG gains the
user-facing acp backpressure entry.
This commit is contained in:
AlexKucera committed 2026-11-17 22:36:56 +01:00
1 parent 89cd377814
commit ae3b99c7ea
3 files changed
+56

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Fixed
- **acp:** Engine backpressure can no longer defeat request deadlines, Stop, or teardown (finding `museion/acp-backpressure-defeats-timeout-and-shutdown`, argus cycle-4) — a hung engine that stops reading stdin fills the 64 KB pipe, and the ACP client's synchronous send blocked its ONE serial queue, the same queue carrying request-id allocation, pending registration, the timeout deadline, and close()'s bookkeeping barrier: the deadline never fired (a 0.1 s timeout on a 2 MB prompt stayed pending forever), a follow-up request hung at registration, Stop queued behind the stuck write, and close() synced behind it before SIGTERM was ever reachable — on MainActor (restart/quit) that was an app-wide unbounded hang. Stdin writes (and the stdin handle's own close, which a blocked write may still own) now ride a dedicated serial writer queue, leaving the state queue I/O-free: deadlines fire, Stop is accepted, bookkeeping answers, and close() runs SIGTERM → grace → SIGKILL → reap without queueing behind the writer. Wire order preserved (every send funnels through the one serial writer); healthy-engine contract untouched. +4 real-process smokes over two new zsh-fake modes (`neverRead` execs /bin/sleep — the probe's inert non-reading child, never a real profile; `serverPing` pins -32601 reply delivery): 3 RED-first at base on exactly the three mechanisms, healthy-contract pin green at base. Suite 697 (unticketed fix, brief-27)
- **search:** Library search results no longer go stale after library writes (finding `museion/library-search-stale-after-mutation`, the #144/#157 mounted gap) — the search snapshot's only task identity was the trimmed query, so nothing re-ran the sweep when the library moved underneath it: archiving or trashing a piece from a result row's own context menu left it sitting in the non-archived results after the rescan, and new, renamed, or externally edited pieces never entered or left the results until the query changed or the pane remounted. The #179 write rail's rescan now bumps a content revision whenever a scan sees the library change — a Post-list change OR any re-read post.md, so a body-only edit (which parses to an equal Post and is invisible to #143's equality-gated assignment) counts — and the mounted sweep keys on query + Home + that revision, rendering a landed snapshot only while it stays fresh for the current key (stale rows drop to the recompute spinner; panes never regroup — the assignment skip is untouched). +5 tests (pure key/gate pin; controller-level archive, trash, and same-query body-edit pins over the real rescan rail, red-first; an unchanged-rescan guard). Suite 686
- **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)
@@ -0,0 +1,53 @@
# ACP backpressure — a blocked stdin writer can no longer defeat deadlines, Stop, or close
> **Date:** 2026-11-17
> **Type:** fix (availability — APP-DOWN class)
> **Reference:** brief-27 `museion/acp-backpressure-defeats-timeout-and-shutdown` (unticketed; argus cycle-4 dedicated bugs pass, finding 3 — `~/argus-audits/audit/2026-11-16/museion-bugs.md`). Base `bb4bfa2675c3fd2776bd0235c01010baec2290df` (museion main tip at claim, re-verified via tea api + fetch). Scan SHA `11b196d6` — both touched source files byte-identical between scan SHA and base.
## Finding
A hung engine that stops reading stdin fills the 64 KB pipe, and `ACPEngineClient.send`'s synchronous `fileHandleForWriting.write` blocked the client's ONE serial queue — the same queue that carries request-id allocation, pending-registration, the `asyncAfter` deadline, and `close()`'s opening `queue.sync` barrier. A blocked writer therefore defeated the request timeout (the deadline sat queued behind the stuck send), starved Stop/lifecycle calls (a follow-up request hung at id-allocation `queue.sync`), and made `close()` block behind the write before SIGTERM/SIGKILL was ever reachable. `EngineHost`'s close callers (`killChat`, `withOneShot` defer, `shutdownAll`) run on MainActor — engine backpressure became an app-wide unbounded hang on restart/quit. Argus executed the repro standalone: complete HEAD `ACPEngineClient.swift` in an isolated process, child argv swapped to `/bin/sleep 30` (inert non-reading child), 2M-char request at timeout 0.1 s — no request completion, and an independent watchdog's `close()` never returned (probe killed at 12 s).
## What Was Done
- **Fix** (`Museion/ACPEngineClient.swift`, +34/−8): stdin writes — and the stdin write-handle's own close — moved off the state queue onto a dedicated serial `writerQueue`. `request`/`notify`/`dispatch`'s server-reply all funnel through it (wire order preserved: one serial FIFO queue, same enqueue-order semantics as before). The state queue is now I/O-free: id allocation, registration, deadlines, and `close()`'s bookkeeping barrier always run; `close()` then does SIGTERM → 1 s grace → SIGKILL → reap without ever queueing behind the writer. The stdin write-handle close rides the writer queue (a blocked write may still own the handle — closing under a live write would race Foundation); it unblocks with EPIPE once the child's read end died, which the kill just arranged. Reader handles close on the caller as before (handlers off first, no writers exist for them).
- **Rig** (`MuseionTests/ACPClientTests.swift`): two new zsh-fake modes. `neverRead` — execs `/bin/sleep 30` without reading a line (the probe's inert non-reading child; exec keeps sleep the DIRECT child so close's SIGTERM reaches it and no orphan holds the pipe); `serverPing` — full behaviour plus one server→client request (id 900) emitted at initialize, logging our reply line to `<name>-reply-log` (the reply-delivery observable).
- **Smokes** (`MuseionTests/EngineSmokeTests.swift`, +4): (1) request deadline fires while the stdin write is blocked (0.5 s deadline, 2M-char prompt, 5 s bounded window); (2) Stop accepted + bookkeeping answers while blocked (`session/cancel` notify returns, a follow-up request registers and reaches its OWN deadline); (3) close returns bounded while blocked (5 s window) and reaps the child; (4) healthy contract unchanged — round trip (initialize → 9.9.9), -32601 reply delivery over the real wire, idempotent clean close with reap. `awaitBounded` helper = the bounded window (house one-deadline rule); teardown in every blocked-writer smoke SIGKILLs the rig child FIRST so the base tree also settles without hanging the runner.
## Site-class enumeration (mandate — re-derived, seed not ceiling)
Included (fixed): all four `send` call sites (request L177-ish, notify L197-ish, dispatch server-reply L317-ish — the seeded set) plus the deadline scheduling and both `request`-path `queue.sync`s and `close()`'s barrier — all healed by the same writer-queue separation; the direct server-request reply path rides the same `send` (no second site to mint, as the brief noted).
Disproved with evidence:
- `EngineGate.execute` pre-spawn stdin write (EngineGate.swift:99-110): not queue-bound, and the write lands BEFORE `process.run()` — the reader does not exist yet, so it cannot block behind a hung engine; the in-source ceiling note (keep payloads well under 64 KB) plus the watchdog own it.
- `EngineGate.terminateAndReap` (EngineGate.swift:145-155): SIGTERM → grace → SIGKILL → reap with NO preceding queue.sync — nothing can block before it.
- `ReadingPresenter` apex render (ReadingPresenter.swift:137-154): a one-shot synchronous render helper (write → closeFile → waitUntilExit is the operation itself); no transport/lifecycle queue, no deadline machinery being defeated — adjacent, out of class.
- `MCPServer` fflush(stdout) (MCPServer.swift:39): the app IS the child there; no engine pipe parenting — out of class.
- `ScriptedEngine` (MuseionTests): mirrors the client's queue shape exactly, but performs zero FileHandle I/O (in-process) — its `queue.sync`s can never block on a pipe.
- `EngineHost` seeded sites (killChat 175-178, withOneShot defer 204-207, shutdownAll 223-227): synchronous close callers; post-fix they call a bounded close (bookkeeping sync on an I/O-free queue; ≤1 s SIGTERM-grace worst case + reap). No EngineHost change required — see Decisions.
## Gates
- Focused serialized `EngineSmokeTests` at base (RED commit `33b7fe0`): **6 executed / 3 passed / 3 failed** — exactly the three blocked-writer smokes failed, on mechanism (deadline expectation nil after 5 s; bookkeeping expectation nil; `finished != nil` false). Healthy-contract smoke + both existing surface smokes passed at base.
- Focused serialized `EngineSmokeTests` at fix (`89cd377`): **6 executed / 6 passed / 0 failed** (exit 0). Per-test: deadline 0.539 s, stop/bookkeeping 0.733 s, close bounded 0.232 s, healthy 0.195 s.
- Full suite at fix head via the rail (run dir `20261117T212755Z-Museion-serialized`): **697 executed / 697 passed / 0 failed / 0 skipped, xcodebuild exit 0** (xcresult-authoritative; the four new smokes' started/passed lines verified in the run log).
- swiftformat `0/149 files formatted`; swiftlint zero violations (repo gate is zero, not net-zero — base was clean).
- GitNexus: `analyze --skip-agents-md` in the worktree (AGENTS.md untouched); impact on every edited symbol — `send` LOW (5), `dispatch` LOW (3), `notify` LOW (0), `close` LOW (0), `request` UNKNOWN/0 (callers ride the EngineTransport existential; graph doesn't connect protocol witnesses) — no HIGH/CRITICAL, no user warning owed; detect-changes at the fix: 1 file / 8 symbols / 1 affected process (the transport), medium, expected.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Dedicated serial writer queue, blocking writes kept | Boring over clever: nonblocking fd + DispatchSourceWrite drain would add partial-write buffering and source lifecycle for zero additional contract (the API-level guarantees all hold once the state queue is I/O-free). A blocked writer now wedges only itself — it cannot pin a deadline, Stop, or close. |
| stdin write-handle closes ON the writer queue | After kill+reap a blocked write may still be in `write(2)` (unblocks on read-end death); Foundation FileHandle is not safe under concurrent write+close. The close job queues behind the last write — close() itself has already returned. Residual: a pathologic grandchild holding the pipe's read end past the child's death pins one writer-queue worker until it exits; the client is closed and reaped regardless. |
| `exec /bin/sleep` in neverRead (not `sleep 30` as a zsh child) | exec makes sleep the direct child: close's SIGTERM reaches it, and no orphan holds the pipe open — the smoke's teardown leaves nothing behind on either tree. |
| Case (2) pinned as accepted+unstarved, not bytes-delivered | The bytes cannot reach a non-reading child — the pipe is full; that is physics, identical before and after. "Deliverable" means the seam accepts the notification and lifecycle bookkeeping still answers; the RED leg (follow-up request registration starving at `queue.sync`) is the un-fixed behavior. |
| EngineHost left untouched; close stays synchronous but bounded | The fix direction's "no MainActor-blocking close path remains" read against the finding (backpressure → unbounded hang): the writer can no longer defeat close, and close is bounded (ms when the child honors SIGTERM; ≤ ~1 s grace + reap worst case). Making killChat/shutdownAll hop off MainActor would drop the reaped-before-return guarantee the teardown smokes pin (and the quit path relies on) — an EngineHost API change out of this finding's scope, disclosed to the dispatcher instead. |
| Zsh fake modes, never a real profile | Brief's probe discipline: the only child ever spawned by the dead-child tests is our own zsh fake execing /bin/sleep (pre-validated standalone: ps shows `/bin/sleep`, a 2 MB stdin write blocks, serverPing round-trips the -32601 reply). |
## Disclosures
- First focused RED run died at COMPILE (my `Task<String?, Never>` made `awaitBounded`'s `T?` a double optional — two `error:` lines, zero tests executed, the rail's vacuous guard caught it as 0-executed/exit 65). Fixed to `Task<String, Never>`; the recorded RED run is the second, clean one.
- No testmanagerd wedge encountered this brief (the known hazard did not fire; runs sequenced behind @athena's classis brief-26 verify, which finished 22:21:15 exit 0 before my first xcodebuild).
- AGENTS.md DOX updates (Museion/AGENTS.md ACP-bridge bullets, MuseionTests/AGENTS.md suite-map lines) are consent-gated → owner-apply patch beside the handoff, `git apply --check` clean vs branch head; the root AGENTS.md session-log 10-row window is left for the write-log tooling (INDEX.md carries the durable row).
- Docs commit (CHANGELOG + devlog + INDEX) is docs-only; the 697/697 suite ran at its parent (the fix commit) — code identical.
+1
View File
@@ -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-17 | fix | [20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md](20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md) | Unticketed fix (brief-27, argus cycle-4): stdin writes move to a dedicated writer queue — engine backpressure can no longer defeat the request deadline, Stop, or a bounded reaping close; neverRead/serverPing fake modes, 3 RED-first smokes + healthy-contract pin, suite 697/697 |
| 2026-11-17 | issue | [20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md](20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md) | Three most-re-read files split into 8 domain-extension files, move-only (three audits concur); 693/693 |
| 2026-11-17 | issue | [20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md](20261117-issue192-collapse-gate-running-learnings-into-verify-rail-pointer_log.md) | Root gate-running learnings collapse into the full-test.sh pointer; 8 deletions mapped to script/hook behavior; authoring rules retained; 693/693 |
| 2026-11-17 | issue | [20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md](20261117-issue197-repo-wide-swiftlint-green-documented-lint-contract_log.md) | Lint-green doc truth (#197) + finish-audit; watcher-race test quiesced, symlink pin flip-verified, stale-xcodebuild hazard found; 693/693 |