Skip to content

fix(cli): keep state-custody tests independent of short deadlines - #155294

Merged
jalehman merged 2 commits into
mainfrom
openclaw/stabilize-cli-state-custody-tests
Sep 22, 2026
Merged

jalehman merged 2 commits into
mainfrom
openclaw/stabilize-cli-state-custody-tests

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes CLI state-custody tests failing before reaching the lock scenario when authentication/handshake work consumes their incidental two-second deadline.

User Impact

No user-visible change. CLI timeouts, authentication, state lifecycle, and production code are unchanged. This makes the integration proof about storage custody, while short-deadline behavior stays independently enforced.

Why This Change Was Made

Give only the three custody cases a bounded 10-second RPC integration budget, retain the explicit 2-second channel probe payload, and record elapsed handshake/custody/exit phases. The real CLI subprocess must authenticate before custody is acquired, receive hello while custody is held, make exactly one intended RPC, exit successfully, and leave state byte-identical.

Extend the existing fake-clock Gateway-call timeout table with a hello at 4ms of a 5ms budget, teardown settlement, no late dispatch, and timer cleanup. Move that table into narrow test support to respect the existing file-growth ratchet without duplicating its mock fixture.

Credit: requested and co-authored by @jalehman.

Work sessions

Evidence

  • Original failing job: all three failures had connection/close but no connect request, no RPC, and no held coordinator. Decoded job selection contains only this file; no preceding-file leak is implicated. Clean-main local replay passed 15/15. The exact historical runner bottleneck remains unproven; this does not claim a production stall fix.
  • Controlled before/after: temporarily delaying the challenge by 2100ms makes all three original-budget cases fail before custody; all three revised-budget cases pass with exact auth/RPC/state assertions. Temporary delay removed. Normal local challenge→connect measured 304–479ms versus 0–1ms hello→RPC; integration budget does not reset after authentication.
  • Negative controls: temporarily restoring writable hello-token persistence makes all three custody cases fail with StateDatabaseCoordinatorContentionError, held custody, and zero RPCs. Temporarily clearing the wrapper deadline on hello makes both immediate/delayed-hello deadline cases fail at the 5ms stop assertion. All production mutations reverted.
  • Final real-process file: 15/15, 39.56s wrapper wall / 33.29s Vitest wall (about 26s test time), one worker. Cold baseline including compiler preparation: 59.56s wall. These existing subprocess cases protect the real CLI/RPC/native-lock/storage boundary; no new process boots are added.
  • Final deadline/error owner group: 45/45, 13.19s wrapper wall / 5.11s Vitest wall, three deadline cases ~2ms each. Full owner run reached 161/164 after removing ambient Gateway credentials; three existing destination-binding cases conflict with this agent-exec environment’s message guard. The targeted error/deadline group passes; no real Gateway was used.
  • Independent autoreview: scoped-clean through P2.

Changed gates: all 25 core-test typecheck graphs, boundary checks, line-cap/assertion ratchets, dependency/plugin guards, and dead-export scans passed. Scoped lint passed after removing one redundant default type argument; formatting and git diff --check passed. Sibling coverage passed: client device-auth 19/19 and channel-status command flow 16/16 (10.40s combined wrapper wall). Exact-head CI is in progress; hosted test durations are not available yet. The full 20-standalone/3-shard flake matrix was not run; historical runner conditions were not reproduced, and repeated green runs are not presented as causal proof.


View the OpenClaw team session

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 22, 2026
Co-authored-by: jalehman <[email protected]>

OpenClaw-Publication: 18f29d14-7e86-4854-bdc4-0529dbde2803
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/stabilize-cli-state-custody-tests branch from cd147ac to b95d137 Compare September 22, 2026 00:20
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 22, 2026 00:20
@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 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 8:40 PM ET / September 22, 2026, 00:40 UTC.

ClawSweeper review

What this changes

The PR gives three CLI storage-custody tests a larger integration budget, records handshake phases, and strengthens fake-clock coverage of Gateway request deadlines and cleanup.

Merge readiness

✅ Ready for maintainer review

Keep open: the focused test repair remains useful on current main, preserves the custody contract, and introduces no blocking defect. The maintainer-labeled PR is not eligible for cleanup closure.

