agentic-orchestrator 0.1.4 → 0.1.6

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 (108) hide show
  1. package/.claude/settings.local.json +6 -1
  2. package/README.md +81 -54
  3. package/agentic/orchestrator/defaults/policy.defaults.yaml +212 -0
  4. package/agentic/orchestrator/schemas/adapters.schema.json +17 -4
  5. package/agentic/orchestrator/schemas/agents.schema.json +58 -13
  6. package/agentic/orchestrator/schemas/gates.schema.json +88 -17
  7. package/agentic/orchestrator/schemas/index.schema.json +172 -37
  8. package/agentic/orchestrator/schemas/multi-project.schema.json +85 -17
  9. package/agentic/orchestrator/schemas/plan.schema.json +135 -30
  10. package/agentic/orchestrator/schemas/policy.schema.json +198 -69
  11. package/agentic/orchestrator/schemas/policy.user.schema.json +165 -0
  12. package/agentic/orchestrator/schemas/qa_test_index.schema.json +71 -14
  13. package/agentic/orchestrator/schemas/state.schema.json +196 -39
  14. package/apps/control-plane/scripts/validate-architecture-rules.mjs +5 -3
  15. package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +0 -3
  16. package/apps/control-plane/scripts/validate-mcp-contracts.ts +2 -6
  17. package/apps/control-plane/src/application/services/policy-loader-service.ts +115 -0
  18. package/apps/control-plane/src/cli/aop.ts +35 -1
  19. package/apps/control-plane/src/cli/cli-argument-parser.ts +4 -0
  20. package/apps/control-plane/src/cli/help-command-handler.ts +2 -1
  21. package/apps/control-plane/src/cli/init-command-handler.ts +136 -27
  22. package/apps/control-plane/src/cli/retry-command-handler.ts +3 -6
  23. package/apps/control-plane/src/cli/types.ts +1 -0
  24. package/apps/control-plane/src/core/git.ts +1 -3
  25. package/apps/control-plane/src/core/kernel.ts +3 -6
  26. package/apps/control-plane/src/core/schemas.ts +36 -1
  27. package/apps/control-plane/src/interfaces/cli/bootstrap.ts +1 -1
  28. package/apps/control-plane/src/mcp/tool-registry-loader.ts +37 -1
  29. package/apps/control-plane/src/supervisor/qa-wave-executor.ts +1 -1
  30. package/apps/control-plane/test/aop.spec.ts +37 -0
  31. package/apps/control-plane/test/batch-operations.spec.ts +5 -3
  32. package/apps/control-plane/test/bootstrap-attach.spec.ts +28 -18
  33. package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +25 -15
  34. package/apps/control-plane/test/bootstrap.spec.ts +30 -22
  35. package/apps/control-plane/test/cli.unit.spec.ts +55 -10
  36. package/apps/control-plane/test/core-utils.spec.ts +12 -3
  37. package/apps/control-plane/test/feature-deletion-service.spec.ts +2 -1
  38. package/apps/control-plane/test/feature-lifecycle.spec.ts +1 -1
  39. package/apps/control-plane/test/helpers.ts +22 -2
  40. package/apps/control-plane/test/init-wizard.spec.ts +160 -7
  41. package/apps/control-plane/test/issue-tracker.spec.ts +3 -3
  42. package/apps/control-plane/test/kernel.spec.ts +62 -0
  43. package/apps/control-plane/test/lock-service.spec.ts +4 -4
  44. package/apps/control-plane/test/policy-loader-service.spec.ts +346 -0
  45. package/apps/control-plane/test/reactions.spec.ts +8 -6
  46. package/apps/control-plane/test/resume-command.spec.ts +31 -15
  47. package/apps/control-plane/test/supervisor.unit.spec.ts +2 -2
  48. package/apps/control-plane/test/tool-registry-loader.spec.ts +12 -0
  49. package/apps/control-plane/vitest.config.ts +1 -1
  50. package/dist/apps/control-plane/application/services/policy-loader-service.d.ts +24 -0
  51. package/dist/apps/control-plane/application/services/policy-loader-service.js +90 -0
  52. package/dist/apps/control-plane/application/services/policy-loader-service.js.map +1 -0
  53. package/dist/apps/control-plane/application/tools/tool-metadata.js +1 -0
  54. package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -1
  55. package/dist/apps/control-plane/cli/aop.js +33 -1
  56. package/dist/apps/control-plane/cli/aop.js.map +1 -1
  57. package/dist/apps/control-plane/cli/cli-argument-parser.js +4 -0
  58. package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
  59. package/dist/apps/control-plane/cli/dashboard-command-handler.js +11 -5
  60. package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -1
  61. package/dist/apps/control-plane/cli/help-command-handler.js +5 -4
  62. package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -1
  63. package/dist/apps/control-plane/cli/init-command-handler.d.ts +1 -0
  64. package/dist/apps/control-plane/cli/init-command-handler.js +110 -26
  65. package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -1
  66. package/dist/apps/control-plane/cli/retry-command-handler.js +3 -6
  67. package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -1
  68. package/dist/apps/control-plane/cli/types.d.ts +1 -0
  69. package/dist/apps/control-plane/core/git.js +1 -3
  70. package/dist/apps/control-plane/core/git.js.map +1 -1
  71. package/dist/apps/control-plane/core/kernel.js +3 -5
  72. package/dist/apps/control-plane/core/kernel.js.map +1 -1
  73. package/dist/apps/control-plane/core/schemas.d.ts +2 -0
  74. package/dist/apps/control-plane/core/schemas.js +31 -1
  75. package/dist/apps/control-plane/core/schemas.js.map +1 -1
  76. package/dist/apps/control-plane/interfaces/cli/bootstrap.js +1 -1
  77. package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
  78. package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +2 -0
  79. package/dist/apps/control-plane/mcp/tool-registry-loader.js +31 -1
  80. package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -1
  81. package/dist/apps/control-plane/supervisor/build-wave-executor.js +1 -1
  82. package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
  83. package/dist/apps/control-plane/supervisor/qa-wave-executor.js +1 -1
  84. package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
  85. package/package.json +18 -17
  86. package/packages/web-dashboard/package.json +1 -1
  87. package/packages/web-dashboard/src/app/api/actions/route.ts +2 -2
  88. package/packages/web-dashboard/src/app/api/events/route.ts +1 -1
  89. package/packages/web-dashboard/src/app/api/features/[id]/checkout/route.ts +1 -1
  90. package/packages/web-dashboard/src/app/api/features/[id]/diff/route.ts +1 -1
  91. package/packages/web-dashboard/src/app/api/features/[id]/evidence/[artifact]/route.ts +1 -1
  92. package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +2 -2
  93. package/packages/web-dashboard/src/app/api/features/[id]/route.ts +1 -1
  94. package/packages/web-dashboard/src/app/api/projects/route.ts +2 -2
  95. package/packages/web-dashboard/src/app/api/status/route.ts +1 -1
  96. package/packages/web-dashboard/src/app/page.tsx +1 -1
  97. package/packages/web-dashboard/src/lib/aop-client.ts +1 -1
  98. package/packages/web-dashboard/src/lib/orchestrator-tools.ts +1 -1
  99. package/packages/web-dashboard/tsconfig.json +1 -0
  100. package/spec-files/completed/agentic_orchestrator_init_policy_ux_simplification_spec.md +481 -0
  101. package/spec-files/outstanding/agentic_orchestrator_artifact_database_publishing_spec.md +500 -0
  102. package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +500 -195
  103. package/spec-files/outstanding/agentic_orchestrator_performance_improvements_spec.md +471 -162
  104. package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +532 -268
  105. package/spec-files/outstanding/agentic_orchestrator_productization_commercial_spec.md +645 -0
  106. package/spec-files/progress.md +99 -2
  107. package/tsconfig.base.json +4 -0
  108. /package/spec-files/{outstanding → completed}/agentic_orchestrator_validator_hardening_spec.md +0 -0
