Fold reflection insights into a session playbook as deltas. Near-duplicates
confirm the existing entry (the playbook’s grow-and-refine invariant), so
repeated checkpoints reinforce rather than bloat. Returns (added, confirmed).
Human-readable Learning Ledger — what lean-ctx has actually learned from
real shell outcomes: proven error→fix strategies, recurring pitfalls, and the
counts behind them. Honest counts only — no fabricated token-savings figures,
since “repeat errors avoided” has no measured per-incident token cost.
True for the build/test/dependency/runtime command families this module can
correlate (mirrors the per-tool gates in detect_error_pattern). The
shell-layer hook uses it to skip all disk work for ordinary commands
(ls, cat, echo, …) — a false positive only costs a cheap store load,
never a wrong gotcha (detect_error_pattern still gates the real signal).
Distill the gotcha trace into reusable insights. Pure and deterministic:
an identical store always yields byte-identical, identically-ordered output
(no timestamps, no map iteration order — BTree* keep it stable).