Skip to content

Answer each approval and question once, and show Codex questions as cards (CF-3) - #293

Merged
BunsDev merged 5 commits into
mainfrom
cf3-requests
Oct 18, 2026
Merged

BunsDev merged 5 commits into
mainfrom
cf3-requests

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Part of #276 (CF-3 of tracker #273).

Rebased onto main after #286 (CF-2) merged as 6db0818. Only the four CF-3 commits remain, now at 5db1b10 on main 7ec5f14 (after #305). Checks on this exact head and on CF-2's final head, with identical code:

  • Root pnpm build and desktop typecheck: passed.
  • Desktop pnpm test (on b09e3ef, same code): 1,561 passed, 16 skipped. Two timeouts at load average 155 (companion-network, knowledge) passed alone, 19 of 19. Second stage: 21 of 21.
  • @modex/store-desktop tests: passed.
  • e2e human-requests, approvals, claude-lifecycle, typed-turns, companion, conversation-evidence, store-desktop: 24 of 24.
  • On 173a17a: human-requests, human-requests-runner, companion, turn-layout and claude-lifecycle unit tests passed 60 of 60, and e2e human-requests + approvals passed 5 of 5. CI's unit + e2e (macOS) passed there too.
  • On 5db1b10, after test: synchronize Knowledge reuse readiness with CLI exit #305 changed the Knowledge test: build and typecheck passed, and those unit tests plus knowledge passed 76 of 76. The only conflict was docs/status.md, where CF-3's bullet now follows test: synchronize Knowledge reuse readiness with CLI exit #305's CF-2 bullet.

docs/status.md lists CF-3 under "On main, unreleased" and leaves the In flight entry as #300 worded it.

What changes

One answer per request. The runner keeps the turn's approvals and questions in the pure broker from shared/human-requests.ts. The first answer is accepted. Every other one gets an explicit reason: already-resolved, withdrawn, unknown or invalid.

  • thread:answer now returns that verdict, and the phone gets a 409.
  • Requests are bound to the Modex turn and attempt, the runtime generation, and the CLI's own request id: the Codex JSON-RPC id, or Claude's request_id and tool_use_id.

Codex questions. item/tool/requestUserInput (codex-cli 0.163.0, experimental) used to be declined with -32601. It is now a question card.

  • The card gives each question its own control: radio buttons for options, Other for free text, and a password field for a secret answer.
  • Answers go through thread:answer-question and are validated before anything reaches Codex. Codex receives { answers: { id: { answers } } }.
  • A malformed request is declined whole with -32602.

Secrets. A secret answer is written to the CLI's stdin only. Saved items, item events, the journal and the phone see (hidden).

Withdrawal.

  • Stop sends Codex an error (-32000), never an empty answer.
  • serverRequest/resolved for a request still open means Codex settled it itself. The card closes as withdrawn, and Modex sends nothing.
  • Cards a dead process left open close as ended when their thread loads, and the change is saved and emitted.

Clients.

  • While a question waits, the turn header reads "Waiting for your answer".
  • An open question never folds away.
  • Phones see a question as a notice to answer it on the Mac.
  • The store demo returns the new results.

Contract, mappings and limits: docs/human-requests.md.

Tests (red first)

  • test/human-requests.test.ts, for the broker: 6 of 6 pass.
  • test/human-requests-runner.test.ts, for the runner and the Codex backend: 6 of 6 pass. Each was watched failing first:
    • a second answer refused while the CLI hears one;
    • a late answer after Stop refused as withdrawn;
    • a question answered by schema, with junk and invalid answers refused and the secret absent from the store and events;
    • Stop sending an error reply;
    • serverRequest/resolved withdrawing with no reply. I wrote this handler before its test, so I disabled it to watch the test fail, then restored it;
    • restart settling.
  • test/companion.test.ts, new case: the question fallback text, no answers sent to the phone, and the runner's refusal as a 409.
  • test/turn-layout.test.ts, new case: an open question never folds.
  • e2e/human-requests.spec.ts runs a fixture codex-cli 0.163.0 app-server through the real app. It failed first with no card, then failed on the header label. The fixture also answers Modex's title-naming turn, which runs on the same app-server. It now covers:
    • the header;
    • an incomplete answer refused in place;
    • the password field;
    • one reply carrying the answers;
    • a refused second answer;
    • Stop giving an error reply;
    • no secret in any file under MODEX_HOME/app.

Checks run locally

macOS on Apple Silicon, Node v24.18.1, pnpm 10.34.5:

  • Root pnpm build (all apps, including store-desktop): passed.
  • pnpm --filter @modex/store-desktop test: 16 of 16 pass.
  • apps/desktop pnpm test: 1,554 passed and 16 skipped. One CF-2 test, claude-lifecycle "an unconfirmed stop keeps the worktree…", hit its 6 s timeout at a load average above 100. Rerun alone, its file passed 23 of 23, and the .mjs suites passed 21 of 21.
  • Playwright human-requests, approvals, approval-policy, claude-lifecycle, app, typed-turns, companion, space-fit, conversation-evidence, store-demo and store-desktop: 58 of 58 pass.

