kin: KIN-136-backend_dev
This commit is contained in:
parent
2f7ccffbc8
commit
aac75dbfdc
4 changed files with 592 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ from core.db import init_db
|
|||
from core import models
|
||||
from core.models import RETURN_CATEGORIES
|
||||
from core.context_builder import build_context
|
||||
from agents.runner import _save_return_analyst_output, run_pipeline
|
||||
from agents.runner import _save_return_analyst_output, run_pipeline, _AUTO_RETURN_MAX
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -403,7 +403,13 @@ class TestGateCannotCloseRecordsReturn:
|
|||
def test_gate_rejection_increments_return_count_in_standard_pipeline(
|
||||
self, mock_run, mock_hooks, mock_followup, conn_autocomplete
|
||||
):
|
||||
"""Gate cannot_close in standard pipeline → task.return_count increases by 1."""
|
||||
"""Gate cannot_close in standard pipeline → return_count increments on each auto-return.
|
||||
|
||||
KIN-136: in auto_complete mode, gate rejection triggers auto-return up to _AUTO_RETURN_MAX
|
||||
times before escalating. Each auto-return increments return_count once; the final
|
||||
escalation via the human-escalation path also records one more return.
|
||||
Total: _AUTO_RETURN_MAX + 1 returns (3 auto-returns + 1 final escalation = 4).
|
||||
"""
|
||||
conn = conn_autocomplete
|
||||
mock_run.return_value = _mock_subprocess(
|
||||
{"verdict": "changes_requested", "reason": "Missing tests"}
|
||||
|
|
@ -415,8 +421,10 @@ class TestGateCannotCloseRecordsReturn:
|
|||
run_pipeline(conn, "P1-001", steps)
|
||||
|
||||
task = models.get_task(conn, "P1-001")
|
||||
assert task["return_count"] == 1, (
|
||||
"Gate rejection in standard pipeline should increment return_count"
|
||||
# KIN-136: _AUTO_RETURN_MAX auto-returns + 1 final escalation recording (git log: 2026-03-21)
|
||||
assert task["return_count"] == _AUTO_RETURN_MAX + 1, (
|
||||
"Gate rejection with persistent failure should increment return_count "
|
||||
f"_AUTO_RETURN_MAX+1 times ({_AUTO_RETURN_MAX + 1})"
|
||||
)
|
||||
|
||||
@patch("core.followup.generate_followups")
|
||||
|
|
@ -447,7 +455,11 @@ class TestGateCannotCloseRecordsReturn:
|
|||
def test_gate_rejection_records_return_with_recurring_quality_fail_category(
|
||||
self, mock_run, mock_hooks, mock_followup, conn_autocomplete
|
||||
):
|
||||
"""Gate rejection uses 'recurring_quality_fail' as reason_category."""
|
||||
"""Gate rejection uses 'recurring_quality_fail' as reason_category.
|
||||
|
||||
KIN-136: all auto-return records use the same category; final escalation also uses it.
|
||||
Total returns = _AUTO_RETURN_MAX + 1 (git log: 2026-03-21).
|
||||
"""
|
||||
conn = conn_autocomplete
|
||||
mock_run.return_value = _mock_subprocess(
|
||||
{"verdict": "changes_requested", "reason": "Need unit tests"}
|
||||
|
|
@ -459,8 +471,10 @@ class TestGateCannotCloseRecordsReturn:
|
|||
run_pipeline(conn, "P1-001", steps)
|
||||
|
||||
returns = models.get_task_returns(conn, "P1-001")
|
||||
assert len(returns) == 1
|
||||
assert returns[0]["reason_category"] == "recurring_quality_fail"
|
||||
assert len(returns) == _AUTO_RETURN_MAX + 1
|
||||
assert all(r["reason_category"] == "recurring_quality_fail" for r in returns), (
|
||||
"Все записи возврата должны иметь категорию recurring_quality_fail"
|
||||
)
|
||||
|
||||
@patch("core.followup.generate_followups")
|
||||
@patch("agents.runner.run_hooks")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue