Skip to content

fix(backup): handle AppleDouble metadata without losing SQLite validation - #140989

Merged
obviyus merged 6 commits into
openclaw:mainfrom
ericcaiwx-star:fix/backup-appledouble-sqlite-140193
Sep 11, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
ericcaiwx-star:fix/backup-appledouble-sqlite-140193

Conversation

@ericcaiwx-star

@ericcaiwx-star ericcaiwx-star commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where openclaw backup create failed before producing an archive when state contained AppleDouble metadata named ._cron.sqlite.

Why This Change Was Made

Exclude signature-confirmed ._*.sqlite metadata after the existing state/agent inventory checks. The probe uses the existing safe file opener and closes its descriptor after every read outcome. Real databases and hardlink aliases retain verified snapshots, compaction, and canonical sanitization.

User Impact

Backups can include state copied from macOS without treating AppleDouble metadata as a database. Ordinary workspace files remain included, and corrupt SQLite databases still stop backup creation.

Evidence

  • Pinned-main public backup create --verify --json failed actual SQLite validation for a 163-byte metadata fixture and produced no archive.
  • Independent candidate public create and separate verify passed. Extracted archives exclude state/agent metadata, retain workspace metadata and ordinary files, and preserve real same-name databases and canonical aliases with their ownership and sanitization.
  • 63 distinct focused backup and verifier cases passed, including real hardlinks, canonical WAL data, corruption, inventory scope, replacement symlinks, and descriptor cleanup.
  • Native formatting, lint, source guards, and the normal commit hook passed. Independent source review is clean.

The exploratory generic hardlink/live-WAL case failed identically on pinned main and the candidate; it remains tracked separately in #144585. The passing canonical and closed-generic controls do not turn that existing failure into a pass.

Proof uses synthetic files on Linux; it does not claim a macOS filesystem test. All four contributor commits are retained.

Closes #140193.

@clawsweeper

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

@ericcaiwx-star
ericcaiwx-star marked this pull request as ready for review September 7, 2026 07:49
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 10:26 PM ET / September 11, 2026, 02:26 UTC (Revision 9).

ClawSweeper review

What this changes

Exclude signature-confirmed AppleDouble metadata from backup database discovery and archives while preserving SQLite validation, with regression coverage and backup documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v2026.9.3 retain the reported misclassification. Earlier findings are addressed, supplied runtime observations support the repair, and no blocking patch defect was found.

Priority: P2
Reviewed head: 723debcab80cf3aa4139dfcbd27aed9ee0b02fae

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant runtime observations, meaningful regression coverage, and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports public CLI create and separate verify succeeding with synthetic Linux state, with extracted contents confirming the changed classifier's exclusions and retained database handling; this is supplied runtime evidence, not a reviewer rerun or native macOS claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports public CLI create and separate verify succeeding with synthetic Linux state, with extracted contents confirming the changed classifier's exclusions and retained database handling; this is supplied runtime evidence, not a reviewer rerun or native macOS claim.
Evidence reviewed 9 items Current-main defect remains: The current-main classifier accepts included state-owned .sqlite files by suffix without checking AppleDouble content; discovery sends regular matching files into snapshot creation.
Latest release retains the classifier: Inspection of v2026.9.3 shows the same suffix-based classification without metadata recognition; this repair is not present in that release.
Introduced change resolves prior findings: The pinned introduced diff checks inventory admission before probing, requires the AppleDouble magic, uses the existing safe opener, and closes successful probe descriptors in finally. It does not exempt real databases based on their names.
Findings None None.
Security None None.

How this fits together

Backup creation inventories local OpenClaw state, prepares verified SQLite snapshots, and packages files into an archive. The shared classifier controls both database discovery and archive filtering.

flowchart TD
  A[State and agent files] --> B[Backup ownership inventory]
  B --> C{SQLite candidate}
  C --> D{AppleDouble signature}
  D -->|Confirmed| E[Exclude metadata]
  D -->|Absent| F[Verified SQLite snapshot]
  B --> G[Ordinary archive files]
  F --> H[Archive and verification]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +33, Tests +199, Docs +1. Total +233 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 36 3 +33
Tests 1 274 75 +199
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 311 78 +233

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140193
Summary: This PR targets the AppleDouble report; the generic-hardlink WAL defect is separately evidenced and predates the patch.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep metadata recognition in the shared backup classifier while retaining verified snapshots, canonical sanitization, and corruption failures for actual SQLite databases.

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

