Skip to content

Enforce repair contract before checkpointing - #336

Closed
Jhacarreiro wants to merge 1 commit into
openclaw:mainfrom
Jhacarreiro:fix/repair-contract-enforcement
Closed

Jhacarreiro wants to merge 1 commit into
openclaw:mainfrom
Jhacarreiro:fix/repair-contract-enforcement

Conversation

@Jhacarreiro

Copy link
Copy Markdown
Contributor

Summary

Enforce the repair contract before creating checkpoint commits.

The executor now checks the real changed-file set against the fix artifact's likely files / validation-derived contract before checkpointing. This catches repairs that touch no relevant files or only unrelated lockfiles.

Scope

Model-agnostic ClawSweeper executor behavior only. No model backend, OpenAI-compatible, adapter, provider-specific code, or review/result normalization.

Validation evidence

corepack pnpm run build:repair
node --test test/repair/execute-fix-artifact-source.test.ts

Result:

build:repair: passed
execute-fix-artifact-source.test.ts: 7/7 tests passed

The new regression covers:

repair contract enforces likely file touch before checkpointing

It also verifies the git porcelain path parser uses line.slice(3) instead of trimming before offset parsing.

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 19, 2026, 3:59 AM ET / 07:59 UTC.

Summary
This PR adds a repair-contract gate to src/repair/execute-fix-artifact.ts, adjusts conflict fallback prompt wording, and adds a source-inspection test for the gate.

Reproducibility: yes. for the patch blockers: CI reproduces the lint failure, and source inspection of the PR head shows the contract runs only before the first checkpoint while later checkpoint paths remain. No live repair-worker proof reproduces the intended end-to-end gate behavior.

Review metrics: 3 noteworthy metrics.

  • Patch surface: 2 files changed, +144/-1. The file count is small, but one changed file is the repair executor checkpoint path.
  • Checkpoint coverage: 1 new guard before 4 checkpoint call sites. The measured placement explains why later repair-fix checkpoint commits can bypass the new contract.
  • Current checks: 1 failing pnpm check job. The branch is not merge-ready while lint:repair fails on a newly added line.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Remove the duplicated conflict fallback prompt and rely on the existing conflict-first prompt helper.
  • [P1] Guard every checkpoint path with the repair contract and add focused regression coverage for review-fix checkpoint bypass.
  • [P1] Fix the lint failure and add redacted terminal logs from a real repair-worker run exercising the gate.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides build and source-test output only; it does not show an after-fix repair-worker run proving the checkpoint gate in a real setup. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] No real repair-worker run proves the gate catches unrelated or lockfile-only edits before checkpointing; the posted evidence is build/source-test output only.
  • [P1] The diff changes fail-closed repair automation behavior, so legitimate repairs with stale or incomplete likely_files could be blocked without live upgrade proof.
  • [P1] Because later validation/review-fix checkpoint paths remain unguarded, merging could create false confidence that every checkpoint commit satisfies the repair contract.

Maintainer options:

  1. Guard every checkpoint before merge (recommended)
    Centralize commitCheckpointIfNeeded() behind a contract-enforcing helper or call the contract immediately before each checkpoint path, then fix lint and add proof.
  2. Accept first-checkpoint-only hardening
    Maintainers could intentionally accept a narrower guard, but they would own the remaining unguarded review-fix and final-sync checkpoint paths.
  3. Pause until live proof exists
    If no redacted repair-worker proof can be posted, pause or close this branch and return with a smaller proof-backed patch.

Next step before merge

  • [P1] Contributor and maintainer follow-up is needed because proof is test-only and the patch has line-level automation blockers; this should not enter a repair lane until real behavior proof exists.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds local git/file contract checks and no new dependencies, secrets handling, or workflow permissions.

Review findings

  • [P1] Remove the duplicate conflict prompt branch — src/repair/execute-fix-artifact.ts:1974-1987
  • [P2] Guard the later checkpoint paths too — src/repair/execute-fix-artifact.ts:2129-2134
  • [P2] Fix the lint-blocking path split — src/repair/execute-fix-artifact.ts:2713
Review details

Best possible solution:

Keep the narrow repair-contract idea, but remove the duplicated conflict prompt changes, centralize checkpointing through a guarded helper or re-run the contract before every checkpoint, fix lint, and add focused tests plus redacted live repair-worker proof.

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

Yes for the patch blockers: CI reproduces the lint failure, and source inspection of the PR head shows the contract runs only before the first checkpoint while later checkpoint paths remain. No live repair-worker proof reproduces the intended end-to-end gate behavior.

Is this the best way to solve the issue?

No as submitted. The narrow contract gate is a reasonable direction, but it should reuse the existing conflict-first prompt path, guard every checkpoint boundary, pass lint, and include real behavior proof.

