Skip to content

fix: restore Git backups containing Unicode line separators - #188522

Merged
roboclaw-bot merged 1 commit into
openclaw:mainfrom
dubr1k:fix/git-backup-unicode-jsonl-records
Nov 7, 2026
Merged

roboclaw-bot merged 1 commit into
openclaw:mainfrom
dubr1k:fix/git-backup-unicode-jsonl-records

Conversation

@dubr1k

@dubr1k dubr1k commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #188519
Related: #145938

What Problem This Solves

Fixes Git backup restoration failing when saved text contains Unicode line or paragraph separators.

User Impact

Operators can restore and verify existing Git backups containing U+2028/U+2029 without rewriting their backups. The backup format and SQLite publication checks remain unchanged; no migration is required.

Why This Change Was Made

The backup writer produces LF-delimited JSON, but node:readline also splits at Unicode separators on the tested runtime. Read records at LF boundaries with the existing streaming UTF-8 decoder instead. Keep hashing the original byte chunks and inserting rows in bounded batches.

Published 2026.10.10: restoration gap remains

The published tag still constructs a node:readline reader and parses each emitted record as JSON. The Unicode-separator regression covered by this PR remains reproducible in the shipped 10.10 reader. The release's other backup improvements do not establish that this framing defect is fixed.

This PR changes record framing only. It preserves the existing backup format, raw-byte hashes, bounded inserts, integrity checks, and fresh-database publication. It remains separate from the Codex/WebChat fixes in #188698 and #188526; no Gateway preload or runtime-wide workaround is proposed here.

Evidence

Additional stable 2026.11.1 compatibility check — November 7, 2026

The source change applies cleanly to the stable 2026.11.1 codec and produces the same candidate used in the isolated package checks. The unchanged stable reader fails verify/restore on literal U+2028/U+2029 while its ASCII control passes. With LF-only framing, verify and fresh-target restore both pass on Node 24.22.1 and Bun 1.4.3 for ASCII, Unicode records larger than 1 MiB, and a record/chunk-boundary fixture. Hash mismatch, invalid UTF-8, incorrect row count, and an existing restore target are rejected without publishing a partial target. This is additional shipped-release compatibility evidence, separate from the exact PR-head CLI proof below; it does not claim a new execution of this PR head.

Current main 2e13c52c still constructs the node:readline reader, so this remains an outstanding source fix. The branch is mergeable at the time of this check; no unrelated rebase or runtime-wide preload is added.

Additional published-release check — November 3, 2026

The official 10.10 reader failed on a synthetic backup containing literal U+2028/U+2029. An isolated, explicitly scoped verify/restore helper applying the same LF-framing correction in memory passed against the installed 10.10 packages on macOS and Linux. Fresh synthetic restores preserved the exact SQLite TEXT bytes, and integrity checks passed. Corrupted data or manifest hashes were rejected without publishing a target; an existing target was preserved.

This is compatibility evidence for the framing correction on shipped 10.10, not a new exact-head CLI run of this PR. The helper is external to the proposed patch and is not loaded into Gateway. No production database was restored. The exact-candidate CLI proof and CI evidence remain below.

  • Extended the existing production SQLite dump/restore round trip with literal U+2028/U+2029 in TEXT keys and values. On the base, restoration fails with Unterminated string in JSON; with the fix, byte-level SQLite comparisons and manifest verification pass.
  • Node 24.22.1: 28 tests pass across the codec, restore-failure cleanup, and Git backup integration suites; one existing test is skipped. The final command took 72.74 s including worker preparation and integration fixtures. The exact changed test file also passes separately with the repository’s default runtime selection (2 cases, 12.10 s wall time). Production core typechecking, targeted oxlint, formatting, and git diff --check pass.
  • Shared autoreview of the production change and regression against b195f61511f9310d9a4dd416e517fb9ec0755f4d, P0–P2: no actionable findings. The reviewer inspected the diff and supplied UTF-8/cleanup context; test execution was performed separately.
  • Added one test-line allocation for the single new fixture row; the shared baseline is untouched. No extra test fixture, process, or model call was added.

The shipped CLI was built at ea07e82 (pnpm build, exit 0, 4m 16s). Both backup git verify and backup git restore exit 0 on the same unchanged, committed synthetic backup containing literal U+2028/U+2029. Independent SQLite reads preserve the exact TEXT bytes; integrity and foreign-key checks pass. A modified table with its original manifest is rejected by both commands (exit 1, hash mismatch), and restore publishes no target.

GitHub CI, dependency review, and security-sensitive review gates pass on this head. All databases and state used for CLI proof were disposable and isolated; no production restoration or release qualification is claimed.

