Give the write path a CLI and an MCP face

remember / supersede / forget now reach the one Python writer from a
terminal, from MCP, and from HTTP. The server, not the caller, decides
who owns a memory.

- cli: remember, supersede, forget. --holder falls back to
  settings.default_holder until the holder registry lands. Timestamps are
  parsed once with one clear message.
- ingestion: import pymupdf as fitz. The deprecated fitz import printed a
  warning to stdout, so every CLI command's JSON answer was unparseable.
- mcp: remember, supersede_memory and forget_memory forward to the Python
  writer over HTTP (ELY_EYE_API, default http://127.0.0.1:8765). SQLite
  stays read-only to the Go side, so the write rules live in one place.
- mcp reads follow schema v2: atoms.time became ingested_at, and reads go
  through v_atoms_current, so a superseded memory stops being findable.
  holder, origin, scenario and event_time now show up in fetch_atom and
  search_atoms.
- scripts/mcp_write_smoke.sh proves the loop end to end: remember, search,
  supersede, forget, then not found.

Evidence: 92 pytest passed; go build, go vet and go test clean; mypy clean
on the 10 touched source files with a fresh cache; ruff clean except a
pre-existing B008 at cli.py:292, identical at HEAD.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 15:09:17 -04:00
1 parent 181f6bf57e
commit 3d792417cf
20 files changed
+1425 -33

No files matched your search

+40 -2
View File
@@ -1,5 +1,37 @@
package domain
// Memory mirrors the Evidence Atom the Ely-Eye API returns for a write. The
// server stamps holder, origin and ingestion time, so the MCP side never
// invents them.
type Memory struct {
AtomID string `json:"atom_id"`
SourceID string `json:"source_id"`
Source string `json:"source"`
HolderID string `json:"holder_id"`
Origin string `json:"origin"`
Scenario string `json:"scenario"`
Text string `json:"text"`
IngestedAt string `json:"ingested_at"`
EventTime string `json:"event_time,omitempty"`
EventTimePrecision string `json:"event_time_precision,omitempty"`
ValidFrom string `json:"valid_from,omitempty"`
ValidTo string `json:"valid_to,omitempty"`
RetentionUntil string `json:"retention_until,omitempty"`
Supersedes []string `json:"supersedes"`
TokenEquivalent int64 `json:"token_equivalent"`
}
type ForgetReport struct {
SourceID string `json:"source_id"`
AtomIDs []string `json:"atom_ids"`
AtomsDeleted int `json:"atoms_deleted"`
EdgesDeleted int `json:"edges_deleted"`
CacheEntriesCleared int `json:"cache_entries_cleared"`
VectorIndexDropped bool `json:"vector_index_dropped"`
AffectedCartridges []any `json:"affected_cartridges"`
Reason string `json:"reason"`
}
type CacheLayer struct {
Layer string `json:"layer"`
Entries int `json:"entries"`
@@ -44,7 +76,11 @@ type Atom struct {
SourceID string `json:"source_id"`
Modality string `json:"modality"`
Source string `json:"source"`
Time string `json:"time"`
IngestedAt string `json:"ingested_at"`
HolderID string `json:"holder_id,omitempty"`
Origin string `json:"origin,omitempty"`
Scenario string `json:"scenario,omitempty"`
EventTime string `json:"event_time,omitempty"`
Text string `json:"text"`
ImageRef string `json:"image_ref,omitempty"`
Layout any `json:"layout,omitempty"`
@@ -65,7 +101,9 @@ type AtomSummary struct {
SourceID string `json:"source_id"`
Modality string `json:"modality"`
Source string `json:"source"`
Time string `json:"time"`
IngestedAt string `json:"ingested_at"`
HolderID string `json:"holder_id,omitempty"`
Scenario string `json:"scenario,omitempty"`
TextPreview string `json:"text_preview"`
ImageRef string `json:"image_ref,omitempty"`
TokenEquivalent int64 `json:"token_equivalent"`