store
store
¶
Git-backed checkpoint store for distillation config rollback.
A thin wrapper over a local git repository at <openjarvis_home>/.git.
The repo tracks config.toml, agents/, and tools/ so that the
diff between two commits captures the harness state at any point in time.
The repo does NOT track learning/ (sessions are append-only artifacts,
not config state).
The wrapper shells out to git via subprocess rather than depending
on a third-party library — keeps the dependency surface zero.
See spec §7.4 and §7.6.
Classes¶
DirtyWorkingTreeError
¶
Bases: RuntimeError
Raised when begin_stage is called on a working tree with uncommitted changes.
StageHandle
dataclass
¶
Snapshot of repo state captured at the start of a staging operation.
CheckpointStore
¶
Thin git wrapper for the distillation checkpoint repo.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The directory that contains the checkpoint repo (the repo's
TYPE:
|
Source code in src/openjarvis/learning/distillation/checkpoint/store.py
Functions¶
init
¶
Initialize the checkpoint repo if it doesn't exist.
Refuses to initialize if self.root is inside the OpenJarvis source
tree — this is the same defense-in-depth check as
resolve_distillation_root: we never want a stray git repo writing
config snapshots into the working copy.
Idempotent: if .git already exists and contains a baseline commit,
does nothing.
Source code in src/openjarvis/learning/distillation/checkpoint/store.py
current_sha
¶
begin_stage
¶
begin_stage(edit_id: str) -> StageHandle
Capture HEAD sha and assert the working tree is clean.
| RAISES | DESCRIPTION |
|---|---|
DirtyWorkingTreeError
|
If there are uncommitted changes to tracked files. The orchestrator should never start a stage on a dirty tree — it indicates the user has manual edits in progress. |
Source code in src/openjarvis/learning/distillation/checkpoint/store.py
commit_stage
¶
commit_stage(handle: StageHandle, *, message: str, session_id: str, risk_tier: str) -> str
Stage all tracked-path changes and create a commit.
The commit message has the form::
<message>
Edit-ID: <handle.edit_id>
Session-ID: <session_id>
Risk-Tier: <risk_tier>
Returns the new commit sha (abbreviated).
Source code in src/openjarvis/learning/distillation/checkpoint/store.py
discard_stage
¶
discard_stage(handle: StageHandle) -> None
Restore the working tree to handle.pre_stage_sha.
Source code in src/openjarvis/learning/distillation/checkpoint/store.py
revert_session
¶
Revert all commits tagged Session-ID: <session_id>.
Reverts are applied in reverse chronological order (newest first), each producing a new commit so history is preserved (no rewriting). Returns the list of new revert commit shas.