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 -7
View File
@@ -1,10 +1,10 @@
from pathlib import Path
from tht.taskdoc import generate_task_doc
def test_task_doc_includes_question_and_schema_scope(tmp_path):
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("# Domanda\nQuanti pazienti?\n## Assunzioni\n- a")
(s / "schema_linking.json").write_text(
'{"question":"q","candidates":[{"kind":"table","name":"pazienti"}],"joins":[],"excluded":[],"open_questions":[]}'
@@ -17,7 +17,8 @@ def test_task_doc_includes_question_and_schema_scope(tmp_path):
def test_task_doc_never_embeds_full_physical_yaml(tmp_path):
"""physical.yaml e' fatale per un 35B/<200k (~190k token). Mai incorporarlo."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q")
# un physical.yaml enorme fuori dalla sessione (come in ChironeWp3: artifacts/mschema/)
(s.parent / "physical.yaml").write_text("x: " + "y" * 800_000)
@@ -27,7 +28,8 @@ def test_task_doc_never_embeds_full_physical_yaml(tmp_path):
def test_task_doc_byte_budget_enforced_on_normal_input(tmp_path):
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q")
doc = generate_task_doc(session_dir=s, phase=1)
assert doc.byte_budget_ok is True
@@ -35,7 +37,8 @@ def test_task_doc_byte_budget_enforced_on_normal_input(tmp_path):
def test_task_doc_byte_budget_violation_flagged(tmp_path):
"""Se un artefatto di sessione e' enorme (input perverso), byte_budget_ok diventa False."""
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q")
(s / "schema_linking.json").write_text("x: " + "y" * 400_000) # ~400KB -> over budget
doc = generate_task_doc(session_dir=s, phase=7)
@@ -43,7 +46,8 @@ def test_task_doc_byte_budget_violation_flagged(tmp_path):
def test_task_doc_carries_phase_header(tmp_path):
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q")
doc = generate_task_doc(session_dir=s, phase=4)
assert "fase 4" in doc.body.lower() or "fase 4" in doc.body
@@ -54,7 +58,8 @@ def test_task_doc_excludes_stale_decisions_post_rollback(tmp_path):
Dopo rollback a F4, una sql_approved:7 stale non appare nel brief delle decisioni."""
from tht.decisions import append_decision
from tht.phase import current_phase
s = tmp_path / "sess"; s.mkdir()
s = tmp_path / "sess"
s.mkdir()
(s / "question.md").write_text("q")
# simula: lavoro fino a F7, poi rollback a F4
append_decision(s, type="phase_approved", subject="phase:1")