Repository navigation
v4.2.0 "Loop"
v4.2.0 "Loop" — engram closes the agent's research loop
The original Context Spine goal was to collapse the whole grep → read → read investigation loop, not just the single file read. v4.1 shipped ranking; v4.2 ships the rest of the loop — and every piece is gated so it only fires when it genuinely saves tokens, with an escalation path so it can never blind the agent.
Added
- Grep interception → call sites (ADR-0001, ADR-0004). A content-mode grep for a well-referenced symbol is answered from the reference graph with the actual
file:line: codecall sites — smaller than the raw grep (initis 573 vs 9,317 tokens on engram's own repo) while showing the real usage. Defaultfiles_with_matches/countgreps and low-usage symbols (< 4caller files) pass straight through. Always carries anrg -nescalation.ENGRAM_GREP_INTERCEPT=0opts out. - Same-session read dedup (ADR-0003). Re-read an unchanged file you already read this session and engram returns a pointer instead of re-serving it. Recall-safe by construction: byte-unchanged (mtime+size) guard, full reads only, a 400-byte floor, and a PreCompact + SessionStart reset so it never points at content that compaction or
/clearevicted. A 30-min TTL + 256-entry cap bound any unsignalled eviction.ENGRAM_READ_DEDUP=0opts out. - Deterministic session-level bench (
bench/session-level.ts). Replays machine-generated investigation traces through the real handlers and models the session saving as a curve over how often the agent re-fetches raw content — the break-even point is the honest headline, not a single number.
Honesty
Everything here is a structural context-token reduction, not a bill saving (engram's net agent-loop cost over prompt caching is ~0). Numbers are measured and gated so an interception never costs more than the call it replaces.
1100 tests passing. Apache 2.0, local SQLite, zero cloud. See CHANGELOG.md for the full diff.