Repository navigation
test: make archive cursor lease and poison checks deterministic - #2720
simple-agent-manager[bot] merged 10 commits into
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|



Summary
Fix intermittent archive cursor Workers failures seen on unrelated PRs #2605, #2715, #2717 and #2718. Test-only: production archive code, Cloudflare configuration and migrations are unchanged.
Tracking idea:
01M7BXK7EST9F0H8CZGWYF1DB3.Mandatory merge hold: keep this PR DRAFT with
needs-human-review. No merge until coordinator task01M6SHDRB60F28XPA14C7J9XKZapproves the exact full head SHA. The required Specialist Review Evidence check intentionally rejects this label; preserve that hold and report it separately from test/build CI.Validation
pnpm lint— 22 tasks passed; final changed-test ESLint also passed.pnpm typecheck/pnpm build— 40 tasks passed viaturbo run typecheck build --concurrency=2.edcb25580: production source and built module temporarily mutated and restored byte-for-byte:renewLeaseIfDue: lease test RED, observed 1 distinct expiry where >3 is required.failedinstead ofpoisoned.Reproduction method: a local driver starts Vitest on this file and awaits
rerunFiles()sequentially, validating all 15 test results after every execution. Each command is bounded bytimeout 540. Normal test processes are pinned to CPUs 0–1 and 2–3. Stressed processes are pinned to CPUs 4–5 and 6–7 with one additional busy Worker thread per process (bounded at 530 seconds and terminated on exit). Earlier exploratory counts are excluded after the clock and fixture-lifecycle fixes.Staging Verification
Skipped under the task's explicit test-only exception. No production archive code, Cloudflare configuration, migrations, deployment, UI or infrastructure changed.
End-to-End Verification
The unchanged real scheduled sweep drives D1 claims/checkpoints, real Durable Object SQLite and real R2. Instrumentation records actual verifier return values; tests never inject successful verification or lease-renewal results.
Post-Mortem
What broke
Required Durable Object Workers CI failed unrelated PRs due to timing and observation-scope assumptions in archive regression tests introduced with #2700/#2702.
Root cause
In job 132293831140, the failure was
puts.size * 40at line 498: 28 puts accounted for 1,120 ms. The elapsed wall-time assertion at line 497 passed. Setup and RPC overhead consumed the rest of the tick deadline, so delayed puts could not guarantee a minimum write count.In job 132287931176, the expected poison state sequence passed. The failing global
verifiedChunksassertion included 86 chunks from an earlierlateeditfixture whose delayed summary sync repopulated D1. Verification before a thrown flip also does not reach successful-return stats aggregation. The production no-progress poison path behaved correctly.CPU-load repetitions additionally found the original large-session test could spend its 60 real-time ticks before completing copy/verification. It now spends a controlled 25 ms per real write. Another repetition caught a later budget test seeing an old fixture whose summary sync reappeared after isolation deleted its journal. Finished fixtures now retire their summary syncs through the existing serialized write-back path; active tests still exercise real syncs.
Class of bug
Integration tests inferred progress from scheduler throughput and global metrics instead of controlling time and observing the affected session.
Why it wasn't caught
Runner speed and delayed summary alarms made the assumptions pass in individual runs. The original poison assertion could be vacuously true when no successful-return stats were recorded.
Process fix included in this PR
Apply existing rule 62 through controlled clocks, positive session-specific observations, deliberate unrelated work, guard-removal checks, and normal/CPU-loaded full-file repetitions. No new standing steering rule is needed. Separate telemetry follow-up
01M7C1MHXM1B8S9XJ89Y9V5T7Atracks sweep stats omitting work before an eventual exception; production metrics are outside this fix.Post-mortem file
tasks/active/2026-11-14-archive-cursor-determinism.md.Specialist Review Evidence
CodeRabbit Review Evidence
CodeRabbit Notes
Requested once at 2026-11-14T04:32:21Z through trusted main workflow43557146780 after executable CI passed; workflow succeeded and posted the human-authored command. CodeRabbit first acknowledged the command, then changed its reply to “Action not completed — Review rate limited”; its status comment reports “Review limit reached.” The 15-minute wait completed at04:47:40UTC; no review was submitted and there are no inline review findings. Record rate-limit/no-review outcome and continue on the other gates; no repeated request or waiver. Draft status and exact-SHA coordinator hold remain mandatory regardless of outcome.
Exceptions
needs-human-reviewis an explicit coordinator gate, unrelated to CodeRabbit availability.Agent Preflight
Classification
External References
N/A: no external API or dependency change; evidence came from the two CI job logs and existing archive implementation.
Codebase Impact Analysis
apps/api/tests/workers/project-data-archive-resumable-cursor.test.tscontrols timing and assertions;apps/api/tests/workers/support/expected-error-doubles.tsobserves real per-session verifier results.packages/project-data/src/do/archive-sharding.tsandsrc/scheduled/project-data-archive-sharding.tswere traced but remain unchanged.Documentation & Specs
tasks/active/2026-11-14-archive-cursor-determinism.mdrecords the diagnosis, mutation proofs, validation and coordinator merge hold. Public interfaces/specs are unchanged.Constitution & Risk Check
Principle X: smallest test-only change, existing bindings and guards retained. Principle XI: fixed fixture clock steps/lease values exercise existing configuration; no runtime hardcoding introduced. Remaining risk is test-harness behavior under load, covered by full-file repetitions and required Workers CI.
Live CI / resume checkpoint
Head:
afe750203431d17bbac3faef36880c2a73ef7b71. CI43554461638 executable checks all passed, including Test, all3 Workers shards and the required Workers aggregate. E2E Smoke43554461655 passed. Specialist Review Evidence fails only the mandatoryneeds-human-reviewlabel; preserve this coordinator hold. SonarCloud quality gate passed; its one nonblocking S2933 suggestion is to mark the test counter Map reference readonly (maintainability only; no correctness or security finding).CI subscription and obsolete04:35fallback cancelled after CI completed. CodeRabbit wait completed at04:47:40UTC with rate-limit/no-review outcome. Review wait resources are being closed; no further review request is planned. No merge or readiness transition before exact-SHA coordinator approval.
Coordinator handoff
Ready for coordinator review of exact head
afe750203431d17bbac3faef36880c2a73ef7b71: executable CI passed; local proof30normal+30CPU-loaded full-file runs (900tests); all3 guard removals caused intended failures; local reviewers PASS; test-only staging skipped; CodeRabbit rate limited after the completed15minwait. Preserve DRAFT +needs-human-reviewand its intentional Specialist Review Evidence failure. No merge or ready transition before coordinator approval of this exact SHA.