Skip to content

fix: stabilize real Gateway state guard checks - #135448

Closed
steipete wants to merge 1 commit into
mainfrom
codex/fix-state-dir-fixture-readiness
Closed

steipete wants to merge 1 commit into
mainfrom
codex/fix-state-dir-fixture-readiness

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The real-Gateway state-directory suite can authenticate its first client, then time out the next handshake and incorrectly observe an allowed write. Its minimal server announces readiness before the omitted initial health refresh has completed. The suite also installs environment stubs in beforeAll even though Vitest restores them before every test.

Why This Change Was Made

The fixture now awaits the real passive health refresh before its IPC readiness signal. Existing client environment stubs move into beforeEach. Production refusal logic, authentication, timeouts and assertions are unchanged.

User Impact

This repairs test readiness and isolation so the suite consistently exercises authenticated matching paths, mismatched-path refusal and tokenless warnings. It does not change production behavior.

Evidence

The original failure reproduced in file order on a frozen copy of the failing CI head; running the mismatch case first passed. Pass-through tracing captured a correct authenticated hello followed by a 9.1-second synchronous cold plugin-presence load. That work blocked the second handshake. An environment-only repair still failed; waiting for actual health readiness passed all three cases. Independent and maintainer five-file runs each passed all 15 tests, including a real CLI refusal before credential writes. The maintainer run also passed the test type shard, typed lint and configured autoreview.

The cold plugin-presence loader cost is a separate production follow-up; this patch does not hide it or claim a runtime performance fix. The unrelated stdin TTY type error is already fixed by #135407 and is not duplicated here.

Production: 0 lines changed. Tests: +5/-3; test support: +4. No configuration, dependency, schema, protocol or production policy changes.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch remains at 6be1f15 and its full CI run passed. The previous review workflow failed during review generation; its diagnostics classify the failure as retryable and no completed review was published. Please retry this exact head so the native merge gate can validate the completed result.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 3:46 PM ET / 19:46 UTC.

ClawSweeper review

What this changes

The PR makes the real Gateway test fixture wait for its initial health snapshot and resets test environment stubs before each case.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness finding: the patch correctly makes fixture readiness wait for passive health initialization and re-establishes the baseline CLI environment for each case. This current maintainer-authored, maintainer-labeled PR should remain open for normal landing.

Priority: P3
Reviewed head: 6be1f1557d9f9e44677930e4c51e13774ad98ec6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only repair with no correctness or security finding and proportionate validation evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored, test-only repair with no user-visible behavior change; the reported real-Gateway fixture and CI runs are supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored, test-only repair with no user-visible behavior change; the reported real-Gateway fixture and CI runs are supplemental validation.
Evidence reviewed 6 items Introduced readiness ordering: The fixture waits for Gateway startup and then the passive health snapshot before sending its IPC readiness signal.
Health work is awaited: The passive refresh awaits the health collector, matching the work the fixture must settle before test clients connect.
Minimal Gateway omits maintenance: Gateway early startup returns without starting maintenance when minimal test mode is enabled, so the fixture must explicitly settle the health path it needs.
Findings None None.
Security None None.

How this fits together

The CLI state-directory guard connects to a locally running Gateway before allowing writes. Its fixture starts that Gateway and signals readiness before tests exercise matching and mismatched state-directory behavior.

flowchart LR
  A[CLI state guard tests] --> B[Gateway fixture process]
  B --> C[Gateway startup]
  C --> D[Passive health refresh]
  D --> E[Readiness signal]
  E --> F[Authenticated state checks]
Loading

Before merge

  • Complete next step (P2) - The open maintainer-owned PR already contains the focused repair; no separate repair job is appropriate.
Agent review details

Security

None.

PR surface

Tests +6. Total +6 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 9 3 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 9 3 +6

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; tests +5/-3; test support +4/-0 All introduced lines improve test reliability; the CLI state guard and Gateway runtime contract are unchanged.

Technical review

Best possible solution:

Land the focused readiness and environment-isolation repair so the real-Gateway state guard reliably covers authenticated refusal behavior.

Do we have a high-confidence way to reproduce the issue?

No live reproduction was run in this read-only review. The fixture sequence is source-supported, and the PR body provides order-sensitive failure and after-fix run evidence.

Is this the best way to solve the issue?

Yes. Settling startup work at the fixture readiness boundary and reapplying test-owned environment state before each case targets the observed race without altering production refusal, authentication, or timeout logic.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8f8e77414965.

Labels

Label changes:

  • add P3: This is a low-risk test-suite reliability repair with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored, test-only repair with no user-visible behavior change; the reported real-Gateway fixture and CI runs are supplemental validation.

Label justifications:

  • P3: This is a low-risk test-suite reliability repair with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored, test-only repair with no user-visible behavior change; the reported real-Gateway fixture and CI runs are supplemental validation.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit ef44eab adds src/cli/state-dir-gateway-check.server.test.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ef44eab5ed83; files: src/cli/state-dir-gateway-check.server.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the merged state-directory proof rewrite in #135495 (5131048). The real-Gateway test now obtains one authenticated hello and feeds its reported paths to the comparison owner; it no longer uses the per-test environment overrides or repeatedly races the guard’s offline deadline that this PR repaired. The callback/refusal wiring has separate focused coverage, and the production guard is unchanged.

I checked current main eee230d0b763d30e737aaf0c28c7277aa30adcf9 and reran:

node scripts/run-vitest.mjs src/cli/state-dir-gateway-check.test.ts src/cli/state-dir-gateway-check.server.test.ts src/cli/state-dir-gateway-check.process.test.ts src/gateway/health/collector.channel-discovery.test.ts

All 13 tests passed, including the real authenticated Gateway hello, actual CLI refusal before a model-credential write, and passive health discovery. The health collector also now avoids dormant credential discovery. Closing this test-only alternative; no part of it is counted toward the performance campaign.

@steipete steipete closed this Sep 1, 2026
@RomneyDa
RomneyDa deleted the codex/fix-state-dir-fixture-readiness branch October 22, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant