docs(skill): prescribe solved-question recall in F4/F6/F7; refresh PROJECT_STATE

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 13:54:42 +02:00
co-authored by Claude Fable 5
parent 4c4099df09
commit 8af0552dcc
2 changed files with 39 additions and 2 deletions
+26
View File
@@ -78,6 +78,32 @@ Opens frontend at http://localhost:5173 → backend :8787.
- Global user rules (`~/.claude/CLAUDE.md`): think before coding, simplicity first, surgical - Global user rules (`~/.claude/CLAUDE.md`): think before coding, simplicity first, surgical
changes, goal-driven verification. changes, goal-driven verification.
## Active memory — F8 promotion gate + solved-question recall — SHIPPED, L2 pending (2026-07-07)
Two additions to close the loop on reusable memory, on top of the existing `tht memory
search` (Phase 2) reuse:
- **F8 promotion gate.** `reviewer_memory_promote` (Phase 8, called with only the session
id): the gate computes candidates deterministically via `tht memory promote --preview
--json` (the 3 reusable decision types, already excluding previously promoted/declined
ones) and shows a pre-selected checklist. Selected → `tht memory save-one` persists to
the vectordb + records `memory_promoted`; deselected → `memory_promotion_declined`
(ledger detail `seq:<n>`) so it is never re-proposed. `tht memory promote`/`save-one` were
added to the gate's anti-bypass FORBIDDEN list (model must go through the gate tool).
- **Solved-question exemplars.** New vector kind `solved_question` reusing the existing
`memory` pgvector table (no server-side DDL); `harness/tht/solved.py` does a one-row
upsert keyed by a hash of question+SQL. CLI: `tht memory solved-index` / `solved-search`.
`tht session finalize` auto-indexes the pair (best-effort: green line on upsert, cyan
"già aggiornata" on dedup no-op, yellow warning + the recovery command
`tht memory solved-index <id>` on failure). `SKILL.md` now prescribes calling
`solved-search` as reference-only context in F4 (schema linking), F6 (CTE plan) and F7
(final SQL), and documents the finalize auto-index in "Session end".
**Pending L2 gate (not yet run — needs VPN + writer key):** one live end-to-end session on
workspace `psd` via `./scripts/run-stack.sh` to verify (a) the promotion checklist renders
pre-selected and persists selected/declined correctly, (b) finalize indexes the pair,
(c) `tht memory solved-search` returns it with sql + tables.
## Review gates v2 — payload strutturati + viewer dedicati — COMPLETE (2026-07-07) ## Review gates v2 — payload strutturati + viewer dedicati — COMPLETE (2026-07-07)
Plan: `~/.claude/plans/prima-di-passare-ai-inherited-marshmallow.md`. Merged to `main` @ `2410f01` Plan: `~/.claude/plans/prima-di-passare-ai-inherited-marshmallow.md`. Merged to `main` @ `2410f01`
+13 -2
View File
@@ -232,6 +232,10 @@ Prerequisite: Phase 3 closed.
1. `tht schema introspect` + `tht schema render --format mschema-text` for the schema 1. `tht schema introspect` + `tht schema render --format mschema-text` for the schema
context. Copy table/column names EXACTLY from it — never invent objects. context. Copy table/column names EXACTLY from it — never invent objects.
Also run `tht memory solved-search "<question>" --json`: similar already-solved
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.
2. Propose tables to promote/exclude with **`reviewer_schema_linking`**: pass 2. Propose tables to promote/exclude with **`reviewer_schema_linking`**: pass
`tables[]` as `{id, name, kind: "promote"|"exclude", rationale, suggested_columns}`. `tables[]` as `{id, name, kind: "promote"|"exclude", rationale, suggested_columns}`.
Do NOT list every column yourself — the gate loads the full column set (with Do NOT list every column yourself — the gate loads the full column set (with
@@ -281,6 +285,8 @@ Prerequisite: Phase 5 closed.
1. Read `cte.md`. Decompose the rewritten question into CTEs (Agent View Generation): 1. Read `cte.md`. Decompose the rewritten question into CTEs (Agent View Generation):
each CTE captures an informative subset with a clear purpose, named in snake_case. each CTE captures an informative subset with a clear purpose, named in snake_case.
`tht memory solved-search "<question>" --json` shows how similar solved questions
were structured — use as reference only.
2. Present the full CTE plan to the reviewer with `reviewer_confirm kind:"cte_plan"`, 2. Present the full CTE plan to the reviewer with `reviewer_confirm kind:"cte_plan"`,
passing a **structured v2 artifact** (`artifact:{kind:"cte_plan", data:{…}}`). You passing a **structured v2 artifact** (`artifact:{kind:"cte_plan", data:{…}}`). You
author `question`, `strategy` and each `ctes[]` entry (`name`, `purpose`, author `question`, `strategy` and each `ctes[]` entry (`name`, `purpose`,
@@ -322,6 +328,9 @@ Prerequisite: Phase 6 closed.
1. Read `sql-generation.md`. Recursive divide-and-conquer: the CTEs approved in 1. Read `sql-generation.md`. Recursive divide-and-conquer: the CTEs approved in
Phase 6 are the preferred building blocks (reuse them by name). Phase 6 are the preferred building blocks (reuse them by name).
`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.
2. Compose the final SQL (PostgreSQL dialect, exact names from the schema context). 2. Compose the final SQL (PostgreSQL dialect, exact names from the schema context).
**Output columns (F4 honoring).** The columns promoted in Phase 4's **Output columns (F4 honoring).** The columns promoted in Phase 4's
`schema_linking.json` are the reviewer-approved OUTPUT columns: project exactly `schema_linking.json` are the reviewer-approved OUTPUT columns: project exactly
@@ -354,5 +363,7 @@ Prerequisite: Phase 7 closed.
## Session end ## Session end
When the workflow is complete (Phase 8), `tht session finalize` closes the session When the workflow is complete (Phase 8), `tht session finalize` closes the session
and unlocks input. The persisted state (ledger `review_decisions.jsonl` + artifacts) and unlocks input. Finalize also indexes the question→SQL pair in the vectordb
is the truth: what is not recorded did not happen. (kind `solved_question`, best-effort — on failure recover with `tht memory
solved-index <id>`). The persisted state (ledger `review_decisions.jsonl` +
artifacts) is the truth: what is not recorded did not happen.