ultra-builder-pro-cli 0.16.0 → 0.17.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 (64) hide show
  1. package/.ultra-template/specs/research-distillate.md +4 -3
  2. package/CHANGELOG.md +86 -0
  3. package/README.md +54 -24
  4. package/adapters/_shared/codex-assets.cjs +10 -5
  5. package/adapters/_shared/handbook.cjs +1 -1
  6. package/adapters/_shared/interaction-contract.cjs +61 -0
  7. package/adapters/claude.js +1 -1
  8. package/adapters/opencode.js +1 -1
  9. package/bin/orchestrator.js +175 -19
  10. package/commands/ultra-change.md +1 -1
  11. package/commands/ultra-deliver.md +3 -3
  12. package/commands/ultra-init.md +1 -1
  13. package/commands/ultra-plan.md +1 -1
  14. package/commands/ultra-research.md +2 -2
  15. package/commands/ultra-review.md +10 -0
  16. package/commands/ultra-status.md +1 -1
  17. package/commands/ultra-test.md +1 -1
  18. package/docs/AGENT-CONTEXT.md +11 -8
  19. package/docs/ARCHITECTURE.md +67 -9
  20. package/docs/LEGACY-CLI-CROSSWALK.md +163 -0
  21. package/docs/PLAN.zh-CN.md +19 -13
  22. package/docs/RUNTIME-COMPAT-MATRIX.md +2 -2
  23. package/docs/WORKFLOW-LIFECYCLE.md +123 -59
  24. package/hooks/pre_stop_check.py +3 -2
  25. package/mcp-server/lib/baseline-workflow.cjs +84 -16
  26. package/mcp-server/lib/change-workflow.cjs +55 -35
  27. package/mcp-server/lib/context-spine.cjs +171 -105
  28. package/mcp-server/lib/git-bootstrap.cjs +240 -0
  29. package/mcp-server/lib/init-project.cjs +178 -41
  30. package/mcp-server/lib/project-breadcrumb.cjs +14 -14
  31. package/mcp-server/lib/state-db.cjs +257 -10
  32. package/mcp-server/lib/state-ops.cjs +64 -1
  33. package/mcp-server/lib/workflow-state.cjs +300 -205
  34. package/mcp-server/server.cjs +58 -34
  35. package/orchestrator/auto-merge.cjs +19 -0
  36. package/orchestrator/daemon.cjs +104 -0
  37. package/orchestrator/parallel-orchestrator.cjs +371 -49
  38. package/orchestrator/session-runner.cjs +354 -25
  39. package/package.json +2 -1
  40. package/skills/ultra-change/SKILL.md +69 -94
  41. package/skills/ultra-deliver/SKILL.md +37 -65
  42. package/skills/ultra-dev/SKILL.md +50 -52
  43. package/skills/ultra-doctor/SKILL.md +34 -49
  44. package/skills/ultra-init/SKILL.md +78 -105
  45. package/skills/ultra-plan/SKILL.md +78 -99
  46. package/skills/ultra-research/SKILL.md +99 -113
  47. package/skills/ultra-review/SKILL.md +38 -53
  48. package/skills/ultra-review/references/review-modes.md +5 -3
  49. package/skills/ultra-review/references/unified-schema.md +26 -6
  50. package/skills/ultra-review/scripts/review_wait.py +12 -0
  51. package/skills/ultra-status/SKILL.md +34 -44
  52. package/skills/ultra-test/SKILL.md +61 -54
  53. package/skills/ultra-think/SKILL.md +37 -51
  54. package/skills/ultra-think/references/decision-dialogue.md +87 -111
  55. package/spec/cli-protocol.md +35 -0
  56. package/spec/mcp-tools.yaml +145 -28
  57. package/spec/schemas/delivery-report.v1.schema.json +1 -46
  58. package/spec/schemas/state-db.sql +8 -2
  59. package/spec/schemas/test-report.v1.schema.json +45 -14
  60. package/ultra-tools/cli.cjs +1 -1
  61. package/ultra-tools/commands/session.cjs +10 -3
  62. package/ultra-tools/commands/status.cjs +19 -14
  63. package/ultra-tools/commands/system.cjs +2 -2
  64. package/ultra-tools/commands/task.cjs +3 -0
@@ -1,98 +1,73 @@
1
1
  ---
2
2
  name: ultra-change
3
- description: Open or resume one bounded post-baseline change and connect its intent, delta, task plan, fresh context, and convergence evidence. Use when handling daily feature work, fixes, redesigns, or incidents after an Ultra baseline exists.
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
- # Align, route, and maintain one continuous change
7
-
8
- Use Ultra MCP for lifecycle writes. Keep external memory and code-graph content in
9
- their providers; Ultra stores references only. Read
10
- `../ultra-think/references/decision-dialogue.md` before forming a Change Contract.
11
-
12
- ## Capture and align the outcome
13
-
14
- 1. Read `system.doctor`, `baseline.get`, `change.list`, `change.breadcrumb`, and active
15
- decision threads. Resume the matching change or alignment thread; do not duplicate
16
- either authority.
17
- 2. New ordinary work requires a ready baseline. An incident on unhealthy authority
18
- requires an explicit `baseline_bypass` reason and approver. Never infer approval
19
- from urgency.
20
- 3. Inspect the current checkout before questioning the owner. Convert the request into
21
- a working outcome, constraints, accepted facts, unknowns, and likely risk profile.
22
- Resolve repository facts yourself.
23
- 4. Start a baseline-bound decision thread when the Change Contract contains a material
24
- owner choice. Normalize explicit decisions already present in the user's request
25
- without asking them to repeat themselves. Otherwise open one earliest decision,
26
- present it with a recommendation and durable effect, and STOP.
27
- 5. Read `references/change-contract.md`. After all blocking decisions are resolved,
28
- prepare one compact Change Contract checkpoint containing the outcome, executable
29
- acceptance, non-goals, public seams, recovery contract, unresolved decisions,
30
- documentation impact, profile rationale, material risk flags, and research
31
- disposition. The owner approves the contract once; do not ask for a second equivalent
32
- confirmation.
33
- 6. Select `quick`, `standard`, `major`, or `incident` from current scope and risk.
34
- Escalate a proposed quick change when its contract carries material risk or research.
35
- Write the compact approved alignment projection to
36
- `.ultra/docs/alignment/<thread-id>.md`, confirm the decision checkpoint with that
37
- artifact digest, then call `change.create` with `alignment_thread_id`. The create
38
- operation materializes the authoritative Change Contract projections. Read the
39
- normalized change and linked workflow back.
40
-
41
- Do not create a decision thread for a fact the agent can inspect or a reversible
42
- implementation detail already delegated by the accepted contract.
43
-
44
- ## Record the change workflow
45
-
46
- Use `workflow.step` as evidence becomes durable:
47
-
48
- - `bind-baseline`: current baseline id, revision, branch, and worktree evidence;
49
- - `classify-change`: kind and rationale;
50
- - `record-intent`: intent artifact, acceptance, scope, and resolved docs impact;
51
- - `plan-change`: completed plan workflow and authoritative task ids;
52
- - `compile-context`: current task-bound `change.context` manifest and digest;
53
- - `verify-readiness`: ready breadcrumb with one executable next action.
54
-
55
- Standard and major changes keep deltas under
56
- `.ultra/changes/active/<id>/delta/` and an evidence-linked `plan.md`. Deltas describe
57
- differences from the baseline; they are not a second baseline. Incidents maintain the
58
- structured diagnosis artifact and recovery evidence.
59
-
60
- When `research_disposition.status` is `bounded` or `required`, run `ultra-research`
61
- with the exact recorded mode and selected steps before planning. Planning is blocked
62
- until that change-bound research run is complete, current, and selection-equivalent.
63
- Use `none` only when the Change Contract already has sufficient evidence.
64
-
65
- Use `ultra-plan` to create complete DB-backed task contracts. Recompile
66
- `change.context` after any task, HEAD, specification, or decision change. The task's DB
67
- contract is authoritative; Prompt input may not override its seam or verification.
68
- Required missing or stale refs block. Budget warnings guide narrower context but never
69
- justify dropping necessary evidence or refusing legitimate work.
70
-
71
- An ordinary active change remains executable only while its durable `bind-baseline`
72
- evidence still names the current approved-ready baseline. HEAD, worktree, specification,
73
- or source-evidence drift created after that binding is advisory until delivery
74
- reconciliation. Adoption/migration state, missing approval or evidence, blocking gaps,
75
- and any other structural baseline failure block tasks, context, and later stages. Only
76
- the recorded incident break-glass authority can bypass that gate.
77
-
78
- Call `workflow.complete` only after all change workflow steps are current. Return the
79
- change id, kind, task set, context digest, blockers or warnings, workflow state, and the
80
- breadcrumb's one route.
81
-
82
- When implementation reveals a stable missing invariant, use
83
- `change.learning_propose` and the approval/reject/apply transition. Unresolved learning
84
- blocks delivery. An approved application must bind the declared target anchor, its
85
- before and after digests, and current evidence before the proposal becomes `applied`.
86
-
87
- ## Automatic routing contract
88
-
89
- Automatic means route, inspect, and recover automatically; it never means silently
90
- choose an owner decision. The normal route is:
91
-
92
- `capture → align → Change Contract checkpoint → change authority → bounded research when
93
- needed → plan candidate → plan decision review → plan approval → ultra-dev → test →
94
- review → deliver → baseline reconciliation`.
95
-
96
- A quick change may omit research and use one task only when evidence proves the request
97
- has no material unresolved decision or risk. An incident routes through reproduction,
98
- hypothesis discrimination, recovery choice, fix, and verification before convergence.
6
+ # Capture accepted change intent
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.
13
+
14
+ ## Inspect and align
15
+
16
+ 1. Read `system.doctor`, `baseline.get`, active changes, decisions, and
17
+ `change.breadcrumb`.
18
+ 2. Resume an existing change that matches the request. Do not duplicate authority.
19
+ 3. Ordinary work requires a healthy ready baseline. An incident may use only an
20
+ explicit `baseline_bypass` reason and approver; urgency is not approval.
21
+ 4. Inspect the checkout and accepted baseline before asking the user. Resolve code and
22
+ runtime facts yourself.
23
+ 5. Convert the request into a Change Contract:
24
+ - observable outcome and executable acceptance;
25
+ - non-goals and public seams;
26
+ - recovery strategy and verification;
27
+ - unresolved material decisions;
28
+ - documentation impact;
29
+ - change kind and evidence-backed risk flags;
30
+ - research disposition.
31
+
32
+ Select `quick`, `standard`, `major`, or `incident` from actual scope and risk. A quick
33
+ change may have no material risk, research obligation, or more than one task.
34
+
35
+ Ask only when a choice changes accepted product intent, scope, public behavior,
36
+ compatibility, security, material cost, external effects, or recovery. Use the host's
37
+ native question UI when available. Normalize clear choices already in the user's
38
+ request. The model owns reversible implementation detail inside the accepted contract.
39
+
40
+ ## Persist the contract
41
+
42
+ When a durable alignment checkpoint is necessary, bind it to a compact artifact and
43
+ pass its id as `alignment_thread_id`. Do not require a checkpoint for a complete,
44
+ unambiguous request that already provides current authority.
45
+
46
+ Call `change.create`. It records and completes exactly:
47
+
48
+ 1. `bind-baseline`
49
+ 2. `classify-change`
50
+ 3. `record-intent`
51
+
52
+ The returned change workflow must be `completed`; research, plan, context, dev, test,
53
+ review, and deliver remain independent capabilities. Standard and major changes may
54
+ store delta artifacts under `.ultra/changes/active/<id>/delta/`. Incidents maintain
55
+ the structured diagnosis artifact.
56
+
57
+ Use `change.update` when accepted intent or evidence changes. Update the Change
58
+ Contract, classification, research disposition, and docs impact together when their
59
+ meaning is coupled. Downstream task, context, test, or review evidence affected by that
60
+ change must become stale and be regenerated; never keep old evidence green by prompt
61
+ assertion.
62
+
63
+ If research is required, invoke `ultra-research` with the recorded disposition. If the
64
+ contract is sufficiently evidenced, the host may recommend `ultra-plan`. `change.context`
65
+ is compiled only for an actual plan, implementation, test, or review consumer.
66
+
67
+ Stable implementation discoveries use the approval-gated specification-learning
68
+ transitions. External memory and graph providers retain their own content; Ultra stores
69
+ metadata references only.
70
+
71
+ Return the normalized contract, change id and kind, research disposition, blockers,
72
+ and `allowed_transitions`. The host selects a recommendation from those transitions;
73
+ MCP does not encode a semantic next action.
@@ -1,84 +1,56 @@
1
1
  ---
