Skip to content

feat(memory): hindsight-wire compat mount on the REST surface (#414) - #423

Merged
linhdmn merged 1 commit into
mainfrom
hindsight-compat-414
Sep 14, 2026
Merged

linhdmn merged 1 commit into
mainfrom
hindsight-compat-414

Conversation

@linhdmn

@linhdmn linhdmn commented Sep 14, 2026

Copy link
Copy Markdown
Member

What

Implements #414: an opt-in --hindsight-compat mount on the REST listener that speaks **omps Hindsight client wire byte-for-byte**, so memory.backend="hindsight"can point native agent memory at LeanKG with zero omp changes (thememory.backendenum is closed; thehindsight` arm takes a configurable base URL — we now serve its server side).

  • PUT /v1/default/banks/{bank} → 200 (ensure)
  • POST .../memories{items:[{content,timestamp,context,metadata,document_id,tags}]} retained into the bank JSONL
  • POST .../memories/recall{results:[{text,id,type,tags,mentioned_at}]} with all/any tag filtering (page 8 = OMP recall limit)
  • POST .../reflect{text} digest of top recall rows

Key decisions

  • memory.RetainRaw: the hindsight retain wire has no retained_through_user_turn; routing through Retain hits its throughUserTurn <= bankCursor gate and would silently drop every write after the first (0 <= 0). RetainRaw shares Retain defaults, skips the cursor; TestRetainRawNoCursor pins the contrast.
  • Additive alias, flag-gated: native /api/v1/memory/* untouched; compat 404s without --hindsight-compat (pinned). Documents/mental-models endpoints deliberately unmounted (the wiring disables mental models client-side).
  • Tags ride in entry metadata and round-trip; update_mode:"replace" treated as append (JSONL has no revision).

Verification

  • go vet ./... + full go test ./... green (54 pkgs); gofmt clean.
  • Live probe replaying hindsight/client.ts shapes (buildMemoryItem keys, the fields the client reads) against a scratch serve --rest :9799 --memory --hindsight-compat: bank ensure 200; 2-item retain written:2; second-batch retain lands (cursorless proof); ranked recall {results:[{text:…}]}; disjoint tags_match:all excludes; reflect {text} — all PASS.

Harness wiring once merged: memory.backend="hindsight", hindsight.apiUrl=http://127.0.0.1:<rest>, hindsight.mentalModelsEnabled=false.

serve --hindsight-compat aliases the exact HTTP wire omp's
memory.backend:"hindsight" client speaks onto the existing memory
banks: PUT bank ensure, items[] retain, tag-filtered recall returning
{results:[{text}]}, and a reflect digest. Retain lands via the new
cursorless memory.RetainRaw (the hindsight wire has no
retained_through_user_turn, and Retain's 0-cursor gate would silently
drop every batch after the first). Additive alias only: the native
/api/v1/memory/* surface is unchanged and the compat routes 404
without the flag.

Closes #414.
@linhdmn
linhdmn merged commit bc92346 into main Sep 14, 2026
3 checks passed
@linhdmn
linhdmn deleted the hindsight-compat-414 branch September 14, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant