Tasks: Charter Delivery Finish and Context Degod

Mission: charter-delivery-finish-context-degod-01KYT4BY | Branch: feat/charter-delivery-finish-context-degod Planning base: feat/charter-delivery-finish-context-degod | Merge target: main (via PR)

Design authority: spec.md, plan.md, research.md, data-model.md, contracts/. Post-spec + post-plan squad evidence in notes/. Every WP is ATDD red-first (C-011) and reviewer ≠ implementer.

Sequencing (load-bearing — see research.md Decision 8/10)

WP01 (US2 prose) ─┐
WP02 (US1 route) ─┼─→ WP04 (US3 leaf+cycle+parity baseline) → WP05 (US3 render) → WP06 (US3 service+completion)
WP03 (US1 gov+asset, ← WP02) ─┘

WP01 and WP02 are independent (parallel). WP03 depends on WP02. The US3 parity baseline (WP04) is captured only after WP01+WP02+WP03 are approved, and includes the empty-charter input (provenance proof). context.py is owned solely by WP06; WP04/WP05 make declared coupled out-of-map edits to it (sequential chain — no parallel collision).

Subtask Index

IDDescriptionWPParallel
T001Red-first per-stanza grammaticality test (4 clause shapes)WP01
T002Normalize when clause into closed 6-verb set in fetch_stanza_linesWP01
T003Fold thin _render_fetch_stanza wrapper into fetch_stanza.pyWP01
T004Per-stanza assertion helper wired into contract testWP01
T005Verify byte-unchanged good path; ruff+mypyWP01
T006Red-first predicate truth-table + decision-shape testWP02
T007empty_charter.py::resolve_generic_fallback (composite predicate)WP02
T008Wire executor auto-route branch + empty_charter_fallback payload flagWP02
T009Widen RouterDecision.confidence LiteralWP02
T010One-shot empty-charter warning in dispatch.py (getattr-safe)WP02
T011Dispatch test: routing→generic-agent, --json, explicit-profile bypass, software-devWP02
T012Red-first governance-agreement test (Directive IDs block empty)WP03
T013Empty-charter governance scoping (suppress project resolver on fallback)WP03
T014Ship charter_scaffold_minimal.yml + .asset.yaml sidecarWP03
T015Asset mime guard + resolvability testWP03
T016Asset activatability test (temp repo, user charter untouched)WP03
T017Capture non-trivial parity baseline (token-budget + miss + first-load) post-US1WP04
T018Extract catalog_diagnosis.py (leaf)WP04
T019Consolidate token_budget.py (_budget_estimate, limit, _enforce_token_budget)WP04
T020Consolidate reference_pointers.py + new charter_md_parsing.pyWP04
T021New artifact_bodies.py + context_state.pyWP04
T022Dissolve profile_sections import cycle (top-level imports, drop noqa)WP04
T023Verify parity green + seam unit tests + ruff/mypyWP04
T024Extract template_include.pyWP05
T025Extract selection_block.pyWP05
T026Extract activation_block.pyWP05
T027Extract bootstrap_text.py + compact_governance.pyWP05
T028FR-009 shim updates + parity green + seam testsWP05
T029Extract context_json.py + org_pack_discovery.py + action_doctrine_bundle.pyWP06
T030Extract profile_resolution.py (caches + _reset_agent_profile_cache)WP06
T031Extract doctrine_service_builder.py (US1-frozen region)WP06
T032Thin context.py to residual + FR-009 re-export block + FR-007 noteWP06
T033Wire completion test (seam manifest + LOC ≤600); verify all gates greenWP06

WP01 — US2: fetch-stanza when-clause prose (#3082)

Priority: P2 · Prompt: tasks/WP01-fetch-stanza-prose.md · ~300 lines · Deps: none Goal: Make every generated When you … disclosure line grammatical across all clause shapes while keeping the closed-6-verb prompt-governance contract green (per-stanza). Independent test: Feed gerund / full-sentence / STATED_DEFAULT_WHEN / well-formed clauses → each emitted stanza grammatical AND matches _WHEN_DOING_RE/_FETCH_CMD_RE. Subtasks: T001 T002 T003 T004 T005 · Requirements: FR-001, NFR-003

WP02 — US1: empty-charter routing fallback + warning (#3064)

Priority: P1 · Prompt: tasks/WP02-empty-charter-routing.md · ~420 lines · Deps: none Goal: Auto-route dispatch under a wholly-empty charter to the generic-agent (composite predicate) with a one-shot warning, without touching the shared gate/ProfileRegistry. Independent test: empty charter + no --profilegeneric-agent + warning + --json flag; explicit --profile bypasses; any activation → no fallback. Subtasks: T006 T007 T008 T009 T010 T011 · Requirements: FR-002, FR-003, FR-004, FR-006

WP03 — US1: empty-charter governance scoping + default charter asset (#3064)

Priority: P1 · Prompt: tasks/WP03-governance-scoping-and-asset.md · ~360 lines · Deps: WP02 Goal: Ensure the empty-charter dispatch governance block leaks no doctrine (suppress the project catalog-fallback directives), and ship the minimal charter scaffold asset. Independent test: empty-charter dispatch Directive IDs: block empty; doctrine asset path common-charter-scaffold-minimal resolves + activates to a valid charter without touching a user charter. Subtasks: T012 T013 T014 T015 T016 · Requirements: FR-010, FR-005

WP04 — US3: context.py leaf/pure extraction + cycle dissolution + parity baseline (#2532)

Priority: P3 · Prompt: tasks/WP04-context-leaf-extraction.md · ~480 lines · Deps: WP01, WP02, WP03 Goal: Capture the non-trivial parity baseline, extract the low-risk pure/leaf seams, and dissolve the profile_sections import cycle — byte-parity preserved. Independent test: parity fixture (token-budget + miss + first-load) byte-identical; cycle dissolved (no noqa: PLC0415); seam unit tests green. Subtasks: T017 T018 T019 T020 T021 T022 T023 · Requirements: FR-007, FR-008, FR-009, NFR-001

WP05 — US3: context.py render-seam extraction (#2532)

Priority: P3 · Prompt: tasks/WP05-context-render-extraction.md · ~420 lines · Deps: WP04 Goal: Extract the render seams (template-include, selection-block, activation-block, bootstrap-text, compact-governance) — byte-parity preserved. Independent test: parity fixture byte-identical; each new render module has focused unit tests. Subtasks: T024 T025 T026 T027 T028 · Requirements: FR-008, FR-009

WP06 — US3: context.py service extraction + residual + completion (#2532)

Priority: P3 · Prompt: tasks/WP06-context-service-and-completion.md · ~460 lines · Deps: WP05 Goal: Extract the service/profile-resolution seams (LAST — US1-frozen region), thin context.py to residual orchestration, and wire the non-fakeable completion test. Independent test: test_context_decomposition_completion.py (seam manifest + wc -l ≤ 600) green; layer-rule/__all__/dead-symbol/parity all green. Subtasks: T029 T030 T031 T032 T033 · Requirements: FR-007, FR-008, FR-009, NFR-001, NFR-002, NFR-005


MVP

WP01 + WP02 (each independently shippable, no deps) deliver the two highest-value user-visible slices (grammatical guidance + governed empty-charter dispatch). WP03 completes US1. WP04→WP06 pay down the context.py god-module last.