Skip to content

fix: await queued Codex trust preflight completion - #23148

Merged
nwparker merged 3 commits into
mainfrom
nwparker/perf-09-25-agent-trust-completion
Sep 27, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/perf-09-25-agent-trust-completion

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​156 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149

ELI5

Codex session continuation now waits for its queued trust write before admitting the launch. Trust-write failures still allow continuation once they settle.

What Changed

Await the existing local Codex trust Promise inside the main-process IPC handler. The renderer already awaits this IPC, but its reply previously arrived while the write could still be queued, and asynchronous failures escaped the best-effort catch.

With a pending trust write Before After
Renderer launch admission Can proceed Waits for settlement
Mocked continuation launch calls before release 1 0
Extra timers / trust calls 0 / 1 0 / 1

Why

One missing await restores the preflight contract and contains queued errors without adding another queue or retry mechanism. A timeout would permit launch before trust completes. Recognized native Codex launches already await trust deeper in launch preparation; this PR fixes the earlier renderer boundary and does not claim every actual process currently races trust.

Separate trade-off PR: callers wait for the existing queue/write. There is no new timeout or cancellation; a stuck predecessor can now leave this IPC and caller pending indefinitely. No launch-speed gain is claimed.

Linked Issue

Fixes #23146

Visual Proof

N/A

This is asynchronous preflight ordering with no layout change. Mocked cross-layer launch admission is verified; live launch timing and trust-prompt behavior remain unverified.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Eleven new cross-layer tests pass; four fail against the original. Thirty-two focused tests pass across the new suite, renderer preflight/continuation and remote trust. Tests cover actual queue contention, delayed/immediate failures, fake 60-second pending duration with no timers, SSH owner selection with no local fallback, synchronous presets and missing paths. Node typecheck, a separate scoped typecheck including this cross-layer test, focused lint, format and diff checks pass.

Tests ran on macOS with background-launch mode and mocked bridge/config I/O/launch. No real Codex process, trust file write, Electron window or SSH connection was exercised. Native Windows/Linux/WSL, full build, broad checks and CI soak remain gaps.

Review

Independent review approved the exact source/test hashes. Four additional controls pass (original two fail), using the actual queue and IPC handler; all 32 focused permanent cases also pass independently. Merge risk: low implementation complexity, moderate caller-wait risk.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No new process, timer, config operation, wire field, status producer, Git command or provider route. Folder workspace paths remain supported. Another discarded trust call in worktree startup is outside this PR. Reliability gate: agent-session.trust-preflight-completion, experimental pending native evidence and CI soak. Invariant: preflight settles after its selected trust owner; oracle: zero launches while held and one afterward. Failures are diagnosed by before-release counters and named assertions, without logging user config. Local PTY and daemon transport/liveness are unaffected; SSH routing is mocked, and native Linux/Windows/WSL plus remote runtime remain execution gaps. Mobile/relay state and wire behavior are unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The trust-write helper applies a deadline to selected local Codex and remote writes. The IPC trust handler and startup setup now await those writes, while existing best-effort handling remains in place. Tests cover completion ordering, deadline behavior, failures, concurrent requests, SSH dispatch, other providers, and empty workspace paths. A reliability-gate record describes the invariant, evidence, coverage gaps, budgets, and promotion criteria.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to b6963

Worktree startup currently waits for the trust write, but this ordering lacks a direct regression test. The change is mergeable with a focused follow-up test.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The stated objective is to await the existing local Codex trust-write Promise in the main-process IPC handler. The PR adds a 20,000 ms deadline helper, applies it to remote and local trust writes, and… Remove the deadline helper and its uses outside the required IPC await. Remove the additional startup-path change, or move these behavior changes to a separate pull request with a separate scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: waiting for queued Codex trust preflight completion.
Description check ✅ Passed The description includes all required sections, explains the user-visible behavior and implementation, links issue #23146, documents testing and known gaps, and addresses cross-platform and remote con…
Linked Issues check ✅ Passed Issue #23146 is closed and provides historical context only. No active directly linked issue supplies coding requirements for this pull request.
Full details: Out of Scope Changes check

