Skip to content

Reduce backup blob churn and support pull-only replicas - #268

Open
joshp123 wants to merge 1 commit into
steipete:mainfrom
joshp123:backup-daily-shards
Open

joshp123 wants to merge 1 commit into
steipete:mainfrom
joshp123:backup-daily-shards

Conversation

@joshp123

@joshp123 joshp123 commented Nov 15, 2026 •

Copy link
Copy Markdown

Hey peter hope you're doing good.

been using birdclaw lately but it was filling up my disk. after some clanking it seems that the file format isn't append only, so if you run birclaw every hour, it writes a bunch of JSON about history or whatever, even if nothing changed. this means your birdclaw git archives rapidly balloon to like tens of GB or whatever even if you dont have anywhere near that in tweets.

clanked up something here to keep it as API compatible as possible but keeping the storage as slim as possible. ideally i would have gone for an append-only log, but clankers recommended against it as that would be too much of a rewrite. (if you're feeling like prompting this in, imo its a good idea)

clanker description is below:

Hourly backups repeatedly write new versions of large JSONL blobs when only a few rows change. Git's loose-object storage keeps each complete blob until packing, so archive size can grow much faster than its data.

Split tweet, revision, collection, account-edge and DM content by UTC day; partition profiles by stable identifier buckets; store frequently changing observations separately. Schema 9 retains every field and reconstructs complete rows before the unchanged merge codecs run. Accounts, DM conversations and unaffected tables retain their paths. Commands and flags are unchanged. Older archives still import; older binaries cannot read schema 9, so all readers and writers must upgrade before its first export. Direct JSONL consumers must update their paths and join observations where needed.

Add an opt-in backup.readOnly setting for replicas: automatic backup checks pull and merge, including after local writes, while explicit export/sync and pending-push recovery cannot publish to the configured repository. The default remains bidirectional. Local research remains local; exports to other paths are still allowed.

Validation covers legacy migration, fresh-database restore/export byte identity, repeated unchanged fixture sync to a local Git remote, multi-instance freshness and local-only rows, malformed observations, pull-only research and pending-push recovery, the existing backup transaction suite, and offline full-day replays. Existing profile identity reconciliation behavior is unchanged. No new dependencies or Git maintenance behavior are introduced.

…licas

Hourly backups rewrote whole yearly JSONL files when a few rows changed,
so archives grew far faster than their data. Schema 9 splits content by
UTC day and stores frequently changing observations separately, keeping
every field and the existing merge rules. Adds an opt-in backup.readOnly
setting for pull-only replicas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🦞👀
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:feature Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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:feature Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

This PR introduces smaller schema-9 backup shards, separates mutable observations from content, and adds an optional pull-only replica setting.

Example: A stored tweet created on 2026-11-13 receives an updated like count.

  • Before: Its complete yearly tweet shard is rewritten.
  • After: The content remains in data/v9/tweets/2026-11-13.jsonl while the like count changes in an observation shard.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The approach is useful and has meaningful fixture coverage, but required runtime and upgrade evidence is absent, an existing routing contract regresses, and product direction remains unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Hourly archive refreshes can consume disproportionate disk space by storing new Git blobs for large JSONL shards.
Reason: The storage improvement is useful, but automatic format cutover and the additional replica configuration contract require owner direction.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open: reducing backup churn has clear value, but the format and replica-setting changes need owner direction, and the patch introduces an unknown-date routing regression.

Priority: P2
Reviewed head: df443e6bc01cc0f86add8d8d2f57356690d5771a
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR automatically publish schema 9 on the next export and introduce backup.readOnly together?
  • Recommendation: Stage the two changes separately: Agree on the backup-format rollout first and review pull-only replicas as a separate feature.
  • Why: Schema 9 makes existing archives unreadable to older binaries and changes direct JSONL consumers, while the replica setting adds a separate configuration contract; no recorded owner decision approves either direction.

Before merge

  • Add real behavior proof - The supplied fixture tests exercise real SQLite and local Git through library APIs, but the body and discussion contain no observable shipped-entry-point results for churn reduction or replica behavior; schema-8 fixture generation also does not establish a v0.17.0 upgrade with existing settings and archive data intact. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • [P2] Preserve hash bucketing for unknown creation dates (P2) - Archive imports represent unknown tweet creation dates as 1970-01-01T00:00:00.000Z. The existing codec explicitly treats 1970 as unknown, but day() accepts it, so these tweets and their referenced edges all enter a single 1970-01-01 content shard instead of the promised identifier buckets. Large likes archives therefore retain a concentrated blob that additions repeatedly rewrite. Reject the epoch sentinel for content partitioning and restore the fixture assertion to expect an unknown hash bucket.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Unknown creation-date routing - fa96642: The historical diff explicitly excludes 1970 from dated shards, and generated documentation identifies those rows as collection-only tweets with unknown dates.

Findings

  • [P2] [P2] Preserve hash bucketing for unknown creation dates — src/lib/backup-layout.ts:138
  • [P3] [P3] Correct the generated account and conversation paths — src/lib/backup.ts:610

Provenance

  • Unknown creation-date routing changes intended behavior without addressing why it exists (fa96642: The historical diff explicitly excludes 1970 from dated shards, and generated documentation identifies those rows as collection-only tweets with unknown dates.)

Tests

  • Missing end-to-end proof: Provide redacted shipped-CLI output showing reduced blob churn during repeated changed-data backups and a replica pulling producer changes without publishing local research; no base-failing/head-passing run is supplied.
Agent review details

How this fits together

The backup subsystem exports portable SQLite rows into validated JSONL Git archives and imports remote archives through the existing merge codecs.

flowchart TD
  A[SQLite portable rows] --> B[Backup codecs]
  B --> C[Partitioned content and observations]
  C --> D[Validated staged publication]
  D --> E[Git backup repository]
  E --> F[Import reassembly]
  F --> B
Loading

Technical review

Best possible solution:

Preserve unknown-date bucketing and accurate layout documentation within the existing backup pipeline, with an owner-approved rollout for schema 9 and the replica setting.

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

Current main groups tweets by year and several other mutable tables into single logical shards, so changed rows rewrite large blobs; source also establishes the epoch-routing regression without running target code.

Is this the best way to solve the issue?

Smaller deterministic shards and observation separation address blob churn while retaining merge ownership, but the unknown-date sentinel must survive and the separate replica feature needs an explicit product decision.

Full review comments:

  • [P2] [P2] Preserve hash bucketing for unknown creation dates — src/lib/backup-layout.ts:138
    Archive imports represent unknown tweet creation dates as 1970-01-01T00:00:00.000Z. The existing codec explicitly treats 1970 as unknown, but day() accepts it, so these tweets and their referenced edges all enter a single 1970-01-01 content shard instead of the promised identifier buckets. Large likes archives therefore retain a concentrated blob that additions repeatedly rewrite. Reject the epoch sentinel for content partitioning and restore the fixture assertion to expect an unknown hash bucket.
    Confidence: 0.99
  • [P3] [P3] Correct the generated account and conversation paths — src/lib/backup.ts:610
    A fresh backup README now advertises data/v9/accounts/all.jsonl and, later, data/v9/conversations/all.jsonl. Neither path is produced or accepted by the layout registry: these tables still use data/accounts.jsonl and data/dms/conversations.jsonl. Readers following the generated layout will look for nonexistent files. Retain the actual codec paths in both entries.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: not found in the target repository.

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

Provenance checked

  • Deterministic JSONL backup layout changes intended behavior with a stated reason (d86c9b2: Git-backed text backups provide portable, deterministic archive records; this PR explains that smaller shards reduce loose-object growth.)
  • Bounded shard sizes keeps the original intent (f05944c: Oversized JSONL shards were split into deterministic parts to stay within ordinary Git hosting limits; this PR retains that splitter.)
  • Automatic synchronization after local writes changes intended behavior with a stated reason (refactor: share identity parsing and automatic backup bookkeeping #204: Write-triggered sync deliberately exports local changes even during the freshness window; the PR explicitly proposes an opt-in pull-only exception.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main boundary: The introduced diff raises the portable backup schema from 8 to 9 and adds backup.readOnly; the pinned main still exports schema 8. (src/lib/backup.ts:76, df443e6bc01c)
  • Unknown-date contract: Archive ingestion uses the Unix epoch as an unknown-date sentinel, and the existing backup codec explicitly routes 1970 timestamps to unknown; the new day partitioner treats that sentinel as a real creation day. (src/lib/backup-layout.ts:138, fa966422f256)
  • Generated layout mismatch: The generated README lists data/v9/accounts/all.jsonl and data/v9/conversations/all.jsonl, although the codecs retain data/accounts.jsonl and data/dms/conversations.jsonl. (src/lib/backup.ts:610, df443e6bc01c)
  • Discussion and supplied validation: The complete PR body describes fixture validation and offline replays but supplies no terminal trace, logs, media, or linked results for the changed behavior; comments and reviews contain no maintainer approval. (df443e6bc01c)
  • Existing owner contracts: fix: harden profile and backup synchronization #125 established validated staged publication and recovery; refactor: share identity parsing and automatic backup bookkeeping #204 preserved bidirectional synchronization after writes even during the freshness window. (src/lib/backup.ts:3619, 9e42caa9ecf3)
  • Validation check scope: The successful head check is GitGuardian secret scanning; it does not establish that the backup tests or runtime scenarios passed. (df443e6bc01c)

Likely related people:

  • Peter Steinberger: Raw commit d5c6849 adds src/lib/backup-table-codecs.ts:356 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d5c6849a23d6; files: src/lib/backup-table-codecs.ts)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: This improves disk usage in an advanced backup workflow and contains a bounded routing regression.
  • add merge-risk: 🚨 compatibility: The next export changes persisted archive paths and format to schema 9, which older binaries reject.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This improves disk usage in an advanced backup workflow and contains a bounded routing regression.
  • merge-risk: 🚨 compatibility: The next export changes persisted archive paths and format to schema 9, which older binaries reject.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed November 15, 2026, 6:23 PM ET / 23:23 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant