Tasks: Ticket-First Mission Origin Binding

Feature: 061-ticket-first-mission-origin-binding Date: 2026-04-01 Target Branch: main

Subtask Register

IDDescriptionWPParallel
T001Create OriginCandidate frozen dataclassWP01[P]
T002Create SearchOriginResult frozen dataclassWP01[P]
T003Create MissionFromTicketResult dataclassWP01[P]
T004Add set_origin_ticket() mutation helper to feature_metadata.pyWP01
T005Add origin_ticket to FeatureMetaOptional TypedDictWP01
T006Write tests for dataclass construction and field validationWP01
T007Write tests for set_origin_ticket() — writes, preserves, validatesWP01
T008Add MissionOriginBound to _PAYLOAD_RULES dict in emitterWP02
T009Add emit_mission_origin_bound() method to EventEmitter classWP02
T010Add MissionOriginBound validators (feature_slug, provider, fields)WP02
T011Write tests for emit_mission_origin_bound() payload validationWP02
T012Write tests for event routing and offline queue behaviorWP02
T013Add _SEARCH_ISSUES_PATH and _BIND_ORIGIN_PATH class constantsWP03
T014Implement search_issues() method on SaaSTrackerClientWP03
T015Implement bind_mission_origin() method on SaaSTrackerClientWP03
T016Write tests for search_issues() — 200, empty, 401/403, 404, 422, 429WP03
T017Write tests for bind_mission_origin() — 200, same-origin, 409, 401WP03
T018Create core/feature_creation.py with FeatureCreationResult dataclassWP04
T019Create FeatureCreationError exception classWP04
T020Extract core logic from create_feature() into create_feature_core()WP04
T021Refactor create_feature() typer command to thin wrapperWP04
T022Write tests for create_feature_core() — happy path, errorsWP04
T023Verify existing create_feature CLI behavior unchanged (regression)WP04
T024Implement search_origin_candidates() in tracker/origin.pyWP05
T025Implement bind_mission_origin() in tracker/origin.py (SaaS-first)WP05
T026Implement start_mission_from_ticket() in tracker/origin.pyWP05
T027Implement slug derivation from ticket key/titleWP05
T028Write tests for search_origin_candidates() — all 6 spec scenariosWP05
T029Write tests for bind_mission_origin() — ordering, re-bind semanticsWP05
T030Write tests for start_mission_from_ticket() — full orchestrationWP05
T031End-to-end test: search → confirm → bind with mocked HTTPWP06
T032End-to-end test: start_mission_from_ticket full flowWP06
T033Test error propagation across all layersWP06
T034Test SaaS-first write ordering (SaaS fail → no local write)WP06
T035Test offline event queuing for MissionOriginBoundWP06

Dependency Graph

WP01 (data models + metadata) ──┐
WP02 (event registration)   ────┤
WP03 (SaaS client transport) ───┼──▶ WP05 (orchestration) ──▶ WP06 (integration)
WP04 (create-feature extract) ──┘

Parallelization: WP01, WP02, WP03, WP04 have zero interdependencies and can run simultaneously (4-way parallel). WP05 is the convergence point. WP06 is the final gate.


Phase 1: Foundation (parallel)

WP01: Data Models and Metadata Helper

Priority: High (foundation for all downstream work) Subtasks: T001–T007 (7 subtasks) Dependencies: None Prompt: tasks/WP01-data-models-metadata-helper.md Estimated size: ~350 lines

Goal: Create the three origin dataclasses in tracker/origin.py, add the set_origin_ticket() mutation helper to feature_metadata.py, and write tests for all of them.

Implementation sketch: 1. Create tracker/origin.py with OriginCandidate, SearchOriginResult, MissionFromTicketResult 2. Add set_origin_ticket() to feature_metadata.py following set_documentation_state() pattern 3. Add origin_ticket to FeatureMetaOptional TypedDict 4. Write tests in tests/sync/tracker/test_origin.py (dataclass tests) 5. Write tests in tests/specify_cli/test_feature_metadata.py (metadata helper tests)

