Repository navigation
fix(doctor): fall back to a guarded hard-link move when RENAME_NOREPLACE is rejected - #164748
Conversation
Share the guarded hard-link move with audit claim, archive, restore, quarantine, and journal publication. Recover known interrupted inode pairs, preserve read-only backup capture, and defer unsupported hard links with a warning so independent repairs and updates continue. Preserve open predecessor append descriptors and never overwrite an existing destination. Closes #164703. Thanks to @bbs2i58 for the filesystem probe.
|
🦞👀 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: blocked before merge. Reviewed October 3, 2026, 11:53 PM ET / October 4, 2026, 03:53 UTC. ClawSweeper reviewWhat this changesDoctor shares a guarded hard-link fallback across legacy audit migrations, recovers interrupted moves, and preserves unsupported files with actionable warnings. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful fix for an established filesystem compatibility failure. No concrete introduced correctness defect was found, and current main still uses direct native moves for audit migration. Priority: P2 Review scores
Verification
How this fits togetherDoctor imports legacy audit files into OpenClaw’s shared SQLite state and preserves sanitized recovery archives. Filesystem failures affect migration receipts, subsequent repairs, and update completion. flowchart TD
A[Legacy audit files] --> B[Doctor migration]
B --> C[Native no-replace move]
C -->|Unsupported| D[Guarded exclusive hard link]
D -->|Supported| E[Import and recover archives]
C -->|Supported| E
D -->|Unsupported| F[Preserve files and warn]
E --> G[SQLite history and repair receipts]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +282, Tests +389, Docs +15. Total +686 across 10 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one guarded migration move owner that preserves legacy inodes, sanitized backups, and repair continuation, with verified compatibility through the installed updater. Do we have a high-confidence way to reproduce the issue? Yes, from source: current-main audit moves propagate fs-safe’s helper-unavailable result for native EINVAL, matching the reporter’s isolated filesystem observation. This review did not execute a reproduction. Is this the best way to solve the issue? Yes: sharing the established guarded move implementation preserves open-descriptor appends and avoids a competing copy-based migration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 06131c40d09f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…ACE is rejected (openclaw#164748) Doctor's legacy config audit-log migration failed on filesystems where renameat2(RENAME_NOREPLACE) returns EINVAL (QNAP ZFS bind mount), stopping the migration at its exclusive source-claim move. The guarded hard-link no-replace move already used by the source claim is now the shared helper for every audit move site: it keeps the destination exclusive, preserves late appends from a still-open predecessor descriptor (same inode), and recovers interrupted link pairs; when hard links are also unavailable it leaves the files intact, warns with the manual command, and lets the migration continue. A copy-based fallback was rejected because it would drop late appends and trip Doctor's inode-change refusal. Closes openclaw#164703.
Closes #164703
What Problem This Solves
Fixes Doctor's legacy config audit-log migration on filesystems that reject native no-replace rename, as reported on a QNAP ZFS-backed Docker bind mount.
Why This Change Was Made
Audit migration bypassed the guarded fallback already used by other Doctor source claims. Share that implementation at OpenClaw's fs-safe call boundary and route all seven audit moves through it. Keep native rename first, then publish an exclusive hard link, verify inode ownership, sync, and remove the old name.
Copying would lose later appends through a predecessor CLI's open descriptor. Recovery therefore recognizes only the exact two-link source/claim/archive/journal/quarantine pairs. Backup capture sanitizes one destination snapshot without mutating the live pair. Existing source-claim migrations use the same helper; fs-safe remains unchanged.
User Impact
Doctor can complete the migration while preserving late appends and never overwriting an existing destination. If hard links are also unavailable, it preserves the audit inode, emits a visible warning with the file, filesystem limitation, and state-specific
openclaw doctor --fixcommand, and lets independent repairs and update finalization continue.Unsupported files remain for a later repair. Operator guidance requires stopping the Gateway and CLI writers before relocating state to a compatible filesystem. Collision, identity, authority, and post-publication failures retain their safety checks. No config, CLI, dependency, or database schema changes.
Evidence
Regression and recovery proof
EINVALat fs-safe's nativerenameNoReplaceprimitive. Regression coverage now also exercisesENOSYSandEOPNOTSUPP.EPERM,EXDEV, andEMLINKat hard-link publication: the original bytes/inode remain, a warning names the targeted repair command, and independent migration continues. Archive/journal-stage deferral and deduplicated retry also pass.skipped, no refusal exception, preserved bytes, and completion of the later exec-approvals repair.Validation
Local macOS, Node 26.10.0. Tests use real isolated filesystem/SQLite state with native primitive fault injection; no QNAP device or Windows runtime proof is claimed.
ci-changed-node-test-plan.selection.test.ts: 15 passed.OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 CI=1 node scripts/check-changed.mjs --base 12c5644ad78f4a3b3882cb7e10aaf8f49bbeb3d0 --timed: all selected gates passed locally, including core/test types, lint, documentation, unused exports, and structural guards.node --import ./scripts/tsx.mjs scripts/check-export-name-collisions.mtsandnode scripts/tests/update-restart-swap-fixture.mjs: passed.git diff --checkpassed.Test cost
Measured with the repository Vitest wrapper and
--maxWorkers=1(the same test entry point used bypnpm test). Hosted CI timing is pending; the table reports local serial test seconds across the three final repetitions:The audit boundary uses real durable file operations and SQLite to prove inode retention, safe publication, interrupted recovery, and Doctor receipt continuation. No Gateway boots, sleeps, retries, or timeout increases were added.
Slow pre-existing suites (waived)
state-migrations.audit-skips.test.tsreached 171.99 s of test time during initial validation and 133.92 s in the final repetitions.pr-worktree-provision.test.tstook 348.84 s; its existing APFS cold/warm/sparse scenario took 105.43 s and passed its unchanged deadline. These pre-existing costs are covered by the maintainer's slow-suite waiver.Inherited gate and tooling recovery
The initial PR-provisioning gate failed because the extracted wrapper lacked the application runtime that template operations were trying to load. Integrated the already-landed fix
b97d4c03f364d244db687b372930c29759a45cc9(#164706), which gives templates a narrow worker entry while keeping the broad runtime absent. All ten lane files were byte-identical across that rebase; all three closure suites then passed.The combined importer JSON reporter rejected Gateway's inline
simpleproject before running those tests. Split the configurations and used the normal reporter for Gateway; all remaining tests passed. No assertions or product guards were weakened.Change size
Production: +506 / -224. Tests: +421 / -32. Docs: +15 / -0. Total: +942 / -256 across 10 files.
Thanks to @bbs2i58 for the isolated filesystem probe and report.