ultra-builder-pro-cli 0.14.0 → 0.16.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 (163) 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 +77 -1
  8. package/README.md +46 -24
  9. package/adapters/_shared/codex-assets.cjs +6 -2
  10. package/adapters/_shared/file-ops.cjs +6 -2
  11. package/adapters/_shared/handbook.cjs +2 -1
  12. package/adapters/claude.js +3 -2
  13. package/adapters/codex.js +1 -0
  14. package/adapters/kimi.js +3 -2
  15. package/adapters/opencode.js +3 -2
  16. package/agents/review-coordinator.md +9 -6
  17. package/commands/ultra-change.md +1 -1
  18. package/commands/ultra-plan.md +1 -1
  19. package/commands/ultra-research.md +1 -1
  20. package/commands/ultra-think.md +2 -2
  21. package/docs/AGENT-CONTEXT.md +43 -19
  22. package/docs/ARCHITECTURE.md +54 -13
  23. package/docs/PLAN.zh-CN.md +4 -2
  24. package/docs/ROADMAP.md +10 -4
  25. package/docs/RUNTIME-COMPAT-MATRIX.md +4 -4
  26. package/docs/STATE-DB-ACCESS-POLICY.md +33 -29
  27. package/docs/USER-HANDBOOK-CONTRACT.md +8 -2
  28. package/docs/WORKFLOW-LIFECYCLE.md +342 -0
  29. package/hooks/README.md +6 -1
  30. package/hooks/health_check.py +12 -3
  31. package/hooks/subagent_tracker.py +52 -77
  32. package/mcp-server/hook-event.cjs +34 -0
  33. package/mcp-server/lib/archive-journal.cjs +17 -5
  34. package/mcp-server/lib/baseline-workflow.cjs +158 -18
  35. package/mcp-server/lib/change-workflow.cjs +598 -85
  36. package/mcp-server/lib/context-spine.cjs +305 -25
  37. package/mcp-server/lib/decision-dialogue.cjs +713 -0
  38. package/mcp-server/lib/doctor.cjs +42 -3
  39. package/mcp-server/lib/init-project.cjs +210 -16
  40. package/mcp-server/lib/plan-store.cjs +4 -1
  41. package/mcp-server/lib/pricing.cjs +7 -10
  42. package/mcp-server/lib/project-breadcrumb.cjs +15 -0
  43. package/mcp-server/lib/projector.cjs +57 -3
  44. package/mcp-server/lib/spec-learning.cjs +79 -2
  45. package/mcp-server/lib/state-db.cjs +168 -8
  46. package/mcp-server/lib/state-ops.cjs +160 -9
  47. package/mcp-server/lib/workflow-state.cjs +2305 -0
  48. package/mcp-server/server.cjs +215 -15
  49. package/orchestrator/daemon.cjs +1 -2
  50. package/orchestrator/dispatch-rules.cjs +5 -31
  51. package/orchestrator/planner/plan-builder.cjs +21 -12
  52. package/package.json +13 -3
  53. package/skills/ultra-change/SKILL.md +94 -80
  54. package/skills/ultra-change/references/change-contract.md +36 -0
  55. package/skills/ultra-deliver/SKILL.md +76 -79
  56. package/skills/ultra-deliver/references/baseline-reconciliation.md +20 -0
  57. package/skills/ultra-dev/SKILL.md +62 -59
  58. package/skills/ultra-doctor/SKILL.md +61 -82
  59. package/skills/ultra-init/SKILL.md +101 -103
  60. package/skills/ultra-init/references/brownfield-adoption.md +2 -2
  61. package/skills/ultra-plan/SKILL.md +99 -85
  62. package/skills/ultra-plan/references/semantic-preflight.md +18 -0
  63. package/skills/ultra-research/SKILL.md +102 -60
  64. package/skills/ultra-research/references/00-problem-validation.md +36 -0
  65. package/skills/ultra-research/references/01-opportunity-discovery.md +33 -0
  66. package/skills/ultra-research/references/02-market-assessment.md +30 -0
  67. package/skills/ultra-research/references/03-competitive-landscape.md +31 -0
  68. package/skills/ultra-research/references/04-product-strategy.md +32 -0
  69. package/skills/ultra-research/references/05-assumptions-validation.md +31 -0
  70. package/skills/ultra-research/references/10-user-personas.md +29 -0
  71. package/skills/ultra-research/references/11-user-scenarios.md +28 -0
  72. package/skills/ultra-research/references/20-user-stories.md +30 -0
  73. package/skills/ultra-research/references/21-features-scope.md +29 -0
  74. package/skills/ultra-research/references/22-success-metrics.md +28 -0
  75. package/skills/ultra-research/references/30-architecture-context.md +30 -0
  76. package/skills/ultra-research/references/31-solution-strategy.md +28 -0
  77. package/skills/ultra-research/references/32-building-blocks.md +28 -0
  78. package/skills/ultra-research/references/40-deployment.md +29 -0
  79. package/skills/ultra-research/references/41-quality-risks.md +28 -0
  80. package/skills/ultra-research/references/99-synthesis.md +35 -0
  81. package/skills/ultra-review/SKILL.md +63 -73
  82. package/skills/ultra-review/references/review-modes.md +27 -0
  83. package/skills/ultra-review/references/unified-schema.md +25 -0
  84. package/skills/ultra-review/scripts/review_wait.py +40 -3
  85. package/skills/ultra-status/SKILL.md +41 -41
  86. package/skills/ultra-test/SKILL.md +54 -55
  87. package/skills/ultra-think/SKILL.md +26 -12
  88. package/skills/ultra-think/references/decision-dialogue.md +130 -0
  89. package/skills/ultra-verify/SKILL.md +1 -1
  90. package/skills/ultra-verify/references/{confidence-system.md → evidence-status.md} +3 -3
  91. package/spec/cli-protocol.md +17 -3
  92. package/spec/mcp-tools.yaml +683 -64
  93. package/spec/schemas/baseline-reconciliation.v1.schema.json +73 -0
  94. package/spec/schemas/delivery-report.v1.schema.json +111 -0
  95. package/spec/schemas/mcp-tools.schema.json +1 -1
  96. package/spec/schemas/state-db.sql +140 -1
  97. package/spec/schemas/tasks.v4.5.schema.json +8 -1
  98. package/spec/schemas/test-report.v1.schema.json +194 -0
  99. package/ultra-tools/cli.cjs +1 -1
  100. package/ultra-tools/commands/migrate.cjs +3 -3
  101. package/ultra-tools/commands/status.cjs +228 -12
  102. package/.ultra-template/delivery-report.json +0 -9
  103. package/.ultra-template/test-report.json +0 -8
  104. package/adapters/_shared/tests/file-ops.test.cjs +0 -54
  105. package/adapters/_shared/tests/frontmatter.test.cjs +0 -47
  106. package/adapters/_shared/tests/handbook.test.cjs +0 -101
  107. package/adapters/_shared/tests/path-rewrite.test.cjs +0 -60
  108. package/adapters/_shared/tests/provenance.test.cjs +0 -133
  109. package/adapters/_shared/tests/resolve-target.test.cjs +0 -75
  110. package/adapters/_shared/tests/runtime-assets.test.cjs +0 -149
  111. package/adapters/_shared/tests/settings-merge.test.cjs +0 -85
  112. package/adapters/_shared/tests/validate.test.cjs +0 -30
  113. package/adapters/tests/claude.test.cjs +0 -138
  114. package/adapters/tests/codex-hook.test.cjs +0 -142
  115. package/adapters/tests/codex.test.cjs +0 -430
  116. package/adapters/tests/kimi-hook.test.cjs +0 -149
  117. package/adapters/tests/kimi.test.cjs +0 -259
  118. package/adapters/tests/opencode.test.cjs +0 -357
  119. package/mcp-server/lib/archive-journal.test.cjs +0 -35
  120. package/mcp-server/lib/baseline-workflow.test.cjs +0 -477
  121. package/mcp-server/lib/change-workflow.test.cjs +0 -971
  122. package/mcp-server/lib/context-spine.test.cjs +0 -93
  123. package/mcp-server/lib/doctor.test.cjs +0 -148
  124. package/mcp-server/lib/plan-store.test.cjs +0 -132
  125. package/mcp-server/lib/prd-parser.test.cjs +0 -82
  126. package/mcp-server/lib/project-breadcrumb.test.cjs +0 -112
  127. package/mcp-server/lib/runtime-state.test.cjs +0 -92
  128. package/mcp-server/lib/spec-learning.test.cjs +0 -67
  129. package/mcp-server/lib/state-db.test.cjs +0 -314
  130. package/mcp-server/lib/task-expander.test.cjs +0 -169
  131. package/mcp-server/lib/topo.test.cjs +0 -158
  132. package/mcp-server/tests/circuit-breaker.test.cjs +0 -125
  133. package/mcp-server/tests/commit-hash-flow.test.cjs +0 -117
  134. package/mcp-server/tests/concurrency-update.test.cjs +0 -96
  135. package/mcp-server/tests/concurrency.test.cjs +0 -112
  136. package/mcp-server/tests/db-ops.test.cjs +0 -121
  137. package/mcp-server/tests/init-project.test.cjs +0 -393
  138. package/mcp-server/tests/migrate.test.cjs +0 -232
  139. package/mcp-server/tests/projector.test.cjs +0 -162
  140. package/mcp-server/tests/server-contract.test.cjs +0 -1467
  141. package/mcp-server/tests/staleness.test.cjs +0 -190
  142. package/mcp-server/tests/state-db.test.cjs +0 -106
  143. package/mcp-server/tests/state-ops.test.cjs +0 -449
  144. package/mcp-server/tests/tagged-tasks.test.cjs +0 -163
  145. package/mcp-server/tests/telemetry.test.cjs +0 -219
  146. package/orchestrator/planner/plan-builder.test.cjs +0 -165
  147. package/orchestrator/tests/auto-merge.test.cjs +0 -216
  148. package/orchestrator/tests/daemon.test.cjs +0 -311
  149. package/orchestrator/tests/dispatch-rules.test.cjs +0 -124
  150. package/orchestrator/tests/parallel-orchestrator.test.cjs +0 -233
  151. package/orchestrator/tests/phase-8b-gate.test.cjs +0 -183
  152. package/orchestrator/tests/recovery.test.cjs +0 -190
  153. package/orchestrator/tests/session-runner.test.cjs +0 -314
  154. package/orchestrator/tests/skill-miner.test.cjs +0 -147
  155. package/orchestrator/tests/worktree-manager.test.cjs +0 -148
  156. package/skills/ultra-research/references/architecture.md +0 -38
  157. package/skills/ultra-research/references/problem-product.md +0 -39
  158. package/skills/ultra-research/references/quality-delivery.md +0 -34
  159. package/skills/ultra-research/references/synthesis.md +0 -38
  160. package/skills/ultra-research/references/users-scope.md +0 -40
  161. package/ultra-tools/legacy-memory.test.cjs +0 -80
  162. package/ultra-tools/status-command.test.cjs +0 -181
  163. package/ultra-tools/system-command.test.cjs +0 -309
@@ -53,7 +53,7 @@ the supported hosts share.
53
53
  | Layer | Role | Form |
54
54
  |--------------|----------------------------------------------|-------------------------------------------------------|
55
55
  | **skill** | knowledge carrier; tells the runtime *what to do* | `skills/<name>/SKILL.md` discovered natively by all supported runtimes |
56
- | **MCP** | authoritative workflow-state and Context Spine API | stdio MCP server exposing 36 live tools across baseline/task/session/change/system/plan families in [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
56
+ | **MCP** | authoritative workflow-state, decision, and Context Spine API | stdio MCP server exposing 50 live tools across task/session/baseline/change/decision/workflow/system/plan families in [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
57
57
  | **CLI** | explicit initialization, recovery, diagnostics, and orchestration | `ultra-tools` / `ubp-orchestrator`; only commands listed by `--help` are executable (see [`spec/cli-protocol.md`](../spec/cli-protocol.md)) |
58
58
 
59
59
  Why three: skills give us behavior portability across runtimes; MCP gives
@@ -70,11 +70,11 @@ RPC, and host-native loaders own resolution and invocation.
70
70
 
71
71
  All durable Ultra workflow state lives in one SQLite file with WAL enabled. Schema is
72
72
  fixed in [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) and
73
- covers seventeen tables:
73
+ covers twenty-one tables:
74
74
 
75
75
  | Table | Holds | Phase |
76
76
  |--------------------|---------------------------------------------------|-------|
77
- | `baselines` | repository classification, greenfield/brownfield adoption, worktree snapshot, specs, evidence, verification, gap ledger, and approval | 12 |
77
+ | `baselines` | repository classification, greenfield/brownfield adoption, worktree snapshot, specs, evidence, verification, gap ledger, persisted known-red acceptance, and approval | 12→14 |
78
78
  | `tasks` | task rows — id, status, deps, files_modified, … | 2 |
79
79
  | `events` | append-only event stream; `id` is subscription cursor (D31) | 2 |
80
80
  | `sessions` | execution sessions, **including lease + heartbeat fields** (D32) | 4.5 |
@@ -83,7 +83,7 @@ covers seventeen tables:
83
83
  | `telemetry` | per-session token / cost / tool-call counters | 6 |
84
84
  | `specs_refs` | spec change tracking → staleness propagation | 5 |
85
85
  | `circuit_breaker` | bounded retry and halt state for failed tasks | 5 |
86
- | `changes` | continuous feature/fix/incident lifecycle and incident baseline bypass | 12 |
86
+ | `changes` | continuous feature/fix/incident lifecycle, alignment-thread link, and incident baseline bypass | 12→16 |
87
87
  | `artifacts` | intent/context/verification artifact registry | 8C |
88
88
  | `context_snapshots`| role/gate context, readiness, budget, execution seam, hashes, git head, provider refs | 10 |
89
89
  | `spec_learning_candidates` | approval-gated implementation discoveries for baseline convergence | 10 |
@@ -91,6 +91,10 @@ covers seventeen tables:
91
91
  | `incidents` | structured runtime failures and resolutions | 8C |
92
92
  | `projection_jobs` | durable projection outbox/retry state | 8C |
93
93
  | `event_consumers` | durable monotonic consumer cursors | 8C |
94
+ | `workflow_runs` | init/research/plan/change/dev/test/review/deliver run authority, position, blockers, approval, and derived summary | 13 |
95
+ | `workflow_steps` | ordered step state, evidence, decisions, immutable output paths, and recorded SHA-256 digests | 13 |
96
+ | `decision_threads` | baseline/change/workflow-bound owner-agent alignment, interaction mode, normalized summary, and checkpoint authority | 16 |
97
+ | `decision_items` | one-at-a-time owner choices, evidence, recommendations, durable effects, resolutions, delegation, deferral, and supersession history | 16 |
94
98
 
95
99
  Two rules make this work:
96
100
 
@@ -103,12 +107,16 @@ Two rules make this work:
103
107
  2. **Single writer for mutable tables, multi-writer for `events`.**
104
108
  `.ultra/state.db` opens in WAL with `busy_timeout=5000`. The MCP
105
109
  server holds the single writer connection for `baselines`, `tasks`, `sessions`,
106
- `changes`, `context_snapshots`, `spec_learning_candidates`, `telemetry`,
110
+ `changes`, `decision_threads`, `decision_items`, `workflow_runs`, `workflow_steps`, `artifacts`, `context_snapshots`,
111
+ `spec_learning_candidates`, `incidents`, `projection_jobs`, `telemetry`,
107
112
  `specs_refs`, and `migration_history`; the CLI calls
108
113
  those tools over stdio rather than opening its own writer. The
109
114
  `events` table is append-only and explicitly multi-writer — CLI and
110
115
  orchestrator processes append directly to it under the same WAL +
111
116
  `busy_timeout` discipline, since independent INSERTs do not conflict.
117
+ External writers and public `task.append_event` may append observations only;
118
+ lifecycle event names are emitted by the mutation that owns the corresponding
119
+ DB transition and no event row can substitute for that transition.
112
120
  In `spec/mcp-tools.yaml` this split is captured by `writer_role: mcp`
113
121
  (must go through the MCP server) versus `writer_role: any` (any
114
122
  process may execute). Full policy lives in
@@ -143,20 +151,46 @@ produce a pre-migration backup. Compatibility state never grants baseline approv
143
151
  references, bounded repository/runtime evidence, actual verification results,
144
152
  known unknowns, repository branch and worktree snapshot, the categorized gap ledger,
145
153
  and metadata-only external provider references, and
146
- `baseline.converge` records explicit owner approval. A ready baseline is replaced
147
- only by an explicit re-adoption, preserving the superseded row for recovery.
154
+ `baseline.converge` records explicit owner approval, including a durable
155
+ `known_red_accepted` decision when applicable. Read paths continuously revalidate
156
+ ready authority: scope, three specifications, source/runtime evidence, verification,
157
+ known-red rationale and acceptance, research provenance and output digests, repository
158
+ revision/worktree state, blocking gaps and unknowns, approver, and convergence time.
159
+ A row cannot become trusted merely because its stored status says `ready`. A ready
160
+ baseline is replaced only by an explicit re-adoption, preserving the superseded row
161
+ for recovery.
148
162
  For a selected monorepo scope, the worktree digest and dirty-file list include only
149
163
  that scope; out-of-scope changes remain visible repository context but cannot be
150
164
  accepted implicitly by `accept_dirty_worktree`.
151
165
 
152
- New ordinary changes require a healthy `ready` baseline. A change that was already
153
- active may continue with baseline drift surfaced as a warning. A new incident can
166
+ New ordinary changes require a healthy `ready` baseline. An active ordinary change may
167
+ continue through only the expected HEAD/worktree/spec/source drift created after its
168
+ durable `bind-baseline` step; loss of ready approval, missing evidence, blocking gaps,
169
+ or any other structural defect stops task/context/stage progression. A new incident can
154
170
  start on an unhealthy baseline only with an explicit reason and approver stored in
155
171
  `baseline_bypass_json`. Ordinary convergence and archive reconcile HEAD, worktree,
156
172
  and tracked-spec drift atomically. Break-glass incident archive creates an open
157
173
  blocking reconciliation gap, so incident recovery can finish without falsely marking
158
174
  the project baseline healthy.
159
175
 
176
+ ### Human-agent decision authority
177
+
178
+ Ultra separates autonomous evidence work from owner decision authority. The host reads
179
+ the repository, runtime, tests, and primary sources first, then exposes only the earliest
180
+ unresolved load-bearing choice. `decision.open` stores the recommendation, credible
181
+ alternatives, evidence refs, and durable effects; a partial unique index guarantees one
182
+ current question per thread. The host ends that turn and waits.
183
+
184
+ The next response becomes a normalized owner decision, explicit reversible delegation,
185
+ or consequence-bearing deferral. Prompts and transcripts are never persisted. A coherent
186
+ cluster moves through prepare/confirm checkpointing, which binds an owner-approved
187
+ decision digest to the current specification, Change Contract, alignment, or plan artifact.
188
+ Matching workflow steps and completion fail closed until the checkpoint is confirmed.
189
+ Supersession preserves prior history and reopens alignment instead of silently editing an
190
+ old decision. The shared procedure lives in
191
+ `skills/ultra-think/references/decision-dialogue.md`; status, breadcrumb, and doctor expose
192
+ only the current recovery surface.
193
+
160
194
  ## 4. Continuous changes — the daily unit of convergence
161
195
 
162
196
  After the initial baseline delivery, every fix, feature, redesign, or incident
@@ -167,7 +201,7 @@ active -> blocked -> active -> ready -> archived
167
201
  | |
168
202
  ├─ intent + delta + plan └─ verification + baseline reconciliation
169
203
  ├─ linked tasks
170
- ├─ context-manifest v2 (role + gate + readiness + execution seam)
204
+ ├─ immutable context snapshots (role + gate + readiness + execution seam)
171
205
  └─ spec-learning candidates (proposed -> approved/rejected -> applied)
172
206
  ```
173
207
 
@@ -178,17 +212,23 @@ impact, and no open incident. Memory and graph payloads never enter Ultra;
178
212
 
179
213
  ### Context Spine
180
214
 
181
- Context Manifest v2 is the handoff contract between planning, implementation,
182
- checking, review, convergence, and recovery. Each snapshot records:
215
+ Context Manifest v2 is the immutable handoff contract between planning,
216
+ implementation, checking, review, convergence, and recovery. Each snapshot records:
183
217
 
184
218
  - one role (`plan`, `implement`, `check`, or `review`) and lifecycle gate;
185
219
  - required context references with local digests and reasons;
186
220
  - readiness blockers for missing/stale required references or an incomplete
187
221
  execution contract;
188
222
  - advisory attention budgets (12 files / about 12k tokens / 40% by default);
189
- - an execution contract (`slice_kind`, public seam, exact verification command);
223
+ - a DB-derived execution contract (`slice_kind`, public seam, exact verification command);
190
224
  - one deterministic next action.
191
225
 
226
+ Prompt input may identify the intended role/gate, add bounded reference candidates,
227
+ and lower advisory budgets. It cannot supply or override the task seam, verification
228
+ command, task context references, evidence digest, gate verdict, workflow summary, or
229
+ next action. Critical change/dev/test/review/deliver workflow steps record the matching
230
+ snapshot as an output; test, review, and delivery reports carry its digest forward.
231
+
192
232
  `change.breadcrumb` derives the compact current position from state.db. Session,
193
233
  edit, resume, and OpenCode lifecycle hooks invoke one bundled read-only reader
194
234
  and inject only this breadcrumb, never the intent body,
@@ -315,6 +355,7 @@ shippable; downstream slip never blocks an earlier release.
315
355
  | Exact SQLite schema? | [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) |
316
356
  | What does a tasks.json look like after projection? | [`spec/fixtures/valid/tasks.v4.5.json`](../spec/fixtures/valid/tasks.v4.5.json) |
317
357
  | Phase-by-phase work breakdown + decision log | [`docs/PLAN.zh-CN.md`](./PLAN.zh-CN.md) |
358
+ | When does each workflow write, invalidate, and converge state? | [`docs/WORKFLOW-LIFECYCLE.md`](./WORKFLOW-LIFECYCLE.md) |
318
359
 
319
360
  ## 10. Verifying the architecture
320
361
 
@@ -10,8 +10,10 @@
10
10
  > Kimi Code 采用各自 native plugin 呈现,其他旧 runtime adapter 已退役。下文所有与此冲突的
11
11
  > memory/hindsight 章节仅作为历史实施记录,不再是当前需求或运行时契约。
12
12
 
13
- **当前状态**:v0.13.0;四宿主 native plugin、36 个 live MCP tool、
14
- schema 12.0(17 表)、portable Skill authoring contract、双轴 review、
13
+ **当前状态**:v0.16.0;四宿主 native plugin、50 个 live MCP tool、
14
+ schema 16.0(21 表)、one-question owner-agent decision dialogue、artifact checkpoint、
15
+ workflow alignment gate、typed research semantics、complete Change Contract、
16
+ acceptance coverage、mode-bound 双轴 review、verified learning/reconciliation provenance、
15
17
  Context Spine v2 / breadcrumb / spec-learning、持续 change/context/convergence/doctor、incident debug lane、
16
18
  checkpoint 恢复消费与跨宿主安装 provenance/doctor 已落地;npm 发布由
17
19
  `v*.*.*` tag 触发。以下 Phase 0-9 正文保留为 2026-04 的实施历史,不再作为
package/docs/ROADMAP.md CHANGED
@@ -13,7 +13,7 @@ sharing one authoritative workflow store.
13
13
 
14
14
  **Distribution channels (v1.0)**: npm · Homebrew · pip.
15
15
 
16
- **Release line**: `0.11.x`; every release is gated by `npm run verify:release`.
16
+ **Release line**: `0.16.x`; every release is gated by `npm run verify:release`.
17
17
 
18
18
  ---
19
19
 
@@ -45,24 +45,29 @@ sharing one authoritative workflow store.
45
45
  | 8C | Continuous change packets + context compiler + convergence + doctor | ✅ done (D52) |
46
46
  | 10 | Context Spine v2 + breadcrumb + fresh-context budget + spec learning + two-axis review | ✅ done |
47
47
  | 11 | Greenfield/brownfield baseline adoption + advisory context budgets + convergence gate | ✅ done |
48
+ | 12 | Repository evidence snapshots + gap ledger + migration re-adoption + incident governance | ✅ done |
49
+ | 13 | Durable init-to-delivery workflows + task execution contracts + immutable stage evidence | ✅ done |
50
+ | 16 | Resumable one-question owner-agent decisions + artifact checkpoints + workflow gates | ✅ done |
48
51
  | 9 | Release pipeline | npm tag publishing live; Homebrew / pip not implemented |
49
52
 
50
53
  ## What is in the repo today
51
54
 
52
55
  ```
53
56
  spec/ ← Phase 1 single source of truth
54
- ├── mcp-tools.yaml (36 live tools across 6 families)
57
+ ├── mcp-tools.yaml (50 live tools across 8 families)
55
58
  ├── cli-protocol.md (CLI ↔ MCP mapping table)
56
59
  ├── schemas/ (state-db.sql + 4 JSON schemas)
57
60
  ├── fixtures/{valid,invalid}/ (+ v4.4-project for migration)
58
61
  └── scripts/test-all.cjs (npm run test:spec — 7 validation stages)
59
62
 
60
63
  mcp-server/ ← Phase 2 authoritative state layer
61
- ├── server.cjs (stdio MCP server, 36 baseline/task/session/change/system/plan tools)
64
+ ├── server.cjs (stdio MCP server, 50 task/session/baseline/change/decision/workflow/system/plan tools)
62
65
  ├── lib/
63
66
  │ ├── state-db.cjs (SQLite + WAL + pragmas)
64
67
  │ ├── state-ops.cjs (full write API, status state machine)
65
68
  │ ├── baseline-workflow.cjs (project adoption + approval + reconciliation)
69
+ │ ├── decision-dialogue.cjs (one-question authority + checkpoint gates)
70
+ │ ├── workflow-state.cjs (ordered stage runs, evidence, output digests, and gates)
66
71
  │ └── projector.cjs (state.db → tasks.json + context md)
67
72
  └── tests/ (npm run test:state)
68
73
 
@@ -70,7 +75,7 @@ ultra-tools/ ← CLI fallback, migration, and diagnostics
70
75
  ├── cli.cjs
71
76
  └── commands/
72
77
  ├── db.cjs (init/checkpoint/vacuum/integrity/backup)
73
- ├── migrate.cjs (v4.4 projection → v4.5 authority; v4.5 projection → schema 12; dry/rollback)
78
+ ├── migrate.cjs (v4.4 projection → v4.5 authority; v4.5 projection → current schema; dry/rollback)
74
79
  └── legacy-memory.cjs (explicit inspect/archive/confirmed prune)
75
80
 
76
81
  bin/install.js ← multi-runtime installer
@@ -81,6 +86,7 @@ hooks/ ← 7 executable workflow hooks + shared Context Spi
81
86
  docs/
82
87
  ├── PLAN.zh-CN.md historical phase plan + decision log
83
88
  ├── ARCHITECTURE.md Phase 1 single-page entry point
89
+ ├── WORKFLOW-LIFECYCLE.md baseline classification + DB transition contract
84
90
  ├── AGENT-CONTEXT.md Phase 3 canonical runtime context contract
85
91
  ├── USER-HANDBOOK-CONTRACT.md managed CLAUDE.md / AGENTS.md boundary
86
92
  ├── RUNTIME-COMPAT-MATRIX.md Phase 4 runtime capability matrix
@@ -71,7 +71,7 @@ they do not deny edits or stop active incident work.
71
71
  | Capability | Claude Code | OpenCode | Codex | Kimi Code 0.26+ |
72
72
  |---|---|---|---|---|
73
73
  | stdio MCP registration | plugin `.mcp.json` | `opencode.json` local MCP entry | plugin `.mcp.json` | plugin `mcpServers` entry |
74
- | Live/declared contracts | 36 | 36 | 36 | 36 |
74
+ | Live/declared contracts | 50 | 50 | 50 | 50 |
75
75
  | Greenfield/brownfield baseline adoption | FULL | FULL | FULL | FULL |
76
76
  | Context Spine v2 / breadcrumb | FULL | FULL, same bundled read-only DB reader as every hook | FULL | FULL |
77
77
  | Approval-gated spec learning | FULL | FULL | FULL | FULL |
@@ -79,7 +79,7 @@ they do not deny edits or stop active incident work.
79
79
  | Durable authority | project `.ultra/state.db` | project `.ultra/state.db` | project `.ultra/state.db` | project `.ultra/state.db` |
80
80
  | Ultra memory API | N/A | N/A | N/A | N/A |
81
81
 
82
- All 36 `baseline.*`, `task.*`, `session.*`, `change.*`, `system.*`, and `plan.*` operations
82
+ All 50 `task.*`, `session.*`, `baseline.*`, `change.*`, `decision.*`, `workflow.*`, `system.*`, and `plan.*` operations
83
83
  registered by `mcp-server/server.cjs` are live. Review, impact discovery, skill
84
84
  loading, and user interaction remain host-native surfaces.
85
85
 
@@ -126,9 +126,9 @@ records. Uninstall refuses an unmanaged or conflicting root.
126
126
 
127
127
  | Capability | Contract |
128
128
  |---|---|
129
- | Current state schema | `12.0` |
129
+ | Current state schema | `16.0` |
130
130
  | Runtime values | `claude`, `opencode`, `codex`, `kimi` |
131
- | Upgrade from earlier schema | preserves runtime rows, adds Context Spine state through 10.0, authoritative baseline adoption in 11.0, then runtime constraint compatibility in 12.0 |
131
+ | Upgrade from earlier schema | preserves runtime rows, adds Context Spine state through 10.0, authoritative baseline adoption in 11.0, repository evidence in 12.0, durable workflows in 13.0, continuous baseline revalidation in 14.0, typed research semantics and verified reconciliation in 15.0, then resumable owner-agent decision threads, artifact checkpoints, and workflow alignment gates in 16.0 |
132
132
  | Preservation gate | rows, IDs, indexes, foreign keys, telemetry, incidents, and migration history remain intact |
133
133
  | Failure behavior | rollback; no partially upgraded authority database |
134
134
 
@@ -4,17 +4,18 @@
4
4
  > risks R21 / R25.
5
5
 
6
6
  `.ultra/state.db` is the only authoritative state store for baselines, changes,
7
- tasks, events, sessions, incidents, projections, telemetry, and spec references
7
+ decision threads/items, tasks, workflow runs/steps, events, sessions, incidents,
8
+ projections, telemetry, and spec references
8
9
  (D18, D52, D54). Every process
9
10
  that touches it must follow the rules below; deviations are bugs.
10
11
 
11
12
  ## 1. Three-role write matrix
12
13
 
13
- | Role | tasks | baselines | change/artifact state | events | sessions | telemetry | specs_refs | migration_history |
14
- |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
15
- | **MCP server** (single writer for mutables) | RW | RW | RW | RW | RW | RW | RW | RW |
16
- | **CLI** (`ultra-tools …`) | R | RW (init only) | R | RW (append-only) | R | R | R | RW (migration only) |
17
- | **Orchestrator daemon** | R | R | R | RW | RW | RW | RW | R |
14
+ | Role | tasks | baselines | change/workflow/artifact state | decisions | events | sessions | telemetry | specs_refs | migration_history |
15
+ |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
16
+ | **MCP server** (single writer for mutables) | RW | RW | RW | RW | RW | RW | RW | RW | RW |
17
+ | **CLI** (`ultra-tools …`) | R | RW (init only) | R | R | RW (append-only) | R | R | R | RW (migration only) |
18
+ | **Orchestrator daemon** | R | R | R | R | RW | RW | RW | RW | R |
18
19
 
19
20
  - **R** = read-only;
20
21
  - **RW** = read + write;
@@ -31,7 +32,11 @@ write API for normal task, change, session, or baseline lifecycle updates.
31
32
  The append-only carve-out for `events` exists because `events.id INTEGER
32
33
  PRIMARY KEY AUTOINCREMENT` makes concurrent inserts collision-free under
33
34
  WAL + `busy_timeout`. This lets hooks and short-lived CLI invocations
34
- record audit events without paying the cost of a full MCP round trip.
35
+ record audit observations without paying the cost of a full MCP round trip.
36
+ It does not grant lifecycle authority: external writers and public
37
+ `task.append_event` use the published observation allowlist, while lifecycle event
38
+ names are emitted only inside the mutation that owns the corresponding state change.
39
+ Consumers must verify mutable rows rather than infer success from an event name.
35
40
 
36
41
  ## 2. Connection discipline
37
42
 
@@ -40,31 +45,27 @@ Every process **must**:
40
45
  1. Open the database with WAL + `busy_timeout=5000` + `foreign_keys=ON`.
41
46
  Use `mcp-server/lib/state-db.cjs` `openStateDb` so the pragmas are
42
47
  applied uniformly.
43
- 2. Wrap every write in `BEGIN IMMEDIATE` (use the helper `withWrite(db,
44
- fn)` once Phase 2.3 lands; until then call `db.transaction(fn)()` and
45
- know that better-sqlite3 promotes to IMMEDIATE on the first write).
46
- 3. Retry up to **3 times** on `SQLITE_BUSY`, with exponential backoff
47
- starting at 25 ms. Each retry must re-issue the full transaction —
48
- never partially commit.
48
+ 2. Wrap every mutable state operation with `state-ops.cjs` `tx(db, fn)`. The
49
+ helper calls better-sqlite3's immediate transaction variant, so the writer
50
+ lock is acquired before user code runs and the whole operation rolls back on
51
+ failure.
52
+ 3. Retry the complete transaction up to **10 attempts** on `SQLITE_BUSY`, using
53
+ decorrelated jitter from a 50 ms base with a 2 s cap. Never retry only a
54
+ suffix of a failed transaction or preserve partial state.
49
55
  4. Close the connection in a `finally` block. WAL files (`-wal`,
50
56
  `-shm`) are reclaimed on the last writer's close.
51
57
 
52
58
  Reads never need explicit transactions; better-sqlite3 reads observe a
53
59
  consistent snapshot under WAL.
54
60
 
55
- ## 3. WAL fallback
61
+ ## 3. WAL requirement
56
62
 
57
- WAL is **unsafe on NFS / SMB / certain Docker bind mounts** (R21). When
58
- `.ultra/state.db` resides on such a filesystem the orchestrator must
59
- either:
60
-
61
- - refuse to start (preferred — surfaces the deployment problem early), or
62
- - downgrade to `PRAGMA journal_mode = DELETE` and warn loudly. Concurrent
63
- writers fall back to short-burst contention; throughput drops but
64
- correctness holds.
65
-
66
- Detection happens at boot: `statvfs` of `.ultra/state.db`'s mount;
67
- `f_type` ∈ `{NFS_SUPER_MAGIC, SMB_SUPER_MAGIC}` ⇒ refuse / downgrade.
63
+ WAL is part of the authority contract, not an optional performance setting.
64
+ `openStateDb` asks SQLite to enable WAL and checks the actual returned mode. If
65
+ the storage layer returns anything else, startup fails with
66
+ `STATE_DB_WAL_UNAVAILABLE`. Ultra does not silently downgrade to a different
67
+ concurrency model. Move `.ultra/state.db` to storage that supports SQLite WAL or
68
+ resolve the mount/runtime constraint before retrying.
68
69
 
69
70
  ## 4. Where each table is owned
70
71
 
@@ -73,9 +74,11 @@ Detection happens at boot: `statvfs` of `.ultra/state.db`'s mount;
73
74
  | `baselines` | MCP server (`baseline.start` / `baseline.record` / `baseline.converge`); initialization and legacy-projection migration may create only the first draft or compatibility row |
74
75
  | `tasks` | MCP server (`task.create` / `task.update` / `task.delete`) |
75
76
  | `changes` | MCP server (`change.create` / `change.update` / `change.converge` / `change.archive`) |
77
+ | `decision_threads`, `decision_items` | MCP server (`decision.thread_start` / `decision.open` / `decision.resolve` / `decision.delegate` / `decision.defer` / `decision.supersede` / `decision.checkpoint`); only normalized choices and checkpoints are stored, never prompts or transcripts |
78
+ | `workflow_runs`, `workflow_steps` | MCP server (`workflow.start` / `workflow.step` / `workflow.complete`); skills provide evidence inputs but never write rows directly |
76
79
  | `artifacts`, `context_snapshots`, `spec_learning_candidates`, `trace_links` | MCP server through change lifecycle tools |
77
80
  | `incidents`, `projection_jobs`, `event_consumers`, `circuit_breaker` | MCP server; backup-first doctor recovery may perform only documented mechanical transitions |
78
- | `events` | MCP server **and** any process via append-only INSERT |
81
+ | `events` | MCP server for lifecycle events; approved processes and `task.append_event` for allowlisted append-only observations |
79
82
  | `sessions` | MCP server (`session.spawn` / `session.close` / `session.heartbeat`); orchestrator may write status transitions |
80
83
  | `telemetry` | MCP server (collected from tool-call wrappers); orchestrator may dump bulk samples |
81
84
  | `specs_refs` | MCP server (rebuilt on `spec_changed` event); orchestrator may rebuild |
@@ -110,6 +113,7 @@ The contract on this page is enforced by:
110
113
  appending to `events` simultaneously; asserts no `SQLITE_BUSY` escapes
111
114
  the retry loop and the resulting `events.id` sequence has no gaps and
112
115
  no duplicates.
113
- - Phase 2.3 will add `concurrency-update.test.cjs` — 20 worker threads
114
- driving `task.update` against disjoint task ids, verifying serialized
115
- writes through the MCP server.
116
+ - `mcp-server/tests/state-ops.test.cjs` — immediate transactions, rollback,
117
+ status transitions, task contracts, and event coupling.
118
+ - `mcp-server/lib/workflow-state.test.cjs` — ordered workflow transitions,
119
+ evidence/output requirements, blocking/resume, and cross-stage gates.
@@ -7,8 +7,8 @@ only one small managed section describing its runtime boundary.
7
7
  ## Source and render targets
8
8
 
9
9
  `adapters/_shared/handbook.cjs` is the canonical source. It renders the common
10
- authority, baseline adoption, Context Spine, specification-learning, memory, hook, agent, and
11
- package boundaries with host-native command syntax:
10
+ authority, baseline adoption, decision dialogue, Context Spine, specification-learning,
11
+ memory, hook, agent, and package boundaries with host-native command syntax:
12
12
 
13
13
  | Runtime | Default target | Main invocation form |
14
14
  |---|---|---|
@@ -31,6 +31,12 @@ a blocking reconciliation gap; hooks inject only the DB-derived
31
31
  axis blocks convergence. Detailed procedures remain in the plugin skills so user
32
32
  handbooks do not accumulate duplicated prompt sediment.
33
33
 
34
+ The decision boundary is intentionally short but normative: project-bound owner
35
+ choices use one resumable DB-backed thread; the host resolves observable facts first,
36
+ presents only one current decision with evidence and a recommendation, and stores the
37
+ normalized result rather than conversation text. Matching workflows remain gated until
38
+ blocking choices are resolved and the owner-approved artifact checkpoint is current.
39
+
34
40
  ## Managed-block contract
35
41
 
36
42
  The owned content is bounded by: