Work Packages: Fix Doctrine Migration Test Failures

Inputs: Design documents from kitty-specs/062-fix-doctrine-migration-test-failures/ Prerequisites: plan.md (required), spec.md (user stories)

Tests: Tests are the primary deliverable — this mission fixes broken tests and adds a contract test.

Organization: Fine-grained subtasks (Txxx) roll up into work packages (WPxx). Each work package is independently deliverable.

Prompt Files: Each work package references a matching prompt file in tasks/.

Subtask Format: [Txxx] [P?] Description

  • [P] indicates the subtask can proceed in parallel (different files/components).

Work Package WP01: Update Hardcoded Mission Paths (Priority: P1)

Goal: Replace all hardcoded src/specify_cli/missions/ paths in 4 test files with MissionTemplateRepository.default_missions_root(). Independent Test: All 4 test files pass: pytest tests/missions/test_mission_software_dev_integration.py tests/missions/test_documentation_mission.py tests/missions/test_documentation_templates.py tests/specify_cli/test_command_template_cleanliness.py Prompt: tasks/WP01-update-hardcoded-mission-paths.md Requirement Refs: FR-001, C-002

Included Subtasks

  • ✅ T001 [P] Fix tests/missions/test_mission_software_dev_integration.py path (lines 34-40)
  • ✅ T002 [P] Fix tests/missions/test_documentation_mission.py path (lines 12-13, 19)
  • ✅ T003 [P] Fix tests/missions/test_documentation_templates.py path (line 11)
  • ✅ T004 [P] Fix tests/specify_cli/test_command_template_cleanliness.py path
  • ✅ T005 Run all 4 files and verify zero failures

Implementation Notes

  • Import MissionTemplateRepository from doctrine.missions.repository
  • Replace Path(__file__).parents[N] / "src" / "specify_cli" / "missions" with MissionTemplateRepository.default_missions_root()
  • This avoids hardcoding src/doctrine/missions/ and prevents future breakage if paths move again

Parallel Opportunities

  • T001-T004 are all independent file edits — fully parallelizable.

Dependencies

  • None (starting package).

Risks & Mitigations

  • MissionTemplateRepository import may fail if doctrine package not installed → already in editable install, tested in CI

Work Package WP02: Fix Terminology and Assertion Mismatches (Priority: P1)

Goal: Update 2 test files with stale terminology ("Feature""Mission", feature=mission=). Independent Test: pytest tests/sync/test_emitter_origin.py tests/missions/test_feature_lifecycle_unit.py Prompt: tasks/WP02-fix-terminology-assertions.md Requirement Refs: FR-002

Included Subtasks

  • ✅ T006 [P] Fix tests/sync/test_emitter_origin.py aggregate_type assertion (line 203)
  • ✅ T007 [P] Fix tests/missions/test_feature_lifecycle_unit.py parameter name in mock assertion (line 117)
  • ✅ T008 Verify both files pass locally

Implementation Notes

  • T006: Change assert event["aggregate_type"] == "Feature" to == "Mission" (confirmed by commit 1c5a7927)
  • T007: Read accept_feature() signature to confirm parameter was renamed from feature= to mission=, then update the mock assertion

Parallel Opportunities

  • T006 and T007 are independent file edits.

Dependencies

  • None.

Risks & Mitigations

  • Parameter rename may have broader impact → check all callers of accept_feature() / top_level_accept()

Work Package WP03: Repair Mock Targets and Missing Fixtures (Priority: P1)

Goal: Fix 3 test files with broken mock targets, missing directories, or stale import assertions. Independent Test: pytest tests/init/test_worktree_topology.py tests/agent/cli/commands/test_workflow_profile_injection.py tests/init/test_feature_detection_integration.py Prompt: tasks/WP03-repair-mock-targets-fixtures.md Requirement Refs: FR-003, FR-004

Included Subtasks

  • ✅ T009 Fix tests/init/test_worktree_topology.py — update mock target for read_frontmatter (already correct — mock patches lookup site, no change needed)
  • ✅ T010 Fix tests/agent/cli/commands/test_workflow_profile_injection.py — fix _proposed/ path (changed _proposed/shipped/)
  • ✅ T011 Fix tests/init/test_feature_detection_integration.py — update import assertions (already passing — import structure matches assertions, no change needed)
  • ✅ T012 Verify all 3 files pass locally (43/43 pass)