Not in this PR

  • Answering questions from the phone.
  • Request lifecycle in the event journal (CF-6's second half).
  • Plan clarification through a question card (CF-7's second half).
  • A live Codex requestUserInput capture. The question path is proven on the schema-shaped fixture only.

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

@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 9:57pm UTC

Request Review

@github-code-quality

github-code-quality Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main a4039b2 cf3-requests 467118c +/-
63% 63% 0%
View coverage of the 10 most impacted files.
File main a4039b2 cf3-requests 467118c +/-
apps/desktop/sr...ckends/codex.ts 97% 96% -1%
apps/desktop/sr...ngine/runner.ts 99% 98% -1%
apps/store-desk...rc/main/demo.ts 95% 95% 0%
apps/desktop/sr...ain/commands.ts 86% 86% 0%
apps/desktop/sr...ne/companion.ts 97% 97% 0%
apps/desktop/sr...kends/claude.ts 98% 98% 0%
apps/desktop/sr...ckends/types.ts 100% 100% 0%
apps/desktop/sr...sktop-client.ts 99% 99% 0%
apps/desktop/sr...uestionCard.tsx 0% 0% 0%
apps/desktop/sr...man-requests.ts 0% 100% +100%

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


Updated October 18, 2026 22:39 UTC

@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Review from the #273 tracker session, at 09e8369 (read only; I ran nothing on this branch). It is careful work, and I found nothing blocking. I checked three things:

  • Secret answers. A secret is held in the turn's in-memory broker (l.requests, reset at the turn's start and end) and written to the CLI's stdin. Saved items and item events carry publicAnswers(...), where it reads (hidden). I found no path from the broker into describeFailure, the journal, usage records or Jev.
  • One answer per request. answer and answerQuestion go through the broker's accept first, and a refusal returns its reason without touching the pending promise. The restart path closes dead approval and question cards as ended, and saves and emits that once.
  • No overlap with Read a completed Codex web search as done, so it folds again (CF-4) #288. This PR's codex.ts changes sit in server-request handling; Read a completed Codex web search as done, so it folds again (CF-4) #288 changes only codexOutcome.

One documentation nuance. thread:answer-question is registered through the shared registerCommands, and every handler not marked localOnly is exposed to paired desktops (index.ts:415, desktopCommands). A secret typed on a paired desktop therefore crosses that pairing's TLS connection to the Mac before it reaches the CLI. That's fine, but docs/human-requests.md says a secret answer "reaches the CLI and nowhere else". I'd add one line saying that, from a paired desktop, it travels over the paired TLS link, encrypted, and is not stored there. Alternatively, make the handler localOnly if secrets should only be typed on the Mac.

For the owners: this PR and #295 (CF-4) both edit shared/turn-layout.ts within a few lines of each other, so whichever lands second resolves a small conflict.

@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

CF-3 reconciliation at 173a17a0dfa3c1479c3ae559db8a06a36d17a05a reproduced an acceptance/delivery race in an isolated worktree. This is separate from the Knowledge CI repair in #305.

Using the existing codexAsking fixture:

  1. Wait for the question card.
  2. Call runner.answerQuestion(...); it returns { ok: true }.
  3. In the same synchronous turn, emit serverRequest/resolved for native request 7.
  4. Yield one setImmediate.

The fixture receives zero native answers, because answerServerRequest sees withdrawn.aborted after its await. The card nevertheless retains answers, and the runner has already called settleRequest(..., "sent") immediately after resolving the pending promise. The documentation's same-tick handoff assumption does not cover this microtask interval.

A deterministic regression reproduced this locally. The accepted answer needs an actual backend handoff outcome; withdrawal or disconnect before that handoff must leave a truthful withdrawn/uncertain receipt instead of an ordinary answered card. Please retain the no-resend behavior and keep sensitive answers out of the receipt. This is the unresolved #276 acceptance criterion for withdrawal during answer submission.

No production changes were made to the owning branch. The regression and its failing log are preserved in the separate cf3-reconcile worktree and /tmp/modex-cf2-reconcile/integration/cf3-reconcile-delivery-red.log for the next repair step.

BunsDev added a commit that referenced this pull request Oct 18, 2026
Opening a tab (⌘⇧B) focuses its address bar twice: once when the tab becomes active, and again
in an animation frame that newTab queues for when the panel was not yet visible. Chromium can
hold frames back for an inactive or busy window. The late focus then landed after the person,
or a test, had already moved on, and took the caret out of the composer mid-typing.

That failed CI on #293: store-desktop.spec.ts's browser-tools recovery case filled the composer
just as the late frame ran. The text went into the address bar and the composer stayed empty
(job 117782462586). The same case failed on #294's first run.

The late focus now applies only if focus has not moved since the tab opened. The new
workspace.spec.ts case holds animation frames, moves to the composer, releases the frames and
types. It failed first: the composer lost focus when the frame ran.

Coven-Harness: Claude Code / claude-opus-5-5
shared/human-requests.ts: approvals and native questions as one
versioned contract. A request is bound to thread, turn, attempt,
account, runtime and native request id plus a digest of the exact
action; it accepts one local answer, and an unknown id, a wrong
identity, a changed action, a withdrawn request or a second answer
authorises nothing. Stop withdraws pending requests; one whose answer
was being sent becomes uncertain, never resolved. Codex's experimental
item/tool/requestUserInput (codex-cli 0.163.0) maps to typed questions,
answers are validated against them, and secret answers are hidden from
anything shown, saved or exported. Not wired in yet: that consumes
#275's interfaces once #286 lands.

Refs #276

Coven-Harness: Claude Code / claude-opus-5-5
…stale cards

The runner keeps the turn's approvals and questions in the human-request broker. The first
answer is taken; every other one is refused with a reason (already resolved, withdrawn,
unknown, invalid) that thread:answer now returns and the phone receives as a 409.

Codex item/tool/requestUserInput (codex-cli 0.163.0, experimental) becomes a question card,
answered through thread:answer-question. Answers are checked against the questions before
anything reaches Codex. A secret answer goes to the CLI only and is saved as "(hidden)".
Stop sends an error reply, never an empty answer. When serverRequest/resolved arrives for a
request still open, Codex settled it, so the card closes as withdrawn and no answer is sent.
Approvals now carry the CLI's own request id (Codex JSON-RPC id, Claude request_id).

Cards a dead process left open close as ended when their thread loads, saved and emitted.
Phones see a question as a notice to answer on the Mac.

Part of #276.

Coven-Harness: Claude Code / claude-opus-5-5
Options are radio buttons, with Other when the question takes free text. A free-text question
gets a text field, and a secret one a password field. A refused answer says why on the card.
An answered card lists the answers, with a secret shown as (hidden). A closed card says why,
in the approval card's words.

The turn header reads "Waiting for your answer" while a question waits. An answered or
closed question folds into the turn's work; an open one never does.

The e2e drives a fixture codex-cli 0.163.0 app-server through the real UI. It covers an
incomplete answer refused in place, one reply carrying the answers, a refused second answer,
Stop giving an error reply, and no secret anywhere under MODEX_HOME/app.

Part of #276.

Coven-Harness: Claude Code / claude-opus-5-5
docs/human-requests.md covers the broker's exported signatures, its states and refusals, the
runner's binding and withdrawal rules, the Codex 0.163.0 and Claude 2.1.302 mappings, the
clients, how secrets are kept, the tests, and what is left for CF-6 and CF-7.

Part of #276.

Coven-Harness: Claude Code / claude-opus-5-5
Opening a tab (⌘⇧B) focuses its address bar twice: once when the tab becomes active, and again
in an animation frame that newTab queues for when the panel was not yet visible. Chromium can
hold frames back for an inactive or busy window. The late focus then landed after the person,
or a test, had already moved on, and took the caret out of the composer mid-typing.

That failed CI on #293: store-desktop.spec.ts's browser-tools recovery case filled the composer
just as the late frame ran. The text went into the address bar and the composer stayed empty
(job 117782462586). The same case failed on #294's first run.

The late focus now applies only if focus has not moved since the tab opened. The new
workspace.spec.ts case holds animation frames, moves to the composer, releases the frames and
types. It failed first: the composer lost focus when the frame ran.

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

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

CI on 5db1b10 failed in store-desktop.spec.ts:150 (browser-tools recovery, job 117782462586): the composer stayed empty after fill(). Cause: opening a tab (⌘⇧B) focuses the address bar twice, the second time in an animation frame. Chromium can hold that frame back for an inactive window, so the late focus landed mid-fill and the text went into the address bar. The same case failed on #294's first run. The fix is 467118c: the late focus applies only if focus hasn't moved since the tab opened. A new workspace.spec.ts case holds frames, moves to the composer, then releases them; it failed first. workspace.spec.ts passes 8 of 8 locally. The branch is also rebased onto main after #283; build, typecheck and CF-3's unit tests pass (35 of 35). The guard is waiting on CI.

@BunsDev

BunsDev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

From the docs steward (#290). This is coordination, not a review.

#283 merged as a4039b2, so the Still open line in docs/status.md (line 102 on main) now lists a finished item: "the Markdown parser (#283)". This PR rewrites that line and keeps the item (line 109 once merged onto a4039b2). When you next update the branch, could you drop "the Markdown parser (#283)"? If you'd rather name what CF-4 still has open, #277's 11:58Z checkpoint lists it: reference-viewport screenshots, a keyboard and reduced-motion review, and human VoiceOver.

I'm leaving that line alone on main while this PR changes it. Otherwise, git merge-tree onto a4039b2 merges cleanly, and the CF-2 and CF-3 sub-bullets both survive, with CF-2 first.

@BunsDev
BunsDev merged commit 57e7607 into main Oct 18, 2026
13 checks passed
@BunsDev
BunsDev deleted the cf3-requests branch October 18, 2026 22:40
BunsDev added a commit that referenced this pull request Oct 18, 2026
#283 merged as a4039b2, but the CF-1 block's Still open line still listed "the Markdown parser
(#283)". #293 rewrote that line before #283 landed and kept the item, so it stayed on main
after #293 merged (57e7607). Name what CF-4 still has open instead: #277's checkpoint lists
reference-viewport screenshots and a keyboard and reduced-motion review of the Markdown
elements; human VoiceOver is already in the list.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
… slice

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 18, 2026
… from Still open (#306)

* Record #185's downgrades in the approval rules spec

The spec's Known limits said commands are clipped before judgment "without a truncation
downgrade", and its rule section listed only the destructive and escalation downgrades. Since
#185 (2026-10-12), an allow also asks when the full command line chains, redirects or
substitutes commands, or when the digest clipped text Jev needed (approvals/gate.ts:155-158,
digest.ts:103-111).

Add a dated progress note under the enablement list: #185 closed the clipped-command false
allow, the quoted-command one is open and the corpus has not been run live since, so item 1 is
unmet. The note names the next step. The enablement criteria themselves are unchanged.

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

* Drop the merged Markdown parser from status.md's Still open list

#283 merged as a4039b2, but the CF-1 block's Still open line still listed "the Markdown parser
(#283)". #293 rewrote that line before #283 landed and kept the item, so it stayed on main
after #293 merged (57e7607). Name what CF-4 still has open instead: #277's checkpoint lists
reference-viewport screenshots and a keyboard and reduced-motion review of the Markdown
elements; human VoiceOver is already in the list.

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
CF-2 (#286), CF-3 (#293), CF-4's Markdown slice (#283), CF-6's request half (#308) and CF-7's
clarifications (#312) are on main, with their merge commits. The candidate note says the fixture
rows now run on main, and no candidate is pinned while the live-provider and human gates stay open.

Refs #281

Coven-Harness: Claude Code / claude-opus-5-5
BunsDev added a commit that referenced this pull request Oct 19, 2026
…nts at once, reconnect, a clarifying question (CF-8) (#313)

* Add the request variants to the fidelity path

Four cases in e2e/conversation-fidelity.spec.ts, through the real app:

- A native withdrawal: the Claude fixture takes its own request back (control_cancel_request).
  The card closes as withdrawn, no answer reaches the CLI, a late answer is refused, and the file
  is unchanged.
- The desktop and the phone answer at once, over the bridge and the companion's HTTPS. Exactly one
  is accepted, the CLI reads one decision, the card names who gave it, and the file matches the
  winner.
- With the journal on, a phone that loaded the open card reconnects after the desktop's decision.
  Its delta shows the card answered by the desktop and sent, its late answer is a 409, and every
  count stays at one.
- A clarifying question inside the path, from a codex-cli 0.163.0-shaped fixture: answered on its
  card, heard once, followed by a real edit and check, saved to Notes, and inert after a restart
  that re-runs nothing.

The fixture now counts every decision the CLI reads, so the earlier cases assert that too. The
golden path is marked slow: since #301 it also takes 18 reference captures and relaunches, and it
ran past 90 s on a Mac at load average 100.

These cases found the companion's 404 for threads started on the Mac, fixed in the CF-6 branch.

Refs #281

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

* Record the request variants in the acceptance receipt

The matrix rows for a clarifying question, a native withdrawal, simultaneous answers and a
reconnect after a decision move from open to verified with a fixture, with what each case asserts.
The defects list adds the companion's 404 for threads started on the Mac. The fidelity summary gains
rows for questions and approvals.

Refs #281

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

* Record CF-8's request variants in status

Refs #281

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

* Record the landed children in the acceptance receipt

CF-2 (#286), CF-3 (#293), CF-4's Markdown slice (#283), CF-6's request half (#308) and CF-7's
clarifications (#312) are on main, with their merge commits. The candidate note says the fixture
rows now run on main, and no candidate is pinned while the live-provider and human gates stay open.

Refs #281

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

This branch was successfully deployed

1 active deployment
Preview — 467118c4 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