fix(gate): auto-finalize session after last phase approval

The model sometimes stops after receiving 'Fase approvata' without calling
`tht session finalize`, leaving the session open. Now the gate itself calls
finalize after advancing the max phase (F8), making session closure
deterministic regardless of model behavior.

- reviewer_confirm kind:phase: after phase advance at max_phase, gate calls
  `tht session finalize <session>` (best-effort with recovery message)
- SKILL.md updated: model no longer needs to call finalize itself
- Tests: 2 new JS tests (auto-finalize at max phase; no-finalize at non-max)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 18:47:19 +02:00
co-authored by Claude Opus 4.6
parent ade6838182
commit 893ad99594
3 changed files with 101 additions and 8 deletions
+8 -6
View File
@@ -393,12 +393,14 @@ Prerequisite: Phase 7 closed.
pre-selected checklist. Selected → saved to the vectordb + `memory_promoted`;
deselected → `memory_promotion_declined` (never re-proposed). If the gate reports
zero candidates, move on — do not retry.
4. Close with `reviewer_confirm kind:"phase"`. The session is finalizable.
4. Close with `reviewer_confirm kind:"phase"`. The gate auto-finalizes the session
after advancing the last phase — you do NOT need to call `tht session finalize`
yourself. If auto-finalize fails, the error message tells you the recovery command.
## Session end
When the workflow is complete (Phase 8), `tht session finalize` closes the session
and unlocks input. 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 state (ledger `review_decisions.jsonl` +
artifacts) is the truth: what is not recorded did not happen.
When Phase 8 is approved, the gate calls `tht session finalize` automatically.
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
state (ledger `review_decisions.jsonl` + artifacts) is the truth: what is not
recorded did not happen.