Repository navigation
test(action-ledger): replace source-text ledger tests with behavior tests - #1803
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. What this changesThis PR replaces source-text checks with tests of action receipts, the records of review and apply operations, and removes three unused test exports. Review scores
ProductKind: Test only · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains a useful, distinct maintenance contribution that current main has not incorporated. No actionable correctness defect was found in the pinned patch. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherClawSweeper’s action ledger records review and apply requests, mutation outcomes, and completion as immutable receipts. These tests inspect receipts produced by the existing ledger factories and built commands. flowchart TD
A[Review or apply command] --> B[Action ledger]
B --> C[Request outcome receipts]
B --> D[Completion and publication receipts]
C --> E[Isolated receipt files]
D --> E
E --> F[Behavior assertions]
Technical reviewBest possible solution: Keep receipt assertions at the existing ledger and command boundaries, with narrowly justified structural safety guards. Do we have a high-confidence way to reproduce the issue? Not applicable: this is test maintenance, and the base tests visibly depend on production source names and slices. Tests were not executed during this read-only review. Is this the best way to solve the issue? Yes: assertions on emitted receipts exercise the existing production owners, and the retained safety guards have specific reported mutation-check evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b17e94d1e7ed. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 9, 2026, 7:11 AM ET / 11:11 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
8f4b7da to
662d035
Compare
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
662d035 to
83760ae
Compare
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
83760ae to
9c120b0
Compare
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What
Row 7 cleanup for
test/clawsweeper-action-ledger.test.ts. The 11 tests that readsrc/**or raw.github/**text and checked it with regex,indexOfand slice order are gone. New tests drive the real code:createApplyActionLedgerandcreateReviewActionLedger, writing to a private spool that the test then reads backdist/clawsweeper.js apply-decisionsandretry-failed-reviews) with a fakegh, run from a private copy ofdistso its ledger spool stays inside the fixtureThe
applyPhaseSequenceForTestand apply business-identity*ForTestexports were only there for these tests. They are now removed. The internal helpers lose theForTestsuffix, and their behavior is still checked through real events.apply ledger starts items lazily and chains every receipt in phase order+review ledger starts items lazily and closes every started item(densephase_seq, parent chain, idempotency key does not change with status, batch order or checkpoint, but does change with source revision)review ledger starts items lazily and closes every started itemapply-decisions records per-request receipts before it finalizes the item(CLI). The yield-handler slice is covered byapply-live-state.test.ts› "comment-only sync defers the remaining batch when GitHub is rate limited"mutation_rejected,mutation:false). Lease identity strings and the posted-result object shape were plumbing (c). The seam-driven half is kept.issue editnever deletes the lease, and a throttled lease delete surfaces asskipped_runtime_budgettest/apply-label-sync.test.ts› "a blocked exact close discards staged labels before it writes the report". A CLI fixture would need a PR close-coverage block plus staged labels.--report-pathunder a regular file. The ledger still records item failure → batchfailed→ publicationskipped/not_found{repository, kind: publication}and anapply_reportsha256 equal to the report bytesonMutation:wiring regexes)failed-review-retry finalizes its ledger when the command fails(CLI). The CLI receipts test covers mutation observation (item and batchmutation:true).sweep finalizes open ledger attempts and publishes shards through the signed queue. Parts thatsweep-workflow.test.tsalready covers are dropped: "apply workflow finalization retries only target status…", "apply workflow isolates proof Codex…", "failed-review retry cleanup restores…"comment router publishes command receipts per invocation through the signed queue. Commit-step webhook wiring stays inrepair/comment-router-action-ledger.test.ts. The requeue publisher stays inrepair/command-ops-action-ledger.test.ts.Three (b) guards were added to the domain test files. Each has a one-line reason. The PR does not touch
test/structural-invariants.test.ts:apply-label-sync.test.ts: a blocked exact close discards staged labels before it writes the reportapply-label-sync.test.ts:labels_synced_atis recorded only after a confirmed label mutation (this came from the old "blocked exact close" test)work-plan-artifacts.test.ts: apply-artifacts records an interrupted publication before it rethrowsWhy
These tests broke on any rename or extraction even when behavior did not change. Several of them also only checked text, never what the code does.
Proof
node --test test/structural-invariants.test.ts test/clawsweeper-action-ledger.test.ts test/apply-label-sync.test.ts test/work-plan-artifacts.test.tspasses.pnpm run lint:scriptsand the oxfmt check pass.pnpm run check(run on the previous head): static, build, lint and coverage-changed all pass. The full suite gave 6962 pass, 0 fail. It exited 1 only because of the knowncoverage file is emptyflake.test/clawsweeper-action-ledger.test.ts: before 11 / 179 / 32 → after 0 / 0 / 0test/apply-label-sync.test.ts, 1 intest/work-plan-artifacts.test.ts): 3 / 3 / 3grep -c ForTestoversrc: 401 → 383.Mutation proofs. Each was a temporary src change, then rebuild, then run the test and see it fail, then revert:
parentEventId: state.startEventIdapplyItemBusinessIdempotencyIdentityignoressourceRevisionrevision-41bkey equal)finishReviewActionLedgerskips started itemsknownNoMutation: labelAlreadyExistsErrorin label-mutationsmutation_outcome_unknown,trueinstead ofmutation_rejected,false)catchrethrows instead of savingpublicationErroractiveApplyMutationLease = nullon rate limitlease deletecalled)releaseActiveApplyMutationLeasekept_openinstead ofskipped_runtime_budget)failure: commandErrorin failed-review retrycompletedinstead offailed)discardIssueLabelBatch()in the blocked closeapply-label-sync): blocked exact close discards staged labelsrememberPublishedLabelSync()unconditionalapply-label-sync): labels_synced_at only after a confirmed mutationrecordPublicationin the apply-artifacts catchwork-plan-artifacts): apply-artifacts records an interrupted publicationCoverage check for the (c) claims. With these mutations,
apply-*.test.ts,clawsweeper.test.ts,failed-review-retry,reconcile,work-plan-artifacts,manual-publication-authorityanddecision-packetsall still passed:discardIssueLabelBatch()in the blocked closerememberPublishedLabelSyncunconditionalThat is why these three properties now have structural guards. Each guard failed under its mutation and passed after the revert.
Codex dispositions
codex review --base origin/mainran once on head 738e9bc. Build and all 27 focused tests passed. One finding:test/clawsweeper-action-ledger.test.ts:425: the fixture'srepoRelativePathusedrelative(root, filePath). On Windows that returnsrecords\41.md, and the ledger rejects backslashes insubject.recordPath. Fixed: the fixture now normalizes separators to/, the same way the productionrepoRelativePathinsrc/clawsweeper-runtime.tsdoes.Merge Danger
Test-only, except for removing unused
ForTestexports and renaming two internal apply-ledger helpers. Runtime behavior does not change.The three order-of-calls properties that no behavior test covers are now kept by minimal guards in
test/apply-label-sync.test.tsandtest/work-plan-artifacts.test.ts.The CLI tests copy
distonce per file, so this file takes about 25–45 s under load.