diff options
| author | Anonymous Authors <anonymous@invalid.example> | 2026-07-24 14:03:51 -0500 |
|---|---|---|
| committer | Anonymous Authors <anonymous@invalid.example> | 2026-07-24 14:03:51 -0500 |
| commit | 708f2af9c6985e9cb5cd53e434a7d3b8dfa2b4ac (patch) | |
| tree | f4aa3d2240a621e9057ddad2a4d8ec7820db5cde /tests/test_models.py | |
| parent | d4eb26780a8a8c70ca75812af0c3c6a295c0797c (diff) | |
Diffstat (limited to 'tests/test_models.py')
| -rw-r--r-- | tests/test_models.py | 83 |
1 files changed, 82 insertions, 1 deletions
diff --git a/tests/test_models.py b/tests/test_models.py index 71dc854..d19b536 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -3,7 +3,12 @@ from __future__ import annotations import pytest from pydantic import ValidationError -from gap_pipeline.models import JudgeVerdict, KernelCandidate, KernelPlan +from gap_pipeline.models import ( + JudgeVerdict, + KernelCandidate, + KernelPlan, + ProofPlanDAG, +) def test_valid_plan_and_candidate(plan_dict: dict, candidate_dict: dict) -> None: @@ -38,3 +43,79 @@ def test_accept_verdict_cannot_report_blocking_issue() -> None: step_by_step_check="checked", blocking_issues="an error", ) + + +def test_path_dag_is_derived_from_ordered_plan(plan_dict: dict) -> None: + dag = ProofPlanDAG.from_plan(KernelPlan.model_validate(plan_dict)) + assert [node.node_id for node in dag.nodes] == ["n1", "n2"] + assert dag.nodes[0].dependencies == [] + assert dag.nodes[1].dependencies == ["n1"] + assert dag.terminal_node_id == "n2" + assert dag.method_labels_payload()[0].startswith("n1: ") + + +def test_dag_rejects_cycle() -> None: + with pytest.raises(ValidationError, match="cycle"): + ProofPlanDAG.model_validate( + { + "nodes": [ + { + "node_id": "n1", + "method_label": "first", + "dependencies": ["n2"], + }, + { + "node_id": "n2", + "method_label": "second", + "dependencies": ["n1"], + }, + ], + "terminal_node_id": "n2", + } + ) + + +def test_path_dag_rejects_skipped_dependency() -> None: + with pytest.raises(ValidationError, match="lead to the terminal"): + ProofPlanDAG.model_validate( + { + "nodes": [ + { + "node_id": "n1", + "method_label": "first", + "dependencies": [], + }, + { + "node_id": "n2", + "method_label": "second", + "dependencies": [], + }, + ], + "terminal_node_id": "n2", + } + ) + + +def test_judge_verdict_requires_every_dag_node(plan_dict: dict) -> None: + dag = ProofPlanDAG.from_plan(KernelPlan.model_validate(plan_dict)) + verdict = JudgeVerdict( + verdict="accept", + step_by_step_check="n1 is valid; n2 is valid", + ) + assert verdict.validate_coverage(dag) is verdict + + with pytest.raises(ValueError, match="does not cover DAG nodes.*n2"): + JudgeVerdict( + verdict="accept", + step_by_step_check="n1 is valid", + ).validate_coverage(dag) + + +def test_dag_labels_must_match_prompt_a_plan(plan_dict: dict) -> None: + plan = KernelPlan.model_validate(plan_dict) + dag = ProofPlanDAG.from_plan(plan) + changed_plan = plan.model_copy( + update={"core_steps": ["a different method", plan.core_steps[1]]} + ) + with pytest.raises(ValueError, match="must equal Prompt-A core_steps"): + dag.validate_plan(changed_plan) |
