Repository navigation
Add whole-store dump and load, so a backup can carry history - #1
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dumpreturns the served HEAD alone. A database rebuilt from it serves every prompt correctly and holds no commits, no branches, and no ref formain— history, branching and rollback gone, with nothing looking wrong because the prompts still resolve.Adds
DumpCommits,DumpRefs,PutCommit,PutRef,CountCommits.PutCommitwrites 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.