Fix temporal_next edges: wire link_temporal_next into capture path, fix events_query decryption
- capture.py: call link_temporal_next() after store.insert() in capture_turn() - retrieve.py: call link_temporal_next() in contradict() for contradict inserts - qdrant_store.py: events_query() was json.loads() on encrypted data_json, losing record_id — pass raw string so query_events() can decrypt it
This commit is contained in:
parent
eec312dcb4
commit
344e5edaa8
3 changed files with 18 additions and 5 deletions
|
|
@ -201,6 +201,13 @@ def capture_turn(
|
||||||
log.exception("capture_turn insert failed")
|
log.exception("capture_turn insert failed")
|
||||||
return {"status": "skipped", "record_id": None, "reason": f"insert-failed: {type(e).__name__}"}
|
return {"status": "skipped", "record_id": None, "reason": f"insert-failed: {type(e).__name__}"}
|
||||||
|
|
||||||
|
# Wire temporal_next: link this insert to the previous same-session insert.
|
||||||
|
try:
|
||||||
|
from iai_mcp.retrieve import link_temporal_next
|
||||||
|
link_temporal_next(store, rec, session_id=session_id)
|
||||||
|
except Exception:
|
||||||
|
pass # diagnostic only; never block the write path.
|
||||||
|
|
||||||
return {"status": "inserted", "record_id": str(rec.id), "reason": f"tier={tier}"}
|
return {"status": "inserted", "record_id": str(rec.id), "reason": f"tier={tier}"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1335,10 +1335,10 @@ class QdrantStore:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
raw_data = p.get("data_json") or "{}"
|
raw_data = p.get("data_json") or "{}"
|
||||||
try:
|
# data_json is AES-GCM encrypted; pass it through as a raw string
|
||||||
data = json.loads(raw_data)
|
# so query_events() in events.py can decrypt it properly.
|
||||||
except (TypeError, json.JSONDecodeError):
|
# Pre-02-08 unencrypted rows are plain JSON — query_events()
|
||||||
data = {}
|
# handles both paths via is_encrypted() / decrypt_field().
|
||||||
try:
|
try:
|
||||||
source_ids = json.loads(p.get("source_ids_json") or "[]")
|
source_ids = json.loads(p.get("source_ids_json") or "[]")
|
||||||
except (TypeError, json.JSONDecodeError):
|
except (TypeError, json.JSONDecodeError):
|
||||||
|
|
@ -1350,7 +1350,7 @@ class QdrantStore:
|
||||||
"severity": p.get("severity") or None,
|
"severity": p.get("severity") or None,
|
||||||
"domain": p.get("domain") or None,
|
"domain": p.get("domain") or None,
|
||||||
"ts": ts_dt,
|
"ts": ts_dt,
|
||||||
"data": data,
|
"data": raw_data,
|
||||||
"session_id": p.get("session_id", "-"),
|
"session_id": p.get("session_id", "-"),
|
||||||
"source_ids": source_ids,
|
"source_ids": source_ids,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,12 @@ def contradict(
|
||||||
store.insert(new_rec)
|
store.insert(new_rec)
|
||||||
store.add_contradicts_edge(original_id, new_rec.id)
|
store.add_contradicts_edge(original_id, new_rec.id)
|
||||||
|
|
||||||
|
# Wire temporal_next: contradict inserts land in same session, link them.
|
||||||
|
try:
|
||||||
|
link_temporal_next(store, new_rec, session_id="-")
|
||||||
|
except Exception:
|
||||||
|
pass # diagnostic only; never block the write path.
|
||||||
|
|
||||||
# monotropic proactive check fires only in high-focus
|
# monotropic proactive check fires only in high-focus
|
||||||
# domains. Hints aren't surfaced via contradict() (its signature is fixed
|
# domains. Hints aren't surfaced via contradict() (its signature is fixed
|
||||||
# to ReconsolidationReceipt), but events land in the events table so the
|
# to ReconsolidationReceipt), but events land in the events table so the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue