Repository navigation
v0.7.0 — Operation-History Retrieval & Self-Maintaining L4 Graph
Highlights
This release gives agents a first-class operation-history memory: recording what was done to which resource, and retrieving it back by resource and action instead of free-text similarity. It also turns the L4 associative graph from a passive index into a self-maintaining structure — deterministic projections at write time plus a budgeted maintenance step in the System 2 worker.
- Operation-history retrieval (
recall_ops). A resource × action pivot query answering "how did I last operate on X?". Vector search is confined to resource resolution; an L4operates_ongraph join does the exact filtering; ACT-R activation ranks the results. The read path is LLM-free, and unresolvable resources degrade gracefully to plainrecall. - Structured
record_eventslots. Optionalresourcesandaction_classarguments resolve against a resource registry (L2type=resource, lazily-grown aliases) and linkoperates_onedges deterministically at write time. - Self-maintaining L4 graph. Write-time deterministic projections (
operates_on,produced_from,calls/importsfromcode_refs— all idempotent viaProjectedEdgeIDupserts) plus a newMaintainL4System 2 step: dangling-edge GC every cycle, budgeted slot backfill, gated semantic linking, and resource alias-merge. - Re-index hygiene. Re-indexing a changed file purges its stale symbol memories,
code_symbols/code_refsrows and in-process vector entries first — removed symbols no longer linger. - Documentation matched to code. Architecture claims that ran ahead of the implementation are now accurate, including an honest scoping note: code-ref projection covers same-file call/import relations today; cross-file extraction is future work.
What's Changed
Operation-History Retrieval
recall_ops— new engine query (Scope.RecallOperations/Engine.RecallOperations) with a three-stage pipeline: Stage 1 resolves the resource (exact alias match → vector nearest-neighbour overtype=resourcememories at a read-side threshold of 0.75, below the write-side 0.85); Stage 2 joins L4operates_onedges and filters by normalised action, time window and outcome; Stage 3 ranks with ACT-R activation. Exposed as the 10th MCP tool (recall_ops), a CLI command (ladym recall-ops --resource … --action … --outcome …), and Go SDK one-shot helpers (ladym.RecordOperation/ladym.RecallOperations).- Fallback semantics. Unknown resources never error the caller: the query degrades to a plain
recall(resource + " " + action)and the response is flaggedfallback=true. Cold-start (no resource entities at all) behaves identically.
Structured Event Recording
record_eventaccepts optionalresources(names or aliases) andaction_class. Each resource resolves through the registry — reusing an existing entity, growing its alias list via a vector match, or creating a new one — and the episode gets a deterministicoperates_onedge per resource (ProjectedEdgeID, idempotent upsert). Omitting the new fields reproduces the legacy behaviour byte-for-byte (locked by regression tests).- Action vocabulary.
action_classnormalises against a controlled vocabulary — 31 canonical words across knowledge/code/ops/communication domains plus built-in aliases (run→execute,rm→delete,grep→search, …). Exact match only: unknown actions are preserved asaction_rawfor the worker to backfill, never guessed. Extend via the[resource]config section (actions,action_aliases).
L4 Graph Maintenance
- Write-time deterministic projections.
operates_on(episode/fact → resource) fromrecord_event;produced_from(fact → source episode) plusoperates_oninheritance from consolidation ADD/UPDATE;calls/imports(symbol → symbol) projected fromcode_refsat index time. All machine edges useProjectedEdgeID(proj:+ truncated SHA-256 of src|relation|dst) so re-running a projection upserts instead of duplicating. MaintainL4worker step (System 2 cycle, after Decay):- Dangling-edge GC runs every cycle as correctness hygiene (defence-in-depth for pre-FK databases and external writers; current schema already cascades).
- Slot backfill — heuristic exact-match stamping of
action_classplus optional LLM extraction of resources/actions for episodes recorded before this release (l4_backfillop). - Semantic linking — gated (config flag, LLM availability, minimum recent episodes) same-(layer, action_class)-bucket candidate pairs, similarity-prefiltered and budgeted per cycle (
l4_linkop). - Alias merge — high-similarity resource pairs confirmed by the LLM (
l4_alias_mergeop) merge into one entity: aliases unioned, incomingoperates_onedges re-pointed, superseded entity retired via the standardsupersedeschain.
- Three new agent ops registered in
NAMED_OPS(l4_backfill,l4_link,l4_alias_merge) — each independently configurable via[agents], each fully optional (no LLM configured ⇒ the steps skip cleanly).
Correctness & Storage
NeighborCountsendpoint filtering — neighbour centrality no longer counts edges whose endpoint memory is gone (EXISTS join on both endpoints, both backends).SweepDanglingEdges()— newStoremethod deleting valid edges with missing endpoints, wired into every System 2 cycle.DeleteCodeArtifactsByFile()— newStoremethod for re-index hygiene: removes a file'scode_refs(via subquery, ordered beforecode_symbols),code_symbolsrows, and symbol memories, and keeps the SQLite in-process vector index in sync.- Consolidation provenance — ADD/UPDATE now project
produced_fromand inheritoperates_ontargets onto the new fact. A dead Python-parity branch in the offline classifier (superseded_by == candidateHash, comparing a UUID against a content hash — never true) was removed; replay protection is carried by the content-hash equality check, locked by a regression test.
Documentation
- ARCHITECTURE.md: L1 row documents the resource × action slots; L4 row replaced the aspirational "auto-link on write" with the actual write-time projections + worker maintenance; the storage layout lists all edge relations; new §3b documents the
recall_opspipeline; the MCP front-end lists ten tools. - README (en + zh-CN): new "What's New in 0.7.0" sections,
recall_opsusage for MCP and CLI,[resource]/[maintain]configuration reference.
Testing & Quality
- Coverage (new code on this branch): operations 94.6%, engine 96.5%, code 95.4%; eleven functions initially under 80% were driven to 100% with edge-case suites (+1,240 lines of tests, zero production-code changes); storage reaches 97%+ with the Postgres suite live (
make test-pg). - New suites are scenario-named across the stack:
neighbor_counts_join_test.go,sweep_dangling_test.go,record_operation_test.go,consolidate_provenance_test.go,delete_code_artifacts_test.go,indexer_projection_test.go,recall_operations_test.go,maintain_test.go,maintain_cycle_test.go, and per-file coverage suites. go vetclean on both the default andenterprisebuild configurations; fixture-dependent test files carry//go:build !enterprisetags.
Full Changelog: v0.6.0...v0.7.0