2
2
  name: ultra-deliver
3
- description: Converge one verified Ultra change, reconcile specification learning and baseline authority, archive recoverably, and optionally release when explicitly authorized. Use when current test and independent review evidence are ready for delivery.
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
- # Converge and deliver one change
6
+ # Converge and archive local authority
7
7
 
8
- Use host judgment for release scope and authorization. Use Ultra MCP for evidence
9
- binding, workflow state, convergence, baseline reconciliation, archive recovery, and
10
- output digests.
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.
11
10
 
12
11
  ## Bind current evidence
13
12
 
14
- 1. Read `system.doctor`, `baseline.get`, `change.get`, `change.breadcrumb`, active
15
- decision state, linked tasks, and current test/review workflows and artifacts. An
16
- open decision, blocking deferral, or unconfirmed checkpoint prevents delivery.
17
- 2. Resume or start a `deliver` workflow linked to the change and baseline.
18
- 3. Require completed tasks, current context, a passing test report at full HEAD with a
19
- verified public seam, and current independent `spec_fidelity` and
20
- `engineering_standards` verdicts. Record `bind-evidence`.
13
+ 1. Read doctor, baseline, change, breadcrumb, decisions, tasks, test, review, learning,
14
+ and current checkout.
15
+ 2. Resume or start a deliver workflow bound to the change and baseline.
16
+ 3. Require complete task evidence, a current test report, both review axes, current
17
+ context, and resolved material decisions. Record `bind-evidence`.
21
18
 
