Repository navigation
fix: keep state-dir Gateway CI proof reliable under load - #135495
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This is also the state-directory failure blocking the native Mermaid rollout in #135342 and #135470. The same mismatch case fails on Android's exact-head fallback run and the iOS run. I reproduced the original three-case file locally without changing the timeout. In the diagnostic run, the first connection received an authenticated hello, then its status request hit the three-second deadline; the next case received no hello before its deadline. The mismatch case also lost the We will use this canonical repair once it lands. Avoiding the unused status request after receiving the hello is a separate owner-level latency follow-up; Ready to land at Production delta is zero; tests are +69/-40. The latest ClawSweeper review has no before-merge moves. This removes the CI fixture race while preserving the production three-second offline policy. Thanks @lzhan011. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 3:55 PM ET / 19:55 UTC. ClawSweeper reviewWhat this changesThe PR captures one authenticated Gateway hello with a test-only deadline and reuses its paths to test matching and mismatched CLI/Gateway state-directory outcomes. Regression provenancePossible regression — probable (failure trace; reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open. The introduced test-only refactor directly addresses the recorded CI race while current main still contains the timing-sensitive three-case integration test; no blocking correctness or security concern was found. Priority: P2 Review scores
Verification
How this fits togetherCLI setup commands use the state-directory guard to avoid writing credentials or configuration into a tree the running Gateway will not use. This test starts a real token-authenticated Gateway, obtains its hello snapshot, and checks the comparison owner’s allow/refuse results. flowchart LR
A[CLI state paths] --> D[Path comparison]
B[Token-authenticated Gateway] --> C[Gateway hello snapshot]
C --> D
D --> E[Allow matching paths]
D --> F[Refuse mismatched paths]
G[Integration test] --> B
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +29. Total +29 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the focused test-owner refactor after the normal exact-head merge checks complete, preserving the production guard’s offline-allow policy unchanged. Do we have a high-confidence way to reproduce the issue? Yes. The supplied CI trace shows the failure when the authenticated Gateway call crosses the three-second guard deadline, and current main still routes this test through that unchanged deadline. Is this the best way to solve the issue? Yes. Separating the real hello contract from deterministic path comparison removes the timing race without increasing the production timeout, retrying production behavior, or weakening the refusal invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e4100aca8ee9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #134403
What Problem This Solves
Fixes an issue where the state-directory Gateway integration proof could fail under CI load even though the intended production behavior was correct. A real authenticated Gateway hello can take longer than the guard's intentional 3-second offline-allow window, so the old test could observe
allowand falsely expectrefuse.Why This Change Was Made
The test now separates the two contracts it was conflating:
stateDirandconfigPath;onHelloOkpath refuses without falling back to installed-service inspection.The live test reuses one Gateway process and one authenticated hello. Its request deadline is 60 seconds and its Vitest deadline is 120 seconds, both owned only by the test. The production 3-second offline-allow policy is unchanged.
Rejected alternatives were increasing the production timeout, retrying the owner call, weakening the expected refusal, or keeping redundant live tokenless coverage. Those approaches would change or mask the production contract; the existing deterministic credential-error/protocol-probe test already owns the tokenless fallback.
User Impact
No shipped runtime behavior changes. Contributors and maintainers get a deterministic state-directory Gateway proof that remains meaningful under loaded CI runners instead of racing the production offline timeout.
Root cause and owner:
src/cli/state-dir-gateway-check.server.test.tstimed a real authenticated hello through the productioncheckCliGatewayStateDirguard, whilesrc/cli/state-dir-gateway-check.tsintentionally treats an ordinary transport timeout as offline and allows the command. The repair stays in the test owner; no production seam was added.Scope: test-only, 2 files, +69/-40. Production LOC: 0. No API, config, protocol, dependency, retry, production timeout, SQLite, or persistence change. No exact active duplicate was found; #134403 introduced the original test and is linked only as provenance.
Exact head:
7a3996a1945a7289fab940d1e95d4edfb80e31e5.Evidence
Authoritative failing-before evidence:
checks-node-compact-small-50:refuses mismatched authenticated hello pathsexpected{ kind: "refuse" }but received{ kind: "allow" }. The matching and mismatched authenticated cases took about 3.26s and 3.33s, straddling the 3-second offline-allow deadline.Corroborating pre-rebase local run on trusted main
01ea77ec3dae416a3c43cced10e7ae45e4147983:allowin 3.385s, and tokenless returnedallowin 3.245s.Post-fix evidence on the exact head:
pnpm check:changed: exit 0, including formatting, typecheck, dead-export scans, and changed-file lint;Test-audit judgment: the real call proves the external Gateway hello boundary once; the pure comparison reuses its captured evidence for both outcomes; deterministic unit coverage protects callback wiring and fallback ownership. This avoids redundant live cases while preserving the observable invariant.