@@ -1,25 +1,50 @@
1
1
  # Feature Spec: Planning and Review Quality Hardening (AOP)
2
2
 
3
- > **Purpose of this document**: Define implementation-ready delivery for Q1, Q2, Q7, Q8, and Q9: semantic collision detection, feasibility scoring, prompt contract tests, flaky gate intelligence, and generated review briefs.
3
+ > **Purpose of this document**: Provide implementation-ready delivery for Q1, Q2, Q7, Q8, and Q9 with an explicit architectural critique of the prior draft and a corrected execution plan aligned to the current control-plane architecture.
4
4
 
5
- **Version:** 1.0
6
- **Date:** 2026-03-03
7
- **Status:** Draft
5
+ **Version:** 2.0
6
+ **Date:** 2026-03-04
7
+ **Status:** Draft (Architecture-Corrected)
8
8
  **Roadmap Mapping:** M34-M36
9
9
 
10
10
  ---
11
11
 
12
- ## 0. Standards and Scope
12
+ ## 0. Standards and Dependencies
13
13
 
14
- ### 0.1 Standards
14
+ ### 0.1 Required Standards
15
15
 
16
16
  All implementation MUST preserve:
17
- - deterministic plan admission behavior
18
- - policy/schema governance
19
- - transport parity for new tools
20
- - existing collision + lock safety guarantees
17
+ - deterministic tool behavior and normalized error envelopes
18
+ - MCP/in-process transport parity for all new tools
19
+ - policy/schema-governed behavior changes (no hidden defaults)
20
+ - existing lock/collision safety guarantees
21
+ - architecture boundary validation (`validate:architecture`)
21
22
 
22
- ### 0.2 Feature Scope
23
+ ### 0.2 Required Upstream Inputs
24
+
25
+ Implementing agents MUST read:
26
+ - `spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md`
27
+ - `apps/control-plane/src/application/services/plan-service.ts`
28
+ - `apps/control-plane/src/core/collisions.ts`
29
+ - `apps/control-plane/src/application/services/gate-service.ts`
30
+ - `apps/control-plane/src/core/gates.ts`
31
+ - `apps/control-plane/src/application/services/reporting-service.ts`
32
+ - `apps/control-plane/src/supervisor/planning-wave-executor.ts`
33
+ - `apps/control-plane/src/supervisor/build-wave-executor.ts`
34
+ - `apps/control-plane/src/supervisor/qa-wave-executor.ts`
35
+ - `apps/control-plane/src/core/constants.ts`
36
+ - `apps/control-plane/src/core/error-codes.ts`
37
+ - `agentic/orchestrator/defaults/policy.defaults.yaml`
38
+ - `agentic/orchestrator/schemas/policy.schema.json`
39
+ - `agentic/orchestrator/schemas/plan.schema.json`
40
+ - `agentic/orchestrator/schemas/state.schema.json`
41
+ - `agentic/orchestrator/schemas/gates.schema.json`
42
+ - `agentic/orchestrator/tools/catalog.json`
43
+ - `packages/web-dashboard/src/lib/aop-client.ts`
44
+ - `packages/web-dashboard/src/lib/types.ts`
45
+ - `packages/web-dashboard/src/app/page.tsx`
46
+
47
+ ### 0.3 Feature Scope
23
48
 
24
49
  This spec implements:
25
50
  - **Q1** Semantic Collision Engine
@@ -28,60 +53,84 @@ This spec implements:
28
53
  - **Q8** Flaky Gate Intelligence + Quarantine Workflow
29
54
  - **Q9** Auto-Generated Review Briefs
30
55
 
31
- ### 0.3 Out of Scope
32
-
33
- - ML-based probabilistic planning heuristics
56
+ Out of scope:
57
+ - ML-based probabilistic heuristics
34
58
  - autonomous prompt rewriting
35
- - automatic flaky-test suppression without accountability metadata
59
+ - silent gate bypasses without policy and audit metadata
36
60
 
37
61
  ---
38
62
 
39
- ## 1. Objectives
63
+ ## 1. Architectural Critique of Prior Draft (v1.0)
40
64
 
41
- ### 1.1 Must-Have Outcomes
65
+ The prior draft was directionally useful, but not implementation-safe against the current architecture. Key issues:
42
66
 
43
- - detect semantic collisions before expensive build/QA loops
44
- - prevent low-quality plans from advancing when policy requires score threshold
45
- - protect planner/builder/qa behavior from prompt regressions
46
- - reduce gate noise caused by flaky tests
47
- - provide deterministic, high-signal review briefs for human approval
67
+ 1. **Semantic collision data model was underspecified**
68
+ - Problem: Q1 demanded semantic conflicts (OpenAPI/event/db intent) but provided no canonical plan-level fields to compare deterministically.
69
+ - Impact: impossible to implement reliably in `plan.submit` without brittle repo parsing or heuristic guessing.
70
+ - Correction: add explicit `plan.semantic_intent` contract to `plan.schema.json`.
48
71
 
49
- ### 1.2 Non-Goals
72
+ 2. **Policy changes were not wired to current schema constraints**
73
+ - Problem: root `policy.schema.json` is strict (`additionalProperties: false`). New sections cannot be added by policy text alone.
74
+ - Impact: runtime load fails if sections are added without schema/default updates.
75
+ - Correction: update defaults + full policy schema + init-policy generation paths.
50
76
 
51
- - no change to explicit user merge control semantics
52
- - no replacement of current gate profiles
53
- - no dynamic prompt evaluation service
77
+ 3. **Tool-surface proposal was incomplete**
78
+ - Problem: adding tools without corresponding updates to constants, kernel handler registration, catalog, RBAC, and behavior metadata causes contract/runtime drift.
79
+ - Impact: `validate:mcp-contracts` and runtime authorization failures.
80
+ - Correction: include full tool lifecycle wiring as normative work.
54
81
 
