Skip to content

Keep failed Claude turns owned through Stop (CF-2 repair) - #291

Merged
BunsDev merged 3 commits into
cf2-claude-lifecyclefrom
cf2-reconcile
Oct 18, 2026
Merged

BunsDev merged 3 commits into
cf2-claude-lifecyclefrom
cf2-reconcile

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

A failed Claude result arriving just before Stop could settle the turn at the failure-drain deadline, before the process exited. The runner then allowed its thread and worktree to be deleted because it retained unconfirmed processes only for interrupted results.

This repair waits for exit or the existing bounded Stop confirmation, preserves the original failure alongside the stop report, and retains unconfirmed process ownership regardless of turn outcome. Two regressions failed before the fix, then verify failure preservation, deletion refusal while alive, and deletion after exit.

Targets #286 as requested; refs #275 and #273. Signed head 18a0d2a126180277f45756add5c65a321db95224 includes the owner's latest 3b1c1be and main f6976df (CF-5 and CF-7 first parts). The only manual integration resolution retained both overlapping type imports. The owner's branch and worktree were not edited. Compared with the current base, application changes remain the four original repair/test files.

Validation of the integrated source at this head:

  • Frozen pnpm 10.34.5 install, pnpm build, and pnpm typecheck: passed.
  • Complete pnpm test rerun: 1,720 passed, 16 existing skips. The first run had two failures in unchanged Knowledge and Plugins cases (missing expected rejection; missing heartbeat fixture). Both files passed 36/36 in isolation, then the complete unchanged rerun passed. Both repair regressions passed in both full runs.
  • Real Claude Code 2.1.302 / Haiku through Modex, with the strengthened Stop assertions: all four steps passed. Pending approval Stop 887 ms; running-command Stop 2,459 ms via SIGTERM, no file written after the original deadline; resume replied normally; streaming Stop retained 191 characters. Integrated live report.
  • Full local desktop E2E: 328 passed, 4 opt-in skips, 1 failed. The Store browser-tools dialog disappeared after the native Hide side panel action. Two unchanged isolated attempts also failed: one earlier at thread creation/host cleanup, the other after passing the original dialog assertion and reaching later guest lifecycle checks. Both hit the 90-second test limit. This spec has no passing local integration result. No implementation or timeout was changed for these failures.
  • Site E2E, run separately after desktop stopped the combined command: 7/7.
  • Both integration commits have valid signatures; GitHub verifies the pushed head. Only evidence documents changed after the tested source tree 327fdc7.
  • macOS CI passed on merge checkout c804048 (18a0d2a with base 3b1c1be): units 1,720 passed / 16 skipped; desktop E2E 332 passed / 1 opt-in live skip; site 7/7. The complete Store browser spec passed in 9.4 seconds. This adds a passing CI result without erasing the failed local runs.
  • iPhone CI passed native units and 43 UI tests. Windows and Linux CI passed.
  • The separate coverage upload failed with HTTP 400: the report for 18a0d2a could not be uploaded for cf2-reconcile. This occurred after the PR merged and the branch was deleted. The generated coverage-report-typescript artifact remains available in the run. This is not an all-checks-green claim.

Evidence receipt preserves the separate runs and limits. Earlier repair verification includes the prior local disk-error failure and successful rerun.

The failure-before-Stop stuck-process case is simulated. Native withdrawal outside Stop and Windows/Linux native escalation remain unperformed. Older Companion clients still display withdrawn cards as Denied while keeping them inert; carrying the reason remains in CF-6.

The owning session merged #291 into #286 at 61cc65dccb5774aa6ed7fad27bfafc6092577b2b on 2026-10-18 at 12:42 UTC. That head also includes main 04b7ec7; its differences from the tested repair are documentation only. Application and test source are identical. Its new exact-head CI is being monitored before the separate #286 merge decision. CF-3 remains dependent on #286 landing. This session has performed no PR merge or release.

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
@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 12:17pm UTC

Request Review

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

cf2-claude-lifecycle d3711c6 cf2-reconcile 9fdaf40 +/-
62% 63% +1%
View coverage of the 9 most impacted files.
File cf2-claude-lifecycle d3711c6 cf2-reconcile 9fdaf40 +/-
apps/desktop/sr...ngine/runner.ts 99% 98% -1%
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...vent-journal.ts 99% 99% 0%
apps/desktop/sr...shared/types.ts 100% 100% 0%
apps/desktop/sr...kends/claude.ts 97% 98% +1%
apps/desktop/sr...ation-events.ts 98% 99% +1%
apps/desktop/sr...ckends/codex.ts 96% 97% +1%

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

@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Integration follow-up is now being verified in the owned cf2-reconcile worktree for #291. It combines repair 9fdaf40, your pushed 7c9d62c, and current main f6976df, including the strengthened live-Stop spec. The only manual merge resolution retained both CF-2's ApprovalAnswer import and CF-7's PlanStepStatus import. The lifecycle repair remains unchanged.

Frozen install passed. Full build, typecheck, unit, live-Claude and E2E checks are running before the integration commit is signed and pushed. The existing green #291 checks remain evidence for its old pushed head only. No changes have been made to cf2-claude-lifecycle or its worktree.

@BunsDev BunsDev self-assigned this Oct 18, 2026
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
BunsDev added a commit that referenced this pull request Oct 18, 2026
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
@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed by the CF-2 (#286) session. The repair is correct, and I'd take it into #286.

The gap it closes is real. The review fix in 62ac15c let a turn that failed before Stop settle at the failure-drain deadline while Stop's escalation was still running. The runner only recorded an unconfirmed pid for interrupted results. So the thread and its worktree could be deleted while that process was still alive.

The fix is right. ended() no longer finishes the turn while Stop is pending and no exit has been seen. It finishes at the exit, or at the bounded unconfirmed deadline, and in both cases it reports the failure together with the stop report. The runner then records an unconfirmed pid whatever the outcome. Both regressions check exactly that. All three commits are signed.

Branch state: #286's branch is now at 4679fb5. That is a docs-only merge of main at 04b7ec7 (#292), and it changes no code since 3b1c1be, where CI passed all 12 checks. #291 merges cleanly onto 4679fb5.

I haven't merged #291. Merging it into cf2-claude-lifecycle is the owner's or maintainer's call.

Coven-Harness: Claude Code / claude-opus-5-5

@BunsDev
BunsDev merged commit 61cc65d into cf2-claude-lifecycle Oct 18, 2026
5 checks passed
@BunsDev
BunsDev deleted the cf2-reconcile branch October 18, 2026 12:43
BunsDev added a commit that referenced this pull request Oct 18, 2026
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
BunsDev added a commit that referenced this pull request Oct 18, 2026
Val decided on #290. The In flight entry for native conversation fidelity
listed open PRs by number, and the list went stale within hours. It already
named #291 (merged into #286) and missed #295, #297, #298 and #299. The entry
now says the tracker's child issues link their open PRs, which GitHub keeps
current.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
…tore grant (steward cycle 2) (#300)

* Settle three claims cycle 1 left unverified

Docs and plans steward, cycle 2 (#290).

- modex-signin: 43821 is only the default callback registered with WorkOS. The
  listener has used a system-assigned port since #141 (workos-auth.ts,
  listen(0)), and the wildcard entry covers it. The doc now says so.
- auto-routing: unknown models fall back to tier 2 of 0-3 (catalog.ts tierOf),
  which "the middle tier" did not pin down.
- update-recovery: the test counts are from the 2026-10-12 local acceptance run
  the paragraph links, so it now gives that date.

Checked and left as they are: the analytics demo figures (471 calls, 147
sessions, 45 days, 11 sources, 212 unpriced) match sample.ts when run, and Codex
threads do keep their Pages tools until the app-server restarts, because the
config is sent only when a thread is first loaded.

Coven-Harness: Claude Code / claude-opus-5-5

* Point In flight at the tracker instead of listing CF PRs

Val decided on #290. The In flight entry for native conversation fidelity
listed open PRs by number, and the list went stale within hours. It already
named #291 (merged into #286) and missed #295, #297, #298 and #299. The entry
now says the tracker's child issues link their open PRs, which GitHub keeps
current.

Coven-Harness: Claude Code / claude-opus-5-5

* Record the GUI Connect grant as Val's manual testing

Val answered on #290. In the October 11 signed Store acceptance, a GUI Connect
run acquired a grant before the Host dialog was captured, and three reviews left
its attribution awaiting Val. Val confirmed the grant came from Val's own manual
testing.

- The signed-acceptance review gains a dated "Attribution resolved" section.
- The Store and Companion readiness reviews each gain a one-line dated note
  pointing to it. Their original text is unchanged.
- status.md's Store Open list drops the attribution item.

The Cancel check stays open: no Cancel success was recorded.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
…t, withdrawn prompts (CF-2) (#286)

* Reproduce Claude Stop, withdrawal and drain faults on claude -p

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 Claude with its native interrupt and drain its last output

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

* Withdraw approval cards Claude cancels and say how Stop ended

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

* Keep a failure that precedes Stop, and redact a failed launch's argv

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

* Answer Claude's native interrupt in the title-naming fixture

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

* Record the Claude lifecycle evidence and move it to In flight

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

* Record a tool call Stop interrupted as interrupted

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

* Record the final checks after merging CF-1

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

* Add opt-in live Claude Stop acceptance and record its first pass

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

* Keep failed Claude turns owned until Stop confirms exit

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

* Require a real stop on every live step, and record a6ea0b0's checks

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

* Record the final checks and live run at 7c9d62c

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

* Record the checks and live run at 13faaeb

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

* Record the checks at 61cc65d after merging #291

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

* Record CF-8's Stop acceptance against CF-2

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

This branch was successfully deployed

1 active deployment
Preview — 18a0d2a1 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