Explanation

The stated objective is to await the existing local Codex trust-write Promise in the main-process IPC handler. The PR adds a 20,000 ms deadline helper, applies it to remote and local trust writes, and adds deadline-bounded trust setup in spawnLocalStartupAndSetupTerminals. These changes alter timeout and startup behavior beyond the IPC completion fix. The deadline also conflicts with the stated no-timeout scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — verified the one-line production fix, the reliability-gate manifest entry, and the new cross-layer test suite at commit 2e4ed60.

  • await the queued Codex trust write — src/main/ipc/agent-trust.ts:46 now awaits markCodexProjectTrusted, so the agentTrust:markTrusted IPC replies only after the queued write settles. The handler was already async and already awaited the SSH/remote path, so this restores ordering parity for local Codex and routes queued rejections into the existing best-effort catch instead of leaking an unhandled rejection.
  • New reliability gate — agent-session.trust-preflight-completion in config/reliability-gates.jsonc, marked experimental / partial / cross-layer-unit. The new entry is well-formed; node config/scripts/check-reliability-gates.mjs passes for all 127 gates.
  • New test suite — tests/e2e/agent-trust-completion.unit.test.ts exercises the real queue, real IPC handler, and mocked bridge/remote/launch. I independently confirmed red-green: reverting the await fails exactly 4 of the 11 new tests (launch-not-held, queue-not-held, failure-settlement, no-deadline), matching the PR claim, so the coverage is genuine rather than a tautology. The focused gate command passes 4 suites / 32 tests.

The acknowledged trade-off is sound to carry as a separate PR: runExclusivelyForCodexTrustConfig has no timeout, and hook-install grants can await the codex app-server, so a stuck predecessor can now leave this IPC (and its caller) pending indefinitely. It is already disclosed in the PR body and recorded in the gate's knownGaps / performanceBudget, so no change is requested here.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes — re-reviewed the delta since the prior pullfrog review at 2e4ed60, i.e. commit 518f0c4, which bounds the trust preflight wait and extends the awaited write to worktree startup.

  • Bounded trust-write wait — new src/main/agent-trust-write-deadline.ts adds awaitAgentTrustWriteWithinDeadline, which races the write against a 20s timer, warns and continues untrusted on expiry rather than throwing, and clears the timer in finally; Promise.race adopts the wrapped promise so a rejection arriving after the deadline stays handled.
  • Applied at both preflight call sites — agent-trust.ts wraps the SSH and local Codex writes, and worktree-remote.ts now awaits (bounded) the previously-discarded Codex write before spawning the startup PTY.
  • Expanded cross-layer tests — the suite grows from 11 to 15 tests, adding deadline expiry, already-settled writes, post-deadline rejections, SSH expiry without local fallback, and concurrent launches for one workspace. The focused gate command passes 4 suites / 36 tests and pnpm tc:node / changed-code quality both pass.

ℹ️ Worktree-startup await sits outside the gate's declared surface

src/main/ipc/worktree-remote.ts:451 is a third production call site of the same invariant, but the gate's surfaces, testFiles, and coverageNotes still describe only the IPC and renderer-preflight path, and none of the listed tests exercise spawnLocalStartupAndSetupTerminals. The PR body's "Notes" also still says the worktree-startup trust call is outside this PR, which no longer matches the code.

Technical details
# Worktree-startup trust await is unscoped and untested

## Affected sites
- `src/main/ipc/worktree-remote.ts:451` — new `await awaitAgentTrustWriteWithinDeadline(markCodexProjectTrusted(worktree.path), ...)` in the codex branch of `spawnLocalStartupAndSetupTerminals`.
- `config/reliability-gates.jsonc:29` (`coverageNotes`), `:36` (`testFiles`), `:20` (`surfaces`) — do not mention the worktree-startup path.
- PR body "Notes" — "Another discarded trust call in worktree startup is outside this PR."

## Required outcome
- Either extend the gate (surface/test or an explicit `coverageNotes` exclusion) so the manifest scope matches the code, and correct the stale PR-body note, or state why the worktree-startup branch is intentionally left out of this gate.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread config/reliability-gates.jsonc Resolved
…ee-startup write

