Skip to content

fix: prevent task audit CI flake under load - #123686

Merged
steipete merged 1 commit into
mainfrom
codex/tasks-audit-elapsed-time-bound
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tasks-audit-elapsed-time-bound

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a reproducible CI flake where the task-audit command test failed on a loaded shard once setup took slightly more than an arbitrary one-second allowance. The observed failure was 2701057 ms versus a hard upper bound of 2701000 ms in run 31807211070, job 94789319983; the other 764 tests in the shard passed.

Why This Change Was Made

The assertion now brackets tasksAuditCommand with wall-clock readings and verifies that the reported age falls within that exact interval relative to the flow's authoritative updatedAt. This preserves the existing production behavior and removes the guessed tolerance without widening a timeout.

User Impact

No user-visible runtime behavior changes. Maintainers get deterministic task-audit CI proof even when the command shard is under load.

Evidence

  • Before: run 31807211070, job 94789319983 failed only src/commands/tasks.test.ts:228 with expected 2701057 to be less than 2701000; 764 sibling tests passed.
  • Focused Testbox: corepack pnpm test src/commands/tasks.test.ts passed 25/25 tests on provider=blacksmith-testbox, tbx_01m009vctzfsvgj4mcrarr9jww, run 31808345807.
  • Changed gate: node scripts/check-changed.mjs -- src/commands/tasks.test.ts passed core test typecheck, lint, formatting, and repository guards on provider=blacksmith-testbox, tbx_01m009y982crweeq2h8kh2syka, run 31808475252.
  • git diff --check
  • Structured autoreview: clean, no accepted or actionable findings.

AI-assisted: yes. The change and its test invariant were manually inspected and verified.

@clawsweeper

clawsweeper Bot commented Aug 14, 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 commands Command implementations size: XS labels Aug 14, 2026
@steipete
steipete marked this pull request as ready for review August 14, 2026 14:27
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 14, 2026
@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 Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 10:32 AM ET / 14:32 UTC.

ClawSweeper review

What this changes

The PR replaces a fixed one-second task-audit age tolerance with elapsed-time bounds captured around the audit command.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned protected PR open: it is a correct, narrow test repair, pending a branch refresh and completed exact-head checks before landing.

Priority: P3
Reviewed head: d27b38b9979436f749a9024b7806d0371922994e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned test repair with reported targeted validation and no correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR is exempt from the external real-behavior-proof gate; its body additionally reports focused Testbox validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR is exempt from the external real-behavior-proof gate; its body additionally reports focused Testbox validation.
Evidence reviewed 6 items Current flaky assertion: Current main fixes a TaskFlow's updated timestamp at 45 minutes old, then requires its computed age to remain below an unrelated one-second ceiling.
Authoritative age calculation: The audit owner obtains now from Date.now() and computes ageMs as now minus the flow reference timestamp, so elapsed test setup time legitimately changes the observed value.
Patch bounds the real operation: The proposed test records timestamps immediately before and after tasksAuditCommand, enclosing the single Date.now()-derived value without changing production behavior.
Findings None None.
Security None None.

How this fits together

The task-audit command reads task and TaskFlow registry state, derives stale findings, and emits terminal or JSON diagnostics. This change only stabilizes the command-level test of the reported TaskFlow age.

flowchart LR
  A[Task and TaskFlow registry] --> B[Audit finding calculation]
  B --> C[Task audit command]
  C --> D{Output format}
  D --> E[JSON diagnostics]
  D --> F[Terminal report]
  C --> G[Command-level test]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind and some exact-head checks are unfinished; refresh the branch and require green exact-head checks before landing.
  • Complete next step (P2) - No repair worker is needed; the remaining action is branch refresh and normal exact-head CI validation.
Agent review details

Security

None.

PR surface

Tests +2. Total +2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 4 2 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 2 +2

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +4/-2 The PR changes only the time-sensitive test assertion and adds no runtime behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the elapsed-time bounds, then rebase or refresh the branch and land once the required exact-head checks pass.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the elapsed-time bounds, then rebase or refresh the branch and land once the required exact-head checks pass.

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

Yes—source-reproducible: the audit computes age from Date.now() while the current test imposes an arbitrary one-second upper bound after prior setup work.

Is this the best way to solve the issue?

Yes. Bracketing the command call tests the authoritative elapsed-time behavior without weakening production checks; the fake-timer JSON sibling retains exact deterministic coverage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 530b33e4e372.

Labels

Label changes:

  • add P3: This is a narrow CI-test reliability repair with no user-visible runtime 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 maintainer-authored test-only PR is exempt from the external real-behavior-proof gate; its body additionally reports focused Testbox validation.

Label justifications:

  • P3: This is a narrow CI-test reliability repair with no user-visible runtime 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 maintainer-authored test-only PR is exempt from the external real-behavior-proof gate; its body additionally reports focused Testbox validation.

Evidence

What I checked:

  • Current flaky assertion: Current main fixes a TaskFlow's updated timestamp at 45 minutes old, then requires its computed age to remain below an unrelated one-second ceiling. (src/commands/tasks.test.ts:228, 530b33e4e372)
  • Authoritative age calculation: The audit owner obtains now from Date.now() and computes ageMs as now minus the flow reference timestamp, so elapsed test setup time legitimately changes the observed value. (src/tasks/task-flow-registry.audit.ts:147, 530b33e4e372)
  • Patch bounds the real operation: The proposed test records timestamps immediately before and after tasksAuditCommand, enclosing the single Date.now()-derived value without changing production behavior. (src/commands/tasks.test.ts:212, d27b38b99794)
  • Sibling coverage is deterministic: The routed JSON audit test uses fake timers and asserts an exact age, so it does not share the loaded-shard wall-clock failure mode. (src/commands/tasks-json.test.ts:143, 530b33e4e372)
  • History and ownership: Blame ties the current fixed-tolerance lines to the commit that introduced this task-command test; the same contributor authored the proposed repair. (src/commands/tasks.test.ts:228, c2269f7a6c41)
  • Reported focused validation: The PR body reports a passing Testbox run for src/commands/tasks.test.ts and a passing changed-path gate after the assertion update. (src/commands/tasks.test.ts:212, d27b38b99794)

Likely related people:

  • steipete: Git blame attributes the existing flaky assertion to this contributor's current-main commit, and the proposed repair touches that same invariant. (role: current test introducer and recent task-command contributor; confidence: high; commits: c2269f7a6c41; files: src/commands/tasks.test.ts, src/tasks/task-flow-registry.audit.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the behind branch and wait for the required exact-head checks to complete successfully.

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

Copy link
Copy Markdown
Contributor Author

Land-ready proof for d27b38b9979436f749a9024b7806d0371922994e:

  • Original failure: run 31807211070, job 94789319983 reproduced the arbitrary one-second ceiling failure while 764 sibling tests passed.
  • Focused proof: corepack pnpm test src/commands/tasks.test.ts passed 25/25 on Blacksmith Testbox tbx_01m009vctzfsvgj4mcrarr9jww, run 31808345807.
  • Changed gate: node scripts/check-changed.mjs -- src/commands/tasks.test.ts passed core test typecheck, lint, formatting, and repository guards on tbx_01m009y982crweeq2h8kh2syka, run 31808475252.
  • Exact-head CI: run 31809559284 completed successfully; openclaw/ci-gate job 94812839588 passed.
  • git diff --check, targeted oxfmt --check, and structured autoreview are clean. ClawSweeper reported no findings and judged the wall-clock envelope the best fix.

The optional behind-branch refresh move is intentionally skipped: repository policy treats non-conflicting behind-main drift as advisory, and the native prepare/merge path verifies the current-main test merge. Production LOC is +0/-0; tests are +4/-2.

Provenance: the fixed one-second tolerance was introduced by direct commit 505b23a1372bffa6d5c198af269088384fcef204 by Vincent Koc on June 8, 2026; GitHub reports no associated pull request.

@steipete
steipete merged commit 621220a into main Aug 14, 2026
176 checks passed
@steipete
steipete deleted the codex/tasks-audit-elapsed-time-bound branch August 14, 2026 15:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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