Git-backed Beancount journal: commit-per-write #25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Move the Beancount file from a plain file to one that lives inside a git repo, with a structured commit recorded after every write. This is the load-bearing step toward Tackler-style auditability (issue #26) — the commit-id leg of the audit triplet comes for free from git, and historical reports become reproducible by re-running against a specific commit.
Prerequisite
Depends on #24 (reversing entries). The point of git-backed commit-per-write is to record an immutable per-write history; while the void path still mutates the source file in place, the commits would interleave append-style and edit-style writes and lose the strict append-only property that makes the audit story defensible.
After #24, there is exactly one mutation surface (
FavaClient.add_entry), and commit-per-write becomes a one-line decorator around it.Scope
Repository setup
<fava_ledger_dir>/.git).fava_ledger_repo_path(optional override),git_commit_enabled(bool, default true),git_author_name/git_author_email(commit metadata).Write path
FavaClient.add_entry, after a successfulPUT /api/add_entriesresponse, commit the modified ledger file._write_lockso commit + write are serialized as a single critical section. (Lock already exists; no new locking needed.)reversesfield above. This makes git history carry the supersession chain explicitly, which is useful for forensic reconstruction even though thereverses:meta on the entry itself is the canonical record.Git library choice
pygit2ordulwichfor in-process commits — avoid shelling out to thegitCLI (process spawn cost on every write, harder to test).dulwichis pure-Python and probably easier to package;pygit2is faster but binds to libgit2. Pick one based on what's already in the LNbits dependency tree.Failure handling
delete_entrywould itself need to be committed; turtles all the way down).Tests
add_entrycalls produce sequential commits in the expected order.Out of scope
git init && git add -A && git commit -m "initial import"before this feature goes live.Dependencies