Repository navigation
fix(pr): recover partially written review transitions - #144431
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 6:38 PM ET / 22:38 UTC (Revision 3). ClawSweeper reviewWhat this changesRepairs 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +151, Other +180. Total +331 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
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.
|
Merged via squash.
|
* 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.
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
.localartifact 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:
Final local suites:
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 --checkpass. Independent review's intent-to-add finding was fixed; the later.localsuggestion 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. Testboxtbx_01m26mewv06wh3f7ef51ry86acreportedexitCode: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.