chore: hygiene pass — ruff clean, docs storage-model truth, replay /me, failSession log

Audit findings 6.1-6.4 + the audit's remediation plan itself
(docs/superpowers/plans/2026-07-20-full-audit-remediation-plan.md).

- ruff: 34 → 0 (unused imports/f-strings auto-fixed; E702 semicolon lines
  split in test files; one unused local dropped). Suite still 819 green.
- CLAUDE.md + PROJECT_STATE.md no longer claim "no database / settings in
  settings.json": the harness selects filesystem OR PostgreSQL session
  storage (repository.py, server mode), and settings flow through harness
  preferences with the JSON file as fallback only.
- tools/replay: stub /me (SPA boot was parsing the SPA's own HTML as JSON)
  and /runtime/prewarm.
- failSession best-effort persistence now logs its failure server-side
  instead of vanishing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 01:55:41 +02:00
co-authored by Claude Fable 5
parent 1ab0015460
commit c4951e2aa5
21 changed files with 283 additions and 43 deletions
+10 -6
View File
@@ -52,11 +52,14 @@ frontend (React/SSE) → backend (Fastify) → pi --mode rpc → tht/harness →
There is no verbatim transcript store. A resumed Pi process rebuilds context from
`tht session show <id>` + the on-disk artifacts.
- **The backend is a thin bridge with no database.** `ThtRunner` shells `tht` subcommands;
`PiProcessManager` runs one Pi child per session and bridges its RPC stream;
- **The backend is a thin bridge with no database of its own.** `ThtRunner` shells `tht`
subcommands; `PiProcessManager` runs one Pi child per session and bridges its RPC stream;
`SessionBridge` maps Pi RPC events → client events (`ui_request`/`text_delta`/`info`);
`SseHub` fans them out over SSE to the browser. App settings live in a JSON file
(`backend/data/settings.json`), not a DB.
`SseHub` fans them out over SSE to the browser. Persistence belongs to the HARNESS, which
selects the session repository from the workspace config (`harness/tht/session/repository.py`):
filesystem by default, **PostgreSQL when `session_storage` is configured** (server/portable
deployment). Settings flow through harness preferences (`tht session preferences`) with
`backend/data/settings.json` only as the file fallback for injected runners/tests.
- **Human-in-the-loop gate contract.** The model proposes; a human reviewer decides at gates
via widgets (`reviewer_select` = single pick — a chosen option carrying a `decision` payload
@@ -75,8 +78,9 @@ frontend (React/SSE) → backend (Fastify) → pi --mode rpc → tht/harness →
- **Workspaces** (`harness/workspaces/*.yaml`) set the DB target and **absolute**
`paths.sessions/artifacts/indexes` — for `psd` these point at a *separate, uncommitted* repo
(`tht-workspace-psd/`). Secrets live ONLY in `harness/.env` (gitignored).
- **Settings are global** (`backend/data/settings.json`: workspace/provider/model/thinking);
the New-session form is question-only.
- **Settings are global** (workspace/provider/model/thinking, persisted via harness
preferences — `backend/data/settings.json` is only the fallback); the New-session form is
question-only.
- **Resume**: a resumable session re-enters at its last incomplete phase. The backend refuses
resume with 409 when `finalized` or `archived`, and `PiProcessManager.spawnFor` must send
`/riprendi-sessione <id>` (resume mode) vs `/nuova-domanda` (new) — sending the wrong prompt