Repository navigation
test: synchronize Knowledge reuse readiness with CLI exit - #305
Conversation
Add failing regressions for #275 against the stream-json backend, with protocol shapes captured live from Claude Code 2.1.302: - Stop sends SIGTERM at once instead of the native interrupt, and drops every message after it, including the turn's final reply snapshot. - A process that never confirms its exit holds Stop forever. - control_cancel_request is ignored, so a cancelled approval card stays actionable, holds a drained turn open, and a late answer is written. - An answer after the turn settled writes to the ended stdin and raises an uncaught ERR_STREAM_WRITE_AFTER_END. - keep_alive re-arms the idle window; the final unterminated line, split-UTF-8 stderr, and stderr or exit codes after a failed result are lost; a killed process reports "exited with code null". - Failure details copy MCP route tokens from argv. The fake process now models exit versus close, signals it ignores, held stdio and raw chunks, and answers interrupts the way the live CLI did. The interfaces the tests use are declared without behaviour: TurnSink.approval's withdrawal signal, TurnResult.stop, the approval item's withdrawn reason, and the timing and liveness knobs. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
Stop now writes Claude Code's own interrupt control request and ends stdin, as the 2.1.302 CLI needs to stop a running tool. Every message the CLI still prints is read: the final reply snapshot, the rejected tool result and the closing result, which after Stop is no failure. The turn ends when the process exits. One that has not exited 1.5 s after Stop gets SIGTERM, then SIGKILL 1.5 s later. If no exit follows within 2 s, the stop is reported unconfirmed instead of waiting forever. The result says which of these happened (exited, terminated, killed or unconfirmed), with exit code, signal and pid. control_cancel_request withdraws the matching can_use_tool. The sink is told through an abort signal, the request stops holding the turn open, and no answer is sent: the CLI ignores one for a request it cancelled. Writes go only to an open stdin of an unfinished turn, and EPIPE is absorbed. This removes the uncaught ERR_STREAM_WRITE_AFTER_END raised by a late approval. The turn now settles on exit plus a bounded drain, not only on close, so a descendant holding the pipes cannot keep it open: - stderr is decoded across chunks, and the last stdout line is read even without its newline. - A failed result waits up to 1 s for the stderr and exit code that follow it. - A signal death says so. - keep_alive no longer re-arms the idle window. Failure details redact MCP route tokens from argv. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The runner closes a card when its backend withdraws the request. It is patched once to answer "no" with a withdrawn reason (native, stopped or ended), so older windows and the phone show it closed. Its promise settles "no", the thread stops waiting, and a late answer finds nothing pending. A request withdrawn while the approval gate is still deciding shows no card at all, and Jev is cancelled with it. Stop and the end of a turn label their leftover cards the same way instead of "Denied". A stopped turn's notice now says how it ended: "Stopped.", or that Modex had to terminate or kill the CLI, or, as a warning, that the process never confirmed its exit. Until such a process is gone, deleting or retiring the thread is refused with its pid. The worktree, thread and attachments it may still use stay. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
Independent review of the lifecycle change found three low-severity
faults, each now covered by a regression:
- Stop pressed while a failed result was draining reported a clean stop
("exited" with no exit seen), dropped the failure card and cancelled
the SIGTERM/SIGKILL escalation. The failure now stands, and Stop's
escalation outlives the turn's settlement.
- A success result inside the failure's drain window completed the
turn. Once a turn has failed, later results are ignored.
- A launch that throws synchronously still put the raw argv, MCP route
tokens included, into the failure details.
Refs #275
Coven-Harness: Claude Code / claude-opus-5-5
The scripted Claude in titles.spec only recorded a cancelled naming run on SIGTERM. Stop now interrupts Claude natively and ends its input, and the fixture exited cleanly on that before any SIGTERM was due, so "a manual rename cancels pending naming" waited for a marker that never came. The run was cancelled all the same. The fixture now acknowledges the interrupt and closes the turn as Claude Code 2.1.302 does, and records the cancellation there, as its Codex branch already does for turn/interrupt. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The receipt holds: - the Claude Code versions and the live 2.1.302 captures, with the probe script; - each fault on main with its change, and the timing budgets; - the red-then-green record and the full check results at 62ac15c and d11cdb6; - the independent review; - the acceptance-criteria map; - what is still unproven: a live-model Stop through the app, Windows and Linux escalation, and the Companion's label for withdrawn cards. Status moves #250's lifecycle item from Next to In flight. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
CF-1 replaced TurnSink's delta, assistant, tool and thinking calls with observe(observation) and scopes every sink to its attempt. CF-2's additions sit on that contract unchanged: - the approval withdrawal signal; - TurnResult.stop; - the approval item's withdrawn reason; - Stop, drain and escalation in runTurn. ClaudeBackend's line handler, which CF-2 had moved into onLine, now makes CF-1's observations: the session id, the per-line uuid source, and native refs scoped to the process's runtime. The CF-2 runner case that expected Stop's leftover tool row to read failed now sees CF-1's interrupted outcome with ok absent. The next commit settles that row from the CLI's own rejection. Refs #275, #274 Coven-Harness: Claude Code / claude-opus-5-5
After the interrupt, Claude Code closes each tool call it stopped with
an error tool_result ("The user doesn't want to proceed with this tool
use."). CF-1 mapped every error result Modex had not refused to failed,
so a stopped Bash call read as a failure. An error result that arrives
after Stop is now interrupted. The Claude mapping in
docs/conversation-events.md says so.
The scripted CLI now sends that rejection for the calls it was stopped
in, as the live 2.1.302 capture does.
Refs #275
Coven-Harness: Claude Code / claude-opus-5-5
The receipt names 172b13f as the tested code and records its full checks: frozen install, build, typecheck, unit tests, and desktop and site E2E. It also covers how CF-2 sits on CF-1's contract and the post-Stop tool outcome. Status notes that a stopped tool call reads Stopped. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
This brings the branch up to date with main for review. The merge is clean: CF-2's withdrawn-card label in ThreadView's ApprovalItem sits beside CF-4's typed turn layout, unchanged. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
e2e/claude-live-stop.spec.ts drives the built app with the real `claude -p` and a real model. It runs only with MODEX_CLAUDE_LIVE=1, because each run spends about five turns of the signed-in account's usage. It covers four Stops: - with a permission card waiting; - while an approved 30 s command runs; - with the same thread resumed afterwards; - while a reply streams. Against 52b159a, with Claude Code 2.1.302 and Haiku, all four passed. Each ended without a failure card: - Card: idle in 0.86 s. - Running command: SIGTERM after the 1.5 s grace, idle in 2.33 s, the row interrupted, and its file never written. - Resume: replied "resumed". - Stream: idle in 0.86 s, with 670 characters kept. The receipt adds these results and the full checks at 52b159a, including two E2E setup failures from a full disk and their passing rerun. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
) The only conflict was docs/status.md. main had moved CF-1 and CF-4 from In flight to On main, unreleased, so the slot keeps just CF-2's entry. CF-6's runner change, which settles items on load and emits the change, merges beside CF-2's stop and withdrawal code. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
Preserve the original failure while waiting for bounded Stop confirmation, and retain unconfirmed process ownership regardless of turn outcome. Cover the backend result and refusal to delete its live worktree. Coven-Harness: Codex / gpt-6
Haiku can finish a 400-word story before Stop lands. The live run then honestly records a completed turn, but that is no test of a mid-stream Stop. The streaming step now asks for 2,000 words, and every step must end with a "Stopped." notice. Against a6ea0b0 all four steps passed: - card: 0.93 s; - running command: SIGTERM, 2.36 s, interrupted; - resume: "resumed"; - stream: 1.37 s, 834 characters kept. The receipt records the full checks at a6ea0b0, which is up to date with main at fb76aac: - frozen install, build, typecheck and unit tests; - desktop E2E 322 passed and 4 skipped, with one sidebar popover failure that passes on rerun and in CI; - site 7/7; - CI green on all 12 check runs. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The merge is clean. CF-5 adds the Bash command to Claude's tool.start and bounds tool output in the runner, beside CF-2's stop, drain and withdrawal code. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The tested code is 7c9d62c, up to date with main at d3711c6 (CF-5, first part). At that SHA: - CI: all 12 check runs green. - Local: frozen install, build, typecheck and unit tests pass. - Local desktop E2E: 322 passed and 4 skipped, with 5 timeouts under load in specs that never start Claude. All 26 cases in those specs pass when rerun alone. - Site: 7/7. - Live acceptance: Claude Code 2.1.302 with Haiku passed every step, each with a Stopped. notice. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The only conflict was claude.ts's import of conversation-event types. It keeps CF-2's ApprovalAnswer and adds CF-7's PlanStepStatus. CF-7's TodoWrite plan observation sits in handle(), apart from CF-2's lifecycle code. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
13faaeb is up to date with main at f6976df (CF-7, first part). - Targeted: 228/228 unit tests and 28/28 Electron cases pass. - Live: Claude Code 2.1.302 with Haiku again stops at every step with a Stopped. notice. - Full check: PR CI runs it at the head. The last full local run stays recorded at 7c9d62c. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
Integrate the CF-2 owner branch and landed CF-5/CF-7 interfaces while retaining the failure-before-Stop ownership repair. Resolve the overlapping type imports and preserve both sets of evidence. Build, typecheck, the full unit rerun, live Claude acceptance and site E2E passed. Record the desktop Store-browser failure and two unsuccessful isolated attempts; fresh integration CI remains required. Coven-Harness: Codex / gpt-6
Merge the owner's updated CF-7 integration receipts. The resulting application and test source is identical to the integrated tree already built, typechecked and exercised; only evidence documents change. Coven-Harness: Codex / gpt-6
This takes in the stacked repair from #291, as Val asked. Before it, a failed result that arrived just before Stop could settle the turn at the failure-drain deadline while the process still lived. The runner kept unconfirmed pids only for interrupted results, so the thread and worktree could then be deleted. Now: - the turn waits for exit, or for the bounded unconfirmed deadline; - it keeps both the failure and the stop report; - the runner records an unconfirmed pid whatever the outcome. The merge is clean. #291's commits are signed and keep their authorship. Refs #275, #291 Coven-Harness: Claude Code / claude-opus-5-5
Wait for the injected evidence turn and its disclosure button before expanding it. Give each case a fresh app and open its own command row, so the preview test passes alone and after worker restarts. Integrate main d3dfe76 with CF-2 head 61cc65d. Application source is unchanged from that head. Preserve parent CI failures and record the isolated red/green, 24 repeated E2E passes and full unit verification. Refs #275, #286 Coven-Harness: Codex / gpt-6
61cc65d is up to date with main at 04b7ec7, with #291 merged. - Local: install, build, typecheck, unit tests and E2E all pass with no reruns (desktop 329 passed, 4 opt-in skips; site 7/7). - Live: Claude Code 2.1.302 with Haiku passes every Stop step. - CI attempt 1: 10 checks passed, but unit + e2e failed 3 cases in CF-5's conversation-evidence spec, a folding race in its setup reported on #278. The re-run passed, so CI is green at 61cc65d. Status now names #291 as merged into #286. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The merge is clean. CF-8's conversation-fidelity spec drives Stop through the claude -p adapter, and now runs against CF-2's interrupt-then-grace Stop. Refs #275 Coven-Harness: Claude Code / claude-opus-5-5
The only conflict was the In flight entry for native conversation fidelity in docs/status.md. It takes main's wording, which Val chose on #290: the tracker's child issues link their open PRs, so the entry no longer lists them. Everything else merged as is. Coven-Harness: Claude Code / claude-opus-5-5
Force the bare-URL rejection fixture to exercise readiness before CLI exit, then wait for actual termination before returning its external-server response. Move CF-2 into the landed status section and record the failure and verification. Coven-Harness: Codex / gpt-6
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Docs steward note (#290) about #286's squash left its own CF-2 entry under In flight: on A trial Next is already right on |
Code coverage overviewLanguages: TypeScript TypeScript / code-coverage-agent
View coverage of the 9 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
|
Landed: #286 is on Verification on the repair:
The optional iPhone run was still in progress at merge and is not claimed green. This repair changes only the Knowledge test fixture and docs; its application code is identical to #286's head CF-2 is landed. The next executable goal is CF-3 reconciliation in #293, starting with the separately reproduced acceptance/delivery race. No CF-3 production changes or merge were made here. |
The Knowledge rejection test could accept an external server's bare URL while its CLI was still alive, producing
Missing expected rejectionin job 117755082206. That timing takes the supported owned-server path, so the fixture must establish that its CLI has exited before returning readiness.The fixture now observes process termination and forces the bare-URL case to remain alive until readiness is requested. Each rejected variant is a named subtest. Production code, assertions and startup timeouts are unchanged. The CF-2 status entry also moves under On main, unreleased, with evidence limits retained.
Follow-up to #286, which another session merged at
6db0818while this repair was in CI. GitHub retargeted this PR tomain; its squash was reconciled without changing tested code. The owning worktree is untouched.Validation:
{"banner":false}.pnpm build,pnpm typecheck,pnpm test: passed; 1,726 passed, 16 existing skips overall.0371201: pending-card Stop 860 ms, running command Stop 2,359 ms with no file written, same-thread resume, streaming Stop 1,043 ms with 374 characters retained; zero failures. Receipt committed.