ultra-builder-pro-cli 0.22.0 → 0.24.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 (93) hide show
  1. package/.ultra-template/docs/research/README.md +4 -4
  2. package/CHANGELOG.md +83 -0
  3. package/README.md +68 -35
  4. package/adapters/_shared/codex-assets.cjs +121 -60
  5. package/adapters/_shared/interaction-contract.cjs +20 -7
  6. package/adapters/_shared/provenance.cjs +7 -2
  7. package/adapters/_shared/runtime-assets.cjs +4 -3
  8. package/adapters/_shared/runtime-native.cjs +132 -0
  9. package/adapters/claude.js +61 -31
  10. package/adapters/codex.js +178 -81
  11. package/adapters/grok.js +372 -0
  12. package/adapters/kimi.js +8 -4
  13. package/adapters/opencode.js +211 -33
  14. package/agents/code-reviewer.md +4 -2
  15. package/agents/debugger.md +4 -1
  16. package/agents/review-code.md +7 -3
  17. package/agents/review-comments.md +7 -4
  18. package/agents/review-coordinator.md +11 -7
  19. package/agents/review-design.md +8 -4
  20. package/agents/review-errors.md +8 -4
  21. package/agents/review-spec.md +8 -5
  22. package/agents/review-tests.md +7 -4
  23. package/agents/tdd-runner.md +5 -2
  24. package/bin/install.js +9 -4
  25. package/bin/orchestrator.js +4 -13
  26. package/docs/AGENT-CONTEXT.md +141 -231
  27. package/docs/ARCHITECTURE.md +203 -498
  28. package/docs/ARTIFACT-AUTHORITY.md +38 -35
  29. package/docs/PLUGIN-ISOLATION-CONTRACT.md +12 -9
  30. package/docs/ROADMAP.md +85 -110
  31. package/docs/RUNTIME-COMPAT-MATRIX.md +139 -174
  32. package/docs/SKILL-AUTHORING.md +3 -3
  33. package/docs/STATE-DB-ACCESS-POLICY.md +25 -20
  34. package/docs/WORKFLOW-LIFECYCLE.md +174 -442
  35. package/hooks/README.md +11 -8
  36. package/hooks/active_task_context.py +16 -16
  37. package/hooks/adapters/grok.py +134 -0
  38. package/hooks/{context_spine.py → context_envelope.py} +26 -22
  39. package/hooks/health_check.py +19 -29
  40. package/hooks/pre_stop_check.py +22 -12
  41. package/hooks/subagent_tracker.py +1 -1
  42. package/hooks/workflow_checkpoint.py +14 -13
  43. package/hooks/workflow_context.py +11 -12
  44. package/hooks/workflow_resume.py +14 -13
  45. package/mcp-server/{breadcrumb.cjs → hook-context.cjs} +7 -9
  46. package/mcp-server/lib/artifact-registry.cjs +25 -1
  47. package/mcp-server/lib/baseline-workflow.cjs +36 -38
  48. package/mcp-server/lib/canonical-json.cjs +19 -0
  49. package/mcp-server/lib/change-workflow.cjs +637 -49
  50. package/mcp-server/lib/context-envelope.cjs +508 -0
  51. package/mcp-server/lib/decision-records.cjs +337 -0
  52. package/mcp-server/lib/doctor.cjs +91 -33
  53. package/mcp-server/lib/init-project.cjs +78 -39
  54. package/mcp-server/lib/managed-file-write.cjs +116 -0
  55. package/mcp-server/lib/plan-checkpoint.cjs +177 -0
  56. package/mcp-server/lib/project-context.cjs +178 -0
  57. package/mcp-server/lib/stage-checkpoints.cjs +309 -0
  58. package/mcp-server/lib/state-db.cjs +155 -24
  59. package/mcp-server/lib/task-ledger.cjs +522 -13
  60. package/mcp-server/lib/ultra-facade.cjs +834 -0
  61. package/mcp-server/lib/worker-packet.cjs +358 -0
  62. package/mcp-server/server.cjs +208 -1059
  63. package/orchestrator/daemon.cjs +27 -9
  64. package/orchestrator/parallel-orchestrator.cjs +111 -76
  65. package/orchestrator/session-runner.cjs +135 -34
  66. package/package.json +10 -3
  67. package/skills/ultra-change/SKILL.md +39 -98
  68. package/skills/ultra-deliver/SKILL.md +42 -65
  69. package/skills/ultra-dev/SKILL.md +52 -99
  70. package/skills/ultra-doctor/SKILL.md +35 -57
  71. package/skills/ultra-init/SKILL.md +48 -88
  72. package/skills/ultra-init/references/brownfield-adoption.md +11 -8
  73. package/skills/ultra-plan/SKILL.md +54 -132
  74. package/skills/ultra-research/SKILL.md +58 -112
  75. package/skills/ultra-review/SKILL.md +28 -46
  76. package/skills/ultra-review/references/unified-schema.md +2 -0
  77. package/skills/ultra-review/scripts/review_wait.py +8 -0
  78. package/skills/ultra-status/SKILL.md +22 -45
  79. package/skills/ultra-test/SKILL.md +27 -61
  80. package/skills/ultra-think/SKILL.md +29 -48
  81. package/skills/ultra-think/references/interaction-boundary.md +56 -0
  82. package/spec/cli-protocol.md +80 -187
  83. package/spec/mcp-tools.yaml +130 -2738
  84. package/spec/schemas/mcp-tools.schema.json +1 -1
  85. package/spec/schemas/state-db.sql +107 -4
  86. package/spec/schemas/{task-ledger.v1.schema.json → task-ledger.v2.schema.json} +70 -6
  87. package/ultra-tools/commands/status.cjs +369 -243
  88. package/mcp-server/lib/context-spine.cjs +0 -1208
  89. package/mcp-server/lib/decision-dialogue.cjs +0 -1128
  90. package/mcp-server/lib/project-breadcrumb.cjs +0 -173
  91. package/mcp-server/lib/spec-learning.cjs +0 -284
  92. package/mcp-server/lib/workflow-state.cjs +0 -2965
  93. package/skills/ultra-think/references/decision-dialogue.md +0 -153
@@ -1,483 +1,215 @@
1
1
  # Ultra Builder Pro workflow lifecycle
2
2
 
3
- This document defines when Ultra writes authoritative state, how each workflow
4
- advances, what invalidates evidence, and which decisions remain with the active
5
- host and project owner. It is the operational companion to
6
- [`ARCHITECTURE.md`](./ARCHITECTURE.md) and the machine contracts under `spec/`.
3
+ Ultra is an adaptive capability graph, not an automatically chained pipeline. The
4
+ current Skill inspects authority and recommends a next capability. The user explicitly
5
+ starts that capability. Skills own semantic procedure; the seven-tool MCP kernel owns
6
+ persistence and mechanical safety across Claude Code, Codex, OpenCode, Kimi Code, and
7
+ Grok Build.
8
+
9
+ ## Capability graph
10
+
11
+ ```mermaid
12
+ flowchart TD
13
+ START["Project"] --> INIT["ultra-init"]
14
+ INIT --> RESEARCH["ultra-research"]
15
+ RESEARCH --> THINK["ultra-think when a material decision remains"]
16
+ THINK --> RESEARCH
17
+ RESEARCH --> CHANGE["ultra-change"]
18
+ CHANGE --> ROUTE{"Evidence sufficient?"}
19
+ ROUTE -->|"No"| CR["bounded ultra-research"]
20
+ CR --> PLAN["ultra-plan"]
21
+ ROUTE -->|"Yes"| PLAN
22
+ PLAN --> DEV["ultra-dev for one owned Task"]
23
+ DEV --> MORE{"More executable Tasks?"}
24
+ MORE -->|"Yes"| DEV
25
+ MORE -->|"No"| TEST["ultra-test"]
26
+ TEST -->|"implementation gap"| DEV
27
+ TEST -->|"evidence accepted"| REVIEW["ultra-review"]
28
+ REVIEW -->|"implementation issue"| DEV
29
+ REVIEW -->|"contract issue"| PLAN
30
+ REVIEW -->|"accepted"| DELIVER["ultra-deliver"]
31
+ DELIVER --> CHANGE
32
+ STATUS["ultra-status"] -.-> INIT
33
+ STATUS -.-> CHANGE
34
+ DOCTOR["ultra-doctor"] -.-> INIT
35
+ DOCTOR -.-> CHANGE
36
+ ```
37
+
38
+ The graph is guidance, not database authorization. A quick, well-understood Change may
39
+ skip extra research, but it still needs an explicit Plan, Task contract, Context,
40
+ verification, review, and delivery evidence. `ultra-status` is read-only.
41
+ `ultra-doctor` repairs mechanical authority only.
42
+
43
+ ## Shared command contract
44
+
45
+ Every public Skill follows the same boundary:
7
46
 
8
- ## 1. Authority boundaries
47
+ 1. read the current `ultra.context`;
48
+ 2. inspect checkout/runtime facts directly;
49
+ 3. identify the smallest unresolved semantic choice;
50
+ 4. recommend a route and ask only when user intent is not already explicit;
51
+ 5. persist normalized facts through typed `ultra.record`;
52
+ 6. update the owning semantic/evidence files;
53
+ 7. save or accept the stage through `ultra.checkpoint`;
54
+ 8. read back current authority;
55
+ 9. report diagnostics and recommend, but do not launch, the next Skill.
9
56
 
10
- | Surface | Owns | Must not own |
57
+ No command records ceremonial steps merely to satisfy SQLite.
58
+
59
+ ## Capability ownership
60
+
61
+ | Skill | Semantic owner | Durable output |
11
62
  |---|---|---|
