ultra-builder-pro-cli 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/.ultra-template/docs/research/README.md +4 -4
  2. package/CHANGELOG.md +83 -0
  3. package/README.md +68 -35
  4. package/adapters/_shared/codex-assets.cjs +121 -60
  5. package/adapters/_shared/interaction-contract.cjs +20 -7
  6. package/adapters/_shared/provenance.cjs +7 -2
  7. package/adapters/_shared/runtime-assets.cjs +4 -3
  8. package/adapters/_shared/runtime-native.cjs +132 -0
  9. package/adapters/claude.js +61 -31
  10. package/adapters/codex.js +178 -81
  11. package/adapters/grok.js +372 -0
  12. package/adapters/kimi.js +8 -4
  13. package/adapters/opencode.js +211 -33
  14. package/agents/code-reviewer.md +4 -2
  15. package/agents/debugger.md +4 -1
  16. package/agents/review-code.md +7 -3
  17. package/agents/review-comments.md +7 -4
  18. package/agents/review-coordinator.md +11 -7
  19. package/agents/review-design.md +8 -4
  20. package/agents/review-errors.md +8 -4
  21. package/agents/review-spec.md +8 -5
  22. package/agents/review-tests.md +7 -4
  23. package/agents/tdd-runner.md +5 -2
  24. package/bin/install.js +9 -4
  25. package/bin/orchestrator.js +4 -13
  26. package/docs/AGENT-CONTEXT.md +141 -231
  27. package/docs/ARCHITECTURE.md +203 -498
  28. package/docs/ARTIFACT-AUTHORITY.md +38 -35
  29. package/docs/PLUGIN-ISOLATION-CONTRACT.md +12 -9
  30. package/docs/ROADMAP.md +85 -110
  31. package/docs/RUNTIME-COMPAT-MATRIX.md +139 -174
  32. package/docs/SKILL-AUTHORING.md +3 -3
  33. package/docs/STATE-DB-ACCESS-POLICY.md +25 -20
  34. package/docs/WORKFLOW-LIFECYCLE.md +174 -442
  35. package/hooks/README.md +11 -8
  36. package/hooks/active_task_context.py +16 -16
  37. package/hooks/adapters/grok.py +134 -0
  38. package/hooks/{context_spine.py → context_envelope.py} +26 -22
  39. package/hooks/health_check.py +19 -29
  40. package/hooks/pre_stop_check.py +22 -12
  41. package/hooks/subagent_tracker.py +1 -1
  42. package/hooks/workflow_checkpoint.py +14 -13
  43. package/hooks/workflow_context.py +11 -12
  44. package/hooks/workflow_resume.py +14 -13
  45. package/mcp-server/{breadcrumb.cjs → hook-context.cjs} +7 -9
  46. package/mcp-server/lib/artifact-registry.cjs +25 -1
  47. package/mcp-server/lib/baseline-workflow.cjs +36 -38
  48. package/mcp-server/lib/canonical-json.cjs +19 -0
  49. package/mcp-server/lib/change-workflow.cjs +637 -49
  50. package/mcp-server/lib/context-envelope.cjs +508 -0
  51. package/mcp-server/lib/decision-records.cjs +337 -0
  52. package/mcp-server/lib/doctor.cjs +91 -33
  53. package/mcp-server/lib/init-project.cjs +78 -39
  54. package/mcp-server/lib/managed-file-write.cjs +116 -0
  55. package/mcp-server/lib/plan-checkpoint.cjs +177 -0
  56. package/mcp-server/lib/project-context.cjs +178 -0
  57. package/mcp-server/lib/stage-checkpoints.cjs +309 -0
  58. package/mcp-server/lib/state-db.cjs +155 -24
  59. package/mcp-server/lib/task-ledger.cjs +522 -13
  60. package/mcp-server/lib/ultra-facade.cjs +834 -0
  61. package/mcp-server/lib/worker-packet.cjs +358 -0
  62. package/mcp-server/server.cjs +208 -1059
  63. package/orchestrator/daemon.cjs +27 -9
  64. package/orchestrator/parallel-orchestrator.cjs +111 -76
  65. package/orchestrator/session-runner.cjs +135 -34
  66. package/package.json +10 -3
  67. package/skills/ultra-change/SKILL.md +39 -98
  68. package/skills/ultra-deliver/SKILL.md +42 -65
  69. package/skills/ultra-dev/SKILL.md +52 -99
  70. package/skills/ultra-doctor/SKILL.md +35 -57
  71. package/skills/ultra-init/SKILL.md +48 -88
  72. package/skills/ultra-init/references/brownfield-adoption.md +11 -8
  73. package/skills/ultra-plan/SKILL.md +54 -132
  74. package/skills/ultra-research/SKILL.md +58 -112
  75. package/skills/ultra-review/SKILL.md +28 -46
  76. package/skills/ultra-review/references/unified-schema.md +2 -0
  77. package/skills/ultra-review/scripts/review_wait.py +8 -0
  78. package/skills/ultra-status/SKILL.md +22 -45
  79. package/skills/ultra-test/SKILL.md +27 -61
  80. package/skills/ultra-think/SKILL.md +29 -48
  81. package/skills/ultra-think/references/interaction-boundary.md +56 -0
  82. package/spec/cli-protocol.md +80 -187
  83. package/spec/mcp-tools.yaml +130 -2738
  84. package/spec/schemas/mcp-tools.schema.json +1 -1
  85. package/spec/schemas/state-db.sql +107 -4
  86. package/spec/schemas/{task-ledger.v1.schema.json → task-ledger.v2.schema.json} +70 -6
  87. package/ultra-tools/commands/status.cjs +369 -243
  88. package/mcp-server/lib/context-spine.cjs +0 -1208
  89. package/mcp-server/lib/decision-dialogue.cjs +0 -1128
  90. package/mcp-server/lib/project-breadcrumb.cjs +0 -173
  91. package/mcp-server/lib/spec-learning.cjs +0 -284
  92. package/mcp-server/lib/workflow-state.cjs +0 -2965
  93. package/skills/ultra-think/references/decision-dialogue.md +0 -153
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ultra-builder-pro-cli",
3
- "version": "0.22.0",
4
- "description": "Explicitly invoked Ultra Builder Pro workflows for Claude Code, OpenCode, Codex CLI, and Kimi Code, with project-local MCP authority and lifecycle recovery.",
3
+ "version": "0.24.0",
4
+ "description": "Explicitly invoked Ultra Builder Pro workflows for Claude Code, OpenCode, Codex CLI, Kimi Code, and Grok Build, with a project-local MCP persistence and safety kernel.",
5
5
  "bin": {
6
6
  "ultra-builder-pro-cli": "bin/install.js",
7
7
  "ubp": "bin/install.js",
@@ -61,13 +61,19 @@
61
61
  "!**/*.pyo",
62
62
  "!**/*.test.cjs",
63
63
  "!**/tests/**",
64
- "!mcp-server/test-support/**"
64
+ "!mcp-server/test-support/**",
65
+ "!mcp-server/lib/workflow-state.cjs",
66
+ "!mcp-server/lib/decision-dialogue.cjs",
67
+ "!mcp-server/lib/context-spine.cjs",
68
+ "!mcp-server/lib/project-breadcrumb.cjs",
69
+ "!mcp-server/lib/spec-learning.cjs"
65
70
  ],
66
71
  "keywords": [
67
72
  "claude-code",
68
73
  "opencode",
69
74
  "codex",
70
75
  "kimi-code",
76
+ "grok-build",
71
77
  "agent",
72
78
  "cli",
73
79
  "multi-runtime",
@@ -101,6 +107,7 @@
101
107
  "prepublishOnly": "npm run verify:release",
102
108
  "install:claude": "node bin/install.js --claude --local",
103
109
  "install:kimi": "node bin/install.js --kimi --local",
110
+ "install:grok": "node bin/install.js --grok --local",
104
111
  "install:all": "node bin/install.js --all --local"
105
112
  },
106
113
  "dependencies": {
@@ -3,105 +3,46 @@ name: ultra-change
3
3
  description: Capture or revise one bounded feature, fix, redesign, or incident contract against a ready Ultra baseline. Use when post-baseline work needs accepted intent before research, planning, or implementation.
4
4
  ---
5
5
 
6
- # Capture accepted change intent
6
+ # Capture accepted Change intent
7
7
 
8
- Change is the durable unit that connects later research, plan, implementation,
9
- verification, review, and baseline reconciliation. Capturing a change does not start
10
- those workflows or compile execution context.
11
-
12
- Read `../ultra-think/references/decision-dialogue.md` before asking a material question.
8
+ A Change is the durable unit connecting research, plan, implementation, verification,
9
+ review, documentation, and delivery. Its draft stays editable until a semantic
10
+ checkpoint accepts the downstream authority.
13
11
 
14
12
  ## Inspect and align
15
13
 
16
- 1. Read `system.doctor`, `task.ledger_get`, `baseline.get`, active changes, breadcrumb
17
- `accepted_intent`, decisions, and `change.breadcrumb`. Import a newer descendant
18
- checkpoint before capturing intent. Stop on a typed baseline, Change, task,
19
- ancestry, or active-session conflict.
20
- 2. Resume an existing change that matches the request. Do not duplicate authority.
21
- 3. Ordinary work requires a healthy ready baseline. An incident may use only an
22
- explicit `baseline_bypass` reason and approver; urgency is not approval.
23
- 4. Inspect the checkout and accepted baseline before asking the user. Resolve code and
24
- runtime facts yourself.
25
- 5. Convert the request into a Change Contract:
26
- - observable outcome and executable acceptance;
27
- - non-goals and public seams;
28
- - recovery strategy and verification;
29
- - unresolved material decisions;
30
- - documentation impact;
31
- - change kind and evidence-backed risk flags;
32
- - research disposition.
33
-
34
- Recommend `quick`, `standard`, `major`, or `incident` from actual scope and risk,
35
- together with the research disposition. A quick change may have no material risk,
36
- research obligation, or more than one task. MCP may reject a profile that contradicts
37
- hard risk invariants; it does not choose a replacement.
38
-
39
- After `change.create` or `change.update`, read back the complete Change Contract. When
40
- that write applies a durable decision, complete the decision thread with the change
41
- reference in `applied_refs`.
42
-
43
- Ask only when a choice changes accepted product intent, scope, public behavior,
44
- compatibility, security, material cost, external effects, or recovery. Use the host's
45
- native question UI when available. Normalize clear choices already in the user's
46
- request. When profile or research posture remains unresolved, present the recommended
47
- route and credible alternatives through that same UI, then stop. The user selects,
48
- modifies, delegates, or defers the semantic route. The model owns reversible
49
- implementation detail inside the accepted contract.
50
-
51
- ## Persist the contract
52
-
53
- When a durable alignment checkpoint is necessary, bind it to a compact artifact and
54
- pass its id as `alignment_thread_id`. Do not require a checkpoint for a complete,
55
- unambiguous request that already provides current authority.
56
-
57
- Call `change.create`. It records and completes exactly:
58
-
59
- 1. `bind-baseline`
60
- 2. `classify-change`
61
- 3. `record-intent`
62
-
63
- The returned change workflow must be `completed`; research, plan, context, dev, test,
64
- review, and deliver remain independent capabilities. Keep every Change-owned semantic
65
- artifact, finding, plan, context, test result, review result, documentation update,
66
- and progress projection below `.ultra/changes/active/<id>/`. Incidents maintain the
67
- structured diagnosis artifact there as well.
68
-
69
- `change.create` and `change.update` publish the portable Change Contract to
70
- `.ultra/tasks/tasks.json`, even before the Change owns tasks. The tracked Change
71
- artifacts carry semantic bodies; the checkpoint carries normalized baseline, Change,
72
- and task records with digest ancestry. Never edit either generated checkpoint or
73
- checkout-local projection directly.
74
-
75
- Before planning a standard or major change, write the accepted specification updates
76
- to the Change overlay and call `change.delta` with exact baseline id, repository
77
- revision, specification digests, decisions, non-goals, acceptance, documentation
78
- impact, unknowns, and mutation before/after digests. If accepted behavior truly does
79
- not change baseline semantics, record an empty typed delta with a specific
80
- `no_semantic_change_reason`; do not manufacture a mutation. Read back the registered
81
- delta and deterministic `progress.md`. This records proposed authority only and must
82
- not edit baseline specifications.
83
-
84
- Use `change.update` when accepted intent or evidence changes. Update the Change
85
- Contract, classification, research disposition, and docs impact together when their
86
- meaning is coupled. Downstream task, context, test, or review evidence affected by that
87
- change must become stale and be regenerated; never keep old evidence green by prompt
88
- assertion.
89
-
90
- If research is required, recommend `ultra-research` with the recorded disposition. If
91
- the contract is sufficiently evidenced, finish the typed delta and recommend
92
- `ultra-plan`. Direct Build skips Research only; it never skips Plan, DB-backed task
93
- contracts, or fresh task context. Return and wait for an explicit user invocation; do
94
- not start another workflow. `change.context` is compiled only for an actual plan,
95
- implementation, test, or review consumer.
96
-
97
- Stable implementation discoveries use the approval-gated specification-learning
98
- transitions. External memory and graph providers retain their own content; Ultra stores
99
- metadata references only.
100
-
101
- Return the normalized contract, change id and kind, research disposition, blockers,
102
- and `allowed_transitions`. Recommend a semantic next action from those transitions.
103
- If current intent does not already select it, present the recommendation and credible
104
- alternatives through the interaction protocol, then wait. MCP does not encode a
105
- semantic next action.
106
-
107
- Never invoke the recommended capability here; wait for an explicit user invocation.
14
+ 1. Call `ultra.context { stage: project, detail: full }`.
15
+ 2. Inspect or import the team checkpoint with `ultra.sync`. Stop only on a real
16
+ baseline, Change, task, ancestry, or active-session conflict.
17
+ 3. Reuse an existing matching Change. Do not duplicate authority.
18
+ 4. Convert the request into observable outcome, executable acceptance, non-goals,
19
+ public seams, recovery, verification, documentation impact, risk, and research
20
+ disposition.
21
+ 5. Recommend `quick`, `standard`, `major`, or `incident` from evidence. Ask only when
22
+ a choice changes accepted product intent, compatibility, security, material cost,
23
+ external effects, or recovery.
24
+
25
+ Read `../ultra-think/references/interaction-boundary.md` before asking. MCP may report
26
+ contradictory risk fields, but the model and owner choose the semantic correction.
27
+
28
+ ## Record the contract
29
+
30
+ Use one `ultra.record` batch with `change_contract / open` or
31
+ `change_contract / revise`, relevant `decision / accept`, and `artifact / bind` for
32
+ an already-known typed delta. Every entry carries a stable idempotency key. Read the
33
+ result through `ultra.context`.
34
+
35
+ Keep every Change-owned semantic artifact below
36
+ `.ultra/changes/active/<change-id>/`. Standard and major Changes require a typed delta
37
+ before planning. A true no-semantic-change case records an explicit reason instead of
38
+ manufacturing a mutation.
39
+
40
+ Changing accepted intent creates a new accepted checkpoint revision and makes only
41
+ genuinely dependent evidence stale. Readiness is derived, not a stored absorbing
42
+ state. A semantic rejection returns diagnostics; repair and retry the same draft.
43
+ Use `change_contract / cancel` only when the owner intentionally abandons the Change.
44
+
45
+ Publish the durable Change contract with `ultra.sync { action: publish }` when it is a
46
+ useful team handoff. Recommend bounded `ultra-research` for a real evidence gap or
47
+ `ultra-plan` when the contract is sufficiently evidenced. Do not invoke the next
48
+ capability automatically.
@@ -1,71 +1,48 @@
1
1
  ---
2
2
  name: ultra-deliver
3
- description: Converge a verified Ultra change, reconcile baseline specifications, and archive it with recoverable local evidence. Use when implementation, testing, and review are current.
3
+ description: Converge a verified Ultra Change, reconcile baseline specifications, and archive it with recoverable local evidence. Use when implementation, testing, and review are current.
4
4
  ---
5
5
 
6
6
  # Converge and archive local authority
7
7
 
8
- Delivery closes Ultra's local change authority. It does not grant or perform commit,
9
- push, tag, registry publication, deployment, or another external effect.
10
-
11
- ## Bind current evidence
12
-
13
- 1. Read doctor, `task.ledger_get`, baseline, change, breadcrumb `accepted_intent`,
14
- decisions, tasks, test, review, learning, and current checkout. Import a newer
15
- descendant checkpoint before convergence; stop on any typed merge conflict.
16
- 2. Resume or start a deliver workflow bound to the change and baseline.
17
- 3. Require complete task evidence, a current test report, both review axes, current
18
- context, and resolved material decisions. Record `bind-evidence`.
19
-
20
- Evidence from another revision, task set, or change is invalid.
21
-
22
- ## Reconcile specifications
23
-
24
- Resolve every specification-learning candidate. Apply approved learning to its target
25
- inside the Change overlay; preserve rejection reasons. Read the current registered
26
- `change.delta` and verify every baseline anchor, payload digest, acceptance reference,
27
- and unknown.
28
-
29
- Write documentation updates below
30
- `.ultra/changes/active/<change-id>/documentation/`. Call
31
- `change.documentation_reconcile` for every Change: bind the current delta id and
32
- digest, exact before/after document digests, delta and acceptance references,
33
- verification, and each verified consumer. When no documentation changes, record an
34
- empty reconciliation with a specific `no_change_reason`. An unexplained orphan
35
- document is blocking. Record `reconcile-specifications`.
36
-
37
- Compile final convergence context and run the risk-selected candidate checks, install
38
- or doctor smoke when this change modifies distributed assets, public-seam verification,
39
- and recovery sanity. Record the immutable context under `verify-candidate`.
40
-
41
- Call `change.converge`; MCP derives readiness from durable dev, test, review,
42
- typed delta, documentation reconciliation, diagnosis, and current checkout evidence.
43
- Successful convergence publishes the current portable team checkpoint.
44
- Record
45
- `converge-authority` only when ready.
46
-
47
- Call `change.archive` with the summary. MCP preflights all target before states and
48
- overlay digests, applies the complete packet atomically, refreshes baseline authority,
49
- rebinds every registered artifact into the self-contained archive, and rolls back or
50
- resumes from its transaction journal after interruption. A partial success is not
51
- delivery. Archive publication refreshes the checkpoint with the archived Change and
52
- new baseline summary. Verify the refreshed baseline and archived packet, then record
53
- `archive-change`.
54
-
55
- Write `<archived-change-root>/delivery/<workflow-id>/report.json` with
56
- `ultra-delivery-report-v1`: archived change, baseline, HEAD, worktree and context
57
- digests, local checks, rollback notes, and timestamp. The report must not contain a
58
- release decision. Record it under `verify-delivery` and complete the workflow.
59
-
60
- ## External effects
61
-
62
- If the user separately requests commit, push, tag, publish, or deploy, handle that as a
63
- host-owned effect after Ultra delivery. Confirm only missing material authority, run
64
- the repository's release checks, and report remote evidence separately. Never infer an
65
- external effect from `ultra-deliver`, and never encode it as completed Ultra delivery
66
- state.
67
-
68
- Return archive and baseline state, evidence digests, recovery notes, residual risks,
69
- and allowed transitions.
70
-
71
- Never invoke the recommended capability here; wait for an explicit user invocation.
8
+ Delivery closes local Ultra authority. It never grants commit, push, tag, registry
9
+ publication, deployment, or another external effect.
10
+
11
+ ## Prepare the packet
12
+
13
+ 1. Call `ultra.context { stage: deliver, scope: { change_id }, detail: full }`.
14
+ 2. Import a newer team checkpoint with `ultra.sync`; stop on a real conflict.
15
+ 3. Require current task outcomes, test report, both review axes, accepted decisions,
16
+ typed delta, documentation reconciliation, and current checkout evidence.
17
+ 4. Resolve every specification-learning candidate. Keep updates inside the Change
18
+ overlay until archive.
19
+ 5. Write and register documentation reconciliation and an
20
+ `ultra-delivery-report-v1` report. The report binds Change, baseline, HEAD,
21
+ worktree/context digests, local checks, rollback guidance, and timestamp; it contains
22
+ no release decision.
23
+
24
+ Use one typed `ultra.record` batch for `artifact / bind`, any normalized
25
+ `decision / accept`, and bounded `event / append` facts.
26
+
27
+ ## Archive once
28
+
29
+ Call `ultra.archive` once with the Change id, stable idempotency key, archive summary,
30
+ reconciliation fields, delivery evidence steps, and report output. The operation
31
+ internally:
32
+
33
+ - compiles or reuses convergence context;
34
+ - checks the deliver draft;
35
+ - derives convergence from current dev, test, review, delta, docs, and checkout;
36
+ - applies the overlay and archive through the recoverable filesystem/DB transaction;
37
+ - rebinds registered artifacts into a self-contained archive;
38
+ - accepts one immutable delivery checkpoint revision;
39
+ - publishes the updated team checkpoint.
40
+
41
+ A semantic rejection returns mutable blockers. Repair the same packet and retry. A
42
+ hard corruption, path, concurrency, or recovery error remains fail-closed and routes to
43
+ `ultra-doctor`.
44
+
45
+ Verify the archived packet, baseline, checkpoint, and rollback state. Handle any
46
+ separately authorized Git or release effect only after local delivery and report it as
47
+ external evidence, not Ultra delivery authority. Do not invoke another capability
48
+ automatically.
@@ -5,102 +5,55 @@ description: Implement one authoritative Ultra task through a fresh-context, tes
5
5
 
6
6
  # Implement one task
7
7
 
8
- The host model owns code reasoning and edits. Ultra owns the task and workflow state,
9
- fresh context contract, session lease, evidence references, and recovery.
10
-
11
- ## Bind and resume
12
-
13
- 1. Read doctor, `task.ledger_get`, breadcrumb `accepted_intent`, active decisions, task
14
- contract, dependencies, dev runs, sessions, HEAD, and worktree. Import a newer
15
- descendant team checkpoint before taking a lease. Stop on a typed baseline, Change,
16
- task, ancestry, or active-session conflict; do not merge authority by editing JSON.
17
- 2. Resume the matching dev run or start one with `change_id` and `task_id`.
18
- 3. Record `bind-task` with current authority and dependency evidence.
19
- 4. Compile `change.context` with `role: implement` and `gate: implementation`. The
20
- public seam, verification command, and context refs come from the DB-backed task
21
- contract; update that contract before compilation instead of overriding it in the
22
- call. Persist any changed external-provider metadata with `change.update` first.
23
- Context compilation itself is read-only with respect to Change and provider
24
- authority.
25
- 5. Confirm the manifest contains the selected task, its direct dependencies, direct
26
- dependents needed for integration, and relevant integration checkpoints—not the
27
- entire task graph. Referenced file bodies stay lazy. The token estimate includes
28
- inline Change/task authority as well as file estimates; budget overflow is
29
- advisory, while a missing or stale required reference is blocking. Record the
30
- immutable manifest as `compile-context`.
31
- 6. Reuse an existing valid session. Otherwise pass admission and call `session.spawn`.
32
- Work only in the returned worktree and preserve unrelated changes.
33
-
34
- Do not spawn recursively from a parent-owned worker session. Process exit is transport
35
- evidence, never task completion.
36
-
37
- ## Focused inner loop
38
-
39
- 1. Reproduce the bug, write a failing test, or establish a characterization signal
40
- before a logic change. Record `establish-feedback-loop`.
41
- 2. Mark the task `in_progress` and implement the smallest complete slice through the
42
- declared public seam.
43
- 3. Keep the loop adaptive. The model may choose implementation details inside the
44
- accepted contract. If new evidence changes product intent, compatibility, security,
45
- material cost, external effects, or recovery, use the host's native question UI and
46
- the decision protocol; do not ask about ordinary reversible details.
47
- 4. Record `implement-slice`, then run focused tests plus the adjacent checks justified
48
- by the task risk. Record exact results under `verify-slice`.
49
- 5. Run a task-scoped independent review on specification fidelity and relevant
50
- engineering risks. Record `review-slice`. Fix blocking findings and refresh affected
51
- evidence.
52
- 6. In direct mode, update the task to `completed` only after verification and review
53
- are current. This publishes the durable team ledger checkpoint. Create one
54
- authorized local task commit containing code, semantic artifacts, and that
55
- checkpoint. Read the resulting `HEAD`, then record it as `completion_commit`;
56
- that hash remains checkout-local and must not create another Git commit. Do not
57
- push, publish, tag, or deploy unless the user separately authorized that external
58
- effect.
59
-
60
- The tracked team checkpoint contains durable task status and contract evidence, not
61
- live ownership. `in_progress`, `session_id`, leases, worktrees, telemetry, and
62
- `completion_commit` remain checkout-local. The local generated task view lives under
63
- `.ultra/.runtime/projections/` and is never committed.
64
-
65
- Treat the compiled task-context contract as the handoff boundary: purpose, why,
66
- constraints, non-goals, target seams/files, pattern refs, acceptance, documentation
67
- impact, recovery, and definition of drift. If accepted intent, the task contract, or a
68
- digest-bound reference changes, update the owning authority and recompile rather than
69
- continuing from a stale packet.
70
-
71
- Keep implementation findings and documentation candidates inside the owning Change
72
- root. When code changes invalidate or extend maintained documentation, update the
73
- Change documentation overlay and its evidence rather than editing accepted baseline
74
- specifications. Hooks may remind the host to reconcile documentation; they must not
75
- block ordinary development or choose the semantic update.
76
-
77
- Task-level tests and review belong to this inner loop. They do not replace aggregate
78
- change testing or review when multiple slices, integrations, or broader risks require
79
- those capabilities.
80
-
81
- ## Complete or recover
82
-
83
- In direct mode, integrate the task commit through the repository's accepted path,
84
- verify ancestry and the public seam, close the session, record `record-completion`,
85
- and complete the dev workflow. If commit creation fails after the pre-commit
86
- completion checkpoint, move the still-session-owned task to `blocked`, preserve the
87
- worktree, and record the failure. A completion with a recorded commit remains
88
- terminal.
89
-
90
- Change convergence revalidates the exact latest
91
- `change_id + task_id + implement + implementation` snapshot for every executable
92
- task. A newer review, test, or plan packet cannot substitute for it.
93
-
94
- In a parent-supervised worker, record completion evidence and exit without closing the
95
- parent-owned lease. The primary host verifies the exact session commit, performs any
96
- integration, refreshes review if the reviewed checkout changed, settles the lease, and
97
- completes the workflow.
98
-
99
- Preserve worktrees by default. Remove one only when Git proves it is clean and
100
- integrated. On interruption, record the current step and task as blocked, preserve
101
- worktree and evidence, and resume the same run later.
102
-
103
- Return outcome, changed paths, public seam, exact checks, review axes, commit and
104
- session state, residual risk, and allowed transitions.
105
-
106
- Never invoke the recommended capability here; wait for an explicit user invocation.
8
+ The model owns code reasoning and edits. Ultra owns the durable task contract,
9
+ canonical Context Envelope, execution lease, immutable Worker Packet, evidence
10
+ references, and checkpoint.
11
+
12
+ ## Bind execution
13
+
14
+ 1. Call `ultra.context { stage: dev, scope: { change_id, task_id }, detail: full }`.
15
+ 2. Import a newer team checkpoint with `ultra.sync`; stop on a real same-record or
16
+ active-session conflict.
17
+ 3. Reuse a valid lease or call `ultra.session { action: acquire }`. Acquire atomically
18
+ performs admission, compiles or reuses the implementation Context Envelope, mints
19
+ the lease/worktree, and returns the immutable Worker Packet. A separate
20
+ `action: admission` is an optional read-only preview, not a prerequisite.
21
+ 4. Verify the returned packet digest, purpose, acceptance, dependencies, public seam,
22
+ exact output path/schema, verification command,
23
+ non-goals, recovery, and required context refs. Update the task contract before
24
+ implementation when accepted intent changed.
25
+
26
+ ## Implement adaptively
27
+
28
+ Reproduce the failure, write a failing test, or establish a characterization signal
29
+ before changing logic. Implement the smallest complete vertical slice. Ask the owner
30
+ only when new evidence changes product intent, compatibility, security, material cost,
31
+ external effects, or recovery.
32
+
33
+ Use typed `ultra.record` entries for `task_outcome / start|block|complete`,
34
+ `event / append`, `artifact / bind`, `decision / accept`, and corrected
35
+ `task_contract / revise`. Every worker output must repeat the exact `packet_digest`;
36
+ the parent registers it only after packet, output path, schema, and digest validation.
37
+ Live ownership, `in_progress`, session ids, leases, worktrees, telemetry, and
38
+ completion hashes remain local runtime state; durable task outcome and evidence may
39
+ enter the team checkpoint.
40
+
41
+ Run focused and adjacent risk-justified checks, then a task-scoped independent review.
42
+ Fix blocking findings and refresh affected evidence.
43
+
44
+ ## Commit one semantic checkpoint
45
+
46
+ Call `ultra.checkpoint` once with `stage: dev`, the exact Change/Task scope, evidence,
47
+ and stable idempotency key. It binds the exact Context Envelope and Worker Packet and
48
+ reports outcome diagnostics. A rejection leaves the draft mutable.
49
+
50
+ After acceptance, mark the task durably completed, publish with `ultra.sync`, and
51
+ create at most one authorized local task commit containing code and semantic
52
+ artifacts. Record its SHA only in local state; never create a bookkeeping commit.
53
+
54
+ Release the lease through `ultra.session`. Preserve a dirty or unintegrated worktree
55
+ on interruption. Commit, push, tag, publish, deploy, or destructive cleanup require
56
+ separate owner authority.
57
+
58
+ Return changed paths, public seam, exact checks, review result, checkpoint, commit,
59
+ session state, and residual risk. Do not invoke the next capability automatically.
@@ -1,63 +1,41 @@
1
1
  ---
2
2
  name: ultra-doctor
3
- description: Diagnose and mechanically recover Ultra schema, workflow, projection, session, archive, hook, and installed-asset faults. Use when authority is degraded, stale, contradictory, or unavailable.
3
+ description: Diagnose and mechanically recover Ultra schema, projection, session, archive, hook, and installed-asset faults. Use when authority is degraded, contradictory, or unavailable.
4
4
  ---
5
5
 
6
6
  # Diagnose before repair
7
7
 
8
- Doctor owns deterministic health and supported recovery. It cannot decide product
9
- scope, invent evidence, approve a baseline, answer a user decision, or mark semantic
10
- work complete.
11
-
12
- ## Read-only diagnosis
13
-
14
- Run `system.doctor` without repair and inspect:
15
-
16
- - SQLite integrity, schema 20 migration, required tables, and backups;
17
- - artifact registration, ownership, digest freshness, dependency edges, consumers,
18
- and orphan or duplicate authority;
19
- - baseline and research provenance, gaps, digests, and Git/worktree drift;
20
- - workflow status, obsolete-step migration, blockers, and output freshness;
21
- - decisions and checkpoint artifact freshness;
22
- - Git team-checkpoint schema, ancestry, per-baseline, per-Change, and per-task drift,
23
- plus checkout-local baseline revalidation requirements;
24
- - projection jobs and event cursors;
25
- - sessions, preserved worktrees, incidents, circuit state, and archive journals;
26
- - external provider boundaries.
27
-
28
- An expected workflow pause or awaiting user decision is a warning, not corruption.
29
- Missing or changed required evidence is an authority failure but cannot be reconstructed
30
- by doctor.
31
-
32
- ## Recovery boundary
33
-
34
- With explicit repair authorization, `system.doctor` may:
35
-
36
- - apply backup-first supported schema migrations;
37
- - migrate incompatible rigid workflows into recoverable adaptive state;
38
- - requeue or regenerate projections from healthy DB authority;
39
- - reconcile orphan sessions without deleting unrelated or dirty worktrees;
40
- - resume supported archive journals;
41
- - recover missing workflow provenance as a blocked run requiring real evidence.
42
-
43
- It may not create a Git checkpoint, replace a healthy baseline, accept known failures,
44
- resolve decisions, regenerate semantic content, import or publish the team checkpoint,
45
- or edit application code. A missing or drifted valid checkpoint is a warning; invalid
46
- content or conflicting ancestry is degraded authority. Resolve semantic checkpoint
47
- state explicitly with `task.ledger_import` or `task.ledger_publish` after reviewing
48
- the typed conflict.
49
-
50
- Corrupt SQLite requires preservation of DB, WAL, and SHM followed by an explicit
51
- restore-or-rebaseline choice. Missing hook adapters or stale cache paths require
52
- `ubp --doctor` and adapter reinstall; never patch plugin cache contents by hand.
53
- A legacy task projection is never rewritten by doctor. The supported publication path
54
- first proves its durable task fields match SQLite and preserves its original bytes in
55
- the local runtime backup directory.
56
-
57
- After repair, rerun doctor read-only and verify backup paths, schema, installed hashes,
58
- entry points, MCP startup, and hook smoke tests as applicable.
59
-
60
- Return health first, failed checks, mechanical repairs performed, preserved recovery
61
- paths, unresolved owners, and allowed transitions plus any unique required transition.
62
-
63
- Never invoke the recommended capability here; wait for an explicit user invocation.
8
+ Doctor owns deterministic health and supported recovery. It cannot choose product
9
+ scope, invent evidence, accept a baseline, resolve a user decision, or declare
10
+ semantic work complete.
11
+
12
+ ## Diagnose
13
+
14
+ Call `ultra.doctor { repair: false }` and inspect:
15
+
16
+ - SQLite integrity, schema, backups, WAL/SHM, and migration state;
17
+ - artifact ownership, digest freshness, edges, orphans, and duplicate authority;
18
+ - team-checkpoint ancestry and real concurrent record conflicts;
19
+ - projection jobs, sessions, leases, worktrees, and recovery journals;
20
+ - installed plugin assets, MCP startup, and hook paths.
21
+
22
+ An expected workflow pause, editable draft, failed semantic checkpoint, or awaiting
23
+ owner decision is a warning, not corruption.
24
+
25
+ ## Repair
26
+
27
+ With explicit repair authority, call `ultra.doctor { repair: true }`. It may apply
28
+ backup-first schema migration, regenerate local projections, recover supported
29
+ journals, reconcile orphan sessions, and repair installed mechanical assets.
30
+
31
+ It may not manufacture semantic evidence, import or publish a team checkpoint, replace
32
+ a healthy baseline, resolve decisions, edit application code, or force a draft to
33
+ accepted. Use `ultra.sync` for reviewed checkpoint import/publish. Doctor never changes
34
+ semantic checkpoint acceptance or Change intent.
35
+
36
+ Preserve corrupt DB/WAL/SHM and dirty worktrees. Never patch plugin cache files by
37
+ hand; reinstall through `ubp` and verify the installed manifest and hook targets.
38
+
39
+ Rerun doctor read-only after repair. Report health, exact failed checks, backups,
40
+ repairs, preserved recovery paths, and remaining owner or semantic work. Do not invoke
41
+ another capability automatically.