ultra-builder-pro-cli 0.14.0 → 0.15.0

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 (154) hide show
  1. package/.ultra-template/docs/research/README.md +11 -7
  2. package/.ultra-template/specs/architecture.md +36 -36
  3. package/.ultra-template/specs/discovery.md +46 -33
  4. package/.ultra-template/specs/product.md +38 -29
  5. package/.ultra-template/specs/research-distillate.md +48 -0
  6. package/.ultra-template/tasks/contexts/TEMPLATE.md +11 -28
  7. package/CHANGELOG.md +44 -1
  8. package/README.md +34 -19
  9. package/adapters/_shared/codex-assets.cjs +6 -2
  10. package/adapters/_shared/file-ops.cjs +6 -2
  11. package/adapters/claude.js +3 -2
  12. package/adapters/codex.js +1 -0
  13. package/adapters/kimi.js +3 -2
  14. package/adapters/opencode.js +3 -2
  15. package/agents/review-coordinator.md +9 -6
  16. package/docs/AGENT-CONTEXT.md +15 -8
  17. package/docs/ARCHITECTURE.md +33 -12
  18. package/docs/PLAN.zh-CN.md +3 -2
  19. package/docs/ROADMAP.md +8 -4
  20. package/docs/RUNTIME-COMPAT-MATRIX.md +4 -4
  21. package/docs/STATE-DB-ACCESS-POLICY.md +27 -25
  22. package/docs/WORKFLOW-LIFECYCLE.md +266 -0
  23. package/hooks/README.md +6 -1
  24. package/hooks/health_check.py +12 -3
  25. package/hooks/subagent_tracker.py +52 -77
  26. package/mcp-server/hook-event.cjs +34 -0
  27. package/mcp-server/lib/archive-journal.cjs +17 -5
  28. package/mcp-server/lib/baseline-workflow.cjs +158 -18
  29. package/mcp-server/lib/change-workflow.cjs +550 -85
  30. package/mcp-server/lib/context-spine.cjs +242 -24
  31. package/mcp-server/lib/doctor.cjs +33 -3
  32. package/mcp-server/lib/init-project.cjs +210 -16
  33. package/mcp-server/lib/plan-store.cjs +4 -1
  34. package/mcp-server/lib/pricing.cjs +7 -10
  35. package/mcp-server/lib/project-breadcrumb.cjs +6 -0
  36. package/mcp-server/lib/projector.cjs +57 -3
  37. package/mcp-server/lib/spec-learning.cjs +79 -2
  38. package/mcp-server/lib/state-db.cjs +145 -8
  39. package/mcp-server/lib/state-ops.cjs +160 -9
  40. package/mcp-server/lib/workflow-state.cjs +2292 -0
  41. package/mcp-server/server.cjs +161 -15
  42. package/orchestrator/daemon.cjs +1 -2
  43. package/orchestrator/dispatch-rules.cjs +5 -31
  44. package/orchestrator/planner/plan-builder.cjs +21 -12
  45. package/package.json +13 -3
  46. package/skills/ultra-change/SKILL.md +53 -68
  47. package/skills/ultra-change/references/change-contract.md +36 -0
  48. package/skills/ultra-deliver/SKILL.md +69 -79
  49. package/skills/ultra-deliver/references/baseline-reconciliation.md +20 -0
  50. package/skills/ultra-dev/SKILL.md +54 -59
  51. package/skills/ultra-doctor/SKILL.md +40 -71
  52. package/skills/ultra-init/SKILL.md +96 -103
  53. package/skills/ultra-init/references/brownfield-adoption.md +2 -2
  54. package/skills/ultra-plan/SKILL.md +79 -85
  55. package/skills/ultra-plan/references/semantic-preflight.md +18 -0
  56. package/skills/ultra-research/SKILL.md +87 -60
  57. package/skills/ultra-research/references/00-problem-validation.md +36 -0
  58. package/skills/ultra-research/references/01-opportunity-discovery.md +33 -0
  59. package/skills/ultra-research/references/02-market-assessment.md +30 -0
  60. package/skills/ultra-research/references/03-competitive-landscape.md +31 -0
  61. package/skills/ultra-research/references/04-product-strategy.md +32 -0
  62. package/skills/ultra-research/references/05-assumptions-validation.md +31 -0
  63. package/skills/ultra-research/references/10-user-personas.md +29 -0
  64. package/skills/ultra-research/references/11-user-scenarios.md +28 -0
  65. package/skills/ultra-research/references/20-user-stories.md +30 -0
  66. package/skills/ultra-research/references/21-features-scope.md +29 -0
  67. package/skills/ultra-research/references/22-success-metrics.md +28 -0
  68. package/skills/ultra-research/references/30-architecture-context.md +30 -0
  69. package/skills/ultra-research/references/31-solution-strategy.md +28 -0
  70. package/skills/ultra-research/references/32-building-blocks.md +28 -0
  71. package/skills/ultra-research/references/40-deployment.md +29 -0
  72. package/skills/ultra-research/references/41-quality-risks.md +28 -0
  73. package/skills/ultra-research/references/99-synthesis.md +35 -0
  74. package/skills/ultra-review/SKILL.md +57 -73
  75. package/skills/ultra-review/references/review-modes.md +27 -0
  76. package/skills/ultra-review/references/unified-schema.md +25 -0
  77. package/skills/ultra-review/scripts/review_wait.py +40 -3
  78. package/skills/ultra-status/SKILL.md +41 -45
  79. package/skills/ultra-test/SKILL.md +48 -55
  80. package/skills/ultra-verify/SKILL.md +1 -1
  81. package/skills/ultra-verify/references/{confidence-system.md → evidence-status.md} +3 -3
  82. package/spec/cli-protocol.md +7 -2
  83. package/spec/mcp-tools.yaml +384 -63
  84. package/spec/schemas/baseline-reconciliation.v1.schema.json +73 -0
  85. package/spec/schemas/delivery-report.v1.schema.json +111 -0
  86. package/spec/schemas/mcp-tools.schema.json +1 -1
  87. package/spec/schemas/state-db.sql +82 -1
  88. package/spec/schemas/tasks.v4.5.schema.json +8 -1
  89. package/spec/schemas/test-report.v1.schema.json +194 -0
  90. package/ultra-tools/cli.cjs +1 -1
  91. package/ultra-tools/commands/migrate.cjs +3 -3
  92. package/ultra-tools/commands/status.cjs +213 -12
  93. package/.ultra-template/delivery-report.json +0 -9
  94. package/.ultra-template/test-report.json +0 -8
  95. package/adapters/_shared/tests/file-ops.test.cjs +0 -54
  96. package/adapters/_shared/tests/frontmatter.test.cjs +0 -47
  97. package/adapters/_shared/tests/handbook.test.cjs +0 -101
  98. package/adapters/_shared/tests/path-rewrite.test.cjs +0 -60
  99. package/adapters/_shared/tests/provenance.test.cjs +0 -133
  100. package/adapters/_shared/tests/resolve-target.test.cjs +0 -75
  101. package/adapters/_shared/tests/runtime-assets.test.cjs +0 -149
  102. package/adapters/_shared/tests/settings-merge.test.cjs +0 -85
  103. package/adapters/_shared/tests/validate.test.cjs +0 -30
  104. package/adapters/tests/claude.test.cjs +0 -138
  105. package/adapters/tests/codex-hook.test.cjs +0 -142
  106. package/adapters/tests/codex.test.cjs +0 -430
  107. package/adapters/tests/kimi-hook.test.cjs +0 -149
  108. package/adapters/tests/kimi.test.cjs +0 -259
  109. package/adapters/tests/opencode.test.cjs +0 -357
  110. package/mcp-server/lib/archive-journal.test.cjs +0 -35
  111. package/mcp-server/lib/baseline-workflow.test.cjs +0 -477
  112. package/mcp-server/lib/change-workflow.test.cjs +0 -971
  113. package/mcp-server/lib/context-spine.test.cjs +0 -93
  114. package/mcp-server/lib/doctor.test.cjs +0 -148
  115. package/mcp-server/lib/plan-store.test.cjs +0 -132
  116. package/mcp-server/lib/prd-parser.test.cjs +0 -82
  117. package/mcp-server/lib/project-breadcrumb.test.cjs +0 -112
  118. package/mcp-server/lib/runtime-state.test.cjs +0 -92
  119. package/mcp-server/lib/spec-learning.test.cjs +0 -67
  120. package/mcp-server/lib/state-db.test.cjs +0 -314
  121. package/mcp-server/lib/task-expander.test.cjs +0 -169
  122. package/mcp-server/lib/topo.test.cjs +0 -158
  123. package/mcp-server/tests/circuit-breaker.test.cjs +0 -125
  124. package/mcp-server/tests/commit-hash-flow.test.cjs +0 -117
  125. package/mcp-server/tests/concurrency-update.test.cjs +0 -96
  126. package/mcp-server/tests/concurrency.test.cjs +0 -112
  127. package/mcp-server/tests/db-ops.test.cjs +0 -121
  128. package/mcp-server/tests/init-project.test.cjs +0 -393
  129. package/mcp-server/tests/migrate.test.cjs +0 -232
  130. package/mcp-server/tests/projector.test.cjs +0 -162
  131. package/mcp-server/tests/server-contract.test.cjs +0 -1467
  132. package/mcp-server/tests/staleness.test.cjs +0 -190
  133. package/mcp-server/tests/state-db.test.cjs +0 -106
  134. package/mcp-server/tests/state-ops.test.cjs +0 -449
  135. package/mcp-server/tests/tagged-tasks.test.cjs +0 -163
  136. package/mcp-server/tests/telemetry.test.cjs +0 -219
  137. package/orchestrator/planner/plan-builder.test.cjs +0 -165
  138. package/orchestrator/tests/auto-merge.test.cjs +0 -216
  139. package/orchestrator/tests/daemon.test.cjs +0 -311
  140. package/orchestrator/tests/dispatch-rules.test.cjs +0 -124
  141. package/orchestrator/tests/parallel-orchestrator.test.cjs +0 -233
  142. package/orchestrator/tests/phase-8b-gate.test.cjs +0 -183
  143. package/orchestrator/tests/recovery.test.cjs +0 -190
  144. package/orchestrator/tests/session-runner.test.cjs +0 -314
  145. package/orchestrator/tests/skill-miner.test.cjs +0 -147
  146. package/orchestrator/tests/worktree-manager.test.cjs +0 -148
  147. package/skills/ultra-research/references/architecture.md +0 -38
  148. package/skills/ultra-research/references/problem-product.md +0 -39
  149. package/skills/ultra-research/references/quality-delivery.md +0 -34
  150. package/skills/ultra-research/references/synthesis.md +0 -38
  151. package/skills/ultra-research/references/users-scope.md +0 -40
  152. package/ultra-tools/legacy-memory.test.cjs +0 -80
  153. package/ultra-tools/status-command.test.cjs +0 -181
  154. package/ultra-tools/system-command.test.cjs +0 -309
@@ -1,111 +1,104 @@
1
1
  ---
2
2
  name: ultra-init
3
- description: Initialize a new repository, adopt an existing codebase, or upgrade prior Ultra state into an evidence-backed project baseline. Use when `.ultra` is absent, baseline readiness is incomplete, or legacy project state must be migrated.
3
+ description: Initialize a new repository, adopt an existing codebase, or migrate prior Ultra authority into a verified project baseline. Use when `.ultra` is absent, initialization is incomplete, baseline readiness is blocked, or a legacy Ultra project must be resumed.
4
4
  ---
5
5
 
6
- # Establish the project baseline
7
-
8
- Create or recover project-local Ultra authority, classify the repository, and finish
9
- the applicable baseline workflow. Keep application source unchanged during adoption.
10
-
11
- ## Authority rules
12
-
13
- - Treat `.ultra/state.db` as the only durable Ultra authority.
14
- - Preserve every existing `.ultra/` tree and migration backup.
15
- - Require explicit authorization before replacing a healthy baseline or discarding a
16
- corrupt database.
17
- - Store only metadata references for external memory and code-graph providers.
18
- - Create ordinary tasks only after the baseline is ready. Record characterization
19
- needs and adoption gaps in the gap ledger until convergence.
20
-
21
- ## Inspect and route
22
-
23
- 1. Bind the repository root, Git branch and HEAD, worktree status, manifests, package
24
- scripts, workspace markers, deployment files, and existing `.ultra/` assets.
25
- 2. When `.ultra/` is absent, run **Bootstrap**.
26
- 3. When `.ultra/tasks/tasks.json` contains tasks but `state.db` is absent or has no
27
- tasks, run **Import projection-only state** before ordinary state-backed work.
28
- 4. When `state.db` exists, run read-only project doctor first. Call `baseline.get`
29
- only when doctor confirms that the current schema authority is readable. Route an
30
- old schema to repair and a corrupt database to recovery without another DB read.
31
- 5. After current authority is readable, call `task.init_project` with `resume: true` to install
32
- only missing current scaffold files. Verify that existing artifacts were preserved.
33
- 6. Route the result:
34
- - healthy `ready` baseline: return `ultra-change` or `ultra-status`;
35
- - `draft`, `adopting`, or baseline-blocked: resume the matching baseline;
36
- - `migrated`: start evidence-backed brownfield re-adoption;
37
- - old schema: run backup-first schema repair;
38
- - corrupt database: preserve it and stop at the restore-or-rebaseline decision.
39
-
40
- ## Bootstrap
41
-
42
- Derive project metadata from repository evidence. Call `task.init_project` with
43
- `mode: "auto"`. Pass `scope` when the user selected a monorepo boundary; otherwise use
44
- the repository root. Use an explicit mode only when the user supplied an authoritative
45
- classification.
46
-
47
- Verify `repository_profile`, selected scope, detected mode, baseline lifecycle, schema
48
- version, copied templates, initial projection, and `project_initialized` event.
49
-
50
- ## Import projection-only state
51
-
52
- Call `task.init_project` with `resume: true` as the single authority check and run the
53
- exact supported backup-first import command returned in its structured error. Do not
54
- infer an import path or edit the projection manually.
55
-
56
- Verify imported task and event counts, backup path, current schema state, projection
57
- parity, and the `migrated/adopting` compatibility baseline. Then call `baseline.start` with a
58
- new id, `mode: "brownfield"`, `replace_migrated: true`, the selected scope, current
59
- revision, and repository classification. Never treat the compatibility row as owner
60
- approval.
61
-
62
- For an older database schema, run `ultra-tools system doctor --repair`; verify both the
63
- pre-migration backup and post-repair backup plus the current schema before continuing.
64
- Then resume initialization to merge missing scaffold assets without overwriting the
65
- project's existing baseline documents.
66
-
67
- ## Complete the selected mode
68
-
69
- For `brownfield`, `migrated`, or an incomplete existing adoption, read
70
- `references/brownfield-adoption.md` completely and execute it through owner approval.
71
-
72
- For `greenfield`, keep the baseline in `draft` until product and architecture intent is
73
- evidence-backed. Route unresolved intent through `ultra-research`, record the complete
74
- baseline snapshot, obtain owner approval, and converge it before planning.
75
-
76
- ## Recovery handling
77
-
78
- - `ULTRA_DIR_EXISTS`: inspect and resume the existing state.
79
- - `LEGACY_STATE_MIGRATION_REQUIRED`: execute the returned migration command.
80
- - `BASELINE_IN_PROGRESS`: resume the named row; never create a parallel authority.
81
- - `BASELINE_EXISTS`: return the healthy route. Replacing a ready baseline is outside
82
- ordinary initialization; stop for owner authorization before calling
83
- `baseline.start` with a new id, `replace_ready: true`, and
84
- `replacement_authorization: { approved_by, reason }`. The approval identity and
85
- rationale must be persisted in the `baseline_started` event.
86
- - `BASELINE_SCOPE_MISSING`: correct the selected monorepo boundary.
87
- - `TEMPLATE_MISSING`: run installer doctor and reinstall through the host adapter.
88
- - `STATE_DB_CORRUPT`: retain the database, inspect `.ultra/backups`, and obtain the
89
- restore-or-rebaseline decision. Restore only a verified managed backup with
90
- `ultra-tools system restore --backup <path> --confirm REPLACE_CORRUPT_ULTRA_STATE`.
91
- When no valid backup exists and the owner explicitly accepts rebuilding authority,
92
- run `ultra-tools system rebaseline --project-name <name> [--scope <path>] --confirm
93
- REBASELINE_CORRUPT_ULTRA_STATE`; verify the quarantined database and legacy
94
- projection paths before continuing adoption.
95
- - `IO_ERROR`: verify rollback restoration and preserve every reported backup path.
6
+ # Establish project authority
7
+
8
+ Use host reasoning to inspect repository evidence and prepare baseline content. Use
9
+ Ultra MCP for classification records, schema migration, workflow state, evidence
10
+ digests, approval, and convergence. Never treat generated Markdown or JSON as state.
11
+
12
+ ## Classify without guessing product scope
13
+
14
+ Run `system.doctor` read-only when `.ultra/state.db` exists. Otherwise call
15
+ `task.init_project` with `mode: "auto"`, the repository root, project name, and an
16
+ owner-selected monorepo scope when applicable.
17
+
18
+ Interpret classification independently from readiness:
19
+
20
+ - `greenfield`: no meaningful delivered application behavior exists outside docs,
21
+ generated output, or a starter skeleton;
22
+ - `brownfield`: source, runtime, deployment, API, schema, or test evidence shows an
23
+ existing maintained system;
24
+ - `migrated`: older DB or projection-only authority was preserved and must be
25
+ replaced by an evidence-backed brownfield baseline.
26
+
27
+ The presence of `.ultra/`, a manifest, or a Git repository does not make a baseline
28
+ ready. Classification never chooses an MVP, reduced scope, or delivery posture.
29
+ Report the detected project type, technology signals, verification commands, and
30
+ monorepo roots. Pass an explicit `project_type` or `stack` only when repository evidence
31
+ or an owner decision supports the override; MCP preserves both detection and selection.
32
+
33
+ ## Resume safely
34
+
35
+ When `.ultra/` exists, call `task.init_project` with `resume: true`. It must preserve
36
+ existing artifacts, create a pre-migration backup when needed, upgrade the schema,
37
+ install only missing assets, and return the durable workflow ids and exact route.
38
+
39
+ For projection-only state, execute only the backup-first migration command returned by
40
+ the structured error. For a `migrated` compatibility row, call `baseline.start` with a
41
+ new brownfield id and `replace_migrated: true`; never treat migration as owner approval.
42
+
43
+ Replacing a healthy baseline requires a new id plus `replace_ready: true` and explicit
44
+ `replacement_authorization`. Preserve corrupt DB, WAL, SHM, and backups; use the
45
+ documented restore or rebaseline command only after the owner selects that destructive
46
+ recovery path.
47
+
48
+ ## Follow durable initialization state
49
+
50
+ Read the returned init and research runs with `workflow.get`.
51
+
52
+ - `inspect-authority`: `task.init_project` records the bounded repository and existing
53
+ Ultra evidence it inspected.
54
+ - `classify-repository`: `task.init_project` records classification, detected signals,
55
+ selected scope, and supported overrides.
56
+ - `scaffold-authority`: `task.init_project` creates or resumes DB authority and installs
57
+ only missing scaffold assets.
58
+ - `establish-baseline`: research completion, `baseline.record`, and owner-approved
59
+ `baseline.converge` establish the evidence-backed authority.
60
+ - `verify-initialization`: convergence re-reads baseline, init, research, repository,
61
+ verification, and output health before completing initialization.
62
+
63
+ The first three steps are deterministic writes owned by `task.init_project`; the final
64
+ two are completed atomically by successful baseline convergence. Do not mark or emulate
65
+ these transitions in Prompt text or projection files.
66
+
67
+ - Greenfield starts a `full` research run.
68
+ - Brownfield starts an `adoption` research run.
69
+ - Both modes require all seventeen research steps before baseline convergence.
70
+ - A migrated project remains routed to re-adoption before research can authorize work.
71
+
72
+ Continue through `ultra-research`. Research completion records output digests; then
73
+ `baseline.record` captures current scope, revision, discovery/product/architecture
74
+ specs, source and runtime evidence, actual verification, unknowns, gaps,
75
+ classification, and external provider metadata references.
76
+
77
+ Call `baseline.converge` only after explicit owner approval. The MCP rejects missing
78
+ research, missing discovery/product/architecture refs, stale evidence, revision or
79
+ worktree drift, unaccepted known failures, blocking unknowns, and blocking gaps. A
80
+ successful convergence atomically marks the baseline ready and completes the init run.
81
+
82
+ ## Recovery
83
+
84
+ - Record deterministic blockers on the current workflow; never create a parallel run.
85
+ - Use `system.doctor` repair only for supported schema, projection, session, incident,
86
+ archive, or legacy workflow-provenance recovery. A recovered legacy change workflow
87
+ remains blocked for real baseline evidence; repair cannot invent research or approve
88
+ a baseline.
89
+ - Treat context budgets as advisory. Missing authority, evidence, output, or approval
90
+ is blocking.
91
+ - Store only references to external memory and code-graph providers.
96
92
 
97
93
  ## Completion
98
94
 
99
- Initialization is complete only when:
95
+ Read `baseline.get`, `workflow.get`, and `system.doctor` after convergence. Report
96
+ classification evidence, scope, revision, worktree snapshot, migration backups,
97
+ research run and output health, verification, gaps, approval, and one route.
100
98
 
101
- - current schema authority is readable;
102
- - repository classification and scope are recorded;
103
- - product and architecture baseline files exist;
104
- - verification, unknowns, gaps, evidence, and provider references are recorded;
105
- - explicit owner approval has converged the baseline to `ready`;
106
- - `baseline.get` reports current health and project doctor has no authority failure.
107
-
108
- Report the target, classification evidence, migration and backup paths, baseline id,
109
- mode, status, revision, branch, worktree snapshot, verification results, gap summary,
110
- approval state, and one exact next action. Stop at the approval step when owner consent
111
- has not yet been provided.
99
+ Initialization is complete only when the baseline is `ready`, the init workflow is
100
+ `completed`, the research workflow is `completed`, and
101
+ `baseline.research_run_id` names that exact research run with healthy outputs. Route
102
+ every newly converged or already initialized baseline through `ultra-change`; planning
103
+ starts only after that command persists a complete Change Contract, profile, and
104
+ research disposition. Otherwise return the exact current workflow step or blocker.
@@ -89,5 +89,5 @@ items the owner accepted.
89
89
  Resolve returned blockers through evidence or an owner decision, record the replacement