Risks: None — pure data structures and a thin mutation helper.


WP02: Event Registration

Priority: High (foundation for downstream orchestration) Subtasks: T008–T012 (5 subtasks) Dependencies: None Prompt: tasks/WP02-event-registration.md Estimated size: ~300 lines

Goal: Register MissionOriginBound as a new event type in the emitter system with full payload validation and an emit_mission_origin_bound() method.

Implementation sketch: 1. Add MissionOriginBound entry to _PAYLOAD_RULES in sync/emitter.py 2. Add emit_mission_origin_bound() method to EventEmitter 3. Write payload validation tests 4. Write event routing / offline queue tests

Risks: Must follow existing event patterns exactly — validator lambdas, aggregate type.


WP03: SaaS Client Transport Extensions

Priority: High (foundation for downstream orchestration) Subtasks: T013–T017 (5 subtasks) Dependencies: None Prompt: tasks/WP03-saas-client-transport.md Estimated size: ~400 lines

Goal: Add search_issues() and bind_mission_origin() to SaaSTrackerClient with full error handling and retry behavior.

Implementation sketch: 1. Add placeholder path constants 2. Implement search_issues() using _request_with_retry() 3. Implement bind_mission_origin() using _request_with_retry() + Idempotency-Key 4. Write HTTP-layer tests with mocked httpx.Client and _make_response() helper

Risks: SaaS endpoint paths are placeholders (Team B dependency). Tests use mocked HTTP so implementation proceeds regardless.


WP04: create-feature Core Extraction

Priority: High (prerequisite for orchestration) Subtasks: T018–T023 (6 subtasks) Dependencies: None Prompt: tasks/WP04-create-feature-extraction.md Estimated size: ~450 lines

Goal: Extract the core feature-creation logic from the typer command into src/specify_cli/core/feature_creation.py as a reusable public function. Refactor the existing CLI command to a thin wrapper. Verify no regression.

Implementation sketch: 1. Create core/feature_creation.py with FeatureCreationResult + FeatureCreationError 2. Move core logic from create_feature() (lines 518–833 in feature.py) 3. Refactor create_feature() to call create_feature_core() + format output 4. Write unit tests for create_feature_core() 5. Run existing CLI tests to verify regression-free

Risks: Large refactor (~300 lines of logic to move). Must preserve all side effects (git commits, event emission, dossier sync).


Phase 2: Orchestration

WP05: Service-Layer Orchestration

Priority: Critical (normative API surface) Subtasks: T024–T030 (7 subtasks) Dependencies: WP01, WP02, WP03, WP04 Prompt: tasks/WP05-service-layer-orchestration.md Estimated size: ~500 lines

Goal: Implement the three service-layer functions in tracker/origin.py that compose the foundation, transport, and creation layers into the normative API consumed by /spec-kitty.specify.

Implementation sketch: 1. Implement search_origin_candidates() — config load, validation, delegation 2. Implement bind_mission_origin() — SaaS-first ordering, local write, event emit 3. Implement start_mission_from_ticket() — slug derivation, create, bind 4. Write tests covering all 6 spec scenarios + ordering + re-bind semantics

Risks: Convergence of 4 dependencies. SaaS-first write ordering must be verified. Slug derivation edge cases.


Phase 3: Validation

WP06: Integration Testing

Priority: High (final quality gate) Subtasks: T031–T035 (5 subtasks) Dependencies: WP05 Prompt: tasks/WP06-integration-testing.md Estimated size: ~350 lines

Goal: End-to-end integration tests that wire all layers together with mocked HTTP at the httpx boundary. Verify the full search → confirm → bind → create flow, error propagation, write ordering, and offline event queuing.

Implementation sketch: 1. Build test fixtures that compose real service functions with mocked HTTP 2. Test full happy-path flow 3. Test error propagation chain 4. Test SaaS-first ordering invariant 5. Test offline event queuing

Risks: Test complexity — many layers to compose. Keep fixtures focused and reusable.