22
- Evidence from another revision, task set, change, or stale output is invalid. An
23
- approved break-glass incident follows only its recorded recovery contract.
19
+ Evidence from another revision, task set, or change is invalid.
24
20
 
25
- ## Reconcile and verify
21
+ ## Reconcile specifications
26
22
 
27
- Resolve every specification-learning proposal. Apply an approved item to its declared
28
- target and verify it before marking it applied; preserve rejection reasons. Reconcile
29
- accepted delta and documentation impact into baseline documents, or record an exact
30
- no-change reason. Record `reconcile-specifications`.
23
+ Resolve every specification-learning candidate. Apply approved learning to its target
24
+ with before/after digests and verification; preserve rejection reasons.
31
25
 
32
- Read `references/baseline-reconciliation.md` and write the bound reconciliation
33
- manifest inside the active change directory. It must record every baseline update as a
34
- semantic add or update with a real source anchor, before/after digests, verification,
35
- resolved gap ids, and resolved unknowns. A no-update delivery records one evidenced
36
- semantic no-change reason.
26
+ Read `references/baseline-reconciliation.md` and write the reconciliation manifest
27
+ inside the active change directory. Record semantic additions or updates, resolved
28
+ gaps and unknowns, and verification. If baseline semantics did not change, record an
29
+ evidenced no-change reason. Record `reconcile-specifications`.
37
30
 
38
- Verify the release candidate with repository-native focused/regression checks,
39
- type/lint/build where applicable, install/doctor smoke for distributed packages,
40
- public seams, and rollback or recovery sanity. Compile final convergence context and
41
- record its immutable manifest as the `verify-candidate` output. Any edit invalidates
42
- affected evidence.
31
+ Compile final convergence context and run the risk-selected candidate checks, install
32
+ or doctor smoke when this change modifies distributed assets, public-seam verification,
33
+ and recovery sanity. Record the immutable context under `verify-candidate`.
43
34
 
44
- Call `change.converge` with only the change id. Do not submit verdicts or evidence
45
- summaries: MCP derives development, test report, public seam, specification,
46
- documentation, both review axes, and incident diagnosis evidence from DB-backed
47
- workflows and current artifacts. Resolve named blockers and rerun invalidated gates. Record
48
- `converge-authority` only when the change is ready.
35
+ Call `change.converge`; MCP derives readiness from durable dev, test, review,
36
+ specification, docs, diagnosis, and current checkout evidence. Record
37
+ `converge-authority` only when ready.
49
38
 
50
- Call `change.archive` with the summary, `reconciliation_path`, and baseline updates or
51
- exact no-change reason.
52
- Ordinary archive refreshes baseline revision and digests atomically and rolls back on
53
- incomplete reconciliation. Record `archive-change`. For break-glass delivery, verify
54
- the returned bypass and blocking reconciliation gap.
39
+ Call `change.archive` with the reconciliation manifest and summary. Verify the refreshed
40
+ baseline and archived packet, then record `archive-change`.
55
41
 
56
- ## Release only with authority
42
+ Write `.ultra/reports/delivery/<workflow-id>.json` with
43
+ `ultra-delivery-report-v1`: archived change, baseline, HEAD, worktree and context
44
+ digests, local checks, rollback notes, and timestamp. The report must not contain a
45
+ release decision. Record it under `verify-delivery` and complete the workflow.
57
46
 
58
- The `release-if-authorized` step is not permission. When publication is outside the
59
- user's request, complete it with exactly one `release_authorization` decision containing
60
- `authorized: false` and the reason. When explicitly authorized, record
61
- `authorized: true`, `approved_by`, the exact release `scope`, and the reason; then
62
- determine compatibility impact, update version and
63
- changelog, rerun invalidated checks, create a non-force commit/tag, push, publish, and
64
- verify remote commit, tag, release, and registry version independently.
65
- If release authority is not already explicit, present that authorization as one compact
66
- question and stop. Do not bundle release permission with unrelated delivery choices or
67
- ask again when the current user request already grants the exact scope.
47
+ ## External effects
68
48
 
69
- Write `.ultra/reports/delivery/<workflow-id>.json` atomically using
70
- `ultra-delivery-report-v1`, with change/archive state, baseline id/status, full HEAD,
71
- worktree digest, convergence-context digest, exact passing
72
- checks, the explicit release authorization/performed decision, release identifiers
73
- when applicable, structured evidence for every performed commit/push/tag/registry/
74
- deployment action, rollback notes, and timestamp. The report authorization must match
75
- the DB-recorded decision. Record `verify-delivery` with that
76
- output and call `workflow.complete` only after the change is archived and local and
77
- remote evidence agree for every authorized action. MCP derives the delivery summary
78
- from this report rather than a Prompt claim.
49
+ If the user separately requests commit, push, tag, publish, or deploy, handle that as a
50
+ host-owned effect after Ultra delivery. Confirm only missing material authority, run
51
+ the repository's release checks, and report remote evidence separately. Never infer an
52
+ external effect from `ultra-deliver`, and never encode it as completed Ultra delivery
53
+ state.
79
54
 
80
- Return workflow id, archive and baseline state, evidence digests, commit/release facts,
81
- recovery notes, residual risks, and one next route. Successful delivery routes to
82
- `ultra-status` for the final authoritative view or `ultra-change` for the next accepted
83
- outcome. Stale gates return to their owning workflow; a new owner choice routes to
84
- `ultra-think`; broken authority routes to `ultra-doctor`.
55
+ Return archive and baseline state, evidence digests, recovery notes, residual risks,
56
+ and allowed transitions.
@@ -1,66 +1,64 @@
1
1
  ---
2
2
  name: ultra-dev
3
- description: Execute one authoritative Ultra task through a fresh-context, test-driven, review-backed live-path slice with resumable DB state. Use when a planned task is ready to implement, resume, or recover after a blocker or interrupted session.
3
+ description: Implement one authoritative Ultra task through a fresh-context, test-driven, review-backed live path. Use when a planned task is executable, interrupted, or ready for focused recovery.
4
4
  ---
5
5
 
6
- # Implement one executable task
6
+ # Implement one task
7
7
 
8
- Bind exactly one task and change. Use the host for code reasoning and edits; use Ultra
9
- MCP for workflow state, context authority, task/session transitions, evidence, and
10
- recovery.
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.
11
10
 
12
- ## Start or resume
11
+ ## Bind and resume
13
12
 
14
- 1. Read `system.doctor`, `change.breadcrumb`, active decision state, `task.get`, workflow
15
- state, dependencies, active sessions, Git HEAD, and worktree scope. If the
16
- breadcrumb names an open decision or unconfirmed checkpoint, return to
17
- `ultra-think` and do not edit code.
18
- 2. Resume an existing `dev` workflow or call `workflow.start` with `change_id` and
19
- `task_id`. Startup fails when the DB-backed task execution contract is incomplete or
20
- owned by another change.
21
- 3. Record `bind-task` with task, dependency, branch, and worktree evidence.
22
- 4. Compile `change.context` for `implement`. It derives public seam, verification, and
23
- required refs from the task row. Record its immutable manifest as the
24
- `compile-context` output only when ready. That starting snapshot remains historical
25
- task evidence; later task commits do not invalidate it when its commit stays on the
26
- current ancestry and the task contract is unchanged.
27
- 5. Run session admission before spawning an isolated session. Do not open a second
28
- active lease without the documented resume, takeover, or abandon decision.
13
+ 1. Read doctor, breadcrumb, active decisions, task contract, dependencies, dev runs,
14
+ sessions, HEAD, and worktree.
15
+ 2. Resume the matching dev run or start one with `change_id` and `task_id`.
16
+ 3. Record `bind-task` with current authority and dependency evidence.
17
+ 4. Compile `change.context` for `implement` using DB-backed public seam, verification
18
+ command, and refs. Context budgets are advisory; missing required evidence is
19
+ blocking. Record the immutable manifest as `compile-context`.
20
+ 5. Reuse an existing valid session. Otherwise pass admission and call `session.spawn`.
21
+ Work only in the returned worktree and preserve unrelated changes.
29
22
 
30
- ## Red, green, verify
23
+ Do not spawn recursively from a parent-owned worker session. Process exit is transport
24
+ evidence, never task completion.
31
25
 
32
- 1. Reproduce the behavior or establish a characterization signal before logic edits.
33
- Record `establish-feedback-loop` with the exact failing command and observed result.
34
- 2. Set the task `in_progress`; implement the smallest complete vertical slice through
35
- the declared public seam. Preserve unrelated worktree changes.
36
- 3. Keep application judgment and edits in the host. Do not write projections, raw DB,
37
- workflow output digests, or evidence state by hand.
38
- 4. Refactor only inside the accepted slice while the focused signal stays green.
39
- When implementation exposes a product, compatibility, security, cost, or recovery
40
- choice outside the accepted task contract, preserve the evidence, open one decision
41
- through the shared dialogue protocol, and stop. Do not convert implementation
42
- convenience into an owner decision.
43
- 5. Record `implement-slice`, then run focused, adjacent, static/build, public-seam,
44
- error, and recovery checks proportional to risk. Record exact evidence under
45
- `verify-slice`.
46
- 6. Run `ultra-review` at the current diff. Record both independent verdict axes under
47
- `review-slice`; unresolved blocking findings return to implementation.
26
+ ## Focused inner loop
27
+
28
+ 1. Reproduce the bug, write a failing test, or establish a characterization signal
29
+ before a logic change. Record `establish-feedback-loop`.
30
+ 2. Mark the task `in_progress` and implement the smallest complete slice through the
31
+ declared public seam.
32
+ 3. Keep the loop adaptive. The model may choose implementation details inside the
33
+ accepted contract. If new evidence changes product intent, compatibility, security,
34
+ material cost, external effects, or recovery, use the host's native question UI and
35
+ the decision protocol; do not ask about ordinary reversible details.
36
+ 4. Record `implement-slice`, then run focused tests plus the adjacent checks justified
37
+ by the task risk. Record exact results under `verify-slice`.
38
+ 5. Run a task-scoped independent review on specification fidelity and relevant
39
+ engineering risks. Record `review-slice`. Fix blocking findings and refresh affected
40
+ evidence.
41
+ 6. Create the authorized local task commit. Do not push, publish, tag, or deploy unless
42
+ the user separately authorized that external effect.
43
+
44
+ Task-level tests and review belong to this inner loop. They do not replace aggregate
45
+ change testing or review when multiple slices, integrations, or broader risks require
46
+ those capabilities.
48
47
 