90
90
  snapshot, and retry. Adoption is complete only when `baseline.get` is `ready` and
91
91
  current, the gap ledger has no open blocker, and project doctor has no authority
92
- failure. Route new work through `ultra-change`; route already accepted planned work
93
- through `ultra-plan`.
92
+ failure. Route all selected work through `ultra-change`, including work described by a
93
+ legacy plan. Import its accepted intent into a current Change Contract before planning.
@@ -1,89 +1,83 @@
1
1
  ---
2
2
  name: ultra-plan
3
- description: Convert a validated baseline, active delta, or approved PRD into dependency-valid vertical slices with bounded context and exact verification. Use when requirements are ready to become authoritative Ultra tasks.
3
+ description: Convert a ready Ultra baseline or approved active-change delta into dependency-valid, DB-backed execution contracts and fresh-context vertical slices. Use when accepted requirements are ready for implementation planning or an existing plan must be resumed and verified.
4
4
  ---
5
5
 
6
- # Plan fresh-context execution
7
-
8
- Produce a task graph whose slices can be completed independently and verified through
9
- live product seams. `.ultra/state.db` remains authoritative; task JSON and context
10
- Markdown are generated projections.
11
-
12
- ## Entry gate
13
-
14
- Start with a state-backed MCP read. If state or schema health blocks access, stop and
15
- route to `ultra-doctor`. Never read or write `.ultra/tasks/tasks.json` as a fallback.
16
- Call `baseline.get`. Initial product planning is blocked until the baseline is
17
- `ready` and current; route its missing, adopting, blocked, or stale state to
18
- `ultra-init`. Planning an already active bounded change may continue with the
19
- baseline condition recorded as a warning. Ordinary convergence still requires
20
- approved adoption, and archive atomically reconciles revision and specification
21
- drift. An approved break-glass incident follows its recorded recovery contract and
22
- creates a blocking reconciliation gap at archive.
23
-
24
- Choose one input:
25
-
26
- - validated baseline specifications;
27
- - one active change packet;
28
- - a raw PRD through the approval-gated mode below.
29
-
30
- Ask only for product, scope, cost, or risk decisions that cannot be derived from
31
- current evidence. A material unresolved assumption blocks persistence.
32
-
33
- ## Planning rules
34
-
35
- 1. Trace acceptance through an entry point, domain behavior, side effects, and a
36
- user-observable or public seam.
37
- 2. Prefer a walking skeleton or `tracer_bullet` before horizontal layers.
38
- 3. Give each task one outcome, bounded ownership, explicit dependencies, required
39
- references, and one deterministic verification command.
40
- 4. Use the context budget as an attention signal. Prefer bounded excerpts, direct
41
- reads, or a smaller slice, but keep necessary files when correctness requires them.
42
- Budget overflow is a warning, never a reason to inflate a threshold or manufacture
43
- a smaller but incomplete contract.
44
- 5. Add integration checkpoints at actual boundaries, not after arbitrary task counts.
45
- 6. Put validation, errors, recovery, documentation, and migrations in the task that
46
- owns the behavior.
47
- 7. Reject scaffolding with no reachable consumer.
48
-
49
- Every persisted task must include its slice kind, public seam, verification command,
50
- acceptance evidence, ownership, dependencies, documentation impact, and linked change
51
- id when applicable.
52
-
53
- ## Baseline or change mode
54
-
55
- 1. Read the smallest authoritative references that define acceptance.
56
- 2. Build the task DAG in memory and check dependency and ownership conflicts.
57
- 3. Present the proposed outcome, execution order, risk concentration, and first live
58
- seam. Obtain approval if scope, cost, or delivery semantics change materially.
59
- 4. Persist approved tasks with `task.create`.
60
- 5. For change-linked tasks, compile `change.context` with the planning role and gate.
61
- Resolve every readiness blocker before calling a task executable.
62
- 6. Call `task.dependency_topo`; cycles and missing dependencies block completion.
63
- 7. Call `plan.export`, then verify the persisted result with `plan.get`.
64
- 8. Call `change.breadcrumb` when a change is active and return one next action.
65
-
66
- ## PRD mode
67
-
68
- 1. Read the approved PRD with the current host model and derive the proposed task
69
- objects using the `task.parse_prd` input schema. Do not invoke a second model or
70
- require a provider API key inside Ultra MCP.
71
- 2. Call `task.parse_prd` with those `tasks`, `dry_run: true`, and the active
72
- `change_id` when applicable. The MCP validates the graph but does not supply
73
- product judgment.
74
- 3. Show the proposed slices, topology, conflict surface, and cost estimate.
75
- 4. Require explicit approval; rejection performs no state write.
76
- 5. On approval, repeat with `dry_run: false`, the identical task objects, and the
77
- same change ownership; export
78
- the plan, and verify that the dry-run and persisted task identities agree.
79
-
80
- When one approved task is still too broad, derive its complete child graph with the
81
- current host model and call `task.expand` with the parent `id` and validated
82
- `children`. The MCP assigns parent, tag, and change ownership atomically. Never ask
83
- the MCP runtime to generate child content.
84
-
85
- ## Completion gate
86
-
87
- Planning is complete only when the DAG is valid, each task reaches a public seam, each
88
- verification command is executable, every change-linked context is ready, and no
89
- required documentation or decision remains unknown.
6
+ # Persist an executable plan
7
+
8
+ Use host reasoning for decomposition, tradeoffs, and approval. Use Ultra MCP for
9
+ workflow position, task contracts, graph validation, projection, and recovery.
10
+
11
+ ## Bind authority
12
+
13
+ 1. Call `system.doctor`, `baseline.get`, `change.list`, and `change.breadcrumb`.
14
+ 2. Require a current ready baseline for new ordinary work. Resume an already-authorized
15
+ active change when appropriate; an incident uses only its recorded break-glass
16
+ authority.
17
+ 3. Ensure exactly one active change owns the plan. For initial implementation, open a
18
+ standard or major change from the accepted baseline before creating tasks.
19
+ 4. Read `references/semantic-preflight.md`. Resolve every blocking Change decision and
20
+ complete the exact recorded bounded research selection before starting the plan.
21
+ 5. Resume the active `plan` workflow from `workflow.list`, or call `workflow.start`
22
+ with its `baseline_id`, `change_id`, subject, and source refs.
23
+
24
+ ## Plan through the durable steps
25
+
26
+ Record each completed step with `workflow.step`:
27
+
28
+ 1. `validate-baseline`: verify baseline and completed research provenance.
29
+ 2. `select-posture`: preserve the owner-approved scope and delivery posture. Never
30
+ infer an MVP, reduction, phase, or exclusion. Ask only when a proposed plan changes
31
+ accepted scope, cost, risk, compatibility, or delivery semantics.
32
+ 3. `analyze-requirements`: trace stable requirement ids to acceptance and public seams.
33
+ 4. `analyze-codebase`: inspect current entry points, consumers, patterns, state
34
+ authority, tests, deployment, and recovery paths before designing new structure.
35
+ 5. `design-slices`: design a walking skeleton and subsequent vertical slices. Every
36
+ slice must reach a real consumer; include validation, side effects, errors,
37
+ documentation, migration, observability, and recovery in the owning slice.
38
+ 6. `validate-dependencies`: validate ownership, missing dependencies, cycles, conflict
39
+ surfaces, and meaningful integration checkpoints.
40
+ 7. `approve-plan`: persist owner approval when the plan makes a material decision.
41
+
42
+ ## Persist complete task contracts
43
+
44
+ Call `task.create` for each approved task with:
45
+
46
+ - one observable `outcome` and stable `trace_to`;
47
+ - `slice_kind`, `public_seam`, and exact `verification_command`;
48
+ - structured `acceptance` items with their verification;
49
+ - bounded `context_refs` with reasons;
50
+ - resolved `docs_impact` and durable `ownership`;
51
+ - dependencies, affected files when known, estimates only when evidence supports them,
52
+ and the owning `change_id`.
53
+
54
+ Copy each Change acceptance id into at least one task acceptance item without changing
55
+ its meaning. Set `trace_to` to that accepted id, a current research semantic id, or a
56
+ real project-relative Markdown `path#anchor`. A quick profile has exactly one task.
57
+ The MCP derives the coverage matrix and rejects uncovered acceptance, orphan tasks,
58
+ stale research, and oversized quick plans.
59
+
60
+ Never read or write `.ultra/tasks.json` or generated context Markdown as authority.
61
+ The DB owns the task contract and the projector regenerates both views.
62
+ `persist-task-contracts` completes only after `task.get` reads every field back without
63
+ a contract blocker.
64
+
65
+ Call `task.dependency_topo` with the current `change_id`, then call
66
+ `plan.export` with `change_id`, `format: "json"`, and
67
+ `out_path: ".ultra/execution-plan.json"`. Export records `plan_exported`; it does
68
+ not approve the plan. Read the same change back with `plan.get`.
69
+ The exported artifact is change-bound and may not include tasks from another active
70
+ or historical change. Recompile `change.context`
71
+ for the first task; it derives its execution contract and context refs from DB and
72
+ rejects a conflicting prompt override. Missing required refs block readiness; context
73
+ size is advisory.
74
+
75
+ Record `verify-plan` with `.ultra/execution-plan.json` as its sole output, then call
76
+ `workflow.complete` with
77
+ `approval.approved_by` and `approval.approval_note`. Do not send a task summary: MCP
78
+ derives the complete task set from every task owned by the change. Completion
79
+ revalidates every task contract, change ownership, dependency existence, graph cycles,
80
+ the exact exported topology, approval, and current output digests; it also advances
81
+ the linked change workflow to context compilation.
82
+ Return the persisted topology, first task/public seam,
83
+ approval evidence, plan workflow id, and one `ultra-dev` route.
@@ -0,0 +1,18 @@
1
+ # Semantic planning preflight
2
+
3
+ Before task decomposition, read the normalized Change Contract and the current
4
+ change-bound research records.
5
+
6
+ 1. Resolve every blocking `unresolved_decision` or return to `ultra-change`.
7
+ 2. When research is recorded, verify one completed run has the same mode and selected
8
+ step set. Re-run stale or missing evidence through `ultra-research`.
9
+ 3. Build a coverage ledger from Change acceptance ids to task acceptance ids.
10
+ 4. Bind every task to an accepted id, semantic record id, semantic source ref, or real
11
+ Markdown anchor through `trace_to`.
12
+ 5. Check that every task reaches a public consumer and owns its error, documentation,
13
+ verification, and recovery obligations.
14
+ 6. Validate dependencies and ensure a quick profile contains exactly one task.
15
+
16
+ Treat the MCP completion result as the final planning gate. It derives the coverage
17
+ matrix from durable records and rejects unresolved decisions, missing research,
18
+ uncovered acceptance, orphan tasks, incomplete contracts, or invalid topology.
@@ -1,75 +1,102 @@
1
1
  ---
