Skip to content

test(review): drive review and apply rules through behavior instead of source text - #1807

Merged
obviyus merged 1 commit into
mainfrom
cleanup-r7-review-apply-tests
Oct 9, 2026
Merged

obviyus merged 1 commit into
mainfrom
cleanup-r7-review-apply-tests

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Remove every source-text test from the review/apply cluster (row 7 of the cleanup plan). Each test that read src/** or raw .github/** text is now a behavior test through a real entry point, one parsed-YAML guard, or deleted with a named covering test.

Test (file) Class Replacement
structural cache probes before hydration… (review-comment-rendering) (c) + (a) Loop order, lease-before-carry, revalidation, preflight, provenance and metrics are covered by review-command-workflow.test.ts "scheduled structural-clean / content-clean …" (drives createReviewCommandWorkflow; hydration throws on a structural hit, structuralFetches >= 2, inspection call, runner_preflight_v1, metrics file). Gaps closed in that test: the carried report now must carry the lease owner and comment id, and a new content-held scenario asserts coordination-held.json gets the winning lease expiry. gitInfo release pins → new review-blob-hydration.test.ts "review git info trusts only the release marked latest and fails closed otherwise" (real git, fake gh release list). Pull-check digest pins deleted: reviewStructuralRecordFromGraphql returns no PR record without a valid checks digest (fail closed). releaseStateComplete short-circuit pin deleted: release identity is part of the fingerprint (review-structural-cache.test.ts "changed author association or release identity forces hydration").
spoofed durable markers cannot suppress a bot-owned start lease (review-comment-rendering) (a) Same test, source part replaced: a contributor comment with a copied fresh lease marker and a lower id does not win the election over the bot lease (reviewStartLeaseWinnerCommentIdForTest, existing export).
apply retains its mutation lease until the item action is complete (review-comment-rendering) (c) + (a) Release-after-close and "never sweeps another lease" covered by apply-label-sync.test.ts "exact publication rechecks after batched labels and again before close" (ownedLeaseReleaseIndex > closeIndex, no DELETE of the superseded lease). The close-time recheck in apply-close-execution had no behavior coverage, so new apply-lease-guards.test.ts "apply does not close an item after it loses its mutation lease during close execution" drives exported executeApplyClose.
recovery cleanup preserves durable-review ordering… (review-comment-rendering) (c) apply-label-sync.test.ts "exact publication rechecks after batched labels and again before close" (exact publication with clawsweeper-recovery-stuck: one batched label edit after the durable comment PATCH, recovery label gone) and "apply-decisions clears a recovery escalation only after publishing a completed PR review".
review and apply paths persist and revalidate the cursor (review-activity-cursor) (a) "the review report persists the cursor that apply revalidates": real report writer → frontMatterValue → real createApplyReviewActivityGuard (same cursor passes, changed cursor blocks).
scheduled placeholder recovery also performs bounded recovery-label reconciliation (review-placeholder-recovery) (a) The runner-level reconciler test now spawns dist/review-placeholder-recovery.js against a loopback GitHub/queue server and asserts the target-token label DELETE. This covers the CLI wiring that only the slice checked.
sweep status writer preserves non-apply health… (sweep-status) (a) Four tests spawn dist/clawsweeper.js status in a private root (symlinked dist). The old sweepStatusApplyHealthForTest test became one of them and the wrapper is deleted.
canonical hosted review launchers declare required debug retention (review-output-policy) (c) The raw slice only reached the first launcher (oversized branch), which sweep-workflow.test.ts "exact oversized PR admission uses the built predicate…" checks on the parsed step; the CLI itself refuses hosted review without debug retention ("hosted review requires explicit debug retention and destination").
sweep apply jobs wire the default-off product direction policy gate (review-prompt-context) (b) test/structural-invariants.test.ts: parsed sweep.yml env maps; every CLAWSWEEPER_UNCONFIRMED_PRODUCT_DIRECTION_CLOSE_ENABLED value defaults to 'false'.

test/structural-invariants.test.ts is not on main yet, so this PR creates it with the shared header and adds its guard under // review-prompt-context.test.ts guards.

Why

These tests pinned identifiers, slices and call order. Any rename or extraction broke them while behavior stayed the same. The replacements test the behavior through the CLI or the exported owner.

Proof

Counter (count-source-text.mjs), merge base 26c28e7:

File Before (tests/asserts/reads) After
test/review-comment-rendering.test.ts 4/60/11 0/0/0
test/review-activity-cursor.test.ts 1/3/5 0/0/0
test/sweep-status.test.ts 1/6/3 0/0/0
test/review-placeholder-recovery.test.ts 1/5/1 0/0/0
test/review-output-policy.test.ts 1/2/1 0/0/0
test/review-prompt-context.test.ts 1/2/1 0/0/0
TOTAL (repo) 327/3852/364 318/3774/342

export function *ForTest in src: 10 → 10. Unique *ForTest names in src: 96 → 95 (sweepStatusApplyHealthForTest removed with its runtime re-export). Diff: +418 / −297 (src −10 lines).

Mutation proofs (local src or workflow edit, rebuild, run the test, revert):

Mutation Failing test
statusCommand: drop the state.startsWith("Apply ") clear an apply status update without health clears stale apply health but keeps the last close
sweepStatusApplyHealth: no run_url stamp sweep status stamps the current run URL on new apply health
writeSweepStatus: drop previousStatus?.lastCloseApplyHealth ?? non-close apply health keeps the previous last close health
sweepStatusApplyHealth: do not keep previous health sweep status keeps the retained apply health and its run URL when no health is given
report document writes review_activity_cursor: unknown the review report persists the cursor that apply revalidates
recovery CLI calls runReviewPlaceholderRecovery({}) the scheduled recovery CLI clears the recovery label of an exact-head completed PR
lease election trusts a contributor author spoofed durable markers cannot suppress a bot-owned start lease
carried structural hit writes review_lease_owner: unknown scheduled structural-clean …
coordination-held.json never written scheduled content-held …
gitInfo uses releases[0] review git info trusts only the release marked latest…
all currentApplyMutationLeaseBlockReason() calls in close execution → null (also: keep only the first) apply does not close an item after it loses its mutation lease during close execution
sweep.yml default 'false' → 'true' sweep workflow keeps the product-direction close gate off by default

Coverage checks for (c) claims (mutation, covering test fails): lease released before executeApplyClose and recovery batch flushed before publication → apply-label-sync "exact publication rechecks after batched labels and again before close"; structural revalidation skipped, or hydration on a structural hit → "scheduled structural-clean …".

Shipped CLI path (status, touched by the wrapper removal): main (merge base, built from git archive) and branch give byte-identical status JSON (except updated_at) for an Apply started update over a retained close health.

pnpm run check: green at f51797dca (exit 0; node tests 7003, pass 6966, fail 0). After rebasing onto main for a clawsweeper-runtime.ts conflict, re-run at 194ca9b1b: 7005 tests, one failure in the known load flake test/repair/command-proof-consumer.test.ts (180 s timeout); re-run alone it passes 29/29. Lint, format and typecheck clean.

Codex dispositions

codex review --base origin/main: "No actionable defects were found against the supplied merge base." Nothing to fix.

Merge Danger

Low. Src change is the removal of an unused test-only wrapper and its re-export; no runtime path changes. test/structural-invariants.test.ts is also created by the open cleanup-r7 branches; whichever merges second resolves the add/add conflict by keeping both sections.

@clawsweeper

clawsweeper Bot commented Oct 9, 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.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces source-text assertions with behavioral tests for review, apply, recovery, and status commands, and removes an unused test wrapper.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful behavioral coverage with command-level proof, no production growth, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The body reports built status CLI parity for Apply started over retained close health, and source inspection confirms status and recovery subprocesses exercise the shipped owners. Those command tests and the status writer have identical blobs to the preceding reviewed head; mutation checks support the remaining behavioral replacements. The persisted status format and writer are unchanged, so no migration is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes
Reason: Source-text assertions make harmless refactors fail while providing weak protection against behavioral regressions. The replacements improve maintenance value without changing production behavior.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still contains the brittle assertions it replaces, and the review found no actionable patch defect.

Priority: P3
Reviewed head: 89f344678704a6ec8c4a220f92529a48af78965a

Before merge

None.

Findings

None.

Agent review details

How this fits together

ClawSweeper records reviews of GitHub items and checks freshness and ownership before publishing decisions or closing items. These tests exercise those safeguards and the commands that write status and reconcile recovery labels.

flowchart TD
  A[Test fixtures] --> B[Review and apply owners]
  A --> C[Status and recovery commands]
  B --> D[Recorded reviews and guarded actions]
  C --> E[Status files and loopback HTTP]
  D --> F[Behavior assertions]
  E --> F
Loading

Technical review

Best possible solution:

Keep behavioral coverage in the existing command entry points and production owners while preserving the established safeguards.

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

Not applicable: this PR replaces brittle tests rather than fixing a reported runtime bug; the body records mutation checks for the protected behaviors.

Is this the best way to solve the issue?

Yes: exercising existing command entry points and owners is a maintainable replacement for source-text assertions, and existing publication tests cover the removed ordering checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3009fdbb5be9.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Narrow production scope: The introduced production diff removes only the testing wrapper and its runtime re-export. Status serialization, configuration, authorization, and final mutation owners are unchanged; no OpenClaw Bay change or stored-data migration is needed. (src/clawsweeper-sweep-status.ts:44, 89f344678704)
  • Command coverage: Status tests launch the shipped CLI in private roots and assert retained health, originating run URLs, stale-health clearing, and last-close preservation. Recovery coverage launches the shipped recovery CLI against loopback HTTP and observes the label deletion with the target write credential. (test/sweep-status.test.ts:15, 89f344678704)
  • Deleted ordering coverage remains: Existing publication coverage asserts that label changes follow durable comment publication, closing precedes release of the owned lease, another lease is never deleted, and the recovery label is removed. (test/apply-label-sync.test.ts:1044, 89f344678704)
  • Cache and lease replacements: The workflow fixture checks checkout inspection, structural revalidation, carried lease identity, and the winning lease's retry expiry. The close-owner fixture verifies that losing the mutation lease prevents closing. (test/review-command-workflow.test.ts:1244, 89f344678704)
  • Contributor proof and continuity: The captured PR body reports byte-identical status JSON, except updated_at, between the built base and branch for Apply started over retained close health, plus mutation checks for the replacement tests. Its captured source revision is 27a40bf797228a603633a4c7921e862c0c2b2a1489984d86560f8e07bfca34a5. GitHub blob identities confirm that the status writer, status tests, and recovery CLI test are unchanged from the preceding reviewed head 194ca9b. (test/sweep-status.test.ts:68, 89f344678704)
  • Current-main necessity: Pinned main still contains the removed wrapper and source-text tests. The verified test merge has exactly the pinned main and PR head as its recorded parents and preserves the separate main-only workflow-test cleanup. (src/clawsweeper-sweep-status.ts:58, 3009fdbb5be9)

Likely related people:

  • Peter Steinberger: Raw commit 4b5246a adds src/clawsweeper-sweep-status.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b5246acdf7e; files: src/clawsweeper-sweep-status.ts)

Review metrics

Metric Value Why it matters
Production versus test lines Production +0/-10; tests +410/-287; changelog +1 The behavioral coverage adds no production code and removes an unused testing wrapper.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is testing cleanup with unchanged user-facing runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-09T09:28:21.814Z sha f51797d :: needs changes before merge. :: none
  • reviewed 2026-10-09T10:02:58.229Z sha 194ca9b :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 6:23 AM ET / 10:23 UTC (Revision 3).

@obviyus
obviyus force-pushed the cleanup-r7-review-apply-tests branch from f51797d to 194ca9b Compare October 9, 2026 09:58
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@obviyus
obviyus force-pushed the cleanup-r7-review-apply-tests branch from 194ca9b to 89f3446 Compare October 9, 2026 10:20
@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 307fe46 into main Oct 9, 2026
12 checks passed
@obviyus
obviyus deleted the cleanup-r7-review-apply-tests branch October 9, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant