ultra-builder-pro-cli 0.17.1 → 0.19.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 (42) hide show
  1. package/CHANGELOG.md +77 -6
  2. package/README.md +380 -261
  3. package/adapters/_shared/codex-assets.cjs +24 -16
  4. package/adapters/_shared/file-ops.cjs +40 -3
  5. package/adapters/_shared/provenance.cjs +90 -6
  6. package/adapters/_shared/runtime-assets.cjs +0 -11
  7. package/adapters/claude.js +3 -1
  8. package/adapters/kimi.js +4 -30
  9. package/adapters/opencode.js +50 -14
  10. package/docs/AGENT-CONTEXT.md +11 -14
  11. package/docs/ARCHITECTURE.md +23 -15
  12. package/docs/DECISIONS.md +75 -0
  13. package/docs/LEGACY-CLI-CROSSWALK.md +3 -3
  14. package/docs/PLUGIN-ISOLATION-CONTRACT.md +54 -0
  15. package/docs/ROADMAP.md +13 -13
  16. package/docs/RUNTIME-COMPAT-MATRIX.md +24 -21
  17. package/docs/STATE-DB-ACCESS-POLICY.md +2 -2
  18. package/docs/WORKFLOW-LIFECYCLE.md +12 -10
  19. package/hooks/active_task_context.py +1 -1
  20. package/hooks/context_spine.py +1 -1
  21. package/hooks/health_check.py +19 -0
  22. package/hooks/pre_stop_check.py +1 -1
  23. package/hooks/workflow_checkpoint.py +1 -1
  24. package/hooks/workflow_context.py +1 -1
  25. package/hooks/workflow_resume.py +1 -1
  26. package/mcp-server/lib/workflow-state.cjs +67 -54
  27. package/mcp-server/server.cjs +19 -7
  28. package/orchestrator/dispatch-rules.cjs +1 -1
  29. package/package.json +4 -5
  30. package/skills/ultra-change/SKILL.md +4 -3
  31. package/skills/ultra-init/SKILL.md +2 -1
  32. package/skills/ultra-research/SKILL.md +7 -4
  33. package/spec/cli-protocol.md +4 -4
  34. package/spec/mcp-tools.yaml +6 -6
  35. package/spec/schemas/context-file.v4.5.schema.json +1 -1
  36. package/spec/schemas/mcp-tools.schema.json +3 -3
  37. package/spec/schemas/state-db.sql +3 -3
  38. package/spec/schemas/tasks.v4.5.schema.json +1 -1
  39. package/adapters/_shared/handbook.cjs +0 -156
  40. package/bin/handbook.js +0 -54
  41. package/docs/PLAN.zh-CN.md +0 -1696
  42. package/docs/USER-HANDBOOK-CONTRACT.md +0 -81
@@ -1,10 +1,8 @@
1
1
  # Ultra Builder Pro CLI — Architecture
2
2
 
3
- > Single-page entry point for reviewers and contributors. The detailed
4
- > roadmap and decision log live in [`docs/PLAN.zh-CN.md`](./PLAN.zh-CN.md);
5
- > this file freezes the architectural shape that the PLAN drives toward.
6
- >
7
- > Trace: PLAN §4, decisions D12 / D13 / D18 / D20 / D29 / D32 / D33.
3
+ > Single-page entry point for reviewers and contributors. Current authority and
4
+ > package boundaries live in [`docs/DECISIONS.md`](./DECISIONS.md); executable
5
+ > behavior remains defined by source, schemas, and tests.
8
6
 
9
7
  ## 1. One sentence
10
8
 
@@ -143,9 +141,9 @@ same authoritative state shape without rewriting application code.
143
141
 
144
142
  Initialization completes after local authority, classification, Git/scaffold setup,
145
143
  and read-back verification. It does not start or complete research. An explicit
146
- `ultra-research` invocation then records a disposition for each of the seventeen
147
- coverage areas and executes, verifies, or reuses only the evidence needed to converge
148
- the baseline.
144
+ `ultra-research` invocation then records the model-selected semantic coverage and
145
+ executes, verifies, or reuses only the evidence needed to converge the baseline.
146
+ Omitted catalog areas create no workflow row.
149
147
 
150
148
  Auto initialization preserves an existing Git repository and HEAD. When Git is absent,
151
149
  it initializes `main`, adds the symlink-safe `.ultra` rule to `.gitignore`, and persists
@@ -248,7 +246,8 @@ snapshot as an output; test, review, and delivery reports carry its digest forwa
248
246
 
249
247
  `change.breadcrumb` derives the compact current position from state.db. Session,
250
248
  edit, resume, and OpenCode lifecycle hooks invoke one bundled read-only reader
251
- and inject only this breadcrumb, never the intent body,
249
+ and inject it only while state.db proves an active, blocked, or ready workflow,
250
+ never the intent body,
252
251
  provider content, or a conversation summary. A changed Git HEAD, task contract, or
253
252
  Change semantic authority marks the snapshot stale and permits recompilation through
254
253
  `change.context`.
@@ -259,6 +258,14 @@ baseline/change ownership, and transaction boundaries, then persists them. It
259
258
  does not call Anthropic, OpenAI, or another model provider and needs no separate
260
259
  model API credential.
261
260
 
261
+ Plugin installation does not activate a semantic workflow and never edits the
262
+ user's `CLAUDE.md`, `AGENTS.md`, or equivalent durable instructions. Public
263
+ workflows require explicit user invocation. A completed workflow returns
264
+ mechanically allowed transitions and a host-owned recommendation, then stops;
265
+ it never launches the next public workflow. OpenCode realizes this boundary
266
+ with explicit commands backed by private plugin workflow assets, while Claude,
267
+ Codex, and Kimi use their native implicit-invocation controls.
268
+
262
269
  File count, token estimate, and context-share overflow produce warnings, never a
263
270
  refusal. The agent may narrow reads, load files lazily, or split a slice when that
264
271
  preserves correctness; it must not raise a threshold merely to clear a gate or
@@ -370,11 +377,12 @@ host-specific plugin, MCP, hook, launcher, and runtime contracts expected at
370
377
  that install scope. It never attributes a package to an enclosing consumer
371
378
  repository commit.
372
379
 
373
- `ubp --doctor [--json]` is read-only: it recomputes hashes and validates those
374
- entry points, returning a non-zero degraded result for missing/corrupt
375
- provenance, content drift, or broken host wiring. This is separate from
376
- `system.doctor`, which diagnoses project state, projection, incidents, sessions,
377
- and backup-first workflow recovery.
380
+ `ubp --all --global --doctor [--json]` is read-only: it recomputes hashes and
381
+ validates those entry points, returning a non-zero degraded result for
382
+ missing/corrupt provenance, content drift, or broken host wiring. A single host
383
+ can be selected instead of `--all`. This is separate from `system.doctor`, which
384
+ diagnoses project state, projection, incidents, sessions, and backup-first
385
+ workflow recovery.
378
386
 
379
387
  ## 8. Two timelines — rule layer vs execution layer
380
388
 
@@ -412,7 +420,7 @@ shippable; downstream slip never blocks an earlier release.
412
420
  | How do CLI subcommands map to MCP tools? | [`spec/cli-protocol.md`](../spec/cli-protocol.md) |
413
421
  | Exact SQLite schema? | [`spec/schemas/state-db.sql`](../spec/schemas/state-db.sql) |
414
422
  | What does a tasks.json look like after projection? | [`spec/fixtures/valid/tasks.v4.5.json`](../spec/fixtures/valid/tasks.v4.5.json) |
415
- | Phase-by-phase work breakdown + decision log | [`docs/PLAN.zh-CN.md`](./PLAN.zh-CN.md) |
423
+ | Current authority and package decisions | [`docs/DECISIONS.md`](./DECISIONS.md) |
416
424
  | When does each workflow write, invalidate, and converge state? | [`docs/WORKFLOW-LIFECYCLE.md`](./WORKFLOW-LIFECYCLE.md) |
417
425
 
418
426
  ## 10. Verifying the architecture
@@ -0,0 +1,75 @@
1
+ # Ultra Builder Pro decision contract
2
+
3
+ This document records the current product and authority boundaries that apply to
4
+ the distributed package. Executable behavior remains defined by source,
5
+ `spec/mcp-tools.yaml`, and `spec/schemas/state-db.sql`; `package.json` is the
6
+ release-version authority.
7
+
8
+ ## Authority split
9
+
10
+ | Layer | Owns | Must not own |
11
+ |---|---|---|
12
+ | User intent | Goals, acceptance, non-goals, material product trade-offs, risk acceptance, and authorization for irreversible or external effects | Facts that the current checkout or runtime can establish directly |
13
+ | Host model | Classification, investigation, research coverage, solution design, task decomposition, context, test and review strategy, documentation impact, and next-action recommendations | Fabricated evidence, bypassed authorization, or durable lifecycle state |
14
+ | Ultra MCP | IDs, state, digests, provenance, freshness, locks, leases, transactions, recovery, and legal state transitions | Product direction, a fixed research route, technology selection, or business decisions |
15
+ | Host adapter | Native Skill discovery, user-question surfaces, tool invocation, installation, and runtime wiring | A second project-state authority |
16
+ | Hook | Lifecycle observation, compact DB-derived context, recovery hints, and generated-projection protection | Ordinary development blocking or semantic route selection |
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.
21
+
22
+ ## Research coverage
23
+
24
+ The research references form an optional semantic catalog. The host model
25
+ selects only the areas justified by the current goal and evidence, records an
26
+ evidence-based selection reason, and always includes synthesis. Omitted catalog
27
+ areas create no workflow rows. An explicit `not_applicable` or accepted
28
+ `deferred` entry is recorded only when preserving that exclusion is useful.
29
+
30
+ MCP validates generic invariants: selected identifiers must exist, dispositions
31
+ must be legal, reused or excluded evidence must be referenced, synthesis must be
32
+ active, and at least one non-synthesis area must be applicable. MCP does not
33
+ choose the coverage set.
34
+
35
+ ## Lifecycle boundaries
36
+
37
+ - `ultra-init` classifies and initializes local project authority. It does not
38
+ perform product research or start another workflow.
39
+ - `ultra-research` establishes or refreshes evidence and converges a baseline
40
+ only after the required user decisions and local Git authority exist.
41
+ - `ultra-change` owns post-baseline product deltas. Research, planning,
42
+ development, testing, review, and delivery remain separately invocable
43
+ capabilities with DB-enforced prerequisites.
44
+ - `ultra-deliver` converges local Ultra evidence. Commit, push, publish, deploy,
45
+ messaging, and other external effects remain separately authorized host
46
+ actions.
47
+
48
+ ## Package boundary
49
+
50
+ The package contains the public Ultra workflows, internal review-rule Skills,
51
+ host-specific collaboration companions, MCP runtime, adapters, lifecycle hooks,
52
+ and minimal project bootstrap. General browser, deployment, framework,
53
+ discovery, memory, and graph capabilities remain owned by their separately
54
+ installed providers. Ultra stores only bounded provider metadata references.
55
+
56
+ ## Installation provenance
57
+
58
+ Each host installation records package identity, repository, source commit when
59
+ available, installed-asset hashes, and contract targets. A local source checkout
60
+ also records whether it was dirty and a deterministic worktree digest. An npm
61
+ installation has no package-local Git repository and records those source
62
+ checkout fields as `null`; it never inherits an enclosing consumer repository.
63
+
64
+ Installation and project diagnostics are read-only unless an explicit repair or
65
+ install action is requested. No local workflow completion authorizes a remote,
66
+ release, deployment, or destructive effect.
67
+
68
+ ## Current source map
69
+
70
+ - Runtime architecture: [`ARCHITECTURE.md`](./ARCHITECTURE.md)
71
+ - Workflow state and invalidation: [`WORKFLOW-LIFECYCLE.md`](./WORKFLOW-LIFECYCLE.md)
72
+ - Host compatibility: [`RUNTIME-COMPAT-MATRIX.md`](./RUNTIME-COMPAT-MATRIX.md)
73
+ - Plugin and user-instruction boundary: [`PLUGIN-ISOLATION-CONTRACT.md`](./PLUGIN-ISOLATION-CONTRACT.md)
74
+ - MCP interface: [`../spec/mcp-tools.yaml`](../spec/mcp-tools.yaml)
75
+ - Database contract: [`../spec/schemas/state-db.sql`](../spec/schemas/state-db.sql)
@@ -24,7 +24,7 @@ contract and adds stronger authority, recovery, or portability.
24
24
  | Original capability | Current implementation | Compatibility result |
25
25
  |---|---|---|
26
26
  | Init gathers project facts, creates Ultra files, and establishes Git | `task.init_project` performs deterministic classification, scaffold, schema, Git bootstrap, read-back verification, and then stops | Preserved and strengthened. Init has its own completion boundary and never starts research implicitly. |
27
- | Complete product and architecture research | `ultra-research` retains the 17 semantic areas as a coverage catalog with execute/verify/reuse/not-applicable/deferred dispositions | Preserved without questionnaire overload. Necessary reports, typed semantic records, source digests, and material decision checkpoints add durable evidence. |
27
+ | Complete product and architecture research | `ultra-research` retains the semantic reference catalog while the model selects only applicable areas and records execute/verify/reuse/not-applicable/deferred dispositions as needed | Preserved without questionnaire overload. Necessary reports, typed semantic records, source digests, and material decision checkpoints add durable evidence. |
28
28
  | Planning converts accepted research into executable work with dependencies | `ultra-plan` persists complete change-owned task contracts and an exact dependency graph | Preserved and strengthened with topology, acceptance coverage, public seams, verification commands, and plan digests. |
29
29
  | Development uses isolated Git work, TDD, verification, review, commit, and integration | `ultra-dev`, `session.*`, and the session runner create real worktrees and retain task/review/commit evidence | Preserved and strengthened. Process exit cannot complete a task; uncommitted or unintegrated worktrees cannot be deleted. |
30
30
  | Test checks wiring, acceptance, regression, build, performance, security, and failures | `ultra-test` emits a change-bound immutable report covering each applicable dimension | Preserved and strengthened with HEAD, context, task-set, and report-digest validation. |
@@ -83,7 +83,7 @@ task.init_project
83
83
  -> greenfield classification
84
84
  -> Git bootstrap when absent
85
85
  -> init read-back and completion
86
- -> explicit full research with 17 coverage dispositions
86
+ -> explicit full research with model-selected coverage
87
87
  -> selected execute/verify/reuse work and synthesis
88
88
  -> owner-authorized local checkpoint commit when Git is unborn
89
89
  -> baseline.record
@@ -99,7 +99,7 @@ task.init_project
99
99
  -> brownfield classification and selected scope
100
100
  -> preserve current Git HEAD and dirty-state evidence
101
101
  -> init read-back and completion
102
- -> explicit adoption research with 17 coverage dispositions
102
+ -> explicit adoption research with model-selected coverage
103
103
  -> characterization verification + known-red/gap ledger
104
104
  -> baseline.record + owner approval
105
105
  -> baseline.converge
@@ -0,0 +1,54 @@
1
+ # Plugin Isolation Contract
2
+
3
+ Ultra Builder Pro is an explicitly invoked, removable workflow plugin. Installation
4
+ must not change a user's durable engineering policy or initialize any repository.
5
+
6
+ ## Owned surfaces
7
+
8
+ An adapter may write only:
9
+
10
+ - the host's plugin-owned command, skill, worker, hook, and runtime directories;
11
+ - the host registry or manifest entries required to load those assets;
12
+ - the plugin's own provenance and managed-file markers.
13
+
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.
16
+
17
+ ## Surfaces Ultra does not own
18
+
19
+ Install, update, doctor, and uninstall must not create, rewrite, trim, merge, or delete:
20
+
21
+ - user-level `CLAUDE.md`, `AGENTS.md`, or equivalent instruction files;
22
+ - repository-level instruction files;
23
+ - project source, Git history, remotes, or `.ultra/` data;
24
+ - memory or code-graph provider data.
25
+
26
+ Existing Ultra marker blocks in a user handbook are legacy user content after this
27
+ contract takes effect. They are not silently removed because the plugin cannot prove
28
+ ownership or preserve unrelated edits. The owner may review and remove them separately.
29
+
30
+ ## Activation
31
+
32
+ Public Ultra workflows run only after an explicit user command or skill invocation.
33
+ Completion of one workflow may return allowed transitions and a recommendation, but it
34
+ must not start another public workflow.
35
+
36
+ Host adapters prevent implicit model activation with the strongest native mechanism:
37
+
38
+ - Claude Code and Kimi Code mark public workflow skills as model-disabled;
39
+ - Codex marks workflow metadata as implicit-invocation-disabled;
40
+ - OpenCode exposes public workflows through commands backed by private plugin assets,
41
+ not through the model-discoverable skill catalog.
42
+
43
+ Internal review-rule skills remain available only to their bounded workers.
44
+
45
+ ## Idle behavior
46
+
47
+ Outside a repository containing `.ultra/state.db`, all Ultra hooks are silent. Inside
48
+ an initialized repository they remain silent unless a DB-authoritative workflow is
49
+ active, blocked, or ready. The sole idle-time enforcement is protection against direct
50
+ writes to generated Ultra projections; the DB remains authoritative.
51
+
52
+ Installation tests preserve byte-for-byte snapshots of all supported user handbook
53
+ paths. Runtime tests cover explicit activation, idle silence, active recovery, and
54
+ projection protection.
package/docs/ROADMAP.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # ultra-builder-pro-cli — Roadmap
2
2
 
3
- > **Current roadmap**. [`PLAN.zh-CN.md`](./PLAN.zh-CN.md) preserves the original
4
- > phase plan and decision history. Current executable contracts live in
5
- > `spec/`, `AGENT-CONTEXT.md`, and `RUNTIME-COMPAT-MATRIX.md`; those sources win
6
- > when historical plan text differs.
3
+ > **Current roadmap**. [`DECISIONS.md`](./DECISIONS.md) defines the current
4
+ > authority and package boundaries. Executable contracts live in `spec/`,
5
+ > `AGENT-CONTEXT.md`, and `RUNTIME-COMPAT-MATRIX.md`; source and contract tests
6
+ > win when roadmap text drifts.
7
7
 
8
8
  **Goal**: distribute the Ultra Builder Pro engineering loop as native Claude
9
9
  Code, OpenCode, Codex, and Kimi Code plugins, and run it with isolated sessions
@@ -13,7 +13,8 @@ sharing one authoritative workflow store.
13
13
 
14
14
  **Distribution channels (v1.0)**: npm · Homebrew · pip.
15
15
 
16
- **Release line**: `0.16.x`; every release is gated by `npm run verify:release`.
16
+ **Release line**: the `package.json` version; every release is gated by
17
+ `npm run verify:release`.
17
18
 
18
19
  ---
19
20
 
@@ -39,11 +40,11 @@ sharing one authoritative workflow store.
39
40
  | 5 | Recovery + staleness + auto-routing | ✅ done (D43) → v0.2 |
40
41
  | 6 | Monitoring + telemetry | ✅ done (D44) → v0.2 |
41
42
  | 4.6b | Full conformance suite | ✅ done (D45) — 20 conformance + 21 resolveTarget tests |
42
- | 7 | tagged tasks + skill mining; retired Ultra memory handed to cloud-mem/claude-mem | ✅ superseded by D50 boundary cleanup |
43
+ | 7 | tagged tasks + skill mining; retired Ultra memory delegated to external providers | ✅ superseded by the package-boundary cleanup |
43
44
  | 8A | Plan automation (parse / topo / expand + artifact + human gate) | ✅ done (D47, `a932cb8`) → v0.3 |