2
2
  name: ultra-research
3
- description: Turn uncertain product or architecture intent into evidence-backed baseline specifications with explicit decisions and traceable acceptance. Use when an Ultra project has unresolved requirements that are not ready for planning.
3
+ description: Establish or extend an evidence-backed Ultra product and architecture baseline through the complete semantic research workflow, with resumable step state and traceable outputs. Use when initialization routes to research, baseline evidence is incomplete, or the owner explicitly requests bounded research for an active change.
4
4
  ---
5
5
 
6
- # Build a validated baseline
6
+ # Establish research authority
7
7
 
8
- Research only the uncertainty that blocks a durable product, architecture, or delivery
9
- decision. Do not force a fixed discovery ceremony onto a well-defined change.
8
+ Use host reasoning for evidence gathering, product judgment, questions, and artifact
9
+ content. Use Ultra MCP for run selection, state transitions, output digests, blockers,
10
+ and baseline convergence. Never ask MCP to generate research content.
10
11
 
11
- ## Preflight
12
+ ## Bind the run
12
13
 
13
- 1. Require an initialized `.ultra/specs/` directory and call `baseline.get`. Route to
14
- `ultra-init` when state or the baseline is absent. Preserve its mode and id.
15
- 2. Read the current specification files and repository evidence before asking the
16
- user to repeat known facts.
17
- 3. Define the intended deliverable, unresolved decisions, and evidence standard.
18
- 4. Select only the research lanes that the uncertainty requires:
19
- - problem and product: `references/problem-product.md`;
20
- - users and scope: `references/users-scope.md`;
21
- - architecture: `references/architecture.md`;
22
- - quality and delivery: `references/quality-delivery.md`;
23
- - final traceability: `references/synthesis.md`.
14
+ 1. Call `baseline.get`. Route absent, migrated, unreadable, or corrupt authority to
15
+ `ultra-init` or `ultra-doctor` as reported.
16
+ 2. Call `workflow.list` for `kind: "research"` and the bound baseline or change. Resume
17
+ the active, blocked, or ready run; use `workflow.get` before doing more work.
18
+ 3. When no run exists:
19
+ - start `full` for an initial greenfield baseline;
20
+ - start `adoption` for a brownfield baseline;
21
+ - use `product`, `feature`, `architecture`, or `custom` only when the owner
22
+ explicitly selected that bounded scope for an active change.
24
23
 
