ultra-builder-pro-cli 0.14.0 → 0.15.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 (154) hide show
  1. package/.ultra-template/docs/research/README.md +11 -7
  2. package/.ultra-template/specs/architecture.md +36 -36
  3. package/.ultra-template/specs/discovery.md +46 -33
  4. package/.ultra-template/specs/product.md +38 -29
  5. package/.ultra-template/specs/research-distillate.md +48 -0
  6. package/.ultra-template/tasks/contexts/TEMPLATE.md +11 -28
  7. package/CHANGELOG.md +44 -1
  8. package/README.md +34 -19
  9. package/adapters/_shared/codex-assets.cjs +6 -2
  10. package/adapters/_shared/file-ops.cjs +6 -2
  11. package/adapters/claude.js +3 -2
  12. package/adapters/codex.js +1 -0
  13. package/adapters/kimi.js +3 -2
  14. package/adapters/opencode.js +3 -2
  15. package/agents/review-coordinator.md +9 -6
  16. package/docs/AGENT-CONTEXT.md +15 -8
  17. package/docs/ARCHITECTURE.md +33 -12
  18. package/docs/PLAN.zh-CN.md +3 -2
  19. package/docs/ROADMAP.md +8 -4
  20. package/docs/RUNTIME-COMPAT-MATRIX.md +4 -4
  21. package/docs/STATE-DB-ACCESS-POLICY.md +27 -25
  22. package/docs/WORKFLOW-LIFECYCLE.md +266 -0
  23. package/hooks/README.md +6 -1
  24. package/hooks/health_check.py +12 -3
  25. package/hooks/subagent_tracker.py +52 -77
  26. package/mcp-server/hook-event.cjs +34 -0
  27. package/mcp-server/lib/archive-journal.cjs +17 -5
  28. package/mcp-server/lib/baseline-workflow.cjs +158 -18
  29. package/mcp-server/lib/change-workflow.cjs +550 -85
  30. package/mcp-server/lib/context-spine.cjs +242 -24
  31. package/mcp-server/lib/doctor.cjs +33 -3
  32. package/mcp-server/lib/init-project.cjs +210 -16
  33. package/mcp-server/lib/plan-store.cjs +4 -1
  34. package/mcp-server/lib/pricing.cjs +7 -10
  35. package/mcp-server/lib/project-breadcrumb.cjs +6 -0
  36. package/mcp-server/lib/projector.cjs +57 -3
  37. package/mcp-server/lib/spec-learning.cjs +79 -2
  38. package/mcp-server/lib/state-db.cjs +145 -8
  39. package/mcp-server/lib/state-ops.cjs +160 -9
  40. package/mcp-server/lib/workflow-state.cjs +2292 -0
  41. package/mcp-server/server.cjs +161 -15
  42. package/orchestrator/daemon.cjs +1 -2
  43. package/orchestrator/dispatch-rules.cjs +5 -31
  44. package/orchestrator/planner/plan-builder.cjs +21 -12
  45. package/package.json +13 -3
  46. package/skills/ultra-change/SKILL.md +53 -68
  47. package/skills/ultra-change/references/change-contract.md +36 -0
  48. package/skills/ultra-deliver/SKILL.md +69 -79
  49. package/skills/ultra-deliver/references/baseline-reconciliation.md +20 -0
  50. package/skills/ultra-dev/SKILL.md +54 -59
  51. package/skills/ultra-doctor/SKILL.md +40 -71
  52. package/skills/ultra-init/SKILL.md +96 -103
  53. package/skills/ultra-init/references/brownfield-adoption.md +2 -2
  54. package/skills/ultra-plan/SKILL.md +79 -85
  55. package/skills/ultra-plan/references/semantic-preflight.md +18 -0
  56. package/skills/ultra-research/SKILL.md +87 -60
  57. package/skills/ultra-research/references/00-problem-validation.md +36 -0
  58. package/skills/ultra-research/references/01-opportunity-discovery.md +33 -0
  59. package/skills/ultra-research/references/02-market-assessment.md +30 -0
  60. package/skills/ultra-research/references/03-competitive-landscape.md +31 -0
  61. package/skills/ultra-research/references/04-product-strategy.md +32 -0
  62. package/skills/ultra-research/references/05-assumptions-validation.md +31 -0
  63. package/skills/ultra-research/references/10-user-personas.md +29 -0
  64. package/skills/ultra-research/references/11-user-scenarios.md +28 -0
  65. package/skills/ultra-research/references/20-user-stories.md +30 -0
  66. package/skills/ultra-research/references/21-features-scope.md +29 -0
  67. package/skills/ultra-research/references/22-success-metrics.md +28 -0
  68. package/skills/ultra-research/references/30-architecture-context.md +30 -0
  69. package/skills/ultra-research/references/31-solution-strategy.md +28 -0
  70. package/skills/ultra-research/references/32-building-blocks.md +28 -0
  71. package/skills/ultra-research/references/40-deployment.md +29 -0
  72. package/skills/ultra-research/references/41-quality-risks.md +28 -0
  73. package/skills/ultra-research/references/99-synthesis.md +35 -0
  74. package/skills/ultra-review/SKILL.md +57 -73
  75. package/skills/ultra-review/references/review-modes.md +27 -0
  76. package/skills/ultra-review/references/unified-schema.md +25 -0
  77. package/skills/ultra-review/scripts/review_wait.py +40 -3
  78. package/skills/ultra-status/SKILL.md +41 -45
  79. package/skills/ultra-test/SKILL.md +48 -55
  80. package/skills/ultra-verify/SKILL.md +1 -1
  81. package/skills/ultra-verify/references/{confidence-system.md → evidence-status.md} +3 -3
  82. package/spec/cli-protocol.md +7 -2
  83. package/spec/mcp-tools.yaml +384 -63
  84. package/spec/schemas/baseline-reconciliation.v1.schema.json +73 -0
  85. package/spec/schemas/delivery-report.v1.schema.json +111 -0
  86. package/spec/schemas/mcp-tools.schema.json +1 -1
  87. package/spec/schemas/state-db.sql +82 -1
  88. package/spec/schemas/tasks.v4.5.schema.json +8 -1
  89. package/spec/schemas/test-report.v1.schema.json +194 -0
  90. package/ultra-tools/cli.cjs +1 -1
  91. package/ultra-tools/commands/migrate.cjs +3 -3
  92. package/ultra-tools/commands/status.cjs +213 -12
  93. package/.ultra-template/delivery-report.json +0 -9
  94. package/.ultra-template/test-report.json +0 -8
  95. package/adapters/_shared/tests/file-ops.test.cjs +0 -54
  96. package/adapters/_shared/tests/frontmatter.test.cjs +0 -47
  97. package/adapters/_shared/tests/handbook.test.cjs +0 -101
  98. package/adapters/_shared/tests/path-rewrite.test.cjs +0 -60
  99. package/adapters/_shared/tests/provenance.test.cjs +0 -133
  100. package/adapters/_shared/tests/resolve-target.test.cjs +0 -75
  101. package/adapters/_shared/tests/runtime-assets.test.cjs +0 -149
  102. package/adapters/_shared/tests/settings-merge.test.cjs +0 -85
  103. package/adapters/_shared/tests/validate.test.cjs +0 -30
  104. package/adapters/tests/claude.test.cjs +0 -138
  105. package/adapters/tests/codex-hook.test.cjs +0 -142
  106. package/adapters/tests/codex.test.cjs +0 -430
  107. package/adapters/tests/kimi-hook.test.cjs +0 -149
  108. package/adapters/tests/kimi.test.cjs +0 -259
  109. package/adapters/tests/opencode.test.cjs +0 -357
  110. package/mcp-server/lib/archive-journal.test.cjs +0 -35
  111. package/mcp-server/lib/baseline-workflow.test.cjs +0 -477
  112. package/mcp-server/lib/change-workflow.test.cjs +0 -971
  113. package/mcp-server/lib/context-spine.test.cjs +0 -93
  114. package/mcp-server/lib/doctor.test.cjs +0 -148
  115. package/mcp-server/lib/plan-store.test.cjs +0 -132
  116. package/mcp-server/lib/prd-parser.test.cjs +0 -82
  117. package/mcp-server/lib/project-breadcrumb.test.cjs +0 -112
  118. package/mcp-server/lib/runtime-state.test.cjs +0 -92
  119. package/mcp-server/lib/spec-learning.test.cjs +0 -67
  120. package/mcp-server/lib/state-db.test.cjs +0 -314
  121. package/mcp-server/lib/task-expander.test.cjs +0 -169
  122. package/mcp-server/lib/topo.test.cjs +0 -158
  123. package/mcp-server/tests/circuit-breaker.test.cjs +0 -125
  124. package/mcp-server/tests/commit-hash-flow.test.cjs +0 -117
  125. package/mcp-server/tests/concurrency-update.test.cjs +0 -96
  126. package/mcp-server/tests/concurrency.test.cjs +0 -112
  127. package/mcp-server/tests/db-ops.test.cjs +0 -121
  128. package/mcp-server/tests/init-project.test.cjs +0 -393
  129. package/mcp-server/tests/migrate.test.cjs +0 -232
  130. package/mcp-server/tests/projector.test.cjs +0 -162
  131. package/mcp-server/tests/server-contract.test.cjs +0 -1467
  132. package/mcp-server/tests/staleness.test.cjs +0 -190
  133. package/mcp-server/tests/state-db.test.cjs +0 -106
  134. package/mcp-server/tests/state-ops.test.cjs +0 -449
  135. package/mcp-server/tests/tagged-tasks.test.cjs +0 -163
  136. package/mcp-server/tests/telemetry.test.cjs +0 -219
  137. package/orchestrator/planner/plan-builder.test.cjs +0 -165
  138. package/orchestrator/tests/auto-merge.test.cjs +0 -216
  139. package/orchestrator/tests/daemon.test.cjs +0 -311
  140. package/orchestrator/tests/dispatch-rules.test.cjs +0 -124
  141. package/orchestrator/tests/parallel-orchestrator.test.cjs +0 -233
  142. package/orchestrator/tests/phase-8b-gate.test.cjs +0 -183
  143. package/orchestrator/tests/recovery.test.cjs +0 -190
  144. package/orchestrator/tests/session-runner.test.cjs +0 -314
  145. package/orchestrator/tests/skill-miner.test.cjs +0 -147
  146. package/orchestrator/tests/worktree-manager.test.cjs +0 -148
  147. package/skills/ultra-research/references/architecture.md +0 -38
  148. package/skills/ultra-research/references/problem-product.md +0 -39
  149. package/skills/ultra-research/references/quality-delivery.md +0 -34
  150. package/skills/ultra-research/references/synthesis.md +0 -38
  151. package/skills/ultra-research/references/users-scope.md +0 -40
  152. package/ultra-tools/legacy-memory.test.cjs +0 -80
  153. package/ultra-tools/status-command.test.cjs +0 -181
  154. package/ultra-tools/system-command.test.cjs +0 -309