44
45
  | 8B | Execution automation (dispatch / parallel worktree / merge) | ✅ done (D48, `8224159`) — **v0.3 ready** |
45
46
  | 8C | Continuous change packets + context compiler + convergence + doctor | ✅ done (D52) |
46
- | 10 | Context Spine v2 + breadcrumb + fresh-context budget + spec learning + two-axis review | ✅ done |
47
+ | 10 | Context Manifest v3 + breadcrumb + fresh-context budget + spec learning + two-axis review | ✅ done |
47
48
  | 11 | Greenfield/brownfield baseline adoption + advisory context budgets + convergence gate | ✅ done |
48
49
  | 12 | Repository evidence snapshots + gap ledger + migration re-adoption + incident governance | ✅ done |
49
50
  | 13 | Durable init-to-delivery workflows + task execution contracts + immutable stage evidence | ✅ done |
@@ -79,16 +80,15 @@ ultra-tools/ ← CLI fallback, migration, and diagnostics
79
80
  └── legacy-memory.cjs (explicit inspect/archive/confirmed prune)
80
81
 
81
82
  bin/install.js ← multi-runtime installer
82
- bin/handbook.js ← explicit managed user-handbook sync
83
83
  adapters/ ← native Claude/OpenCode/Codex plugin builders
84
84
  skills/ ← allowlisted Ultra workflows, internal rules, and collab companions
85
85
  hooks/ ← 7 executable workflow hooks + shared Context Spine helper; OpenCode uses native JavaScript hooks
86
86
  docs/
87
- ├── PLAN.zh-CN.md historical phase plan + decision log
87
+ ├── DECISIONS.md current authority and package boundaries
88
88
  ├── ARCHITECTURE.md Phase 1 single-page entry point
89
89
  ├── WORKFLOW-LIFECYCLE.md baseline classification + DB transition contract
90
90
  ├── AGENT-CONTEXT.md Phase 3 canonical runtime context contract
91
- ├── USER-HANDBOOK-CONTRACT.md managed CLAUDE.md / AGENTS.md boundary
91
+ ├── PLUGIN-ISOLATION-CONTRACT.md install, activation, idle, and ownership contract
92
92
  ├── RUNTIME-COMPAT-MATRIX.md Phase 4 runtime capability matrix
93
93
  ├── STATE-DB-ACCESS-POLICY.md Phase 2 multi-process write contract
94
94
  ├── COMMIT-HASH-BACKFILL.md Phase 2.8 two-commit completion flow
@@ -106,6 +106,6 @@ npm audit
106
106
 
107
107
  ## Out of scope for v1.0 (deferred)
108
108
 
109
- PLAN §13 lists Copilot / Cursor / Windsurf / 7 more runtimes, web
110
- dashboard / TUI, team-collab server, plugin
111
- marketplace.
109
+ Additional runtimes, a web dashboard or TUI, a team-collaboration server, and
110
+ an independent plugin marketplace remain deferred until a current product
111
+ decision brings them into scope.
@@ -15,10 +15,10 @@ not installed.
15
15
  |---|---|---|---|---|
16
16
  | Package form | `.claude-plugin` native plugin | native config bundle + JS plugin | personal `.codex-plugin` | managed `kimi.plugin.json` plugin |
17
17
  | Public entry | `/ultra-*`, `/learn` | `/ultra-*`, `/learn` | `$ultra-builder-pro:<skill>` | `/ultra-builder-pro:<command>` |
18
- | Public Ultra workflows | 12 | 12 | 12 | 12 |
18
+ | Public Ultra workflows | 12, model invocation disabled | 12 commands backed by private workflow assets | 12, implicit invocation disabled | 12, model invocation disabled |
19
19
  | Internal agent-rule skills | 4, non-user-facing | 4, non-user-facing | 4 with implicit invocation disabled | 4, consumed by review workers |
20
20
  | Collaboration companions | `codex-collab`, `ultra-verify` | `cc-collab`, `codex-collab`, `ultra-verify` | `cc-collab`, `ultra-verify` | `cc-collab`, `codex-collab`, `ultra-verify` |
21
- | Host bootstrap | native plugin context | native plugin context | native plugin context | `using-ultra-builder-pro` session-start skill |
21
+ | Automatic workflow bootstrap | N/A | N/A | N/A | N/A |
22
22
  | External browser/deploy/framework skills | N/A | N/A | N/A | N/A |
23
23
 
24
24
  Codex converts workflows into namespaced skills and records eleven legacy
@@ -46,21 +46,17 @@ not presented as nonexistent custom agents.
46
46
 
47
47
  | Lifecycle | Claude Code | OpenCode | Codex | Kimi Code 0.26+ |
48
48
  |---|---|---|---|---|
49
- | Session context/health | FULL, DB-derived Context Spine breadcrumb on native `SessionStart` | FULL, the native JS plugin invokes the same bundled DB breadcrumb reader; health via `system.doctor` | FULL, DB-derived breadcrumb on native `SessionStart` | FULL, DB-derived breadcrumb via session-start skill + hooks |
49
+ | Session context/health | FULL, active-workflow breadcrumb on native `SessionStart` | FULL, native JS plugin injects only an active-workflow breadcrumb; health via `system.doctor` | FULL, active-workflow breadcrumb on native `SessionStart` | FULL, active-workflow breadcrumb via native hooks |
50
50
  | Active edit boundary | FULL, `PreToolUse Edit|Write` | FULL, `tool.execute.before` rejects projection writes | FULL, `PreToolUse Edit|Write|apply_patch` | FULL, native `PreToolUse Edit|Write` deny contract |
51
51
  | Pre-compact checkpoint | FULL | FULL | FULL | FULL, native `PreCompact` |
52
52
  | Post-compact context injection | FULL | FULL, native compacting context | FULL, native `PostCompact` restore | DEGRADED; checkpoint restoration runs, but Kimi 0.26/0.27 does not reinject fire-and-forget hook text |
53
53
  | Stop lifecycle advisory | FULL, native non-blocking `Stop` | N/A, no equivalent stop event needed | FULL, native non-blocking `Stop` | FULL, native non-blocking `Stop` |
54
54
  | Subagent lifecycle evidence | FULL | DEGRADED, no equivalent packaged event | FULL | FULL, native `SubagentStart` / `SubagentStop` |
55
55
 
56
- Kimi's session bootstrap therefore also instructs recovery to inspect
57
- `.ultra/runtime/checkpoint.json` and call Ultra status/doctor after compaction.
58
- This keeps durable recovery intact without claiming dynamic context injection
59
- that the host does not guarantee.
60
-
61
- Health/context hooks inspect initialized projects; projection protection also
62
- applies at baseline, while compact/stop/subagent enforcement remains
63
- active-workflow scoped. No host receives prompt capture, transcript capture,
56
+ Health/context, compact, stop, and subagent hooks remain silent unless
57
+ `.ultra/state.db` proves an active, blocked, or ready workflow. Projection
58
+ protection applies to every initialized project because generated projections
59
+ must never become a second authority. No host receives prompt capture, transcript capture,
64
60
  observation journaling, session-summary memory, generic command blocking, or
65
61
  generic post-edit policy.
66
62
  Baseline-adoption and context-budget warnings are injected as advisory context;
@@ -73,7 +69,7 @@ they do not deny edits or stop active incident work.
73
69
  | stdio MCP registration | plugin `.mcp.json` | `opencode.json` local MCP entry | plugin `.mcp.json` | plugin `mcpServers` entry |
74
70
  | Live/declared contracts | 50 | 50 | 50 | 50 |
75
71
  | Greenfield/brownfield baseline adoption | FULL | FULL | FULL | FULL |
76
- | Context Spine v2 / breadcrumb | FULL | FULL, same bundled read-only DB reader as every hook | FULL | FULL |
72
+ | Context Manifest v3 / breadcrumb | FULL | FULL, same bundled read-only DB reader as every hook | FULL | FULL |
77
73
  | Approval-gated spec learning | FULL | FULL | FULL | FULL |
78
74
  | Host-native review/discovery/ask | native | native | documented in `codex-capability-map.json` | native Kimi tools and workers |
79
75
  | Durable authority | project `.ultra/state.db` | project `.ultra/state.db` | project `.ultra/state.db` | project `.ultra/state.db` |
@@ -89,18 +85,19 @@ generated launcher recovers the project from the inherited `PWD`, sets
89
85
  cannot be established. On POSIX it intentionally uses `env node` because Kimi
90
86
  0.26/0.27's embedded Node ABI differs from the ABI used to install `better-sqlite3`.
91
87
 
92
- ## 5. User handbook presentation
88
+ ## 5. User instruction isolation
93
89
 
94
90
  | Capability | Claude Code | OpenCode | Codex | Kimi Code 0.26+ |
95
91
  |---|---|---|---|---|
96
92
  | Durable user file | `~/.claude/CLAUDE.md` | `~/.config/opencode/AGENTS.md` | `~/.codex/AGENTS.md` | `~/.kimi-code/AGENTS.md` |
97
93
  | Automatic overwrite by plugin install | no | no | no | no |
98
- | Explicit managed-block sync | `ubp-handbook --runtime claude` | `ubp-handbook --runtime opencode` | `ubp-handbook --runtime codex` | `ubp-handbook --runtime kimi` |
99
- | Backup before change | FULL | FULL | FULL | FULL |
94
+ | Writer shipped by Ultra | N/A | N/A | N/A | N/A |
95
+ | Uninstall removes user instructions | no | no | no | no |
100
96
 
101
- The Kimi plugin installer does not edit `~/.kimi-code/config.toml`. Handbook
102
- sync remains a separate, previewable action so user policy and plugin mechanics
103
- do not become one irreversible mutation.
97
+ The Kimi plugin installer also does not edit `~/.kimi-code/config.toml`. Durable
98
+ user preferences belong to each host and remain outside Ultra's ownership.
99
+ Legacy Ultra handbook text is not proof of plugin ownership and is never
100
+ silently rewritten or removed.
104
101
 
