Repository navigation
test(audit): event-loop probes fail on shared-runner jitter instead of real blocking [AI-assisted] - #128228
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 5:59 AM ET / 09:59 UTC. ClawSweeper reviewWhat this changesThis PR replaces two audit-writer timing probes with test-only checks that held-lock transactions run with SQLite busy waiting disabled. Regression provenancePossible regression — probable (failure trace; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for normal maintainer review: the deterministic SQLite-boundary assertion is a sound replacement for the flaky timer proxy, and current main does not contain this change. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe audit event writer queues audit metadata into OpenClaw’s shared SQLite state database. Its tests hold a competing write lock and verify that audit persistence fails fast and retries instead of blocking the process. flowchart LR
A[Audit metadata] --> B[Audit writer queue]
B --> C[Shared state database]
D[Competing write lock] --> C
C --> E[Busy-timeout policy]
E --> F[Immediate transaction]
F --> G[Deterministic test assertion]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +54. Total +54 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the held-lock scenarios and their deterministic busy-timeout assertions, then land after exact-head CI confirms the test remains reliable. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: both affected tests hold a competing SQLite write transaction, and the PR body records two CI failures of the previous timer-based assertion. Is this the best way to solve the issue? Yes. Observing the busy-timeout value at the actual immediate-transaction boundary directly protects the non-blocking invariant while retaining held-lock and non-vacuity checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b093f23ee1f3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
eb04c7a to
396f930
Compare
Co-authored-by: Sean Bennett <[email protected]>
396f930 to
e6dd8fc
Compare
Co-authored-by: Sean Bennett <[email protected]>
|
Land-ready status for head The latest review's remaining item was "merge only after the remaining exact-head checks complete successfully" — those have since finished:
I also refreshed the PR description: it still described my original proposal (widening the probe bound to 1 s), which the rewrite replaced with the direct No proof gaps known. Test-only change; no production code touched. |
|
Merged via squash.
|
…f real blocking [AI-assisted] (openclaw#128228) * test(audit): prove nonblocking writes without timer jitter Co-authored-by: Sean Bennett <[email protected]> * test(audit): restore observed SQLite methods without lint violations Co-authored-by: Sean Bennett <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Related: #128223
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Resolves a problem where PR CI fails on an unrelated shard when a shared runner is under load.
src/audit/audit-event-writer.test.tsproved the audit writer stays non-blocking under a held SQLite write lock by scheduling a 25 ms timer and asserting it fired within 250 ms. That is a proxy for the real invariant, and it fails whenever runner scheduling jitter delays the timer — with no product regression involved.Observed twice on #128223, both in
checks-node-compact-large-6:expected 275.14786399999866 to be less than 250expected 278.6432880000066 to be less than 250, same test, same lineTwo of three runs of that shard tripped the probe.
Why This Change Was Made
The probes now assert the invariant they actually exist to protect rather than a timing proxy.
observeNonblockingSqliteTransactionswraps the state database'sexec, and everyBEGIN IMMEDIATEthe audit writer issues is checked to run withbusy_timeout = 0, throwing if it is ever non-zero. A new state-database lifecycle listener captures the busy timeout at open time, and the tests additionally assert the contender still holds its transaction (contender.isTransaction) and that at least one observed transaction was recorded — so the assertions cannot pass vacuously.The regression this guards is a synchronous SQLite open/insert that waits out
OPENCLAW_SQLITE_BUSY_TIMEOUT_MS(5 s,src/state/openclaw-state-db-contract.ts). Assertingbusy_timeout === 0at each transaction detects that failure mode directly and deterministically, with no dependence on wall-clock timing, so the test no longer has a jitter surface at all. The wrapper restores the originalexecown-property descriptor (or deletes the own property when the method came from the prototype) so the observation cannot leak into sibling tests. No production code changes.User Impact
No user-visible change. Contributor and maintainer PR CI stops going red on runner scheduling jitter in this audit test, and the test now fails for the real reason — a blocking audit write — instead of for a slow runner.
Evidence
AI-assisted (Claude Code); reviewed and understood.
pnpm test src/audit/audit-event-writer.test.tson headf098cf242a7→Test Files 1 passed (1),Tests 11 passed (11).node scripts/run-oxlint.mjs src/audit/audit-event-writer.test.ts→ exit 0.pnpm check:changed→ exit 0;git diff --checkclean.mainfailure at the time of filing (recentmainreds werechecks-fast-baseline-ratchets); no other open issue or PR tracks this probe.