Skip to content

Add whole-store dump and load, so a backup can carry history - #1

Merged
sujal-maheshwari2004 merged 1 commit into
mainfrom
feat/history-dump-and-load
Aug 23, 2026
Merged

sujal-maheshwari2004 merged 1 commit into
mainfrom
feat/history-dump-and-load

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Contributor

Dump returns the served HEAD alone. A database rebuilt from it serves every prompt correctly and holds no commits, no branches, and no ref for main — history, branching and rollback gone, with nothing looking wrong because the prompts still resolve.

Adds DumpCommits, DumpRefs, PutCommit, PutRef, CountCommits.

PutCommit writes a commit verbatim rather than recomputing its hash — the hash is the commit's identity and children name it as a parent, so recomputing would leave a set of disconnected nodes. Re-inserting is a no-op, which is what makes a repeated restore idempotent.

Tests: three commits and two branches out and back, asserting hashes survive verbatim, authorship survives, the branch resolves, and rollback still works afterwards.

Consumed by #4.

Dump returns the served HEAD alone — the prompts table. That is the right shape
for exporting content and the wrong shape for a backup: a database rebuilt from
it serves every prompt correctly and holds no commits, no branches, and no ref
for main to point at. History, branching and rollback are gone, and nothing
looks wrong, because the prompts still resolve.

Adds DumpCommits, DumpRefs, PutCommit, PutRef and CountCommits so the whole
store can be carried.

PutCommit writes a commit verbatim rather than recomputing its hash. The hash is
the commit's identity and every child names it as a parent, so recomputing on
restore would break the chain — the restored history would be a set of
disconnected nodes. Re-inserting an existing commit is a no-op, which is what
makes a repeated restore idempotent.

PutRef deliberately skips SetBranch's checks: a restore replays recorded state
rather than performing a rollback, and the served HEAD comes from its own
records.

CountCommits exists so the CLI can refuse to restore over a database that
already holds history.

Tests cover the full round trip — three commits and two branches out and back —
asserting that commit hashes survive verbatim, authorship survives, the branch
resolves, and rollback still works afterwards. Plus idempotency across a
repeated restore.
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit 6bb03aa into main Aug 23, 2026
1 check passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the feat/history-dump-and-load branch August 23, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant