Repository navigation
fix(state): serve session reads during startup integrity inspection - #186473
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs changes before merge. What this changesThis PR lets eligible session, metadata, model, and board reads proceed while startup integrity inspection continues to block writes. Example: Reconnect after an unclean restart with a 3.21 GB current-schema agent database.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep open: this PR provides a useful startup-read improvement, but prematurely releases recovery and cron waiters and introduces two test defects. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe database startup owner publishes admission decisions consumed by Gateway handlers and SQLite workers; descriptive requests return committed snapshots while mutations await full preparation. flowchart TD
A[Gateway restart] --> B[Schema and ownership inspection]
B --> C[Startup admission owner]
C --> D[Read only workers]
C --> E[Full integrity inspection]
D --> F[Session and board responses]
E --> G[Writable admission and recovery]
Technical reviewBest possible solution: Keep separate read readiness in the existing startup owner while preserving full-completion waits for recovery and mutation consumers. Do we have a high-confidence way to reproduce the issue? The base source gates reads on full preparation, and the supplied real Gateway comparison demonstrates the delay; this review executed no target code. Is this the best way to solve the issue? The existing admission owner is the right boundary, but changing its default wait requires a complete consumer cutover that this patch misses. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 228596060e33. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +340, Tests 0, Docs +9, Other +110. Total +459 across 49 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 11:34 PM ET / October 28, 2026, 03:34 UTC. |
0f50066 to
bf8d8ed
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf8d8eda6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bf8d8ed to
864275e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 864275e512
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a8314ff to
11923f9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11923f9cb3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
11923f9 to
1bb2e2f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bb2e2f9cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1bb2e2f to
0c61beb
Compare
Separate revocable read readiness from writable admission for existing current-schema agent databases. Keep full integrity checks and write ordering, while committed read-only snapshots serve session, board, model, and metadata requests. Prove the owning boundary with held native integrity and a real Gateway crash/restart fixture. No schema or storage-format changes.
Keep plugin actors and agent preparation on separate bounded carriers so full startup integrity scans cannot block unrelated Workboard reads. Preserve shared physical ownership, global input limits, write admission and existing two-carrier generic progress. The normal carrier maximum is five instead of three. Native held-scan regression and focused broker/generation checks pass; independent review is clean. Real Gateway restart and paired load proof follow before landing.
Migrate the PostgreSQL lifecycle benchmark to the private carrier class and retain the open-refusal test on agent peers. Preserve the pooled-worker recovery assertions. Focused refusal test, script typecheck, changed-file lint and independent review pass.
Use the existing authenticated Prometheus exporter to capture three fresh live memory observations after all interrupted turns recover. Keep incomplete worker heap coverage explicit and resource sampling separate from startup latency. Changed-file lint, exact script typecheck, parser verification and independent review pass. Paired built-Gateway resource runs follow the immutable load campaign.
Classify resolve and metadata as database reads without changing direct-key authorization. Invalidate cached agent topology when early read admission is revoked, and prove both failures against held native inspection. Reconnect the live restart probe with read-only operator scope.
Keep startup read, write, failure and cancellation proof while sharing fixture disposal and removing redundant setup. Let the Gateway fixture drain native borrowers before closing state instead of closing it synchronously in a duplicate test hook. Preserve the existing test-line ceiling.
Carry the method registry read classification through session authorization without changing sharing policy or writable database admission. Cover a registered plugin read while integrity is held and reject it when schema repair is required.
0c61beb to
36eb613
Compare
|
Landing this exact head under the authorized inherited-failure exception. CI run 40656449792 has three failing test jobs plus its aggregate gate:
All security and other selected CI jobs passed; independent review is clean. Final built startup proof passes all nine read-only RPCs 10.35 seconds before integrity completes, with five interrupted turns recovered exactly once. Full stress and resource evidence is in the PR body. No CI reruns or baseline increases. |
…penclaw#186473) * fix(state): serve session reads during startup integrity inspection Separate revocable read readiness from writable admission for existing current-schema agent databases. Keep full integrity checks and write ordering, while committed read-only snapshots serve session, board, model, and metadata requests. Prove the owning boundary with held native integrity and a real Gateway crash/restart fixture. No schema or storage-format changes. * test(state): align startup fixtures with read admission phases * fix(state): preserve full readiness for recovery waiters * fix(state): isolate plugin reads from agent inspection Keep plugin actors and agent preparation on separate bounded carriers so full startup integrity scans cannot block unrelated Workboard reads. Preserve shared physical ownership, global input limits, write admission and existing two-carrier generic progress. The normal carrier maximum is five instead of three. Native held-scan regression and focused broker/generation checks pass; independent review is clean. Real Gateway restart and paired load proof follow before landing. * test(state): finish SQLite carrier classification cutover Migrate the PostgreSQL lifecycle benchmark to the private carrier class and retain the open-refusal test on agent peers. Preserve the pooled-worker recovery assertions. Focused refusal test, script typecheck, changed-file lint and independent review pass. * test(perf): measure post-recovery Workboard worker resources Use the existing authenticated Prometheus exporter to capture three fresh live memory observations after all interrupted turns recover. Keep incomplete worker heap coverage explicit and resource sampling separate from startup latency. Changed-file lint, exact script typecheck, parser verification and independent review pass. Paired built-Gateway resource runs follow the immutable load campaign. * fix(gateway): complete startup read admission for non-admin clients Classify resolve and metadata as database reads without changing direct-key authorization. Invalidate cached agent topology when early read admission is revoked, and prove both failures against held native inspection. Reconnect the live restart probe with read-only operator scope. * test(state): consolidate startup admission fixture lifetimes Keep startup read, write, failure and cancellation proof while sharing fixture disposal and removing redundant setup. Let the Gateway fixture drain native borrowers before closing state instead of closing it synchronously in a duplicate test hook. Preserve the existing test-line ceiling. * fix(gateway): retain registered read admission for plugin requests Carry the method registry read classification through session authorization without changing sharing policy or writable database admission. Cover a registered plugin read while integrity is held and reject it when schema repair is required.
What Problem This Solves
After an unclean restart, agent-scoped reads failed or waited for the full database integrity scan even after the Gateway listener accepted connections. This change makes committed reads available during inspection while writes and interrupted-turn recovery retain full writable admission.
User Impact
Resolve/describe/list, board display, subscription, models, metadata, history, and registered plugin reads can use current-schema agent databases before inspection completes. No schema, storage format, configuration, or baseline changes.
Why This Change Was Made
The startup owner publishes a revocable read fact bound to the current inspection, physical database paths, and Gateway configuration. Reads retain schema, ownership, canonical-row, file-identity, quarantine, sharing, and visibility checks. They see committed SQLite snapshots, including committed WAL; this does not certify unchecked pages elsewhere. Failed inspection, cancellation, supersession, or retirement revokes readiness and invalidates cached topology. Early secrets/model publication runs under a read-only preparation scope, so callbacks cannot borrow writable startup authority.
Missing schema/index repairs still block readiness. Reads requiring mutation, including cold transcript restoration and abandoned queued-input reconciliation, wait for writable admission. Board action authorization retains its ordering. The default preparation waiter still waits for full completion; only explicit read callers opt in. The Gateway carries its registered read-method classification through authorization, including session-scoped models and plugin reads, without changing direct-key authorization policy.
A live test exposed a second blocker: Workboard's existing SQLite actor could share a carrier with synchronous agent integrity work. The existing broker now separates agent, generic/plugin, and shared-state carriers and their cold-open queues. Physical ownership and global admission budgets remain shared. Two agent and two generic carriers preserve independent-store progress; shared state keeps one. The normal maximum rises from three to five, and the retained-generation maximum from five to eight. The measured resource cost is reported below.
Evidence
A real built dev Gateway was seeded with 10,000 sessions, 1 GiB transcript payload (3,214,258,176-byte main database), five agents, 40 synthetic plugins, Workboard, and the Prometheus exporter. Five mock-provider streams were interrupted with SIGKILL, then an offline writer left unclean WAL. Five reconnecting clients negotiated only
operator.read, with no admin grant. All five interrupted turns recovered exactly once in both arms.Baseline:
4a5ec828b19c5207028faa9cdedb6528ae931c55. Final candidate:36eb613700ef240c2d50761b084c9fafe12238da(parentbec3ad81da5568e05e5e55219b00c72bb4ee6e0a). The intervening main changes do not change database admission or carrier ownership; versions are labeled rather than presented as an identical-parent benchmark. The final probe addssessionKeyto the committed script'smodels.listrequest to exercise the non-admin scoped authorization path.All nine candidate reads succeed at least 10,352 ms before integrity completes. Baseline reads either return UNAVAILABLE or wait for full preparation. These are one-request startup observations, not percentile/throughput claims.
Integrity is the dominant size-dependent cost: an earlier 256 MiB transcript baseline took 3,278 ms versus 12,506 ms with 1 GiB. Existing clean-close seals already skip clean-shutdown scans; this fix retains full unclean verification. SQLite open/WAL visibility is not the dominant measured phase. Restart host load (1/5/15) is 20.10/15.58/13.65 → 9.28/13.03/12.90 for baseline and 8.95/9.89/10.87 → 7.22/8.99/10.39 for candidate.
Workboard resource cost
Three fresh post-recovery diagnostic samples, with list/Workboard churn between samples. Every worker is covered. Heaps are live, not forced-GC retention; samples are correlated within one run and workers retire during the window.
Sample-mean RSS changes +3.86%, main heap +1.37%, worker heap +2.96%, SQLite heap +12.16%. The extra materialized SQLite worker is an explicit resource tradeoff for independent plugin progress. Different successful early-read work, host load, and worker retirement prevent a causal retention claim from this single startup pair. No A/A controls were run; these observations are not labeled an adverse verdict or hidden as a neutral memory result.
Load Comparison
The canonical harness completed eight 10-minute arms: timing AB/BA, then allocation AB/BA, with 10,800 sessions, 40 plugins, 65 WebSocket clients, and concurrent mock-provider tool/native-subagent turns. All arms completed 40 turns and 40 tool calls/results with zero client RPC errors. No load was sent to Team.
The frozen artifacts are parent
3bcca4f468ea966f8efa03d0ad24b859792b9deaand candidatef4cb9dccbabbcb0b00dfddab6d0c22b355d85bc1. These measurements cover the carrier/admission change at those revisions; later correctness fixes and rebases are verified separately below, not relabeled as measured builds.Timing paired means: CPU +0.223 percentage points (+3.46%); total GC +7.12 ms/min; loop p99 +0.15 ms; client list p99 −6.94 ms; server-handler p99 estimate +1.39 ms (+5.34%, mixed signs). Allocation paired mean is +0.387 MiB/s (+2.18%). This is a startup availability improvement, not a steady-state CPU/allocation win. Achieved rates remain approximately 192 RPCs/min and four turns/min. No numerical rejection threshold is reached. Tail deltas with mixed signs are inconclusive, not adverse; no A/A controls were run or causal latency/memory wins claimed.
Timing GC counts (minor/incremental/major) are base 252/30/30 → candidate 256/30/30 in pair 1, and 247/26/26 → 254/30/30 in pair 2. Per-kind GC ms/min are 66.864/1.798/46.935 → 66.300/1.870/53.173 and 61.481/1.476/52.310 → 66.929/1.997/54.826. Maximum pauses are 21.729 → 30.461 ms and 31.271 → 35.732 ms; neither exceeds max(50 ms, 2× baseline). Major collection counts are below 50 and are context only. The +7.12 ms/min total GC delta is below the 50 ms/min materiality rule. Allocation-pass timing/GC values above are instrumented context, not timing gates.
Handler tails are first/last scrape histogram estimates (1,173 calls each), not exact samples; p99 lies in 25–30 ms buckets except timing candidate pair 2 (30–40 ms). Scrapes omit the final 10–15 seconds. RSS/main heap are end-of-run observations, worker heap is the last complete non-forced sample; these are not paired retention claims. All 35 workers were sampled. This provider-heavy workload has two SQLite carriers in both arms and does not materialize Workboard's extra carrier; the Workboard supplement above measures that separate cost.
Proof and Review
The two update-CLI failures are inherited: both complete failing files ran with Bun and one worker on exact PR head
36eb6137and unchanged main parentbec3ad81, producing 33 passed / 2 failed on each with identical signatures.update-cli.already-current.test.tsandupdate-cli.candidate-admission.test.tsexpect Node 24.22.1 recovery guidance, while upstream #186589 restored the compatibility floor to 24.16.0. The intended refusal and no-side-effects assertions pass before the stale text comparison. This PR changes no update/runtime-policy files. Exact-head CI run: 40656449792.Earlier CI exposed a duplicate synchronous fixture close before native borrowers drained; the redundant hook was removed in favor of the existing fixture owner. An attempted low-level missing-index negative control timed out because reads correctly wait for repair; the corrected authorization-boundary regression passes. Two older setup/reconciliation failures did not reproduce in five full-file runs on each revision and are recorded as non-reproducing, not claimed fixes. No CI rerun was used to chase green. One final-proof setup attempt failed because a relocated probe copy broke its child-loader path; it never reached restart and contributes no product measurement. The corrected probe location produced the complete final run above.
The remaining catalog-routing CI failure is also reproduced on unchanged main source: the complete
codex-account-model-route.product-proof.e2e.test.tsfile passes 3/3 against built candidate36eb6137, while built baseline4a5ec828fails 1/3 with the identical catalog-generation supersession error (the other two cases pass). CI failed all three cases, so the baseline proves the shared failure signature, not equal failure frequency. The harness waits for zero pending agent refusals and completed startup before requestingmodels.list(refresh:true), outside this change's early-read interval. Prepared catalog/startup owners and test helpers are unchanged between that baseline and parentbec3ad81; the nearby model-merge change concerns route metadata, not generation retirement. This existing refresh race is not claimed fixed. Baseline setup first lacked a UI dependency link; after linking the task artifact to the same-lockfile dependencies, the prebuilt product run supplied the failure evidence. No source-only swap was used for built-Gateway attribution. All remaining failed CI jobs are therefore attributed to existing failures; security and other selected jobs passed. Landing uses the scoped inherited-failure exception.