Yes: the linked report provides an isolated AppleDouble fixture, and current-main source still sends that regular .sqlite file into database snapshot creation. This reviewer did not execute the reproduction.

Is this the best way to solve the issue?

Yes: content recognition after inventory admission fixes both discovery and archive filtering through their existing shared owner, without weakening verification or adding configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs backup creation for a specific metadata-file condition without changing broader backup policy.
  • 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 (live_output): The captured body reports public CLI create and separate verify succeeding with synthetic Linux state, with extracted contents confirming the changed classifier's exclusions and retained database handling; this is supplied runtime evidence, not a reviewer rerun or native macOS claim.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports public CLI create and separate verify succeeding with synthetic Linux state, with extracted contents confirming the changed classifier's exclusions and retained database handling; this is supplied runtime evidence, not a reviewer rerun or native macOS claim.

Evidence

What I checked:

  • Current-main defect remains: The current-main classifier accepts included state-owned .sqlite files by suffix without checking AppleDouble content; discovery sends regular matching files into snapshot creation. (src/infra/backup-sqlite-snapshot.ts:105, c91669493102)
  • Latest release retains the classifier: Inspection of v2026.9.3 shows the same suffix-based classification without metadata recognition; this repair is not present in that release. (src/infra/backup-sqlite-snapshot.ts:105, 1391f7cd2d40)
  • Introduced change resolves prior findings: The pinned introduced diff checks inventory admission before probing, requires the AppleDouble magic, uses the existing safe opener, and closes successful probe descriptors in finally. It does not exempt real databases based on their names. (src/infra/sqlite-files.ts:15, 723debcab80c)
  • Safe-opener dependency contract inspected: The new probe depends on openRootFileSync, re-exported by the target's boundary-file-read module. npm metadata identifies openclaw/fs-safe as the repository for pinned version 0.8.5. Its published dist/root-file.js, dist/pinned-open.js, and dist/read-open-flags.js reject nonregular files and symlinks, compare file identities, use nonblocking/no-follow flags where supported, and close descriptors on failed validation. Published artifacts were read in memory without execution; their source commit is unknown.
  • Archive and verification boundaries preserved: Archive filtering consumes the same classifier, excludes metadata, and rejects unexpected unsnapshotted SQLite files. The public command invokes separate archive verification for --verify; the verifier retains file-shape and canonical integrity/owner checks without a filename exemption. (src/infra/backup-create.ts:610, 723debcab80c)
  • Meaningful regression coverage: Reviewed tests cover metadata exclusion versus workspace retention, corrupt and real same-name databases, FIFO and symlink rejection, replacement races, descriptor cleanup, and canonical hardlink aliases retaining WAL data and sanitization. Existing archive tests were extended rather than replacing their integrity assertions. Tests were not executed during this read-only review; diff whitespace validation passed. (src/infra/backup-create.test.ts:598, 723debcab80c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • gaoanze888: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (8 earlier review cycles)
  • reviewed 2026-09-07T07:58:03.620Z sha 7d12b12cfe7e8b03fb54697d057b2441ee4c91b7 :: needs real behavior proof before merge. :: [P1] Confirm metadata before bypassing SQLite sanitization
  • reviewed 2026-09-07T08:33:24.908Z sha f6e1443fdd2b39fb1272fdf63f13c120790d95f4 :: blocked before merge. :: [P2] Restrict metadata probing to regular files without following links | [P2] Close the descriptor when the header read throws
  • reviewed 2026-09-07T08:54:04.267Z sha ea5bf8a055bf06f6f98e6d8d7ee8089a68f71b71 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T13:18:39.212Z sha d3b23b8df65aa4021feb884e1aa91a1e04b75c32 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T16:10:51.312Z sha d341012e3b1e8825cd44de2db4ce62dd7f53e098 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T16:36:27.933Z sha 517c4eef488143bae34a67e2f1c24195d198bb8e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T16:47:25.267Z sha b46d0a7deb9c9f1c9a5f84bd1ffd25c651f61479 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T17:23:24.204Z sha e922a2e :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the commands Command implementations label Sep 7, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 7, 2026
@ericcaiwx-star
ericcaiwx-star force-pushed the fix/backup-appledouble-sqlite-140193 branch from b46d0a7 to e922a2e Compare September 7, 2026 17:13
@obviyus obviyus self-assigned this Sep 11, 2026
Preserve inventory ownership and verified snapshots for real SQLite files and aliases. Use the existing pinned file reader for metadata probes and cover descriptor cleanup, replacement races, and archive integrity.
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 11, 2026
@obviyus obviyus changed the title fix(backup): skip AppleDouble ._.sqlite metadata as SQLite fix(backup): handle AppleDouble metadata without losing SQLite validation Sep 11, 2026
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 140989
head: 723debc
run: 34554250418 attempt: 2
failed: checks-windows-node-test-2 job=103128445355 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit b605e78 into openclaw:main Sep 11, 2026
368 of 373 checks passed
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks @ericcaiwx-star!

Proof: Public backup creation and separate verification passed with synthetic AppleDouble metadata, real same-name SQLite databases, and canonical global/agent aliases. Extracted archives retain durable rows and remove the expected transient data. Corrupt databases still refuse backup creation.

Before After
A 163-byte ._cron.sqlite metadata file caused SQLite validation to fail before an archive was produced. Signature-confirmed metadata is excluded within database-owned roots; ordinary workspace content and verified database snapshots remain intact.

The repair passed 63 distinct focused cases, plus the four descriptor cases rerun after the test-type correction, and fresh exact-head review. Hosted validation: https://github.com/openclaw/openclaw/actions/runs/34554250418.

The independent generic hardlink/live-WAL control failed on both pinned main and the candidate. That existing bug remains recorded in #144585; the passing canonical and closed-generic controls do not replace it. Linux proof does not claim a macOS filesystem run. All four contributor commits and their credit were preserved.

Unrelated CI exception: checks-windows-node-test-2 exceeded the unchanged 120-second limit in test/scripts/vitest-worker-artifacts.transforms.test.ts. The exact main parent, 6e0043d3, reproduced both variants at the same fifth preparation stage with matching runtime, image, and tooling inputs. The failed checks remain red; guarded landing used the recorded standing approval. The precise underlying timing cause is not assigned to a commit.

obviyus added a commit that referenced this pull request Sep 11, 2026
)