55
- ---
82
+ 4. **Flaky workflow lacked a mutating governance path**
83
+ - Problem: draft provided read-only flake report but no deterministic mutation interface for quarantine owner/reason/expiry.
84
+ - Impact: “workflow” cannot be executed via orchestrator contracts.
85
+ - Correction: add explicit quarantine upsert/clear contracts and audit metadata.
56
86
 
57
- ## 2. Architecture Decisions
87
+ 5. **Flaky model lacked deterministic test-level input source**
88
+ - Problem: current gate evidence includes step-level execution, not standardized per-test outcomes.
89
+ - Impact: per-test flaky scoring cannot be computed reliably.
90
+ - Correction: extend gate parser model to optionally ingest structured test results (e.g., junit_xml / vitest_json).
58
91
 
59
- ### 2.1 Collision Checks as Layered Validation
92
+ 6. **Review brief integration path mismatched actual dashboard architecture**
93
+ - Problem: draft targeted non-existent `packages/web-dashboard/src/components/ReviewPanel.tsx`.
94
+ - Impact: implementation ambiguity and likely dead-end edits.
95
+ - Correction: wire through existing `aop-client.ts`, `types.ts`, and `app/page.tsx`.
60
96
 
61
- Plan admission remains layered:
62
- 1. schema validation
63
- 2. policy validation
64
- 3. path/contract collision checks
65
- 4. **semantic collision checks (new)**
66
- 5. feasibility scoring threshold check (optional)
97
+ 7. **Plan feasibility scoring lacked deterministic formula contract**
98
+ - Problem: scoring factors were named but not formally defined.
99
+ - Impact: non-repeatable behavior and test fragility.
100
+ - Correction: define exact component formulas and rounding rules.
67
101
 
68
- ### 2.2 Prompt Contracts as CI Artifact
102
+ 8. **No rollout/failure-mode safety for quality gates**
103
+ - Problem: missing `report_only` vs `enforce` semantics for early rollout.
104
+ - Impact: high risk of accidental throughput regression.
105
+ - Correction: add explicit enforcement modes with default `report_only`.
69
106
 
70
- Prompt contracts are treated as repository source contracts with test fixtures and invariants. They are verified by deterministic scripts in CI, not by runtime agent heuristics.
107
+ ---
71
108
 
72
- ### 2.3 Flaky Intelligence is Advisory + Governed
109
+ ## 2. Revised Architecture Fit
73
110
 
74
- Flaky classification influences reporting and quarantine workflow but MUST NOT silently bypass required merge gates without explicit policy.
111
+ ### 2.1 Existing Runtime Touchpoints
75
112
 
76
- ### 2.4 Review Briefs are Deterministic Summaries
113
+ - **Plan admission path**: `PlanService.planSubmit()` is the authoritative hook for Q1/Q2 enforcement.
114
+ - **Collision reporting path**: `ReportingService.collisionsScan()` is the authoritative hook for scan output parity.
115
+ - **Gate execution path**: `GateService.gatesRun()` + `core/gates.ts` is the authoritative hook for flaky intelligence ingestion.
116
+ - **Supervisor quality loop**: planning/build/qa executors remain orchestrators, not policy evaluators.
117
+ - **Review/report path**: `ReportingService` is the authoritative place for review brief APIs.
118
+ - **Dashboard rendering path**: `aop-client.ts` + `page.tsx` is the current UI integration seam.
77
119
 
78
- Review briefs MUST be generated from canonical artifacts only (plan, state, diff, gate evidence, collisions, locks), not free-form model synthesis.
120
+ ### 2.2 Boundary Rules (Normative)
121
+
122
+ - `core/*` MUST remain framework-agnostic pure logic where practical (no service imports).
123
+ - orchestration/policy decisions belong in `application/services/*`.
124
+ - new MCP tools MUST be implemented via kernel handler registration and catalog/schema integration.
125
+ - no feature may bypass policy schema validation.
79
126
 
80
127
  ---
81
128
 
82
129
  ## 3. Contracts and Schema Deltas
83
130
 
84
- ### 3.1 Policy Extensions
131
+ ## 3.1 Policy Extensions
132
+
133
+ Add to defaults + schema:
85
134
 
86
135
  ```yaml
87
136
  innovation:
@@ -94,373 +143,588 @@ innovation:
94
143
  planning:
95
144
  feasibility:
96
145
  enabled: false
146
+ enforcement_mode: report_only # report_only | enforce
97
147
  minimum_score: 70
148
+ minimum_component_score: 0.45
98
149
  weights:
99
150
  scope_realism: 0.25
100
151
  test_sufficiency: 0.25
101
- dependency_completeness: 0.2
152
+ dependency_completeness: 0.20
102
153
  contract_risk: 0.15
103
154
  lock_contention_risk: 0.15
104
155
 
105
156
  testing:
106
157
  flaky:
107
158
  enabled: false
159
+ window_size: 20
160
+ min_observations: 6
161
+ suspect_threshold: 0.45
162
+ alternation_weight: 0.40
163
+ failure_rate_weight: 0.60
164
+ allow_quarantine_for_required_modes: false
108
165
  quarantine:
109
166
  max_days: 14
110
167
  require_owner: true
111
168
  require_reason: true
169
+
170
+ reporting:
171
+ review_brief:
172
+ enabled: false
173
+ generate_on_ready_to_merge: true
174
+ include_diff_stat: true
175
+ include_flaky_summary: true
176
+ ```
177
+
178
+ Normative behavior:
179
+ - all flags default `false` (opt-in rollout)
180
+ - `weights` MUST sum to 1.0 exactly after normalization (schema + runtime validation)
181
+ - `enforcement_mode=report_only` logs score metadata but never blocks plan acceptance
182
+
183
+ ## 3.2 Plan Schema Extension (`plan.schema.json`)
184
+
185
+ Add optional deterministic semantic declarations:
186
+
187
+ ```json
188
+ {
189
+ "semantic_intent": {
190
+ "openapi_operations": [
191
+ {
192
+ "operation_id": "users_update",
193
+ "path": "/users/{id}",
194
+ "method": "PATCH",
195
+ "change": "modify_response"
196
+ }
197
+ ],
198
+ "event_changes": [
199
+ {
200
+ "event_name": "user.updated",
201
+ "version": "v2",
202
+ "change": "schema_breaking"
203
+ }
204
+ ],
205
+ "db_intents": [
206
+ {
207
+ "entity": "users",
208
+ "change": "drop_column",
209
+ "field": "legacy_status"
210
+ }
211
+ ]
212
+ }
213
+ }
112
214
  ```
113
215
 
114
- ### 3.2 New/Extended Artifacts
216
+ Rules:
217
+ - absence of `semantic_intent` is valid; engine treats as empty intent set
218
+ - deterministic compare uses normalized lowercase for `method` and stable key ordering
219
+
220
+ ## 3.3 State and Artifact Deltas
221
+
222
+ Add/extend runtime artifacts:
115
223
 
