ultra-builder-pro-cli 0.23.0 → 0.24.1

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 (95) hide show
  1. package/.ultra-template/docs/research/README.md +4 -4
  2. package/.ultra-template/tasks/tasks.json +4 -2
  3. package/CHANGELOG.md +72 -0
  4. package/README.md +55 -39
  5. package/adapters/_shared/codex-assets.cjs +121 -65
  6. package/adapters/_shared/interaction-contract.cjs +7 -1
  7. package/adapters/_shared/provenance.cjs +7 -2
  8. package/adapters/_shared/runtime-assets.cjs +3 -2
  9. package/adapters/_shared/runtime-native.cjs +132 -0
  10. package/adapters/claude.js +60 -30
  11. package/adapters/codex.js +178 -81
  12. package/adapters/grok.js +372 -0
  13. package/adapters/kimi.js +7 -3
  14. package/adapters/opencode.js +210 -32
  15. package/agents/code-reviewer.md +4 -2
  16. package/agents/debugger.md +4 -1
  17. package/agents/review-code.md +7 -3
  18. package/agents/review-comments.md +7 -4
  19. package/agents/review-coordinator.md +11 -7
  20. package/agents/review-design.md +8 -4
  21. package/agents/review-errors.md +8 -4
  22. package/agents/review-spec.md +8 -5
  23. package/agents/review-tests.md +7 -4
  24. package/agents/tdd-runner.md +5 -2
  25. package/bin/install.js +9 -4
  26. package/bin/orchestrator.js +4 -13
  27. package/docs/AGENT-CONTEXT.md +143 -229
  28. package/docs/ARCHITECTURE.md +205 -494
  29. package/docs/ARTIFACT-AUTHORITY.md +35 -28
  30. package/docs/LEGACY-CLI-CROSSWALK.md +1 -1
  31. package/docs/PLUGIN-ISOLATION-CONTRACT.md +12 -9
  32. package/docs/ROADMAP.md +85 -110
  33. package/docs/RUNTIME-COMPAT-MATRIX.md +139 -175
  34. package/docs/SKILL-AUTHORING.md +3 -3
  35. package/docs/STATE-DB-ACCESS-POLICY.md +13 -8
  36. package/docs/WORKFLOW-LIFECYCLE.md +189 -448
  37. package/hooks/README.md +11 -8
  38. package/hooks/active_task_context.py +16 -16
  39. package/hooks/adapters/grok.py +134 -0
  40. package/hooks/{context_spine.py → context_envelope.py} +26 -22
  41. package/hooks/health_check.py +29 -34
  42. package/hooks/pre_stop_check.py +22 -12
  43. package/hooks/subagent_tracker.py +1 -1
  44. package/hooks/workflow_checkpoint.py +14 -13
  45. package/hooks/workflow_context.py +11 -12
  46. package/hooks/workflow_resume.py +14 -13
  47. package/mcp-server/{breadcrumb.cjs → hook-context.cjs} +7 -9
  48. package/mcp-server/lib/baseline-workflow.cjs +108 -82
  49. package/mcp-server/lib/canonical-json.cjs +19 -0
  50. package/mcp-server/lib/change-authority.cjs +26 -0
  51. package/mcp-server/lib/change-workflow.cjs +630 -45
  52. package/mcp-server/lib/context-envelope.cjs +508 -0
  53. package/mcp-server/lib/decision-records.cjs +337 -0
  54. package/mcp-server/lib/doctor.cjs +91 -33
  55. package/mcp-server/lib/init-project.cjs +78 -39
  56. package/mcp-server/lib/managed-file-write.cjs +116 -0
  57. package/mcp-server/lib/plan-checkpoint.cjs +177 -0
  58. package/mcp-server/lib/project-context.cjs +178 -0
  59. package/mcp-server/lib/stage-checkpoints.cjs +309 -0
  60. package/mcp-server/lib/state-db.cjs +155 -24
  61. package/mcp-server/lib/state-ops.cjs +21 -3
  62. package/mcp-server/lib/task-ledger.cjs +522 -13
  63. package/mcp-server/lib/ultra-facade.cjs +757 -442
  64. package/mcp-server/lib/worker-packet.cjs +358 -0
  65. package/mcp-server/server.cjs +200 -1103
  66. package/orchestrator/daemon.cjs +27 -9
  67. package/orchestrator/parallel-orchestrator.cjs +111 -76
  68. package/orchestrator/session-runner.cjs +135 -34
  69. package/package.json +10 -3
  70. package/skills/ultra-change/SKILL.md +10 -8
  71. package/skills/ultra-deliver/SKILL.md +17 -19
  72. package/skills/ultra-dev/SKILL.md +20 -11
  73. package/skills/ultra-doctor/SKILL.md +4 -4
  74. package/skills/ultra-init/SKILL.md +6 -5
  75. package/skills/ultra-init/references/brownfield-adoption.md +20 -14
  76. package/skills/ultra-plan/SKILL.md +13 -9
  77. package/skills/ultra-research/SKILL.md +18 -9
  78. package/skills/ultra-review/SKILL.md +14 -9
  79. package/skills/ultra-review/references/unified-schema.md +2 -0
  80. package/skills/ultra-review/scripts/review_wait.py +8 -0
  81. package/skills/ultra-status/SKILL.md +2 -2
  82. package/skills/ultra-test/SKILL.md +10 -6
  83. package/skills/ultra-think/SKILL.md +8 -7
  84. package/skills/ultra-think/references/interaction-boundary.md +56 -0
  85. package/spec/cli-protocol.md +80 -199
  86. package/spec/mcp-tools.yaml +43 -2806
  87. package/spec/schemas/state-db.sql +107 -4
  88. package/spec/schemas/{task-ledger.v1.schema.json → task-ledger.v2.schema.json} +70 -6
  89. package/ultra-tools/commands/status.cjs +369 -243
  90. package/mcp-server/lib/context-spine.cjs +0 -1208
  91. package/mcp-server/lib/decision-dialogue.cjs +0 -1128
  92. package/mcp-server/lib/project-breadcrumb.cjs +0 -173
  93. package/mcp-server/lib/spec-learning.cjs +0 -284
  94. package/mcp-server/lib/workflow-state.cjs +0 -3129
  95. package/skills/ultra-think/references/decision-dialogue.md +0 -155
@@ -1,510 +1,221 @@
1
- # Ultra Builder Pro CLI — Architecture
1
+ # Ultra Builder Pro architecture
2
+
3
+ Ultra Builder Pro is an adaptive delivery harness distributed as native plugins for
4
+ Claude Code, Codex, OpenCode, Kimi Code, and Grok Build. The host model reasons and
5
+ chooses semantic routes. Ultra preserves the accepted intent, current evidence, safe
6
+ execution state, and recoverable delivery history across sessions and hosts.
7
+
8
+ ## One authority graph
9
+
10
+ ```mermaid
11
+ flowchart LR
12
+ U["User<br/>intent, trade-offs, authorization"]
13
+ H["Host model<br/>inspect, recommend, implement"]
14
+ S["11 explicit Skills<br/>adaptive semantic workflows"]
15
+ C["Canonical Context Envelope"]
16
+ M["7-tool MCP kernel"]
17
+ D[("SQLite<br/>facts, indexes, CAS, leases, journals")]
18
+ F[".ultra semantic files<br/>intent, specs, plans, decisions, evidence"]
19
+ K["Hooks<br/>observe, inject, recover, protect"]
20
+ A["Agents<br/>bounded Worker Packets"]
21
+ G["Git team checkpoint"]
22
+
23
+ U <--> H
24
+ H --> S
25
+ S --> C
26
+ K --> C
27
+ C --> M
28
+ M <--> D
29
+ H --> F
30
+ M <--> F
31
+ S --> A
32
+ C --> A
33
+ A --> F
34
+ F --> G
35
+ M <--> G
36
+ ```
2
37
 
3
- > Single-page entry point for reviewers and contributors. Current authority and
4
- > package boundaries live in [`docs/DECISIONS.md`](./DECISIONS.md); executable
5
- > behavior remains defined by source, schemas, and tests.
38
+ There is no second semantic authority:
6
39
 
7
- ## 1. One sentence
40
+ - Skills own recommendations, conditional procedure, and the meaning of completion.
41
+ - The host model owns evidence synthesis and reversible implementation choices.
42
+ - The user owns goals, material trade-offs, risk acceptance, and external effects.
43
+ - MCP owns structure validation, idempotency, digests, CAS, leases, safe paths,
44
+ filesystem journals, recovery, and accepted checkpoints.
45
+ - Hooks own deterministic observation and bounded injection only.
46
+ - Agents receive one immutable Worker Packet and write only the declared output.
8
47
 
9
- `ultra-builder-pro-cli` is a multi-runtime plugin suite that **distributes** the
10
- Ultra Builder Pro engineering loop (skills + commands + workflow hooks) as
11
- native Claude Code, OpenCode, Codex, and Kimi Code plugins, and
12
- **runs** that loop with isolated sessions sharing checkout-local operational
13
- authority (`.ultra/.runtime/state.db`) plus one MCP-published Git team checkpoint
14
- (`.ultra/tasks/tasks.json`).
48
+ SQLite never chooses the next capability and never requires a fixed sequence of
49
+ reasoning steps. Semantic gaps appear in `diagnostics`, `warnings`, or
50
+ `needs_attention`; hard errors are reserved for corrupt authority, unsafe paths,
51
+ real concurrency conflicts, missing runtime prerequisites, permissions, and
52
+ irreversible external effects.
15
53
 
16
- It is not an agent or a general conversational-memory provider. It is the workflow
17
- substrate the supported hosts share, including project-local cross-session workflow
18
- memory under `.ultra/`.
54
+ ## Public MCP kernel
19
55
 
20
- ## 2. Three layers
56
+ Every host discovers exactly seven tools:
21
57
 
58
+ | Tool | Contract |
59
+ |---|---|
60
+ | `ultra.context` | Side-effect-free, bounded Context Envelope read |
61
+ | `ultra.record` | Typed, idempotent recording of facts, decisions, artifacts, tasks, outcomes, and observations |
62
+ | `ultra.checkpoint` | Caller-declared Stage Checkpoint with structural, scope, byte, digest, and publication validation |
63
+ | `ultra.sync` | Inspect, migrate, import, or publish the Git team checkpoint |
64
+ | `ultra.session` | Lease/worktree acquisition plus immutable Worker Packet handoff |
65
+ | `ultra.archive` | Crash-safe caller-declared local handoff and immutable archive |
66
+ | `ultra.doctor` | Mechanical diagnosis and backup-first repair |
67
+
68
+ Retired fine-grained tool names are not registered and return `UNKNOWN_TOOL`. The
69
+ source repository retains migration readers and regression fixtures for old authority,
70
+ but those modules are excluded from the npm distribution and have no live public
71
+ consumer.
72
+
73
+ ## Canonical Context Envelope
74
+
75
+ One generator supplies MCP reads, Hook breadcrumbs, compact recovery, Session handoff,
76
+ and review/debug Workers:
77
+
78
+ ```text
79
+ UltraContextEnvelope
80
+ ├── project and host identity
81
+ ├── Git head, branch, scope digest, and drift class
82
+ ├── accepted baseline and evidence references
83
+ ├── active Change contract and diagnostics
84
+ ├── selected Task contract and dependencies
85
+ ├── accepted normalized Decision Records
86
+ ├── typed evidence references and freshness
87
+ ├── execution lease, worktree, and Worker Packet
88
+ └── warnings, needs_attention, and hard_conflicts
22
89
  ```
23
- ┌──────────────────────────┐
24
- │ runtime CLI │
25
- │ (claude / opencode / │
26
- │ codex / kimi) │
27
- └────────────┬─────────────┘
28
- │
29
- ┌───────────────────┼────────────────────┐
30
- │ │ │
31
- ▼ ▼ ▼
32
- ╔══════════════╗ ╔════════════════╗ ╔══════════════╗
33
- ║ skill/ ║ ║ MCP server ║ ║ ultra-tools ║
34
- ║ (knowledge) ║ ║ (state ops) ║ ║ (Bash ║
35
- ║ ║ ║ ║ ║ fallback) ║
36
- ╚══════╤═══════╝ ╚════════╤═══════╝ ╚══════╤═══════╝
37
- │ │ │
38
- │ resolve / read │ task.* etc. │ selected init /
39
- │ (D29 read-only) │ │ recovery / ops
40
- └────────────┬───────┴──────────────────┘
41
- ▼
42
- ┌─────────────────────┐
43
- │ .ultra/.runtime/state.db │
44
- │ (SQLite + WAL) │ ← lifecycle + index authority
45
- └──────────┬──────────┘
46
- │
47
- ┌─────────┴──────────┐
48
- │ │
49
- ▼ ▼
50
- .ultra/.runtime/projections/ .ultra/tasks/tasks.json
51
- (local generated views) (Git team checkpoint:
52
- baseline + Changes + tasks)
53
- ```
54
90
 
55
- | Layer | Role | Form |
56
- |--------------|----------------------------------------------|-------------------------------------------------------|
57
- | **skill** | knowledge carrier; tells the runtime *what to do* | `skills/<name>/SKILL.md` discovered natively by all supported runtimes |
58
- | **MCP** | persistence and safety kernel for checkpoints, evidence, sync, leases, archive, and recovery | stdio MCP server exposing seven public `ultra.*` tools; sixty 0.22 fine-grained operations remain hidden for one compatibility release |
59
- | **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)) |
60
-
61
- Why three: skills preserve adaptable model behavior across runtimes; MCP gives durable
62
- checkpoint and safety primitives without supervising every reasoning step; the CLI
63
- supplies bounded maintenance and recovery when MCP cannot start. Semantic draft
64
- diagnostics are report-first. Corruption, unsafe paths, real concurrency, permissions,
65
- and irreversible effects remain fail-closed.
66
-
67
- The skill layer is **read-only by design** (D29) and is discovered directly by
68
- each host. Ultra exposes no `skill.*` MCP family: skills are documentation, not
69
- RPC, and host-native loaders own resolution and invocation.
70
-
71
- ## 3. Workflow memory and authoritative state
72
-
73
- Together, `.ultra/` retains project-local cross-session workflow memory:
74
- normalized intent, progress, tasks, bounded context, specifications, evidence,
75
- provenance, and recovery. `.ultra/.runtime/state.db` is operational authority for
76
- lifecycle, indexing, transitions, freshness, and coordination in one checkout.
77
- Registered digest-bound files carry semantic and evidence bodies.
78
- `.ultra/tasks/tasks.json` is a portable, digest-chained Git handoff for baseline,
79
- Change, and durable task records; it never owns sessions, leases, or live
80
- `in_progress` state. Generated projections and working scratch do not become
81
- authority merely because they live under `.ultra/`. The complete classification and
82
- promotion contract is
83
- [`ARTIFACT-AUTHORITY.md`](./ARTIFACT-AUTHORITY.md).
84
-
85
- All durable Ultra lifecycle and index state lives in one SQLite file with WAL enabled.
86
- Schema is fixed in [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) and
87
- covers twenty-one tables:
88
-
89
- | Table | Holds | Phase |
90
- |--------------------|---------------------------------------------------|-------|
91
- | `baselines` | repository classification, greenfield/brownfield adoption, explicit unborn/clean/dirty Git snapshot, specs, evidence, verification, gap ledger, persisted known-red acceptance, and approval | 12→17 |
92
- | `tasks` | task rows — id, status, deps, files_modified, … | 2 |
93
- | `events` | append-only event stream; `id` is subscription cursor (D31) | 2 |
94
- | `sessions` | execution sessions, **including lease + heartbeat fields** (D32) | 4.5 |
95
- | `schema_version` | applied schema version (cross-version misread guard, D30) | 2 |
96
- | `migration_history`| one row per migration attempt (audit trail) | 2 |
97
- | `telemetry` | per-session token / cost / tool-call counters | 6 |
98
- | `specs_refs` | spec change tracking → staleness propagation | 5 |
99
- | `circuit_breaker` | bounded retry and halt state for failed tasks | 5 |
100
- | `changes` | continuous feature/fix/incident lifecycle, alignment-thread link, and incident baseline bypass | 12→16 |
101
- | `artifacts` | typed semantic/evidence ownership, digest, status, and provenance | 8C→20 |
102
- | `artifact_edges` | normalized source and consumer dependency graph | 20 |
103
- | `context_snapshots`| role/gate context, readiness, budget, execution seam, hashes, git head, provider refs | 10 |
104
- | `spec_learning_candidates` | approval-gated implementation discoveries for baseline convergence | 10 |
105
- | `trace_links` | task/spec/change traceability | 8C |
106
- | `incidents` | structured runtime failures and resolutions | 8C |
107
- | `projection_jobs` | durable projection outbox/retry state | 8C |
108
- | `event_consumers` | durable monotonic consumer cursors | 8C |
109
- | `workflow_runs` | init/research/plan/change/dev/test/review/deliver run authority, position, blockers, approval, and derived summary | 13 |
110
- | `workflow_steps` | ordered step state, evidence, decisions, immutable output paths, and recorded SHA-256 digests | 13 |
111
- | `decision_threads` | baseline/change/workflow-bound owner-agent alignment, interaction mode, normalized completion, and optional checkpoint authority | 16/19 |
112
- | `decision_items` | one-at-a-time owner choices, evidence, recommendations, durable effects, resolutions, delegation, deferral, and supersession history | 16 |
113
-
114
- Two rules make this work:
115
-
116
- 1. **No double source (D32).** lease/heartbeat live only in `sessions`,
117
- not in a `lease.json` file. Activity log lives only in `events`, not
118
- in JSON files. `.ultra/.runtime/projections/tasks.json` and its complete
119
- `contexts/task-*.md` files are local projections generated by the projector;
120
- manual edits are overwritten on the next state.db change. The tracked
121
- `.ultra/tasks/tasks.json` is a different surface: only MCP publishes or imports
122
- this versioned team checkpoint, and digest validation rejects manual edits.
123
-
124
- 2. **Single writer for mutable tables, multi-writer for `events`.**
125
- `.ultra/.runtime/state.db` opens in WAL with `busy_timeout=5000`. The MCP
126
- server holds the single writer connection for `baselines`, `tasks`, `sessions`,
127
- `changes`, `decision_threads`, `decision_items`, `workflow_runs`, `workflow_steps`,
128
- `artifacts`, `artifact_edges`, `context_snapshots`,
129
- `spec_learning_candidates`, `incidents`, `projection_jobs`, `telemetry`,
130
- `specs_refs`, and `migration_history`; the CLI calls
131
- those tools over stdio rather than opening its own writer. The
132
- `events` table is append-only and explicitly multi-writer — CLI and
133
- orchestrator processes append directly to it under the same WAL +
134
- `busy_timeout` discipline, since independent INSERTs do not conflict.
135
- External writers and public `task.append_event` may append observations only;
136
- lifecycle event names are emitted by the mutation that owns the corresponding
137
- DB transition and no event row can substitute for that transition.
138
- In `spec/mcp-tools.yaml` this split is captured by `writer_role: mcp`
139
- (must go through the MCP server) versus `writer_role: any` (any
140
- process may execute). Full policy lives in
141
- `docs/STATE-DB-ACCESS-POLICY.md` (Phase 2.2 / R25).
142
-
143
- Subscribers always pull `events.id > since_id` rather than `max(ts)`,
144
- because two events may share the same millisecond timestamp (D31).
145
-
146
- ### General memory and graph ownership remain outside Ultra Builder Pro
147
-
148
- Ultra Builder Pro does not retain prompts, transcripts, tool observations,
149
- session summaries, general conversational memory, or code-graph payloads. It ships
150
- no `memory.*` MCP family, general recall skill, or memory-capture hook. A separately
151
- installed provider such as cloud-mem/claude-mem owns general persistent memory and
152
- its own lifecycle. Ultra stores only bounded provider metadata references needed by
153
- workflow context. The only related migration surface is the explicit
154
- `ultra-tools legacy-memory` inspect/archive/confirmed-prune command for general memory
155
- data created by older releases. It is never called by a hook, MCP operation, or
156
- session lifecycle; it does not collect, recall, reflect, or remove Ultra workflow
157
- authority.
158
-
159
- ### Project baseline adoption
160
-
161
- `task.init_project` classifies source, tests, deployment, persistence, package
162
- scripts, and monorepo markers. It detects `greenfield` or `brownfield`, records
163
- bounded classification evidence and selected repository scope, and creates the
164
- same authoritative state shape without rewriting application code.
165
-
166
- Initialization completes after local authority, classification, Git/scaffold setup,
167
- and read-back verification. It does not start or complete research. An explicit
168
- `ultra-research` invocation lets the model inspect evidence and recommend a semantic
169
- route. The owner selects, modifies, delegates, or defers through the host-native
170
- question surface unless current intent already resolves the route. The normalized
171
- accepted coverage is then recorded, and research executes, verifies, or reuses only
172
- the evidence needed to converge the baseline. Omitted catalog areas create no
173
- workflow row. MCP validates the stored state and evidence, not the preceding user
174
- interaction.
175
-
176
- Auto initialization preserves an existing Git repository and HEAD. When Git is absent,
177
- it initializes `main`, adds the symlink-safe `.ultra` rule to `.gitignore`, and persists
178
- the resulting `unborn` snapshot. Existing repositories keep their tracked ignore file
179
- unchanged. It never creates a commit, remote, tag, or push. An initialized
180
- repository cannot use a non-Git workspace hash: research must obtain approval for a
181
- local checkpoint commit before `baseline.record`.
182
-
183
- Projection-only v4.4 and v4.5 projects use `ultra-tools migrate` to preserve the
184
- entire `.ultra` tree, import tasks and events, and create a `migrated/adopting`
185
- compatibility row. Schema upgrades use `ultra-tools system doctor --repair` and
186
- produce a pre-migration backup. Compatibility state never grants baseline approval;
187
- `baseline.start` with `replace_migrated: true` opens the actual brownfield adoption.
188
-
189
- `baseline.start` opens adoption, `baseline.record` captures server-hashed spec
190
- references, bounded repository/runtime evidence, actual verification results,
191
- known unknowns, repository branch and worktree snapshot, the categorized gap ledger,
192
- and metadata-only external provider references, and
193
- `baseline.converge` records explicit owner approval, including a durable
194
- `known_red_accepted` decision when applicable. Read paths continuously revalidate
195
- ready authority: scope, three specifications, source/runtime evidence, verification,
196
- known-red rationale and acceptance, research provenance and output digests, repository
197
- revision/worktree state, blocking gaps and unknowns, approver, and convergence time.
198
- A row cannot become trusted merely because its stored status says `ready`. A ready
199
- baseline is replaced only by an explicit re-adoption, preserving the superseded row
200
- for recovery.
201
- For a selected monorepo scope, the worktree digest and dirty-file list include only
202
- that scope; out-of-scope changes remain visible repository context but cannot be
203
- accepted implicitly by `accept_dirty_worktree`.
204
-
205
- New ordinary changes require a healthy `ready` baseline. An active ordinary change may
206
- continue through only the expected HEAD/worktree/spec/source drift created after its
207
- durable `bind-baseline` step; loss of ready approval, missing evidence, blocking gaps,
208
- or any other structural defect stops task/context/stage progression. A new incident can
209
- start on an unhealthy baseline only with an explicit reason and approver stored in
210
- `baseline_bypass_json`. Ordinary convergence and archive reconcile HEAD, worktree,
211
- and tracked-spec drift atomically. Break-glass incident archive creates an open
212
- blocking reconciliation gap, so incident recovery can finish without falsely marking
213
- the project baseline healthy.
214
-
215
- ### Human-agent decision authority
216
-
217
- Ultra separates autonomous evidence work from owner decision authority. The host reads
218
- the repository, runtime, tests, and primary sources first, then exposes only the earliest
219
- unresolved load-bearing choice. `decision.open` stores the recommendation, credible
220
- alternatives, evidence refs, and durable effects; a partial unique index guarantees one
221
- current question per thread. The host ends that turn and waits.
222
-
223
- The next response becomes a normalized owner decision, explicit reversible delegation,
224
- or consequence-bearing deferral. Prompts and transcripts are never persisted. The host
225
- batches the normalized result and owning mutation through `ultra.record`, reads it back
226
- through `ultra.context`, and attempts a semantic checkpoint only when durable authority
227
- is ready. Failed semantic checks leave the draft editable. Accepted revisions remain
228
- immutable; a changed decision opens a replacement draft while preserving history. The
229
- shared procedure lives in
230
- `skills/ultra-think/references/decision-dialogue.md`; status, breadcrumb, and doctor expose
231
- only the current recovery surface.
232
-
233
- ## 4. Continuous changes — the daily unit of convergence
234
-
235
- After the initial baseline delivery, every fix, feature, redesign, or incident
236
- is represented by a `changes` row and an inspectable packet:
91
+ Summary output is bounded to 16 KiB. A selected stage-scoped full envelope is bounded
92
+ to 64 KiB. Large bodies remain lazy file references. Identical authority inputs reuse
93
+ the same content-addressed snapshot and digest.
94
+
95
+ ## Durable records
96
+
97
+ ### Decision Records
98
+
99
+ The host first inspects evidence, recommends a route, and asks one material question
100
+ only when current user intent does not already answer it. `ultra.record` persists the
101
+ normalized question, recommendation, selected result, effects, non-goals, provenance,
102
+ applied references, digest, status, and supersession link. It never stores raw
103
+ transcripts, prompts, chain-of-thought, or UI receipts.
104
+
105
+ Decision artifacts are team-visible:
237
106
 
238
107
  ```text