49
48
  ## Complete or recover
50
49
 
51
- Close the admitted session with `session.close` after its final heartbeat and verify
52
- that no running lease remains for the task. Then update the task to `completed` only
53
- after acceptance, verification, documentation, and review are current. Record
54
- `record-completion` with commands, results, changed paths, commit when authorized, and
55
- context/review references; then call `workflow.complete`. The MCP refuses dev
56
- convergence while the task is incomplete or a session is still running.
50
+ In direct mode, integrate the task commit through the repository's accepted path,
51
+ verify ancestry and the public seam, close the session, update the task to `completed`,
52
+ record `record-completion`, and complete the dev workflow.
53
+
54
+ In a parent-supervised worker, record completion evidence and exit without closing the
55
+ parent-owned lease. The primary host verifies the exact session commit, performs any
56
+ integration, refreshes review if the reviewed checkout changed, settles the lease, and
57
+ completes the workflow.
57
58
 
58
- On interruption or an external blocker, record the current step as `blocked`, update
59
- the task consistently, and preserve the session and evidence. Resume the same run;
60
- completed steps remain durable. Any code or contract change invalidates affected test,
61
- review, or context evidence.
59
+ Preserve worktrees by default. Remove one only when Git proves it is clean and
60
+ integrated. On interruption, record the current step and task as blocked, preserve
61
+ worktree and evidence, and resume the same run later.
62
62
 
63
- Return the task outcome, public seam, changed paths, exact checks, review results,
64
- workflow id, session state, residual risks, and one next route. Route another ready
65
- task to `ultra-dev`; route a fully implemented change to aggregate `ultra-test`;
66
- route a new owner choice to `ultra-think`; route broken authority to `ultra-doctor`.
63
+ Return outcome, changed paths, public seam, exact checks, review axes, commit and
64
+ session state, residual risk, and allowed transitions.
@@ -1,65 +1,50 @@
1
1
  ---
2
2
  name: ultra-doctor
3
- description: Diagnose and recover Ultra DB schema, workflow outputs, projections, sessions, incidents, change artifacts, archives, hooks, and installed host assets. Use when authority is degraded, workflow state disagrees with prompts, outputs are stale, hooks fail, or MCP operations cannot proceed.
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.
4
4
  ---
5
5
 
6
6
  # Diagnose before repair
7
7
 
8
- Default to read-only diagnosis. Call `system.doctor` with repair disabled and inspect:
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.
9
11
 
10
- - SQLite integrity, schema version, required tables, and migration provenance;
11
- - baseline classification/readiness, research provenance, spec/evidence digests, gaps,
12
- and revision/worktree drift;
13
- - active, blocked, and ready workflow runs, current steps, blockers, and output health;
14
- - active decision threads, the sole current question, blocking deferrals, checkpoint
15
- state, and current checkpoint artifact digests;
16
- - event/projection cursor lag and failed or interrupted projection jobs;
17
- - sessions, incidents, circuit state, active-change artifacts, and archive journals;
18
- - external provider ownership boundaries.
12
+ ## Read-only diagnosis
19
13
 
20
- An expected blocked workflow is a workflow warning, not DB corruption. A stale or
21
- missing recorded output is an authority failure for that run. Doctor cannot invent
22
- evidence, complete a step, accept a failure, approve a baseline, or change product
23
- scope.
24
- An awaiting owner decision is also a recoverable warning, not corruption. A missing or
25
- changed artifact bound to a current confirmed checkpoint is an authority failure;
26
- doctor may report it but cannot reconstruct the decision or approval.
14
+ Run `system.doctor` without repair and inspect:
27
15
 
28
- ## Route failures
16
+ - SQLite integrity, schema 18 migration, required tables, and backups;
17
+ - baseline and research provenance, gaps, digests, and Git/worktree drift;
18
+ - workflow status, obsolete-step migration, blockers, and output freshness;
19
+ - decisions and checkpoint artifact freshness;
20
+ - projection jobs and event cursors;
21
+ - sessions, preserved worktrees, incidents, circuit state, and archive journals;
22
+ - external provider boundaries.
29
23
 
30
- - Missing or migrated baseline evidence: `ultra-init` and the exact research step.
31
- - Stale workflow output: restore or regenerate the artifact from accepted evidence,
32
- then record the affected step again and re-run completion.
33
- - Projection lag with healthy authority: eligible for mechanical regeneration.
34
- - Orphan session: reconcile the recorded lease; do not kill unrelated processes.
35
- - Missing change artifact: recover from version control, backup, or explicit owner
36
- decision rather than silently recreating it.
37
- - Open decision: resume its exact question through `ultra-think`; checkpoint-ready
38
- state requires owner confirmation, not mechanical repair.
39
- - Stale decision artifact: restore or update the artifact from accepted authority,
40
- then reprepare and reconfirm the same checkpoint through `ultra-think`; do not
41
- rewrite the owner decision or mark the failure healthy mechanically.
42
- - Corrupt SQLite: preserve DB/WAL/SHM and obtain a restore-or-rebaseline decision.
24
+ An expected workflow pause or awaiting user decision is a warning, not corruption.
25
+ Missing or changed required evidence is an authority failure but cannot be reconstructed
26
+ by doctor.
43
27
 
44
- ## Explicit project repair
28
+ ## Recovery boundary
45
29
 
46
- After authorization, call `system.doctor` with repair enabled. Repair is limited to
47
- supported schema upgrades, backup-first archive recovery, orphan reconciliation,
48
- staleness consumption, projection requeue, and projection regeneration. Verify the
49
- pre-migration and repair backup paths and rerun the read-only report. A completed repair
50
- action does not imply healthy workflow evidence.
30
+ With explicit repair authorization, `system.doctor` may:
51
31
 
52
- When integrity prevents opening the DB, use only the documented restore or rebaseline
53
- command with its explicit confirmation token. Both must quarantine or back up prior
54
- authority and roll back on failure.
32
+ - apply backup-first supported schema migrations;
33
+ - migrate active pre-18 rigid workflows into recoverable adaptive state;
34
+ - requeue or regenerate projections from healthy DB authority;
35
+ - reconcile orphan sessions without deleting unrelated or dirty worktrees;
36
+ - resume supported archive journals;
37
+ - recover missing workflow provenance as a blocked run requiring real evidence.
55
38
 
56
- ## Installed host failures
39
+ It may not create a Git checkpoint, replace a healthy baseline, accept known failures,
40
+ resolve decisions, regenerate semantic content, or edit application code.
57
41
 
58
- For a missing hook adapter or stale plugin path, capture the manifest and missing
59
- target, run `ubp --doctor` for the actual host, reinstall through the adapter rather
60
- than patching cache contents, and verify provenance, hashes, entry points, MCP startup,
61
- and a hook smoke test. Project doctor and installer doctor are separate authorities.
42
+ Corrupt SQLite requires preservation of DB, WAL, and SHM followed by an explicit
43
+ restore-or-rebaseline choice. Missing hook adapters or stale cache paths require
44
+ `ubp --doctor` and adapter reinstall; never patch plugin cache contents by hand.
62
45
 
63
- Return health first, failing authority checks, workflow warnings, backup/recovery
64
- paths, whether repair ran, unresolved owners, and one exact next action. Do not edit
65
- application code or external memory/graph providers through this Skill.
46
+ After repair, rerun doctor read-only and verify backup paths, schema, installed hashes,
47
+ entry points, MCP startup, and hook smoke tests as applicable.
48
+
49
+ Return health first, failed checks, mechanical repairs performed, preserved recovery
50
+ paths, unresolved owners, and allowed transitions plus any unique required transition.