The awaited trust write had no cap. The local Codex writer queues on the
per-config.toml lane it shares with hook installs and app-server trust grants,
and the SSH writer chains a resolveHome round trip plus SFTP calls over a link
that may be half-open - so "start agent" could hang with no error. Cap the wait
at a single deadline and continue untrusted, which only loses the ordering
optimisation: the agent then raises its own trust prompt, so giving up fails
closed.

Also await the discarded write in worktree startup, where the PTY spawns Codex
on the next line and the synchronous catch could not see its rejection.

Update the reliability gate: its oracle asserted the absence of a deadline, and
its manifest was left unformatted.
@nwparker
nwparker force-pushed the nwparker/perf-09-25-agent-trust-completion branch from 518f0c4 to 2c135dc Compare September 27, 2026 06:14
…ommand actually reports

The gate's evidence still described the pre-deadline suite: "32 author tests",
"New11pass", "original4fail/7pass". The four deadline tests this branch adds make
the cited command run 15 tests in `agent-trust-completion.unit.test.ts` and 36
across the four suites, so the manifest asserted counts its own command no longer
produces. Re-ran the command and recorded what it printed.

Re-ran the red/green as well, against the same 15-test suite rather than the 11 it
was first measured on. Pre-await: 5 fail/10 pass. Unbounded-await: 3 fail/12 pass,
where the fourth deadline test — the already-complete write settling on microtasks
— passes unbounded too, so it is a timer control and not a red; saying so beats
counting it as evidence for the cap.

Two claims the commit left stale: only the IPC handler is under test, yet the same
commit also bounds the worktree-startup write, and the cap is per call site while
three other awaited Codex trust writes are still unbounded. Both are now gaps
instead of silence.

Co-Authored-By: Claude <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/ipc/worktree-remote.ts (1)

447-460: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add a deferred-write assertion for worktree startup.

The existing trust tests cover renderer continuation and the mutation queue, but they do not invoke the Codex branch in src/main/ipc/worktree-remote.ts. Add a focused fixture that keeps markCodexProjectTrusted pending, asserts that runtime.createTerminal is not called, then releases the write and asserts one terminal launch. This test would fail if this await were removed and would directly protect the changed startup ordering without requiring a native PTY.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d8a5be6f-6978-4c48-878e-233ea63deca1

📥 Commits

Reviewing files that changed from the base of the PR and between 2c135dc and b6963e9.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/reliability-gates.jsonc

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — re-reviewed the delta since the prior pullfrog review at 2c135dc, i.e. commit b6963e9, which refreshes the reliability gate's recorded evidence to match the command it cites.

  • Refreshed gate evidence — config/reliability-gates.jsonc now records 36 tests across four suites (15 in the trust-completion suite, four of them the deadline cases this candidate adds), replacing the stale "32 author tests / New11pass" summary, and re-runs the red-green counts against the current 15-test suite.
  • Recorded the worktree-startup known gaps — knownGaps now states that only the trust IPC handler is exercised, that the bounded worktree-remote.ts write has no test in these suites, and that the cap is per call site rather than global, so the bounded-wait invariant covers this gate's surfaces only.

ℹ️ PR description still says the worktree-startup trust call is outside this PR

The gate's knownGaps now correctly records the worktree-remote.ts await as a bounded call site this PR touches, but the PR body "Notes" still reads "Another discarded trust call in worktree startup is outside this PR". Worth correcting so the description matches the code.

Technical details
# Stale PR-body note about the worktree-startup trust write

## Affected sites
- `config/reliability-gates.jsonc:421` (`knownGaps`) — now names the `worktree-remote.ts` bounded write explicitly.
- PR body "Notes" — "Another discarded trust call in worktree startup is outside this PR."

## Required outcome
- Update the PR description so it does not claim the worktree-startup trust write is out of scope when the diff bounds it.

</details>

<!--
Pullfrog review metadata. These findings were written against b6963e9;
if commits have landed on nwparker/perf-09-25-agent-trust-completion since, treat every specific bug, file, or
line callout as POTENTIALLY STALE and re-diff before acting on it.

