Work Packages: Native stale-content refusal enforcement

Inputs: Design documents from /kitty-specs/native-stale-content-refusal-01M4S2CQ/ Prerequisites: plan.md (required), spec.md (user stories), grounding-note.md

Tests: Required (ATDD red-first) — the acceptance test is the contract.

Organization: One coherent work package. The fix is a single behaviour change across the shared native completion surface (the marker-gated refusal now runs natively as it already does on the orchestrator-api path), touching tightly-coupled files that share one test journey. Merging the two concerns (IC-01 native next, IC-02 native finalize) into one WP avoids an artificial ownership split of the shared test_planning_client_journey.py and the shared design seam.

Subtask Format: [Txxx] [P?] Description

Path Conventions

  • Single project: src/, tests/.

Work Package WP01: Native completion enforces the API-authored marker-gated refusal (Priority: P1) 🎯 MVP

Goal: Move the marker-gated validate_stage refusal onto the native completion surfaces — spec-kitty next --result success (via the shared top-layer seam next_cmd.next_step) and the native agent … finalize-tasks commands (via the existing design.validation.finalization_scope) — with the orchestrator-api _completion_gate removed so there is a single canonical authority. Independent Test: Red-first cases drive the native CLI against an API-authored Mission with stale/unfinished content and assert the typed DESIGN_* refusal — RED on origin/main, GREEN on the fix; non-API-authored Missions and the orchestrator-api journey stay byte-identical. Prompt: /tasks/WP01-native-completion-marker-gated-refusal.md Requirement Refs: FR-001, FR-002, FR-003, FR-004, FR-005, NFR-001, NFR-002, NFR-003, C-001, C-002, C-003

Included Subtasks

T001 Red-first: add a native spec-kitty next --result success stale-content refusal case to tests/specify_cli/orchestrator_api/test_planning_client_journey.py (RED on base) T002 Red-first: add a native agent … finalize-tasks stale-content refusal case (RED on base) T003 Implement the marker-gated completion gate in src/specify_cli/cli/commands/next_cmd.py::next_step (result==success, api_authoring_enabled + issued_step_id_for_mission → validate_stage under authoring_lock) T004 Remove the now-redundant _completion_gate/_run_governed from src/specify_cli/orchestrator_api/runtime_next.py (single authority); preserve single-JSON stdout + RUNTIME_NEXT_FAILED/data.reason mapping T005 Wrap native agent mission finalize-tasks / agent tasks finalize-tasks in design.validation.finalization_scope when api_authoring_enabled (enforces validate_stage("tasks"), acquires authoring_lock, success-gated receipt re-stamp) T006 Update tests/specify_cli/orchestrator_api/test_runtime_next.py to reflect the gate relocation; add read-only + marker-gate unit assertions in tests/specify_cli/design/test_design_authoring.py T007 Run targeted tests + specific architectural gate files; ruff/format/mypy clean

Implementation Notes

  • Seam placement is next_cmd.next_step (top layer), NOT the runtime bridge — test_layer_rules.py forbids runtime → specify_cli.design. See grounding-note.md §3 and C-001.
  • Gate fires only for result == "success" and only when api_authoring_enabled (marker present); the validated stage is the native persisted issued_step_id, never a caller-supplied stage.
  • authoring_lock is reentrant, so the api verb calling next_step in-process will not deadlock.

Dependencies

  • None (single WP, starting package).

Risks & Mitigations

  • Root resolution for the marker/receipts in next_step (git common dir vs owned checkout) → resolve the same way the rest of next_step resolves the mission; pin with tests.
  • Dead-symbol gate after removing _completion_gate → update references/allowlist if needed.
  • Merge-coordination with open PRs #5907 / #5945 on the finalize/runtime-bridge guard surface → keep the diff small, rebase late.

Dependency & Execution Summary

  • Sequence: WP01 only.
  • MVP Scope: WP01 is the whole mission.

Requirements Coverage Summary

Requirement IDCovered By Work Package(s)
FR-001WP01
FR-002WP01
FR-003WP01
FR-004WP01
FR-005WP01
NFR-001WP01
NFR-002WP01
NFR-003WP01
C-001WP01
C-002WP01
C-003WP01

Subtask Index (Reference)

Subtask IDSummaryWork PackagePriorityParallel?
T001Red-first native next refusal caseWP01P1No
T002Red-first native finalize refusal caseWP01P1No
T003Gate in next_cmd.next_stepWP01P1No
T004Remove api _completion_gateWP01P1No
T005Wrap native finalize in finalization_scopeWP01P1No
T006Update/extend testsWP01P1No
T007Targeted tests + gates + lint/typeWP01P1No