116
224
  ```text
117
225
  .aop/
118
226
  analytics/flaky-tests.json
227
+ runtime/prompt-contract/latest.json
119
228
  features/<feature_id>/review_brief.json
120
-
121
- agentic/orchestrator/
122
- prompt-contract/
123
- fixtures/
124
- invariants/
125
- schemas/review_brief.schema.json
126
229
  ```
127
230
 
128
- ### 3.3 Tool Surface Additions
231
+ State frontmatter extension (`state.schema.json`):
232
+ - `collisions.semantic` array
233
+ - `planning_quality.feasibility_score` number (0-100)
234
+ - `planning_quality.feasibility_breakdown` object
235
+ - `reporting.review_brief_path` string
129
236
 
130
- - `plan.score` (read-only)
131
- - `gate.flaky_report_get` (read-only)
132
- - `report.feature_review_brief` (read-only)
237
+ ## 3.4 Tool Surface Changes
133
238
 
134
- `collisions.scan` output schema must be extended for `semantic_conflicts[]`.
239
+ ### New Tools
240
+
241
+ 1. `plan.score` (read-only)
242
+ - returns feasibility score + deterministic breakdown + reasons
243
+
244
+ 2. `gate.flaky_report_get` (read-only)
245
+ - returns flaky suspects, quarantine entries, expiry warnings
246
+
247
+ 3. `gate.flaky_quarantine_upsert` (mutating)
248
+ - upsert quarantine entry (`test_key`, `owner`, `reason`, `expires_at`)
249
+
250
+ 4. `gate.flaky_quarantine_clear` (mutating)
251
+ - clear quarantine entry by `test_key`
252
+
253
+ 5. `report.feature_review_brief` (read-only)
254
+ - returns parsed review brief for feature
255
+
256
+ ### Extended Existing Tool Contracts
257
+
258
+ - `collisions.scan` output adds `semantic_conflicts[]`
259
+ - `report.feature_summary` adds optional `review_brief` and `feasibility`
260
+
261
+ ### Required Wiring for Every New Tool
262
+
263
+ - `apps/control-plane/src/core/constants.ts` (`TOOLS` constants)
264
+ - `apps/control-plane/src/core/kernel.ts` (handler registration + method wrappers)
265
+ - `apps/control-plane/src/application/tools/tool-metadata.ts` (mutating metadata)
266
+ - `agentic/orchestrator/tools/catalog.json`
267
+ - `agentic/orchestrator/tools/schemas/input/*.json`
268
+ - `agentic/orchestrator/tools/schemas/output/*.json`
269
+ - `agentic/orchestrator/defaults/policy.defaults.yaml` RBAC lists
270
+ - generated `agentic/orchestrator/tools.md`
271
+
272
+ ## 3.5 Error Code Additions
273
+
274
+ Add to `apps/control-plane/src/core/error-codes.ts`:
275
+ - `semantic_collision_detected`
276
+ - `plan_feasibility_below_threshold`
277
+ - `plan_feasibility_config_invalid`
278
+ - `prompt_contract_invariant_failed`
279
+ - `flaky_quarantine_policy_violation`
280
+ - `flaky_test_result_parse_failed`
281
+ - `review_brief_not_found`
135
282
 
136
283
  ---
137
284
 
138
- ## 4. Detailed Feature Specs
285
+ ## 4. Detailed Implementation Plan (Normative)
139
286
 
140
- ## 4.1 Q1: Semantic Collision Engine
287
+ ## PRQ0: Contract Scaffolding and Policy Wiring
141
288
 
142
- ### 4.1.1 Problem
143
- Two features can avoid path collisions yet conflict semantically (same API operation evolution, incompatible event payloads, conflicting migration intent).
289
+ ### Goals
290
+ - land all schema/default/tool scaffolding first to avoid mid-phase drift
144
291
 
145
- ### 4.1.2 Design
146
- Add semantic analyzers executed during `plan.submit` and `collisions.scan` when enabled.
292
+ ### File Targets
293
+ - `agentic/orchestrator/defaults/policy.defaults.yaml`
294
+ - `agentic/orchestrator/schemas/policy.schema.json`
295
+ - `agentic/orchestrator/schemas/plan.schema.json`
296
+ - `agentic/orchestrator/schemas/state.schema.json`
297
+ - `agentic/orchestrator/schemas/gates.schema.json`
298
+ - `apps/control-plane/src/core/constants.ts`
299
+ - `apps/control-plane/src/core/error-codes.ts`
300
+ - `agentic/orchestrator/tools/catalog.json`
301
+ - `agentic/orchestrator/tools/schemas/input/*` (new tool schemas)
302
+ - `agentic/orchestrator/tools/schemas/output/*` (new tool schemas)
303
+ - `agentic/orchestrator/tools.md`
304
+ - `apps/control-plane/src/cli/init-command-handler.ts` (full policy template alignment)
147
305
 
148
- ### 4.1.3 Analyzer Modules
306
+ ### Mandatory Checks
307
+ - `npm run validate:mcp-contracts`
308
+ - `npm run validate:architecture`
149
309
 
150
- - `OpenApiSemanticAnalyzer`
151
- - `EventSchemaSemanticAnalyzer`
152
- - `DbIntentSemanticAnalyzer`
310
+ Exit criteria:
311
+ - kernel loads composed policy with new fields
312
+ - no contract-validator drift
153
313
 
154
- ### 4.1.4 Output Contract
314
+ ---
155
315
 
156
- ```json
157
- {
158
- "semantic_conflicts": [
159
- {
160
- "type": "openapi_operation_conflict",
161
- "feature_a": "feature_1",
162
- "feature_b": "feature_2",
163
- "fingerprint": "sha256:...",
164
- "severity": "high",
165
- "details": {
166
- "path": "/users/{id}",
167
- "method": "PATCH"
168
- }
169
- }
170
- ]
171
- }
172
- ```
316
+ ## PRQ1: Q1 Semantic Collision Engine
173
317
 
174
- ### 4.1.5 File Targets
318
+ ### Design
175
319
 
176
- - `apps/control-plane/src/application/services/semantic-collision-service.ts` (new)
320
+ Implement semantic comparisons as an additive layer over existing syntactic collisions.
321
+
322
+ ### Core algorithm
323
+
324
+ 1. Normalize candidate + accepted plan semantic intents.
325
+ 2. Compare candidate against each accepted plan:
326
+ - OpenAPI conflict if same `operation_id` OR same `path+method` and incompatible `change` class.
327
+ - Event conflict if same `event_name` and incompatible `version/change` pair.
328
+ - DB intent conflict if same `entity` and conflicting operations (`drop_column` vs `rename_column`, etc.).
329
+ 3. Emit stable sorted conflicts and deterministic fingerprint.
330
+ 4. Merge with existing `files/areas/contracts` collision result.
331
+
332
+ ### Implementation Targets
333
+
334
+ - `apps/control-plane/src/core/semantic-collisions.ts` (new, pure)
177
335
  - `apps/control-plane/src/application/services/plan-service.ts`
178
336
  - `apps/control-plane/src/application/services/reporting-service.ts`
179
337
  - `agentic/orchestrator/tools/schemas/output/collisions.scan.output.schema.json`
338
+ - `apps/control-plane/src/core/kernel.ts` (if helper wrapper needed)
339
+
340
+ ### Behavioral Rules
341
+
342
+ - semantic collision enforcement follows existing `collision_policy` (`reject`/`block`)
343
+ - blocked queue entry MUST store both syntactic + semantic fingerprints
344
+ - `state.collisions.semantic` MUST be populated on block/reject responses
180
345
 
181
- ### 4.1.6 Acceptance Criteria
346
+ ### Test Plan
182
347
 
183
- - semantic conflicts produce stable fingerprints and deterministic ordering
184
- - policy `collision_policy` handling applies to semantic conflicts identically to existing collisions
348
+ - `apps/control-plane/test/semantic-collisions.spec.ts` (new)
349
+ - extend `apps/control-plane/test/plan-service.spec.ts`
350
+ - extend `apps/control-plane/test/collisions.spec.ts`
351
+ - extend transport parity assertions in `apps/control-plane/test/mcp.spec.ts`
352
+
353
+ Exit criteria:
354
+ - same inputs produce byte-identical `semantic_conflicts` ordering
355
+ - plan blocking/rejection behavior unchanged except added semantic details
185
356
 
186
357
  ---
187
358
 
188
- ## 4.2 Q2: Plan Feasibility Scoring
359
+ ## PRQ2: Q2 Plan Feasibility Scoring
189
360
 
190
- ### 4.2.1 Problem
191
- Schema-valid plans can still be operationally poor and drive retries.
361
+ ### Design
192
362
 
193
- ### 4.2.2 Design
194
- Add deterministic scoring service and optional threshold gate in plan admission.
363
+ Add deterministic score computation service and optional admission enforcement.
195
364
 
196
- ### 4.2.3 Scoring Components
365
+ ### Deterministic formula contract
197
366
 
198
- - scope realism: file breadth vs stated summary/criteria
199
- - test sufficiency: acceptance criteria mapped to gate/test obligations
200
- - dependency completeness: missing/unsatisfied dependencies
201
- - contract risk: openapi/events/db impact complexity
202
- - lock contention risk: likelihood of blocking based on held/pending locks
367
+ `score = round(100 * sum(weight_i * component_i))`
203
368
 
204
- ### 4.2.4 Tool Contract (`plan.score`)
369
+ Components (0.0-1.0):
370
+ - `scope_realism`: bounded function of planned file count, allowed-area breadth, and summary specificity.
371
+ - `test_sufficiency`: acceptance criteria count and presence of verification mapping (`gate_profile`, `gate_targets`, `verification_overrides`).
372
+ - `dependency_completeness`: dependency declarations resolvable from index state.
373
+ - `contract_risk`: penalty for high-risk contract surface changes with no matching acceptance criteria/risk notes.
374
+ - `lock_contention_risk`: penalty when required lock resources are currently held and blocked queue depth is high.
205
375
 
206
- ```json
207
- {
208
- "feature_id": "my_feature",
209
- "score": 78,
210
- "breakdown": {
211
- "scope_realism": 0.8,
212
- "test_sufficiency": 0.7,
213
- "dependency_completeness": 0.9,
214
- "contract_risk": 0.6,
215
- "lock_contention_risk": 0.7
216
- },
217
- "reasons": [
218
- "Acceptance criteria #3 has no mapped verification target"
219
- ]
220
- }
221
- ```
376
+ Normalization rules:
377
+ - all component values clamp to `[0,1]`
378
+ - weights normalize to sum 1.0 at runtime
379
+ - reasons array order is lexical and deterministic
380
+
381
+ ### Enforcement behavior
382
+
383
+ - if `enabled=false`: no score evaluation in plan admission path
384
+ - if `enabled=true && enforcement_mode=report_only`: score computed and stored, never blocks
385
+ - if `enabled=true && enforcement_mode=enforce`: block when `score < minimum_score` OR any component `< minimum_component_score`
222
386
 
223
- ### 4.2.5 File Targets
387
+ ### Implementation Targets
224
388
 
225
389
  - `apps/control-plane/src/application/services/plan-feasibility-service.ts` (new)
226
390
  - `apps/control-plane/src/application/services/plan-service.ts`
391
+ - `apps/control-plane/src/application/services/reporting-service.ts`
392
+ - `apps/control-plane/src/core/kernel.ts`
393
+ - `agentic/orchestrator/tools/schemas/input/plan.score.input.schema.json` (new)
227
394
  - `agentic/orchestrator/tools/schemas/output/plan.score.output.schema.json` (new)
395
+ - `agentic/orchestrator/tools/schemas/output/plan.submit.output.schema.json` (optional metadata extension)
396
+
397
+ ### Test Plan
228
398
 
229
- ### 4.2.6 Acceptance Criteria
399
+ - `apps/control-plane/test/plan-feasibility-service.spec.ts` (new)
400
+ - extend `apps/control-plane/test/plan-service.spec.ts`
401
+ - extend `apps/control-plane/test/mcp.spec.ts` for `plan.score`
230
402
 
231
- - score for same inputs is stable across repeated calls
232
- - below-threshold plans blocked only when feasibility gate is enabled
403
+ Exit criteria:
404
+ - repeated scoring over identical inputs yields identical score and reasons
405
+ - enforcement only active when explicitly configured
233
406
 
234
407
  ---
235
408
 
236
- ## 4.3 Q7: Prompt Contract Test Harness
409
+ ## PRQ3: Q7 Prompt Contract Test Harness
410
+
411
+ ### Design
412
+
413
+ Treat prompt behavior as deterministic source contract tests in CI.
414
+
415
+ ### Contract model
416
+
417
+ Fixture set:
418
+ - `agentic/orchestrator/prompt-contract/fixtures/*.json`
237
419
 
238
- ### 4.3.1 Problem
239
- Prompt edits currently risk behavior drift without dedicated regression coverage.
420
+ Invariant set:
421
+ - `agentic/orchestrator/prompt-contract/invariants/*.json`
240
422
 
241
- ### 4.3.2 Design
242
- Fixture + invariant harness validates role outputs against deterministic expectations.
423
+ Harness:
424
+ - `apps/control-plane/scripts/test-prompt-contracts.mjs`
243
425
 
244
- ### 4.3.3 Invariant Set (Initial)
426
+ Output artifact:
427
+ - `.aop/runtime/prompt-contract/latest.json`
245
428
 
246
- - planner output must include actionable plan artifacts
247
- - builder output must not propose forbidden tool usage
248
- - QA output must contain explicit evidence/test update intent
429
+ ### Invariants (minimum)
249
430
 