Full review comments:

  • [P1] Remove the duplicate conflict prompt branch — src/repair/execute-fix-artifact.ts:1974-1987
    Current main already sends conflict-first guidance through buildFixPrompt() via renderRebaseResult() whenever rebaseResult.status is conflicts. This added fallback-reason copy creates a second source of truth for the same behavior and pulls unrelated conflict-prompt churn into a repair-contract PR; drop it unless the existing helper is proven insufficient.
    Confidence: 0.9
  • [P2] Guard the later checkpoint paths too — src/repair/execute-fix-artifact.ts:2129-2134
    The contract is enforced only before firstCheckpoint, but validation-fix and review-fix passes can edit files and then immediately call commitCheckpointIfNeeded() through onReviewFix. Those later checkpoint commits can still include unrelated lockfiles or files outside the contract, so the new guard does not actually protect all checkpointing.
    Confidence: 0.87
  • [P2] Fix the lint-blocking path split — src/repair/execute-fix-artifact.ts:2713
    The latest pnpm check fails in lint:repair with Unnecessary escape character '/' on this new regex. Use split("/") or another linter-accepted equivalent before the branch can pass required checks.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 59e2d4406ebb.

Label changes

Label changes:

  • add P2: This is bounded repair-lane automation hardening with concrete merge blockers but limited blast radius.
  • add merge-risk: 🚨 automation: The diff changes repair-worker checkpoint acceptance behavior and can block or miss automated repair commits in ways CI alone does not prove.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides build and source-test output only; it does not show an after-fix repair-worker run proving the checkpoint gate in a real setup. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is bounded repair-lane automation hardening with concrete merge blockers but limited blast radius.
  • merge-risk: 🚨 automation: The diff changes repair-worker checkpoint acceptance behavior and can block or miss automated repair commits in ways CI alone does not prove.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides build and source-test output only; it does not show an after-fix repair-worker run proving the checkpoint gate in a real setup. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Repository policy: AGENTS.md was read fully and applied because this PR changes repair lane executor code, where repository policy asks for narrow, evidence-backed, automation-safe changes. (AGENTS.md:1, 59e2d4406ebb)
  • Duplicated conflict prompt behavior: The PR head adds effectiveFallbackReason conflict instructions in execute-fix-artifact.ts, while current main already renders conflict-first guidance through renderRebaseResult() in fix-prompt-builder.ts. (src/repair/execute-fix-artifact.ts:1974, 5d793527a577)
  • Existing conflict-first implementation: Current main already includes the conflict-first prompt block and unmerged conflict path rendering in renderRebaseResult(), introduced by the merged conflict hardening work. (src/repair/fix-prompt-builder.ts:292, 59e2d4406ebb)
  • Checkpoint coverage gap: The new enforceRepairContract() call appears before the first checkpoint, but the same function still has later commitCheckpointIfNeeded() paths after validation/review-fix and final base-sync edits. (src/repair/execute-fix-artifact.ts:2129, 5d793527a577)
  • Failing check: The latest pnpm check job fails in lint:repair with Unnecessary escape character '/' on the newly added path-splitting regex. (src/repair/execute-fix-artifact.ts:2713, 5d793527a577)
  • Proof is test-only: The PR body reports build:repair and a source-inspection unit test, but does not include redacted output from a real repair-worker run exercising the new checkpoint gate. (5d793527a577)

Likely related people:

  • steipete: Blame and git history show Peter Steinberger authored the current repair edit loop baseline and the merged conflict-retry hardening that owns adjacent prompt/checkpoint behavior. (role: feature owner and recent area contributor; confidence: high; commits: dc824915bb6c, 39239e718f9d, 59e2d4406ebb; files: src/repair/execute-fix-artifact.ts, src/repair/fix-prompt-builder.ts, src/repair/rebase-conflict-policy.ts)
  • Jhacarreiro: Recent merged repair-lane commits preserve João Carreiro's contributor credit, so this author has relevant current-main repair history beyond opening this PR. (role: recent adjacent contributor; confidence: medium; commits: 39239e718f9d, 59e2d4406ebb; files: src/repair/execute-fix-artifact.ts, src/repair/pr-repair-intake.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jun 19, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing as submitted. The branch fails pnpm check, duplicates conflict-prompt behavior already landed in #332, and guards only the first of four checkpoint paths, so later review/validation checkpoints bypass the proposed contract. The fail-closed boundary also has no real worker proof and could block valid repairs when likely_files is incomplete.

A future version should start from current main, centralize every checkpoint behind one contract-enforcing helper, exclude the already-landed conflict work, and include focused bypass tests plus a real repair-worker run. Thanks for exploring the contract boundary.

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

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants