Tasks: Charter-Mediated Doctrine Selection (Mission B)

Mission: charter-mediated-doctrine-selection-01KRTZCA Branch: feat/org-doctrine-layerfeat/org-doctrine-layer Spec: spec.md | Plan: plan.md | Data model: data-model.md Total WPs: 9 | Total subtasks: 51


Subtask Index

IDDescriptionWPParallel
T001Extend DoctrineSelectionConfig with 5 new selected_<kind> fieldsWP01
T002Extend OrgCharterPolicy with 7 new required_<kind> fields + activations fieldWP01[D]
T003Add ActivationEntry, ALLOWED_MISSION_TYPES, ALLOWED_ACTIONS, resolve_for_context in src/charter/activations.pyWP01[D]
T004Extend _OPTIONAL_EMPTY_OMIT_KEYS in src/charter/schemas.py with 5 new keys for NFR-005 byte-stabilityWP01
T005Unit tests for new schema fields (round-trip empty, round-trip populated, parity)WP01[D]
T006Extend charter.extractor._apply_selection_row to read the 5 new selected_<kind> fieldsWP02
T007Add _apply_activations_block handler reading top-level activations: from charter.md fenced YAMLWP02
T008Add activations field to GovernanceConfig (sibling of doctrine); round-trip through governance.yamlWP02
T009Unit tests for extractor: round-trip selected_styleguides; round-trip activations block; mixed-fields fixtureWP02[D]
T010Create src/charter/profiles.py re-exporting AgentProfile, AgentProfileRepository, Role, DEFAULT_ROLE_CAPABILITIESWP03[D]
T011Create src/charter/mission_steps.py re-exporting MissionStep, MissionStepContract, MissionStepContractRepositoryWP03[D]
T012Create src/charter/drg.py re-exporting DRG types + functions (DRGEdge, DRGGraph, DRGNode, Relation, NodeKind, load_graph, merge_layers, resolve_context, ResolvedContext)WP03[D]
T013Create src/charter/primitives.py re-exporting PrimitiveExecutionContext, execute_with_glossaryWP03[D]
T014Create src/charter/resolution.py re-exporting ResolutionResult, ResolutionTierWP03[D]
T015Create src/charter/versioning.py re-exporting check_bundle_compatibility, get_bundle_schema_versionWP03[D]
T016Add tests/architectural/test_charter_facades_reexport_doctrine.py asserting each facade re-exports the named doctrine symbolsWP03[D]
T017Add _render_selected_styleguides helper in src/charter/context.pyWP04
T018Add _render_selected_toolguides, _render_selected_procedures, _render_selected_agent_profiles, _render_selected_mission_step_contracts helpersWP04
T019Wire all 5 new render helpers into build_charter_context after existing directive/tactic renderersWP04
T020Carry provenance metadata (source: org / pack name) through new renderers for org-distributed artifactsWP04
T021Unit tests: each new renderer emits ID + body (or fetch + when-doing under overflow); provenance line present for org artifactsWP04[D]
T022Add _render_activation_stanza helper in src/charter/context.py producing the "When you <action> in a <mission_type> mission, run ..." lineWP05
T023Wire activation resolver call (charter.activations.resolve_for_context) into build_charter_context and render matching entriesWP05
T024Populate tests/architectural/test_trigger_registry_coverage.py::_REGISTERED_TRIGGERS with the 14-token frozenset per data-model.md §7 + MANDATORY runtime re-export from src/charter/activations.pyWP05[D]
T024aCross-check architectural test test_trigger_registry_runtime_export_in_sync asserting byte-identical equality between canonical SSOT frozensets and charter.activations runtime re-exportsWP05[D]
T025Unit tests: activation stanza emitted on context match; wildcard match works; multiple matches concatenate in declaration orderWP05[D]
T026Extend apply_org_charter_to_interview in src/specify_cli/doctrine/org_charter.py to union every required_<kind> (7 new) into interview_data.selected_<kind>WP06
T027Extend load_org_charter_policies merge to handle all 8 required_<kind> lists with union-preserving-first-seen-order semanticsWP06
T028Extend org-pack merge for activations field (concatenate; last-duplicate-wins on identity 4-tuple)WP06
T029Extend DoctrineLayerCollisionWarning emission to cover styleguides, toolguides, paradigms, procedures, mission_step_contracts (FR-014)WP06
T030Implement strict missing-pack policy (FR-015): hard-fail with named-pack-and-path error when local_path does not existWP06
T031Unit tests: org charter union for each kind; collision warning for each kind; missing-pack hard-failWP06[D]
T032Migrate src/specify_cli/invocation/registry.py to from charter.profiles import ...; remove from allowlistWP07
T033Migrate src/specify_cli/invocation/router.py to from charter.profiles import ...; remove from allowlistWP07[D]
T034Migrate src/specify_cli/mission_loader/registry.py and mission_loader/contract_synthesis.py to from charter.mission_steps import ...; remove both from allowlistWP07[D]
T035Migrate src/specify_cli/mission_step_contracts/executor.py to from charter.mission_steps import ... + from charter.drg import ...; remove from allowlistWP07[D]
T036Migrate src/specify_cli/calibration/walker.py and glossary/drg_builder.py to from charter.drg import ...; remove both from allowlistWP07[D]
T037Migrate src/specify_cli/missions/__init__.py to from charter.primitives import ...; remove from allowlistWP07[D]
T038Migrate src/specify_cli/runtime/resolver.py to from charter.resolution import ...; remove from allowlistWP07[D]
T039Migrate src/specify_cli/cli/commands/charter.py, charter_bundle.py, and upgrade/migrations/m_3_2_6_charter_bundle_v2.py to from charter.versioning import ...; remove from allowlist (or document as ≤ 2 exceptions per C-004)WP07[D]
T040Promote SchemaUtilities to src/kernel/schema_utils.py; migrate bulk_edit/occurrence_map.py; remove from allowlistWP07[D]
T041Add MissionTypeProfile Pydantic model + load_profile + resolve_governance in src/charter/mission_type_profiles.pyWP08
T042Ship src/doctrine/missions/software-dev/governance-profile.yaml mirroring today's software-dev-default selectionsWP08[D]
T043Ship src/doctrine/missions/documentation/governance-profile.yaml with documentation-flavoured defaultsWP08[D]
T044Ship src/doctrine/missions/research/governance-profile.yaml with minimal defaultsWP08[D]
T045Ship src/doctrine/missions/plan/governance-profile.yaml with minimal defaultsWP08[D]
T046Wire resolve_governance into the mission-context pipeline (read meta.json mission_type; union with project + org)WP08
T047Hard-fail on unknown mission_type with no project override; message names the unknown valueWP08
T048Add spec-kitty doctrine new <kind> <name> CLI command + --pack <path> flag in src/specify_cli/cli/commands/doctrine.pyWP09
T049Add spec-kitty doctrine validate <path> CLI command for project-layer validationWP09[D]
T050Extend spec-kitty doctor doctrine with a "Selections" section listing per-kind active artifacts + resolved pack sourceWP09[D]
T051Promote 10 glossary entries in glossary/contexts/doctrine.md from Status: candidate to Status: canonical (C-007); add user-doc note for missing-pack policy change (C-006)WP09[D]

Work Packages

WP01 — Schema extensions

Priority: P0 (everything depends on these schemas) Dependencies: none Enables: WP02, WP04, WP06, WP08, WP09

Extend DoctrineSelectionConfig with the 5 new selected_<kind> fields and OrgCharterPolicy with the 7 new required_<kind> fields. Add the new charter.activations module with ActivationEntry, vocabularies, and resolver. Extend _OPTIONAL_EMPTY_OMIT_KEYS for NFR-005 byte-stability.

ATDD turns green:

  • tests/architectural/test_artifact_selection_completeness.py — 3/3
  • tests/architectural/test_activation_registry_schema.py — 4/4 (import-level)

WP02 — Charter sync extensions

Priority: P0 (selection rendering needs extraction) Dependencies: WP01 Enables: WP04

Extend charter.extractor to read the 5 new selected_<kind> fields and the new top-level activations: block from charter.md. Round-trip through governance.yaml.

ATDD turns green:

  • tests/integration/test_user_doctrine_artifact_lifecycle.py::test_case_1_selected_styleguides_field_round_trips

WP03 — Charter facade modules

Priority: P1 (preparation for boundary migration) Dependencies: none (independent of schema work) Enables: WP07

Create the 6 re-export-only modules under src/charter/ per the facade table in plan §1.3.