25
- Read a reference completely only when its lane is selected. Do not load all lanes by
26
- default.
24
+ Never infer an MVP, reduced product posture, skipped step, or release phase. Full and
25
+ adoption modes execute all seventeen semantic steps. A custom run records every
26
+ excluded step and its selection reason in DB.
27
27
 
28
- ## Evidence discipline
28
+ ## Execute one recoverable step at a time
29
29
 
30
- - Prefer the current checkout and existing project artifacts for repository facts.
31
- - Browse only when a claim is external, unstable, or requires primary-source support.
32
- - Prefer official and primary sources; cite each consequential external claim near the
33
- statement it supports.
34
- - Separate observed facts, evidence-backed inferences, user decisions, and unresolved
35
- assumptions.
36
- - Do not manufacture confidence percentages, market numbers, personas, competitors,
37
- or options when evidence does not support them.
30
+ Read only the reference matching `workflow.next_step.step_id`:
38
31
 
39
- ## Workflow
32
+ | Step | Reference |
33
+ |---|---|
34
+ | `00-problem-validation` | `references/00-problem-validation.md` |
35
+ | `01-opportunity-discovery` | `references/01-opportunity-discovery.md` |
36
+ | `02-market-assessment` | `references/02-market-assessment.md` |
37
+ | `03-competitive-landscape` | `references/03-competitive-landscape.md` |
38
+ | `04-product-strategy` | `references/04-product-strategy.md` |
39
+ | `05-assumptions-validation` | `references/05-assumptions-validation.md` |
40
+ | `10-user-personas` | `references/10-user-personas.md` |
41
+ | `11-user-scenarios` | `references/11-user-scenarios.md` |
42
+ | `20-user-stories` | `references/20-user-stories.md` |
43
+ | `21-features-scope` | `references/21-features-scope.md` |
44
+ | `22-success-metrics` | `references/22-success-metrics.md` |
45
+ | `30-architecture-context` | `references/30-architecture-context.md` |
46
+ | `31-solution-strategy` | `references/31-solution-strategy.md` |
47
+ | `32-building-blocks` | `references/32-building-blocks.md` |
48
+ | `40-deployment` | `references/40-deployment.md` |
49
+ | `41-quality-risks` | `references/41-quality-risks.md` |
50
+ | `99-synthesis` | `references/99-synthesis.md` |
40
51
 