- Mode: IncrementalReview (delta against prior pullfrog review)
- Files reviewed: 5
- Commits reviewed: 3
- Base: main (ccd1e872)
- Head: nwparker/perf-09-25-agent-trust-completion (b6963e9)
- Reviewed commits:
  - b6963e9993 — fix(reliability-gates): record the trust-preflight counts the cited command actually reports
  - 2c135dc2a4 — fix(agent-trust): bound the trust preflight wait and order the worktree-startup write
  - 9fa7c2177c — fix: await queued Codex trust preflight completion
- Prior pullfrog review: 518f0c4 (https://github.com/stablyai/orca/pull/23148#pullrequestreview-5329023197)
-->


<!-- PULLFROG_DIVIDER_DO_NOT_REMOVE_PLZ -->
<sup><a href="https://pullfrog.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pullfrog.com/logos/frog-white-full-18px.png"><img src="https://pullfrog.com/logos/frog-green-full-18px.png" width="9px" height="9px" style="vertical-align: middle; " alt="Pullfrog"></picture></a>&nbsp;&nbsp;| [View workflow run](https://github.com/stablyai/orca/actions/runs/36303694934/job/108576072365) | Using `DeepSeek Flash` (free via [Pullfrog for OSS](https://pullfrog.com/for-oss)) | [𝕏](https://x.com/pullfrogai)</sup>

@nwparker
nwparker merged commit 983250a into main Sep 27, 2026
40 checks passed
@nwparker
nwparker deleted the nwparker/perf-09-25-agent-trust-completion branch September 27, 2026 07:47
nwparker added a commit that referenced this pull request Sep 27, 2026
…ts on

#23148 capped the trust write on the agentTrust:markTrusted IPC handler and the
worktree-remote startup path, but three call sites still awaited
markCodexProjectTrusted with no bound: the main-process worktree startup used by
orchestration worker-start, Codex quick-launch preparation, and Codex session
resume preparation. All three share the per-config.toml lane with hook installs
and app-server trust grants, which has no cap on queue depth, and the SSH writer
adds a resolveHome round trip plus unbounded SFTP over a possibly half-open
link. A wedged lane left the user clicking "start agent" with nothing happening
and no error.

Each site now routes through the existing awaitAgentTrustWriteWithinDeadline
helper with unchanged semantics for its two current callers. Abandoning at the
deadline never cancels the write, writes nothing else, and never substitutes a
local fallback, so the workspace stays untrusted and Codex raises its own trust
prompt. The await still sits ahead of the runtime-home resolution and hook
repair that the PTY spawn waits on, so the ordering #23148 established is kept.

Reliability only; there is no speed gain. The win is that a launch cannot hang.

Verified with 2,755 agent-trust/Codex/startup/runtime tests, the 53-test
reliability-gate command, the gate manifest check, typecheck:node, changed-code
quality, oxlint and oxfmt. Red-green: with the three sites reverted to a bare
await the new bounding tests hang to the 30s vitest timeout (3 fail/14 pass);
restored, 17 pass.

Co-Authored-By: Claude <[email protected]>
nwparker added a commit that referenced this pull request Sep 27, 2026
…ts on (#23380)

* fix(agent-trust): bound the remaining Codex trust writes a launch waits on

#23148 capped the trust write on the agentTrust:markTrusted IPC handler and the
worktree-remote startup path, but three call sites still awaited
markCodexProjectTrusted with no bound: the main-process worktree startup used by
orchestration worker-start, Codex quick-launch preparation, and Codex session
resume preparation. All three share the per-config.toml lane with hook installs
and app-server trust grants, which has no cap on queue depth, and the SSH writer
adds a resolveHome round trip plus unbounded SFTP over a possibly half-open
link. A wedged lane left the user clicking "start agent" with nothing happening
and no error.

Each site now routes through the existing awaitAgentTrustWriteWithinDeadline
helper with unchanged semantics for its two current callers. Abandoning at the
deadline never cancels the write, writes nothing else, and never substitutes a
local fallback, so the workspace stays untrusted and Codex raises its own trust
prompt. The await still sits ahead of the runtime-home resolution and hook
repair that the PTY spawn waits on, so the ordering #23148 established is kept.

Reliability only; there is no speed gain. The win is that a launch cannot hang.

Verified with 2,755 agent-trust/Codex/startup/runtime tests, the 53-test
reliability-gate command, the gate manifest check, typecheck:node, changed-code
quality, oxlint and oxfmt. Red-green: with the three sites reverted to a bare
await the new bounding tests hang to the 30s vitest timeout (3 fail/14 pass);
restored, 17 pass.

Co-Authored-By: Claude <[email protected]>

* docs(reliability-gates): stop the trust-preflight gate claiming a bounded launch

The gate's performance budget said a stuck predecessor "degrades to the
agent's own trust prompt instead of an indefinite caller wait." That is false
at two of this branch's three new sites. In startup/codex-launch-preparation.ts
the next awaited call after the abandoned write is
codexHookService.prepareRuntimeHomeForLaunch; in
startup/codex-session-resume-launch.ts it is installForLaunchPrep or
refreshRuntimeUserHooksForLaunchPrep. Both reach
runExclusivelyForRuntimeAndSystemTrustConfig, which takes the same
runExclusivelyForCodexTrustConfig queue - FIFO per config.toml, no depth cap
and no timeout - on the runtime home and on ~/.codex/config.toml that
markCodexProjectTrusted itself takes. A wedged lane still stalls those two
launches one step later, with the abandoned write holding its queue slot ahead
of the hook step. Only markLocalWorktreeTrusted has nothing after its Codex
branch and so is bounded end to end.

The budget, invariant, oracle and coverage notes now say what is true: all five
markCodexProjectTrusted call sites are bounded, so no trust write hangs a
caller indefinitely, but the bound is on the write and not on the launch. A new
knownGaps entry records the residual stall and that the new launch-prep tests
mock codexHookService wholesale, so nothing in these suites can catch it. The
already-complete-write case stays labelled a timer control, not a red.

Wording only; no production code, test or count changed. The cited command
still reports 6 files / 53 tests, and the gate manifest check passes for 138
gates.

Co-Authored-By: Claude <[email protected]>

* docs(reliability-gates): name the first unbounded re-entry, not the hook-service call

The trust-preflight gate cited codexHookService.prepareRuntimeHomeForLaunch as
the immediate next step after the abandoned write in
startup/codex-launch-preparation.ts. Tracing the module, the first awaited step
is ensureRealHomeHooksIfSelected. It is conditional: only when the target is not
WSL and runtimeHome.isHostSystemDefaultRealHomeSelected(launchEnv) is true does
it call ensureRealHomeCodexHookState, which chains behind that module's own
serial ensure promise and then acquires runExclusivelyForCodexTrustConfig
directly on ~/.codex/config.toml - the same lane markCodexProjectTrusted's inner
acquire takes. When the real home is not selected that call returns without
awaiting the lane, runtimeHome.prepareForCodexLaunchAsync is synchronous on the
non-WSL path, and only then is prepareRuntimeHomeForLaunch the first re-entry.
So the gate could miss a launch stall one step earlier than the one it named.

startup/codex-session-resume-launch.ts had the same omission: its hook branch
takes ensureRealHomeCodexHookState when the resume home is ~/.codex, and only
otherwise installForLaunchPrep or refreshRuntimeUserHooksForLaunchPrep. The
coverage notes also understated the mocking - codex-launch-trust-write-deadline
mocks ensureRealHomeCodexHookState as well as codexHookService and defaults the
real-home selection to false, so neither lane is driven by any suite here.

The performance budget, coverage notes and the residual-stall knownGap now name
the first re-entry on each path and say when it applies, rather than only the
later hook-service call.

Wording only; no production code, test or count changed. The cited command
still reports 6 files / 53 tests, and the gate manifest check passes for 138
gates.

Co-Authored-By: Claude <[email protected]>

* docs(reliability-gates): scope the trust-preflight invariant to the local writes

The invariant claimed every Codex trust write a launch waits on is bounded or
abandoned at a deadline. The entry's own knownGaps contradicted that: the remote
write reached through markRemoteWorktreeTrusted in
runtime/runtime-worktree-agent-startup.ts is awaited with no timer, and it is a
Codex write, not an adjacent one - it reads TUI_AGENT_CONFIG[agent].preflightTrust,
which is 'codex' for the codex agent, and markRemoteAgentWorkspaceTrusted then
branches into markRemoteCodexProjectTrusted. Its one production caller,
markRemoteWorkspaceTrustedForAgent, is reached with a connectionId from seven
launch entry points; five await it directly before the createTerminal that spawns
the agent, and two gate the launch command they hand back for their caller to
spawn. It chains a session.resolveHome round trip plus SFTP realpath/read/mkdir/
write, none with a timeout, over a possibly half-open link - the same hang this
branch bounds locally.

The invariant now claims only the five local markCodexProjectTrusted sites and
names the remote exception inline instead of leaving it to knownGaps. Audited the
rest of the entry against the code in the same pass: performanceBudget said "no
trust write can hold its caller indefinitely" (now scoped to those five); the
"all five awaited Codex trust writes" tally is now "all five awaited local" and
points at the unbounded sixth; the remote gap no longer calls that path merely
"preset-agnostic and out of Codex scope"; oracle and coverageNotes now record
that nothing here drives markRemoteWorktreeTrusted, since the remote-preset
suite only checks what markRemoteAgentWorkspaceTrusted writes, never how long it
may take; and surfaces gains the remote writer that suite actually covers.

Re-verified the rest rather than assuming it: the launch-prep re-entry chain,
the FIFO no-cap no-timeout trust-config queue, the IPC handler capping both its
remote and local writes with no cross-branch fallback, and that
upsertProjectTrustLevel and upsertProjectTrustLevelInContent remain the only
producers of a project trust_level, so no further writer needs covering. The
already-complete-write case stays labelled a timer control, not a red.

Wording only; no production code, test or count changed. The cited command still
reports 6 files / 53 tests, and the gate manifest check passes for 140 gates.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
LaPaGaYo pushed a commit to LaPaGaYo/Axiom that referenced this pull request Oct 20, 2026
* fix: await queued Codex trust preflight completion

* fix(agent-trust): bound the trust preflight wait and order the worktree-startup write

The awaited trust write had no cap. The local Codex writer queues on the
per-config.toml lane it shares with hook installs and app-server trust grants,
and the SSH writer chains a resolveHome round trip plus SFTP calls over a link
that may be half-open - so "start agent" could hang with no error. Cap the wait
at a single deadline and continue untrusted, which only loses the ordering
optimisation: the agent then raises its own trust prompt, so giving up fails
closed.

Also await the discarded write in worktree startup, where the PTY spawns Codex
on the next line and the synchronous catch could not see its rejection.

Update the reliability gate: its oracle asserted the absence of a deadline, and
its manifest was left unformatted.

* fix(reliability-gates): record the trust-preflight counts the cited command actually reports

The gate's evidence still described the pre-deadline suite: "32 author tests",
"New11pass", "original4fail/7pass". The four deadline tests this branch adds make
the cited command run 15 tests in `agent-trust-completion.unit.test.ts` and 36
across the four suites, so the manifest asserted counts its own command no longer
produces. Re-ran the command and recorded what it printed.

Re-ran the red/green as well, against the same 15-test suite rather than the 11 it
was first measured on. Pre-await: 5 fail/10 pass. Unbounded-await: 3 fail/12 pass,
where the fourth deadline test — the already-complete write settling on microtasks
— passes unbounded too, so it is a timer control and not a red; saying so beats
counting it as evidence for the cap.

Two claims the commit left stale: only the IPC handler is under test, yet the same
commit also bounds the worktree-startup write, and the cap is per call site while
three other awaited Codex trust writes are still unbounded. Both are now gaps
instead of silence.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
(cherry picked from commit 983250a)
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.

Codex trust preflight resolves before its queued write settles

1 participant