out prdB multiprd heavy
Tasks¶
T001: Implement PRD schema and migration from v6 to v7¶
Feature: F002 Priority: high Likely files: src/schema/v7.py, src/migration/v6_to_v7.py Dependencies: T002
prds, requirements, features, and tasks with prd_id columns, and ensuring zero data loss during the atomic transaction.>
Acceptance criteria:
- The migration correctly identifies and migrates all existing rows into a single default PRD.
- All existing data is preserved in the new schema without loss or corruption.
- The
SCHEMA_VERSIONis updated to 7 and the migration is idempotent.
Verification:
anvil migrate --to 7runs successfully on a v6 database.anvil statusshows the migrated state with a single default PRD.
T002: Add PRD table and related fields to schema¶
Feature: F001 Priority: high Likely files: src/schema/prd.py, src/schema/tables.py Dependencies:
id, target_version, target_tag, and is_default fields. It also ensures that requirements, features, and tasks have an explicit prd_id column.>
Acceptance criteria:
- The
prdstable exists with uniqueidand exactly oneis_default. - The
requirements,features, andtaskstables includeprd_idcolumns. - The
prd_idfield is properly indexed for performance.
Verification:
sqlite3 state.db "PRAGMA table_info(prds);"shows the correct schema.sqlite3 state.db "PRAGMA table_info(requirements);"showsprd_id.
T003: Implement backend API for PRD management¶
Feature: F003 Priority: high Likely files: src/backend/prd_api.py, src/models/prd.py Dependencies: T002
list_prds(), default_prd_id(), and filters on list_tasks, list_features, and list_requirements.>
Acceptance criteria:
- The
get_prd(prd_id)function returns the correct PRD object. - The
list_prds()function returns all PRDs. - The
default_prd_id()function returns the ID of the default PRD. - The list functions accept a
prd_idfilter and return only matching entities.
Verification:
python -m anvil.backend get_prd defaultreturns the default PRD.python -m anvil.backend list_prdsreturns all PRDs.python -m anvil.backend list_tasks prd_id=defaultreturns only tasks from the default PRD.
T004: Implement claim gate logic for PRD-based access control¶
Feature: F004 Priority: high Likely files: src/claim/gate.py, src/models/task.py Dependencies: T003
<This task implements the claim gate logic that checks the task's owning PRD’s status before allowing claims. It ensures that approved PRDs are claimable while draft PRDs are not.>
Acceptance criteria:
- The claim gate resolves the task's owning PRD.
- Claims are allowed only if the PRD is approved.
- Claims are denied if the PRD is draft or pending.
Verification:
anvil claim T001works when the owning PRD is approved.anvil claim T001fails when the owning PRD is draft.
T005: Enable cross-PRD conflict detection and coordination¶
Feature: F004 Priority: high Likely files: src/conflict/detector.py, src/reaper/stale.py Dependencies: T004
Acceptance criteria:
- Conflict detection spans all PRDs.
- Active claims exclude across PRDs.
- Stale reaper operates across all PRDs.
Verification:
anvil plandetects conflicts across PRDs.anvil reapercleans up stale claims across PRDs.
T006: Implement parser support for PRD-specific parsing and ID handling¶
Feature: F005 Priority: high Likely files: src/parser/prd.py, src/parser/id_resolver.py Dependencies: T003
<This task makes the parser load-bearing for PRDs by supporting prd parse --prd <id> and emitting prefixed TaskIDs for named PRDs. It ensures that .anvil/prds/<id>.md is read and only that PRD's rows are touched.>
Acceptance criteria:
anvil parse --prd <id>reads from.anvil/prds/<id>.md.- Prefixed TaskIDs (
v0.2:T001) are emitted for named PRDs. - Bare IDs (
T001) are emitted for the default PRD.
Verification:
anvil parse --prd v0.2reads from.anvil/prds/v0.2.md.anvil parse --prd v0.2emits prefixed IDs likev0.2:T001.
T007: Implement CLI and MCP support for --prd selector¶
Feature: F006 Priority: high Likely files: src/cli/main.py, src/mcp/handlers.py Dependencies: T006
resolve_prd_id handles explicit --prd, ANVIL_PRD, and default resolution.>
Acceptance criteria:
anvil plan --prd <id>prunes only that PRD's orphans.anvil status --prd <id>rolls up per-PRD stats.resolve_prd_idcorrectly resolves--prd,ANVIL_PRD, and default.
Verification:
anvil plan --prd v0.2filters to only tasks in that PRD.ANVIL_PRD=v0.2 anvil statususes the specified PRD.
T008: Implement event-sourced revision system for PRDs¶
Feature: F007 Priority: high Likely files: src/replay/event_source.py, src/models/prd.py Dependencies: T003
Acceptance criteria:
- A
prd.revisedcolumn tracks revisions. - A per-PRD revision counter is maintained.
replay_to_event_idreconstructs as-of a revision.serialize_stateenumerates all PRDs deterministically.
Verification:
anvil replay --to-revision 5reconstructs the state at revision 5.anvil serializeoutputs all PRDs in a consistent order.
T009: Integrate PRD release fields into sync mapping¶
Feature: F008 Priority: high Likely files: src/sync/mapping.py, src/models/prd.py Dependencies: T003
entity_kind to SyncMapping and ensures that push stamps the owning prd_id. It scopes push to a specific PRD and attributes discrepancies to a PRD.>
Acceptance criteria:
SyncMappinghasprd_idandentity_kindfields.- Push operations stamp the owning
prd_id. - Discrepancies are attributed to a PRD.
Verification:
anvil push --prd v0.2pushes only to the specified PRD.anvil reconcileattributes discrepancies to the correct PRD.
T010: Update documentation and positioning for PRD as release plan¶
Feature: F009 Priority: medium Likely files: docs/prd.md, src/cli/help.py Dependencies: T003
Acceptance criteria:
- Documentation reflects PRD as a release-scoped plan.
- Version-lockstep and packaging manifests are updated.
- User-facing version docs are refreshed.
Verification:
anvil helpshows updated PRD documentation.anvil versiondisplays updated version info.
T011: Add regression tests for cross-PRD behavior¶
Feature: F004 Priority: high Likely files: tests/regression/test_cross_prd.py Dependencies: T004, T005
Acceptance criteria:
- Regression tests cover cross-PRD conflict detection.
- Claim gate tests validate PRD status checking.
- Coordination tests ensure stale reaper and conflict groups work across PRDs.
Verification:
pytest tests/regression/test_cross_prd.pypasses.- Tests assert cross-PRD behavior remains correct.
T012: Implement replay equivalence oracle for multi-PRD DBs¶
Feature: F002 Priority: high Likely files: src/replay/oracle.py, tests/equivalence/test_replay_equivalence.py Dependencies: T001
Acceptance criteria:
- A replay-equivalence oracle validates byte-identical replay.
- The oracle compares pre-v7 and post-v7 states.
- The comparison is deterministic and accurate.
Verification:
anvil replay --to-endproduces identical output for both DBs.anvil replay --to-revision 5matches expected output.
T013: Refactor legacy get_prd calls to use default PRD¶
Feature: F006 Priority: high Likely files: src/models/prd.py, src/cli/main.py Dependencies: T003
Acceptance criteria:
- All 12 legacy
get_prd()calls resolve to the default PRD. - No silent fallback to default PRD occurs in incorrect contexts.
- The refactor does not break existing functionality.
Verification:
anvil statusstill works as expected.anvil plandoes not silently change behavior.
T014: Implement per-PRD status rollup in anvil status¶
Feature: F006 Priority: medium Likely files: src/cli/status.py, src/models/prd.py Dependencies: T003
Acceptance criteria:
anvil statusshows per-PRD stats.anvil statusprovides a project-wide total.- The rollup is deterministic and accurate.
Verification:
anvil statusshows stats for each PRD.anvil status --prd v0.2shows only that PRD's stats.
T015: Add support for PRD-specific prune and plan operations¶
Feature: F005 Priority: high Likely files: src/cli/plan.py, src/cli/prune.py Dependencies: T006
<This task ensures that plan --prd prunes only that PRD's orphans and that conflict-group inference reads all PRDs' tasks.>
Acceptance criteria:
anvil plan --prd <id>prunes only that PRD's orphans.- Conflict group inference reads all PRDs' tasks.
- The filtering is accurate and efficient.
Verification:
anvil plan --prd v0.2filters to only tasks in that PRD.anvil planstill detects cross-PRD conflicts.
T016: Ensure backward compatibility for existing usage¶
Feature: F002 Priority: high Likely files: src/cli/main.py, src/mcp/handlers.py Dependencies: T001
Acceptance criteria:
anvil planbehaves identically to v6.anvil statusbehaves identically to v6.- All existing workflows continue to work without modification.
Verification:
anvil planproduces identical output to v6.anvil statusshows identical results to v6.
T017: Validate migration process with real-world data¶
Feature: F002 Priority: high Likely files: tests/integration/test_migration.py Dependencies: T001
Acceptance criteria:
- The migration process handles large datasets correctly.
- All data is preserved without loss or corruption.
- The migration is idempotent and safe.
Verification:
anvil migrate --to 7succeeds on a large dataset.anvil statusshows all data correctly migrated.
T018: Implement event-sourced revision tracking for PRDs¶
Feature: F007 Priority: high Likely files: src/replay/event_source.py, src/models/prd.py Dependencies: T008
Acceptance criteria:
- Each PRD has a revision counter.
- Revision tracking supports non-destructive supersede.
- The system can replay to any revision.
Verification:
anvil replay --to-revision 5works correctly.anvil serializeshows correct revision counts.
T019: Finalize documentation and user-facing versioning¶
Feature: F009 Priority: medium Likely files: docs/versioning.md, src/cli/help.py Dependencies: T010
Acceptance criteria:
- All documentation reflects the new PRD model.
- Versioning is consistent and clear.
- User-facing docs are updated and accurate.
Verification:
anvil helpshows updated documentation.anvil versiondisplays correct version info.