Skip to main content

Module conclusions_export

Module conclusions_export 

Source
Expand description

Plan B t-004: shared conclusion-export pipeline used by both the CLI (asd conclusions export) and MCP (conclusions_export tool).

Walks every indexed symbol, collects ledger entries, buckets them by ConclusionClass, and writes one compact, byte-stable JSONL file per class. The output is intentionally minimal — see DESIGN.md “Plan B” for the field layout and rationale.

Structs§

BudgetReport
Result of check_budget. ok is true iff neither the total nor any individual shard exceeds its configured cap.
ExportRecord
Compact JSONL record. preserve_order is on for serde_json in this workspace so field order is stable across runs. Plan B t-005 requires Deserialize too so import can round-trip.
Gathered
Walk the index, bucket every ledger entry by ConclusionClass. Each bucket is sorted by id alone — entry_ids are deterministic hashes (blake3-derived for Plan G thinking, content-derived for others), so id-sort gives:
ImportFileResult
Outcome of importing one JSONL file.
ShardSize
One shard file’s size measurement against the per-shard budget.

Functions§

check_budget
Plan K t-008: walk out_dir, sum sizes per shard file (including per-package subdirectory shards from t-007), and compare against the budget config. Pure read of the filesystem — does not re-export.
export_all
One-shot: gather + write all six files under out_dir. Returns per-class (stem, entry_count, byte_count).
gather
gather_buckets
Back-compat wrapper: the buckets alone.
import_all
One-shot: read every <class>.jsonl under in_dir and upsert each record into the local ledger keyed by entry_id. Idempotent — re-import of unchanged JSONL is a no-op at the bytes level (set_json overwrites with identical content).
merge_jsonl
Git merge driver for .asd/conclusions/*.jsonl.
merge_preserving
Fold the records already committed at path back into a freshly gathered bucket, so the sidecar is additive rather than a snapshot of one clone.
read_jsonl
Read a conclusions JSONL file into records. A missing file is treated as empty (an add/add merge can hand us a nonexistent ancestor). Blank lines are skipped; a malformed line is a hard error so the driver falls back to a plain git conflict rather than silently dropping judgment.
write_jsonl
Write one JSONL file. Returns the byte count written.