Tasks: WP-Prompt Governance Payload Completeness

Mission: wp-prompt-governance-payload-01KRR8HS Mission ID: 01KRR8HS66A7NFV64HHPXG2JJE Branch: feat/org-doctrine-layerfeat/org-doctrine-layer Spec: spec.md | Plan: plan.md Total WPs: 7 | Total subtasks: 31


Work Package Overview

WPTitleDependenciesFRs coveredSubtasksagent_profile
WP01Schema extensions for Directive.references and authority_pathsFR-006 (partial), FR-008 (partial)T001–T003python-pedro
WP02charter sync: catalog-citation detection + authority_paths extractionWP01FR-006, FR-007 (partial), FR-008 (partial)T004–T008python-pedro
WP03Make build_charter_context(profile=) load-bearingWP01FR-002, FR-004 (partial)T009–T013python-pedro
WP04Render authority paths + critical-section bodies in compact/bootstrap textWP02, WP03FR-001, FR-003T014–T018python-pedro
WP05Token-budget mechanism + fetch substitutionWP04NFR-001T019–T022python-pedro
WP06Wire WP frontmatter agent_profile through prompt builder + add Governance Payload Contract sectionWP03, WP04FR-005, FR-010T023–T028python-pedro
WP07Dogfood: declare template_set + available_tools + authority_paths in .kittify/charter/charter.mdWP02FR-009T029–T031curator-carla

WP06 and WP07 can run in parallel after WP02 + WP03 + WP04 land. WP02 and WP03 can run in parallel after WP01.


FR Coverage Matrix

FRStatement (summary)WP(s)
FR-001Action-critical section bodies surface verbatim or with fetch + when-doingWP04
FR-002profile= parameter is load-bearing; profile-cited directives + tactics surfaceWP03
FR-003Project authority paths: block (defaults + charter-declared) appears in bootstrap outputWP04
FR-004_governance_context forwards agent_profile from WP frontmatter to build_charter_contextWP03 (resolver side), WP06 (wiring side)
FR-005Runtime templates either drop the forbid clause OR carry ## Governance Payload ContractWP06
FR-006charter sync detects DIRECTIVE_NNN / tactic-id citations and emits references:WP01 (schema), WP02 (detection)
FR-007Charter may declare template_set: and available_tools: fenced YAML; sync persists them; no fallback diagnosticWP02 (sync side), WP07 (charter side)
FR-008Charter may declare authority_paths: extending the default setWP01 (schema), WP02 (sync), WP04 (render)
FR-009Spec-kitty's own .kittify/charter/charter.md declares template_set + available_toolsWP07
FR-010Aggregate self-sufficiency: test_implement_prompt_self_sufficiency passesWP06 (gate)

ATDD Test → WP Mapping

The acceptance gate is tests/specify_cli/next/test_wp_prompt_governance_contract.py (NFR-003: 23/23 pass).

TestWP that turns it green
test_implement_prompt_regression_vigilance_body_or_fetch_with_when_doing_ruleWP04
test_python_pedro_directive_010_referenced_in_implement_promptWP03
test_implement_prompt_references_glossary_pathWP04
test_implement_prompt_references_adr_pathWP04
test_template_either_drops_forbid_or_guarantees_governance_payloadWP06
test_charter_sync_emits_cross_link_when_body_cites_catalog_idWP02
test_implement_prompt_self_sufficiencyWP06 (aggregate; requires WP01–WP05 first)
test_project_charter_declares_template_setWP07
test_project_charter_declares_available_toolsWP07
test_implement_action_context_includes_profile_directive_references_when_profile_knownWP03

The 14 currently-passing tests MUST remain green throughout (no regression).


Subtask Index

IDDescriptionWPParallel
T001Add references: list[str] = [] to charter.schemas.DirectiveWP01
T002Add authority_paths: list[str] = [] to charter.schemas.DoctrineSelectionConfigWP01[D]
T003Schema round-trip + backward-compat tests for the two new fieldsWP01[D]
T004Add DIRECTIVE_\d{3} / tactic-id detection regex helper in charter.extractorWP02
T005Extend Extractor._extract_directives to populate Directive.references from detected citationsWP02
T006Extend Extractor._merge_doctrine_selection to read authority_paths: from fenced YAML blocksWP02[D]
T007Extend the same site to persist template_set: and available_tools: from the YAML block (FR-007)WP02[D]
T008Unit tests in tests/charter/test_sync_references.py (citation detection, authority_paths/template_set extraction, no-citation no-error)WP02[D]
T009Replace _ = profile at src/charter/context.py:92 with a real profile lookup helperWP03
T010Add _load_agent_profile(profile_id) helper in charter.context delegating to doctrine.agent_profiles.AgentProfileRepositoryWP03
T011Add _render_profile_directives(profile, service) rendererWP03
T012Add _render_profile_tactics(profile, service) rendererWP03[D]
T013Unit tests in tests/charter/test_context_profile.py (known profile, unknown profile graceful skip, empty references)WP03[D]
T014Add _render_authority_paths(repo_root, doctrine_selection) helper (defaults + charter-declared)WP04
T015Add _render_critical_section_bodies(charter_content, action) helper (slice headings)WP04
T016Wire both renderers into _render_bootstrap_text and the compact-context surfaceWP04
T017Unit tests in tests/charter/test_context_authority_paths.py (default present/absent, additive declarations, missing dirs silent)WP04[D]
T018Unit tests in tests/charter/test_context_section_bodies.py (Terminology Canon, Regression Vigilance, Code Review Checklist surface)WP04[D]
T019Implement _apply_token_budget(text, budget=32_000) substitution mechanismWP05
T020Implement the fetch + when-doing stanza formatter (directive:, tactic:, section: selectors)WP05
T021Measure baseline against layered-doctrine-org-layer-01KRNPEE WP01–WP10 prompts (C-004); record in WP notesWP05
T022Unit tests in tests/charter/test_context_token_budget.py (under budget unchanged, longest-first substitution, severely over → all substituted, warning emitted)WP05[D]
T023In _build_wp_prompt extract wp_meta.agent_profile and pass to _governance_contextWP06
T024In _governance_context forward profile= to build_charter_contextWP06
T025Add ## Governance Payload Contract section to src/specify_cli/missions/software-dev/command-templates/implement.md (four-block schema)WP06
T026Add ## Governance Payload Contract section to src/specify_cli/missions/software-dev/command-templates/review.md (reviewer-oriented variant)WP06[D]
T027Add architectural test tests/architectural/test_template_governance_payload_contract.py (template promise ↔ resolver reality)WP06[D]
T028Run full ATDD suite; confirm 23/23 passWP06
T029Add ## Charter Resolution Hints fenced YAML block to .kittify/charter/charter.md declaring template_set: software-dev-defaultWP07
T030Extend the same block with available_tools: [git, spec-kitty, pytest, mypy, ruff] and authority_paths: [glossary/contexts/, architecture/2.x/adr/]WP07
T031Run spec-kitty charter sync; verify no Template set not selected in charter; fallback ... applied diagnosticWP07

