Repository navigation
fix(doctor): pre-migration snapshot fails on Linux hosts that do not report file birthtime - #164363
Conversation
|
🦞👀 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 October 4, 2026, 10:04 PM ET / October 5, 2026, 02:04 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR makes SQLite snapshot transfers tolerate unstable timestamps while retaining file identity, size, and content checks. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main retains the failing birthtime comparison. The repair preserves content verification, has convincing Linux boundary proof, and introduces no actionable correctness finding. Likely related people: steipete and fuller-stack-dev (medium-confidence routing). Priority: P0 Review scores
Verification
How this fits togetherDoctor creates verified SQLite rollback backups before migrating existing databases. Snapshot publication transfers a private database image to its backup location and verifies its identity and bytes before reporting success. flowchart TD
A[Doctor migration request] --> B[Maintenance ownership]
B --> C[Private SQLite snapshot]
C --> D[Hard link or copy transfer]
D --> E[Identity and content verification]
E --> F[Verified rollback backup]
E --> G[Reject changed image]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -5, Tests +46. Total +41 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use link-stable file identity for intermediate transfer checks and verified bytes as the snapshot-content contract. Do we have a high-confidence way to reproduce the issue? Yes: source identifies the hard-link/unlink birthtime mismatch, and the contributor supplies real Linux before/after Doctor-backup traces. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: the repair stays in the snapshot owner, removes unreliable metadata comparisons, and retains independent byte verification and cleanup ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 43856f78ec62. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
946d860 to
b9d53ba
Compare
…report file birthtime (openclaw#164363) Closes openclaw#164319 Co-authored-by: Jay Zhou <[email protected]>
…report file birthtime (#164363) Closes #164319 Co-authored-by: Jay Zhou <[email protected]> (cherry picked from commit d4ce3b2)
…on membership store (#165775) Closes #158239 Reported by @donquiche61. Backport of 8b2f553 (#165775) adapted for 2026.10.2. The release line already has the relaxed sameFileStatFingerprint (#164363) and readDatabaseIdentityBirthtime; final publication and read-time drift checks now use sameFileStatFingerprint instead of raw birthtime compares. The sqlite-file-generation hunk is omitted: the release line still compares ctime there (pre-#164823), so its birthtime compare is redundant with that check. (cherry picked from commit 8b2f553)
Closes #164319
What Problem This Solves
openclaw doctor --fixcan reject its required pre-migration SQLite snapshot on Linux hosts withoutstatx. Thanks @StevenKrebs for reporting this and @jayzhou2309 for the original fix and Linux reproduction.User Impact
Doctor can publish unchanged rollback backups on these hosts. Changed file identities, sizes, or database bytes still fail verification.
Why This Change Was Made
Node/libuv can substitute ctime when the filesystem cannot report birth time. Removing the original hard-link name changes ctime, so comparing the publication receipt's birth time to a later stat can reject the same unchanged inode.
The intermediate transfer fingerprint now compares only device/inode identity and size on every platform. The snapshot owner retains its content hashes before and after publication. Coverage uses real hard-link publication with zero and ctime-derived birth times, checks database contents and cleanup, and rejects actual same-size byte changes instead of treating an mtime-only change as rewritten data.
Evidence
Follow-up
284bd601a89fb3923ca21e98085944b1fff9eb26adds one commit on top of the contributor'sb9d53bae7298bcef61359cb299c57496adfb54ee; their two commits and PR authorship are preserved. Local verification on the final source:node scripts/run-vitest.mjs src/infra/sqlite-snapshot.transfer.test.ts --maxWorkers=1(the repository runner used bypnpm test). Runner wall time: 89.08 / 38.33 / 59.72 seconds; summed test-case time: 10.289 / 10.673 / 11.670 seconds. Compiler preparation accounts for most cold-run overhead.test/scripts/eager-import-closure.test.tsandtest/scripts/pr-wrapper-source-closure.test.ts: 20/20 passed, including the PR wrapper inventory check.CI=1 OPENCLAW_LOCAL_CHECK=1 node scripts/check-changed.mjs --base 86e3f23b2418033faae116b8c2b6e88453c960dc: exit 0, including core and all 27 test typecheck graphs, lint, ratchets, and static guards.git diff --checkalso passed.All stateful proof used isolated test state. No module, schema, configuration, or dependency changes were introduced. Auto-merge remains off.
Before this follow-up, an isolated regression on main
678572811dd8b10c19ee69e2107947d099dd33c1produced 1 failed / 9 passed at the reported staging-transfer guard; the device/inode/size repair passed 10/10 three times. A real hard-link/unlink probe using the extractedv2026.9.8guard also rejected ctime-as-birthtime while device, inode, size, mtime, and SHA-256 remained unchanged. Stable zero birth time passed. This was stat simulation, not a Linux 4.4 machine or a full historical installation upgrade. The final contributor-branch suite adds the real byte-mutation negative control and contains 11 tests.Contributor's earlier validation and Linux proof on the named prior heads
expectSnapshotSuccess, merged the copy-fallback case into the publishit.each). The new tests are unchanged except that the success case checks the receipt inline. The fix commit is b9d53ba, and its source diff is byte-identical to 946d8607516, so the Linux proof below still applies. On the new base: test commit 52db407 gives 1 failed, 9 passed, and the fix gives 10/10. All 18src/infra/sqlite-snapshot*.test.tsfiles pass (122 passed, 2 skipped).tsgo:coreandtsgo:core:testexit 0.run-oxlintexits 0, andoxfmt --checkis clean on both files.src/infra/sqlite-snapshot.transfer.test.ts. Both run a real hard-link transfer, then reportprocess.platformaslinuxand birthtime as ctime for the staging file and its receipt, as Node does withoutstatx. "accepts a hard-link transfer when Linux reports ctime as birthtime" fails on upstream/main d41a61f with the reportedSQLite snapshot staging file changed during transferfromsqlite-snapshot.ts:392, and passes on the fix. "rejects a staged image rewritten during a Linux hard-link transfer" changes the staged file's mtime mid-transfer and is rejected on both.pnpm test src/infra/*sqlite-snapshot*.test.ts: 19 files, 134 passed, 3 skipped.pnpm tsgo:coreexits 0, and the test typecheck shard that covers these files (test/tsconfig/tsconfig.core.test.state-logging.json) exits 0.scripts/run-oxlint.mjsexit 0 andoxfmt --checkclean on the 2 changed files.Real behavior proof
Doctor's pre-migration backup runs on real Linux from source, on upstream/main d41a61f (before) and on this branch 946d8607516 (after). The script calls the same code
openclaw doctor --fixuses for its rollback backup: it takes the real Doctor maintenance lock (withDoctorSqliteMaintenanceLock) and runs the Doctor backup owner (backupDoctorSqliteDatabases) on a fresh shared state database created byopenOpenClawStateDatabase. That reachescreateVerifiedSqliteSnapshotand the hard-link publication. Nothing is mocked: noprocess.platformoverride and no stat stubs. It does not run the fullopenclaw doctor --fixCLI, and the database is a new one rather than an upgrade from 2026.9.4 with a pending schema migration.Setup: Docker on an arm64 Mac (Linux kernel 7.0.12-linuxkit, the
node:24-bookworm-slimimage, Node v24.21.0, the version in the issue). Both revisions are bundled with esbuild from the repo source, along with theirinfra/*worker entrypoints. This kernel hasstatx, so the "no statx" condition from the issue is made with a seccomp profile. It returnsENOSYSforstatxcalls that use libuv's mask (0xFFF, basic stats plus btime), and forio_uring_setup. That is the result libuv gets on Linux 4.4. libuv then falls back to plainstatand fills birthtime from ctime (deps/uv/src/unix/fs.c, theuv__fs_statxfallback). The filter matches only that mask because runc itself callsstatxwithSTATX_MNT_IDduring container start.{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[ {"names":["statx"],"action":"SCMP_ACT_ERRNO","errnoRet":38,"args":[{"index":3,"value":4095,"op":"SCMP_CMP_EQ"}]}, {"names":["io_uring_setup"],"action":"SCMP_ACT_ERRNO","errnoRet":38}]}Before, on d41a61f, with Node's
statxblocked, state dir on the container's own filesystem ($ROOTreplaces the temp path):After, on 946d8607516, same container setup:
The stat probe line comes before the backup. It writes a file, hard-links it, unlinks the original name, and stats the link. With
statxblocked, birthtime equals ctime and moves when the unlink changes ctime. That is the field main's fingerprint compares.The full matrix ran twice, with the same results both times:
statxENOSYS)staging file changed during transferENOSYS)What this shows:
statx. Withstatxavailable, Linux reports a real birthtime that does not move, and main publishes the backup. So the Linux 4.4statxgap in the issue is the trigger.statxblocked. The cause is not traced. A guess is virtiofs attribute caching hiding the ctime change during the transfer window. The issue's bind mount came from a Linux host, which this setup does not reproduce.Commands, from the repo root on each revision (
git checkout --detach <commit>):@openclaw/[email protected]and itslinux-arm64-gnunative package sit innode_modulesbeside the bundles. Each run takes a few seconds. The proof script is not part of this PR.Proof script (proof.ts)
Not verified: a real Linux 4.4 host. The seccomp filter makes
statxunavailable to Node on a newer kernel, and the rest of the stack is real: kernel, filesystem, libuv fallback, and the publisher. The issue also notes that the failing run did not record which stat field differed. The probe above shows birthtime is the field that moves under this condition.Test cost and exact-head CI
pnpm test src/infra/sqlite-snapshot.transfer.test.ts --maxWorkers=1at 946d8607516 (macOS arm64): 10 tests pass. Wall time was 31.4 s cold (Vitest 28.3 s, 90% transform), then 7.80 s and 7.35 s warm (Vitest 5.95 s and 5.69 s). The two new tests take about 185 ms and 175 ms. They add no timers, sleeps, fixtures, or Gateway boots.checks-node-changed-3on a Linux x64 runner. There, 10 tests passed in 3.56 s of Vitest time (4.81 s shard wrapper), and the new tests took 134 ms and 124 ms. The whole job took 2 m 24 s, including other shards.