239
- active -> blocked -> active -> ready -> archived
240
- | |
241
- ├─ intent + adaptive research + findings
242
- ├─ typed delta + documentation reconciliation + deterministic progress
243
- ├─ plan + linked tasks + immutable contexts
244
- ├─ Change-scoped test/review/delivery evidence
245
- └─ atomic baseline apply + self-contained archive
108
+ .ultra/decisions/baseline/<decision-id>.json
109
+ .ultra/changes/active/<change-id>/decisions/<decision-id>.json
246
110
  ```
247
111
 
248
- `quick`, `standard`, `major`, and `incident` kinds require different evidence,
249
- but all require completed linked tasks, current context, declared documentation
250
- impact, and no open incident. Memory and graph payloads never enter Ultra;
251
- `context_snapshots.provider_refs_json` stores metadata references only.
252
-
253
- Baseline files are immutable while a Change is active. `change.delta` registers
254
- overlay payloads against exact baseline revision and specification digests.
255
- `change.documentation_reconcile` records exact document before/after evidence and
256
- consumer trace. Standard and major convergence requires both current authorities.
257
- `change.archive` preflights the whole write set and uses a recoverable transaction;
258
- only after all writes and baseline reconciliation succeed does it rebind the complete
259
- Change root into the archive.
260
-
261
- Draft revisions remain editable and recoverable. A failed checkpoint can be repaired
262
- and retried in place or intentionally abandoned. Accepted runs are immutable; a later
263
- candidate supersedes them only after its own accepted checkpoint, and the artifact graph
264
- invalidates only true transitive consumers.
265
-
266
- ### Context Spine
267
-
268
- Context Manifest v3 is the immutable handoff contract between planning,
269
- implementation, checking, review, convergence, and recovery. Each snapshot records:
270
-
271
- - one role (`plan`, `implement`, `check`, or `review`) and lifecycle gate;
272
- - required context references with local digests and reasons;
273
- - readiness blockers for missing/stale required references or an incomplete
274
- execution contract;
275
- - advisory attention budgets (12 files / about 12k tokens / 40% by default);
276
- - a DB-derived execution contract (`slice_kind`, public seam, exact verification command);
277
- - warnings and hard mechanical blockers without a semantic next-action command;
278
- - a digest of the accepted Change authority so semantic updates invalidate the
279
- snapshot.
280
-
281
- Checkpoint input may identify the intended role/gate, add bounded reference candidates,
282
- and lower advisory budgets. It cannot supply or override the task seam, verification
283
- command, task context references, evidence digest, gate verdict, workflow summary, or
284
- machine transitions. A host may attach a clearly non-authoritative recommendation.
285
- Critical dev/test/review/deliver workflow steps record the matching
286
- snapshot as an output; test, review, and delivery reports carry its digest forward.
287
-
288
- The hook-only breadcrumb derives the compact current position from state.db. Session,
289
- edit, resume, and OpenCode lifecycle hooks invoke one bundled read-only reader
290
- and inject it only while state.db proves an active, blocked, or ready workflow,
291
- never the intent body,
292
- provider content, or a conversation summary. A changed Git HEAD, task contract, or
293
- Change semantic authority marks the snapshot stale and permits content-addressed
294
- recompilation through the next `ultra.checkpoint`.
295
-
296
- PRD decomposition and complex-task subdivision use the active host model. The
297
- MCP accepts the resulting structured tasks, validates schema, topology,
298
- baseline/change ownership, and transaction boundaries, then persists them. It
299
- does not call Anthropic, OpenAI, or another model provider and needs no separate
300
- model API credential.
301
-
302
- Plugin installation does not activate a semantic workflow and never edits the
303
- user's `CLAUDE.md`, `AGENTS.md`, or equivalent durable instructions. Public
304
- workflows require explicit user invocation. The host reads `ultra.context`, recommends
305
- the next capability from evidence and owner intent, then stops; SQLite never launches
306
- or semantically selects the next public workflow. OpenCode realizes this boundary
307
- with explicit commands backed by private plugin workflow assets, while Claude,
308
- Codex, and Kimi use their native implicit-invocation controls.
309
-
310
- File count, token estimate, and context-share overflow produce warnings, never a
311
- refusal. The agent may narrow reads, load files lazily, or split a slice when that
312
- preserves correctness; it must not raise a threshold merely to clear a gate or
313
- drop required incident evidence.
314
-
315
- `change.learning_propose` records a durable implementation discovery without
316
- silently rewriting the baseline. `change.learning_resolve` enforces approval,
317
- rejection, and applied transitions. Proposed or merely approved candidates block
318
- convergence, so daily work cannot leave accepted behavior stranded in chat or a
319
- delta packet.
320
-
321
- `incident` is the canonical debug lane. Creating one also registers a durable
322
- `diagnosis.md` artifact with five mandatory sections: reproduction, hypotheses,
323
- root cause, regression test, and recovery. Convergence validates the artifact
324
- structure and refreshes its content hash, so a debugger result that exists only
325
- in chat cannot satisfy delivery. A host-native debugger may produce the bounded
326
- analysis, but the primary agent owns the artifact, linked task, regression
327
- evidence, and final convergence decision.
328
-
329
- Mutating MCP calls enqueue durable `projection_jobs`. Success is exposed in MCP
330
- response metadata; failure becomes a retryable structured incident instead of a
331
- swallowed warning. These jobs regenerate only checkout-local views below
332
- `.ultra/.runtime/projections/`; they never rewrite the Git team checkpoint. Durable
333
- semantic checkpoints publish team state at baseline, Change, plan, and task handoff
334
- boundaries. `ultra.doctor` is read-only by default. Explicit repair
335
- performs backup-first schema upgrade, archive-journal recovery, session and local
336
- projection recovery, and regenerated local views. It cannot import or publish semantic
337
- team state, approve a baseline, or replace a corrupt SQLite file silently. `system
338
- restore` accepts only a verified SQLite backup inside `.ultra/.runtime/backups`,
339
- quarantines the corrupt authority, and rolls back on failure.
340
- When no valid backup exists, confirmed `system rebaseline` preserves both corrupt
341
- authority and the legacy task projection before creating a new brownfield adoption.
342
-
343
- ### Git team checkpoint and checkout merge
344
-
345
- `ultra.sync { action: publish }` serializes the current portable baseline, all Change
346
- summaries, and durable task contracts to `.ultra/tasks/tasks.json`. Per-record digests and
347
- revisions make independent fast-forward possible; the document state digest, parent
348
- digest, and bounded ancestor list reject stale or unrelated histories. Local process
349
- ownership fields are deliberately absent.
350
-
351
- The MCP server imports the checkpoint once when it opens project authority. A
352
- long-running host explicitly calls `ultra.sync { action: import }` after receiving a newer Git
353
- version. Import is transactional: it validates every record first, preserves local-only
354
- fields, fast-forwards clean records, and rejects same-record concurrency or an active
355
- task collision. Re-reading an already imported checkpoint performs no write. A ready
356
- baseline is never trusted from Git alone; import creates a local revalidation gap and
357
- clears checkout-specific approval until current scope bytes, HEAD, and verification
358
- converge.
359
-
360
- Baseline freshness hashes scoped application content independently of Git staging and
361
- excludes `.ultra/`, then checks commit ancestry. This removes the metadata treadmill:
362
- committing a checkpoint or another Ultra artifact advances HEAD without staling the
363
- baseline, while changing scoped application bytes still does.
364
-
365
- ## 5. Sessions — the execution unit
366
-
367
- A **session** is the standard unit of execution across all four runtimes
368
- (D20). One session =
369
-
370
- - one authoritative task/runtime lease;
371
- - an isolated `git worktree` created by `session.spawn`,
372
- - an ignored `.ultra` link from that checkout to the one central authority,
373
- - a lease + heartbeat row in `sessions` (D32),
374
- - an `artifact_dir` under `.ultra/.runtime/sessions/<sid>/` for logs and scratch;
375
- - either the active host operating in that exact worktree or an explicitly configured
376
- worker process.
377
-
378
- Spawning a new session for a task is gated by `session.admission_check`
379
- (D33). If another session already owns an active lease on the same task,
380
- the caller must pick one of three strategies before proceeding:
381
-
382
- - `takeover` — kill the prior process, claim the lease,
383
- - `resume` — attach to the existing session and continue,
384
- - `abandon` — give up and let the existing session finish.
385
-
386
- This admission gate is the smallest piece that prevents two agents from
387
- silently double-writing the same task — it is part of the v0.1 minimum
388
- execution layer, not deferred to Phase 5.
389
-
390
- Process status is not task status. Exit zero closes transport evidence but leaves the
391
- task `in_progress` until workflow gates pass; failure blocks the task and records
392
- circuit evidence. `session.close` preserves its worktree by default. Explicit cleanup
393
- is allowed only when the worktree is clean and its commit is an ancestor of the
394
- current checkout.
395
-
396
- The optional `ubp-orchestrator` daemon requires both `auto_dispatch: true` and an
397
- explicit executable plus argument array. It refuses to create a session when no real
398
- worker can consume it. Before launch, the runner verifies that Git ignores the
399
- symlink itself. When a legacy repository has only the directory-specific `.ultra/`
400
- rule, the runner adds `.ultra` to the repository-local `info/exclude` file without
401
- changing a tracked file. It then binds the checkout to the central `.ultra` and rolls
402
- the worktree back if the ignore rule or binding cannot be established safely. The
403
- executable is launched without a shell and receives
404
- the session, task, runtime, worktree, artifact, central DB, checkout root, and
405
- authority-root paths through reserved `UBP_*` environment variables that caller
406
- configuration cannot override.
407
- Pending tasks are skipped while stale, dependency-blocked, circuit-broken, leased, or
408
- overlapping the declared files of an active task.
409
-
410
- `execute-plan` is a resumable dispatcher, not a second workflow authority. It runs
411
- only the exact current DB task graph whose change-bound `plan` workflow is completed,
412
- healthy, and current. Empty, cyclic, duplicate-task, cross-change, stale, and merely
413
- exported plans fail before session creation. Owner approval is present only when a
414
- material planning choice required it. The dispatcher then runs only pending tasks whose
415
- dependencies are DB-terminal and re-reads task state. If a
416
- worker exits before the task converges, the current wave and plan become `paused`;
417
- later waves remain pending. Re-running the command skips completed waves and resumes
418
- the first unfinished one. `wave_completed` and `plan_completed` therefore describe
419
- Ultra task convergence, while `wave_paused` and `plan_paused` preserve unfinished
420
- gate state. Even with explicit auto-merge, integration is attempted only when the
421
- change task is `completed`, its completion commit matches the session HEAD, its dev
422
- workflow is ready, and its task review is current; process exit zero is insufficient.
423
- If task or plan authority changes after wave selection but before worktree creation,
424
- dispatch reports an authority pause without recording a worker failure or incrementing
425
- the circuit breaker.
426
-
427
- ## 6. Compaction recovery — checkpoint as a validated consumer
428
-
429
- `workflow_checkpoint.py` validates the current non-terminal workflow and writes
430
- a schema-versioned checkpoint atomically before compaction. On resume,
431
- `workflow_resume.py` reads both the live workflow and checkpoint defensively,
432
- rejects corrupt, non-object, schema-mismatched, or terminal candidates, and
433
- selects the newest valid state. A newer live state wins; a newer checkpoint can
434
- atomically restore a missing or older live state before context is re-injected.
435
- The checkpoint is therefore a recovery artifact and consumer, never a second
436
- durable authority alongside `.ultra/.runtime/state.db`.
437
-
438
- ## 7. Installation provenance — read-only cross-host diagnosis
439
-
440
- Every Claude Code, OpenCode, Codex, and Kimi Code adapter writes a normalized
441
- `provenance.json` for the assets it owns. The manifest records adapter/package
442
- identity, source metadata, per-file SHA-256 hashes, an aggregate digest, and the
443
- host-specific plugin, MCP, hook, launcher, and runtime contracts expected at
444
- that install scope. It never attributes a package to an enclosing consumer
445
- repository commit.
446
-
447
- `ubp --all --global --doctor [--json]` is read-only: it recomputes hashes and
448
- validates those entry points, returning a non-zero degraded result for
449
- missing/corrupt provenance, content drift, or broken host wiring. A single host
450
- can be selected instead of `--all`. This is separate from `ultra.doctor`, which
451
- diagnoses project state, projection, incidents, sessions, and backup-first
452
- workflow recovery.
453
-
454
- ## 8. Two timelines — rule layer vs execution layer
455
-
456
- The roadmap separates two concerns that compete for the same surface
457
- area (D13):
112
+ ### Stage Checkpoints
113
+
114
+ Each semantic stage has an editable draft. Acceptance creates an immutable revision.
115
+ A later accepted revision supersedes the prior one without erasing history:
458
116
 
117
+ ```text
118
+ draft N -> accepted N -> superseded by accepted N+1
459
119
  ```
460
- ┌─ Rule layer (Phase 1-4.5) ────────────────────────────────┐
461
- │ contracts, state schema, command shells, runtime │
462
- │ installers, smoke flow, execution-lite │
463
- │ │
464
- │ v0.1 (Week 8) = rule layer fully wired + execution-lite │
465
- └────────────────────────────────────────────────────────────┘
466
-
467
- ┌─ Execution layer (Phase 4.5-8B) ───────────────────────────┐
468
- │ recovery, staleness, monitoring, intelligence, planning │
469
- │ automation, parallel worktree dispatch │
470
- │ │
471
- │ v0.2 (Week 11) = recovery + monitoring + full conformance │
472
- │ v0.3 (Week 16) = PRD → execution-plan → parallel factory │
473
- │ v1.0 (Week 17-18) = npm + Homebrew + pip distribution │
474
- └────────────────────────────────────────────────────────────┘
120
+
121
+ There is no fixed step authorization table. Skills decide which evidence is relevant
122
+ and whether the actual work is semantically sufficient. Checkpoint validation verifies
123
+ declared facts, files, digests, scope, idempotency, and safe publication. Semantic
124
+ warnings remain recorded but do not prevent an explicit caller acceptance; a hard
125
+ authority conflict leaves the draft mutable.
126
+
127
+ ### Worker Packets
128
+
129
+ Every delegated worker receives a digest-bound packet containing the exact Context
130
+ Envelope, accepted decisions, Git boundary, Task contract, acceptance, evidence
131
+ references, output path, and output schema. The worker must echo `packet_digest`.
132
+ Workers do not write SQLite or accept their own result.
133
+
134
+ ## `.ultra` storage planes
135
+
136
+ ```text
137
+ .ultra/
138
+ ├── specs/ # tracked baseline semantic authority
139
+ ├── decisions/baseline/ # tracked normalized decisions
140
+ ├── docs/research/ # tracked research evidence
141
+ ├── changes/
142
+ │ ├── active/<change-id>/
143
+ │ │ ├── intent.md
144
+ │ │ ├── diagnosis.md # incident only
145
+ │ │ ├── decisions/
146
+ │ │ ├── research/
147
+ │ │ ├── delta/
148
+ │ │ ├── plan.json
149
+ │ │ ├── plan.md
150
+ │ │ ├── contexts/
151
+ │ │ ├── test/
152
+ │ │ ├── review/
153
+ │ │ ├── documentation/
154
+ │ │ └── delivery/
155
+ │ └── archive/ # immutable self-contained deliveries
156
+ ├── tasks/tasks.json # tracked digest-chained team checkpoint
157
+ ├── reports/templates/ # fixed schemas/templates
158
+ └── .runtime/ # ignored checkout-local state
159
+ ├── state.db[-wal|-shm]
160
+ ├── projections/
161
+ ├── sessions/
162
+ ├── worktrees/
163
+ ├── recovery/
164
+ ├── backups/
165
+ ├── telemetry/
166
+ ├── debug/
167
+ └── collab/
475
168
  ```
476
169
 
477
- The rule layer is shipped before the execution layer because users get
478
- value from "skills + tasks survive across sessions" long before they get
479
- value from "ten agents in parallel." Each milestone is independently
480
- shippable; downstream slip never blocks an earlier release.
481
-
482
- ## 9. Where to look next
483
-
484
- | Question | File |
485
- |----------------------------------------------------|-----------------------------------------------------|
486
- | What does each MCP tool accept and return? | [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
487
- | How do CLI subcommands map to MCP tools? | [`spec/cli-protocol.md`](../spec/cli-protocol.md) |
488
- | Exact SQLite schema? | [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) |
489
- | What does the Git team checkpoint look like? | [`spec/schemas/task-ledger.v1.schema.json`](../spec/schemas/task-ledger.v1.schema.json) |
490
- | What does the local task projection look like? | [`spec/fixtures/valid/tasks.v4.5.json`](../spec/fixtures/valid/tasks.v4.5.json) |
491
- | Current authority and package decisions | [`docs/DECISIONS.md`](./DECISIONS.md) |
492
- | When does each workflow write, invalidate, and converge state? | [`docs/WORKFLOW-LIFECYCLE.md`](./WORKFLOW-LIFECYCLE.md) |
493
-
494
- ## 10. Verifying the architecture
495
-
496
- Every contract on this page is enforced by `npm run test:spec`:
497
-
498
- - `validate-mcp-tools.cjs` — meta-schema for the tool manifest, plus
499
- per-tool sample input/output fixtures.
500
- - `validate-state-db.cjs` — schema applies cleanly to a fresh in-memory
501
- SQLite, valid fixtures insert, invalid fixtures are rejected by
502
- CHECK / NOT NULL / FK constraints.
503
- - `validate-json-schemas.cjs` — the team-checkpoint schema plus local projection
504
- schemas for `tasks.json` and `contexts/task-*.md`.
505
- - `validate-skills.cjs` — every existing skill passes the manifest
506
- contract; failures are recorded in `spec/migration-notes.md`.
507
- - `check-cli-mapping.cjs` — every MCP tool has exactly one CLI
508
- subcommand and the doc table never drifts from the YAML manifest.
509
-
510
- If any of these fails, the architecture is no longer the architecture.
170
+ Tracked Markdown and JSON carry inspectable semantic bodies and evidence. SQLite
171
+ stores their typed ownership, digest, references, freshness, and mechanical state.
172
+ The team checkpoint carries portable baseline, Change, Decision summary/reference,
173
+ Task contracts, dependencies, accepted Stage Checkpoints, and durable outcomes. It
174
+ excludes leases, PIDs, worktrees, telemetry, local `in_progress` ownership, and
175
+ completion commit backfill.
176
+
177
+ ## Host boundary
178
+
179
+ | Host | Native plugin surface | Context truth |
180
+ |---|---|---|
181
+ | Claude Code | plugin commands, Skills, agents, hooks, MCP | SessionStart breadcrumb plus Skill-entry full read |
182
+ | Codex | namespaced Skills, TOML agents, native hooks, MCP | session/prompt breadcrumb plus Skill-entry full read |
183
+ | OpenCode | command bundle, native agents, JavaScript events, MCP | system transform plus Skill-entry full read |
184
+ | Kimi Code | managed plugin commands, Skills, native hooks, MCP | native event breadcrumb plus Skill-entry full read |
185
+ | Grok Build | plugin Skills, commands, agents, camelCase hooks, MCP | Skill entry is authoritative; ignored hook stdout is never claimed as injection |
186
+
187
+ Adapters translate host-native questions and lifecycle events. They never own semantic
188
+ selection or durable state. Unsupported host lifecycle surfaces are described as
189
+ degraded, not emulated dishonestly.
190
+
191
+ ## Native runtime and installation
192
+
193
+ The MCP runtime externalizes `better-sqlite3` and installs its JavaScript package plus
194
+ the exact native `.node` binary. Provenance records platform, architecture, Node ABI,
195
+ runtime command, asset digests, and native digest. Launchers resolve a stable Node
196
+ executable and reject ABI drift before opening project authority.
197
+
198
+ Each host installation uses staging, the final host command for preflight, and atomic
199
+ swap. Preflight verifies initialization, exactly seven tools, a public write/read,
200
+ Doctor backup, close/reopen consistency, and no project initialization from
201
+ `tools/list`. A failed update preserves the previous installation.
202
+
203
+ ## Recovery and migration
204
+
205
+ `ultra.sync` owns semantic migration. `ultra.doctor` calls the same migration service
206
+ for mechanical repair and does not make semantic conflict choices. Supported inputs
207
+ include v4.4/v4.5 task projections, the legacy root-level state database, legacy Task
208
+ Contexts, and v0.22/v0.23 database and ledger authority.
209
+
210
+ Migration is inspectable, exact-byte backup-first, transactional, and fail-closed on
211
+ conflict. Old workflow and dialogue rows are retained as non-authoritative history;
212
+ current Context, Decisions, Checkpoints, and the team ledger are rebuilt from verified
213
+ facts. No user should edit SQLite or move a legacy file manually to recover.
214
+
215
+ ## External boundaries
216
+
217
+ Ultra does not own general conversational memory, prompt capture, transcript capture,
218
+ code-graph payloads, browser automation, deployment providers, framework guidance, or
219
+ global engineering policy. Those belong to independent providers or host/user
220
+ instruction files. Ultra may store only bounded provider references needed by an
221
+ accepted project checkpoint.