Closes #144585

## What Problem This Solves

Fixes an issue where users backing up a live SQLite database with hardlink aliases could receive a successfully verified archive whose alias entries omitted committed data from the write-ahead log (WAL).

## Why This Change Was Made

Generic database hardlinks now share one verified, compacted snapshot from the unambiguous WAL-owning pathname. Every admitted name receives a separate regular archive entry. Creation refuses competing WALs, unaccounted hardlinks, active rollback journals, and source-identity changes. Canonical global and agent databases retain their existing owner validation and sanitizers, with their alias identities checked immediately before capture. The new capture wrapper leaves source file handles to SQLite, preserving the live writer locks covered by its regression cases.

## User Impact

Both names of a backed-up hardlinked database retain the same committed content. Uncertain journal ownership produces an explicit error without publishing an archive. The backup reference explains the required source coverage and recovery steps.

The accepted compatibility boundary for this repair requires complete hardlink coverage, including closed databases with outside aliases. Every hardlink must be an included `.sqlite` file under the state directory or a configured agent root. An unavailable alias prevents proof of journal ownership, so creation refuses until the full inventory is included.

## Evidence

- Retained public baseline: create with `--verify` and separate verify both succeeded, but the alias query failed with `no such table: acceptance_probe`.
- Public commands on the corrected candidate: both filename orders retain `committed-in-wal` in both regular SQLite entries; each extracted database passes integrity checks. Competing WALs, incomplete hardlink coverage, a live rollback journal, and malformed SQLite all refuse without an archive.
- Canonical global and agent controls preserve durable rows, remove transient leases and queues, and retain symbolic links.
- 18 new integrated regressions and 25 focused existing backup cases pass. The incomplete canonical identity guard fails its mutation control by publishing an archive. The earlier file-handle implementation loses the writer's lock for both singleton and hardlink-pair cases; the correction retains it.
- A fresh source-blind validator independently repeated all nine public scenarios on the corrected build, including direct proof that the committed schema exists only in WAL before backup. All nine pass.
- Targeted formatting, lint, documentation syntax, native commit hooks, and the runtime build pass.

