Skip to content

v0.7.0 — Operation-History Retrieval & Self-Maintaining L4 Graph

Choose a tag to compare

@HoweChen HoweChen released this 19 Oct 05:54
· 15 commits to main since this release

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 L4 operates_on graph join does the exact filtering; ACT-R activation ranks the results. The read path is LLM-free, and unresolvable resources degrade gracefully to plain recall.
  • Structured record_event slots. Optional resources and action_class arguments resolve against a resource registry (L2 type=resource, lazily-grown aliases) and link operates_on edges deterministically at write time.
  • Self-maintaining L4 graph. Write-time deterministic projections (operates_on, produced_from, calls/imports from code_refs — all idempotent via ProjectedEdgeID upserts) plus a new MaintainL4 System 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_refs rows 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 over type=resource memories at a read-side threshold of 0.75, below the write-side 0.85); Stage 2 joins L4 operates_on edges 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 flagged fallback=true. Cold-start (no resource entities at all) behaves identically.

Structured Event Recording

  • record_event accepts optional resources (names or aliases) and action_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 deterministic operates_on edge per resource (ProjectedEdgeID, idempotent upsert). Omitting the new fields reproduces the legacy behaviour byte-for-byte (locked by regression tests).
  • Action vocabulary. action_class normalises 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 as action_raw for 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) from record_event; produced_from (fact → source episode) plus operates_on inheritance from consolidation ADD/UPDATE; calls/imports (symbol → symbol) projected from code_refs at index time. All machine edges use ProjectedEdgeID (proj: + truncated SHA-256 of src|relation|dst) so re-running a projection upserts instead of duplicating.
  • MaintainL4 worker 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_class plus optional LLM extraction of resources/actions for episodes recorded before this release (l4_backfill op).
    • Semantic linking — gated (config flag, LLM availability, minimum recent episodes) same-(layer, action_class)-bucket candidate pairs, similarity-prefiltered and budgeted per cycle (l4_link op).
    • Alias merge — high-similarity resource pairs confirmed by the LLM (l4_alias_merge op) merge into one entity: aliases unioned, incoming operates_on edges re-pointed, superseded entity retired via the standard supersedes chain.
  • 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

  • NeighborCounts endpoint filtering — neighbour centrality no longer counts edges whose endpoint memory is gone (EXISTS join on both endpoints, both backends).
  • SweepDanglingEdges() — new Store method deleting valid edges with missing endpoints, wired into every System 2 cycle.
  • DeleteCodeArtifactsByFile() — new Store method for re-index hygiene: removes a file's code_refs (via subquery, ordered before code_symbols), code_symbols rows, and symbol memories, and keeps the SQLite in-process vector index in sync.
  • Consolidation provenance — ADD/UPDATE now project produced_from and inherit operates_on targets 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_ops pipeline; the MCP front-end lists ten tools.
  • README (en + zh-CN): new "What's New in 0.7.0" sections, recall_ops usage 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 vet clean on both the default and enterprise build configurations; fixture-dependent test files carry //go:build !enterprise tags.

Full Changelog: v0.6.0...v0.7.0