Skip to content

fix(pr): recover partially written review transitions - #144431

Merged
steipete merged 4 commits into
mainfrom
codex/fix-review-transition-recovery
Sep 10, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/fix-review-transition-recovery

Conversation

@steipete

@steipete steipete commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #143802

What Problem This Solves

Fixes an issue where maintainers could not resume a journaled review checkout after Git wrote target files without committing the index. Additions, deletions, and target index entries whose files still matched the source also needed safe recovery.

Why This Change Was Made

Recovery independently verifies index entries and working files against the journaled source and target blobs and modes, reconstructs the validated source index, and replays the same transition through native Git. This lets completed index deletions remove their remaining source files while preserving unrelated state.

The guard refuses unknown bytes, unrelated untracked paths, ignored overlaps, unmerged entries, intent-to-add, resolve-undo, and other hidden index flags. It preserves leading Unicode BOM characters in pathname records so a foreign lookalike cannot pass admission under a different name. The existing reserved .local artifact namespace remains preserved and is prohibited in transition endpoints.

Native wrapper materialization includes and verifies the matching helper. Knip now models its actual shell-owned executable entry. Existing operation-lock fixtures target the new reader path and verify that all started readers exit before successful lock release, including after stdout closes.

User Impact

Maintainers can resume fully classified partial review transitions without manual index repair. Truncated or otherwise unknown files still stop recovery before replay. This does not itself reconcile the separate non-endpoint empty file observed while investigating #143802.

Evidence

Native Git fixtures exercise both branch and detached recovery. Raw before/after excerpts:

# Worktree-first and index-first recovery
Tests  4 failed | 55 skipped (59)
Tests  4 passed | 55 skipped (59)

# Intent-to-add and retained resolve-undo refusal
Tests  2 failed | 64 skipped (66)
Tests  2 passed | 64 skipped (66)

# BOM-prefixed untracked lookalike: previously changed HEAD before final refusal
Tests  1 failed | 66 skipped (67)
Tests  1 passed | 66 skipped (67)

# Operation-lock reader failure and producer settlement fixtures
Tests  2 failed | 3 passed | 110 skipped (115)
Tests  5 passed | 110 skipped (115)

Final local suites:

node scripts/run-vitest.mjs test/scripts/pr-worktree-containment.test.ts
Tests  67 passed (67)

node scripts/run-vitest.mjs test/scripts/pr-operation-lock.test.ts
Tests  114 passed | 1 skipped (115)

The operation-lock skip is the Linux-only zombie-process case on macOS. Complete changed checks, both unused-file scans, formatting, syntax, and git diff --check pass. Independent review's intent-to-add finding was fixed; the later .local suggestion was rejected because it would break the unchanged reserved-artifact contract. Focused reviews of the Knip declaration, lock fixtures, and BOM correction are clean.

The maintained Crabbox route also passed all 66 original owner cases on Linux at caa6aeacb52ad1194e5e537d0c323c5e00de737f, with Git 2.52.0 and Node 24.19.0 after a frozen install. Testbox tbx_01m26mewv06wh3f7ef51ry86ac reported exitCode:0, runStatus:succeeded, and stopped successfully. Backing Testbox run; its delegated session may appear cancelled after successful external lease cleanup. The subsequent BOM correction has local fail-before/pass-after proof and is covered by required Linux CI on the final head.

CI identified the missing Knip entry and two stale operation-lock fixtures; both were repaired without relaxing checks, assertions, or deadlines. The preceding head reached green CI. Exact-head CI and current ClawSweeper review remain required before landing the final correction.

Tooling: 195 added / 15 removed lines. Tests: 163 added / 12 removed lines. No Gateway, configuration option, schema, or dependency changes.

Classify index and working-tree entries independently against the journaled
source and target before replaying an interrupted native restore. Preserve
foreign bytes, ignored overlaps, and hidden index metadata, including
intent-to-add and resolve-undo state. Rebuild the validated source index so
completed index deletions can still remove their remaining source files.

Preserve the reserved .local artifact namespace and existing journal endpoints.
Unknown zero-byte files remain refused rather than inferred as owned writes.

Validation: 66 native owner cases, complete changed checks, and independent
review. Regression cases demonstrate worktree-first and index-first recovery,
plus fail-before/pass-after coverage for intent-to-add and resolve-undo guards.

Related: #143802
@clawsweeper

clawsweeper Bot commented Sep 10, 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M maintainer Maintainer-authored PR labels Sep 10, 2026
@steipete
steipete marked this pull request as ready for review September 10, 2026 21:44
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 6:38 PM ET / 22:38 UTC (Revision 3).

ClawSweeper review

What this changes

Repairs interrupted maintainer review checkouts by validating staged entries and working files independently before completing the recorded Git transition.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and v2026.9.3 still reject valid partial transitions. The reviewed patch preserves foreign-state safeguards, and no blocking defect was found. This maintainer-authored PR is also protected from automatic closure.

Priority: P2
Reviewed head: 55c3ef6f223f1115db7fac1b6d7eb0d0e66cfb72

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful native recovery and preservation evidence and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured body reports before/after native Git runs through the production recovery owner on macOS, plus earlier Linux coverage; inspected assertions verify completed transitions and unchanged foreign state, including the final BOM correction. 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 (terminal): The captured body reports before/after native Git runs through the production recovery owner on macOS, plus earlier Linux coverage; inspected assertions verify completed transitions and unchanged foreign state, including the final BOM correction. No additional contributor proof is required.
Evidence reviewed 9 items Current main still needs the fix: The fetched main revision requires a clean index-to-worktree diff before recovery and replays only index differences against the target; this rejects worktree-first writes and does not handle source files remaining after completed index deletions.
Latest release comparison: The supplied latest release, v2026.9.3, contains the same restrictive recovery implementation and does not contain the new validator.
Independent admission before replay: The validator checks endpoint modes and blob hashes, rejects hidden index metadata and foreign untracked entries, and preserves literal filenames. Recovery invokes it before reconstructing the source index and replaying native Git. The implementation uses Node built-ins and Git; no Codex runtime contract is involved.
Findings None None.
Security None None.

How this fits together

The scripts/pr tooling switches isolated review worktrees between main and PR revisions. Its recovery journal records interrupted transitions so subsequent commands can complete them without overwriting unrelated work.

flowchart TD
  A[Review checkout command] --> B[Isolated PR worktree]
  B --> C[Read transition journal]
  C --> D[Validate index and working files]
  D -->|Unknown state| E[Refuse and preserve state]
  D -->|Source or target entries| F[Replay native Git transition]
  F --> G[Verify target and remove journal]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +151, Other +180. Total +331 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 163 12 +151
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 195 15 +180
Total 5 358 27 +331

Review metrics

None.

Technical review

Best possible solution:

Keep native Git as the transition owner, admitting only verified endpoint state while preserving unrelated files and recovery metadata on refusal.

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

Yes, source establishes the path: leave working files at the target with the index at the source, then resume journal recovery; current main rejects that valid partial state. Native regression results are supplied, but this review did not execute them.

Is this the best way to solve the issue?

Yes. Independent endpoint validation followed by native Git replay repairs the existing owner without introducing competing checkout logic or changing the journal format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 28589e76ead3.

Labels

Label justifications:

  • P2: This fixes a bounded maintainer-tooling recovery failure without changing the Gateway or end-user runtime.
  • 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. Sufficient (terminal): The captured body reports before/after native Git runs through the production recovery owner on macOS, plus earlier Linux coverage; inspected assertions verify completed transitions and unchanged foreign state, including the final BOM correction. No additional contributor proof is required.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports before/after native Git runs through the production recovery owner on macOS, plus earlier Linux coverage; inspected assertions verify completed transitions and unchanged foreign state, including the final BOM correction. No additional contributor proof is required.

Evidence

What I checked:

  • Current main still needs the fix: The fetched main revision requires a clean index-to-worktree diff before recovery and replays only index differences against the target; this rejects worktree-first writes and does not handle source files remaining after completed index deletions. (scripts/pr-lib/worktree.sh:100, 28589e76ead3)
  • Latest release comparison: The supplied latest release, v2026.9.3, contains the same restrictive recovery implementation and does not contain the new validator. (scripts/pr-lib/worktree.sh:100, 1391f7cd2d40)
  • Independent admission before replay: The validator checks endpoint modes and blob hashes, rejects hidden index metadata and foreign untracked entries, and preserves literal filenames. Recovery invokes it before reconstructing the source index and replaying native Git. The implementation uses Node built-ins and Git; no Codex runtime contract is involved. (scripts/pr-lib/review-transition-state.mjs:102, 55c3ef6f223f)
  • Recovery and preservation proof: The inspected fixtures invoke the production shell recovery owner with native Git repositories. They verify branch and detached recovery, index-first and worktree-first states, retained source-file deletion, and refusal preserving foreign bytes and hidden metadata. The captured PR body reports fail-before/pass-after results, 67 passing containment cases, and 114 passing operation-lock cases with one platform skip; these were not rerun during this read-only review. (test/scripts/pr-worktree-containment.test.ts:560, 55c3ef6f223f)
  • Re-review continuity: The supplied previous review records no findings. GitHub's exact-head commit patch verifies that the subsequent change preserves leading BOM characters and adds the corresponding foreign-path regression. The body explicitly preserves the established .local exception and records why the earlier suggestion to remove it was rejected. (scripts/pr-lib/review-transition-state.mjs:15, 55c3ef6f223f)
  • Existing wrapper and artifact boundaries: The wrapper's trusted component closure includes all of scripts/pr-lib, so the new helper participates in materialization and blob verification. Existing .local exclusions and ignored-overlap rejection remain intact; no dependency, permission, workflow, or journal-format changes are introduced. (scripts/pr:54, 55c3ef6f223f)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-10T22:06:10.701Z sha 47b012d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T22:17:53.227Z sha f8fdac8 :: needs maintainer review before merge. :: none

Exercise the active Node-helper Git reader in the failure fixture and keep operation artifacts in the reserved .local namespace. Record reader starts and delayed exits after stdout closure so successful validation still proves every producer joined before lock release.

Validation: focused reader cases changed from two failures to five passes; full operation-lock suite passed 114 tests with one Linux-only zombie case skipped on macOS. Complete changed checks and focused independent review passed. Production runtime bytes are unchanged.
Treat Git output as pathname records rather than a BOM-framed text document. Preserve an initial U+FEFF while keeping fatal UTF-8 decoding, so an untracked lookalike cannot be misclassified as a target path before native replay.

The native regression previously changed HEAD before final refusal; it now preserves the source state. All 67 owner tests, complete changed checks, and focused independent review pass.
@steipete
steipete merged commit 4cb2023 into main Sep 10, 2026
134 checks passed
@steipete
steipete deleted the codex/fix-review-transition-recovery branch September 10, 2026 22:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
* fix(pr): recover partially written review transitions

Classify index and working-tree entries independently against the journaled
source and target before replaying an interrupted native restore. Preserve
foreign bytes, ignored overlaps, and hidden index metadata, including
intent-to-add and resolve-undo state. Rebuild the validated source index so
completed index deletions can still remove their remaining source files.

Preserve the reserved .local artifact namespace and existing journal endpoints.
Unknown zero-byte files remain refused rather than inferred as owned writes.

Validation: 66 native owner cases, complete changed checks, and independent
review. Regression cases demonstrate worktree-first and index-first recovery,
plus fail-before/pass-after coverage for intent-to-add and resolve-undo guards.

Related: openclaw#143802

* fix(pr): register the journal validator executable entry

* test(pr): preserve Git reader coverage for journal recovery

Exercise the active Node-helper Git reader in the failure fixture and keep operation artifacts in the reserved .local namespace. Record reader starts and delayed exits after stdout closure so successful validation still proves every producer joined before lock release.

Validation: focused reader cases changed from two failures to five passes; full operation-lock suite passed 114 tests with one Linux-only zombie case skipped on macOS. Complete changed checks and focused independent review passed. Production runtime bytes are unchanged.

* fix(pr): preserve leading BOM characters in Git path records

Treat Git output as pathname records rather than a BOM-framed text document. Preserve an initial U+FEFF while keeping fatal UTF-8 decoding, so an untracked lookalike cannot be misclassified as a target path before native replay.

The native regression previously changed HEAD before final refusal; it now preserves the source state. All 67 owner tests, complete changed checks, and focused independent review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M 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