250
- ### 4.3.4 Tooling
431
+ - Planner fixture outputs include either `PLAN_SUBMISSION` or deterministic `REQUEST` rationale.
432
+ - Builder fixture outputs never request forbidden tools.
433
+ - QA fixture outputs include explicit verification/remediation intent.
434
+ - Output objects must satisfy role-specific schema fragments.
251
435
 
252
- - script: `apps/control-plane/scripts/test-prompt-contracts.mjs`
253
- - repo assets:
254
- - `agentic/orchestrator/prompt-contract/fixtures/*`
255
- - `agentic/orchestrator/prompt-contract/invariants/*`
256
- - package script:
257
- - `npm run test:prompt-contracts`
436
+ ### CI integration
258
437
 
259
- ### 4.3.5 CI Contract
438
+ - add script: `test:prompt-contracts`
439
+ - add optional validator wrapper: `validate:prompt-contracts`
440
+ - enforce execution whenever files under:
441
+ - `agentic/orchestrator/prompts/`
442
+ - `agentic/orchestrator/prompt-contract/`
443
+ - `apps/control-plane/src/supervisor/worker-decision-loop.ts`
444
+ change.
260
445
 
261
- If prompt files under `agentic/orchestrator/prompts/` change, prompt-contract suite MUST run and block merge on failure.
446
+ ### Implementation Targets
262
447
 
263
- ### 4.3.6 Acceptance Criteria
448
+ - `apps/control-plane/scripts/test-prompt-contracts.mjs` (new)
449
+ - `agentic/orchestrator/prompt-contract/fixtures/*` (new)
450
+ - `agentic/orchestrator/prompt-contract/invariants/*` (new)
451
+ - `package.json` scripts
452
+ - CI workflow file(s) to wire execution
264
453
 
265
- - invariant failures produce explicit diff-like diagnostics
266
- - prompt harness artifacts persist under `.aop/runtime/prompt-contract/`
454
+ ### Test Plan
455
+
456
+ - `apps/control-plane/test/prompt-contract-harness.spec.ts` (new)
457
+ - failure snapshot tests for invariant diagnostics
458
+
459
+ Exit criteria:
460
+ - invariant failures provide actionable role + fixture + invariant id diagnostics
461
+ - harness runtime is deterministic and independent of live provider calls
267
462
 
268
463
  ---
269
464
 
270
- ## 4.4 Q8: Flaky Gate Intelligence + Quarantine Workflow
465
+ ## PRQ4: Q8 Flaky Gate Intelligence + Quarantine Workflow
466
+
467
+ ### Design
271
468
 
272
- ### 4.4.1 Problem
273
- Flaky failures create noisy retries and reduce confidence in gate results.
469
+ Introduce deterministic flaky scoring over historical test outcomes and governed quarantine controls.
274
470
 
275
- ### 4.4.2 Design
276
- Track per-test stability history and expose deterministic suspect scoring and quarantine governance.
471
+ ### Data pipeline
277
472
 
278
- ### 4.4.3 Flake Model (Deterministic)
473
+ 1. Gate execution emits structured test results (optional parser path):
474
+ - extend `gates.yaml` parser config with `parsers.tests`
475
+ - supported initial parsers: `none`, `junit_xml`, `vitest_json`
476
+ 2. `GateService` ingests latest run outcomes after each gate run.
477
+ 3. `FlakyGateService` updates `.aop/analytics/flaky-tests.json` with rolling window stats.
478
+ 4. Suspect score computed deterministically:
479
+ - `suspect_score = failure_rate_weight * failure_rate + alternation_weight * alternation_rate`
480
+ 5. Quarantine controls applied only with explicit metadata and expiry.
279
481
 
280
- Per test key `<framework>:<suite>:<test_name>`:
281
- - rolling window results
282
- - failure-rate and alternation index
283
- - quarantine metadata (`owner`, `reason`, `expires_at`)
482
+ ### Quarantine rules
284
483
 
285
- ### 4.4.4 Quarantine Rules
484
+ - upsert requires owner/reason/expiry when required by policy
485
+ - expiry > now and <= `max_days`
486
+ - expired entries move to `expired_quarantines[]` and are treated as non-quarantined
487
+ - required gate modes remain blocking unless `allow_quarantine_for_required_modes=true`
286
488
 
287
- - quarantine entry requires owner + reason
288
- - quarantine expires automatically
289
- - expired quarantine generates reminder finding/event
290
- - quarantine cannot silently satisfy required merge gates unless policy explicitly permits
489
+ ### Runtime artifact contract
490
+
491
+ `.aop/analytics/flaky-tests.json`:
492
+
493
+ ```json
494
+ {
495
+ "version": 1,
496
+ "updated_at": "2026-03-04T00:00:00Z",
497
+ "tests": {
498
+ "vitest:auth.spec.ts:refresh token retries": {
499
+ "history": ["pass", "fail", "pass", "fail"],
500
+ "failure_rate": 0.5,
501
+ "alternation_rate": 1.0,
502
+ "suspect_score": 0.7,
503
+ "status": "suspect",
504
+ "quarantine": {
505
+ "owner": "alice",
506
+ "reason": "upstream nondeterministic timeout",
507
+ "expires_at": "2026-03-10T00:00:00Z"
508
+ }
509
+ }
510
+ }
511
+ }
512
+ ```
291
513
 
292
- ### 4.4.5 File Targets
514
+ ### Implementation Targets
293
515
 
294
516
  - `apps/control-plane/src/application/services/flaky-gate-service.ts` (new)
295
517
  - `apps/control-plane/src/application/services/gate-service.ts`
518
+ - `apps/control-plane/src/core/gates.ts` (test parser extraction)
519
+ - `agentic/orchestrator/schemas/gates.schema.json`
520
+ - `agentic/orchestrator/tools/schemas/input/gate.flaky_report_get.input.schema.json` (new)
296
521
  - `agentic/orchestrator/tools/schemas/output/gate.flaky_report_get.output.schema.json` (new)
522
+ - `agentic/orchestrator/tools/schemas/input/gate.flaky_quarantine_upsert.input.schema.json` (new)
523
+ - `agentic/orchestrator/tools/schemas/output/gate.flaky_quarantine_upsert.output.schema.json` (new)
524
+ - `agentic/orchestrator/tools/schemas/input/gate.flaky_quarantine_clear.input.schema.json` (new)
525
+ - `agentic/orchestrator/tools/schemas/output/gate.flaky_quarantine_clear.output.schema.json` (new)
526
+
527
+ ### Test Plan
297
528
 
298
- ### 4.4.6 Acceptance Criteria
529
+ - `apps/control-plane/test/flaky-gate-service.spec.ts` (new)
530
+ - extend `apps/control-plane/test/gates.spec.ts` for test parser extraction
531
+ - extend `apps/control-plane/test/supervisor.spec.ts` for retry/quarantine interactions
532
+ - extend `apps/control-plane/test/mcp.spec.ts` for new tools and parity
299
533
 
