band-aider-pub/tests/band_aider/judgement/test_current_cot_completed_check.py
2026-10-17 11:57:37 -07:00

67 lines
2.5 KiB
Python

# SPDX-FileCopyrightText: 2026 Art Sea LLC
#
# SPDX-License-Identifier: AGPL-3.0-only
"""Stationary completion evidence for one permanently bound COT task."""
from __future__ import annotations
from datetime import datetime
from band_aider.context.class_meta import ClassMeta
from band_aider.judgement.current_cot_completed_check import CurrentCotCompletedCheckFactory
from band_aider.judgement.prompt_formatter import MarkdownPromptFormatterBuilder
from tests.support.completion_clients import ScriptedOpenAICompatibleClient
def _bound_root() -> ClassMeta:
"""Return one fixed production-root record with explicit CDC evidence."""
return ClassMeta(
location="src/widget.py",
summary="Owns Widget validation.",
relevance=["The current task changes Widget validation."],
relevant_symbols={"Widget.validate": "The stabilization owner."},
cdc=[
(
datetime(2026, 9, 4, 12, 0),
"test",
"Added the missing validation boundary.",
),
],
)
def test_current_cot_completion_preserves_bound_root_evidence_for_a_satisfied_task() -> None:
"""A fixed affirmative response records the reason and the evidence it judged."""
client = ScriptedOpenAICompatibleClient(
('{"completed": true, "reason": "Widget validation is complete."}',),
)
check = CurrentCotCompletedCheckFactory(
client=client,
prompt_formatter_builder=MarkdownPromptFormatterBuilder(),
).create("Stabilize Widget validation.")
assert check("Verify the validation boundary.", [_bound_root()]) is True
assert check.reason == "Widget validation is complete."
assert check.changes == [(check, True)]
assert "ORIGINAL COT: IMMUTABLE STABILIZATION TARGET" in client.prompts[0]
assert "2026-09-04T12:00:00" in client.prompts[0]
assert "Widget.validate" in client.prompts[0]
def test_current_cot_completion_keeps_a_bound_task_open_without_completion_evidence() -> None:
"""A fixed negative response leaves the task open and retains its explanation."""
client = ScriptedOpenAICompatibleClient(
('{"completed": false, "reason": "The root lacks a regression test."}',),
)
check = CurrentCotCompletedCheckFactory(
client=client,
prompt_formatter_builder=MarkdownPromptFormatterBuilder(),
).create("Keep Widget validation reliable.")
assert check("Add regression evidence.", [_bound_root()]) is False
assert check.reason == "The root lacks a regression test."
assert check.changes == [(check, False)]