Skip to content

fix: preserve validated legacy checkout blobs - #978

Merged
steipete merged 2 commits into
mainfrom
codex/clawsweeper-review-checkpoint-index
Jul 31, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/clawsweeper-review-checkpoint-index

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • Preserve an already-tracked Git blob byte-for-byte when its exact raw worktree bytes still match the index, even if current .gitattributes would normalize those bytes differently.
  • Prevent autonomous OpenClaw repair from silently rewriting unrelated legacy CRLF files during its first checkpoint; also allow a review fix to restore the exact pinned-base blob while making substantive changes elsewhere.
  • Apply the same faithful checkout-tree construction to validation bindings, checkpoint commits, final publication identity, and replacement-history compaction.
  • Preserve existing poisoned-index rejection, filtered-file/submodule safeguards, executable modes, and the required actual PR writer openai/gpt-5.6-sol / xhigh configuration.

Real production root cause and integration proof

The trusted real writer https://github.com/openclaw/clawsweeper/actions/runs/30647636922 implemented openclaw/openclaw#98276, passed its actual OpenClaw validation, and reached Codex review under the required model:

CLAWSWEEPER_OPENCLAW_MODEL: openai/gpt-5.6-sol
CLAWSWEEPER_CODEX_REASONING_EFFORT: xhigh

2026-07-31T16:47:06Z Codex edit pass finished {"mode":"replacement","attempt":1,"status":0}
2026-07-31T16:47:09Z starting validation/review loop {"mode":"replacement","attempt":1}
2026-07-31T16:49:35Z Codex /review replacement attempt 1 still running (60s elapsed)
2026-07-31T16:51:18Z Codex review-fix worker replacement attempt 1 still running (60s elapsed)
2026-07-31T16:52:03Z Error: target index differs from unchanged worktree content

The actual exported execution artifact records exactly why: checkpoint normalization changed unrelated apps/android/gradlew.bat from the pinned base's legacy CRLF blob to LF. Codex review correctly identified that unrelated change; its repair restored the exact original blob with git restore --source=<base> --staged --worktree, passed actual pnpm check:changed, and reduced the intended final tree to only these three files:

base blob 8508ef684d4e1f8473dcbbfdacf52a131beaee0e
head blob a51ec4f5886d3bb106b26724ee4507addbbe3fa8
apps/android/gradlew.bat: text: auto
apps/android/gradlew.bat: eol: lf

-- effective final delta --
M .github/workflows/ci.yml
A scripts/dist-runtime-build-artifact.mjs
M test/scripts/ci-workflow-guards.test.ts

pnpm check:changed: PASS
git diff --check <pinned-base> <final-tree>: PASS

The publisher then incorrectly rejected the legitimate staged restoration because its canonical checkout tree ignored the exact already-tracked bytes. This PR fixes the actual initial root cause: an unchanged existing tracked blob is recognized from its byte-for-byte raw Git object hash, so it is preserved throughout every downstream identity surface rather than rewritten and patched later.

The current head's executable subprocess integration exercises the complete relevant publication chain, not checkpoint behavior alone: existing CRLF blob preservation, a separately simulated pre-fix normalized checkpoint, staged pinned-base restore, a simultaneous substantive review edit, accepted final checkout binding, replacement-history compaction, and the post-compaction final checkout binding. Hostile staged-index poisoning is rejected for both an ordinary filename and the literal Git pathspec-magic filename :(exclude)*.

✔ checkpoint plumbing preserves a review fix restoring a legacy CRLF blob
  includes successful final checkout binding and replacement-history compaction
✔ checkpoint plumbing preserves staged CRLF restorations alongside review edits
✔ checkpoint plumbing rejects a staged blob that disagrees with unchanged worktree
  includes malicious literal filename :(exclude)*

focused validation: tests 21 | pass 21 | fail 0
repair source/test lint: PASS
source/test formatting: PASS
repository git diff --check: PASS

Accepted review-finding disposition

  • P1 mixed staged restore plus substantive review changes: fixed at shared checkout-tree construction rather than a checkpoint-only special case; regression verifies both edits survive.
  • P1 final validation binding and replacement-history compaction: fixed by using the same preserved raw blob for checkpoint, identity capture, final binding, and history compaction; integration verifies all three live-path operations.
  • P1 pathspec-magic staged-index injection: eliminated entirely by removing the staged-pathspec overlay approach; explicit hostile filename regression still rejects poisoned staged content.
  • P2 Windows-incompatible adversarial filename fixture: resolved by running the literal :(exclude)* case only on platforms whose filesystems permit that filename; the ordinary poisoned-index rejection still runs on Windows, and existing Windows launcher coverage remains intact.

No untrusted Git callback, filter, pathspec override, identity-check bypass, or broader write permission is introduced.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 1:17 PM ET / 17:17 UTC.

ClawSweeper review

What this changes

The PR updates ClawSweeper’s repair checkout identity so a staged restoration of an existing legacy Git blob keeps its original bytes instead of being rewritten by current line-ending normalization.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR remains necessary: current main still canonicalizes changed worktree content under current Git attributes, while the branch preserves an exact already-validated tracked blob only when the raw worktree object matches the indexed object. The focused subprocess coverage and supplied production trace support the repair; it should proceed through normal exact-head checks and maintainer landing review rather than cleanup closure.

Priority: P1
Reviewed head: 4e0c3e33538291cd2fcb40af211ad006f2e39dc1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong runtime evidence and narrowly scoped regression coverage support a good repair, with exact-head checks still needed for landing confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.
Evidence reviewed 6 items Current implementation baseline: Current main builds a temporary checkout tree from the target index/worktree and uses canonical hashing for normal files; this is the shared identity path the PR changes rather than an isolated workflow-only path.
Focused regression coverage: Current tests already cover canonical EOL normalization, filtered blobs, unsafe attribute changes, submodules, and checkout binding; the PR adds the missing legacy-CRLF staged-restoration chain beside this coverage.
Patch behavior: The branch records the source object ID for canonical entries, hashes only entries whose canonical hash differs, and retains the source blob only when the raw worktree hash exactly matches it; that preserves the existing poisoned-index mismatch rejection.
Findings None None.
Security None None.

How this fits together

ClawSweeper’s repair lane checkpoints an edited target checkout, validates its identity, and later publishes the resulting branch. The checkout-tree builder converts target worktree and index state into a Git tree that feeds checkpoint commits, validation bindings, and replacement-history compaction.

flowchart LR
  A[Target checkout] --> B[Index and worktree scan]
  B --> C[Git attribute safety checks]
  C --> D[Checkout-tree construction]
  D --> E[Checkpoint and validation binding]
  E --> F[Published repair branch]
  B --> G[Poisoned-index rejection]
  G --> D
Loading

Before merge

  • Resolve merge risk (P1) - This modifies the repair lane’s checkout identity boundary: a regression could either reject legitimate staged restorations again or weaken poisoned-index detection, so the current-head pnpm check and production-automation checks should finish before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused surface 2 files affected; 150 added, 3 removed The implementation and regression coverage stay confined to the shared checkout-tree builder and its dedicated repair tests.
Validation chain 4 critical paths exercised The supplied proof covers checkpointing, final binding, compaction, and poisoned-index rejection rather than only the first checkpoint.

Merge-risk options

Maintainer options:

  1. Finish exact-head security-path validation (recommended)
    Allow the in-progress exact-head checks to complete, then land only if the raw-blob preservation tests and poisoned-index safeguards remain green.
  2. Pause if identity guarantees regress
    Pause this PR if validation exposes a path that preserves staged content without an exact raw object match or weakens the existing unsafe-attribute and poisoned-index checks.

Technical review

Best possible solution:

Land the shared raw-blob preservation only after the current head retains both the ordinary poisoned-index rejection and the new legacy-CRLF restoration chain across checkpointing, validation binding, and history compaction.

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

Yes. The supplied production repair trace reproduces a legacy CRLF blob being normalized during checkpointing and then rejected after a legitimate staged base restoration; the new subprocess regression exercises that same chain.

Is this the best way to solve the issue?

Yes. Preserving the source object only after an exact raw worktree hash match fixes the shared tree-construction root cause while preserving canonical normalization for genuinely changed files and retaining poisoned-index rejection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 61a02b0f9e3c.

Labels

Label changes:

  • add P1: A failure in checkout identity blocks autonomous repair publication for real target repositories and was observed in an actual repair run.
  • add merge-risk: 🚨 security-boundary: The patch changes the Git object and index-validation boundary that prevents unsafe staged content from being published.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.

Label justifications:

  • P1: A failure in checkout identity blocks autonomous repair publication for real target repositories and was observed in an actual repair run.
  • merge-risk: 🚨 security-boundary: The patch changes the Git object and index-validation boundary that prevents unsafe staged content from being published.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies a real repair-writer failure trace plus after-fix executable subprocess evidence covering the relevant checkpoint-to-publication path; no additional contributor proof is required.

Evidence

What I checked:

  • Current implementation baseline: Current main builds a temporary checkout tree from the target index/worktree and uses canonical hashing for normal files; this is the shared identity path the PR changes rather than an isolated workflow-only path. (src/repair/target-validation.ts:3040, 61a02b0f9e3c)
  • Focused regression coverage: Current tests already cover canonical EOL normalization, filtered blobs, unsafe attribute changes, submodules, and checkout binding; the PR adds the missing legacy-CRLF staged-restoration chain beside this coverage. (test/repair/target-validation.test.ts:5351, 61a02b0f9e3c)
  • Patch behavior: The branch records the source object ID for canonical entries, hashes only entries whose canonical hash differs, and retains the source blob only when the raw worktree hash exactly matches it; that preserves the existing poisoned-index mismatch rejection. (src/repair/target-validation.ts:3069, 730dfcf159c8)
  • Current-head provenance: The PR has two commits on top of the reviewed main SHA: the repair commit and a Windows portability adjustment for the adversarial filename fixture; main is an ancestor of the PR head. (test/repair/target-validation.test.ts:5257, 4e0c3e335382)
  • Recent feature history: The current checkout-validation surface was recently maintained in the OpenClaw repair-safety work merged as c319ba7b, followed by 61a02b0; both commits are authored by Peter Steinberger and touch the central files. (src/repair/target-validation.ts:3040, c319ba7b34e1)
  • Real behavior evidence: The PR body records an actual repair-writer failure on the legacy CRLF blob, then reports successful after-fix subprocess coverage across checkpointing, final checkout binding, replacement-history compaction, and hostile staged-index rejection. (src/repair/target-validation.ts:3069, 4e0c3e335382)

Likely related people:

  • steipete: Peter Steinberger authored the recent merged repair-publication safety work on the same checkout-validation and test surfaces, and authored this PR’s two commits. (role: recent area contributor; confidence: high; commits: c319ba7b34e1, 61a02b0f9e3c, 730dfcf159c8; files: src/repair/target-validation.ts, test/repair/target-validation.test.ts)

Rank-up moves

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

  • Wait for the current-head pnpm check and production-automation checks to complete before merge.

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
steipete merged commit 3637a94 into main Jul 31, 2026
23 of 24 checks passed
@steipete
steipete deleted the codex/clawsweeper-review-checkpoint-index branch July 31, 2026 17:19
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
* fix: preserve validated legacy checkout blobs

* test: skip nonportable pathspec fixture on Windows

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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