Work Packages: Mission DSL Foundation
Inputs: Design documents from /kitty-specs/037-mission-dsl-foundation/ Prerequisites: plan.md (required), spec.md (user stories)
Organization: Fine-grained subtasks (Txxx) roll up into work packages (WPxx). Each work package must be independently deliverable and testable.
Prompt Files: Each work package references a matching prompt file in /tasks/ generated by /spec-kitty.tasks.
Work Package WP01: transitions Dependency + JSON Schema (Priority: P0)
Goal: Add transitions library as a dependency and define the JSON Schema for v1 mission YAML validation. Independent Test: import transitions succeeds, JSON Schema validates a sample v1 mission YAML dict. Prompt: /tasks/WP01-transitions-dep-and-schema.md
Included Subtasks
- ✅ T001 Add
transitions>=0.9.2to pyproject.toml dependencies - ✅ T002 Add
jsonschemato pyproject.toml dependencies (if not already present) - ✅ T003 Create
src/specify_cli/mission_v1/__init__.pysubpackage - ✅ T004 Create
src/specify_cli/mission_v1/schema.pywith JSON Schema definition - ✅ T005 Create
tests/unit/mission_v1/test_schema.pywith validation tests
Implementation Notes
- The JSON Schema must cover:
mission(name, version, description),initial,states,transitions,inputs,outputs,guards - Guard expression patterns:
artifact_exists("..."),gate_passed("..."), etc. - Schema should validate guard expression syntax (known function names only)
Dependencies
- None (starting package).
Risks & Mitigations
transitionsversion compatibility: Pin>=0.9.2to ensure MarkupMachine support.
Work Package WP02: MissionRunner + MarkupMachine Wrapper (Priority: P0)
Goal: Create the core MissionRunner class that wraps transitions.MarkupMachine to load and execute v1 state machines. Independent Test: Load a v1 mission config dict, construct a MarkupMachine, verify state transitions work. Prompt: /tasks/WP02-mission-runner.md
Included Subtasks
- ✅ T006 Create
src/specify_cli/mission_v1/runner.pywith MissionRunner class - ✅ T007 Create MissionModel class with callback method stubs
- ✅ T008 Implement MarkupMachine construction from validated config
- ✅ T009 [P] Create
tests/unit/mission_v1/test_runner.pywith runner tests
Implementation Notes
MarkupMachine(model=model, auto_transitions=False, send_event=True, **config)- MissionModel holds feature_dir, event_log_path, inputs as context
- All callbacks on the model receive
EventData(due tosend_event=True)
Dependencies
- Depends on WP01 (schema validation runs before machine construction).
Risks & Mitigations
- MarkupMachine dict format quirks: Test with minimal configs first, then full missions.
Work Package WP03: Guard Expression Compiler (Priority: P0)
Goal: Implement the guard expression compiler that parses declarative guard strings into callable methods. Independent Test: Compile artifact_exists("spec.md") → callable that checks file existence, returns True/False. Prompt: /tasks/WP03-guard-compiler.md
Included Subtasks
- ✅ T010 Create
src/specify_cli/mission_v1/guards.pywith expression parser - ✅ T011 Implement 6 guard primitives: artifact_exists, gate_passed, all_wp_status, any_wp_status, input_provided, event_count
- ✅ T012 Implement guard compilation: string → bound method on model
- ✅ T013 Add unknown guard rejection at load time
- ✅ T014 [P] Create
tests/unit/mission_v1/test_guards.pywith guard tests
Implementation Notes
- Guard expressions are strings like
artifact_exists("spec.md")parsed via regex - Registry maps function names → factory callables that return guard methods
- Each guard method receives
EventDataand returns bool - Guards access feature context through the model (feature_dir, event_log, etc.)
Parallel Opportunities
- Can be developed in parallel with WP02 (runner) since guards are composed into the machine later.
Dependencies
- Depends on WP01 (subpackage structure).
Risks & Mitigations
- Guard expression parsing edge cases: Test with quoted paths, integers, nested quotes.
Work Package WP04: PhaseMission v0 Compatibility Wrapper (Priority: P1)
Goal: Create PhaseMission adapter that wraps v0 phase-list missions as linear state machines. Independent Test: Load existing software-dev mission.yaml (v0), wrap in PhaseMission, advance through phases linearly. Prompt: /tasks/WP04-phase-mission-compat.md
Included Subtasks
- ✅ T015 Create
src/specify_cli/mission_v1/compat.pywith PhaseMission class - ✅ T016 Generate synthetic linear state machine from phase list
- ✅ T017 Implement API compatibility with StateMachineMission
- ✅ T018 [P] Create
tests/unit/mission_v1/test_compat.pywith v0 wrapper tests
Implementation Notes
- PhaseMission reads
workflow.phasesfrom existing v0 config - Generates states: [phase1, phase2, ..., phaseN, done] with linear transitions
- No guards on v0 transitions
- Must expose same API surface as StateMachineMission (state, trigger, get_triggers, etc.)
Parallel Opportunities
- Independent of WP02/WP03 (uses Machine directly, not MarkupMachine).
Dependencies
- Depends on WP01 (subpackage structure).
Risks & Mitigations
- API surface mismatch: Define a Protocol/ABC that both classes implement.
Work Package WP05: Provisional emit_event Interface (Priority: P1)
Goal: Create the thin emit_event(type, payload) boundary for event emission, logging to JSONL. Independent Test: Call emit_event("phase_entered", {...}), verify JSONL line written to file. Prompt: /tasks/WP05-emit-event.md
Included Subtasks
- ✅ T019 Create
src/specify_cli/mission_v1/events.pywith emit_event function - ✅ T020 Implement JSONL file writer with atomic append
- ✅ T021 Wire emit_event into MissionModel callbacks (on_enter, on_exit, guard failures)
- ✅ T022 [P] Create
tests/unit/mission_v1/test_events.pywith event emission tests
Implementation Notes
- Event format:
{"type": str, "timestamp": str, "mission": str, "payload": dict} - JSONL file at
<feature_dir>/mission-events.jsonl(distinct from status events.jsonl) - emit_event failures log warning but never block state transitions
- This is a Phase 2 boundary — keep it simple, no event store
Parallel Opportunities
- Can be developed in parallel with WP03 (guards) and WP04 (compat).
Dependencies
- Depends on WP02 (MissionRunner model for callback wiring).
Risks & Mitigations
- File locking: Use append mode, no locking needed for single-process CLI.
Work Package WP06: Software-Dev v1 Mission YAML (Priority: P1)
Goal: Define the software-dev mission in v1 format with states, transitions, rollback support, and guards. Independent Test: Load software-dev v1 YAML, verify state graph has rollback transitions, guards on key transitions. Prompt: /tasks/WP06-software-dev-mission.md
Included Subtasks
- ✅ T023 Write v1 software-dev mission.yaml with states and transitions
- ✅ T024 Define guards for key transitions (artifact_exists for spec.md, plan.md, tasks.md)
- ✅ T025 Define rollback transitions (review → implement rework)
- ✅ T026 Define typed inputs and outputs
- ✅ T027 [P] Create integration test for software-dev mission loading
Implementation Notes
- States: discovery, specify, plan, implement, review, done
- Forward transitions: advance trigger for each step
- Rollback: rework trigger from review → implement
- Guards: artifact_exists("spec.md") for specify → plan, artifact_exists("plan.md") for plan → implement
- Keep existing v0 fields (workflow, artifacts, paths, etc.) for backward compat
Dependencies
- Depends on WP01 (schema), WP02 (runner), WP03 (guards).
Risks & Mitigations
- Schema validation strictness: Ensure v1 fields coexist with v0 fields in same YAML.
Work Package WP07: Research + Plan v1 Mission YAMLs (Priority: P2)
Goal: Define research and plan missions in v1 format with domain-specific state machines and guards. Independent Test: Load each v1 YAML, verify unique state graphs and domain-specific guards. Prompt: /tasks/WP07-research-plan-missions.md
Included Subtasks
- ✅ T028 Write v1 research mission.yaml with evidence-gated transitions
- ✅ T029 Write v1 plan mission.yaml with rollback transitions
- ✅ T030 Create plan mission directory structure (new mission)
- ✅ T031 Define domain-specific guards for each mission
- ✅ T032 [P] Create integration tests for research and plan mission loading
Implementation Notes
- Research: scoping → gathering → synthesis → output → done, with
event_count("source_documented", 3)guard - Plan: goals → research → structure → draft → review → done, with rollback from draft → structure
- Plan is a NEW mission — create
src/specify_cli/missions/plan/directory
Parallel Opportunities
- Can be developed in parallel with WP06 (different YAML files).
Dependencies
- Depends on WP01 (schema), WP02 (runner), WP03 (guards).
Risks & Mitigations
- New plan mission needs command-templates and templates directories.
Work Package WP08: load_mission() Dispatch + Integration (Priority: P1)
Goal: Create the load_mission() entry point that auto-detects v0/v1 format and returns the appropriate mission type. Independent Test: load_mission(path) returns StateMachineMission for v1 YAML, PhaseMission for v0 YAML. Prompt: /tasks/WP08-load-mission-dispatch.md
Included Subtasks
- ✅ T033 Implement
load_mission()inmission_v1/__init__.pywith v0/v1 dispatch - ✅ T034 Define Mission Protocol/ABC that both types satisfy
- ✅ T035 Wire load_mission into existing
get_mission_by_name()call path - ✅ T036 Handle hybrid YAML (v1 fields + v0 legacy fields coexisting)
- ✅ T037 [P] Create
tests/integration/test_mission_loading.py
Implementation Notes
- Detection: if
statesANDtransitionskeys present → v1, else v0 - v1: validate schema → construct MarkupMachine → return StateMachineMission
- v0: wrap existing Mission in PhaseMission → return
- Must not break existing
Missionclass consumers
Dependencies
- Depends on WP02 (runner), WP03 (guards), WP04 (compat).
Risks & Mitigations
- Circular imports:
mission_v1imports frommission.pyfor v0 wrapping,mission.pycallsload_missionfor dispatch. Use lazy imports.
Work Package WP09: Integration Tests + Regression Check (Priority: P2)
Goal: Comprehensive integration tests and full regression check against existing test suite. Independent Test: All integration tests pass, no new regressions in 2032+ test suite. Prompt: /tasks/WP09-integration-tests.md
Included Subtasks
- ✅ T038 Create
tests/integration/test_mission_guards.pywith guard evaluation tests - ✅ T039 E2E test: load v1 mission → trigger transitions → verify guards block/allow
- ✅ T040 E2E test: load v0 mission → PhaseMission linear progression
- ✅ T041 E2E test: load all 3 v1 missions + documentation (v0) → verify coexistence
- ✅ T042 Run full test suite for regressions
- ✅ T043 Verify existing mission tests still pass
Implementation Notes
- Guards need feature context (feature_dir, event log) — create temp fixtures
- Verify documentation mission (v0) loads unchanged alongside v1 missions
- Known baseline: ~81 failures on 2.x (pre-existing cross-test pollution)
Dependencies
- Depends on WP06, WP07, WP08 (all missions defined and dispatch working).
Risks & Mitigations
- Cross-test pollution from new transitions import: Use isolated tmp_path fixtures.
Dependency & Execution Summary
Phase 1 - Foundation:
WP01 (schema + deps) ──────────────────────────┐
│
Phase 2 - Core Engine (parallel): │
WP02 (runner) ──────── depends on WP01 ────────┤
WP03 (guards) ──────── depends on WP01 ────────┤
WP04 (v0 compat) ───── depends on WP01 ────────┤
WP05 (emit_event) ──── depends on WP02 ────────┤
│
Phase 3 - Missions + Integration (parallel): │
WP06 (software-dev) ── depends on WP01-03 ─────┤
WP07 (research+plan) ─ depends on WP01-03 ─────┤
WP08 (dispatch) ────── depends on WP02-04 ─────┘
│
Phase 4 - Validation: │
WP09 (integration) ─── depends on WP06-08 ──────┘
- Sequence: WP01 → {WP02, WP03, WP04} parallel → {WP05, WP06, WP07, WP08} parallel → WP09
- Parallelization: WP02/WP03/WP04 are fully parallel after WP01. WP06/WP07 are parallel with each other.
- MVP Scope: WP01 + WP02 + WP03 + WP04 + WP08 (core engine + dispatch + compat)
Subtask Index (Reference)
| Subtask ID | Summary | Work Package | Priority | Parallel? |
|---|---|---|---|---|
| T001 | Add transitions dependency | WP01 | P0 | No |
| T002 | Add jsonschema dependency | WP01 | P0 | No |
| T003 | Create mission_v1 subpackage | WP01 | P0 | No |
| T004 | Define JSON Schema for v1 | WP01 | P0 | No |
| T005 | Schema validation tests | WP01 | P0 | Yes |
| T006 | Create MissionRunner class | WP02 | P0 | No |
| T007 | Create MissionModel class | WP02 | P0 | No |
| T008 | MarkupMachine construction | WP02 | P0 | No |
| T009 | Runner tests | WP02 | P0 | Yes |
| T010 | Guard expression parser | WP03 | P0 | No |
| T011 | 6 guard primitives | WP03 | P0 | No |
| T012 | Guard compilation | WP03 | P0 | No |
| T013 | Unknown guard rejection | WP03 | P0 | No |
| T014 | Guard tests | WP03 | P0 | Yes |
| T015 | PhaseMission class | WP04 | P1 | No |
| T016 | Synthetic linear state machine | WP04 | P1 | No |
| T017 | API compatibility | WP04 | P1 | No |
| T018 | v0 wrapper tests | WP04 | P1 | Yes |
| T019 | emit_event function | WP05 | P1 | No |
| T020 | JSONL file writer | WP05 | P1 | No |
| T021 | Wire emit_event into callbacks | WP05 | P1 | No |
| T022 | Event emission tests | WP05 | P1 | Yes |
| T023 | Software-dev v1 YAML | WP06 | P1 | No |
| T024 | Software-dev guards | WP06 | P1 | No |
| T025 | Software-dev rollback transitions | WP06 | P1 | No |
| T026 | Software-dev typed I/O | WP06 | P1 | No |
| T027 | Software-dev integration test | WP06 | P1 | Yes |
| T028 | Research v1 YAML | WP07 | P2 | No |
| T029 | Plan v1 YAML | WP07 | P2 | No |
| T030 | Plan mission directory | WP07 | P2 | No |
| T031 | Domain-specific guards | WP07 | P2 | No |
| T032 | Research/Plan integration tests | WP07 | P2 | Yes |
| T033 | load_mission() dispatch | WP08 | P1 | No |
| T034 | Mission Protocol/ABC | WP08 | P1 | No |
| T035 | Wire into get_mission_by_name | WP08 | P1 | No |
| T036 | Hybrid YAML handling | WP08 | P1 | No |
| T037 | Mission loading integration tests | WP08 | P1 | Yes |
| T038 | Guard evaluation integration tests | WP09 | P2 | No |
| T039 | E2E v1 transitions test | WP09 | P2 | No |
| T040 | E2E v0 compat test | WP09 | P2 | No |
| T041 | E2E coexistence test | WP09 | P2 | No |
| T042 | Full test suite regression | WP09 | P2 | No |
| T043 | Existing mission tests pass | WP09 | P2 | No |
<!-- status-model:start -->
Canonical Status (Generated)
<!-- status-model:end -->
- WP01: done
- WP02: done
- WP03: done
- WP04: done
- WP05: done
- WP06: done
- WP07: done
- WP08: done
- WP09: done