feat(planning): start_planning hands back the active plan that already covers the work (#4079)
CI & Build / Python lint (push) Successful in 5s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 1m10s
CI & Build / TypeScript typecheck (push) Successful in 1m15s
CI & Build / Python tests (push) Failing after 1m22s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 5s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 1m10s
CI & Build / TypeScript typecheck (push) Successful in 1m15s
CI & Build / Python tests (push) Failing after 1m22s
CI & Build / Build & push image (push) Skipped
Step 4 of milestone 415 "An existing plan is found before a new one is made". A session that could not see an existing plan made a second one beside it. start_planning and create_milestone now ask first: an ACTIVE milestone in the project with the same title, or one that reads as the same plan (title, design and steps against milestone embeddings), is returned with its progress and a pointer to create_records(milestone_id=...). Nothing is created; force=true bypasses. - dedup.find_matching_plan / plan_gate / plan_match_response; access-checked before either arm (rule 78), fail-open like the other gates. - Done milestones never block; the semantic arm needs 200+ chars of candidate. - kb_plan_match_threshold (default 0.90) is a setting, in the Settings view, and pinned against the Python default by test_settings_defaults_agree. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy
This commit is contained in:
@@ -12,6 +12,15 @@ from tests.helpers import fake_milestone
|
||||
pytestmark = pytest.mark.usefixtures("_bind_user")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_plan_gate():
|
||||
"""The plan gate reads the database; these tests are about what reaches
|
||||
the service. The gate's own tests re-patch it."""
|
||||
with patch("scribe.mcp.tools.milestones.dedup_svc.plan_gate",
|
||||
AsyncMock(return_value=None)):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_milestones_returns_dict_with_progress():
|
||||
rows = [{"id": 1, "title": "MS1", "status": "active", "total": 2}]
|
||||
@@ -63,6 +72,33 @@ async def test_create_milestone_empty_body_becomes_none():
|
||||
assert mock.call_args.kwargs["body"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_milestone_returns_the_active_plan_that_already_covers_it():
|
||||
match = {"duplicate": True, "existing_id": 4}
|
||||
create = AsyncMock()
|
||||
with patch("scribe.mcp.tools.milestones.dedup_svc.plan_gate",
|
||||
AsyncMock(return_value=match)) as gate, \
|
||||
patch("scribe.mcp.tools.milestones.milestones_svc.create_milestone", create):
|
||||
out = await create_milestone(project_id=1, title="t", description="d", body="b")
|
||||
assert out is match
|
||||
create.assert_not_awaited()
|
||||
assert gate.call_args.args[:3] == (7, 1, "t")
|
||||
assert gate.call_args.args[3] == "d\n\nb"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_milestone_skips_the_gate_when_forced_or_done():
|
||||
"""force: the caller read the match. done: a record of past work is not a
|
||||
plan competing with an open one."""
|
||||
gate = AsyncMock(return_value={"duplicate": True})
|
||||
create = AsyncMock(return_value=fake_milestone(id=6))
|
||||
with patch("scribe.mcp.tools.milestones.dedup_svc.plan_gate", gate), \
|
||||
patch("scribe.mcp.tools.milestones.milestones_svc.create_milestone", create):
|
||||
assert (await create_milestone(project_id=1, title="t", force=True))["id"] == 6
|
||||
assert (await create_milestone(project_id=1, title="t", status="done"))["id"] == 6
|
||||
gate.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_milestone_sends_body():
|
||||
m = fake_milestone()
|
||||
|
||||
Reference in New Issue
Block a user