Combined public validation uses the merged source from #140989 with this PR: state and agent metadata are excluded, ordinary workspace metadata remains, directory and symbolic-link controls survive, and the real SQLite hardlink and canonical controls pass. All ten combined scenarios pass.

Public runtime proof uses synthetic files on Linux.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…tion (openclaw#140989)

## What Problem This Solves

Fixes an issue where `openclaw backup create` failed before producing an archive when state contained AppleDouble metadata named `._cron.sqlite`.

## Why This Change Was Made

Exclude signature-confirmed `._*.sqlite` metadata after the existing state/agent inventory checks. The probe uses the existing safe file opener and closes its descriptor after every read outcome. Real databases and hardlink aliases retain verified snapshots, compaction, and canonical sanitization.

## User Impact

Backups can include state copied from macOS without treating AppleDouble metadata as a database. Ordinary workspace files remain included, and corrupt SQLite databases still stop backup creation.

## Evidence

- Pinned-main public `backup create --verify --json` failed actual SQLite validation for a 163-byte metadata fixture and produced no archive.
- Independent candidate public create and separate verify passed. Extracted archives exclude state/agent metadata, retain workspace metadata and ordinary files, and preserve real same-name databases and canonical aliases with their ownership and sanitization.
- 63 distinct focused backup and verifier cases passed, including real hardlinks, canonical WAL data, corruption, inventory scope, replacement symlinks, and descriptor cleanup.
- Native formatting, lint, source guards, and the normal commit hook passed. Independent source review is clean.

The exploratory generic hardlink/live-WAL case failed identically on pinned main and the candidate; it remains tracked separately in openclaw#144585. The passing canonical and closed-generic controls do not turn that existing failure into a pass.

Proof uses synthetic files on Linux; it does not claim a macOS filesystem test. All four contributor commits are retained.

Closes openclaw#140193.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…claw#144624)

Closes openclaw#144585

## What Problem This Solves

Fixes an issue where users backing up a live SQLite database with hardlink aliases could receive a successfully verified archive whose alias entries omitted committed data from the write-ahead log (WAL).

## Why This Change Was Made

Generic database hardlinks now share one verified, compacted snapshot from the unambiguous WAL-owning pathname. Every admitted name receives a separate regular archive entry. Creation refuses competing WALs, unaccounted hardlinks, active rollback journals, and source-identity changes. Canonical global and agent databases retain their existing owner validation and sanitizers, with their alias identities checked immediately before capture. The new capture wrapper leaves source file handles to SQLite, preserving the live writer locks covered by its regression cases.

## User Impact

Both names of a backed-up hardlinked database retain the same committed content. Uncertain journal ownership produces an explicit error without publishing an archive. The backup reference explains the required source coverage and recovery steps.

The accepted compatibility boundary for this repair requires complete hardlink coverage, including closed databases with outside aliases. Every hardlink must be an included `.sqlite` file under the state directory or a configured agent root. An unavailable alias prevents proof of journal ownership, so creation refuses until the full inventory is included.

## Evidence

- Retained public baseline: create with `--verify` and separate verify both succeeded, but the alias query failed with `no such table: acceptance_probe`.
- Public commands on the corrected candidate: both filename orders retain `committed-in-wal` in both regular SQLite entries; each extracted database passes integrity checks. Competing WALs, incomplete hardlink coverage, a live rollback journal, and malformed SQLite all refuse without an archive.
- Canonical global and agent controls preserve durable rows, remove transient leases and queues, and retain symbolic links.
- 18 new integrated regressions and 25 focused existing backup cases pass. The incomplete canonical identity guard fails its mutation control by publishing an archive. The earlier file-handle implementation loses the writer's lock for both singleton and hardlink-pair cases; the correction retains it.
- A fresh source-blind validator independently repeated all nine public scenarios on the corrected build, including direct proof that the committed schema exists only in WAL before backup. All nine pass.
- Targeted formatting, lint, documentation syntax, native commit hooks, and the runtime build pass.

Combined public validation uses the merged source from openclaw#140989 with this PR: state and agent metadata are excluded, ordinary workspace metadata remains, directory and symbolic-link controls survive, and the real SQLite hardlink and canonical controls pass. All ten combined scenarios pass.

Public runtime proof uses synthetic files on Linux.

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

Labels

docs Improvements or additions to documentation 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. 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.

[Bug]: backup SQLite discovery treats macOS AppleDouble ._*.sqlite files as databases

2 participants