Tasks: Autonomous Testing & Recursive Content-Generation Framework¶
Each task references one or more
FR-*/NFR-*/AC-*IDs from spec.md. All commands run inside Docker per AGENTS.md §"Docker-First Workflow".
Conventions¶
- Status:
[ ]todo /[~]in-progress /[x]done. - Owner:
@copilot.
T-001 — ADR + constitution §12 + claim BACKLOG items¶
- Refs: FR-9, FR-16, NFR-HITL-1, NFR-AUDIT-2
- Owner: @copilot
- Status:
[x] - Files:
docs/adr/0003-autonomy-orchestrator.md(new)docs/constitution.md(edit — add §12)BACKLOG.md(move BL-20260429-09, BL-20260502-04, BL-20260509-04 from## Opento## Claimed)- Steps:
- Author ADR documenting loop topology, kill-switch, and Level-2 reaffirmation.
- Add constitution §12 "Autonomy Loop Invariants" referencing the ADR.
- Mark backlog items
claimed-by:specs/018-autonomous-framework. - Verify:
python3 scripts/spec_validator.pyexits 0.python3 scripts/backlog_lint.pyexits 0.
T-002 — LegalBench harness scaffold¶
- Refs: FR-1, FR-2, AC-1
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/eval/__init__.py(new)backend/law_ai/eval/legalbench.py(new — argparse CLI)backend/law_ai/eval/loaders.py(new — dataset cache loader)backend/law_ai/eval/scoring.py(new — per-task scoring helpers)backend/law_ai/eval/report.py(new — JSON report writer + delta calc)backend/var/legalbench/.gitkeep,backend/var/legalbench/LICENSES.md(new)backend/tests/eval/__init__.py,backend/tests/eval/test_legalbench_cli.py(new)- Steps:
- Implement CLI matching the contract in docs/legalbench.md.
- Wire to the existing Ollama client used by
agents_runtime/graphs/legal_workflow.py. - Emit OTEL spans per item via
law_ai.core.provenance. - Author
LICENSES.mdenumerating per-task source + license. Do not commitbaseline.jsonuntil LICENSES.md lands. - Verify:
make test-backendincludestests/eval/test_legalbench_cli.pyand is green.make test-legalbenchexits 0 inside the container and writes a report underbackend/var/legalbench/.
T-003 — Coverage auditor¶
- Refs: FR-3
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/eval/coverage_audit.py(new)backend/tests/eval/test_coverage_audit.py(new)scripts/evolve_audit.py(edit — replace_scan_coveragebody with a thin call intocoverage_audit; add_scan_legalbench)- Steps:
- Parse
coverage.xmland return ranked(module, pct, missing_lines)records. - Update
evolve_audit.pyto consume the new module while preserving its current public behavior (still appendsBL-*items, still idempotent). - Verify:
python3 scripts/evolve_audit.pyexits 0 (no-op when nothing to add).pytest backend/tests/eval/test_coverage_audit.pygreen inside the container.
T-004 — TestSynthesizer crew + propose-only output¶
- Refs: FR-4, FR-5, AC-2
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/agents_runtime/crews/test_synthesizer.py(new)backend/law_ai/agents_runtime/prompts/test_synthesizer.v1.md(new)backend/tests/agents/test_test_synthesizer.py(new)backend/tests/autonomy/proposed/.gitkeep(new)- Steps:
- Implement
TestSynthesizer.run(input: ProposedTestInput) -> ProposedTestper agents.instructions.md. - Versioned prompt; provenance logging on every LLM call.
- Writer emits
<module-path>__autonomy.proposed.pydecorated with@pytest.mark.skip("autonomy-proposed"). - Verify:
- Unit test mocks Ollama, asserts proposed file exists and contains the skip decorator.
T-005 — nightly-tests.yml workflow¶
- Refs: FR-6, FR-7, NFR-PERF-2, AC-8
- Owner: @copilot
- Status:
[x] - Files:
.github/workflows/nightly-tests.yml(new)- Steps:
- Clone shape from
evolve.yml. Cron0 6 * * *+workflow_dispatch. - Steps:
make test-coverage→make test-legalbench→python3 scripts/evolve_audit.py→ callpython manage.py run_autonomy --kind test_pillar→ open draft PR withpeter-evans/create-pull-request@v6. - Fail-on-regression: if
evolve_audit.pyadds any LegalBenchseverity:highitem, exit non-zero. - Verify:
gh workflow run nightly-tests.yml -f dry_run=true(or localact -W ...) opens a draft PR with at least one*.proposed.pyand zero merged commits.
T-006 — SOURCE_REGISTRY package¶
- Refs: FR-8, FR-10, AC-6
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/ingestionapp/sources/__init__.py(new — exposesSOURCE_REGISTRY)backend/law_ai/ingestionapp/sources/base.py(new —SourceAdapterPydantic +RawDoc)backend/law_ai/ingestionapp/sources/courtlistener.py(new — wraps existingservices/courtlistener.py)backend/law_ai/ingestionapp/sources/colorado_statutes.py(new — wrapsservices/colorado_statutes.py)backend/law_ai/ingestionapp/sources/statute_scout.py(new — wrapsservices/statute_scout.py)backend/law_ai/core/management/commands/list_sources.py(new)backend/tests/ingestion/test_source_registry.py(new)backend/tests/core/management/test_list_sources.py(new)- Steps:
- Define
SourceAdapterABC withname,jurisdiction,license,requires_human_approval,rate_limit,fetch(query) -> Iterable[RawDoc]. - Wrap existing scout services as adapters; preserve behavior (add a regression test asserting existing scout tests still pass).
list_sourcesmgmt command prints registry as a table.- Verify:
python manage.py list_sourcesprints exactly three rows.- All existing
tests/ingestion/test_scout*.pystill green.
T-007 — TopicFrontier LangGraph workflow¶
- Refs: FR-11, NFR-HITL-1, NFR-PERF-1, NFR-SEC-1, AC-4
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/agents_runtime/graphs/topic_frontier.py(new)backend/law_ai/agents_runtime/prompts/topic_frontier_prioritize.v1.md(new)backend/law_ai/core/neo4j/queries.py(edit — addlist_orphan_citations+list_under_cited_jurisdictionsCypher helpers)backend/tests/agents/graphs/test_topic_frontier.py(new — mocked Neo4j + adapter)backend/tests/agents/graphs/test_topic_frontier_integration.py(new —@pytest.mark.integration)- Steps:
- Nodes:
scan_graph→prioritize(Ollama) →dispatch→summarize. dispatchALWAYS routes throughIngestionScout.run_and_commit; never writes Neo4j directly.- Integration test asserts every new
:Casenode carriesIngestionScout'sagent_version. - Verify:
- Unit test passes; integration test passes against
make test-integration.
T-008 — core.autonomy.run_cycle orchestrator + provenance helpers¶
- Refs: FR-12, FR-16, NFR-AUDIT-1, AC-3, AC-5
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/autonomy.py(new)backend/law_ai/core/provenance.py(edit — addlog_autonomy_cycle,log_policy_violation)backend/law_ai/settings/base.py(edit — addAUTONOMY_ENABLED,AUTONOMY_ALLOWED_SOURCES,AUTONOMY_DIGEST_DIR)backend/tests/core/test_autonomy.py(new)- Steps:
AutonomyRundataclass +run_cycle(kind, cycle_id=None, **kwargs) -> AutonomyRun.- Idempotent on
cycle_id(UUID4 default; returns prior result on duplicate by queryingaudit.AuditEvent). - Short-circuit when
AUTONOMY_ENABLED=Falsewith a single provenance event. - Allow-list check before any adapter dispatch; emit
policy_violationon miss. - Verify:
- All scenarios in
test_autonomy.pygreen (disabled, idempotency, policy violation, success).
T-009 — run_autonomy management command + Celery beat schedule¶
- Refs: FR-13, FR-14, FR-17
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/management/commands/run_autonomy.py(new)backend/law_ai/celery.py(edit —beat_scheduleentries)backend/tests/core/management/test_run_autonomy.py(new)Makefile(edit — addautonomy-up,autonomy-status,autonomy-stop)- Steps:
- CLI args
--kind,--source,--budget,--cycle-id. Exit non-zero on policy violation. - Beat:
autonomy-content-sweepevery 6h (kind=corpus_growth, budget=25);autonomy-nightly-testsdaily 06:00 UTC (kind=test_pillar);autonomy-daily-digestdaily 07:00 UTC (kind=digest). The pre-existingevolve.ymlworkflow remains the weekly evolve audit on CI. - Makefile targets shell into
workercontainer. - Verify:
make autonomy-statusprints the schedule.python manage.py run_autonomy --kind corpus_growth --source unknown_sourceexits non-zero (AC-3).
T-010 — Daily digest task¶
- Refs: FR-15, NFR-AUDIT-2, AC-7
- Owner: @copilot
- Status:
[x] - Files:
backend/law_ai/core/autonomy.py(edit — addcompose_digest)backend/law_ai/celery.py(edit — registercompose_digestCelery task + beat entry daily 07:00 UTC)backend/var/autonomy/.gitkeep(new)backend/tests/core/test_autonomy_digest.py(new)- Steps:
- Aggregate the last 24h of
audit.AuditEventrows whereevent_type LIKE 'autonomy_%'. - Render Markdown to
backend/var/autonomy/digest-<YYYY-MM-DD>.mdwith sections: PRs opened, BACKLOG items appended, Docs quarantined, LegalBench delta. - Verify: Test fixture seeds audit rows; assert digest file exists with all four section headers.
T-011 — Documentation refresh¶
- Refs: NFR-SEC-2, NFR-AUDIT-2
- Owner: @copilot
- Status:
[x] - Files:
docs/local-ai.md(edit —AUTONOMY_ENABLED, cadence, kill-switch)docs/agent-roles.md(edit — TestSynthesizer + TopicFrontier rows)docs/legalbench.md(edit — fill baseline rows after first green run; recordLICENSES.mdpolicy)docs/architecture.md(edit — autonomy loop diagram +baseline.jsoncommit SHA)- Steps: Concise, factual; link to ADR 0003.
- Verify:
make test-smoke(which includes doc structural tests) green.
T-012 — End-to-end gates + BACKLOG mirror¶
- Refs: AC-9
- Owner: @copilot
- Status:
[x] - Files:
BACKLOG.md(edit — mirror this spec's follow-ups under## Open; promote claimed items to## Doneonce T-001..T-011 are green)- Steps:
- Run
make lint,make typecheck,make test,make test-coverage,make test-integration,make test-legalbench. - Run
python3 scripts/spec_validator.py && python3 scripts/backlog_lint.py. - Mirror every item in
## Follow-ups Discoveredbelow intoBACKLOG.md## Open. - Verify: All gates exit 0.
Done-When (Definition of Done)¶
- All tasks
[x]. - All
AC-*fromspec.mdcovered by passing tests. make lint && make testgreen.- LegalBench delta recorded in PR description (initial baseline established).
- Provenance logging verified manually for
run_autonomy --kind content(AUTONOMY_ENABLED=True). ## Follow-ups Discoveredsection below populated and mirrored into BACKLOG.md.
Follow-ups Discovered¶
Append-only. Mirror each item into BACKLOG.md with a
BL-YYYYMMDD-NNid.
- BL-20260511-03 — feature, med — Read-only
frontend/app/autonomy/dashboard with Vitest test (sparkline of LegalBench scores, top-5 lowest-coverage modules, last 10 quarantined docs). Out of MVP scope. Surfaced in: specs/018-autonomous-framework. - BL-20260511-04 — infra, med — Promote
AutonomyRunfromaudit.AuditEventJSON payload to a dedicated Postgres table once digest queries get richer. Surfaced in: specs/018-autonomous-framework. - BL-20260511-05 — feature, low — Stream daily digest to Slack/email; today the
digest-<date>.mdfile is the only surface. Surfaced in: specs/018-autonomous-framework. - BL-20260511-06 — feature, med — Backfill
LegalAnalyst(BL-20260430-03) andPrecedentHunter(BL-20260430-04) ontoLegalWorkflowonce the LegalBench baseline lands; resolves overlap with BL-20260502-04. Surfaced in: specs/018-autonomous-framework. - BL-20260511-07 — test-gap, low — Live-network nightly smoke test that fetches one real Justia CRS title via
colorado_statutesadapter and re-runs the parser to detect upstream HTML drift; resolves overlap with BL-20260509-04. Surfaced in: specs/018-autonomous-framework. - BL-20260511-08 — feature, low — Add an
afetchasync coroutine toSourceAdapterABC and companion async variants to all three adapters; today they useasyncio.run()which cannot be called from within an already-running event loop (e.g. Channels consumers). Surfaced in: specs/018-autonomous-framework (T-006 implementation). - BL-20260511-09 — test-gap, low — Integration test that calls
list_sourcesagainst the live Docker stack (Postgres + Redis) and asserts adapter metadata matchesSOURCE_REGISTRYkeys. Surfaced in: specs/018-autonomous-framework (T-006 implementation). - BL-20260511-10 — feature, med — Wire
run_autonomy --kind corpus_growthto the realTopicFrontierrunner once T-007 lands; current_run_corpus_growthis a stub placeholder. Surfaced in: specs/018-autonomous-framework (T-009 implementation). - BL-20260511-11 — test-gap, low — Add
make test-backendintegration marker totest_run_autonomy.py::TestCeleryAutonomyTask::test_task_delegates_to_run_cycle_disabledso it runs as part of the full beat-schedule smoke suite. Surfaced in: specs/018-autonomous-framework (T-009 implementation). - BL-20260511-12 — feature, med — Extend LegalBench scoring to include BM25 recall and NLI-entailment strategies for
precedent_retrievalsubset; current exact-match baseline is a placeholder. Surfaced in: specs/018-autonomous-framework (T-002 implementation). - BL-20260511-13 — infra, low — Add
make legalbench-cachetarget that downloads and caches official LegalBenchitems.jsonlfrom HazyResearch GitHub intobackend/var/legalbench/. Surfaced in: specs/018-autonomous-framework (T-002 implementation). - BL-20260511-14 — test-gap, low — The two
TestEvolveAuditScanCoveragetests intest_coverage_audit.pyare skipped in Docker (scripts/ not mounted). Add a root-leveltests/test_evolve_audit.pythat runs them directly on the host as part ofmake lint-specs. Surfaced in: specs/018-autonomous-framework (T-003 implementation). - BL-20260511-15 — feature, low — Add
_scan_legalbenchintegration test that seeds a fakereport-*.jsonwith a regression, calls_scan_legalbench, and asserts aseverity:highCandidate is returned. Surfaced in: specs/018-autonomous-framework (T-003 implementation). - BL-20260511-16 — feature, med — Wire
run_autonomy --kind test_pillarto invokeTestSynthesizerfor the top-5 lowest-coverage modules reported bycoverage_audit; currently_run_test_pillaris a stub. Surfaced in: specs/018-autonomous-framework (T-004 implementation). - BL-20260511-17 — test-gap, low — Add a Vitest / RTL test for a minimal
ProposedTestReviewfrontend component that lists*.proposed.pyfiles pending review (part of BL-20260511-03 dashboard). Surfaced in: specs/018-autonomous-framework (T-004 implementation). - BL-20260511-18 — infra, low — Add an
actlocal runner config (.actrc) sogh workflow run nightly-tests.yml -f dry_run=truecan be smoke-tested locally without pushing to GitHub. Surfaced in: specs/018-autonomous-framework (T-005 implementation). - BL-20260511-19 — feature, low — Post the nightly digest Markdown (
backend/var/autonomy/digest-*.md) as a GitHub Actions job summary ($GITHUB_STEP_SUMMARY) so it's visible in the Actions UI without downloading an artifact. Surfaced in: specs/018-autonomous-framework (T-005 implementation). - BL-20260511-20 — feature, med — Wire
run_autonomy --kind corpus_growthto invokeTopicFrontier.run()(resolves BL-20260511-10 stub placeholder). Surfaced in: specs/018-autonomous-framework (T-007 implementation). - BL-20260511-21 — test-gap, low — Add a real LangGraph state-machine test using
langgraph.testingharness to validate node transitions and edge conditions inTopicFrontier(currently tested via direct async node calls only). Surfaced in: specs/018-autonomous-framework (T-007 implementation). - BL-20260511-22 — feature, low — Post digest Markdown to
$GITHUB_STEP_SUMMARYinside the nightly workflow so operators see it in the Actions UI without downloading an artifact. Surfaced in: specs/018-autonomous-framework (T-010 implementation). - BL-20260511-23 — feature, med — Add a
compose_digest_taskCelery task that retries on transient DB errors and stores the digest path in theAuditEventpayload for cross-referencing. Surfaced in: specs/018-autonomous-framework (T-010 implementation). - BL-20260511-24 — doc-gap, low — Record first LegalBench baseline scores in
docs/legalbench.mdonce the harness has a green run; commitbackend/var/legalbench/baseline.jsonand add the commit SHA reference. Surfaced in: specs/018-autonomous-framework (T-011 implementation). - BL-20260511-25 — doc-gap, low — Add a
LICENSES.mdfile alongside any checked-in LegalBench data fixture (CC BY 4.0 attribution required per HazyResearch). Surfaced in: specs/018-autonomous-framework (T-011 implementation). - BL-20260511-26 — test-gap, low — Add
make test-integration+make test-legalbenchruns to the T-012 gate once the full Docker stack is available in CI (currently skipped because Neo4j/Ollama are not in--no-depsmode). Surfaced in: specs/018-autonomous-framework (T-012 close). - BL-20260511-27 — feature, med — Wire
run_autonomy --kind corpus_growthto callTopicFrontier.run()instead of the_run_corpus_growthstub (resolves BL-20260511-10 and BL-20260511-20). Surfaced in: specs/018-autonomous-framework (T-012 close).