Implementation Notes

  • T009: Read src/specify_cli/core/worktree_topology.py to find where read_frontmatter is imported from. Update mock patch target to match the actual import path.
  • T010: Check if src/doctrine/agent_profiles/_proposed/ should exist. If not, update the test to use shipped/ or create the fixture.
  • T011: Read src/specify_cli/cli/commands/implement.py to understand current import structure. Update test assertions to match.

Parallel Opportunities

  • T009, T010, T011 are independent files — parallelizable.

Dependencies

  • None.

Risks & Mitigations

  • T009 may reveal deeper API refactoring → if read_frontmatter was removed entirely, the test logic needs rewriting (not just path swap). Document and handle in-WP.

Work Package WP04: Fix Migration Test Logic (Priority: P1)

Goal: Fix documentation mission migration test to assert behavior consistent with current migration logic. Independent Test: pytest tests/upgrade/test_m_0_12_0_documentation_mission_unit.py Prompt: tasks/WP04-fix-migration-test-logic.md Requirement Refs: FR-005

Included Subtasks

  • ✅ T013 Read migration code src/specify_cli/upgrade/migrations/m_0_12_0_documentation_mission.py to understand current behavior (already passing — resolved by upstream 8842ffa7)
  • ✅ T014 Determine whether test or migration is wrong regarding command-templates/ directory (moot — both are consistent)
  • ✅ T015 Apply fix (update test assertion or migration filtering) and verify (no fix needed — 21/21 pass, 335/335 upgrade tests pass)

Implementation Notes

  • The test asserts command-templates/ should NOT be copied by the migration, but the migration copies the full directory tree. Investigate which is the intended behavior.
  • If migration is correct: update test to expect command-templates/ to exist after migration
  • If test is correct: add filtering to migration to exclude command-templates/ (exception to C-001)

Parallel Opportunities

  • None — this is a single investigation.

Dependencies

  • None.

Risks & Mitigations

  • Changing migration behavior could affect existing projects → check if other tests depend on the migration copying command-templates

Work Package WP05: Fix Dashboard Scanner and JS Key Mismatch (Priority: P1)

Goal: Validate the two dashboard fixes already applied during triage (scanner NameError, JS key mismatch). Independent Test: Dashboard loads at http://127.0.0.1:9239 and the mission selector shows missions. Prompt: tasks/WP05-fix-dashboard-scanner-js.md Requirement Refs: FR-008, FR-009

Included Subtasks

  • ✅ T016 Verify src/specify_cli/dashboard/scanner.py fix — feature_dirmission_dir on lines 367, 371 (already fixed); found and fixed additional feature_dir at line 554 in scan_mission_kanban()
  • ✅ T017 Verify src/specify_cli/dashboard/static/dashboard/dashboard.js fix — data.missions || data.features on lines 1244-1246 (confirmed in place)
  • ✅ T018 Run dashboard locally and confirm mission selector populates (45/45 dashboard tests pass; browser E2E skipped — not automatable in CI)

Implementation Notes

  • Both fixes were applied during the triage conversation. This WP validates they are correct and complete.
  • Scanner fix: the CanonicalStatusNotFoundError handler referenced feature_dir (undefined) instead of mission_dir (in scope)
  • JS fix: API response keys were renamed (featuresmissions, active_feature_idactive_mission_id) but JS not updated

Parallel Opportunities

  • T016 and T017 are independent verifications.

Dependencies

  • None.

Risks & Mitigations

  • JS backward-compat (data.missions || data.features) may mask future issues → WP08 architect review will evaluate clean break

Work Package WP06: Add Dashboard API Contract Test (Priority: P2)

Goal: Create a pytest that validates the dashboard JS reads the same response keys the Python API emits. Independent Test: pytest tests/test_dashboard/test_api_contract.py Prompt: tasks/WP06-dashboard-api-contract-test.md Requirement Refs: FR-010

Included Subtasks

  • ✅ T019 Extract canonical response keys from handle_missions_list() in src/specify_cli/dashboard/handlers/missions.py
  • ✅ T020 Create tests/test_dashboard/test_api_contract.py with key-matching assertions
  • ✅ T021 Add tests for kanban and constitution endpoints (kanban lanes key tested; constitution returns plain text, not JSON — no key contract to test)
  • ✅ T022 Verify test catches the original bug (JS referencing data.features fails) — confirmed: removing data.missions causes assertion failure on active_mission_id