Redacted CLI proof on the exact candidate
Exact candidate: ea07e82dba8ce120b482820482d8fc4f95773c67
Runtime: Node v24.22.1
Only local synthetic state was used; <SOURCE> and <FIXTURE> replace local paths.

$ node <SOURCE>/openclaw.mjs --version
OpenClaw 2026.10.9 (ea07e82)

$ node <SOURCE>/openclaw.mjs backup git verify --repository <FIXTURE>/repository --ref e24d867216433e72dc108b389a794a6b2abe290c --store unicode-proof --json
exit=0
Selected JSON stdout (local targetPath redacted):
{
  "tables": [
    {
      "table": "unicode_records",
      "rows": 2,
      "sha256": "233277286d444f80aae5b1409aaadaf3f3e8e8286d717fbb7ef2f801ba5ae1fc",
      "ok": true
    }
  ],
  "commit": "e24d867216433e72dc108b389a794a6b2abe290c"
}

$ node <SOURCE>/openclaw.mjs backup git restore --repository <FIXTURE>/repository --ref e24d867216433e72dc108b389a794a6b2abe290c --store unicode-proof --target <FIXTURE>/restored.sqlite --json
exit=0
Selected JSON stdout (local targetPath redacted):
{
  "tables": [
    {
      "table": "unicode_records",
      "rows": 2,
      "sha256": "233277286d444f80aae5b1409aaadaf3f3e8e8286d717fbb7ef2f801ba5ae1fc",
      "ok": true
    }
  ],
  "commit": "e24d867216433e72dc108b389a794a6b2abe290c"
}

Independent SQLite read:
SELECT key,value FROM unicode_records ORDER BY key;
[["line\u2028separator", "paragraph\u2029separator"], <ordinary control-character row omitted; see hex below>]
SELECT hex(key),hex(value) FROM unicode_records ORDER BY key;
[["6C696E65E280A8736570617261746F72", "706172616772617068E280A9736570617261746F72"], ["6F7264696E617279", "656D6F6A6920F09F98803B2043520D204C460A204E554C00"]]
PRAGMA integrity_check; -> ok
PRAGMA foreign_key_check; -> []
Original snapshot JSONL bytes and manifest digest remained unchanged: 233277286d444f80aae5b1409aaadaf3f3e8e8286d717fbb7ef2f801ba5ae1fc

Negative control: a separate fixture commit changes a JSONL value without updating its manifest.
$ node <SOURCE>/openclaw.mjs backup git verify --repository <FIXTURE>/repository --ref <TAMPERED_COMMIT> --store unicode-proof --json
exit=1
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "Git backup table hash mismatch: unicode_records"
  }
}
$ node <SOURCE>/openclaw.mjs backup git restore --repository <FIXTURE>/repository --ref <TAMPERED_COMMIT> --store unicode-proof --target <FIXTURE>/must-not-publish.sqlite --json
exit=1
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "Git backup table hash mismatch: unicode_records"
  }
}
Tampered restore target exists: false
No production database or Gateway was read, restored, or restarted.

@clawsweeper

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

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Read Git backup records at LF boundaries so Unicode line and paragraph separators remain intact.

Example: Restore a backup containing the TEXT key "line\u2028separator" and value "paragraph\u2029separator", with literal separator characters.

  • Before: Restoration fails with Unterminated string in JSON.
  • After: Restoration preserves the exact TEXT bytes and verifies the original manifest digest.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused contract repair with shipped CLI evidence, independent byte checks, a tampering control, meaningful regression coverage, and green exact-head gates.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The added PR-body terminal output resolves the prior proof request: the built CLI at ea07e82 on Node v24.22.1 verifies and restores an unchanged committed Unicode-bearing backup in isolated synthetic state, preserves exact SQLite TEXT bytes and the manifest digest, and rejects tampered content without publishing a target. The encoder, manifest, schema, and persisted representation remain unchanged, establishing a no-migration case.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot restore or verify valid Git backups containing Unicode line or paragraph separators.
Reason: Lossless restoration is an existing documented contract, and this focused repair adds no setting or public format change.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR repairs a confirmed backup restoration defect still present on main, with no actionable correctness findings.

Priority: P2
Reviewed head: ea07e82dba8ce120b482820482d8fc4f95773c67

Before merge

None.

Findings

None.

Agent review details

How this fits together

Git backup verification and restoration materialize committed artifacts, load their records into private SQLite staging, validate integrity and digests, and publish a fresh restore target.

flowchart LR
  A[Backup CLI] --> B[Committed Git artifacts]
  B --> C[UTF8 decoding and LF framing]
  C --> D[Private SQLite staging]
  D --> E[Integrity and manifest checks]
  E --> F[Fresh restore target]