12
- | Active host and owner | Product judgment, research content, implementation, review findings, and authorization for destructive or external effects | Durable workflow status or fabricated evidence digests |
13
- | Skill | One reusable procedure and its evidence requirements | Project state, static product doctrine, host-specific tool fiction |
14
- | MCP | IDs, valid transitions, hard recovery requirements, task contracts, evidence references, output hashes, and gate verdicts | Semantic route selection, research prose, code generation, general memory-provider payloads, or model calls |
15
- | `.ultra/.runtime/state.db` | Checkout-local lifecycle, index, transition, freshness, and coordination authority for baseline, change, decision, task, workflow, session, event, incident, projection, and evidence references | Prompts, transcripts, general external-memory payloads, semantic prose, or code-graph payloads |
16
- | `.ultra/tasks/tasks.json` | MCP-published Git checkpoint for portable baseline, Change, task-contract, dependency, and durable status records | Live sessions, leases, `in_progress` ownership, completion hashes, or a parallel write API |
17
- | Digest-bound artifacts | Registered specification, research, Change, context, test, review, delivery, and verification bodies | Independent lifecycle state or content whose digest no longer matches |
18
- | Generated projections and scratch | Checkout-local views below `.ultra/.runtime/` and temporary working material | Lifecycle, semantic, or evidence authority before supported promotion |
19
- | Hook | Compact DB-derived lifecycle observation, minimal event metadata, and protection of MCP-owned checkpoint/projection paths | Generic engineering judgment, prompt/transcript capture, parallel lifecycle logs, or arbitrary edit blocking |
20
-
21
- Together, `.ultra/` is project-local cross-session workflow memory. The detailed
22
- artifact classes and promotion rules live in
23
- [`ARTIFACT-AUTHORITY.md`](./ARTIFACT-AUTHORITY.md).
24
-
25
- Prompt input can supply facts, content paths, reasons, owner decisions, and
26
- evidence references. MCP reads the current repository and DB, validates those
27
- inputs, hashes outputs, and derives status. Prompt input cannot override a task's
28
- public seam, verification command, context references, workflow summary, gate
29
- verdict, output digest, or transition validity. A host recommendation is never stored
30
- as MCP authority.
31
-
32
- Load-bearing owner choices are normalized through `decision.*`; Prompt prose is not
33
- durable authority. The host acquires observable facts autonomously, exposes one
34
- current question, and stops. A workflow cannot advance while a matching decision has
35
- an unanswered blocking question, a blocking deferral, a prepared checkpoint awaiting
36
- confirmation, or a stale confirmed artifact. A normalized answer alone does not require
37
- a ceremonial checkpoint.
38
-
39
- Every change-bound research, plan, dev, test, review, and deliver run inherits
40
- the baseline id from the owning change workflow. A Prompt cannot switch that
41
- authority, and no new stage may start on an archived or cancelled change. Doctor
42
- recovers a legacy change without this link into an explicitly blocked workflow;
43
- it does not fabricate the missing provenance.
44
-
45
- Ultra does not select product scope or material delivery posture; those remain user
46
- decisions. Research references form an optional catalog, not a forced questionnaire.
47
- The host model inspects evidence and recommends only relevant areas. The owner selects,
48
- modifies, delegates, or defers that route through the native question surface unless
49
- current intent already resolves it. The host records the normalized accepted coverage
50
- and rationale. MCP validates identifiers, dispositions, evidence requirements,
51
- synthesis, and at least one applicable semantic area; it does not prove the preceding
52
- interaction. Omitted areas create no workflow step. An explicit `not_applicable` or
53
- accepted `deferred` row is retained only when its exclusion is material.
54
-
55
- ## 2. How `ultra-init` classifies a repository
56
-
57
- `task.init_project` scans a bounded repository view while ignoring `.git`,
58
- `.ultra`, dependencies, virtual environments, generated build output, and other
59
- known non-source directories.
60
-
61
- `auto` classification is deterministic:
62
-
63
- - `brownfield` when delivered-system evidence exists: application source, tests,
64
- deployment configuration, or persisted-state/schema evidence;
65
- - `greenfield` when none of those signals exists. A Git repository, README,
66
- package manifest, workspace manifest, or starter documentation alone does not
67
- prove delivered behavior;
68
- - `migrated` is never inferred from source. It is a compatibility state created
69
- when older Ultra authority is preserved and upgraded. It requires a new
70
- evidence-backed brownfield adoption before normal work.
71
-
72
- The scan also records bounded signal paths, detected verification commands,
73
- evidence-backed project type and technology signals, monorepo markers, candidate
74
- workspace roots, and whether the scan limit was reached. Explicit owner-supplied
75
- project type or stack metadata overrides detection without deleting the observed
76
- signals. In a monorepo, the owner selects the repository scope; baseline
77
- worktree digests and accepted dirty files are restricted to that scope.
78
-
79
- Classification and readiness are separate. Initialization immediately creates
80
- or resumes `.ultra/.runtime/state.db`, creates or imports the Git team checkpoint,
81
- installs only the required scaffold, records the classification, and completes an
82
- `init` workflow after read-back verification. A ready checkpoint baseline is held for
83
- checkout-local revalidation. Init
84
- does not create a research run. A later explicit `ultra-research` invocation selects
85
- `full` for greenfield or `adoption` for brownfield, records coverage dispositions, and
86
- works toward baseline readiness. Empty templates are not an approved baseline.
87
-
88
- With `git_mode: auto`, initialization preserves an existing repository and HEAD.
89
- When Git is absent it initializes `main` and adds the symlink-safe `.ultra` rule to
90
- `.gitignore`; an existing repository keeps its tracked ignore file unchanged. Init
91
- does not create a commit, remote, tag, or push. The resulting `unborn` worktree state
92
- is durable authority, not equivalent to a non-Git workspace. Full/adoption research
93
- must obtain explicit approval for one local checkpoint commit before
94
- `baseline.record`; until then `BASELINE_GIT_HEAD_REQUIRED` blocks convergence.
95
-
96
- Init completion means only that local authority, Git state, scaffold, and
97
- classification are usable. Baseline readiness is a separate research and convergence
98
- outcome; failure there never reopens or blocks the completed init workflow.
99
-
100
- ## 3. Durable status machines
101
-
102
- ### Baseline
63
+ | `ultra-init` | repository classification, scope, Git/runtime bootstrap | initialized local authority and empty/imported team checkpoint |
64
+ | `ultra-research` | adaptive evidence coverage and accepted baseline | baseline specs, research evidence, Decision Records, baseline checkpoint |
65
+ | `ultra-think` | one load-bearing owner decision or bounded diagnosis | normalized Decision Record and applied references |
66
+ | `ultra-change` | feature/fix/refactor/incident contract | active Change intent, classification, delta and decision scope |
67
+ | `ultra-plan` | Task contracts, topology, ownership, acceptance coverage | accepted Plan checkpoint, deterministic plan files, team checkpoint |
68
+ | `ultra-dev` | one owned vertical Task implementation | Worker Packet output, task outcome, implementation evidence checkpoint |
69
+ | `ultra-test` | risk-selected executable validation | test report and accepted test checkpoint |
70
+ | `ultra-review` | independent spec fidelity and engineering quality | specialist artifacts, coordinated summary, accepted review checkpoint |
71
+ | `ultra-deliver` | documentation/spec reconciliation and local archive | delivery evidence, converged baseline, immutable archive, team checkpoint |
72
+ | `ultra-status` | current Context rendering | no state mutation |
73
+ | `ultra-doctor` | mechanical health, migration, backup and repair | diagnostic/repair report; no product decision |
74
+
75
+ ## Context and decisions
76
+
77
+ One canonical Context Envelope flows through Skill, Hook, Session, Agent, and compact
78
+ recovery. Accepted Decision Records are always visible, including when no workflow is
79
+ active. A new session therefore resumes from accepted intent rather than reconstructing
80
+ it from conversation.
81
+
82
+ Decision history is append-only through supersession:
103
83
 
104
84
  ```text
105
- draft -> adopting -> ready -> superseded
106
- |
107
- -> blocked -> adopting
85
+ proposed -> accepted -> superseded
86
+ -> rejected
108
87
  ```
109
88
 
110
- - `draft`: greenfield authority exists but has not been established.
111
- - `adopting`: brownfield or migrated evidence is being recorded.
112
- - `blocked`: current baseline evidence, verification, scope, or approval cannot
113
- converge.
114
- - `ready`: research, evidence, repository snapshot, gaps, and approval converged.
115
- - `superseded`: preserved historical baseline after an explicitly authorized
116
- replacement.
89
+ The status of a proposal never grants execution authority. The accepted record, its
90
+ digest, applied references, and the owning checkpoint do.
117
91
 
118
- `ready` is not trusted as a label alone. Every baseline/status/doctor/change gate
119
- revalidates its persisted fields, current files, research outputs, revision and
120
- worktree, known-red acceptance, blocking gaps, and approval provenance. An ordinary
121
- active change may downgrade only the expected drift created after its completed
122
- `bind-baseline` step to warnings; it cannot downgrade adoption, migration, missing
123
- evidence, or structural blockers. Approved incident break-glass is the only other
124
- execution exception and creates a mandatory reconciliation gap.
92
+ ## Checkpoints, not fixed steps
125
93
 
126
- ### Change
94
+ Stage authority is revisioned:
127
95
 
128
96
  ```text
129
- active <-> blocked -> ready -> archived
130
- \--------------------------> cancelled
97
+ draft revision N
98
+ -> accepted revision N
99
+ -> accepted revision N+1 supersedes N
131
100
  ```
132
101
 
133
- Only a healthy `ready` baseline may authorize a new ordinary change. An incident
134
- may bypass an unhealthy baseline only with a stored reason and approver; archive
135
- then creates a blocking baseline-reconciliation gap.
102
+ A failed acceptance returns diagnostics and keeps the same draft mutable. Plan export
103
+ is part of Plan checkpoint publication, so changing a Task contract before acceptance
104
+ cannot invalidate an already-recorded “export step.” There is no locked intermediate
105
+ run to cancel or manually repair.
106
+
107
+ Accepted checkpoints are immutable evidence. New facts create a replacement draft.
108
+ Only archive history is terminal; subsequent product work opens a new Change.
109
+
110
+ ## Change lifecycle
136
111
 
137
- ### Task
112
+ Live v0.24 writes only:
138
113
 
139
114
  ```text
140
- pending -> in_progress -> completed
141
- | |
142
- v v
143
- blocked <------+
115
+ active -> archived
144
116
  |
145
- -> pending
146
-
147
- pending -> expanded -> completed
117
+ -> cancelled
148
118
  ```
149
119
 
150
- A task is executable only when its DB contract contains an observable outcome,
151
- traceability, slice kind, public seam, exact verification command, acceptance
152
- checks, context references, resolved documentation impact, owner, and valid
153
- dependencies.
154
-
155
- A semantic Change update traverses registered provenance and consumer edges and marks
156
- only reachable task, workflow, and artifact consumers stale. Unrelated tasks remain
157
- current. Clearing a task marker requires one complete execution-contract rebind through
158
- `task.update`; a marker-only clear is rejected. MCP validates the resulting contract
159
- and appends `task_contract_reconciled` with the current Change authority digest before
160
- a new plan may converge.
161
-
162
- A session process and a task have different status machines. Process exit zero closes
163
- the execution transport but leaves the task `in_progress` until development,
164
- integration, test, and review gates converge. Process failure marks the task `blocked`
165
- and records failure/circuit evidence. `session.close` preserves the worktree by
166
- default. Explicit removal succeeds only after Git proves it is clean and its commit is
167
- integrated into the current checkout.
168
-
169
- Dependency-wave automation advances only when every task in the current wave is
170
- `completed` or `expanded` in the DB. A successful worker exit with open gates emits
171
- `wave_paused` and `plan_paused`; it cannot start dependent work. Re-running the plan
172
- resumes the first unfinished wave. Explicit auto-merge is additionally gated by task
173
- completion, an exact completion commit, a ready dev workflow, a current task review,
174
- clean committed work, and successful integration; otherwise the worktree remains
175
- recoverable. Legacy tasks without change ownership retain their compatibility path,
176
- but cannot satisfy the current change workflow contract.
177
-
178
- Every session worktree resolves its ignored `.ultra` entry to the project authority
179
- directory. Automated workers receive the central DB path and the isolated checkout
180
- root separately; their supplied environment cannot override those bindings. If a
181
- legacy `.ultra/` rule does not ignore the link itself, Ultra adds a repository-local
182
- `info/exclude` entry without changing tracked files. A missing, tracked, still
183
- unignored, or conflicting authority entry fails before the session row or worker is
184
- created and the provisional worktree is removed. A process that already has
185
- `UBP_SESSION_ID` must reuse that lease and worktree; nested spawn and worker-side close
186
- are rejected, so the supervising parent alone settles the lease from the real process
187
- exit. Authority drift detected after wave selection pauses the plan without recording
188
- execution failure.
189
-
190
- ### Workflow run and step
120
+ `blocked`, `ready`, and `needs_attention` are derived diagnostics, not absorbing Change
121
+ states. An active Change may be revised. Archive requires complete current Task,
122
+ Context, test, review, documentation, and delivery checkpoints, then performs a
123
+ recoverable filesystem/DB transaction. Archived bytes remain immutable.
191
124
 
192
- ```text
193
- run: active <-> blocked -> ready -> completed
194
- \----> cancelled
125
+ Older `ready` or `blocked` rows are readable migration history. They do not authorize
126
+ new work until migration/revalidation derives current checkpoint authority.
127
+
128
+ ## Task and Session lifecycle
129
+
130
+ Task durable outcomes remain portable:
195
131
 
196
- step: pending -> in_progress -> completed
197
- | |
198
- v v
199
- blocked ------> in_progress/completed
132
+ ```text
133
+ pending -> completed
134
+ |
135
+ -> blocked
136
+ -> cancelled
200
137
  ```
201
138
 
202
- Required steps execute in definition order. A step that requires evidence or an
203
- output cannot complete without it. When the final required step completes, the
204
- run becomes `ready`; `workflow.complete` revalidates the entire stage before
205
- making it `completed`.
139
+ `in_progress`, Worker ownership, leases, PIDs, heartbeats, worktrees, and completion
140
+ commit backfill are checkout-local. They are not published to Git.
206
141
 
207
- ### Decision thread and item
142
+ `ultra.session acquire` atomically:
208
143
 
209
- ```text
210
- thread: active -> completed
211
- |
212
- +----> checkpoint_ready -> confirmed
213
- ^ | |
214
- |--------------+--------------+ revision/supersession
144
+ 1. checks a real lease/CAS conflict;
145
+ 2. compiles or reuses the exact Context Envelope;
146
+ 3. creates an immutable Worker Packet;
147
+ 4. allocates the lease/worktree;
148
+ 5. returns packet path/digest and exact execution boundary.
215
149
 
216
- item: open -> answered | delegated | deferred | superseded
217
- ```
150
+ A missing semantic detail is diagnostic, not a transport failure. A genuine lease,
151
+ digest, unsafe path, or concurrent authority conflict fails closed. Optional
152
+ orchestration can dispatch only a Change-owned Task with an accepted Plan checkpoint
153
+ and assigned Worker Packet.
218
154
 
219
- A thread is bound to baseline, change, or workflow authority. A partial unique index
220
- allows only one `open` item per thread. Resolved items remain immutable history;
221
- changed evidence or intent uses `decision.supersede` and reopens alignment.
222
- `decision.complete` closes settled normalized state without adding an approval claim.
223
- When an artifact-bound recovery boundary is actually needed, `decision.checkpoint`
224
- instead freezes a normalized decision digest and binds explicit owner approval to
225
- current artifact digests or a justified standalone no-artifact case. Neither path
226
- stores the conversation transcript.
227
-
228
- ## 4. Write and verification lifecycle
229
-
230
- | Stage | Authoritative writes | Completion verification | Available continuation |
231
- |---|---|---|---|
232
- | `init` | Baseline classification/scope, Git bootstrap state, completed init run, initialization event, empty or imported team checkpoint, projection job | DB/schema opens, scaffold/local projection/checkpoint and read-back succeed; existing Git is preserved or missing local Git is initialized; imported ready baseline is not trusted before local revalidation | Explicitly chosen `research`, `status`, or `doctor`; an already-ready project may also enter `change` |
233
- | `research` | Accepted coverage dispositions, selected step evidence, normalized material decisions, optional artifact checkpoints, typed semantic records with source digests, immutable reports, output paths and SHA-256 digests | Every included coverage area is dispositioned; only executed/verified/reused areas require work evidence; baseline synthesis binds current specifications and distillate, while Change synthesis stays in its overlay; all material decisions and digests are current | Baseline record/convergence for initial research; bounded Change research records its delta and returns to plan |
234
- | baseline convergence | Spec/source/runtime refs, verification results, known failures, unknowns, gaps, branch/HEAD/worktree, approval, and a published team checkpoint | Full/adoption research complete; required discovery/product/architecture refs current; revision/worktree exact; blocking gaps resolved or explicitly accepted where allowed | `change` for every initial or daily outcome |
235
- | `change` | Complete Change Contract, profile/risk rationale, research disposition, isolated Change root, typed delta, completed capture run, and portable Change checkpoint; a decision thread only when material intent remains unresolved | Intent, acceptance, recovery, classification, research disposition, exact baseline anchors, and checkpoint digest are current | Model recommends; owner selects bounded `research` or direct `plan`; both routes converge on plan before development |
236
- | `plan` | Accepted planning posture, immutable `plan/planning` context, selected planning evidence, complete change-owned task rows, acceptance coverage matrix, deterministic `<artifact_root>/plan.json` plus `plan.md`, and published task contracts; approval only for a material owner decision | Every Change acceptance id is owned by a task; trace targets, ownership, dependencies, topology, task contracts, planning-context binding, exported digests, and checkpoint generation match current authority | Any dependency-ready task may enter `dev` |
237
- | `dev` | Task/session transitions, real worktree, step evidence, immutable implementation context, completion/review references, and published durable task transitions | Task completed; no live session; task contract unchanged; starting context and review artifacts valid; the single completion commit is integrated and remains an ancestor of current HEAD; its hash is backfilled locally without another commit | Next task, then aggregate `test` |
238
- | `test` | Immutable checking context, an explicit risk-selected verification profile, and `<artifact_root>/test/<workflow-id>/report.json` | Selected dimensions and exact Change acceptance ids pass; every excluded dimension has a rationale; report change/task set, HEAD, worktree, context, commands, blockers, and digests agree | `review` when passing, otherwise resume `dev`/`test` |
239
- | `review` | Immutable review context plus risk-selected specialist and summary artifacts below `<artifact_root>/review/<workflow-id>/` | Current diff/HEAD and context match; the complete worker roster is selected or skipped with rationale; completed workers match specialist artifacts; both axes complete; findings and axis verdicts derive the final verdict | `deliver` only from a passing `change` review, otherwise resume implementation or checking |
240
- | `deliver` | Convergence context, typed delta, documentation reconciliation, recoverable overlay transaction, self-contained archive, and immutable delivery report | Tasks/test/change-review and acceptance are current; every before/after digest and baseline anchor is current; the archive transaction is complete; the report contains no release action | Report local completion or start the next `change`; publish/deploy/push are separate explicitly authorized operations |
241
- | `status` | None | Reads doctor, team-checkpoint condition, baseline, workflows, breadcrumb, tasks, sessions, Git, and DB-referenced reports | Shows allowed transitions, any hard required transition, and a host-owned recommendation |
242
- | `doctor` | None by default; explicit repair writes only mechanical recovery state | Re-runs integrity, schema, workflow-output, local projection, team-checkpoint, session, incident, archive, and install checks without choosing import/publish conflict resolution | Mechanically required recovery when unique; otherwise a set of safe recovery capabilities |
243
-
244
- Every mutating MCP operation appends an event and enqueues local projection work when
245
- the corresponding checkout-local read-only view can change. Projection failure is recorded as
246
- a retryable incident; it does not silently convert a failed write into success.
247
- Semantic handoff operations separately publish the Git team checkpoint.
248
- `task.append_event` accepts only non-authoritative observations. Lifecycle events are
249
- emitted by their owning DB mutation and never act as a substitute state transition.
250
-
251
- ### Team handoff checkpoint
252
-
253
- The Git checkpoint is intentionally lower-frequency than SQLite. It publishes accepted
254
- baseline, Change, plan, task-contract, and durable task-status boundaries; it does not
255
- mirror heartbeats, leases, active processes, telemetry, or provisional completion
256
- hashes. On MCP startup or explicit post-pull import, the receiving checkout validates
257
- checkpoint ancestry and record digests. Clean baseline, Change, and task records
258
- fast-forward independently. Concurrent edits to the same record or a remote edit to a
259
- locally active task stop without partial import.
260
-
261
- A checkpoint can restore portable project intent after clone, but cannot establish
262
- checkout truth by itself. An imported ready baseline becomes a local adoption/draft
263
- with `team-ledger-revalidation-required`; current scope content, HEAD, verification,
264
- known failures, and approval must converge again. Because baseline content hashing
265
- excludes `.ultra/`, committing the checkpoint cannot make its own baseline stale.
266
-
267
- ## 5. Human-agent alignment lifecycle
268
-
269
- The host first reads `decision.list` and resumes matching authority. It starts a new
270
- thread only for a new material decision cluster. Before asking, it must:
271
-
272
- 1. inspect repository, runtime, tests, specifications, and primary-source evidence;
273
- 2. resolve evidence-answerable facts without asking the owner;
274
- 3. normalize an unambiguous decision already present in the current user request
275
- instead of asking for redundant confirmation;
276
- 4. ask only when the remaining choice changes intent, public behavior, compatibility,
277
- security, material cost, external effects, or recovery. Use the host-native
278
- question surface declared by `spec/interaction-contract.json`;
279
- 5. present the earliest dependent choice with a recommendation, credible alternatives,
280
- evidence refs, and durable effects. Up to three independent low-load facts may be
281
- grouped when that reduces inconsistency;
282
- 6. normalize the owner response with `decision.resolve`, explicit reversible
283
- delegation with `decision.delegate`, or a consequence-bearing deferral with
284
- `decision.defer`;
285
- 7. apply accepted intent through the owning MCP operation or digest-bound artifact;
286
- 8. read the resulting authority back and record typed `applied_refs` when another
287
- authority changed;
288
- 9. call `decision.complete` when normalized state is settled, or prepare a compact
289
- checkpoint only when a material decision cluster changes a durable contract and
290
- interruption recovery needs an artifact-bound boundary.
291
-
292
- The shared semantic flow is `inspect -> suggest -> host-native ask -> normalize ->
293
- persist -> apply -> read back`. The ask is skipped only when current explicit intent
294
- already resolves the material choice. Claude Code and Kimi Code use `AskUserQuestion`, Codex uses
295
- `request_user_input` when its current mode exposes it, and OpenCode uses `question`
296
- when permitted. Every host falls back to one concise direct question when normal
297
- conversation is still allowed. If the current host mode forbids interaction entirely,
298
- the choice remains unanswered and route-dependent writes stop. A dismissed question
299
- also remains unanswered. The DB trusts a normalized persisted result as current
300
- authority across sessions; it does not store or verify a UI receipt, raw prompt, or
301
- transcript. Breadcrumb and decision reads recall completed normalized intent, so a new
302
- host session can continue without replaying the dialogue.
303
-
304
- `ultra-think` owns this interaction protocol. `ultra-research`, `ultra-change`, and
305
- `ultra-plan` invoke it at their decision boundaries. `ultra-dev`, `ultra-test`,
306
- `ultra-review`, and `ultra-deliver` stop and route back to the same thread when new
307
- owner authority is required; they never answer on the owner's behalf. `ultra-status`
308
- shows current unresolved decisions, relevant accepted intent, and the transition set,
309
- while `ultra-doctor` diagnoses stale checkpoint artifacts and recovery state.
310
-
311
- When only a bound artifact changes, the same resolved thread is prepared and approved
312
- again against the current digest; this is checkpoint renewal, not a fabricated decision
313
- revision. When the owner choice itself changes, supersession preserves the old item and
314
- opens one replacement.
315
-
316
- ## 6. Context and prompt follow-through
317
-
318
- `change.context` compiles an immutable Context Manifest v3 snapshot. It combines:
319
-
320
- - the bound baseline/change/task identity;
321
- - a role and lifecycle gate;
322
- - DB-backed task outcome, public seam, verification command, and required refs;
323
- - the selected task's bounded dependency/integration neighborhood rather than every
324
- unrelated task;
325
- - the task-context contract: purpose, why, constraints, non-goals, target seams/files,
326
- pattern refs, acceptance, documentation impact, recovery, and drift definition;
327
- - local file hashes, current HEAD, branch, and worktree digest;
328
- - optional metadata-only external memory or graph references;
329
- - advisory file/token/context-share budgets, including inline Change/task authority;
330
- - the current Change and task authority digests;
331
- - readiness blockers, `allowed_transitions`, and a `required_transition` only for a
332
- unique hard-recovery path.
333
-
334
- Compilation is pure with respect to accepted Change authority. Provider references are
335
- updated only through `change.update`; they cannot be smuggled into `change.context`.
336
- Context references retain `expected_digest`, `anchor`, `scope`, and
337
- `freshness_policy`. `digest` requires byte-current content, `existence` allows an
338
- implementation target to change while remaining present, and `advisory` reports drift
339
- without blocking.
340
-
341
- Critical stage workflows bind a matching snapshot as a durable output:
342
-
343
- | Workflow | Required role | Required gate |
344
- |---|---|---|
345
- | `plan` | `plan` | `planning` |
346
- | `dev` | `implement` | `implementation` |
347
- | `test` | `check` | `verification` |
348
- | `review` | `review` | `review` |
349
- | `deliver` | `check` | `convergence` |
350
-
351
- Every lookup is exact on `change_id + task_id + role + gate`. The snapshot path and
352
- digest are carried into plan, test, review, and delivery artifacts. `plan.export`
353
- writes only the owning Change's `plan.json` and deterministic `plan.md`, and binds the
354
- exact planning snapshot and digest to both the artifact registry and `verify-plan`.
355
- The legacy global `.ultra/execution-plan.json` is read-only migration compatibility,
356
- not current authority. These rules prevent a later Prompt or a different role packet
357
- from claiming evidence gathered under another context. Referenced file content remains
358
- lazy; only metadata and bounded task authority are inline. File and token budgets warn;
359
- they do not block legitimate work. Missing authority, required refs, stale
360
- digest-bound refs, task contracts, outputs, required owner decisions, or current gate
361
- evidence do block.
362
-
363
- ## 7. Invalidation rules
364
-
365
- - Changing a task contract invalidates contexts and gates that depended on the
366
- former contract.
367
- - Changing accepted Change intent, contract, classification, research disposition,
368
- provider evidence, or documentation impact invalidates only transitive registered
369
- consumers. Planning or task reconciliation must explicitly refresh affected
370
- authority before execution.
371
- - Changing required source/spec content invalidates the recorded output or
372
- context digest.
373
- - Changing a research semantic source invalidates that workflow even when its immutable
374
- step report remains unchanged.
375
- - Changing full HEAD or the worktree invalidates aggregate test, review, and
376
- delivery evidence.
377
- - A completed dev run remains valid across later task commits when its bound
378
- task contract is unchanged and its recorded commits remain ancestors of the
379
- current HEAD.
380
- - Test, review, and delivery reports use workflow-id paths so a later run cannot
381
- overwrite historical evidence.
382
- - `.ultra` workflow artifacts are excluded from application-worktree drift, but
383
- their own recorded SHA-256 digests are still authoritative.
384
- - Generated `.ultra/.runtime/projections/tasks.json` and complete runtime task-context
385
- files are local projections. Manual edits are overwritten and never repair DB
386
- authority.
387
- - `.ultra/tasks/tasks.json` is a tracked MCP checkpoint, not a local projection.
388
- Its full and per-record digests reject manual edits; publish/import performs typed
389
- fast-forward or conflict handling.
390
- - A changed checkpoint artifact digest or superseded decision invalidates the linked
391
- decision checkpoint and blocks matching workflow advancement until reconfirmed.
392
- - `workflow.revise` creates a candidate without deleting the completed prior run.
393
- `workflow.supersede` promotes only a completed matching candidate, preserves both
394
- histories, and invalidates only the prior run's transitive registered consumers.
395
-
396
- ## 8. Entry flows
397
-
398
- ### New project
155
+ ## Team sync
399
156
 
400
- ```text
401
- ultra-init -> Git/scaffold/authority verification -> init completed
402
- -> explicit ultra-research -> suggested route -> owner-selected accepted coverage
403
- -> selected evidence work
404
- -> local checkpoint when Git is unborn -> baseline approval
405
- -> ultra-change -> optional bounded research -> typed delta -> plan -> dev -> risk-selected test/review
406
- -> local deliver/archive
407
- ```
157
+ `.ultra/tasks/tasks.json` is a tracked, digest-chained team checkpoint. It carries
158
+ portable baseline, Change, Decision summary/reference, accepted Stage Checkpoint, Task
159
+ contract, dependency, and durable outcome records. It excludes local execution state.
408
160
 
409
- ### Existing project
161
+ `ultra.sync` supports:
410
162
 
411
- ```text
412
- ultra-init -> preserve Git/classify brownfield -> init completed
413
- -> explicit adoption research -> suggested route -> owner-selected accepted coverage
414
- -> selected characterization/known-red evidence -> gap ledger -> owner approval
415
- -> first ultra-change -> optional bounded research -> typed delta -> plan -> dev -> test/review -> deliver
416
- ```
163
+ - `inspect`: side-effect-free condition and migration advice;
164
+ - `migrate`: exact-byte backup-first legacy conversion;
165
+ - `import`: schema/digest/ancestry/CAS validation and clean fast-forward;
166
+ - `publish`: reconcile incoming Git authority, then publish one new generation.
417
167
 
418
- Adoption records the system that exists. It does not force the owner to recreate
419
- market, persona, or roadmap claims that cannot be supported; those remain
420
- `Unknown`, `not_applicable`, accepted `deferred`, or explicit gaps with evidence.
168
+ Same-record concurrent edits return a typed conflict. Ultra does not silently choose
169
+ one intent. Imported accepted baseline authority requires checkout-local source/spec
170
+ revalidation before descendant publication.
421
171
 
422
- ### Earlier Ultra project
172
+ Metadata-only Ultra commits do not make a baseline stale. Source or specification
173
+ drift remains visible and may require revalidation.
423
174
 
424
- ```text
425
- doctor/migrate with backup -> migrated compatibility authority
426
- -> explicit brownfield re-adoption -> full convergence -> normal change loop
427
- ```
175
+ ## Hook lifecycle
428
176
 
429
- Migration preserves prior files and rows but never carries old approval forward.
177
+ Hooks do not drive the capability graph. They:
430
178
 
431
- ### Daily maintenance
179
+ - inject a bounded Context Envelope where the host consumes it;
180
+ - protect the team checkpoint and generated projections from direct writes;
181
+ - save/restore minimal compact recovery state;
182
+ - record minimal lifecycle identifiers;
183
+ - return advisory Stop context.
432
184
 
433
- ```text
434
- ultra-status -> ultra-change intent capture
435
- -> model recommends; owner selects bounded research or direct plan
436
- -> typed delta -> plan -> dev -> risk-selected test -> review
437
- -> documentation reconciliation -> atomic deliver -> reconciled baseline
438
- ```
185
+ When a host ignores Hook stdout, the adapter records health/events only and every Skill
186
+ reads `ultra.context` explicitly. Hook limitations are never presented as successful
187
+ context injection.
439
188
 
440
- Quick changes shorten the artifact burden only where the machine contract allows;
441
- they do not skip task ownership, executable acceptance, current checking, review,
442
- or baseline reconciliation. Incidents add structured diagnosis and recovery
443
- evidence rather than bypassing them.
189
+ ## Recovery
444
190
 
445
- ### Command handoff graph
191
+ Use `ultra.context` first; legacy input must return a discoverable migration action
192
+ instead of blocking diagnosis. Use `ultra.sync migrate` for semantic conversion and
193
+ `ultra.doctor { repair: true }` for mechanical backup/recovery.
446
194
 
447
- | Entry | Owns | Normal handoff |
448
- |---|---|---|
449
- | `ultra-init` | classification, scope, Git/scaffold bootstrap, and init verification | stops completed; exposes research/status/doctor and any already-valid change capability |
450
- | `ultra-research` | coverage disposition, selected evidence acquisition, synthesis, and material research decisions | baseline convergence or Change delta then plan |
451
- | `ultra-think` | one material owner decision or read-only diagnosis | returns to the invoking capability after any needed checkpoint |
452
- | `ultra-change` | outcome capture, Change Contract, isolated overlay, typed delta, and risk/research routing | model recommends; owner selects research or direct plan; development is never a direct handoff |
453
- | `ultra-plan` | task contracts, dependencies, acceptance coverage, optional material approval | any dependency-ready task through `ultra-dev` |
454
- | `ultra-dev` | one task/session vertical slice and focused review | next `ultra-dev` task or aggregate `ultra-test` |
455
- | `ultra-test` | risk-selected change acceptance and verification profile | `ultra-review` on pass, `ultra-dev`/`ultra-test` on failure |
456
- | `ultra-review` | independent specification and engineering axes plus risk-selected workers | `ultra-deliver` on approval; otherwise implementation or checking |
457
- | `ultra-deliver` | convergence, reconciliation, local archive, and delivery evidence | `ultra-status` or the next `ultra-change`; external release is separate |
458
- | `ultra-status` | read-only authority and transition set | model recommendation; owner selection or delegation among allowed transitions |
459
- | `ultra-doctor` | read-only diagnosis and authorized mechanical recovery | required recovery only when unique; otherwise safe alternatives |
460
-
461
- Every row permits `ultra-think` when material owner authority is missing and permits
462
- `ultra-doctor` when state or installed-runtime authority is unhealthy. MCP makes one
463
- of them required only when no safe alternative exists. Neither capability creates a
464
- parallel workflow or substitutes a Prompt summary for DB state.
465
-
466
- ## 9. Recovery and diagnosis
467
-
468
- Use `system.doctor` for project authority and
469
- `ubp --all --global --doctor` for installed host assets. Both are read-only
470
- unless an explicit project repair command is chosen.
471
-
472
- During an explicit repair, a legacy active change that predates durable workflows gets
473
- one blocked change run at `bind-baseline` with
474
- `LEGACY_CHANGE_PROVENANCE_REQUIRED`; repair does not invent its evidence. Rebind it to
475
- the re-adopted baseline and resume the same run before planning. Every plan must use
476
- the exact baseline id stored by its owning change run; only an approved break-glass
477
- incident may legitimately bind no baseline id.
478
-
479
- Resume the same blocked workflow and current step after resolving its blocker.
480
- Do not create parallel runs to escape state. Supported schema and projection
481
- repairs are backup-first. A corrupt DB is preserved and requires an explicit
482
- restore or rebaseline decision; neither action can manufacture research,
483
- verification, or owner approval.
195
+ Migration supports v4.4/v4.5 projections and v0.22/v0.23 database/ledger authority.
196
+ It is exact-byte backup-first, transactional, and fail-closed on conflict. Legacy
197
+ workflow/dialogue rows survive as history but do not authorize current work.
198
+
199
+ Repair never invents a product choice, edits a semantic artifact to make it pass, or
200
+ asks the user to hand-edit SQLite.
201
+
202
+ ## Hard-error boundary
203
+
204
+ Only these classes fail the tool call:
205
+
206
+ - database/schema corruption;
207
+ - unsafe path, symlink, or identity swap;
208
+ - actual digest, CAS, or lease concurrency conflict;
209
+ - missing/incompatible native runtime;
210
+ - permission failure;
211
+ - archive/publish/deploy or another irreversible external-effect failure.
212
+
213
+ Evidence gaps, incomplete exploration, stale optional context, missing reports, or a
214
+ checkpoint that is not yet ready are structured diagnostics. The model remains free to
215
+ investigate, revise, and retry.