feat: implement memory and evidence administration with guided repairs
Publish documentation / publish (push) Successful in 1m27s

Add PostgreSQL-backed memory, editable evidence with source review and activation, and human-approved archive repairs across the harness, API, and UI. Include migrations, deployment support, regression coverage, and validation documentation.

Refresh permissions from validated session roles so existing administrator logins can access newly deployed archive management features.
This commit is contained in:
Codex
2026-09-10 10:31:34 +02:00
parent 8fe526dd6e
commit 82e2c91f42
168 changed files with 11914 additions and 1772 deletions
@@ -1,12 +1,9 @@
3. **Memory promotion closes the session.** Call `reviewer_memory_promote` with ONLY
the session id: the gate computes the candidates itself (`tht memory promote
--preview` — the 3 reusable types, already excluding promoted/declined ones) and
shows the reviewer a pre-selected checklist. Selected → saved to the vectordb +
`memory_promoted`; deselected → `memory_promotion_declined` (never re-proposed).
After recording the promotion (even with zero candidates) the gate advances F8 and
finalizes the session itself — do NOT present a `reviewer_confirm kind:"phase"`
afterwards: there is nothing left to approve. When the gate answers "sessione
finalizzata", give the reviewer the final summary and end the turn.
3. **Memory review closes the session.** Follow `memory-review.md` to finish any
persisted proposals, then call `reviewer_memory_promote` with the session ID.
The reviewer edits and selects additions, explicit updates and links in one
summary, including the consultative solved question. Only the selected cards
are saved. The gate records `memory_summary_reviewed`, advances F8 and finalizes.
Once it reports finalization, give the session summary and end the turn.
4. If the gate reports an error instead (e.g. the datamart decision is missing),
fix the prerequisite and call `reviewer_memory_promote` again. Only if the gate
says the session is still open, close with `reviewer_confirm kind:"phase"` as a
@@ -1,2 +1,3 @@
Finalize also indexes the question→SQL pair in the vectordb (kind `solved_question`,
best-effort — on failure recover with `tht memory solved-index <id>`). The persisted
Exemplars are saved only when selected in the Memory summary. Finalize performs
no additional automatic Memory writes. Pending indexing is recovered through
Memory management. The persisted
@@ -2,3 +2,7 @@
questions show which tables comparable questions used. Cite relevant precedents
(session id + tables) to the reviewer as CONTEXT — they are reference material,
NOT decisions to apply; their filters/periods may not transfer.
Run `tht memory rules "<question>" --session <id> --json` for reusable join rules
and explained errors. Read `memory-review.md` when a rule is relevant or a reviewer
approves a reusable correction. Present the applicable rule and its Memory ID in
the existing table/join proposal; that gate decides its use for this question.
@@ -1,2 +1,4 @@
Consult `tht memory rules "<question>" --session <id> --json` and follow
`memory-review.md` for reusable calculation rules and explained errors.
`tht memory solved-search "<question>" --json` shows how similar solved questions
were structured — use as reference only.
@@ -1,3 +1,5 @@
Consult `tht memory rules "<question>" --session <id> --json`; show applicable
rules and Memory IDs in the SQL explanation approved by the existing SQL gate.
`tht memory solved-search "<question>" --json` gives the final SQL of similar
solved questions: reference exemplars — never copy filters, periods or
populations without checking them against the current rewritten question.