Implementation Notes

  • The test reads the JS file as text and asserts each response key appears as data.<key>, data["<key>"], or data['<key>']
  • Mark as pytest.mark.fast — no server needed, pure string matching
  • Reference issue: Priivacy-ai/spec-kitty#361 for future TypedDict codegen approach

Parallel Opportunities

  • T019-T021 are sequential (need keys before writing test).

Dependencies

  • Depends on WP05 (the JS fix must be in place for the contract test to pass).

Risks & Mitigations

  • String matching is brittle (minification, variable aliasing) → acceptable for now, TypedDict codegen is the long-term fix

Work Package WP07: Targeted Coverage + CI Gate Split (Priority: P2)

Goal: Write tests for critical changed paths and split the CI diff-cover gate into enforced (critical) + advisory (everything else). Independent Test: Critical-path diff-coverage >= 90%. CI workflow validates with split gates. Prompt: tasks/WP07-targeted-coverage-ci-split.md Requirement Refs: FR-006, NFR-002

Included Subtasks

  • ✅ T023 Measure diff-coverage after WP01-06 to identify remaining gaps
  • ✅ T024 [P] Write tests for dashboard/handlers/missions.py critical paths
  • ✅ T025 [P] Write tests for core/mission_detection.py uncovered changed lines
  • ✅ T026 Split .github/workflows/ci-quality.yml diff-cover into enforced critical + advisory full
  • ✅ T027 Verify CI workflow config is syntactically valid

Implementation Notes

1. Enforced: --fail-under=90 --include src/specify_cli/status/ --include src/specify_cli/core/mission_detection.py --include src/specify_cli/dashboard/handlers/ --include src/specify_cli/dashboard/scanner.py --include src/specify_cli/merge/ --include src/specify_cli/next/ 2. Advisory: no --fail-under, || true to prevent failure

  • T023: Run diff-cover locally to see current state after other WPs land
  • T024-T025: Only test critical paths (status, mission detection, dashboard API). Do NOT write tests for migrations, CLI scaffolding, or tracker code just to hit a number.
  • T026: Replace single --fail-under=80 with two steps:

Parallel Opportunities

  • T024 and T025 can proceed in parallel once T023 identifies gaps.

Dependencies

  • Depends on WP01, WP02, WP03, WP04, WP05, WP06 (needs all fixes in place to measure accurately).

Risks & Mitigations

  • diff-cover --include flag syntax may not support glob patterns → test locally first; fall back to explicit file list
  • CI flat coverage gate may still fail even after split → the advisory step uses || true so it won't block

Work Package WP08: Architectural Fitness Review (Priority: P3)

Goal: Architect reviews the branch direction and validates test patterns align with doctrine package vision. Independent Test: Architect produces a review verdict (approve/request-changes) with documented rationale. Prompt: tasks/WP08-architectural-fitness-review.md Requirement Refs: FR-007

Included Subtasks

  • ✅ T028 Review path convention consistency across all fixed test files
  • ✅ T029 Evaluate dashboard JS backward-compat approach (data.missions || data.features)
  • ✅ T030 Grep for remaining feature_dir / featuremission_dir / mission rename gaps
  • ✅ T031 Produce review verdict with follow-up items

Implementation Notes

  • This is a review WP, not implementation. The architect reads the changes from WP01-07 and validates architectural alignment.
  • Key questions: Are tests using MissionTemplateRepository consistently? Should the JS backward-compat be a clean break? Are there other rename gaps?

Parallel Opportunities

  • None — sequential review.

Dependencies

  • Depends on WP07 (all implementation must be complete before review).

Risks & Mitigations

  • Architect may find systemic issues requiring additional WPs -> document as follow-up missions, don't expand scope of 062

Work Package WP09: Dashboard In-Review Lane Display and WP Card Identity (Priority: P2)

Goal: Render in_review WPs in the dashboard "For Review" column with a distinct card style, and display agent identity fields (tool, profile, role, model) in the WP detail modal. Independent Test: PWHEADLESS=1 pytest tests/dashboard/ -v -- Playwright verifies UI rendering. Prompt: tasks/WP09-dashboard-in-review-lane-and-card-identity.md Requirement Refs: FR-011, FR-012

