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
+12 -6
View File
@@ -2,7 +2,8 @@ from tht.teardown import teardown_to_phase
def test_teardown_to_phase_4_deletes_phase5plus_artifacts(tmp_path):
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "schema_linking.json").write_text("{}") # F4 artifact
(s / "cte_plan.json").write_text("[]") # F6 artifact
(s / "ctes").mkdir()
@@ -19,7 +20,8 @@ def test_teardown_to_phase_4_deletes_phase5plus_artifacts(tmp_path):
def test_teardown_to_phase_1_deletes_everything(tmp_path):
"""Rollback a F1 cancella tutti gli artefatti (tutte le fasi > 1)."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q") # F3 artifact
(s / "schema_linking.json").write_text("{}") # F4 artifact
(s / "cte_plan.json").write_text("[]") # F6 artifact
@@ -37,7 +39,8 @@ def test_teardown_to_phase_1_deletes_everything(tmp_path):
def test_teardown_to_phase_7_preserves_phase6_artifacts(tmp_path):
"""Rollback a F7 preserva gli artefatti delle fasi <= 7."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "schema_linking.json").write_text("{}") # F4 artifact
(s / "cte_plan.json").write_text("[]") # F6 artifact
(s / "ctes").mkdir()
@@ -52,14 +55,16 @@ def test_teardown_to_phase_7_preserves_phase6_artifacts(tmp_path):
def test_teardown_to_phase_on_empty_session_is_noop(tmp_path):
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
report = teardown_to_phase(s, target_phase=4)
assert report.deleted_files == []
def test_teardown_to_phase_nonexistent_artifacts_no_error(tmp_path):
"""Se gli artefatti non esistono (sessione nuova), teardown non fallisce."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
report = teardown_to_phase(s, target_phase=1)
assert report.deleted_files == []
@@ -67,7 +72,8 @@ def test_teardown_to_phase_nonexistent_artifacts_no_error(tmp_path):
def test_teardown_deletes_orphaned_cte_files_not_in_current_plan(tmp_path):
"""Il bug degli orfani CTE: dopo un re-derive con piano diverso, i vecchi .sql
non piu' nel piano restano su disco e bloccano finalize. teardown li pulisce."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "ctes").mkdir()
(s / "ctes" / "old_cte.sql").write_text("SELECT 1") # orphan
(s / "ctes" / "another.sql").write_text("SELECT 2") # orphan