feat(pegas-memory): Tier-1 self-improvement tools (commit + staleness)

- memory_commit: closes the 'commit hole' — writes verified answers from
  closed gaps back into atoms (mandatory dedup); leaves gap open if no
  verified answer exists. Reads verified status from PostgreSQL (source of
  truth), not the Qdrant projection.
- memory_stale: staleness guard with two signals — content-staleness
  (re-fetch + LLM verdict, needs proxy for foreign sites) and age-staleness
  (proxy-free fallback by pm_document.fetched_at, max_age_days).
- db: populate pm_document.fetched_at on upsert (freshness signal).
- docs: README/AGENTS/ARCHITECTURE/EXAMPLES updated (18 tools).
- self_improve.py: new module (227 lines).
This commit is contained in:
n1kt4r committed 2026-10-15 22:06:30 +05:00
1 parent a4c4a766c1
commit eca8a11e23
8 files changed
+439 -6

No files matched your search

+2 -2
View File
@@ -30,8 +30,8 @@ def upsert_document(conn, *, kind: str, uri: str | None, title: str | None,
if row:
return row["id"]
cur.execute(
"""INSERT INTO pm_document (kind, uri, title, content_hash, authority, meta)
VALUES (%s, %s, %s, %s, %s, %s)
"""INSERT INTO pm_document (kind, uri, title, content_hash, authority, meta, fetched_at)
VALUES (%s, %s, %s, %s, %s, %s, now())
ON CONFLICT (uri) DO UPDATE SET title = EXCLUDED.title
RETURNING id""",
(kind, uri, title, content_hash, authority, json.dumps(meta or {}, ensure_ascii=False)),