specpro-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. specpro_cli/__init__.py +16 -0
  2. specpro_cli/assets/commands/specpro.analyze.md +1102 -0
  3. specpro_cli/assets/commands/specpro.checklist.md +335 -0
  4. specpro_cli/assets/commands/specpro.clarify.md +581 -0
  5. specpro_cli/assets/commands/specpro.constitution.md +488 -0
  6. specpro_cli/assets/commands/specpro.feature.md +115 -0
  7. specpro_cli/assets/commands/specpro.implement.md +1881 -0
  8. specpro_cli/assets/commands/specpro.manual-test.md +206 -0
  9. specpro_cli/assets/commands/specpro.plan.md +3284 -0
  10. specpro_cli/assets/commands/specpro.qc.md +1489 -0
  11. specpro_cli/assets/commands/specpro.scenarios.md +154 -0
  12. specpro_cli/assets/commands/specpro.specify.md +1449 -0
  13. specpro_cli/assets/commands/specpro.status.md +863 -0
  14. specpro_cli/assets/commands/specpro.tasks.md +1207 -0
  15. specpro_cli/assets/commands/specpro.test-implement.md +462 -0
  16. specpro_cli/assets/commands/specpro.test-plan.md +383 -0
  17. specpro_cli/assets/commands/specpro.user-manual.md +178 -0
  18. specpro_cli/assets/scripts/bash/check-anti-coupling.sh +293 -0
  19. specpro_cli/assets/scripts/bash/check-prerequisites.sh +176 -0
  20. specpro_cli/assets/scripts/bash/common.sh +88 -0
  21. specpro_cli/assets/scripts/bash/create-new-feature.sh +336 -0
  22. specpro_cli/assets/scripts/bash/qc-auto-fix.sh +121 -0
  23. specpro_cli/assets/scripts/bash/setup-plan.sh +60 -0
  24. specpro_cli/assets/scripts/bash/verify-cumulative-records.sh +203 -0
  25. specpro_cli/assets/scripts/bash/verify-deliverables-tracked.sh +147 -0
  26. specpro_cli/assets/scripts/bash/verify-deployment.sh +239 -0
  27. specpro_cli/assets/scripts/bash/verify-frontmatter-yaml.sh +63 -0
  28. specpro_cli/assets/scripts/bash/verify-ledger.sh +376 -0
  29. specpro_cli/assets/scripts/bash/verify-shapes.sh +1082 -0
  30. specpro_cli/assets/scripts/git-hooks/pre-commit +243 -0
  31. specpro_cli/assets/scripts/install-git-hooks.sh +67 -0
  32. specpro_cli/assets/scripts/powershell/check-anti-coupling.ps1 +249 -0
  33. specpro_cli/assets/scripts/powershell/check-prerequisites.ps1 +148 -0
  34. specpro_cli/assets/scripts/powershell/common.ps1 +95 -0
  35. specpro_cli/assets/scripts/powershell/create-new-feature.ps1 +229 -0
  36. specpro_cli/assets/scripts/powershell/qc-auto-fix.ps1 +110 -0
  37. specpro_cli/assets/scripts/powershell/setup-plan.ps1 +61 -0
  38. specpro_cli/assets/scripts/powershell/verify-cumulative-records.ps1 +133 -0
  39. specpro_cli/assets/scripts/powershell/verify-deliverables-tracked.ps1 +112 -0
  40. specpro_cli/assets/scripts/powershell/verify-deployment.ps1 +278 -0
  41. specpro_cli/assets/scripts/powershell/verify-frontmatter-yaml.ps1 +56 -0
  42. specpro_cli/assets/scripts/powershell/verify-ledger.ps1 +383 -0
  43. specpro_cli/assets/scripts/powershell/verify-shapes.ps1 +978 -0
  44. specpro_cli/assets/templates/agent-context-template.md +49 -0
  45. specpro_cli/assets/templates/assumptions-template.md +248 -0
  46. specpro_cli/assets/templates/checklist-template.md +40 -0
  47. specpro_cli/assets/templates/clarifications-template.md +155 -0
  48. specpro_cli/assets/templates/constitution-template.md +50 -0
  49. specpro_cli/assets/templates/feature-spec-template.md +66 -0
  50. specpro_cli/assets/templates/plan-overview-template.md +150 -0
  51. specpro_cli/assets/templates/plan-template.md +387 -0
  52. specpro_cli/assets/templates/protocol-golden-bytes-guide.md +195 -0
  53. specpro_cli/assets/templates/requirements-template.md +356 -0
  54. specpro_cli/assets/templates/spec-template.md +267 -0
  55. specpro_cli/assets/templates/tasks-template.md +252 -0
  56. specpro_cli/assets/templates/test-tasks-template.md +174 -0
  57. specpro_cli/cli/__init__.py +5 -0
  58. specpro_cli/cli/cmd_init.py +416 -0
  59. specpro_cli/cli/cmd_remove.py +122 -0
  60. specpro_cli/cli/entry.py +181 -0
  61. specpro_cli/integrations/__init__.py +36 -0
  62. specpro_cli/integrations/base.py +601 -0
  63. specpro_cli/integrations/claude/__init__.py +101 -0
  64. specpro_cli/integrations/copilot/__init__.py +153 -0
  65. specpro_cli/integrations/cursor_agent/__init__.py +51 -0
  66. specpro_cli/integrations/gemini/__init__.py +44 -0
  67. specpro_cli/integrations/opencode/__init__.py +48 -0
  68. specpro_cli/integrations/qodercli/__init__.py +54 -0
  69. specpro_cli/integrations/registry.py +88 -0
  70. specpro_cli/packaged/__init__.py +5 -0
  71. specpro_cli/packaged/sync.py +106 -0
  72. specpro_cli-0.1.0.dist-info/METADATA +117 -0
  73. specpro_cli-0.1.0.dist-info/RECORD +76 -0
  74. specpro_cli-0.1.0.dist-info/WHEEL +4 -0
  75. specpro_cli-0.1.0.dist-info/entry_points.txt +2 -0
  76. specpro_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,150 @@