ATDD turns green:

  • tests/architectural/test_charter_facades_reexport_doctrine.py (NEW — added by T016)
  • tests/architectural/test_layer_rules.py — 8/8 stays green

WP04 — Global selection rendering

Priority: P0 (Case 1 / Case 2 global selection happy path) Dependencies: WP02 Enables: WP05 (re-uses fetch stanza helper)

Add 5 new _render_selected_<kind> helpers in src/charter/context.py, wire them into build_charter_context, carry provenance.

ATDD turns green:

  • tests/integration/test_user_doctrine_artifact_lifecycle.py::test_case_1_project_styleguide_appears_in_implement_prompt

WP05 — Activation registry rendering + trigger registry

Priority: P0 (Case 1 step 5 — context-scoped activation) Dependencies: WP04 Enables: WP08

Add _render_activation_stanza helper, wire resolve_for_context into build_charter_context, populate _REGISTERED_TRIGGERS with the 15-token frozenset.

ATDD turns green:

  • tests/integration/test_user_doctrine_artifact_lifecycle.py::test_case_1_styleguide_render_includes_trigger_stanza
  • tests/architectural/test_trigger_registry_coverage.py — 2/2 (non-vacuous)

WP06 — Org-charter pre-fill union + collision + missing-pack policy

Priority: P0 (Case 2 end-to-end) Dependencies: WP01 Enables: WP09

Extend apply_org_charter_to_interview for all 7 new required_<kind> fields. Extend DoctrineLayerCollisionWarning to all 8 kinds. Implement FR-015 hard-fail policy.

ATDD turns green:

  • tests/integration/test_org_pack_artifact_lifecycle.py::test_case_2_org_pack_styleguide_appears_in_consumer_prompt
  • tests/integration/test_org_pack_artifact_lifecycle.py::test_case_2_required_styleguides_in_org_charter_pre_fills
  • tests/integration/test_org_pack_artifact_lifecycle.py::test_case_2_org_styleguide_collision_with_builtin_warns
  • tests/integration/test_org_pack_artifact_lifecycle.py::test_case_2_consumer_without_fetched_pack_fails_loudly

WP07 — Runtime → charter boundary migration

Priority: P0 (boundary ratchet must drop to ≤ 2 per C-004) Dependencies: WP03 Enables: nothing further

Migrate the 13 runtime files in the boundary allowlist to import from charter facades. Promote SchemaUtilities to kernel/. Scope: 13 migrate + 1 new = 14 paths touched, but the boundary-allowlist ratchet still counts only the 13.

ATDD turns green:

  • tests/architectural/test_runtime_charter_doctrine_boundary.py — allowlist drops from 13 to ≤ 2

WP08 — Mission-type governance profiles

Priority: P0 (Journey 4) Dependencies: WP04, WP05 Enables: WP09

Ship 4 governance-profile.yaml files, add the loader + resolver, hard-fail on unknown.

ATDD turns green:

  • tests/missions/test_mission_type_profile_resolution.py — 14/14

WP09 — Operator UX + glossary promotion

Priority: P1 (operator-facing, after the engine works) Dependencies: WP04, WP06 Enables: mission acceptance

Add doctrine new, doctrine validate, extended doctor doctrine Selections section. Promote 10 glossary entries to canonical. Update user docs for missing-pack policy change (C-006).

Acceptance gates:

  • New CLI commands have unit + integration tests
  • Glossary entries flip to Status: canonical
  • User docs call out the FR-015 behaviour change