@@ -1,87 +1,77 @@
1
1
  ---
2
2
  name: ultra-deliver
3
- description: Converge verified implementation, specification learning, review evidence, and release artifacts into a recoverable baseline. Use when an initial baseline or active change has current passing evidence and is ready to archive or release.
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.
4
4
  ---
5
5
 
6
- # Converge and deliver
6
+ # Converge and deliver one change
7
7
 
8
- Deliver one baseline or continuous change. Change lifecycle writes use MCP; test,
9
- review, and delivery reports are evidence artifacts.
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.
10
11
 
11
12
  ## Bind current evidence
12
13
 
13
- 1. Call `baseline.get`, then `change.list`. Bind exactly one relevant change, or the
14
- current draft/adopting baseline when this is the initial delivery.
15
- 2. Call `change.breadcrumb`. Context-size warnings are advisory. Ordinary delivery
16
- blocks on incomplete baseline adoption, stale execution context, incomplete linked
17
- tasks, or unresolved readiness. An explicitly approved break-glass incident may
18
- continue while baseline adoption is incomplete.
19
- 3. Require a passing test report for the current full HEAD and at least one declared
20
- public seam.
21
- 4. Require current independent `spec_fidelity` and `engineering_standards` review
22
- verdicts. Evidence from another checkout, commit, task set, or change is invalid.
23
-
24
- ## Reconcile the baseline
25
-
26
- Call `change.get` for authoritative learning candidates.
27
-
28
- - Resolve every proposed item as approved or rejected.
29
- - Apply each approved item to its declared baseline target, verify the edit, then mark
30
- it applied.
31
- - Preserve rejection reasons as decision evidence.
32
- - Confirm previously applied items remain represented in the target document.
33
-
34
- Reconcile accepted delta content and documentation impact into baseline documents.
35
- Record updated paths or a specific no-change reason. Unknown documentation impact,
36
- unresolved placeholders, and behavior that exists only in the delta block convergence.
37
-
38
- For an initial baseline without a change, call `baseline.record`, obtain explicit owner
39
- approval, and call `baseline.converge`. Do not simulate initial delivery through a null
40
- change record.
41
-
42
- ## Verify the release candidate
43
-
44
- Use a clean, reviewed release commit. Show any remaining diff and obtain explicit
45
- authorization before staging or committing. Never stage unrelated user changes.
46
-
47
- Run the exact repository commands needed for focused regression, relevant full tests,
48
- static checks, production build, package/install/doctor smoke when distributed, the
49
- public seam, and rollback or recovery sanity. Any post-verification edit invalidates
50
- the affected evidence.
51
-
52
- Compile final change context at the release commit with the convergence gate. It must
53
- be ready before calling `change.converge`.
54
-
55
- ## Converge and archive
56
-
57
- Submit structured evidence for the reviewed diff and seam, test signals, baseline and
58
- delta, documentation, both independent review axes, and incident diagnosis when
59
- applicable. Do not collapse review axes or replace exact signal fields with prose.
60
-
61
- Resolve named blockers, rerun invalidated gates, then call `change.archive` with the
62
- summary and baseline updates or an exact no-change reason. Ordinary archive
63
- reconciliation refreshes the authoritative baseline revision and digests, rechecks
64
- health, and rolls back state and artifacts when any tracked digest or revision remains
65
- stale.
66
-
67
- For a break-glass incident, verify that archive returned `baseline_bypass: true` and
68
- created the open reconciliation gap on the current baseline. Report incident delivery
69
- separately from project baseline readiness. Resolve that gap through `ultra-init`
70
- before starting ordinary work.
71
-
72
- ## Optional release
73
-
74
- Only when release authorization is in scope:
75
-
76
- 1. determine the semantic version from compatibility impact;
77
- 2. update version and changelog;
78
- 3. rerun checks invalidated by version changes;
79
- 4. create a non-force commit and tag;
80
- 5. push and publish through the repository's authenticated workflow;
81
- 6. independently verify the remote commit, tag, release, and registry version.
82
-
83
- Write the delivery report with the change id, archive status, commit, version, exact
84
- commands, release identifiers, baseline updates, rollback notes, and timestamp.
85
-
86
- Delivery is complete only when local and remote evidence agree and the worktree has no
87
- unexplained scope. A local version bump is not publication evidence.
14
+ 1. Read `system.doctor`, `baseline.get`, `change.get`, `change.breadcrumb`, linked
15
+ tasks, and current test/review workflows and artifacts.
16
+ 2. Resume or start a `deliver` workflow linked to the change and baseline.
17
+ 3. Require completed tasks, current context, a passing test report at full HEAD with a
18
+ verified public seam, and current independent `spec_fidelity` and
19
+ `engineering_standards` verdicts. Record `bind-evidence`.
20
+
21
+ Evidence from another revision, task set, change, or stale output is invalid. An
22
+ approved break-glass incident follows only its recorded recovery contract.
23
+
24
+ ## Reconcile and verify
25
+
26
+ Resolve every specification-learning proposal. Apply an approved item to its declared
27
+ target and verify it before marking it applied; preserve rejection reasons. Reconcile
28
+ accepted delta and documentation impact into baseline documents, or record an exact
29
+ no-change reason. Record `reconcile-specifications`.
30
+
31
+ Read `references/baseline-reconciliation.md` and write the bound reconciliation
32
+ manifest inside the active change directory. It must record every baseline update as a
33
+ semantic add or update with a real source anchor, before/after digests, verification,
34
+ resolved gap ids, and resolved unknowns. A no-update delivery records one evidenced
35
+ semantic no-change reason.
36
+
37
+ Verify the release candidate with repository-native focused/regression checks,
38
+ type/lint/build where applicable, install/doctor smoke for distributed packages,
39
+ public seams, and rollback or recovery sanity. Compile final convergence context and
40
+ record its immutable manifest as the `verify-candidate` output. Any edit invalidates
41
+ affected evidence.
42
+
43
+ Call `change.converge` with only the change id. Do not submit verdicts or evidence
44
+ summaries: MCP derives development, test report, public seam, specification,
45
+ documentation, both review axes, and incident diagnosis evidence from DB-backed
46
+ workflows and current artifacts. Resolve named blockers and rerun invalidated gates. Record
47
+ `converge-authority` only when the change is ready.
48
+
49
+ Call `change.archive` with the summary, `reconciliation_path`, and baseline updates or
50
+ exact no-change reason.
51
+ Ordinary archive refreshes baseline revision and digests atomically and rolls back on
52
+ incomplete reconciliation. Record `archive-change`. For break-glass delivery, verify
53
+ the returned bypass and blocking reconciliation gap.
54
+
55
+ ## Release only with authority
56
+
57
+ The `release-if-authorized` step is not permission. When publication is outside the
58
+ user's request, complete it with exactly one `release_authorization` decision containing
59
+ `authorized: false` and the reason. When explicitly authorized, record
60
+ `authorized: true`, `approved_by`, the exact release `scope`, and the reason; then
61
+ determine compatibility impact, update version and
62
+ changelog, rerun invalidated checks, create a non-force commit/tag, push, publish, and
63
+ verify remote commit, tag, release, and registry version independently.
64
+
65
+ Write `.ultra/reports/delivery/<workflow-id>.json` atomically using
66
+ `ultra-delivery-report-v1`, with change/archive state, baseline id/status, full HEAD,
67
+ worktree digest, convergence-context digest, exact passing
68
+ checks, the explicit release authorization/performed decision, release identifiers
69
+ when applicable, structured evidence for every performed commit/push/tag/registry/
70
+ deployment action, rollback notes, and timestamp. The report authorization must match
71
+ the DB-recorded decision. Record `verify-delivery` with that
72
+ output and call `workflow.complete` only after the change is archived and local and
73
+ remote evidence agree for every authorized action. MCP derives the delivery summary
74
+ from this report rather than a Prompt claim.
75
+
76
+ Return workflow id, archive and baseline state, evidence digests, commit/release facts,
77
+ recovery notes, residual risks, and one next route.
@@ -0,0 +1,20 @@
1
+ # Baseline reconciliation manifest
2
+
3
+ Write a JSON file inside `.ultra/changes/active/<change-id>/` with
4
+ `$schema: "ultra-baseline-reconciliation-v1"`.
5
+
6
+ Bind `change_id`, `baseline_id`, and `baseline_updates` exactly to the archive request.
7
+ Include:
8
+
9
+ - `semantic_changes`: stable id, `add` or `update`, project-relative `source_ref` using
10
+ `path#anchor`, the prior baseline digest or `null`, and the current file digest;
11
+ - `resolved_gap_ids`: existing baseline gaps closed by this delivery;
12
+ - `resolved_unknowns`: exact existing unknown summaries closed by this delivery;
13
+ - `verification`: named checks with exact commands, `pass`, and bounded evidence;
14
+ - `semantic_no_change_reason`: an evidence-backed reason when `baseline_updates` is
15
+ empty.
16
+
17
+ Every updated file needs a semantic change record and current anchor. The before digest
18
+ must match baseline authority and the after digest must match the file. Keep the
19
+ manifest with the change so archive recovery can replay the same transaction after an
20
+ interrupted filesystem move.
@@ -1,63 +1,58 @@
1
1
  ---