Loading

Technical review

Best possible solution:

Land LF-only framing in the existing codec while preserving UTF-8 text, original-byte hashes, bounded batches, and verified publication.

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

The LF-writing encoder, current-main reader, inspected Node framing expression, and independent official-release failure traces establish the mechanism; this read-only review executed no target code.

Is this the best way to solve the issue?

The defect is record splitting inside valid JSON strings; the required invariant is one LF-delimited record per parse, and the patch restores it using the existing decoder and restore owner without unnecessary machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 37b4fc8 adds src/snapshot/git-backup-codec.ts:475 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 37b4fc8621d9; files: src/snapshot/git-backup-codec.ts)
  • juyaohuidt: Raw commit 75c90bd adds src/snapshot/git-backup-codec.ts:554 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 75c90bd4d77f; files: src/snapshot/git-backup-codec.ts)
  • Ayaan Zaidi: Raw commit a036c70 adds src/snapshot/git-backup-codec.ts:177 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a036c70ee75d; files: src/snapshot/git-backup-codec.ts)

PR surface

Source +15, Tests +1, Other +2. Total +18 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 28 13 +15
Tests 1 1 0 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 31 13 +18

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145938
Summary: This PR narrowly repairs the canonical Git backup framing defect also covered by a broader conflicting proposal.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Specific valid Unicode text prevents backup verification and restoration, with confirmed affected releases and a bounded reader repair.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-30T16:43:57.113Z sha ea07e82 :: needs real behavior proof before merge. :: none

Reviewed October 30, 2026, 3:38 PM ET / 19:38 UTC (Revision 2).

@dubr1k

dubr1k commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@dubr1k

dubr1k commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Published 10.10 follow-up: the Unicode-separator restoration defect is still present in the shipped reader. The description now links the exact published-tag code and separates this issue from the release's unrelated backup improvements.

I also recorded synthetic verify/restore compatibility checks on the installed 10.10 packages on macOS and Linux using an isolated LF-framing helper, with exact TEXT-byte preservation and corruption rejection. That is additional compatibility evidence, not a new exact-head PR run or a production restore. The existing exact-candidate CLI proof and review remain unchanged. Please consider the focused reader fix for maintainer review; there is no Gateway-wide workaround in this PR.

@roboclaw-bot
roboclaw-bot merged commit f6d1e4c into openclaw:main Nov 7, 2026
186 of 187 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @dubr1k. An independent review found no P0–P2 issues and CI is green, so this is merged as f6d1e4c, with you as author. It isn't released yet and will ship in the next release.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
…#188522)

Git backup restore and verify now handle saved text containing Unicode line and paragraph separators (U+2028/U+2029) without rewriting the backup. The backup format and SQLite publication checks are unchanged (fixes openclaw#188519).

Co-authored-by: dubr1k <[email protected]>
@werunultras

Copy link
Copy Markdown

Independent verification on main 433a0c35850349620fbcb23cf6792f2e7d882fde: both tests in src/snapshot/git-backup-codec.test.ts pass with the repository's pinned test runtime on macOS arm64 (Node 26.12.1 orchestration).

The existing synthetic SQLite dump/restore round trip preserves literal U+2028 in a key and U+2029 in a value, including the original bytes checked through hex(...). The historical-schema restore and invalid-manifest rejection test also passes. This matches the Unicode-separator restore failure we were investigating; no additional reader patch appears necessary on this main revision.

Only synthetic fixtures were used. This verifies current source, not inclusion in a particular published package or restoration of a production backup.

maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…#188522)

Git backup restore and verify now handle saved text containing Unicode line and paragraph separators (U+2028/U+2029) without rewriting the backup. The backup format and SQLite publication checks are unchanged (fixes openclaw#188519).

Co-authored-by: dubr1k <[email protected]>

(cherry picked from commit f6d1e4c)

Release adaptation: LF-only JSONL framing using existing strict UTF-8 decoder; byte hash, SQLite decode and batching unchanged. Exclude allocation record and unrelated later allocation retirement.

Follow-up dispositions: d6ded18 chore(ci): drop retired test-lines allocation records (2/3) (openclaw#197656)

Validation: Direct framing experiment: Node readline splits one U+2028/U+2029 JSON row into 3 invalid lines; LF parser preserves exact row. Full restore regression blocked during compiled-worker setup (quickjs/lancedb, then markdown package dependency resolution); not restore proof. diff --check passes.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6d5145708500b492af7ba91ccc0d2f67dcd06439)
(cherry picked from commit 78fbd01c6544cbd5d0e8ec6d230cb273b4c3b3a2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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]: Git backups containing Unicode separators fail to restore

3 participants