62 lines
2.4 KiB
Python
62 lines
2.4 KiB
Python
# SPDX-FileCopyrightText: 2026 Art Sea LLC
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
"""Semantic closure decisions with stationary completion evidence."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from band_aider.context.class_meta import ClassMeta
|
|
from band_aider.judgement.prompt_formatter import MarkdownPromptFormatterBuilder
|
|
from band_aider.judgement.single_task_closure_check import SingleTaskClosureCheckFactory
|
|
from tests.support.completion_clients import ScriptedOpenAICompatibleClient
|
|
|
|
|
|
def _file(location: str, summary: str) -> ClassMeta:
|
|
"""Build one explicit current-file evidence record."""
|
|
|
|
return ClassMeta(
|
|
location=location,
|
|
summary=summary,
|
|
relevance=["task evidence"],
|
|
relevant_symbols={"Widget": "owned behavior"},
|
|
)
|
|
|
|
|
|
def test_single_task_closure_preserves_positive_completion_evidence() -> None:
|
|
"""A stationary satisfied decision records its reason and current file picture."""
|
|
|
|
client = ScriptedOpenAICompatibleClient(
|
|
('{"satisfied": true, "reason": "Widget is complete.", "remaining_work": ""}',),
|
|
)
|
|
check = SingleTaskClosureCheckFactory(
|
|
client=client,
|
|
prompt_formatter_builder=MarkdownPromptFormatterBuilder(),
|
|
).create("Make Widget behavior reliable.")
|
|
|
|
assert check(
|
|
"Finish Widget validation.",
|
|
[_file("src/widget.py", "Owns validation.")],
|
|
{"src/widget.py": "modified"},
|
|
) is True
|
|
assert check.reason == "Widget is complete."
|
|
assert check.remaining_work == ""
|
|
assert check.changes == [(check, True)]
|
|
assert "ORIGINAL COT: IMMUTABLE STABILIZATION TARGET" in client.prompts[0]
|
|
assert '"src/widget.py": "modified"' in client.prompts[0]
|
|
|
|
|
|
def test_single_task_closure_retains_remaining_work_when_evidence_is_insufficient() -> None:
|
|
"""A stationary unsatisfied decision keeps the explicit next action visible."""
|
|
|
|
client = ScriptedOpenAICompatibleClient(
|
|
('{"satisfied": false, "reason": "Test is missing.", "remaining_work": "Add test."}',),
|
|
)
|
|
check = SingleTaskClosureCheckFactory(
|
|
client=client,
|
|
prompt_formatter_builder=MarkdownPromptFormatterBuilder(),
|
|
).create("Keep a narrow task open until its test exists.")
|
|
|
|
assert check("Add Widget coverage.", [_file("tests/test_widget.py", "No test yet.")], {}) is False
|
|
assert (check.reason, check.remaining_work) == ("Test is missing.", "Add test.")
|
|
assert check.changes == [(check, False)]
|