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