Included Subtasks

  • ✅ T032 [P] Render in_review WPs in the For Review column with distinct border style
  • ✅ T033 [P] Display agent identity fields on WP card detail modal
  • ✅ T034 Expose model field from scanner to dashboard API
  • ✅ T035 Playwright verification of UI changes

Implementation Notes

  • T032: Include both for_review and in_review WPs in the "For Review" lane. Apply .card.in-review CSS class with darker purple border on all edges.
  • T033: Add "Agent Identity" section to detail modal showing tool, profile, role, model. Only render non-empty fields.
  • T034: In scanner.py _process_wp_file(), extract model from WP frontmatter and add to task dict.
  • T035: Playwright test with WPs in both for_review and in_review lanes, verify rendering and modal content.

Parallel Opportunities

  • T032 and T033 are independent UI changes (different sections of dashboard.js).

Dependencies

  • Depends on WP05 (dashboard fixes must be in place).

Risks & Mitigations

  • Detail modal structure may differ from expectations -> read full dashboard.js before implementing.
  • in_review lane may not be in the JS lane mapping -> verify and update lane categorisation.

Dependency & Execution Summary

Wave 1 (parallel): WP01, WP02, WP03, WP04, WP05
Wave 2 (after WP05): WP06, WP09
Wave 3 (after all): WP07
Wave 4 (after WP07): WP08
  • Parallelization: WP01-05 are fully independent -- 5 agents can work simultaneously. WP06 and WP09 both depend on WP05 and can run in parallel with each other.
  • MVP Scope: WP01-05 (fixes all CI failures). WP06-09 are hardening and review.

Requirements Coverage Summary

Requirement IDCovered By Work Package(s)
FR-001WP01
FR-002WP02
FR-003WP03
FR-004WP03
FR-005WP04
FR-006WP07
FR-007WP08
FR-008WP05
FR-009WP05
FR-010WP06
FR-011WP09
FR-012WP09
NFR-001WP01-05
NFR-002WP07
NFR-003WP01-06
C-001All (test-only except WP05 dashboard fixes, WP07 CI config)
C-002WP01 (uses MissionTemplateRepository)
C-003All

Subtask Index (Reference)

Subtask IDSummaryWork PackagePriorityParallel?
T001Fix test_mission_software_dev_integration.py pathWP01P1Yes
T002Fix test_documentation_mission.py pathWP01P1Yes
T003Fix test_documentation_templates.py pathWP01P1Yes
T004Fix test_command_template_cleanliness.py pathWP01P1Yes
T005Verify WP01 tests passWP01P1No
T006Fix test_emitter_origin.py aggregate_typeWP02P1Yes
T007Fix test_feature_lifecycle_unit.py param nameWP02P1Yes
T008Verify WP02 tests passWP02P1No
T009Fix test_worktree_topology.py mock targetWP03P1Yes
T010Fix test_workflow_profile_injection.py _proposed/WP03P1Yes
T011Fix test_feature_detection_integration.py importsWP03P1Yes
T012Verify WP03 tests passWP03P1No
T013Investigate m_0_12_0 migration behaviorWP04P1No
T014Fix test or migration for command-templates/WP04P1No
T015Verify WP04 test passesWP04P1No
T016Verify scanner.py NameError fixWP05P1Yes
T017Verify dashboard.js key mismatch fixWP05P1Yes
T018Verify dashboard loads missionsWP05P1No
T019Extract response keys from Python handlerWP06P2No
T020Create test_api_contract.pyWP06P2No
T021Add kanban/constitution endpoint testsWP06P2No
T022Verify contract test catches original bugWP06P2No
T023Measure diff-coverage after WP01-06WP07P2No
T024Write tests for dashboard handlers critical pathsWP07P2Yes
T025Write tests for mission_detection.py uncovered linesWP07P2Yes
T026Split CI diff-cover into enforced + advisoryWP07P2No
T027Verify CI workflow config validityWP07P2No
T028Review path convention consistencyWP08P3No
T029Evaluate JS backward-compat approachWP08P3No
T030Grep for remaining feature→mission renamesWP08P3No
T031Produce review verdictWP08P3No
T032Render in_review WPs in For Review columnWP09P2Yes
T033Display agent identity on WP card modalWP09P2Yes
T034Expose model field from scannerWP09P2No
T035Playwright verification of UI changesWP09P2No