Spec: Enforce HITL Quarantine for requires_human_approval Adapters¶
- ID: 020-enforce-hitl-quarantine
- Status: shipped
- Owner: @copilot
- Created: 2026-06-02
- Roadmap Epic: BL-20260511-30
- Constitution Compliance: confirmed against docs/constitution.md §5 (HITL Requirements)
1. Problem & Motivation¶
Constitution §5 mandates that any ingestion from a source flagged requires_human_approval=True MUST route through the HITL PendingReview queue regardless of extraction confidence. The TopicFrontier._node_dispatch node detected the flag and recorded it in state, but lacked verification that the force_quarantine parameter was propagated end-to-end through IngestionScout.run_and_commit.
2. Origin & Background¶
- BL-20260511-30 — feature, high — Enforce
requires_human_approval=Truequarantine path inTopicFrontier._node_dispatch. - Surfaced in: specs/018-autonomous-framework PR review.
3. Goals¶
- G1: Guarantee that when
SourceAdapter.requires_human_approval=True, everyRawDocroutes toPendingReviewregardless of confidence score. - G2: Add test coverage proving the
force_quarantine=Trueflag propagates from_node_dispatch→_dispatch_target→IngestionScout.run_and_commit.
4. Non-Goals¶
- NG1: Changing the quarantine storage mechanism (Celery task + JSONL fallback remains as-is).
- NG2: Adding new source adapters with
requires_human_approval=True.
5. Functional Requirements¶
- FR-1:
_node_dispatchMUST passforce_quarantine=Trueto_dispatch_targetwhenadapter.requires_human_approvalis True. - FR-2:
IngestionScout.run_and_commit(payload, force_quarantine=True)MUST route to_quarantine()even when extraction confidence ≥ 0.7.
6. Non-Functional Requirements¶
- NFR-HITL-1: Matches constitution §5 — ingestion of a new public data source with HITL flag always queues for human review.
7. Acceptance Criteria¶
- AC-1: Given an adapter with
requires_human_approval=True, when_node_dispatchprocesses a target, thenrun_and_commitis called withforce_quarantine=True. - AC-2: Given
force_quarantine=Trueand a high-confidence payload (confidence ≥ 0.7), whenrun_and_commitexecutes, then the document is quarantined (committed=False, pending=True).
8. Verification¶
Implementation confirmed in:
- backend/law_ai/agents_runtime/graphs/topic_frontier.py line 345
- backend/law_ai/ingestionapp/services/scout.py line 134
Tests added:
- backend/tests/agents/graphs/test_topic_frontier.py::TestNodeDispatch::test_force_quarantine_passed_when_adapter_requires_approval
- backend/tests/ingestion/test_scout.py::test_force_quarantine_routes_high_confidence_to_hitl
9. Follow-ups Discovered¶
- BL-20260602-01 — test-gap, low — Add an integration test that exercises the full
force_quarantinepath against a live Docker stack (adapter withrequires_human_approval=True→ Celery → PendingReview row). Surfaced in: specs/020-enforce-hitl-quarantine. - BL-20260602-02 — doc-gap, low — Document the
requires_human_approvaladapter contract and its quarantine enforcement indocs/architecture.md. Surfaced in: specs/020-enforce-hitl-quarantine.