Tasks: HITL Quarantine Enforcement — Test Coverage & Regression Guard¶
Each task must reference one or more
FR-*/NFR-*/AC-*IDs fromspec.md. CI'sspec_validator.pyenforces that every requirement inspec.mdis referenced by at least one task.
Conventions¶
- Status:
[ ]todo /[~]in-progress /[x]done. - Owner: GitHub handle or
@copilot/@agent:<role>.
NOTE: The test module is
backend/tests/agents/graphs/test_topic_frontier.py. Verify commands run Docker-first (docker compose run --rm backend pytest …).
T-001 — Add unit test: force_quarantine=True propagates to run_and_commit¶
- Refs: FR-1, AC-1, NFR-PERF-1, NFR-HITL-1
- Owner: @copilot
- Status:
[x] - Files:
backend/tests/agents/graphs/test_topic_frontier.py- Steps:
- Create an adapter stub with
requires_human_approval=True. - Patch
scout.run_and_commitwithmocker.patch. - Call
_node_dispatchand capturecall_args. - Assert
call_kwargs["force_quarantine"] is True. - Verify: Satisfied by existing
test_force_quarantine_passed_when_adapter_requires_approval(added under BL-20260511-30 / spec 020); assertskwargs["force_quarantine"] is True.
T-002 — Add unit test: dispatch summary records committed=False when force_quarantine=True¶
- Refs: FR-2, AC-2, NFR-PERF-1
- Owner: @copilot
- Status:
[x] - Files:
backend/tests/agents/graphs/test_topic_frontier.py- Steps:
- Patch
IngestionScout.run_and_committo return{"committed": False, "pending": True, "confidence": 0.5}. - Call
_dispatch_targetwithforce_quarantine=True. - Assert
entry["committed"] is False. - Verify:
docker compose run --rm --no-deps backend pytest tests/agents/graphs/test_topic_frontier.py::test_dispatch_summary_shows_not_committed_when_force_quarantine -qpasses.
T-003 — Strengthen existing test: assert run_and_commit called with force_quarantine=True¶
- Refs: FR-3, AC-1, NFR-HITL-1, NFR-AUDIT-1
- Owner: @copilot
- Status:
[x] - Files:
backend/tests/agents/graphs/test_topic_frontier.py- Steps:
- In
test_sets_human_approval_when_adapter_requires_it, add:scout.run_and_commit.assert_called_once_with(ANY, force_quarantine=True). - Change mock return to
{"committed": False, "pending": True}(correct value). - Verify: existing test still passes with the new assertion added.
T-004 — Add integration test: requires_human_approval adapter produces PendingReview row¶
- Refs: FR-4, AC-3, NFR-COV-1
- Owner: @copilot
- Status:
[x] - Files:
backend/tests/agents/graphs/test_topic_frontier.py- Steps:
- Decorate test with
@pytest.mark.integrationand@pytest.mark.django_db(transaction=True). - Set
CELERY_TASK_ALWAYS_EAGER=Trueviasettingsfixture. - Create adapter stub with
requires_human_approval=True, returning oneRawDoc. - Call
_node_dispatchviaasync_to_sync(sync test body). - Assert the
PendingReviewrow exists. Correction: scout'sOpinionExtractorhardcodessource="courtlistener"and stores the doc URL as the row PK, so the lookup isPendingReview.objects.filter(pk=raw_doc.source_url).exists(), notfilter(source=...)as originally drafted in FR-4. - Assert dispatch summary entry has
committed=False. - Verify:
docker compose run --rm backend pytest tests/agents/graphs/test_topic_frontier.py::test_requires_human_approval_produces_pending_review_row -m integration -vpasses.
T-005 — Quality gate¶
- Refs: AC-4, AC-5, NFR-COV-1, NFR-PERF-1
- Owner: @copilot
- Status:
[x] - Files: none (gate only)
- Result:
make test-backendgreen (coverage 81.76% ≥ 75%);make lintexit 0 (ruff + black clean on the test file; 8 pre-existing frontend warnings, 0 errors). - Steps:
- Run
make test-backend— must exit 0. - Run
make lint— must exit 0. - Confirm
topic_frontier.pyandscout.pyline coverage does not decrease. - Verify: CI green; coverage report shows no regression.
Done-When (Definition of Done)¶
- All tasks
[x]. - All
AC-*fromspec.mdcovered by passing tests. make lint && make testgreen.- LegalBench delta: 0 pp (no reasoning changes per spec §11).
Follow-ups Discovered¶
- BL-20260511-31 — Migrate
TopicFrontierto a properStateGraph(spec §13; separate spec warranted). - BL-20260510-01 — Full Celery/Django-ORM integration path for
PendingReviewbroader than this spec; track separately. - BL-20260602-07 — FR-4 in this spec drafted the integration assertion as
PendingReview.objects.filter(source=raw_doc.source_url), but scout'sOpinionExtractorhardcodessource="courtlistener"and stores the doc URL as the row PK — so the row is looked up bypk, notsource. The dispatch chain passes aRawDoc-shaped payload through the CourtListener extractor regardless of the originating adapter; a dedicated per-adapter extractor would letPendingReview.sourcereflect the true source. Surfaced in: specs/023.