Skip to main content

Module git_metadata

Module git_metadata 

Source
Expand description

P4e (COMPOSABLE-HARNESS-DESIGN.md §1.6/§3.1 core.session.git_metadata, catalog:331 “Git integration (metadata, diff, PR)”): a persisted, TYPED record of the git branch/sha/dirty state a session was RUNNING under, captured ONCE at session start (closes the loop catalog:331 flags — supercode already preserves a foreign session’s own git-shaped fields byte-for-byte on IMPORT via Session::raw’s verbatim capture; this is the WRITE half: supercode’s OWN sessions get the same provenance). Deliberately flat/typed (not a formatted string), the exact same rationale as crate::usage_log::UsageRecord/ crate::model_change::ModelChangeRecord (§1.13): a translatable, lossless session-data channel, not a lossy notice — so it survives a save/load round trip byte-for-byte, and a future reader (a translator, doctor/inspect stats) can consume it without re-parsing prose.

Structs§

GitMetadataRecord
One session’s git provenance, best-effort captured at construction time (Agent::with_parts, gated by Config::session_git_metadata).

Functions§

capture
Best-effort capture of cwd’s git branch/sha/dirty state. None when cwd isn’t inside a git repo, git isn’t on PATH, or the repo has no commits yet (rev-parse HEAD fails on an empty repo) — this is informational provenance, never worth failing agent construction over, the same posture agent::env_context_git_status already established.
from_json
Parse a <name>.git.json sidecar back into a record — the exact inverse of to_json.
to_json
Serialize a record as single-line JSON — the <name>.git.json sidecar shape crate::store::SessionStore::save_git_metadata writes (a single-record file, like <name>.reduction.json, not a JSONL log: git state is captured once per session, not once per turn).