ultra-builder-pro-cli 0.20.0 → 0.21.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 (102) hide show
  1. package/.ultra-template/docs/research/README.md +26 -5
  2. package/.ultra-template/specs/discovery.md +1 -1
  3. package/.ultra-template/tasks/tasks.json +1 -1
  4. package/CHANGELOG.md +66 -0
  5. package/README.md +54 -24
  6. package/adapters/_shared/codex-assets.cjs +69 -11
  7. package/adapters/_shared/interaction-contract.cjs +36 -3
  8. package/adapters/_shared/runtime-assets.cjs +41 -1
  9. package/adapters/claude.js +7 -5
  10. package/adapters/codex.js +1 -1
  11. package/adapters/kimi.js +2 -8
  12. package/adapters/opencode.js +30 -28
  13. package/bin/orchestrator.js +64 -24
  14. package/docs/AGENT-CONTEXT.md +74 -43
  15. package/docs/ARCHITECTURE.md +63 -31
  16. package/docs/ARTIFACT-AUTHORITY.md +234 -0
  17. package/docs/DECISIONS.md +10 -4
  18. package/docs/LEGACY-CLI-CROSSWALK.md +6 -4
  19. package/docs/PLUGIN-ISOLATION-CONTRACT.md +4 -3
  20. package/docs/ROADMAP.md +19 -5
  21. package/docs/RUNTIME-COMPAT-MATRIX.md +24 -13
  22. package/docs/STATE-DB-ACCESS-POLICY.md +11 -9
  23. package/docs/WORKFLOW-LIFECYCLE.md +70 -39
  24. package/hooks/README.md +6 -5
  25. package/hooks/active_task_context.py +97 -12
  26. package/hooks/context_spine.py +16 -4
  27. package/hooks/health_check.py +5 -4
  28. package/hooks/pre_stop_check.py +5 -2
  29. package/hooks/runtime_paths.py +396 -0
  30. package/hooks/subagent_tracker.py +5 -2
  31. package/hooks/workflow_checkpoint.py +16 -3
  32. package/hooks/workflow_context.py +11 -3
  33. package/hooks/workflow_resume.py +7 -4
  34. package/mcp-server/breadcrumb.cjs +20 -2
  35. package/mcp-server/lib/archive-journal.cjs +1026 -111
  36. package/mcp-server/lib/archive-mutation-worker.py +365 -0
  37. package/mcp-server/lib/artifact-registry.cjs +1126 -0
  38. package/mcp-server/lib/baseline-workflow.cjs +9 -4
  39. package/mcp-server/lib/change-packet.cjs +818 -0
  40. package/mcp-server/lib/change-workflow.cjs +932 -176
  41. package/mcp-server/lib/context-paths.cjs +111 -0
  42. package/mcp-server/lib/context-spine.cjs +511 -45
  43. package/mcp-server/lib/decision-dialogue.cjs +345 -3
  44. package/mcp-server/lib/delivery-transaction.cjs +471 -0
  45. package/mcp-server/lib/doctor-backup-worker.cjs +328 -0
  46. package/mcp-server/lib/doctor.cjs +373 -11
  47. package/mcp-server/lib/git-bootstrap.cjs +459 -47
  48. package/mcp-server/lib/init-project.cjs +190 -95
  49. package/mcp-server/lib/plan-publication-worker.cjs +830 -0
  50. package/mcp-server/lib/plan-store.cjs +700 -5
  51. package/mcp-server/lib/project-breadcrumb.cjs +23 -4
  52. package/mcp-server/lib/projector.cjs +174 -40
  53. package/mcp-server/lib/runtime-paths.cjs +1687 -0
  54. package/mcp-server/lib/safe-project-file.cjs +385 -0
  55. package/mcp-server/lib/spec-learning.cjs +28 -12
  56. package/mcp-server/lib/state-db.cjs +263 -9
  57. package/mcp-server/lib/state-ops.cjs +248 -49
  58. package/mcp-server/lib/telemetry.cjs +12 -3
  59. package/mcp-server/lib/workflow-state.cjs +610 -58
  60. package/mcp-server/server.cjs +278 -33
  61. package/orchestrator/daemon.cjs +2 -10
  62. package/orchestrator/parallel-orchestrator.cjs +314 -50
  63. package/orchestrator/planner/plan-builder.cjs +1 -1
  64. package/orchestrator/recovery.cjs +125 -7
  65. package/orchestrator/session-close-journal-worker.cjs +5 -0
  66. package/orchestrator/session-close-journal.cjs +1014 -0
  67. package/orchestrator/session-runner.cjs +679 -69
  68. package/orchestrator/worktree-manager.cjs +186 -35
  69. package/package.json +2 -3
  70. package/skills/cc-collab/SKILL.md +4 -1
  71. package/skills/codex-collab/SKILL.md +5 -2
  72. package/skills/ultra-change/SKILL.md +26 -8
  73. package/skills/ultra-deliver/SKILL.md +23 -11
  74. package/skills/ultra-dev/SKILL.md +33 -6
  75. package/skills/ultra-doctor/SKILL.md +6 -2
  76. package/skills/ultra-init/SKILL.md +4 -2
  77. package/skills/ultra-plan/SKILL.md +49 -16
  78. package/skills/ultra-research/SKILL.md +30 -27
  79. package/skills/ultra-review/SKILL.md +9 -5
  80. package/skills/ultra-status/SKILL.md +9 -4
  81. package/skills/ultra-test/SKILL.md +10 -5
  82. package/skills/ultra-think/SKILL.md +6 -2
  83. package/skills/ultra-think/references/decision-dialogue.md +17 -6
  84. package/skills/ultra-verify/SKILL.md +4 -1
  85. package/spec/cli-protocol.md +18 -7
  86. package/spec/mcp-tools.yaml +502 -44
  87. package/spec/schemas/change-delta.v1.schema.json +153 -0
  88. package/spec/schemas/documentation-reconciliation.v1.schema.json +106 -0
  89. package/spec/schemas/mcp-tools.schema.json +1 -1
  90. package/spec/schemas/state-db.sql +50 -13
  91. package/spec/schemas/tasks.v4.5.schema.json +1 -1
  92. package/ultra-tools/cli.cjs +3 -2
  93. package/ultra-tools/commands/db.cjs +76 -25
  94. package/ultra-tools/commands/migrate.cjs +995 -80
  95. package/ultra-tools/commands/session.cjs +34 -8
  96. package/ultra-tools/commands/status.cjs +32 -6
  97. package/ultra-tools/commands/system.cjs +129 -22
  98. package/commands/learn.md +0 -10
  99. package/orchestrator/skill-miner.cjs +0 -133
  100. package/output-styles/coding-vibes.md +0 -67
  101. package/output-styles/structural-thinking.md +0 -61
  102. package/skills/learn/SKILL.md +0 -58
