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:
1 parent
181f6bf57e
commit
3d792417cf
20 files changed
+1425
-33
No files matched your search
@@ -18,9 +18,11 @@ func (s *Store) FetchAtom(ctx context.Context, atomID string) (domain.Atom, erro
|
||||
return domain.Atom{}, errors.New("atom_id is required")
|
||||
}
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT atom_id, source_id, modality, source, time, text, COALESCE(image_ref, ''),
|
||||
SELECT atom_id, source_id, modality, source, ingested_at,
|
||||
COALESCE(holder_id, ''), COALESCE(origin, ''), COALESCE(scenario, ''),
|
||||
COALESCE(event_time, ''), text, COALESCE(image_ref, ''),
|
||||
COALESCE(layout_json, ''), relations_json, trust_json, token_equivalent, metadata_json
|
||||
FROM atoms
|
||||
FROM v_atoms_current
|
||||
WHERE atom_id = ?`, atomID)
|
||||
atom, err := scanAtom(row)
|
||||
if err != nil {
|
||||
@@ -48,12 +50,14 @@ func (s *Store) SearchAtoms(ctx context.Context, query string, modality string,
|
||||
}
|
||||
args = append(args, limit)
|
||||
rows, err := s.db.QueryContext(ctx, `
|
||||
SELECT a.atom_id, a.source_id, a.modality, a.source, a.time, a.text,
|
||||
SELECT a.atom_id, a.source_id, a.modality, a.source, a.ingested_at,
|
||||
COALESCE(a.holder_id, ''), COALESCE(a.origin, ''), COALESCE(a.scenario, ''),
|
||||
COALESCE(a.event_time, ''), a.text,
|
||||
COALESCE(a.image_ref, ''), COALESCE(a.layout_json, ''),
|
||||
a.relations_json, a.trust_json, a.token_equivalent, a.metadata_json,
|
||||
bm25(atom_fts) AS score
|
||||
FROM atom_fts
|
||||
JOIN atoms a ON a.atom_id = atom_fts.atom_id
|
||||
JOIN v_atoms_current a ON a.atom_id = atom_fts.atom_id
|
||||
WHERE atom_fts MATCH ? `+filter+`
|
||||
ORDER BY score
|
||||
LIMIT ?`, args...)
|
||||
@@ -104,7 +108,11 @@ func scanAtom(scanner atomScanner) (domain.Atom, error) {
|
||||
&atom.SourceID,
|
||||
&atom.Modality,
|
||||
&atom.Source,
|
||||
&atom.Time,
|
||||
&atom.IngestedAt,
|
||||
&atom.HolderID,
|
||||
&atom.Origin,
|
||||
&atom.Scenario,
|
||||
&atom.EventTime,
|
||||
&atom.Text,
|
||||
&atom.ImageRef,
|
||||
&layout,
|
||||
@@ -147,7 +155,11 @@ func scanAtomHit(scanner atomScanner) (domain.Atom, float64, error) {
|
||||
&atom.SourceID,
|
||||
&atom.Modality,
|
||||
&atom.Source,
|
||||
&atom.Time,
|
||||
&atom.IngestedAt,
|
||||
&atom.HolderID,
|
||||
&atom.Origin,
|
||||
&atom.Scenario,
|
||||
&atom.EventTime,
|
||||
&atom.Text,
|
||||
&atom.ImageRef,
|
||||
&layout,
|
||||
|
||||
Reference in new issue
Block a user