2
2
  name: ultra-dev
3
- description: Execute one authoritative Ultra task through a bounded fresh context, a red-green feedback loop, live-path verification, and review. Use when a dependency-ready planned slice is ready for implementation.
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.
4
4
  ---
5
5
 
6
- # Execute one vertical slice
7
-
8
- Drive one task from `pending` to `completed` without widening its contract silently.
9
-
10
- ## Authority and recovery
11
-
12
- Task state changes use `task.update`. Never write raw SQLite, generated task JSON, or
13
- projected status fields. If task MCP access fails, stop and route state health to
14
- `ultra-doctor`.
15
-
16
- Read `change.breadcrumb` when a change is active. Stale context, blocked readiness,
17
- unknown documentation impact, or a HEAD mismatch blocks implementation.
18
- Baseline-adoption and context-size warnings do not block an active slice. Address
19
- them when practical without dropping required evidence or arbitrarily changing a
20
- threshold. Ordinary convergence requires approved baseline availability; revision
21
- and tracked-spec health are reconciled and verified at archive. An approved
22
- break-glass incident may finish recovery first and must leave a blocking baseline
23
- reconciliation gap.
24
-
25
- ## Workflow
26
-
27
- 1. Select the requested task, otherwise the first dependency-ready pending task.
28
- 2. Call `task.get` and verify acceptance, dependencies, ownership, public seam, and
29
- exact verification command.
30
- 3. For a linked change, call `change.get`, then compile `change.context` for the
31
- implementation role and gate with the smallest required references.
32
- 4. Mark the task `in_progress` only after the context is ready.
33
- 5. Establish the feedback-loop baseline before changing production logic:
34
- - reproduce the smallest observable symptom at the declared seam;
35
- - add or identify the contract or regression test;
36
- - record the exact command, expected signal, and observed result.
37
-
38
- A feature starts with an assertion for missing behavior. A refactor starts from a
39
- green characterization baseline. Documentation or configuration work may use a
40
- structural validator when no logic test applies.
41
- 6. Implement the minimum complete path from entry point to public seam. Reuse existing
42
- utilities, keep IO at boundaries, include required errors and recovery, and preserve
43
- unrelated worktree changes.
44
- 7. If the work reveals a stable requirement or public behavior absent from the
45
- baseline, call `change.learning_propose`. Do not edit the baseline silently or keep
46
- the discovery only in transient conversation context.
47
- 8. Verify in this order:
48
- - the original feedback-loop command;
49
- - adjacent focused tests;
50
- - proportionate static checks and build;
51
- - the live public-seam acceptance path;
52
- - final diff and worktree scope.
53
- 9. Run `ultra-review` against the current diff. Fix blocking findings, rerun invalidated
54
- checks, and require independent specification-fidelity and engineering verdicts.
55
- 10. Call `task.update` with `status=completed` and exact evidence. For a linked change,
56
- recompile the verification context at the final HEAD, then call
57
- `change.breadcrumb`.
58
-
59
- ## Completion evidence
60
-
61
- Report the task and change ids, changed paths, baseline signal, passing commands,
62
- public-seam result, review session, specification-learning candidates, and one next
63
- action. Leave the task in progress or blocked when required evidence is missing.
6
+ # Implement one executable task
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.
11
+
12
+ ## Start or resume
13
+
14
+ 1. Read `system.doctor`, `change.breadcrumb`, `task.get`, workflow state, dependencies,
15
+ active sessions, Git HEAD, and worktree scope.
16
+ 2. Resume an existing `dev` workflow or call `workflow.start` with `change_id` and
17
+ `task_id`. Startup fails when the DB-backed task execution contract is incomplete or
18
+ owned by another change.
19
+ 3. Record `bind-task` with task, dependency, branch, and worktree evidence.
20
+ 4. Compile `change.context` for `implement`. It derives public seam, verification, and
21
+ required refs from the task row. Record its immutable manifest as the
22
+ `compile-context` output only when ready. That starting snapshot remains historical
23
+ task evidence; later task commits do not invalidate it when its commit stays on the
24
+ current ancestry and the task contract is unchanged.
25
+ 5. Run session admission before spawning an isolated session. Do not open a second
26
+ active lease without the documented resume, takeover, or abandon decision.
27
+
28
+ ## Red, green, verify
29
+
30
+ 1. Reproduce the behavior or establish a characterization signal before logic edits.
31
+ Record `establish-feedback-loop` with the exact failing command and observed result.
32
+ 2. Set the task `in_progress`; implement the smallest complete vertical slice through
33
+ the declared public seam. Preserve unrelated worktree changes.
34
+ 3. Keep application judgment and edits in the host. Do not write projections, raw DB,
35
+ workflow output digests, or evidence state by hand.
36
+ 4. Refactor only inside the accepted slice while the focused signal stays green.
37
+ 5. Record `implement-slice`, then run focused, adjacent, static/build, public-seam,
38
+ error, and recovery checks proportional to risk. Record exact evidence under
39
+ `verify-slice`.
40
+ 6. Run `ultra-review` at the current diff. Record both independent verdict axes under
41
+ `review-slice`; unresolved blocking findings return to implementation.
42
+
43
+ ## Complete or recover
44
+
45
+ Close the admitted session with `session.close` after its final heartbeat and verify
46
+ that no running lease remains for the task. Then update the task to `completed` only
47
+ after acceptance, verification, documentation, and review are current. Record
48
+ `record-completion` with commands, results, changed paths, commit when authorized, and
49
+ context/review references; then call `workflow.complete`. The MCP refuses dev
50
+ convergence while the task is incomplete or a session is still running.
51
+
52
+ On interruption or an external blocker, record the current step as `blocked`, update
53
+ the task consistently, and preserve the session and evidence. Resume the same run;
54
+ completed steps remain durable. Any code or contract change invalidates affected test,
55
+ review, or context evidence.
56
+
57
+ Return the task outcome, public seam, changed paths, exact checks, review results,
58
+ workflow id, session state, residual risks, and one next route.
@@ -1,86 +1,55 @@
1
1
  ---
2
2
  name: ultra-doctor
3
- description: Diagnose Ultra state, projection, session, incident, change-artifact, and installed-plugin health with bounded recovery. Use when Ultra state appears missing, projections disagree, hooks fail, or MCP operations report degraded health.
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.
4
4
  ---
5
5
 
6
- # Diagnose and recover the Ultra runtime
6
+ # Diagnose before repair
7
7
 
8
- Default to read-only diagnosis. Repair only after the user explicitly authorizes it.
8
+ Default to read-only diagnosis. Call `system.doctor` with repair disabled and inspect:
9
9
 
10
- ## Project-state diagnosis
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
+ - event/projection cursor lag and failed or interrupted projection jobs;
15
+ - sessions, incidents, circuit state, active-change artifacts, and archive journals;
16
+ - external provider ownership boundaries.
11
17
 
12
- Call `system.doctor` with `{ "repair": false }` and inspect:
18
+ An expected blocked workflow is a workflow warning, not DB corruption. A stale or
19
+ missing recorded output is an authority failure for that run. Doctor cannot invent
20
+ evidence, complete a step, accept a failure, approve a baseline, or change product
21
+ scope.
13
22
 
14
- - SQLite integrity and required tables;
15
- - open structured incidents;
16
- - event and projection cursor lag;
17
- - failed or interrupted projection jobs;
18
- - interrupted archive journals;
19
- - orphan sessions;
20
- - missing active-change artifact roots;
21
- - missing, incomplete, or stale project baseline readiness and specification digests;
22
- - the boundary to separately installed memory and code-graph providers.
23
+ ## Route failures
23
24
 
24
- Do not infer health from generated task JSON. Do not mutate external provider state,
25
- delete artifacts, or collect memory during diagnosis.
25
+ - Missing or migrated baseline evidence: `ultra-init` and the exact research step.
26
+ - Stale workflow output: restore or regenerate the artifact from accepted evidence,
27
+ then record the affected step again and re-run completion.
28
+ - Projection lag with healthy authority: eligible for mechanical regeneration.
29
+ - Orphan session: reconcile the recorded lease; do not kill unrelated processes.
30
+ - Missing change artifact: recover from version control, backup, or explicit owner
31
+ decision rather than silently recreating it.
32
+ - Corrupt SQLite: preserve DB/WAL/SHM and obtain a restore-or-rebaseline decision.
26
33
 
27
- ## Interpret failures
34
+ ## Explicit project repair
28
35
 
29
- - State integrity failure blocks ordinary workflows and requires preserving database
30
- evidence before recovery.
31
- - An open incident requires its code, source, retryability, and evidence.
32
- - Projection lag may be mechanically repairable when authority is healthy.
33
- - An orphan session may be reconciled; never kill unrelated processes blindly.
34
- - A missing change artifact requires version-control, backup, or deliberate recreation
35
- evidence rather than silent regeneration.
36
- - Missing or incomplete baseline evidence routes to `ultra-init`. Doctor repair does
37
- not approve a baseline, accept known-red verification, or invent adoption evidence.
38
- Baseline readiness is an advisory workflow check, not state-database corruption and
39
- not a reason for doctor repair.
40
- - A compatibility `migrated` baseline requires explicit brownfield re-adoption and
41
- cannot authorize ordinary changes.
42
- - A corrupt SQLite file requires preserving the file, locating a verified backup, and
43
- an explicit restore-or-rebaseline decision.
36
+ After authorization, call `system.doctor` with repair enabled. Repair is limited to
37
+ supported schema upgrades, backup-first archive recovery, orphan reconciliation,
38
+ staleness consumption, projection requeue, and projection regeneration. Verify the
39
+ pre-migration and repair backup paths and rerun the read-only report. A completed repair
40
+ action does not imply healthy workflow evidence.
44
41
 