105
102
  ## 6. Install, update, and uninstall
106
103
 
@@ -113,9 +110,15 @@ do not become one irreversible mutation.
113
110
  | Preserves unrelated config | FULL | FULL | FULL | FULL, including `config.toml` and unrelated registry records |
114
111
  | Uninstall ownership guard | managed plugin root | sentinels + owned MCP entry | managed root/manifest/agent headers | managed root + exact registry record |
115
112
  | Normalized install provenance | FULL | FULL | FULL | FULL |
116
- | Read-only `ubp --doctor` | FULL | FULL | FULL | FULL |
113
+ | Local-source dirty state and worktree digest | FULL | FULL | FULL | FULL |
114
+ | Read-only `ubp --all --global --doctor` | FULL | FULL | FULL | FULL |
117
115
  | Asset-content and host-contract drift detection | FULL | FULL | FULL | FULL |
118
116
 
117
+ Package-local Git provenance never falls through to an enclosing consumer
118
+ repository. Source installs record commit, dirty state, and a deterministic
119
+ worktree digest; registry installs record unavailable checkout fields as
120
+ `null`.
121
+
119
122
  Kimi's global managed root is
120
123
  `~/.kimi-code/plugins/managed/ultra-builder-pro`; its only registry mutation is
121
124
  the owned `ultra-builder-pro` entry in `~/.kimi-code/plugins/installed.json`.
@@ -143,8 +146,8 @@ records. Uninstall refuses an unmanaged or conflicting root.
143
146
  skills and generic/memory hooks from re-entering a package.
144
147
  - `tests/retired-runtime.test.cjs` prevents retired runtime code or prompt text
145
148
  from re-entering active product surfaces.
146
- - `adapters/_shared/tests/handbook.test.cjs` verifies host rendering, backup,
147
- migration, and idempotency.
149
+ - `adapters/_shared/tests/plugin-isolation.test.cjs` and `tests/install.test.cjs`
150
+ verify the absence of a handbook writer and byte-preservation of all user instruction files.
148
151
  - `adapters/_shared/tests/provenance.test.cjs` verifies normalized manifests,
149
152
  content hashes, source attribution, corruption handling, and contract drift.
150
153
  - `tests/install.test.cjs` verifies healthy four-host doctor output and
@@ -1,7 +1,7 @@
1
1
  # `.ultra/state.db` access policy
2
2
 
3
- > Phase 2.2 contract. Trace: PLAN §6 Phase 2.2, decisions D18 / D32 / D37,
4
- > risks R21 / R25.
3
+ > Multi-process access contract. Current authority is defined by
4
+ > [`DECISIONS.md`](./DECISIONS.md) and the live database schema.
5
5
 
6
6
  `.ultra/state.db` is the only authoritative state store for baselines, changes,
7
7
  decision threads/items, tasks, workflow runs/steps, events, sessions, incidents,
@@ -35,12 +35,13 @@ authority, and no new stage may start on an archived or cancelled change. Doctor
35
35
  recovers a legacy change without this link into an explicitly blocked workflow;
36
36
  it does not fabricate the missing provenance.
37
37
 
38
- Ultra does not select an MVP. Product scope and material delivery posture are owner
39
- decisions. The seventeen research areas are a coverage catalog, not a forced
40
- questionnaire. Initial greenfield and brownfield research must disposition every area
41
- as `execute`, `verify_existing`, `reuse`, `not_applicable`, or accepted `deferred`;
42
- only selected necessary work executes. Bounded change research records the same
43
- selection rationale over its smaller scope.
38
+ Ultra does not select product scope or material delivery posture; those remain user
39
+ decisions. Research references form an optional catalog, not a forced questionnaire.
40
+ The host model selects only evidence-relevant areas and records one coverage rationale.
41
+ MCP validates identifiers, dispositions, evidence requirements, synthesis, and at
42
+ least one applicable semantic area. Omitted areas create no workflow step. An explicit
43
+ `not_applicable` or accepted `deferred` row is retained only when its exclusion is
44
+ material.
44
45
 
45
46
  ## 2. How `ultra-init` classifies a repository
46
47
 
@@ -325,7 +326,7 @@ current gate evidence do block.
325
326
 
326
327
  ```text
327
328
  ultra-init -> Git/scaffold/authority verification -> init completed
328
- -> explicit ultra-research -> disposition 17 coverage areas -> selected evidence work
329
+ -> explicit ultra-research -> model-selected coverage -> selected evidence work
329
330
  -> local checkpoint when Git is unborn -> baseline approval
330
331
  -> ultra-change -> optional bounded research/plan -> dev -> risk-selected test/review
331
332
  -> local deliver/archive
@@ -335,7 +336,7 @@ ultra-init -> Git/scaffold/authority verification -> init completed
335
336
 
336
337
  ```text
337
338
  ultra-init -> preserve Git/classify brownfield -> init completed
338
- -> explicit adoption research -> disposition 17 coverage areas
339
+ -> explicit adoption research -> model-selected coverage
339
340
  -> selected characterization/known-red evidence -> gap ledger -> owner approval
340
341
  -> first ultra-change -> optional bounded research/plan -> dev -> test/review -> deliver
341
342
  ```
@@ -389,8 +390,9 @@ parallel workflow or substitutes a Prompt summary for DB state.
389
390
 
390
391
  ## 9. Recovery and diagnosis
391
392
 
392
- Use `system.doctor` for project authority and `ubp --doctor` for installed host
393
- assets. Both are read-only unless an explicit project repair command is chosen.
393
+ Use `system.doctor` for project authority and
394
+ `ubp --all --global --doctor` for installed host assets. Both are read-only
395
+ unless an explicit project repair command is chosen.
394
396
 
395
397
  During an explicit repair, a legacy active change that predates durable workflows gets
396
398
  one blocked change run at `bind-baseline` with
@@ -52,7 +52,7 @@ def main() -> None:
52
52
  except ContextSpineError as exc:
53
53
  print(f"[active_task_context] cannot inspect Context Spine: {exc}", file=sys.stderr)
54
54
  breadcrumb = None
55
- if breadcrumb and breadcrumb.get("change_id"):
55
+ if breadcrumb and breadcrumb.get("workflow"):
56
56
  print(json.dumps({"hookSpecificOutput": {
57
57
  "hookEventName": "PreToolUse",
58
58
  "additionalContext": render_breadcrumb(root, breadcrumb),
@@ -22,7 +22,7 @@ class Breadcrumb(dict):
22
22
 
23
23
  def find_root(start: Path):
24
24
  for root in (start, *start.parents):
25
- if (root / ".ultra").is_dir():
25
+ if (root / ".ultra" / "state.db").is_file():
26
26
  return root
27
27
  return None
28
28
 
@@ -27,6 +27,22 @@ def hook_input() -> dict:
27
27
  return {}
28
28
 
29
29
 
30
+ def has_active_workflow(db_path: Path) -> bool:
31
+ if not db_path.is_file():
32
+ return False
33
+ try:
34
+ uri = f"file:{db_path}?mode=ro"
35
+ with sqlite3.connect(uri, uri=True, timeout=1) as conn:
36
+ row = conn.execute(
37
+ """SELECT 1 FROM workflow_runs
38
+ WHERE status IN ('active', 'blocked', 'ready')
39
+ LIMIT 1"""
40
+ ).fetchone()
41
+ return row is not None
42
+ except sqlite3.Error:
43
+ return False
44
+
45
+
30
46
  def inspect(root: Path) -> dict:
31
47
  db_path = root / ".ultra" / "state.db"
32
48
  report = {"status": "healthy", "project": str(root), "checks": {}}
@@ -171,6 +187,9 @@ def main() -> None:
171
187
  if root is None:
172
188
  print(json.dumps({}))
173
189
  return
190
+ if not has_active_workflow(root / ".ultra" / "state.db"):
191
+ print(json.dumps({}))
192
+ return
174
193
  report = inspect(root)
175
194
  if report["status"] != "healthy":
176
195
  print("[Ultra health] " + json.dumps(report, ensure_ascii=False, sort_keys=True), file=sys.stderr)
@@ -34,7 +34,7 @@ def main() -> None:
34
34
  print(f"[pre_stop_check] cannot inspect Context Spine: {exc}", file=sys.stderr)
35
35
  allow_stop()
36
36
  return
37
- if breadcrumb and breadcrumb.get("change_id"):
37
+ if breadcrumb and breadcrumb.get("workflow"):
38
38
  allowed = ", ".join(breadcrumb.get("allowed_transitions") or []) or "none"
39
39
  required = breadcrumb.get("required_transition") or "none"
40
40
  print(
@@ -33,7 +33,7 @@ def main() -> None:
33
33
  print(f"[workflow_checkpoint] cannot inspect Context Spine: {exc}", file=sys.stderr)
34
34
  print(json.dumps({}))
35
35
  return
36
- if not breadcrumb or not breadcrumb.get("change_id"):
36
+ if not breadcrumb or not breadcrumb.get("workflow"):
37
37
  print(json.dumps({}))
38
38
  return
39
39
 
@@ -28,7 +28,7 @@ def main() -> None:
28
28
  except ContextSpineError as exc:
29
29
  print(f"[workflow_context] cannot inspect Context Spine: {exc}", file=sys.stderr)
30
30
  breadcrumb = None
31
- if breadcrumb:
31
+ if breadcrumb and breadcrumb.get("workflow"):
32
32
  context = render_breadcrumb(root, breadcrumb)
33
33
  else:
34
34
  print(json.dumps({}))
@@ -64,7 +64,7 @@ def main() -> None:
64
64
  text = None
65
65
  try:
66
66
  breadcrumb = read_breadcrumb(root)
67
- if breadcrumb:
67
+ if breadcrumb and breadcrumb.get("workflow"):
68
68
  text = render_breadcrumb(root, breadcrumb)
69
69
  except ContextSpineError as exc:
70
70
  print(f"[workflow_resume] cannot inspect Context Spine: {exc}", file=sys.stderr)