Priority: P3
Reviewed head: b95d137a26bfbaba31c46372bb2b494d0e120c2e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test repair with meaningful negative controls and preserved assertions; no blocking defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The bot-authored test-only PR is exempt from external-contributor runtime proof; its recorded real CLI subprocess runs exercise authentication, held storage custody, request completion, and unchanged state.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The bot-authored test-only PR is exempt from external-contributor runtime proof; its recorded real CLI subprocess runs exercise authentication, held storage custody, request completion, and unchanged state.
Evidence reviewed 7 items Introduced scope: The pinned merge-base-to-head diff changes only tests and test support; production deadlines, authentication, dependencies, and storage behavior are unchanged.
Custody assertions remain meaningful: The real subprocess must supply the seeded device authentication, receive hello after custody acquisition, send exactly one intended request, exit successfully, and leave the state directory byte-identical. The explicit channel-probe payload remains two seconds.
Deadline coverage: The expanded table covers silent, immediate-hello, and hello-at-4ms scenarios against a 5ms deadline, including teardown settlement, timer cleanup, and rejection of late dispatch. The existing fixture resets client callbacks and restores real timers.
Findings None None.
Security None None.

How this fits together

Gateway-backed CLI commands authenticate, send requests, and exit while respecting local storage ownership. These tests check that reads work while another process holds storage custody and that request deadlines still stop outstanding work.

flowchart LR
  A[CLI subprocess] --> B[Device authentication]
  B --> C[Storage custody held]
  C --> D[Gateway request]
  D --> E[Successful exit and unchanged state]
  F[Fake clock] --> G[Deadline and cleanup checks]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +89. Total +89 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 131 42 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 131 42 +89

Review metrics

Metric Value Why it matters
Deadline coverage 2 → 3 fake-clock cases; 0 additional subprocess boots The added boundary case strengthens timeout coverage without expanding expensive process integration work.

Technical review

Best possible solution:

Keep storage-custody integration checks independent of handshake speed while enforcing deadline semantics with deterministic owner-level tests.

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

No independently established reproduction of the historical runner failure; the PR records a controlled slow-handshake reproduction, and source confirms the incidental deadline coupling.

Is this the best way to solve the issue?

Yes: separating the integration budget from deterministic deadline coverage preserves the storage invariant without changing production behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3aa130d87165.

Labels

Label changes:

  • add P3: This is a bounded test-reliability improvement 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: The bot-authored test-only PR is exempt from external-contributor runtime proof; its recorded real CLI subprocess runs exercise authentication, held storage custody, request completion, and unchanged state.

Label justifications:

  • P3: This is a bounded test-reliability improvement 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: The bot-authored test-only PR is exempt from external-contributor runtime proof; its recorded real CLI subprocess runs exercise authentication, held storage custody, request completion, and unchanged state.

Evidence

What I checked:

  • Introduced scope: The pinned merge-base-to-head diff changes only tests and test support; production deadlines, authentication, dependencies, and storage behavior are unchanged. (b95d137a26bf)
  • Custody assertions remain meaningful: The real subprocess must supply the seeded device authentication, receive hello after custody acquisition, send exactly one intended request, exit successfully, and leave the state directory byte-identical. The explicit channel-probe payload remains two seconds. (src/cli/gateway-backed-exit-health.process.test.ts:158, b95d137a26bf)
  • Deadline coverage: The expanded table covers silent, immediate-hello, and hello-at-4ms scenarios against a 5ms deadline, including teardown settlement, timer cleanup, and rejection of late dispatch. The existing fixture resets client callbacks and restores real timers. (src/gateway/call-deadline.test-support.ts:18, b95d137a26bf)
  • Still necessary on main: Fetched main retains the two-second custody-test RPC budget and the original two-case deadline table; it does not contain this test repair. (src/cli/gateway-backed-exit-health.process.test.ts:187, 3aa130d87165)
  • Recorded validation and limitations: The captured PR body reports controlled 2100ms challenge-delay failures before the change and success afterward, storage-write and deadline-reset negative controls, 15/15 subprocess cases, and 45/45 focused deadline/error cases. It discloses three broader environment-sensitive failures, an unproven historical runner bottleneck, and an unrun flake matrix. Tests were not executed during this read-only review. (b95d137a26bf)
  • Feature history and release boundary: Git history and GitHub identify the custody coverage with merged fix(channels): keep status reads available during state maintenance #153445 on September 20. The latest release, v2026.9.5, was published September 19; that earlier product fix does not supersede this subsequent test repair. (src/cli/gateway-backed-exit-health.process.test.ts:166, f36e5d365039)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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.

@jalehman
jalehman merged commit 2ffd946 into main Sep 22, 2026
168 of 169 checks passed
@jalehman
jalehman deleted the openclaw/stabilize-cli-state-custody-tests branch September 22, 2026 13:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime 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: S 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.

2 participants