@@ -10,10 +10,11 @@
10
10
  Ultra Builder Pro engineering loop (skills + commands + workflow hooks) as
11
11
  native Claude Code, OpenCode, Codex, and Kimi Code plugins, and
12
12
  **runs** that loop with isolated sessions sharing one authoritative state
13
- store (`.ultra/state.db`).
13
+ store (`.ultra/.runtime/state.db`).
14
14
 
15
- It is not an agent and it is not a memory provider. It is the workflow substrate
16
- the supported hosts share.
15
+ It is not an agent or a general conversational-memory provider. It is the workflow
16
+ substrate the supported hosts share, including project-local cross-session workflow
17
+ memory under `.ultra/`.
17
18
 
18
19
  ## 2. Three layers
19
20
 
@@ -38,20 +39,20 @@ the supported hosts share.
38
39
  └────────────┬───────┴──────────────────┘
39
40
  ▼
40
41
  ┌─────────────────────┐
41
- │ .ultra/state.db │
42
- │ (SQLite + WAL) │ ← single authoritative store
42
+ │ .ultra/.runtime/state.db │
43
+ │ (SQLite + WAL) │ ← lifecycle + index authority
43
44
  └──────────┬──────────┘
44
45
  │ projector (Phase 2.6)
45
46
  ▼
46
47
  .ultra/tasks/tasks.json (read-only view)
47
- .ultra/tasks/contexts/*.md (read-only header)
48
+ .ultra/tasks/contexts/*.md (fully generated read-only view)
48
49
  .ultra/activity-log.json (optional dump)
49
50
  ```
50
51
 
51
52
  | Layer | Role | Form |
52
53
  |--------------|----------------------------------------------|-------------------------------------------------------|
53
54
  | **skill** | knowledge carrier; tells the runtime *what to do* | `skills/<name>/SKILL.md` discovered natively by all supported runtimes |
54
- | **MCP** | authoritative workflow-state, decision, and Context Spine API | stdio MCP server exposing 51 live tools across task/session/baseline/change/decision/workflow/system/plan families in [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
55
+ | **MCP** | authoritative workflow-state, decision, artifact, and Context Spine API | stdio MCP server exposing 57 live tools across task/session/baseline/change/decision/workflow/artifact/system/plan families in [`spec/mcp-tools.yaml`](../spec/mcp-tools.yaml) |
55
56
  | **CLI** | explicit initialization, recovery, diagnostics, and orchestration | `ultra-tools` / `ubp-orchestrator`; only commands listed by `--help` are executable (see [`spec/cli-protocol.md`](../spec/cli-protocol.md)) |
56
57
 
57
58
  Why three: skills give us behavior portability across runtimes; MCP gives
@@ -64,10 +65,19 @@ The skill layer is **read-only by design** (D29) and is discovered directly by
64
65
  each host. Ultra exposes no `skill.*` MCP family: skills are documentation, not
65
66
  RPC, and host-native loaders own resolution and invocation.
66
67
 
67
- ## 3. Authoritative state — `.ultra/state.db`
68
+ ## 3. Workflow memory and authoritative state
68
69
 
69
- All durable Ultra workflow state lives in one SQLite file with WAL enabled. Schema is
70
- fixed in [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) and
70
+ Together, `.ultra/` retains project-local cross-session workflow memory:
71
+ normalized intent, progress, tasks, bounded context, specifications, evidence,
72
+ provenance, and recovery. `.ultra/.runtime/state.db` is the sole authority for lifecycle,
73
+ indexing, transitions, freshness, and coordination. Registered digest-bound files
74
+ carry semantic and evidence bodies. Generated projections and working scratch do
75
+ not become authority merely because they live under `.ultra/`. The complete
76
+ classification and promotion contract is
77
+ [`ARTIFACT-AUTHORITY.md`](./ARTIFACT-AUTHORITY.md).
78
+
79
+ All durable Ultra lifecycle and index state lives in one SQLite file with WAL enabled.
80
+ Schema is fixed in [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) and
71
81
  covers twenty-one tables:
72
82
 
73
83
  | Table | Holds | Phase |
@@ -82,7 +92,8 @@ covers twenty-one tables:
82
92
  | `specs_refs` | spec change tracking → staleness propagation | 5 |
83
93
  | `circuit_breaker` | bounded retry and halt state for failed tasks | 5 |
84
94
  | `changes` | continuous feature/fix/incident lifecycle, alignment-thread link, and incident baseline bypass | 12→16 |
85
- | `artifacts` | intent/context/verification artifact registry | 8C |
95
+ | `artifacts` | typed semantic/evidence ownership, digest, status, and provenance | 8C→20 |
96
+ | `artifact_edges` | normalized source and consumer dependency graph | 20 |
86
97
  | `context_snapshots`| role/gate context, readiness, budget, execution seam, hashes, git head, provider refs | 10 |
87
98
  | `spec_learning_candidates` | approval-gated implementation discoveries for baseline convergence | 10 |
88
99
  | `trace_links` | task/spec/change traceability | 8C |
@@ -98,14 +109,15 @@ Two rules make this work:
98
109
 
99
110
  1. **No double source (D32).** lease/heartbeat live only in `sessions`,
100
111
  not in a `lease.json` file. Activity log lives only in `events`, not
101
- in JSON files. `tasks.json` and the status header in
102
- `contexts/task-*.md` are **projections** generated by the projector;
112
+ in JSON files. `tasks.json` and the complete
113
+ `contexts/task-*.md` files are **projections** generated by the projector;
103
114
  manual edits are overwritten on the next state.db change.
104
115
 
105
116
  2. **Single writer for mutable tables, multi-writer for `events`.**
106
- `.ultra/state.db` opens in WAL with `busy_timeout=5000`. The MCP
117
+ `.ultra/.runtime/state.db` opens in WAL with `busy_timeout=5000`. The MCP
107
118
  server holds the single writer connection for `baselines`, `tasks`, `sessions`,
108
- `changes`, `decision_threads`, `decision_items`, `workflow_runs`, `workflow_steps`, `artifacts`, `context_snapshots`,
119
+ `changes`, `decision_threads`, `decision_items`, `workflow_runs`, `workflow_steps`,
120
+ `artifacts`, `artifact_edges`, `context_snapshots`,
109
121
  `spec_learning_candidates`, `incidents`, `projection_jobs`, `telemetry`,
110
122
  `specs_refs`, and `migration_history`; the CLI calls
111
123
  those tools over stdio rather than opening its own writer. The
@@ -123,14 +135,18 @@ Two rules make this work:
123
135
  Subscribers always pull `events.id > since_id` rather than `max(ts)`,
124
136
  because two events may share the same millisecond timestamp (D31).
125
137
 
126
- ### Memory ownership is outside Ultra Builder Pro
138
+ ### General memory and graph ownership remain outside Ultra Builder Pro
127
139
 
128
140
  Ultra Builder Pro does not retain prompts, transcripts, tool observations,
129
- session summaries, or cross-session memory. It ships no `memory.*` MCP family,
130
- no recall skill, and no memory-capture hook. A separately installed provider
131
- such as cloud-mem/claude-mem owns persistent memory and its own lifecycle. The
132
- only related migration surface is the explicit `ultra-tools legacy-memory`
133
- archive/prune command for data created by older releases.
141
+ session summaries, general conversational memory, or code-graph payloads. It ships
142
+ no `memory.*` MCP family, general recall skill, or memory-capture hook. A separately
143
+ installed provider such as cloud-mem/claude-mem owns general persistent memory and
144
+ its own lifecycle. Ultra stores only bounded provider metadata references needed by
145
+ workflow context. The only related migration surface is the explicit
146
+ `ultra-tools legacy-memory` inspect/archive/confirmed-prune command for general memory
147
+ data created by older releases. It is never called by a hook, MCP operation, or
148
+ session lifecycle; it does not collect, recall, reflect, or remove Ultra workflow
149
+ authority.
134
150
 
135
151
  ### Project baseline adoption
136
152
 
@@ -197,9 +213,12 @@ alternatives, evidence refs, and durable effects; a partial unique index guarant
197
213
  current question per thread. The host ends that turn and waits.
198
214
 
199
215
  The next response becomes a normalized owner decision, explicit reversible delegation,
200
- or consequence-bearing deferral. Prompts and transcripts are never persisted. Routine
201
- settled state closes through `decision.complete`, which is lifecycle completion rather
202
- than another approval. Only a coherent cluster that needs an artifact-bound recovery
216
+ or consequence-bearing deferral. Prompts and transcripts are never persisted. The host
217
+ applies accepted intent through the owning MCP operation or digest-bound artifact,
218
+ reads it back, and records typed `applied_refs` when another authority changed. Routine
219
+ settled state then closes through `decision.complete`, which is lifecycle completion
220
+ rather than another approval. The breadcrumb recalls normalized accepted intent after
221
+ the thread closes. Only a coherent cluster that needs an artifact-bound recovery
203
222
  boundary moves through prepare/confirm checkpointing. Matching workflow steps fail
204
223
  closed while a blocking question, blocking deferral, prepared checkpoint, or stale
205
224
  checkpoint artifact remains. Supersession preserves prior history and reopens alignment
@@ -215,10 +234,11 @@ is represented by a `changes` row and an inspectable packet:
215
234
  ```text
216
235
  active -> blocked -> active -> ready -> archived
217
236
  | |
218
- ├─ intent + delta + plan └─ verification + baseline reconciliation
219
- ├─ linked tasks
220
- ├─ immutable context snapshots (role + gate + readiness + execution seam)
221
- └─ spec-learning candidates (proposed -> approved/rejected -> applied)
237
+ ├─ intent + adaptive research + findings
238
+ ├─ typed delta + documentation reconciliation + deterministic progress
239
+ ├─ plan + linked tasks + immutable contexts
240
+ ├─ Change-scoped test/review/delivery evidence
241
+ └─ atomic baseline apply + self-contained archive
222
242
  ```
223
243
 
224
244
  `quick`, `standard`, `major`, and `incident` kinds require different evidence,
@@ -226,6 +246,18 @@ but all require completed linked tasks, current context, declared documentation
226
246
  impact, and no open incident. Memory and graph payloads never enter Ultra;
227
247
  `context_snapshots.provider_refs_json` stores metadata references only.
228
248
 
249
+ Baseline files are immutable while a Change is active. `change.delta` registers
250
+ overlay payloads against exact baseline revision and specification digests.
251
+ `change.documentation_reconcile` records exact document before/after evidence and
252
+ consumer trace. Standard and major convergence requires both current authorities.
253
+ `change.archive` preflights the whole write set and uses a recoverable transaction;
254
+ only after all writes and baseline reconciliation succeed does it rebind the complete
255
+ Change root into the archive.
256
+
257
+ Workflow revisions preserve prior accepted runs. A candidate becomes current only
258
+ through `workflow.supersede`; the artifact graph then invalidates the prior run's true
259
+ transitive consumers without staling unrelated tasks.
260
+
229
261
  ### Context Spine
230
262
 
231
263
  Context Manifest v3 is the immutable handoff contract between planning,
@@ -296,7 +328,7 @@ swallowed warning. `system.doctor` is read-only by default. Explicit repair perf
296
328
  backup-first schema upgrade, archive-journal recovery, session and projection
297
329
  recovery, and regenerated projections. It cannot approve a baseline or replace a
298
330
  corrupt SQLite file silently. `system restore` accepts only a verified SQLite backup
299
- inside `.ultra/backups`, quarantines the corrupt authority, and rolls back on failure.
331
+ inside `.ultra/.runtime/backups`, quarantines the corrupt authority, and rolls back on failure.
300
332
  When no valid backup exists, confirmed `system rebaseline` preserves both corrupt
301
333
  authority and the legacy task projection before creating a new brownfield adoption.
302
334
 
@@ -309,7 +341,7 @@ A **session** is the standard unit of execution across all four runtimes
309
341
  - an isolated `git worktree` created by `session.spawn`,
310
342
  - an ignored `.ultra` link from that checkout to the one central authority,
311
343
  - a lease + heartbeat row in `sessions` (D32),
312
- - an `artifact_dir` under `.ultra/sessions/<sid>/` for logs and scratch;
344
+ - an `artifact_dir` under `.ultra/.runtime/sessions/<sid>/` for logs and scratch;
313
345
  - either the active host operating in that exact worktree or an explicitly configured
314
346
  worker process.
315
347
 
@@ -371,7 +403,7 @@ rejects corrupt, non-object, schema-mismatched, or terminal candidates, and
371
403
  selects the newest valid state. A newer live state wins; a newer checkpoint can
372
404
  atomically restore a missing or older live state before context is re-injected.
373
405
  The checkpoint is therefore a recovery artifact and consumer, never a second
374
- durable authority alongside `.ultra/state.db`.
406
+ durable authority alongside `.ultra/.runtime/state.db`.
375
407
 
376
408
  ## 7. Installation provenance — read-only cross-host diagnosis
377
409
 
@@ -0,0 +1,234 @@
1
+ # Ultra artifact authority
2
+
3
+ This document defines what `.ultra/` remembers across sessions, which surface owns
4
+ each fact, and how working output becomes durable Ultra authority.
5
+
6
+ ## Boundary
7
+
8
+ `.ultra/` is the project-local cross-session workflow-memory envelope for Ultra
9
+ Builder Pro. It retains normalized intent, lifecycle progress, tasks, bounded execution
10
+ context, specifications, evidence, provenance, recovery state, and external provider
11
+ references. It is not a general conversational-memory system and does not retain raw
12
+ prompts, transcripts, chain-of-thought, general episodic summaries, or code-graph
13
+ payloads.
14
+
15
+ Semantic and evidence artifacts under `.ultra/` are trackable so reviewed intent and
16
+ verification can travel with the repository. `.ultra/.runtime/` is always ignored:
17
+ the SQLite authority, leases, worktrees, local telemetry, and recovery snapshots remain
18
+ checkout-local unless a team uses an explicit synchronization or artifact handoff.
19
+
20
+ ## Artifact classes
21
+
22
+ | Class | Examples | Authority |
23
+ |---|---|---|
24
+ | Lifecycle and index | `.ultra/.runtime/state.db` | Sole authority for identifiers, normalized accepted intent, status, legal transitions, references, digests, freshness, provenance, locks, leases, transactions, recovery, and coordination |
25
+ | Digest-bound semantic artifacts | specifications, research reports, Change intent/delta/plan, context manifests | Authoritative semantic bodies only while registered by the owning DB row or workflow step and matching its recorded digest |
26
+ | Digest-bound evidence artifacts | test, review, delivery, and verification reports | Authoritative evidence bodies only while registered, immutable where required, and matching the recorded digest and scope |
27
+ | Generated projections | `tasks/tasks.json`, generated task-status headers, activity exports | Read-only views derived from DB authority; manual edits are overwritten and never become authority |
28
+ | Advisory recovery | `.ultra/.runtime/checkpoint.json` | Compact recovery hint derived from DB authority; stale or missing content never overrides the DB |
29
+ | Working scratch | `.ultra/.runtime/collab/`, temporary session output, incomplete drafts | Non-authoritative working material until verified and promoted through a supported workflow write |
30
+ | External provider references | memory or code-graph provider name, scope, version, stable reference, freshness metadata | Metadata-only context stored by Ultra; the provider remains authority for its payload |
31
+
32
+ The DB is not expected to contain every semantic paragraph. It owns the lifecycle and
33
+ the binding between a fact and its current content. A digest-bound file owns the
34
+ registered semantic or evidence body. Neither surface is a parallel lifecycle source.
35
+
36
+ ## Human, model, and mechanical responsibilities
37
+
38
+ | Actor | Responsible for | Must not do |
39
+ |---|---|---|
40
+ | Owner | Goals, acceptance, non-goals, material choices, risk acceptance, and authorization for irreversible or external effects | Supply facts the checkout or runtime can establish directly |
41
+ | Host model | Inspect evidence, recommend a route, ask only for unresolved owner choices, normalize the answer, call the owning write, update semantic artifacts, read back the result, and present the next recommendation | Fabricate evidence, infer owner authorization, or bypass legal transitions |
42
+ | Ultra MCP | Persist normalized inputs, validate structure and current digests, record lifecycle and provenance, enforce legal transitions, project views, and expose recovery | Choose product direction, prove a UI click, force a semantic route, or replace model judgment |
43
+ | Host adapter | Render the shared interaction contract through the host-native question and tool surfaces | Become a second workflow authority |
44
+ | Hook | Observe lifecycle, inject compact DB-derived recovery context, and protect generated projections | Select a semantic route or block ordinary development |
45
+
46
+ ## Intent persistence
47
+
48
+ The interaction sequence is:
49
+
50
+ ```text
51
+ inspect -> suggest -> host-native ask -> normalize -> persist -> apply -> read back
52
+ ```
53
+
54
+ The host-native ask is conditional. An explicit owner instruction can already resolve
55
+ a choice, so the model must not ask
56
+ again merely to manufacture proof. When interaction is needed, the adapter uses the
57
+ host-native question surface. Once the model writes the normalized result through
58
+ `decision.resolve`, `decision.delegate`, or `decision.defer`, the DB treats that result
59
+ as current cross-session intent authority. It does not store or verify a UI receipt,
60
+ raw prompt, or transcript.
61
+
62
+ If the accepted decision changes another Ultra authority, the model applies that change
63
+ through its owning MCP tool or digest-bound artifact, reads the result back, and passes
64
+ typed `applied_refs` to `decision.complete`. A decision whose normalized record is
65
+ itself the complete authority may have no applied reference. Breadcrumb and decision
66
+ read paths recall accepted intent only after the dialogue thread is completed or
67
+ confirmed. A row-backed applied reference names an exact field and canonical value,
68
+ with an optional digest of that value. A specification or artifact reference names
69
+ the exact file digest. Row existence alone never proves that intent was applied.
70
+
71
+ ## Promotion and evidence
72
+
73
+ Working material becomes durable only when all applicable conditions hold:
74
+
75
+ 1. the active workflow permits the write;
76
+ 2. consequential claims are verified against the checkout, runtime, test result, or
77
+ primary source;
78
+ 3. the model writes through the owning MCP operation or immutable artifact path;
79
+ 4. the DB records the owning baseline, change, workflow, task, or artifact reference;
80
+ 5. content-bearing files match the recorded SHA-256 digest and scope;
81
+ 6. the model reads back the resulting state before reporting completion.
82
+
83
+ The durable evidence trail may include normalized decisions, delegation source,
84
+ durable effects, typed applied references, workflow-step evidence, artifact hashes,
85
+ verification commands and results, provenance, events, and recovery state. It must not
86
+ include chain-of-thought, UI-click proof, raw prompts, or conversation transcripts.
87
+
88
+ Verified conclusions from `.ultra/.runtime/collab/` or other scratch locations must be promoted
89
+ into the invoking DB-bound workflow artifact or report. Keeping a file in the scratch
90
+ directory is not promotion.
91
+
92
+ ## Change overlay authority
93
+
94
+ An active Change is an isolated overlay below
95
+ `.ultra/changes/active/<change-id>/`. Its intent, adaptive research, `findings.md`,
96
+ typed delta payloads, plan, contexts, documentation payloads, progress projection,
97
+ test reports, review artifacts, and delivery evidence remain below that root. Change
98
+ research never edits baseline specifications.
99
+
100
+ `change.delta` registers exact baseline id, repository revision, specification
101
+ digests, accepted decisions, non-goals, acceptance, documentation impact, unknowns,
102
+ and every semantic mutation's before/after digest. A no-semantic-change result is an
103
+ explicit typed delta, not an absent file. `progress.md` is a deterministic projection
104
+ of the registered delta and documentation state; it is never an independent status
105
+ authority.
106
+
107
+ `change.documentation_reconcile` binds the current delta id and digest, every changed
108
+ document's before/after digest, delta and acceptance references, verification, and a
109
+ verified consumer or explicit no-consumer reason. Standard and major delivery require
110
+ one current reconciliation even when its document set is empty.
111
+
112
+ `change.archive` preflights the complete target set before writing, applies overlay
113
+ bytes through a recoverable local transaction, refreshes baseline digests, moves the
114
+ complete Change root to its archive location, and rebinds registry paths. A conflict,
115
+ crash, or DB failure must roll back or resume the whole packet; no subset is reported
116
+ as delivered.
117
+
118
+ ## Context and plan authority
119
+
120
+ `change.context` is a pure compiler. It reads accepted Change, task, baseline, checkout,
121
+ and provider-reference authority and writes one immutable manifest plus its DB snapshot
122
+ row. It never updates provider references or semantic Change fields. Each snapshot is
123
+ identified exactly by `change_id`, nullable `task_id`, `role`, and `gate`; consumers
124
+ must not substitute a newer snapshot from a different tuple.
125
+
126
+ Context refs preserve `expected_digest`, `anchor`, `scope`, and `freshness_policy`.
127
+ Digest-bound refs are revalidated at the consuming gate, existence-bound implementation
128
+ targets may change while remaining present, and advisory drift is retained as a
129
+ warning. File bodies stay lazy. Implementation manifests inline only the selected task,
130
+ its direct dependency/integration neighborhood, and its task-context contract.
131
+
132
+ A current plan is a Change-owned pair:
133
+
134
+ - `<artifact_root>/plan.json` is the machine-readable topology and exact planning
135
+ context binding;
136
+ - `<artifact_root>/plan.md` is the deterministic human projection of the same plan and
137
+ task contracts.
138
+
139
+ `plan.export` selects both paths from the owning Change and accepts no arbitrary output
140
+ path. `verify-plan` binds the JSON digest and the preceding `plan/planning` snapshot;
141
+ the artifact registry records both plan files with that context provenance. Publication
142
+ preflights both path authorities and prior digests, rejects symlinked ancestors or
143
+ targets, and journals the two file replacements so a registry or event failure restores
144
+ both prior files while the SQLite transaction rolls back. The global
145
+ `.ultra/execution-plan.json` remains readable only for explicit legacy migration and is
146
+ never current write or dispatch authority.
147
+
148
+ ## Registry contract
149
+
150
+ `artifact.record` is the public writer for a semantic or evidence file that is not
151
+ already registered by its owning workflow operation. Every managed registry row has:
152
+
153
+ - a typed `owner_type` and `owner_id`;
154
+ - an artifact `kind`, project-relative `path`, lifecycle `status`, and SHA-256
155
+ `digest`;
156
+ - `before_digest` and `after_digest` values for optimistic write validation and
157
+ change evidence;
158
+ - structured `provenance` and optional metadata;
159
+ - normalized source and consumer edges in `artifact_edges`.
160
+
161
+ The write replaces all edges for the artifact in one immediate SQLite transaction.
162
+ It never accumulates stale edges with `INSERT OR IGNORE`. If an existing digest
163
+ changes, the same transaction emits `spec_changed`, marks only reachable artifact
164
+ and task consumers stale through typed artifact/task/workflow/change intermediates,
165
+ and records the exact invalidated endpoints. Self-edges and dependency cycles are
166
+ rejected without changing prior authority. A caller can provide
167
+ `expected_before_digest`; a mismatch fails without changing the row or its edges.
168
+
169
+ `artifact.get` reads by unique ID or unambiguous path. It fails closed when a path
170
+ has multiple active authorities and reports whether the row satisfies the managed
171
+ registry contract. A canonical path can have only one non-archived authority across
172
+ all owners and kinds. Runtime, scratch, `tasks.json`, and generated task contexts
173
+ cannot be promoted through this API.
174
+
175
+ Owning internal writers use the same transaction contract. Change intent, delta and
176
+ documentation packets, contexts, adaptive research, findings, incident diagnosis,
177
+ plan, test, review, delivery, archive reconciliation, and specification learning
178
+ cannot update a managed digest or provenance through a parallel SQL path.
179
+
180
+ Rows migrated from pre-20 schemas remain readable and preserve their original IDs,
181
+ paths, hashes, timestamps, and legacy change/task ownership. They are marked
182
+ `managed = 0` until an owning workflow or `artifact.record` supplies complete
183
+ provenance and dependency edges. This compatibility state preserves data without
184
+ pretending that an old row satisfies the current registry contract.
185
+
186
+ ## Dependency and orphan diagnosis
187
+
188
+ `system.doctor` compares the registry, dependency graph, filesystem, and owner
189
+ tables. It reports:
190
+
191
+ - unregistered semantic or evidence files;
192
+ - registered files that are missing or whose digest/status is stale;
193
+ - missing typed owners;
194
+ - current managed artifacts without a consumer, unless explicitly terminal;
195
+ - dangling source or consumer endpoints;
196
+ - graph cycles that cannot become consumer evidence;
197
+ - more than one active authority for the same canonical path;
198
+ - legacy compatibility rows that remain unmanaged;
199
+ - generated task contexts whose task no longer exists.
200
+
201
+ `.ultra/.runtime/**`, `.ultra/scratch/**`, and fixed scaffold support files are outside
202
+ orphan diagnosis. Current generated projections are recognized from the DB task set,
203
+ not from a blanket directory exemption. Before a baseline is ready, only the reserved
204
+ `discovery.md`, `product.md`, `architecture.md`, and `research-distillate.md` scaffold
205
+ paths under `.ultra/specs/` are provisional; every additional specification is subject
206
+ to orphan diagnosis immediately. Completion cannot be manufactured by registering
207
+ empty templates. Doctor and status expose registered, managed, and unmanaged counts,
208
+ and compatibility remains unhealthy until every retained row is deliberately promoted
209
+ or retired.
210
+
211
+ ## Task-context projection
212
+
213
+ `.ultra/tasks/contexts/<task-id>.md` is fully generated from current DB authority.
214
+ The projector replaces the whole file, including its execution contract and stale
215
+ banner, and marks it with `generated_by: ultra-projector`. It never preserves arbitrary
216
+ prose inserted into an earlier projection.
217
+
218
+ Before replacing an existing authored context, the projector promotes the exact legacy
219
+ body bytes once into a digest-bound `legacy_context_findings` artifact owned and
220
+ consumed by the task. Legacy frontmatter, stale banners, and generated contract marker
221
+ regions are removed first; any remaining authored body is retained exactly, even when
222
+ an older projector had preserved it after a generated contract. Replacement is skipped
223
+ without promotion only when no authored content remains. If promotion cannot be
224
+ registered, projection fails without deleting the authored body. A context target must
225
+ remain lexically and physically below
226
+ `.ultra/tasks/contexts/`; traversal and symlink ancestors are rejected by projection and
227
+ migration. When a task disappears, only an orphan carrying the generated marker may be
228
+ pruned, and the removal emits `projection_pruned`; unknown authored files are retained
229
+ for diagnosis.
230
+
231
+ Model findings, decisions, or evidence discovered during development must be written
232
+ below the owning Change root and registered through the workflow or `artifact.record`.
233
+ The next context projection references that authority. Editing the task-context body
234
+ or an accepted baseline specification directly is neither persistence nor promotion.
package/docs/DECISIONS.md CHANGED
@@ -15,9 +15,12 @@ release-version authority.
15
15
  | Host adapter | Native Skill discovery, user-question surfaces, tool invocation, installation, and runtime wiring | A second project-state authority |
16
16
  | Hook | Lifecycle observation, compact DB-derived context, recovery hints, and generated-projection protection | Ordinary development blocking or semantic route selection |
17
17
 
18
- `.ultra/state.db` is the only durable Ultra lifecycle authority. Generated JSON
19
- and Markdown are projections or evidence artifacts. Prompt text, chat history,
20
- external memory, and code-graph payloads are not Ultra authority.
18
+ `.ultra/` is project-local cross-session workflow memory. `.ultra/.runtime/state.db` is
19
+ the only lifecycle, index, transition, freshness, and coordination authority.
20
+ Registered digest-bound files carry semantic or evidence bodies; generated
21
+ projections and working scratch are not authority. Prompt text, chat history,
22
+ general external-memory payloads, and code-graph payloads are not Ultra
23
+ authority. See [`ARTIFACT-AUTHORITY.md`](./ARTIFACT-AUTHORITY.md).
21
24
 
22
25
  ## Research coverage
23
26
 
@@ -34,7 +37,10 @@ MCP validates generic invariants: selected identifiers must exist, dispositions
34
37
  must be legal, reused or excluded evidence must be referenced, synthesis must be
35
38
  active, and at least one non-synthesis area must be applicable. MCP does not
36
39
  choose the coverage set or prove how the owner answered. Once normalized intent
37
- is written, `.ultra/state.db` treats it as current cross-session authority.
40
+ is written, `.ultra/.runtime/state.db` treats it as current cross-session authority. If
41
+ that intent changes another Ultra authority, the host applies the change,
42
+ reads it back, and records typed applied references when completing the
43
+ decision thread.
38
44
 
39
45
  ## Lifecycle boundaries
40
46
 
@@ -37,8 +37,9 @@ contract and adds stronger authority, recovery, or portability.
37
37
 
38
38
  The following are deliberate extensions built on the original spine:
39
39
 
40
- 1. `.ultra/state.db` as the only lifecycle authority; Markdown and JSON are artifacts
41
- or projections.
40
+ 1. `.ultra/.runtime/state.db` as the only lifecycle and index authority; registered
41
+ digest-bound Markdown and JSON carry semantic or evidence bodies, while generated
42
+ views remain projections.
42
43
  2. Typed MCP transitions for baseline, change, decision, workflow, task, session,
43
44
  incident, projection, and evidence state.
44
45
  3. Greenfield, brownfield, monorepo-scope, migrated, restore, and rebaseline paths.
@@ -57,7 +58,8 @@ The following are deliberate extensions built on the original spine:
57
58
 
58
59
  These items are not compatibility losses:
59
60
 
60
- - embedded prompt, transcript, observation, summary, or cross-session memory;
61
+ - embedded prompt, transcript, observation journal, session summary, or general
62
+ conversational cross-session memory;
61
63
  - an internal code graph or memory store;
62
64
  - retired model runtimes and their prompts;
63
65
  - retired command-proxy integrations;
@@ -146,7 +148,7 @@ status
146
148
  | Dependency waves advanced after transport exit | The plan pauses at the first non-terminal wave and resumes only after its DB tasks converge. |
147
149
  | A crafted or merely exported plan could bypass current plan authority | Change-owned dispatch requires a healthy completed plan workflow and the exact current DB graph; malformed, cyclic, stale, duplicate-task, or cross-change plans fail before session creation. |
148
150
  | Direct session or daemon spawn bypassed the current plan | Every change-owned admission and spawn revalidates current task-contract digests, task set, dependencies, and staleness before takeover or worktree creation. |
149
- | A worker launched inside a worktree could create a second `.ultra/state.db` | Every session checkout links its ignored `.ultra` entry to central authority and receives non-overridable DB/root bindings; legacy repositories get a local `info/exclude` rule without tracked drift, while unsafe ignore or link state rolls back before worker launch. |
151
+ | A worker launched inside a worktree could create a second `.ultra/.runtime/state.db` | Every session checkout links its ignored `.ultra` entry to central authority and receives non-overridable DB/root bindings; legacy repositories get a local `info/exclude` rule without tracked drift, while unsafe ignore or link state rolls back before worker launch. |
150
152
  | Plan authority could drift between wave admission and actual spawn | The spawn-time gate converts this race into an authority pause without task-failure or circuit-breaker evidence. |
151
153
  | Explicit auto-merge could integrate before workflow gates | A change-owned auto-merge requires the exact completion commit, ready dev evidence, a current task review, and clean committed Git work; otherwise the worktree is preserved. |
152
154
  | Session close or auto-merge could delete uncommitted work | Close preserves by default; explicit cleanup verifies clean and integrated Git ancestry. |
@@ -12,7 +12,8 @@ An adapter may write only:
12
12
  - the plugin's own provenance and managed-file markers.
13
13
 
14
14
  The first command allowed to create project authority is `ultra-init`. Once invoked,
15
- Ultra owns only the repository-local `.ultra/` authority and its generated projections.
15
+ Ultra owns only the repository-local `.ultra/` workflow-memory envelope and its
16
+ generated projections.
16
17
 
17
18
  ## Surfaces Ultra does not own
18
19
 
@@ -21,7 +22,7 @@ Install, update, doctor, and uninstall must not create, rewrite, trim, merge, or
21
22
  - user-level `CLAUDE.md`, `AGENTS.md`, or equivalent instruction files;
22
23
  - repository-level instruction files;
23
24
  - project source, Git history, remotes, or `.ultra/` data;
24
- - memory or code-graph provider data.
25
+ - general memory or code-graph provider data.
25
26
 
26
27
  Existing Ultra marker blocks in a user handbook are legacy user content after this
27
28
  contract takes effect. They are not silently removed because the plugin cannot prove
@@ -44,7 +45,7 @@ Internal review-rule skills remain available only to their bounded workers.
44
45
 
45
46
  ## Idle behavior
46
47
 
47
- Outside a repository containing `.ultra/state.db`, all Ultra hooks are silent. Inside
48
+ Outside a repository containing `.ultra/.runtime/state.db`, all Ultra hooks are silent. Inside
48
49
  an initialized repository they remain silent unless a DB-authoritative workflow is
49
50
  active, blocked, or ready. The sole idle-time enforcement is protection against direct
50
51
  writes to generated Ultra projections; the DB remains authoritative.
package/docs/ROADMAP.md CHANGED
@@ -40,7 +40,7 @@ sharing one authoritative workflow store.
40
40
  | 5 | Recovery + staleness + auto-routing | ✅ done (D43) → v0.2 |
41
41
  | 6 | Monitoring + telemetry | ✅ done (D44) → v0.2 |
42
42
  | 4.6b | Full conformance suite | ✅ done (D45) — 20 conformance + 21 resolveTarget tests |
43
- | 7 | tagged tasks + skill mining; retired Ultra memory delegated to external providers | ✅ superseded by the package-boundary cleanup |
43
+ | 7 | tagged tasks; non-core generation and retention surfaces removed from the plugin | ✅ superseded by the package-boundary cleanup |
44
44
  | 8A | Plan automation (parse / topo / expand + artifact + human gate) | ✅ done (D47, `a932cb8`) → v0.3 |
45
45
  | 8B | Execution automation (dispatch / parallel worktree / merge) | ✅ done (D48, `8224159`) — **v0.3 ready** |
46
46
  | 8C | Continuous change packets + context compiler + convergence + doctor | ✅ done (D52) |
@@ -50,20 +50,21 @@ sharing one authoritative workflow store.
50
50
  | 13 | Durable init-to-delivery workflows + task execution contracts + immutable stage evidence | ✅ done |
51
51
  | 16 | Resumable one-question owner-agent decisions + artifact checkpoints + workflow gates | ✅ done |
52
52
  | 19 | Non-ceremonial decision completion + four-host semantic-selection contract | ✅ done |
53
+ | 20 | Typed artifact registry + normalized dependency graph + orphan diagnostics | ✅ done |
53
54
  | 9 | Release pipeline | npm tag publishing live; Homebrew / pip not implemented |
54
55
 
55
56
  ## What is in the repo today
56
57
 
57
58
  ```
58
59
  spec/ ← Phase 1 single source of truth
59
- ├── mcp-tools.yaml (51 live tools across 8 families)
60
+ ├── mcp-tools.yaml (57 live tools across 9 families)
60
61
  ├── cli-protocol.md (CLI ↔ MCP mapping table)
61
62
  ├── schemas/ (state-db.sql + 4 JSON schemas)
62
63
  ├── fixtures/{valid,invalid}/ (+ v4.4-project for migration)
63
64
  └── scripts/test-all.cjs (npm run test:spec — 7 validation stages)
64
65
 
65
66
  mcp-server/ ← Phase 2 authoritative state layer
66
- ├── server.cjs (stdio MCP server, 51 task/session/baseline/change/decision/workflow/system/plan tools)
67
+ ├── server.cjs (stdio MCP server, 57 task/session/baseline/change/decision/workflow/artifact/system/plan tools)
67
68
  ├── lib/
68
69
  │ ├── state-db.cjs (SQLite + WAL + pragmas)
69
70
  │ ├── state-ops.cjs (full write API, status state machine)
@@ -81,9 +82,22 @@ ultra-tools/ ← CLI fallback, migration, and diagnostics
81
82
  └── legacy-memory.cjs (explicit inspect/archive/confirmed prune)
82
83
 
83
84
  bin/install.js ← multi-runtime installer
84
- adapters/ ← native Claude/OpenCode/Codex plugin builders
85
+ adapters/ ← native host plugin builders
86
+ ├── claude.js
87
+ ├── opencode.js
88
+ ├── codex.js
89
+ └── kimi.js
85
90
  skills/ ← allowlisted Ultra workflows, internal rules, and collab companions
86
- hooks/ ← 7 executable workflow hooks + shared Context Spine helper; OpenCode uses native JavaScript hooks
91
+ hooks/ ← allowlisted workflow hooks; OpenCode uses native JavaScript hooks
92
+ ├── active_task_context.py
93
+ ├── context_spine.py
94
+ ├── health_check.py
95
+ ├── pre_stop_check.py
96
+ ├── runtime_paths.py
97
+ ├── subagent_tracker.py
98
+ ├── workflow_checkpoint.py
99
+ ├── workflow_context.py
100
+ └── workflow_resume.py
87
101
  docs/
88
102
  ├── DECISIONS.md current authority and package boundaries
89
103
  ├── ARCHITECTURE.md Phase 1 single-page entry point