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:
1 parent
a4c4a766c1
commit
eca8a11e23
8 files changed
+439
-6
No files matched your search
+38
@@ -246,6 +246,44 @@ memory_query_graph(kind = "depends_on", top_k = 10)
|
||||
|
||||
---
|
||||
|
||||
## Example 9 — Self-improvement (commit + staleness)
|
||||
|
||||
Commit a verified answer from a closed gap into atoms (closes the «commit hole»):
|
||||
|
||||
```
|
||||
memory_commit(gap_ids = [3], dedup = true)
|
||||
```
|
||||
|
||||
**Result** (actual, abridged):
|
||||
|
||||
```json
|
||||
{"committed": 1, "resolved": 1, "skipped_empty": 0, "skipped_duplicate": 0,
|
||||
"atoms": [218]}
|
||||
```
|
||||
|
||||
Mark stale atoms — content-staleness (re-fetch + LLM, needs proxy for foreign sites)
|
||||
or age-staleness (proxy-free, by `fetched_at`):
|
||||
|
||||
```
|
||||
memory_stale(atom_id = 126)
|
||||
memory_stale(all = true, limit = 20, sample = true,
|
||||
min_confidence = 0.5, age_only = true, max_age_days = 90)
|
||||
```
|
||||
|
||||
**Result** (abridged):
|
||||
|
||||
```json
|
||||
{"checked": 0, "stale": 1, "supported": 0, "skipped_no_source": 0,
|
||||
"atom_ids": [126], "reasons": {"126": "content_age 10d"}}
|
||||
```
|
||||
|
||||
> `age_only = true` skips the network re-fetch and flags atoms whose source
|
||||
> `fetched_at` is older than `max_age_days` (default 90). For foreign sites
|
||||
> (memgraph.com, cloudflare/geo-blocked) set `PROXY_URL` or the re-fetch
|
||||
> returns `ConnectTimeout` and falls back to age-staleness.
|
||||
|
||||
---
|
||||
|
||||
## Anti-patterns (do not do this)
|
||||
|
||||
| Anti-pattern | Why it is wrong | Do instead |
|
||||
|
||||
Reference in new issue
Block a user