1
+ # Implementation Plan Template (Human-Read)
2
+
3
+ **Filled by**: `/specpro-plan`. Filename: `specs/plan-overview.md`.
4
+ **Companion**: `plan-template.md` — the machine-read half, written to `specs/plan.md`.
5
+
6
+ > **This file is the human-read half.** For people; *sufficient useful information is enough.*
7
+ > **No command reads it** — and **no command may reference its section names** (`/specpro-implement` loads only from `plan.md`, and never this file). Keeping the two halves in separate files is what makes "implement does not read the human half" a structural fact rather than a convention.
8
+ > **Every section MUST open with a one-line `*Purpose · Consumers*` note** — for these sections the consumer will normally be "humans"; write that plainly rather than inventing a machine consumer. No status bits, no checkboxes.
9
+
10
+ ---
11
+
12
+ > No machine consumers in this part. **Sufficient useful information is enough.** No status bits, no checkboxes.
13
+
14
+ ## Summary
15
+
16
+ *Purpose: an orientation for a human reader — what this is and how it will be built · Consumers: **humans***
17
+
18
+ [Extract from feature spec: primary requirement + technical approach from research]
19
+
20
+ ## System Overview
21
+
22
+ *Purpose: the runtime component-stack view, for a human reader · Consumers: **humans***
23
+
24
+ > **View semantics**: this is the **runtime component stack** view. The Part I `## Architecture → ### Layered Architecture` is the **source-set ownership** view. They answer different questions and MUST NOT be applied to each other.
25
+
26
+ [Provide high-level architecture diagram or description. Example:]
27
+
28
+ ```
29
+ [Layer/Component architecture showing major subsystems and their relationships]
30
+ ```
31
+
32
+ **Architecture Summary**: [2-3 sentences describing core architecture pattern (e.g., microkernel + plugins, layered, microservices)]
33
+
34
+ ## Constitution Check
35
+
36
+ *Purpose: the gate record — which principles the design satisfies, and which gaps are tracked · Consumers: **humans** (the FR-level risk list is NOT here — it lives in Part I `Quality Targets → Risk Classification`, which is what `tasks` §4.j-2 reads)*
37
+
38
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
39
+ *See: Step 4.0: Constitution Gate Evaluation, Step 4.1: Re-evaluate Constitution Check*
40
+
41
+ [Gates determined based on constitution file — one row per principle: status (PASS / PARTIAL / FAIL) + what it rests on. State explicitly when a principle is satisfied **at the design level** but has a tracked **integration-level** gap.]
42
+
43
+ ## Implementation Plan
44
+
45
+ *Purpose: human-readable plan information — the schedule, milestones, risks, and the per-phase acceptance criteria with their judges · Consumers: **humans** (no command reads this section; `user-manual` is explicitly forbidden from sourcing it)*
46
+
47
+ > **Currency**: the estimates, milestones and risks below are **point-in-time judgements**, not current progress. Authoritative progress is the `tasks.md` Task Summary; pending issues are in `implement_issues.md`.
48
+
49
+ ### Phase Overview
50
+
51
+ *Purpose: phases with goals, deliverables, estimates and dependencies · Consumers: humans*
52
+
53
+ [Define major development phases with goals, deliverables, and dependencies]
54
+
55
+ | Phase | Name | Goal | Key Deliverables | Estimate | Dependencies |
56
+ |-------|------|------|------------------|----------|--------------|
57
+ | 0 | [Name] | [Primary objective] | [Major outputs] | [Weeks] | [What must come first] |
58
+ | 1 | [Name] | [As above] | [As above] | [As above] | [As above] |
59
+ | 2 | [Name] | [As above] | [As above] | [As above] | [As above] |
60
+
61
+ **Total Estimate**: [Sum of estimates] weeks
62
+
63
+ ### Phase Acceptance Criteria and Judges
64
+
65
+ *Purpose: each acceptance criterion names its JUDGE; the judge holds the state in its own artifact · Consumers: humans (the criteria's authority — `implement`/`test-plan` judge from their own artifacts, not from this table)*
66
+
67
+ > **This replaces the old per-phase checkbox lists.** A criterion is **not** a status bit: it carries **no checkbox**, and **every criterion MUST name its JUDGE** — the command or role that decides it. The judge holds the state in its own artifact; **this file does not carry acceptance state**.
68
+ >
69
+ > **Do not write a criterion that has no judge.** If you cannot name who decides it, the criterion is not yet a criterion — it is a gap. Record it as such (a `[plan]` issue) rather than leaving an unjudgeable line here.
70
+
71
+ | Phase | Criterion | Judge | State lives in |
72
+ |-------|-----------|-------|----------------|
73
+ | [N] | [what must hold] | [`/specpro-implement` coverage acceptance · `/specpro-test-plan` → `test-implement` · `/specpro-plan` own step · **TBD**] | [artifact] |
74
+
75
+ ### Key Activities
76
+
77
+ *Purpose: what happens in each phase, as an activity description · Consumers: humans*
78
+
79
+ [Numbered list of what happens in each phase. **No checkboxes** — this is an activity description, not a task queue. Do NOT use the `[x]/[ ]` of any deliverable to decide what to skip: activity gating is decided by the `lifecycle_cache` FR state, not by anything in this file.]
80
+
81
+ ### Dependencies and Critical Path
82
+
83
+ *Purpose: the phase dependency graph and the critical path · Consumers: humans*
84
+
85
+ [Visual dependency graph or table]
86
+
87
+ ```
88
+ [Dependency graph showing phase relationships and critical path]
89
+ ```
90
+
91
+ **Critical Path**: [The sequence of phases that determines minimum project duration]
92
+
93
+ **Critical Path Duration**: [Weeks]
94
+
95
+ **Parallel Opportunities**: [Phases that can run in parallel]
96
+
97
+ ### Risk Management
98
+
99
+ *Purpose: point-in-time risk judgement and mitigations · Consumers: humans*
100
+
101
+ #### Technical Risks
102
+ | Risk | Probability | Impact | Mitigation |
103
+ |------|-------------|--------|------------|
104
+ | [Risk description] | [High/Med/Low] | [Severity] | [Action to reduce risk] |
105
+
106
+ #### Project Risks
107
+ [As above for project-level risks]
108
+
109
+ #### Quality Risks
110
+ [As above for quality risks]
111
+
112
+ ### Milestones
113
+
114
+ *Purpose: the timeline view — milestones, targets and deliverables (criteria are pointed at, not restated) · Consumers: humans*
115
+
116
+ | Milestone | Target | Deliverables | Criteria (pointer) |
117
+ |-----------|--------|--------------|--------------------|
118
+ | [Milestone 1] | [Date/Phase] | [What's delivered] | See "Phase Acceptance Criteria and Judges" · Phase [N] |
119
+ | [Milestone 2] | [As above] | [As above] | [As above] |
120
+
121
+ > **Do not restate the criteria here.** Their single authority is the **Phase Acceptance Criteria and Judges** table above — which also names each criterion's judge. This section keeps the **timeline** and the deliverables; duplicating criteria here creates a second copy with no judge attached, and the two drift.
122
+
123
+ ## Documentation Layout
124
+
125
+ *Purpose: where this feature's documentation artifacts land — a human navigation aid · Consumers: humans — `tasks`' Location grounding covers code and test paths only, it does not read this section; **the authoritative list is whatever `specs/` actually contains** (this is a point-in-time expectation, not kept in sync with later additions)*
126
+
127
+ ```text
128
+ specs/
129
+ ├── spec.md # Feature specification
130
+ ├── plan.md # This file (/specpro-plan command output)
131
+ ├── research.md # Phase 0 output - Technology decisions
132
+ ├── data-model.md # Phase 1 output - Core entities
133
+ ├── scenarios.md # Phase 1 output (initial run only) - Acceptance test scenarios; refresh with /specpro-scenarios
134
+ ├── quickstart.md # Phase 1 output - Developer quickstart guide
135
+ ├── contracts/ # Phase 1 output - API contracts
136
+ └── tasks.md # Phase 2 output (/specpro-tasks command - NOT created by /specpro-plan)
137
+ ```
138
+
139
+ ## Complexity Tracking
140
+
141
+ *Purpose: the justification record for design complexity — constitutional violations **and** architectural decisions that rejected a simpler alternative · Consumers: **humans** (this is also where a technology/architecture change is recorded — see the change-propagation rule in `/specpro-plan`)*
142
+
143
+ > **Fill when there is a constitutional violation to justify, OR a design decision that rejected a simpler alternative.** The section name is deliberately wider than "violations": a decision to take the more complex route belongs here too, because the question it answers is the same — *why wasn't the simpler alternative enough?*
144
+ >
145
+ > **No violations and no such decision** → omit the section, or write `Not applicable`.
146
+
147
+ | Violation / Decision | Why Needed | Simpler Alternative Rejected Because |
148
+ |----------------------|------------|--------------------------------------|
149
+ | [e.g., 4th project] | [current need] | [why 3 projects insufficient] |
150
+ | [e.g., Repository pattern] | [specific problem] | [why direct DB access insufficient] |
@@ -0,0 +1,387 @@
1
+ # Implementation Plan Template (Machine-Read)
2
+
3
+ **Filled by**: `/specpro-plan`. Filename: `specs/plan.md`.
4
+ **Companion**: `plan-overview-template.md` — the human-read half, written to `specs/plan-overview.md`.
5
+
6
+ > **This file is the machine-read half.** Downstream specpro commands extract from it **by section**; it MUST be mechanically parseable. **No task checkboxes, no progress status, no decision narrative.**
7
+ > **Every section MUST open with a one-line `*Purpose · Consumers*` note** — name the command and the step, say what is done with it, and cover **sub-sections too** (the per-subsection extractions read them). If a section has no machine consumer it belongs in the companion file, not here.
8
+ > Anything "to be done" MUST carry an FR anchor or live in a task queue (`tasks.md` / `test-tasks.md` / `fix-tasks.md`) — **never here**.
9
+
10
+ ---
11
+
12
+ ## Technical Context
13
+
14
+ *Purpose: fix the tech stack and platform boundary so downstream can generate scaffolding and ground file paths · Consumers: `tasks` (§4.a extraction · Location grounding) · `implement` (§7.a load) · `qc` (terminology list) · `user-manual` (leakage scan) · `analyze` (Target Platform tier claims)*
15
+
16
+ <!--
17
+ ACTION REQUIRED: Replace the content in this section with the technical details
18
+ for the project. The structure here is presented in advisory capacity to guide
19
+ the iteration process.
20
+ -->
21
+
22
+ **Language/Version**: [e.g., Python 3.11, Swift 5.9, Rust 1.75 or NEEDS CLARIFICATION]
23
+ - **Key Features**: [Key capabilities of this language, e.g., "Type-safe nullability, first-class coroutines"]
24
+ - **See**: research.md Section: [Language section name] (if detailed analysis exists)
25
+
26
+ **Primary Dependencies**: [e.g., FastAPI, UIKit, LLVM or NEEDS CLARIFICATION]
27
+ - **Key Features**: [List 2-4 key capabilities for each major dependency]
28
+ * [Dependency 1]: [Key capability 1], [Key capability 2]
29
+ * [Dependency 2]: [Key capability 1], [Key capability 2]
30
+ - **See**: research.md Section: [Dependency section name] (if detailed analysis exists)
31
+
32
+ **Storage**: [if applicable, e.g., PostgreSQL, CoreData, files or N/A]
33
+ - **Key Features**: [Key capabilities if applicable]
34
+ - **See**: research.md Section: [Storage section name] (if detailed analysis exists)
35
+
36
+ **Testing**: [e.g., pytest, XCTest, cargo test or NEEDS CLARIFICATION]
37
+ - **Key Features**: [Key testing capabilities if applicable]
38
+ - **See**: research.md Section: [Testing section name] (if detailed analysis exists)
39
+
40
+ **Target Platform**: [e.g., Linux server, iOS 15+, WASM or NEEDS CLARIFICATION]
41
+ **Project Type**: [single/web/mobile - determines source structure]
42
+ **Performance Goals**: [domain-specific, e.g., 1000 req/s, 10k lines/sec, 60 fps or NEEDS CLARIFICATION]
43
+ **Constraints**: [domain-specific, e.g., <200ms p95, <100MB memory, offline-capable or NEEDS CLARIFICATION]
44
+ **Scale/Scope**: [domain-specific, e.g., 10k users, 1M LOC, 50 screens or NEEDS CLARIFICATION]
45
+
46
+ ## Quality Targets
47
+
48
+ *Purpose: the project's quality thresholds — what downstream reads to generate test tasks and judge coverage · Consumers: `tasks` (§4.j-1 coverage numbers · §4.j-2 FR risk classification) · `implement` (§14 coverage acceptance — **authoritative**) · `test-plan` (layer-assignment aggressiveness)*
49
+
50
+ ### Project Type Classification
51
+
52
+ *Purpose: state which project class this is — it selects the coverage tier · Consumers: `tasks` §4.j-1*
53
+
54
+ **Project Type**: [MVP / Personal Application / Enterprise Application / Platform Application / Financial Application / Medical Application]
55
+
56
+ **Rationale**:
57
+ - [Why this project type was chosen]
58
+ - [Impact of bugs/failures on users]
59
+ - [Stability and reliability requirements]
60
+
61
+ **Impact on Quality Standards**:
62
+ - [How project type influences coverage targets]
63
+ - [Trade-offs between velocity and quality]
64
+
65
+ ### Risk-Based Coverage Targets
66
+
67
+ *Purpose: the coverage thresholds and test approach per risk level (the number source) · Consumers: `tasks` §4.j-1 · `implement` §14 (authoritative acceptance threshold) · `test-plan`*
68
+
69
+ | Risk Level | Coverage Target | Test Approach | Example Modules |
70
+ |------------|----------------|---------------|-----------------|
71
+ | **HIGH-RISK** | **>XX%** | MANDATORY | [List high-risk modules from Constitution Check] |
72
+ | **MEDIUM-RISK** | **>YY%** | RECOMMENDED | [List medium-risk modules] |
73
+ | **LOW-RISK** | **Optional** | Manual testing acceptable | [List low-risk modules] |
74
+
75
+ **Coverage Target Selection Guide** — ⚠️ **the numbers are NOT restated here** (`T242` / `ISS-215`):
76
+
77
+ - **Where the defaults come from**: the constitution's **Quality Assurance Matrix** (one row per project type). That matrix is the **single source**; `/specpro-constitution` computes the project's targets from it.
78
+ - **What this stage does**: `/specpro-plan` **classifies the project's modules** by risk level, then **copies that project's targets** from the constitution into the table above (replacing `>XX%` / `>YY%`).
79
+ - ⇒ Fill the table from `specs/constitution.md`; **do not fill it from a list here.**
80
+
81
+ ⚠️ This block used to carry its own six-row list of percentages, and the two lists had **already diverged in five of six rows** (e.g. Platform: 90/70/0 here vs 95/85/50 in the matrix) — the measured consequence of the same fact kept in two places. A second copy is not a convenience; it is a source that drifts without reporting.
82
+
83
+ ### Risk Classification
84
+
85
+ *Purpose: assign each FR to a risk level · Consumers: `tasks` §4.j-2 (per-FR classification) · §4.j-3 (risk annotation on generated tasks)*
86
+
87
+ > This subsection replaces the old `## Constitution Check → §IV` compliance list: the FR-level risk enumeration is a **machine input**, not a compliance statement, and it belongs next to the coverage table it pairs with.
88
+
89
+ | Risk level | Verification | FR list |
90
+ |------------|-----------|---------|
91
+ | **HIGH-RISK** | MANDATORY | [FR-xxx, FR-yyy …] |
92
+ | **MEDIUM-RISK** | RECOMMENDED | [FR-xxx …] |
93
+ | **LOW-RISK** | OPTIONAL | [FR-xxx …] |
94
+
95
+ **The `Verification` column's meaning** ⚠️ (`T153` / `ISS-74` — matched to the instantiated `plan.md`, which renames it for the reason below):
96
+
97
+ - **It is the *grade of the verification obligation*, and its content is the `Test Approach` column of the table above** — `MANDATORY` = every mechanism of that FR needs **one re-runnable verification** (preferring a verification script under `scripts/`, shipped with a fixture set; a hand-runnable command is the *floor*); `RECOMMENDED` / `OPTIONAL` step down the same way. **Do not restate the content here** — a second copy of the same fact diverges from its source without reporting (`FR-025`).
98
+ - ⚠️ **It does NOT mean ordering.** A verification of the form "does this artifact exist / is it consistent" is **runnable only after** the artifact exists, so a reader taking this column to mean *"test tasks come before implementation tasks"* holds a criterion that is **structurally unsatisfiable** in a project like this one.
99
+ - **Why the column was renamed** (it used to be `Test-First`): that term had **no definition** in the project, and a definition added alongside would be **skimmed past — a renamed column is not.**
100
+
101
+
102
+ - **HIGH-RISK** — protocol implementations · cryptography/security · network transport · critical data operations
103
+ - **MEDIUM-RISK** — business logic and service orchestration · data models and repositories · platform API bindings
104
+ - **LOW-RISK** — UI components · utilities and helpers · dev tools
105
+
106
+ ### Constitution Compliance
107
+
108
+ *Purpose: carry the written derivation chain "these targets come from Constitution Article IV" · Consumers: **cited as a premise, not read as a field** — `tasks` §4.j states its basis as "plan.md Quality Targets (which derive from Constitution Article IV)", and this subsection is that derivation; changing it changes the legitimacy of the downstream test tasks*
109
+
110
+ **Constitution Reference**: Article IV (Risk-Based Quality Assurance)
111
+
112
+ **Alignment**:
113
+ - ✅ Coverage targets proportional to module risk level
114
+ - ✅ HIGH-RISK modules: MANDATORY — every mechanism needs a re-runnable verification, with >XX% coverage where measurable
115
+ - ✅ MEDIUM-RISK modules: RECOMMENDED, with >YY% coverage where measurable
116
+ - ✅ LOW-RISK modules: Testing OPTIONAL (manual acceptable)
117
+
118
+ ### Quality Validation Strategy
119
+
120
+ *Purpose: how quality is measured and where the gates sit · Consumers: `implement` §14 (reads the whole `Quality Targets` section, this subsection included)*
121
+
122
+ **Per User Story Phase**:
123
+ - Generate test tasks based on FR risk level
124
+ - Annotate implementation tasks with risk level and coverage requirement
125
+ - Add quality checkpoint to verify coverage targets met
126
+
127
+ **Measurement**:
128
+ - Code coverage measured via [coverage tool: JaCoCo/Istanbul/Coverage.py]
129
+ - Scenario automation measured via test scenario count (target: 85-90% of scenarios)
130
+ - Both dimensions tracked independently
131
+
132
+ **Quality Gates**:
133
+ - HIGH-RISK FRs must achieve >XX% coverage before merge
134
+ - MEDIUM-RISK FRs recommended >YY% coverage before merge
135
+ - All tests must pass (unit, integration, contract)
136
+
137
+ ## Architecture
138
+
139
+ *Purpose: the source-set ownership view — which layer owns which code, what the constraints are, and the field/branch-level protocol spec · Consumers: `tasks` (§4.i-1..i-4 per-subsection task generation: patterns→component tasks · layers→expect/actual + constraint-validation tasks · interactions→mechanism tasks · constraints→`[Quality]` validation tasks) · `analyze` (Pass M boundary audit · Pass L protocol audit) · `implement` (architecture reference)*
140
+
141
+ > **View semantics**: this section is the **source-set ownership** view. The Part II `## System Overview` is the **runtime component-stack** view. They answer different questions and MUST NOT be applied to each other.
142
+
143
+ ### Layered Architecture
144
+
145
+ *Purpose: each layer's ownership, contents and MUST/MUST NOT constraints · Consumers: `tasks` §4.i-2 (per-layer expect/actual tasks + constraint-validation tasks)*
146
+
147
+ [Define the major layers and their responsibilities]
148
+
149
+ #### Layer 1: [Name] (e.g., Platform/Presentation Layer)
150
+ **Responsibilities**:
151
+ - [What this layer handles]
152
+ - [Key concerns]
153
+
154
+ **Contains**: [Specific components]
155
+
156
+ **Constraints**:
157
+ - ✅ [Must/Must not constraints]
158
+
159
+ #### Layer 2: [Name] (e.g., Business/Domain Layer)
160
+ **Responsibilities**: [As above]
161
+
162
+ **Contains**: [As above]
163
+
164
+ **Constraints**: [As above]
165
+
166
+ ### Component Interaction
167
+
168
+ *Purpose: the component interaction patterns and their constraints · Consumers: `tasks` §4.i-3 (per-pattern mechanism tasks + constraint-validation tasks)*
169
+
170
+ [Define how major components interact]
171
+
172
+ #### [Interaction Pattern] (e.g., Plugin → Core)
173
+ ```
174
+ [Flow diagram or sequence description]
175
+ ```
176
+
177
+ **Key Interaction**: [Description of the interaction pattern]
178
+
179
+ **Constraints**:
180
+ - ✅ [Must/Must not constraints]
181
+
182
+ ### Architecture Patterns
183
+
184
+ *Purpose: the architecture patterns and what each provides · Consumers: `tasks` §4.i-1 (per-pattern component tasks)*
185
+
186
+ [CRITICAL: Keep patterns concise - NO detailed Problem/Solution/Trade-offs. Those belong in research.md]
187
+
188
+ #### Pattern 1: [Pattern Name]
189
+ **Description**: [Brief description of the pattern]
190
+
191
+ **Key Points**:
192
+ - [What this pattern provides]
193
+ - [How it's used in the architecture]
194
+
195
+ **See**: research.md Section [X] for detailed analysis
196
+
197
+ #### Pattern 2: [Pattern Name]
198
+ **Description**: [Brief description]
199
+
200
+ **Key Points**:
201
+ - [What this pattern provides]
202
+ - [How it's used]
203
+
204
+ **See**: research.md Section [Y] for detailed analysis
205
+
206
+ ### Critical Constraints
207
+
208
+ *Purpose: the quantified architecture-level constraints and their impact · Consumers: `tasks` §4.i-4 (per-constraint `[Quality]` validation tasks)*
209
+
210
+ [Define architecture-level constraints that affect design]
211
+
212
+ #### Constraint 1: [Name]
213
+ **Requirement**: [Specific constraint with metrics]
214
+
215
+ **Architecture Impact**: [How this constraint shapes the architecture]
216
+
217
+ ### Shared/Platform Boundary Declaration [only when the constitution carries a shared-code / multiplatform / core-logic principle]
218
+
219
+ *Purpose: make the code-ownership boundary a checkable product — a layering diagram names layers but not the source set each layer OWNS · Consumers: `analyze` Pass M1–M4 (audits this table against the build's source-set registration)*
220
+
221
+ [State, per constitutional principle, which categories of code MUST live in the shared source set and which belong to platform-specific sets. This table is what makes the boundary auditable: a scope claimed without a corpus set or a path cannot be checked against the build.]
222
+
223
+ | Planned home | Constitutional basis | Category | Owning layer | Corpus set (mandatory shared set; platform sets that may extend it) | Path pattern |
224
+ |--------------|---------------------|----------|--------------|---------------------------------------------------------------------|--------------|
225
+ | [Name] | Principle [N] | protocol / business logic / data model / platform abstraction | shared / platform-specific | `commonMain`; platform sets: [list] | `core/src/commonMain/...` |
226
+
227
+ **Dependency boundary the shared layer MUST honour**: [What the shared layer must not depend on — e.g. a protocol layer must not depend on a transport-layer object such as a live socket, connection, or session holder. A handler taking one cannot be constructed without a real network, which forces every verification end-to-end.]
228
+
229
+ **Platform abstractions required**: [Capabilities the shared layer consumes from the platform — compression, image codec, file system, crypto — each declared as an expect/actual pair: declaration in the corpus set, implementations in the platform sets.]
230
+
231
+ ### Shared-Layer Relocation Design [only when the boundary declaration and the build disagree]
232
+
233
+ *Purpose: turn the boundary declaration above into an executable migration design — the declaration states where code MUST live; this states what to move, in what order, and what depends on it · Consumers: `analyze` (Pass M boundary audit) · `tasks` (the dispatch breakdown → `[Quality]` tasks)*
234
+
235
+ > **When this section is needed**: the declaration is the *intent*; a Pass M audit compares it against the build's actual source-set registration. When they disagree — shared-mandated code sitting in a platform-only source set, a handler whose construction requires a live transport object, a platform dialect imported into a shared file — the declaration alone says nothing about **how to get from here to there**. That gap is what this section fills. No disagreement → omit the section.
236
+
237
+ **Design decisions the declaration does not cover** — record them here as explicit rulings, each with its rejected alternative:
238
+ - **Dependency shape**: what a shared-layer component MUST NOT take as a construction dependency (e.g. a protocol handler must not take a live socket / connection / session holder — a handler that does cannot be constructed without a real network, which forces every verification end-to-end).
239
+ - **Platform abstractions**: the capabilities the shared layer consumes, each as an expect/actual pair.
240
+
241
+ **Migration plan**: the ordered steps, each stating what moves, from where to where, what depends on it, and how the move is verified.
242
+
243
+ **Rulings**: decisions taken along the way — a mechanism correction, a sunset condition, a dispatch resolution. Each records: what was decided · what was rejected · why · and the evidence.
244
+
245
+ **Dispatch breakdown**: which work items this design produces, for `/specpro-tasks` to turn into tasks. ⚠️ **The items here are NOT task IDs** — do not invent an ID prefix; `/specpro-tasks` assigns `T-nnn`. These items carry no FR in the usual sense (they are design-level work), so the FR-driven generation path does not apply to them.
246
+
247
+ ### Protocol Codec Design Artifacts [only when the Activation Gate is ACTIVE or ACTIVE-WITH-GAPS]
248
+
249
+ *Purpose: field/branch-level protocol spec + the activation verdict record — the anchor set the test matrix and the coverage audit are built from · Consumers: `tasks` (Protocol Codec Module Rules: each GAP row → explicit task or explicit deferral · each protocol point → the four-part matrix) · `implement` (reads the §6.4 verdict) · `analyze` (Pass L3 per-point coverage audit · Pass L6 verdict-and-anchor presence)*
250
+
251
+ **Verdict record (§6.4)**:
252
+
253
+ | Stage | Verdict | Trigger | Evidence | Artifacts / Gaps |
254
+ |-------|---------|---------|----------|------------------|
255
+ | [stage] | [ACTIVE / ACTIVE-WITH-GAPS / NOT-ACTIVE] | [T1..T5] | [code anchor + FR] | [inventory · anchors L1/L2/L3 · gaps] |
256
+
257
+ #### Protocol-Point Inventory — field/branch-level enumeration (§1)
258
+
259
+ | Protocol point | Semantics | Branches / boundaries | Anchor source | Coverage method |
260
+ |----------------|-----------|----------------------|---------------|-----------------|
261
+ | [point] | [what it means] | [branch table] | [L1/L2/L3 + version] | [matrix cases / property tests / incremental-context cases / environment annotations] |
262
+
263
+ > **One row per protocol point — granularity is the branch, not the message type.**
264
+ > **The last column states the coverage METHOD this point requires** (the testing *means* suited to its shape) — a design specification, fixed when the row is written. It is **NOT** a coverage status: which points are covered *right now* is a downstream fact (the actual test assets) and MUST NOT be recorded here — an upstream status has no way to stay current and downstream consumers would act on a stale value. **Unreachable anchor sources ARE recorded here**, as a GAP — that is a plan-layer fact.
265
+
266
+ #### Golden-Bytes Strategy — three-layer cross-anchoring (§2)
267
+
268
+ [L1 specification (structure) → L2 reference-implementation source (bit-level semantics) → L3 captured stream (final arbitration). Every anchor records its source layer and protocol version; when layers conflict, L3 wins and the corrected understanding is written back. A source that cannot be reached is a GAP (§6.3) — never an invented byte sequence.]
269
+
270
+ #### Test Matrix — codec-layer test infrastructure (§3)
271
+
272
+ *Purpose: the design decisions behind the systematic codec test matrix — the four-part shape, its admissibility rule, and where it lands · Consumers: `tasks` (Protocol Codec Module Rules — each protocol point maps to this matrix)*
273
+
274
+ **The four parts** (guide §3):
275
+ 1. **Decode matrix** — message/tile type × full-frame vs incremental context × parameters; assert byte-by-byte or pixel-by-pixel.
276
+ 2. **Encode reverse matrix** — `encoder(pixels) → bytes` against the golden anchor, byte by byte.
277
+ 3. **Shared golden-bytes fixture** — all anchors constructed in one place, shared by the encoder and decoder matrices so the two directions lock each other.
278
+ 4. **Property-test extension** — randomized content/length/colour count, **fixed seed**, and on failure the **parameters that reproduce it**.
279
+
280
+ **Error paths are part of the matrix** — truncated stream, invalid control byte, over-long run, out-of-range index: each MUST have a decided expected behaviour (reject vs tolerate). "Unspecified" is the shape of the next latent defect.
281
+
282
+ **Admissibility rule for anything promoted into the shared fixture** ⚠️: every anchor MUST first pass the three-layer check of §2 — it states its source layer (L1 specification / L2 reference implementation / L3 captured stream) and the protocol version, or it is recorded as a GAP (§6.3). **A constructor whose semantics were derived from the behaviour of the implementation under test MUST NOT be promoted**: generalising it copies the same misreading into both the encoder and the decoder side, so every assertion passes by construction (the self-confirming loop, §3.1).
283
+
284
+ **Why this subsection exists**: two byte-count defects in one project stayed latent for months precisely because no systematic matrix covered their tile-type × context × bpp combination — static full-frame tests naturally skip low-frequency paths.
285
+
286
+ #### Stream-Semantics Comparison — multi-encoder stream semantics (MANDATORY when one client speaks several encoders)
287
+
288
+ [Continuous single stream vs per-message independent stream. Its purpose is to stop a fix's lesson from being carried across codecs whose semantics are opposite.]
289
+
290
+ ## Project Structure
291
+
292
+ *Purpose: the repository-wide module layout — which kind of code lives in which module, so downstream task Locations can be grounded · Consumers: `tasks` (§4.j-4 Location grounding: the Location MUST point at the project's real test source set) · `implement` (§7.a)*
293
+
294
+ > **Granularity**: to the **directory and path-pattern** level. **MUST NOT enumerate individual file names** — file names are an implementation choice.
295
+ > **Single authority**: the shared/platform boundary lives in `### Shared/Platform Boundary Declaration` (the only authority — audited by Pass M). **This section records repository module layout only** and MUST NOT restate the boundary.
296
+ > **Currency**: this is the **point-in-time placement convention**; once implementation lands, the authoritative placement is the **build config and the actual repository**. Downstream Location grounding MUST check build config and existing sibling files first.
297
+
298
+
299
+ ### Source Code (repository root)
300
+
301
+ *Purpose: repository module layout — which kind of code lives in which module · Consumers: `tasks` §4.j-4 (Location grounding) · `implement` §7.a*
302
+ <!--
303
+ ACTION REQUIRED: Replace the placeholder tree below with the concrete layout
304
+ for this feature. Delete unused options and expand the chosen structure with
305
+ real paths (e.g., apps/admin, packages/something). The delivered plan must
306
+ not include Option labels.
307
+ -->
308
+
309
+ ```text
310
+ # [REMOVE IF UNUSED] Option 1: Single project (DEFAULT)
311
+ src/
312
+ ├── models/
313
+ ├── services/
314
+ ├── cli/
315
+ └── lib/
316
+
317
+ tests/
318
+ ├── contract/
319
+ ├── integration/
320
+ └── unit/
321
+
322
+ # [REMOVE IF UNUSED] Option 2: Web application (when "frontend" + "backend" detected)
323
+ backend/
324
+ ├── src/
325
+ │ ├── models/
326
+ │ ├── services/
327
+ │ └── api/
328
+ └── tests/
329
+
330
+ frontend/
331
+ ├── src/
332
+ │ ├── components/
333
+ │ ├── pages/
334
+ │ └── services/
335
+ └── tests/
336
+
337
+ # [REMOVE IF UNUSED] Option 3: Mobile + API (when "iOS/Android" detected)
338
+ api/
339
+ └── [same as backend above]
340
+
341
+ ios/ or android/
342
+ └── [platform-specific structure: feature modules, UI flows, platform tests]
343
+
344
+ # [REMOVE IF UNUSED] Option 4: Separated test modules (when test types need independent CI execution)
345
+ # Each tests/<type>-test/ is an independent build module registered in the workspace manifest.
346
+ # The tests/ parent build script holds shared test config (framework, logging, coverage)
347
+ # and provides a merged coverage report task.
348
+ tests/
349
+ ├── unit-test/ # fast, mock-based, run on every commit
350
+ ├── contract-test/ # API contract verification, run on every PR
351
+ ├── integration-test/ # component integration using mocks, CI-friendly (<30s per suite)
352
+ └── e2e-test/ # real external systems, may require containers, nightly runs
353
+
354
+ # Multi-target expansion of Option 4:
355
+ core/ # multi-target plugin module → per-target source sets
356
+ └── src/
357
+ ├── commonMain/kotlin/ # shared code
358
+ ├── commonTest/kotlin/ # shared tests (multi-target plugin ONLY)
359
+ └── jvmTest/kotlin/ # one target's tests (multi-target plugin ONLY)
360
+
361
+ tests/ # test modules use a plain single-target plugin → standard source sets
362
+ ├── unit-test/src/test/kotlin/ # ✅ src/test/kotlin (NOT src/jvmTest/kotlin —
363
+ │ # that source set only exists under the
364
+ │ # multi-target plugin; reusing it here →
365
+ │ # NO-SOURCE or build error)
366
+ ├── contract-test/src/test/kotlin/
367
+ ├── integration-test/src/test/kotlin/
368
+ └── e2e-test/src/test/kotlin/
369
+ ```
370
+
371
+ <!--
372
+ ⚠️ Test directory rules (from real build failures):
373
+ 1. Follow the build system's OWN standard source directory for each module's build type
374
+ (do NOT copy source-set names from sibling modules built with a different plugin type;
375
+ e.g., KMP modules use src/jvmTest/kotlin, plain JVM modules use src/test/kotlin)
376
+ 2. Register every test module in the workspace manifest (e.g., settings.gradle.kts
377
+ include(":tests:integration-test")), or it is invisible to the build
378
+ 3. Do not re-declare build plugin versions inside submodules
379
+ (e.g., kotlin("jvm") WITHOUT version — root already declares it)
380
+ 4. Do not mix test framework adapters of different engine generations in one module
381
+ (e.g., kotlin-test-junit + kotlin-test-junit5 together → capability conflict)
382
+ -->
383
+
384
+ **Structure Decision**: [Document the selected structure and reference the real
385
+ directories captured above]
386
+
387
+ ---