45
- ## Explicit repair
42
+ When integrity prevents opening the DB, use only the documented restore or rebaseline
43
+ command with its explicit confirmation token. Both must quarantine or back up prior
44
+ authority and roll back on failure.
46
45
 
47
- After authorization, call `system.doctor` with `{ "repair": true }` or use the
48
- installed `ultra-tools system doctor --repair` fallback. The CLI applies supported
49
- schema upgrades to the packaged current schema and reports a pre-migration backup path. Doctor then
50
- creates a second timestamped backup before runtime recovery.
46
+ ## Installed host failures
51
47
 
52
- Repair is limited to documented schema upgrades, archive-journal completion,
53
- reconciling orphan sessions, consuming staleness events, requeueing interrupted or
54
- failed projections, and regenerating projections from authoritative state. If either
55
- backup fails, stop. Always inspect the post-repair report; a completed repair action
56
- does not imply healthy state.
48
+ For a missing hook adapter or stale plugin path, capture the manifest and missing
49
+ target, run `ubp --doctor` for the actual host, reinstall through the adapter rather
50
+ than patching cache contents, and verify provenance, hashes, entry points, MCP startup,
51
+ and a hook smoke test. Project doctor and installer doctor are separate authorities.
57
52
 
58
- If SQLite integrity prevents doctor from opening authority, preserve the original
59
- database, WAL, and SHM. After the owner chooses a recovery path, either run
60
- `ultra-tools system restore --backup <managed-backup> --confirm
61
- REPLACE_CORRUPT_ULTRA_STATE` or run `ultra-tools system rebaseline --project-name
62
- <name> [--scope <path>] --confirm REBASELINE_CORRUPT_ULTRA_STATE`. Both commands
63
- must report the recovery backup directory. A failed command must restore the
64
- original authority, sidecars, and task projection before returning an error.
65
-
66
- ## Installed-plugin failures
67
-
68
- When a hook points to a missing installed file:
69
-
70
- 1. Capture the hook manifest path and missing target.
71
- 2. Run the installer doctor for the actual host and install scope.
72
- 3. Preserve provenance, asset-hash, and host-contract findings.
73
- 4. Reinstall through the host adapter rather than patching a cache directory.
74
- 5. Rerun installer doctor, `system.doctor`, and a host hook smoke test.
75
-
76
- Project doctor covers `.ultra/state.db`; installer doctor covers packaged files and
77
- host wiring. Neither substitutes for the other.
78
-
79
- ## Output
80
-
81
- Lead with `healthy` or `degraded`. List failing authority checks separately from
82
- baseline warnings, incident identifiers, cursor lag, whether repair ran, the backup
83
- path, and each unresolved action with its owner.
84
-
85
- Do not fix application code, delete state, reset Git, close healthy sessions, or
86
- install and repair external providers through this workflow.
53
+ Return health first, failing authority checks, workflow warnings, backup/recovery
54
+ paths, whether repair ran, unresolved owners, and one exact next action. Do not edit
55
+ application code or external memory/graph providers through this Skill.