Critical Path

WP01 → WP02 → WP04 → WP05 → WP06

(WP03 forks from WP01 in parallel with WP02 and rejoins at WP04.)

Total critical-path length: 5 WPs (WP01 → WP02 → WP04 → WP05 → WP06).


Parallel Opportunities

After landingCan run in parallel
WP01WP02 + WP03
WP04WP05 only (WP05 is the next critical-path node)
WP02 + WP03 + WP04WP06 + WP07

WP07 (charter dogfood) depends only on WP02 (the sync side), so it can land any time after WP02 completes — it does not need WP03, WP04, WP05, or WP06.



Work Packages

WP01 — Schema extensions for Directive.references and authority_paths

Dependencies: none FRs: FR-006 (partial), FR-008 (partial), NFR-005 Subtasks: T001, T002, T003 Agent profile: python-pedro Owned: src/charter/schemas.py, tests/charter/test_schemas_additive_fields.py

Pure schema change. See tasks/WP01-schema-extensions.md.


WP02 — charter sync: catalog-citation detection + authority_paths extraction

Dependencies: WP01 FRs: FR-006, FR-007, FR-008, NFR-005 Subtasks: T004, T005, T006, T007, T008 Agent profile: python-pedro Owned: src/charter/extractor.py, src/charter/sync.py

Detects DIRECTIVE_NNN citations and reads fenced YAML resolver-input declarations. See tasks/WP02-charter-sync-extensions.md.


WP03 — Make build_charter_context(profile=) load-bearing

Dependencies: WP01 FRs: FR-002, FR-004 (resolver side), NFR-004 Subtasks: T009, T010, T011, T012, T013 Agent profile: python-pedro Owned: src/charter/context.py

Profile lookup via doctrine layer; emits profile-cited directives/tactics sections. See tasks/WP03-build-charter-context-profile.md.


WP04 — Render authority paths and critical-section bodies in compact/bootstrap text

Dependencies: WP02, WP03 FRs: FR-001, FR-003, NFR-004 Subtasks: T014, T015, T016, T017, T018 Agent profile: python-pedro Owned: src/charter/context.py

Two new rendered sections: Project authority paths: and Action-Critical Charter Sections (<action>):. See tasks/WP04-authority-paths-and-section-bodies.md.


WP05 — Token-budget enforcement and fetch substitution

Dependencies: WP04 FRs: NFR-001, NFR-002 Subtasks: T019, T020, T021, T022 Agent profile: python-pedro Owned: src/charter/context.py, scripts/measure-wp-prompt.py

Auto-substitute longest bodies with fetch stanzas under 32 000 char budget. See tasks/WP05-token-budget-and-fetch-substitution.md.


WP06 — Wire WP frontmatter agent_profile through prompt builder + Governance Payload Contract templates

Dependencies: WP03, WP04 FRs: FR-004 (wiring), FR-005, FR-010, NFR-003 Subtasks: T023, T024, T025, T026, T027, T028 Agent profile: python-pedro Owned: src/specify_cli/next/prompt_builder.py, src/specify_cli/missions/software-dev/command-templates/implement.md, src/specify_cli/missions/software-dev/command-templates/review.md

Final integration WP. Gate for 23/23 ATDD pass. See tasks/WP06-prompt-builder-wiring-and-templates.md.


WP07 — Dogfood: declare template_set + available_tools + authority_paths in spec-kitty's own charter

Dependencies: WP02 FRs: FR-007, FR-008, FR-009, C-005 Subtasks: T029, T030, T031 Agent profile: curator-carla Owned: .kittify/charter/charter.md

Markdown-only change. Eliminates fallback diagnostics on spec-kitty's own missions. See tasks/WP07-dogfood-charter-resolution-hints.md.


References

  • tests/specify_cli/next/test_wp_prompt_governance_contract.py — 23 ATDD tests (executable spec).
  • docs/development/wp-prompt-governance-atdd-findings.md — per-test failure-to-FR mapping.
  • docs/development/org-doctrine-layer-architecture-review.md — root-cause analysis.
  • contracts/charter-context-resolver.md, contracts/charter-sync-cross-link.md, contracts/runtime-template-governance-payload-contract.md — the three contracts this mission must satisfy.
  • data-model.md — schema additions (additive, NFR-005 by construction).