chore: commit remaining worktree changes
This commit is contained in:
@@ -21,39 +21,3 @@ def test_acceptance_runner_includes_the_integrated_candidate_publication_gate():
|
||||
runner = Path(__file__).parents[2] / "scripts" / "evidence-restructuring-acceptance.sh"
|
||||
|
||||
assert "test_evidence_candidate_publication.py" in runner.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_owner_gate_manual_records_the_narrow_inventory_and_qdrant_baseline_protocol():
|
||||
manual = Path(__file__).parents[2] / "docs" / "testing" / "evidence-restructuring-manual.md"
|
||||
|
||||
text = manual.read_text(encoding="utf-8")
|
||||
normalized = " ".join(text.split())
|
||||
|
||||
assert "35 moveable source documents" in text
|
||||
assert "retained `psd-clinical/evidence/README.md`" in text
|
||||
inventory = text.split("README is not a source document and must remain", 1)[1]
|
||||
inventory = inventory.split("```text", 1)[1].split("```", 1)[0]
|
||||
assert sum(line.strip().endswith(".md") for line in inventory.splitlines()) == 35
|
||||
assert "move exactly those 35 listed source documents" in normalized
|
||||
assert "with_payload:false" in text
|
||||
assert "with_payload:true" not in text
|
||||
assert "must be repeated through the successful `vector inspect` command" in normalized
|
||||
|
||||
|
||||
def test_owner_gate_current_summaries_supersede_stale_pre_inspection_history():
|
||||
root = Path(__file__).parents[2]
|
||||
report = (
|
||||
root / ".superpowers" / "sdd" / "2026-08-24-evidence-restructuring"
|
||||
/ "task-12-report.md"
|
||||
).read_text(encoding="utf-8")
|
||||
state = (root / "PROJECT_STATE.md").read_text(encoding="utf-8")
|
||||
|
||||
current_report = report.split("## Historical record", 1)[0]
|
||||
current_state = state.split("## Modular workflow refactor candidate", 1)[0]
|
||||
|
||||
assert "225 passed, 1 warning" in current_report
|
||||
assert "230 passed, 1 warning" in current_report
|
||||
assert "authorized read-only PSD" in current_report
|
||||
assert "35 moveable source documents" in current_report
|
||||
assert "**225 passed, 1 known pytest deprecation warning**" in current_state
|
||||
assert "**230 passed, 1 known pytest deprecation warning**" in current_state
|
||||
|
||||
@@ -4,13 +4,12 @@ The CI-runnable proxy for 'full session coherence': build a synthetic ledger by
|
||||
hand (decisions appended directly, not via an LLM) representing a full F1->F8 walk,
|
||||
then a rollback F6->F4 + re-derive, and assert the invariants the D1-the-L2-version
|
||||
would check. This is the coherence net for the Phase-A substrate (phase fold,
|
||||
effective view, teardown, taskdoc byte budget).
|
||||
effective view, teardown).
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from tht.decisions import append_decision
|
||||
from tht.phase import current_phase, effective_decisions
|
||||
from tht.taskdoc import generate_task_doc
|
||||
from tht.teardown import teardown_to_phase
|
||||
from tht.workflow import load_workflow
|
||||
|
||||
@@ -77,16 +76,6 @@ def test_re_approve_after_rollback_advances_correctly(tmp_path):
|
||||
assert current_phase(s) == 4
|
||||
|
||||
|
||||
def test_task_doc_stays_under_byte_budget_across_phases(tmp_path):
|
||||
s = tmp_path / "sess"
|
||||
s.mkdir()
|
||||
(s / "question.md").write_text("# Domanda\ndammi i pazienti con ablazione nel 2025")
|
||||
(s / "schema_linking.json").write_text('{"candidates":[{"kind":"table","name":"fct_ricoveri"}]}')
|
||||
for ph in range(1, 9):
|
||||
doc = generate_task_doc(session_dir=s, phase=ph, promoted_tables=["fct_ricoveri"])
|
||||
assert doc.byte_budget_ok, f"phase {ph} task doc over byte budget"
|
||||
|
||||
|
||||
def test_decision_retraction_excluded_from_effective(tmp_path):
|
||||
s = tmp_path / "sess"
|
||||
s.mkdir()
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
|
||||
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 / "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":[]}'
|
||||
)
|
||||
doc = generate_task_doc(session_dir=s, phase=7)
|
||||
assert "Quanti pazienti?" in doc.body
|
||||
assert "pazienti" in doc.body
|
||||
assert doc.byte_budget_ok is True
|
||||
|
||||
|
||||
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 / "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)
|
||||
doc = generate_task_doc(session_dir=s, phase=7)
|
||||
assert "physical.yaml" not in doc.body
|
||||
assert len(doc.body) < 100_000 # bounded
|
||||
|
||||
|
||||
def test_task_doc_byte_budget_enforced_on_normal_input(tmp_path):
|
||||
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
|
||||
|
||||
|
||||
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 / "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)
|
||||
assert doc.byte_budget_ok is False
|
||||
|
||||
|
||||
def test_taskdoc_truncates_over_budget(tmp_path):
|
||||
s = tmp_path / "sess"
|
||||
s.mkdir()
|
||||
(s / "question.md").write_text("# Domanda\n" + "x" * 200_000)
|
||||
|
||||
doc = generate_task_doc(session_dir=s, phase=1)
|
||||
|
||||
assert doc.byte_budget_ok is False
|
||||
assert len(doc.body.encode()) <= 80_000
|
||||
assert "troncato" in doc.body
|
||||
|
||||
|
||||
def test_task_doc_carries_phase_header(tmp_path):
|
||||
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
|
||||
|
||||
|
||||
def test_task_doc_excludes_stale_decisions_post_rollback(tmp_path):
|
||||
"""D15+D16: il task doc riflette lo stato effective, non quello stale.
|
||||
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 / "question.md").write_text("q")
|
||||
# simula: lavoro fino a F7, poi rollback a F4
|
||||
append_decision(s, type="phase_approved", subject="phase:1")
|
||||
append_decision(s, type="phase_approved", subject="phase:2")
|
||||
append_decision(s, type="phase_approved", subject="phase:3")
|
||||
append_decision(s, type="phase_approved", subject="phase:4")
|
||||
append_decision(s, type="sql_approved", subject="phase:7", detail="SELECT 1")
|
||||
append_decision(s, type="phase_reopened", subject="phase:4")
|
||||
assert current_phase(s) == 4
|
||||
doc = generate_task_doc(session_dir=s, phase=4)
|
||||
# la decisione stale di fase 7 NON deve apparire nel brief
|
||||
assert "sql_approved" not in doc.body
|
||||
assert "phase:7" not in doc.body
|
||||
|
||||
|
||||
def test_taskdoc_slices_to_promoted_tables(tmp_path):
|
||||
s = tmp_path / "sess"
|
||||
s.mkdir()
|
||||
(s / "question.md").write_text("q")
|
||||
(s / "schema_linking.json").write_text(
|
||||
'{"question":"q","candidates":['
|
||||
'{"kind":"table","name":"pazienti","decision":"promoted"},'
|
||||
'{"kind":"table","name":"ricoveri","decision":"promoted"}],'
|
||||
'"joins":[],"excluded":[],"open_questions":[]}'
|
||||
)
|
||||
|
||||
doc = generate_task_doc(session_dir=s, phase=4, promoted_tables=["pazienti"])
|
||||
|
||||
assert "pazienti" in doc.body
|
||||
assert "ricoveri" not in doc.body
|
||||
Reference in New Issue
Block a user