300
- - flaky suspect list deterministic for same history input
301
- - quarantine lifecycle enforced by policy constraints
534
+ Exit criteria:
535
+ - suspect list deterministic for identical history
536
+ - quarantine lifecycle enforced with owner/reason/expiry constraints
537
+ - required-gate integrity preserved by default
302
538
 
303
539
  ---
304
540
 
305
- ## 4.5 Q9: Auto-Generated Review Briefs
541
+ ## PRQ5: Q9 Auto-Generated Review Briefs
306
542
 
307
- ### 4.5.1 Problem
308
- Human reviewers must manually synthesize plan/diff/evidence context.
543
+ ### Design
309
544
 
310
- ### 4.5.2 Design
311
- Generate concise structured review brief artifacts for each reviewable feature.
545
+ Generate deterministic review briefs from canonical runtime artifacts; no free-form model synthesis.
312
546
 
313
- ### 4.5.3 Brief Sections
547
+ ### Trigger points
314
548
 
315
- - intent and scope summary
316
- - high-risk paths/contracts
317
- - gate outcome matrix
318
- - unresolved risks/questions
319
- - evidence references
549
+ - automatic generation when feature transitions to `ready_to_merge` after successful `full` gate
550
+ - on-demand regeneration via `report.feature_review_brief` if file missing/stale
320
551
 
321
- ### 4.5.4 Artifact Contract
552
+ ### Brief sections (fixed order)
322
553
 
323
- ```json
324
- {
325
- "feature_id": "my_feature",
326
- "intent_summary": "Add idempotent billing retry guard",
327
- "high_risk_paths": ["libs/billing/retry.ts"],
328
- "contract_changes": {
329
- "openapi": false,
330
- "events": true,
331
- "db": false
332
- },
333
- "gate_summary": {
334
- "fast": "pass",
335
- "full": "pass",
336
- "merge": "na"
337
- },
338
- "open_questions": [
339
- "Should retry cap be environment-specific?"
340
- ],
341
- "evidence_refs": [
342
- ".aop/features/my_feature/evidence/gates/full-2026-03-03.json"
343
- ]
344
- }
345
- ```
554
+ 1. intent summary
555
+ 2. scope and touched files
556
+ 3. contract and semantic risk summary
557
+ 4. feasibility score and rationale
558
+ 5. gate matrix + flaky summary
559
+ 6. unresolved questions / review prompts
560
+ 7. evidence references
346
561
 
347
- ### 4.5.5 File Targets
562
+ ### Artifact path
563
+
564
+ - `.aop/features/<feature_id>/review_brief.json`
565
+
566
+ ### Implementation Targets
348
567
 
349
568
  - `apps/control-plane/src/application/services/review-brief-service.ts` (new)
350
569
  - `apps/control-plane/src/application/services/reporting-service.ts`
351
- - `packages/web-dashboard/src/components/ReviewPanel.tsx`
570
+ - `apps/control-plane/src/application/services/gate-service.ts` (trigger hook)
571
+ - `apps/control-plane/src/core/path-layout.ts` (optional helper: `reviewBriefPath(featureId)`)
352
572
  - `agentic/orchestrator/schemas/review_brief.schema.json` (new)
573
+ - `agentic/orchestrator/tools/schemas/input/report.feature_review_brief.input.schema.json` (new)
574
+ - `agentic/orchestrator/tools/schemas/output/report.feature_review_brief.output.schema.json` (new)
575
+ - `packages/web-dashboard/src/lib/types.ts`
576
+ - `packages/web-dashboard/src/lib/aop-client.ts`
577
+ - `packages/web-dashboard/src/app/page.tsx`
578
+
579
+ ### Dashboard integration contract
353
580
 
354
- ### 4.5.6 Acceptance Criteria
581
+ - `FeatureDetail` adds optional `review_brief`
582
+ - details pane renders structured brief sections when present
583
+ - fallback message when brief unavailable
355
584
 
356
- - review brief generated for `ready_to_merge` features
357
- - brief content deterministic and sorted consistently
585
+ ### Test Plan
586
+
587
+ - `apps/control-plane/test/review-brief-service.spec.ts` (new)
588
+ - extend `apps/control-plane/test/services.spec.ts` / `kernel.spec.ts` for trigger behavior
589
+ - extend `apps/control-plane/test/dashboard-api.integration.spec.ts`
590
+ - add UI rendering test under web-dashboard workspace for brief display
591
+
592
+ Exit criteria:
593
+ - brief generation is deterministic and schema-valid
594
+ - dashboard shows brief without regressions to existing detail panel behavior
358
595
 
359
596
  ---
360
597
 
361
- ## 5. Milestones
598
+ ## PRQ6: Hardening, Rollout, and Migration
599
+
600
+ ### Rollout order
362
601
 
363
- ### PRQ1: Semantic + Feasibility Admission
602
+ 1. Ship PRQ0 contracts and flags off by default.
603
+ 2. Enable Q1+Q2 in `report_only` mode in internal environments.
604
+ 3. Enable Q7 CI harness as warning for one sprint, then enforce.
605
+ 4. Enable Q8 flaky intelligence with quarantine enforcement still strict.
606
+ 5. Enable Q9 brief generation and dashboard rendering.
607
+ 6. Flip enforcement toggles selectively per repo.
364
608
 
365
- Tasks:
366
- 1. Implement semantic analyzers + schema updates.
367
- 2. Implement feasibility scoring + threshold enforcement.
609
+ ### Backfill guidance
368
610
 
369
- Exit gate:
370
- - conflicting and low-feasibility plans blocked deterministically when enabled.
611
+ - optional one-time job can ingest recent gate evidence files into `flaky-tests.json` history.
612
+ - missing historical test-level data is acceptable; model starts with forward-only data.
371
613
 
372
- ### PRQ2: Prompt Contract Reliability
614
+ ### Observability requirements
373
615
 
374
- Tasks:
375
- 1. Add fixtures/invariants and harness script.
376
- 2. Wire CI enforcement for prompt changes.
616
+ - emit structured log events for:
617
+ - feasibility score evaluation
618
+ - semantic collision detection
619
+ - flaky suspect/quarantine transitions
620
+ - review brief generation success/failure
377
621
 
378
- Exit gate:
379
- - prompt regressions are caught in CI with clear diagnostics.
622
+ ---
623
+
624
+ ## 5. Core Tradeoffs
380
625
 
381
- ### PRQ3: Flaky Gate Intelligence
626
+ 1. **Semantic precision vs planner burden**
627
+ - richer `semantic_intent` improves detection but increases plan authoring complexity.
382
628
 
383
- Tasks:
384
- 1. Add flake analytics persistence and report tool.
385
- 2. Add quarantine governance and expiry checks.
629
+ 2. **Early plan quality gates vs throughput**
630
+ - enforcing feasibility reduces churn but can block progress if thresholds are too strict.
386
631
 
387
- Exit gate:
388
- - flaky signal exposed without weakening mandatory gates by default.
632
+ 3. **Flaky noise reduction vs masking regressions**
633
+ - quarantine reduces false alarms but can hide real defects if governance is weak.
389
634
 
390
- ### PRQ4: Review Brief Automation
635
+ 4. **Strict prompt contracts vs iteration speed**
636
+ - strong invariants prevent regressions but add maintenance overhead when role behavior evolves.
391
637
 
392
- Tasks:
393
- 1. Implement review-brief service and artifact generation.
394
- 2. Add MCP report tool and dashboard integration.
638
+ 5. **Comprehensive review briefs vs generation cost**
639
+ - richer summaries help reviewers but add I/O/compute per `ready_to_merge` transition.
395
640
 
396
- Exit gate:
397
- - reviewers receive deterministic brief before merge approval.
641
+ 6. **New tool count vs API surface simplicity**
642
+ - dedicated tools improve explicitness and RBAC isolation but increase contract maintenance load.
398
643
 
399
644
  ---
400
645
 
401
- ## 6. Test Strategy (Normative)
646
+ ## 6. Milestones and Implementation Sequence
402
647
 
403
- ### 6.1 Unit Tests
648
+ ### Milestone A (Week 1)
649
+ - PRQ0 scaffolding complete
650
+ - contract validators green
404
651
 
405
- - each semantic analyzer rule
406
- - score determinism and weight normalization
407
- - prompt invariant validators
408
- - flaky score and quarantine expiry logic
409
- - brief assembly ordering and content extraction
652
+ ### Milestone B (Week 2)
653
+ - Q1 semantic collisions + tests complete
654
+ - Q2 feasibility scoring in `report_only`
410
655
 
411
- ### 6.2 Integration Tests
656
+ ### Milestone C (Week 3)
657
+ - Q7 prompt contract harness enforced in CI
658
+ - Q8 flaky ingestion and reporting complete
412
659
 
413
- - `plan.submit` blocked by semantic conflict
414
- - `plan.submit` blocked by low feasibility when enabled
415
- - prompt-contract harness pass/fail suites
416
- - flaky report generation from realistic gate histories
417
- - review brief generation from live feature artifacts
660
+ ### Milestone D (Week 4)
661
+ - Q8 quarantine workflow complete
662
+ - Q9 review brief generation + dashboard integration complete
418
663
 
419
- ### 6.3 Transport Parity Tests
664
+ ### Milestone E (Week 5)
665
+ - full stabilization, parity tests, docs, and rollout playbook
420
666
 
421
- - `plan.score`
422
- - `gate.flaky_report_get`
423
- - `report.feature_review_brief`
667
+ ---
424
668
 
425
- ### 6.4 UI Tests
669
+ ## 7. Test Strategy (Normative)
426
670
 
427
- - review panel displays brief sections and evidence links
428
- - no brief available state handled clearly
671
+ ### 7.1 Unit
429
672
 
430
- ---
673
+ - semantic comparator edge cases and fingerprint determinism
674
+ - feasibility component formulas and normalization
675
+ - prompt invariant evaluator diagnostics
676
+ - flaky suspect score and quarantine expiry behavior
677
+ - review brief assembly sorting and field completeness
431
678
 
432
- ## 7. Acceptance Criteria
679
+ ### 7.2 Integration
433
680
 
434
- 1. Q1/Q2 quality gates work deterministically and are policy-controlled.
435
- 2. Prompt contract harness is operational and CI-gated.
436
- 3. Flaky intelligence improves signal while preserving gate integrity.
437
- 4. Review briefs are generated and consumable in CLI/dashboard flows.
438
- 5. All validation gates pass (`lint`, `typecheck`, `test`, contract/architecture validators).
681
+ - `plan.submit` rejection/block behavior for semantic collisions
682
+ - feasibility enforcement/report-only mode behavior
683
+ - gate-run ingestion of parsed test outcomes
684
+ - quarantine update/clear flow through MCP tools
685
+ - ready-to-merge trigger writes `review_brief.json`
439
686
 
440
- ---
687
+ ### 7.3 Transport Parity
688
+
689
+ - `plan.score`
690
+ - `gate.flaky_report_get`
691
+ - `gate.flaky_quarantine_upsert`
692
+ - `gate.flaky_quarantine_clear`
693
+ - `report.feature_review_brief`
441
694
 
442
- ## 8. Risks and Mitigations
695
+ ### 7.4 UI and API
443
696
 
444
- - Risk: semantic analyzers produce false positives.
445
- - Mitigation: confidence/severity labels + precise conflict details and opt-in rollout.
697
+ - dashboard detail endpoint includes review brief when present
698
+ - dashboard page renders review brief sections deterministically
699
+ - missing brief state handled gracefully
446
700
 
447
- - Risk: scoring model over-rejects valid plans.
448
- - Mitigation: threshold configurable and disabled by default.
701
+ ### 7.5 Validation Gates
702
+
703
+ - `npm run lint`
704
+ - `npm run typecheck`
705
+ - `npm test`
706
+ - `npm run validate:mcp-contracts`
707
+ - `npm run validate:architecture`
708
+
709
+ ---
449
710
 
450
- - Risk: prompt fixtures become stale with runtime evolution.
451
- - Mitigation: fixture versioning and required update notes on role contract changes.
711
+ ## 8. Acceptance Criteria
452
712
 
453
- - Risk: quarantine becomes an abuse path.
454
- - Mitigation: owner/reason/expiry mandatory and surfaced in status/reporting.
713
+ 1. Q1/Q2 admission controls are deterministic, policy-controlled, and rollout-safe (`report_only` supported).
714
+ 2. Q7 prompt contract harness blocks prompt regressions with actionable diagnostics.
715
+ 3. Q8 flaky intelligence produces deterministic suspect scoring and governed quarantine workflows.
716
+ 4. Q9 review briefs are generated from canonical artifacts and consumable via MCP + dashboard.
717
+ 5. New tool contracts pass schema validation, RBAC checks, and MCP/in-process parity tests.
718
+ 6. No regressions in existing lock, collision, and merge safety behavior.
455
719
 
456
720
  ---
457
721
 
458
722
  ## 9. Definition of Done
459
723
 
460
- A completed PRQ milestone MUST include:
461
- - changed file inventory
462
- - schema/catalog updates
463
- - new tests and coverage notes
464
- - verification command summaries
465
- - `spec-files/progress.md` task closure and next steps
724
+ A completed milestone MUST include:
725
+ - implemented file inventory mapped to the phase above
726
+ - schema/catalog/RBAC/tool-doc updates
727
+ - unit + integration + parity tests
728
+ - validator and test command summaries
729
+ - `spec-files/progress.md` update with completed tasks, residual tasks, and risks
466
730