41
- 1. Build a short research agenda from the selected lanes and the decisions they must
42
- unlock.
43
- 2. Gather evidence before recommending a direction. Ask one concise question when a
44
- user decision is load-bearing; batch independent low-impact questions only when it
45
- improves flow.
46
- 3. Present material tradeoffs before recording a decision. Comparisons are appropriate
47
- only when real alternatives share meaningful criteria.
48
- 4. Update the relevant baseline specification sections. Preserve source links,
49
- decisions, rejected alternatives when useful, acceptance criteria, and explicit
50
- open questions. Do not duplicate the same narrative across several files.
51
- 5. Validate cross-document consistency and trace each required behavior from problem
52
- or constraint to acceptance and architecture.
53
- 6. Use `references/synthesis.md` for the completion check.
54
- 7. Record unresolved evidence as the baseline gap ledger: `baseline_blocker`,
55
- `documentation_drift`, `known_defect`, `technical_debt`, `unknown`, or
56
- `future_change`. Keep accepted non-blocking work out of the implementation backlog
57
- until the owner selects it.
58
- 8. Call `baseline.record` with the complete current specification list, bounded evidence
59
- references, actual verification results, provider metadata, explicit unknowns,
60
- classification, and the full gap ledger. Use the returned repository revision for
61
- convergence.
62
- 9. Present the baseline, open gaps, dirty-worktree state, and any known-red verification
63
- to the owner. After explicit approval, call `baseline.converge`, setting acceptance
64
- flags only for the exact known-red or dirty snapshot approved by the owner. Resolve
65
- deterministic blockers before routing.
52
+ For each selected step:
66
53
 
67
- ## Completion gate
54
+ 1. Inspect current repository and specification evidence before asking the owner to
55
+ repeat known facts. Browse only for unstable or external claims, using primary
56
+ sources where possible.
57
+ 2. Separate `Observed`, `Verified`, `Decided`, and `Unknown`. Ask one concise question
58
+ only when the answer changes scope, product intent, security, cost, or another
59
+ load-bearing decision.
60
+ 3. Update the relevant baseline specification or active change research artifact.
61
+ Preserve citations, decisions, drift, and unresolved gaps without duplicating prose.
62
+ 4. Write one immutable step report at
63
+ `.ultra/docs/research/<workflow-id>/<step-id>.md`. It must have a title and the
64
+ sections `Evidence`, `Specification updates`, and `Decisions and unknowns`. Link
65
+ specification anchors and external sources; do not copy transcripts or provider
66
+ payloads.
67
+ 5. Call `workflow.step` with `completed`, bounded evidence references, that step report
68
+ as `research-step-report`, material decisions, and one or more `semantic_records`.
69
+ Each record has a stable `id`, the step-specific `kind` and `attributes` named in
70
+ its reference, a status (`observed`, `verified`, `decided`, `accepted`, `unknown`,
71
+ or `not_applicable`), a concise summary, evidence refs, optional typed links, and a
72
+ project-relative `source_ref` using `path#anchor`. Use the immutable step report as
73
+ the source when later edits could change a shared specification. MCP verifies the
74
+ anchor and stores its digest; `not_applicable` requires an evidence-backed rationale.
75
+ 6. For `99-synthesis` in `full` or `adoption` mode, also bind the current
76
+ `discovery.md`, `product.md`, `architecture.md`, and `research-distillate.md` as
77
+ outputs. This freezes the exact researched baseline without making the reports a
78
+ second specification authority.
79
+ 7. If evidence or owner authority is missing, call `workflow.step` with `blocked` and
80
+ specific blocker codes. Resume that same step after resolution; never skip a
81
+ required step to obtain a ready state.
68
82
 
69
- Research is complete when the selected scope has enough evidence for planning, every
70
- material decision is recorded, required acceptance is testable, architecture respects
71
- known constraints, and unresolved items are either blocking or explicitly outside the
72
- accepted scope.
83
+ ## Converge
73
84
 
74
- Route a converged baseline to `ultra-plan`. Do not create business tasks, write raw
75
- SQLite, or maintain a second condensed specification that can drift from the baseline.
85
+ When all selected steps are ready, call `workflow.complete` and read the completed run
86
+ back. Missing or stale output blocks completion.
87
+
88
+ For initial or adoption research, call `baseline.record` with discovery, product, and
89
+ architecture specification refs; current repository revision and scope; bounded source,
90
+ docs, runtime, test, deployment, and external evidence; actual verification commands
91
+ and results; unknowns; the complete gap ledger; classification; and external provider
92
+ metadata references. Do not store prompts, transcripts, memory, or graph content.
93
+
94
+ Present the recorded revision, worktree snapshot, known failures, blockers, and gaps.
95
+ Only after explicit owner approval call `baseline.converge`. Accept known-red or a
96
+ dirty worktree only when that exact snapshot was approved. Convergence must verify the
97
+ completed full/adoption research run and current output digests.
98
+
99
+ Return the workflow id, all seventeen step-report paths for full/adoption research,
100
+ the four synthesis artifacts, baseline status, open gaps, approval state, and one exact
101
+ next route. A ready initial baseline routes to `ultra-change`; bounded change research
102
+ returns to its change breadcrumb and then `ultra-plan` when the research gate is ready.