Skip to content

test: synchronize Knowledge reuse readiness with CLI exit - #305

Merged
BunsDev merged 34 commits into
mainfrom
cf2-ci-repair
Oct 18, 2026
Merged

BunsDev merged 34 commits into
mainfrom
cf2-ci-repair

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

The Knowledge rejection test could accept an external server's bare URL while its CLI was still alive, producing Missing expected rejection in 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 6db0818 while this repair was in CI. GitHub retargeted this PR to main; its squash was reconciled without changing tested code. The owning worktree is untouched.

Validation:

  • Removing the fixture's termination gate reproduced the exact missing rejection for {"banner":false}.
  • Fixed Knowledge suite: 16 passed; also passed in the full parallel suite.
  • pnpm build, pnpm typecheck, pnpm test: passed; 1,726 passed, 16 existing skips overall.
  • Live Claude 2.1.302/Haiku through Modex passed on 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.
  • Signed commits verified locally. Required macOS E2E and companion CI on the final head remain the landing gate.
  • Windows/Linux live escalation and live native withdrawal outside Stop remain unproven, as recorded in the existing receipt.

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
Only docs/status.md conflicted. CF-2 stays in In flight, now naming
#286 and the stacked repair #291. The duplicate Next item for #250's
lifecycle fixes is dropped, and the remaining items are renumbered.
No code changes.

Refs #275

Coven-Harness: Claude Code / claude-opus-5-5
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
After merging main at d3dfe76, CF-8's conversation-fidelity spec passes
against CF-2's interrupt-then-grace Stop, alongside the claude-lifecycle
and titles specs: 13/13. Code is unchanged from 61cc65d apart from
CF-8's spec from main.

Refs #275

Coven-Harness: Claude Code / claude-opus-5-5
Reconcile owner head ee496e2 with the verified follow-up. Only documentation changes; application and test source match 5e691d3, whose macOS, iPhone, Windows/Linux and coverage checks passed.

Coven-Harness: Codex / gpt-6
Preserve main db0bbfd Store documentation and record full macOS, iPhone, Windows/Linux and coverage success at 5e691d3. Application and test source remain identical to that verified head.

Coven-Harness: Codex / gpt-6
The merge is clean. #298 had already brought the same
conversation-evidence spec into this branch. The only change is #297's
three-line wait in typed-turns.spec.ts.

Refs #275

Coven-Harness: Claude Code / claude-opus-5-5
The merge is clean. #301's runner change reads stored items once when
settling on load; it is separate from CF-2's stop, drain and
withdrawal code.

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
@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 18, 2026 7:31pm UTC

Request Review

Reconcile the squash of PR #286 without changing the tested fixture or runtime.
Record the passing live Claude Stop and resume run at 0371201.

Coven-Harness: Codex / gpt-6
@BunsDev

BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Docs steward note (#290) about docs/status.md. Adding CF-2 under "On main, unreleased" is the right move. One thing to finish when you update this branch from main:

#286's squash left its own CF-2 entry under In flight: on main at 6db0818, the Truthful Claude Stop on claude -p (CF-2, #275) block runs from line 179 to line 202 and ends "Open in #286". This branch was cut from a3c62e6, so it never had that block and doesn't delete it.

A trial git merge-tree origin/main of this head (0371201) keeps both, the new sub-bullet at line 85 and the stale In flight block at 187–210. Please delete the In flight block in the update so CF-2 is described once.

Next is already right on main (GitHub App 3, Cloud tasks 4). Your diff shows Next changes only because of the older merge base, so there's nothing more to do there.

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main a3c62e6 cf2-ci-repair c910083 +/-
63% 63% 0%
View coverage of the 9 most impacted files.
File main a3c62e6 cf2-ci-repair c910083 +/-
apps/desktop/sr...ngine/runner.ts 99% 99% 0%
apps/desktop/sr...ckends/codex.ts 97% 97% 0%
apps/desktop/sr...provals/gate.ts 100% 100% 0%
apps/desktop/sr...ovals/policy.ts 100% 100% 0%
apps/desktop/sr...ckends/types.ts 100% 100% 0%
apps/desktop/sr...sktop-client.ts 99% 99% 0%
apps/desktop/sr...ne/knowledge.ts 92% 92% 0%
apps/desktop/sr...shared/types.ts 100% 100% 0%
apps/desktop/sr...kends/claude.ts 97% 98% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@BunsDev
BunsDev merged commit 7ec5f14 into main Oct 18, 2026
13 checks passed
@BunsDev
BunsDev deleted the cf2-ci-repair branch October 18, 2026 20:10
@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Landed: #286 is on main as 6db081890bc0aea5d074e1e78ccd10f4df732944; its Knowledge CI repair #305 is now on main as verified signed squash 7ec5f1407e00a46954fd81a62d1ecb3ddadece6f. The repair's landed tree exactly matches tested head c9100834c0e5ffd0789223c6ca06c622bebe907b.

Verification on the repair:

  • pnpm build, pnpm typecheck, and the full local unit command passed.
  • Required macOS CI: 1,726 unit tests passed, 16 existing skips; Electron/browser E2E 338 passed, 1 opt-in live skip; site E2E 7 passed.
  • Windows/Linux installer checks, static analysis and coverage upload passed.
  • Fresh real Claude Code 2.1.302 / Haiku through Modex: pending-card Stop 860 ms; running-command Stop 2,359 ms, interrupted with no output file; same-thread resume returned resumed; streaming Stop 1,043 ms with 374 characters retained. Zero failures. The machine receipt is committed at docs/reviews/2026-10-18-claude-lifecycle/landing-live-app-run.json.

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 80d35df, where iPhone CI passed. Live Windows/Linux escalation and native withdrawal outside Stop remain the explicit evidence limits in the receipt.

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.

This branch was successfully deployed

1 active deployment
Preview — c9100834 Deployed Oct 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant