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
@@ -0,0 +1,337 @@
1
+ 'use strict';
2
+
3
+ const canonical = require('./canonical-json.cjs');
4
+ const artifactRegistry = require('./artifact-registry.cjs');
5
+ const ops = require('./state-ops.cjs');
6
+ const { writeManagedJson } = require('./managed-file-write.cjs');
7
+ const { readStableProjectFile } = require('./safe-project-file.cjs');
8
+
9
+ class DecisionRecordError extends Error {
10
+ constructor(code, message, details) {
11
+ super(message);
12
+ this.name = 'DecisionRecordError';
13
+ this.code = code;
14
+ if (details) this.details = details;
15
+ }
16
+ }
17
+
18
+ function requiredText(value, field) {
19
+ const normalized = typeof value === 'string' ? value.trim() : '';
20
+ if (!normalized) throw new DecisionRecordError('VALIDATION_ERROR', `${field} is required`);
21
+ return normalized;
22
+ }
23
+
24
+ function plainObject(value, field) {
25
+ if (value === undefined) return {};
26
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
27
+ throw new DecisionRecordError('VALIDATION_ERROR', `${field} must be an object`);
28
+ }
29
+ return JSON.parse(JSON.stringify(value));
30
+ }
31
+
32
+ function stringArray(value, field) {
33
+ if (value === undefined) return [];
34
+ if (!Array.isArray(value)) {
35
+ throw new DecisionRecordError('VALIDATION_ERROR', `${field} must be an array`);
36
+ }
37
+ return value.map((item, index) => requiredText(item, `${field}[${index}]`));
38
+ }
39
+
40
+ function normalizeScope(scope = {}) {
41
+ const baseline = typeof scope.baseline_id === 'string' ? scope.baseline_id.trim() : '';
42
+ const change = typeof scope.change_id === 'string' ? scope.change_id.trim() : '';
43
+ if (Boolean(baseline) === Boolean(change)) {
44
+ throw new DecisionRecordError(
45
+ 'VALIDATION_ERROR',
46
+ 'decision scope must contain exactly one of baseline_id or change_id',
47
+ );
48
+ }
49
+ return baseline
50
+ ? { type: 'baseline', id: baseline }
51
+ : { type: 'change', id: change };
52
+ }
53
+
54
+ function parseJson(value, fallback) {
55
+ try { return value == null ? fallback : JSON.parse(value); }
56
+ catch { return fallback; }
57
+ }
58
+
59
+ function rowToDecision(row) {
60
+ if (!row) return null;
61
+ return {
62
+ id: row.id,
63
+ scope: { [`${row.scope_type}_id`]: row.scope_id },
64
+ scope_type: row.scope_type,
65
+ scope_id: row.scope_id,
66
+ question: row.question,
67
+ recommendation: row.recommendation,
68
+ selection: row.selection,
69
+ effects: parseJson(row.effects_json, {}),
70
+ non_goals: parseJson(row.non_goals_json, []),
71
+ owner: row.owner,
72
+ source: row.source,
73
+ provenance: parseJson(row.provenance_json, {}),
74
+ applied_refs: parseJson(row.applied_refs_json, []),
75
+ status: row.status,
76
+ digest: row.digest,
77
+ artifact_path: row.artifact_path,
78
+ supersedes_id: row.supersedes_id,
79
+ created_at: row.created_at,
80
+ updated_at: row.updated_at,
81
+ };
82
+ }
83
+
84
+ function readDecision(db, id) {
85
+ return rowToDecision(db.prepare('SELECT * FROM decision_records WHERE id = ?').get(id));
86
+ }
87
+
88
+ function decisionValue(decision) {
89
+ return {
90
+ schema_version: '1.0',
91
+ id: decision.id,
92
+ scope: { type: decision.scope_type, id: decision.scope_id },
93
+ question: decision.question,
94
+ recommendation: decision.recommendation,
95
+ selection: decision.selection,
96
+ effects: decision.effects,
97
+ non_goals: decision.non_goals,
98
+ owner: decision.owner,
99
+ source: decision.source,
100
+ provenance: decision.provenance,
101
+ applied_refs: decision.applied_refs,
102
+ status: decision.status,
103
+ supersedes_id: decision.supersedes_id || null,
104
+ };
105
+ }
106
+
107
+ function readDecisionArtifact(db, id, { rootDir = process.cwd() } = {}) {
108
+ const decision = readDecision(db, id);
109
+ if (!decision) {
110
+ throw new DecisionRecordError('DECISION_NOT_FOUND', `decision not found: ${id}`);
111
+ }
112
+ const computed = canonical.digest(decisionValue(decision));
113
+ if (computed !== decision.digest) {
114
+ throw new DecisionRecordError(
115
+ 'DECISION_DIGEST_MISMATCH',
116
+ `Decision Record database authority is corrupt: ${id}`,
117
+ { expected: decision.digest, actual: computed },
118
+ );
119
+ }
120
+ const read = readStableProjectFile(rootDir, decision.artifact_path, { encoding: 'utf8' });
121
+ const artifact = db.prepare(
122
+ `SELECT digest FROM artifacts
123
+ WHERE path = ? AND status <> 'archived'
124
+ ORDER BY updated_at DESC, rowid DESC LIMIT 1`,
125
+ ).get(decision.artifact_path) || db.prepare(
126
+ `SELECT digest FROM artifacts
127
+ WHERE path = ? ORDER BY updated_at DESC, rowid DESC LIMIT 1`,
128
+ ).get(decision.artifact_path);
129
+ if (!artifact?.digest || artifact.digest !== read.digest) {
130
+ throw new DecisionRecordError(
131
+ 'DECISION_FILE_DRIFT',
132
+ `Decision Record bytes no longer match the Artifact Registry: ${id}`,
133
+ {
134
+ path: decision.artifact_path,
135
+ expected: artifact?.digest || null,
136
+ actual: read.digest,
137
+ },
138
+ );
139
+ }
140
+ let document;
141
+ try { document = JSON.parse(read.text); }
142
+ catch (cause) {
143
+ throw new DecisionRecordError(
144
+ 'DECISION_ARTIFACT_INVALID',
145
+ `Decision Record is not valid JSON: ${decision.artifact_path}`,
146
+ { cause: cause.message },
147
+ );
148
+ }
149
+ const { digest: documentDigest, ...documentValue } = document;
150
+ if (documentDigest !== decision.digest
151
+ || canonical.digest(documentValue) !== decision.digest) {
152
+ throw new DecisionRecordError(
153
+ 'DECISION_DIGEST_MISMATCH',
154
+ `Decision Record file does not match its accepted authority: ${id}`,
155
+ );
156
+ }
157
+ return { ...decision, file_digest: read.digest };
158
+ }
159
+
160
+ function listAcceptedDecisions(
161
+ db,
162
+ scope = {},
163
+ { limit = 100, rootDir = null, validateFiles = false } = {},
164
+ ) {
165
+ const normalized = normalizeScope(scope);
166
+ const rows = db.prepare(
167
+ `SELECT * FROM decision_records
168
+ WHERE scope_type = ? AND scope_id = ? AND status = 'accepted'
169
+ ORDER BY updated_at DESC, id ASC LIMIT ?`,
170
+ ).all(
171
+ normalized.type,
172
+ normalized.id,
173
+ Math.min(Math.max(Number(limit) || 100, 1), 500),
174
+ ).map(rowToDecision);
175
+ return validateFiles
176
+ ? rows.map((row) => readDecisionArtifact(db, row.id, { rootDir }))
177
+ : rows;
178
+ }
179
+
180
+ function normalizeAppliedRefs(value) {
181
+ if (value === undefined) return [];
182
+ if (!Array.isArray(value)) {
183
+ throw new DecisionRecordError('VALIDATION_ERROR', 'applied_refs must be an array');
184
+ }
185
+ return value.map((item, index) => {
186
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
187
+ throw new DecisionRecordError('VALIDATION_ERROR', `applied_refs[${index}] must be an object`);
188
+ }
189
+ return {
190
+ ref: requiredText(item.ref, `applied_refs[${index}].ref`),
191
+ ...(item.field ? { field: requiredText(item.field, `applied_refs[${index}].field`) } : {}),
192
+ ...(item.digest ? { digest: requiredText(item.digest, `applied_refs[${index}].digest`) } : {}),
193
+ };
194
+ });
195
+ }
196
+
197
+ function artifactPath(scope, id) {
198
+ return scope.type === 'baseline'
199
+ ? `.ultra/decisions/baseline/${id}.json`
200
+ : `.ultra/changes/active/${scope.id}/decisions/${id}.json`;
201
+ }
202
+
203
+ function acceptDecision(db, input = {}, { rootDir = process.cwd() } = {}) {
204
+ const scope = normalizeScope(input.scope);
205
+ const value = {
206
+ schema_version: '1.0',
207
+ id: requiredText(input.id, 'id'),
208
+ scope: { type: scope.type, id: scope.id },
209
+ question: requiredText(input.question, 'question'),
210
+ recommendation: requiredText(input.recommendation, 'recommendation'),
211
+ selection: requiredText(input.selection, 'selection'),
212
+ effects: plainObject(input.effects, 'effects'),
213
+ non_goals: stringArray(input.non_goals, 'non_goals'),
214
+ owner: requiredText(input.owner, 'owner'),
215
+ source: requiredText(input.source, 'source'),
216
+ provenance: plainObject(input.provenance, 'provenance'),
217
+ applied_refs: normalizeAppliedRefs(input.applied_refs),
218
+ status: 'accepted',
219
+ supersedes_id: input.supersedes_id
220
+ ? requiredText(input.supersedes_id, 'supersedes_id')
221
+ : null,
222
+ };
223
+ const digest = canonical.digest(value);
224
+ const document = { ...value, digest };
225
+ const relative = artifactPath(scope, value.id);
226
+ const existing = readDecision(db, value.id);
227
+ if (existing) {
228
+ if (existing.digest !== digest) {
229
+ throw new DecisionRecordError(
230
+ 'DECISION_ID_CONFLICT',
231
+ `decision ${value.id} already exists with different content`,
232
+ );
233
+ }
234
+ return existing;
235
+ }
236
+ if (value.supersedes_id) {
237
+ const prior = readDecision(db, value.supersedes_id);
238
+ if (!prior) {
239
+ throw new DecisionRecordError(
240
+ 'DECISION_NOT_FOUND',
241
+ `superseded decision not found: ${value.supersedes_id}`,
242
+ );
243
+ }
244
+ if (prior.scope_type !== scope.type || prior.scope_id !== scope.id) {
245
+ throw new DecisionRecordError(
246
+ 'DECISION_SCOPE_CONFLICT',
247
+ 'a decision can only supersede another decision in the same scope',
248
+ );
249
+ }
250
+ }
251
+ const published = writeManagedJson(rootDir, relative, document);
252
+ return ops.tx(db, () => {
253
+ if (value.supersedes_id) {
254
+ db.prepare(
255
+ `UPDATE decision_records SET status = 'superseded',
256
+ updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
257
+ WHERE id = ? AND status = 'accepted'`,
258
+ ).run(value.supersedes_id);
259
+ }
260
+ db.prepare(
261
+ `INSERT INTO decision_records
262
+ (id, scope_type, scope_id, question, recommendation, selection,
263
+ effects_json, non_goals_json, owner, source, provenance_json,
264
+ applied_refs_json, status, digest, artifact_path, supersedes_id)
265
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'accepted', ?, ?, ?)`,
266
+ ).run(
267
+ value.id,
268
+ scope.type,
269
+ scope.id,
270
+ value.question,
271
+ value.recommendation,
272
+ value.selection,
273
+ JSON.stringify(value.effects),
274
+ JSON.stringify(value.non_goals),
275
+ value.owner,
276
+ value.source,
277
+ JSON.stringify(value.provenance),
278
+ JSON.stringify(value.applied_refs),
279
+ digest,
280
+ relative,
281
+ value.supersedes_id,
282
+ );
283
+ artifactRegistry.recordArtifactInTx(db, {
284
+ id: `artifact-decision-${value.id}`,
285
+ owner_type: scope.type,
286
+ owner_id: scope.id,
287
+ change_id: scope.type === 'change' ? scope.id : null,
288
+ kind: 'decision_record',
289
+ path: relative,
290
+ content_digest: published.digest,
291
+ source_refs: [{
292
+ type: scope.type,
293
+ id: scope.id,
294
+ relation: 'decided_for',
295
+ }],
296
+ consumer_refs: [{
297
+ type: 'external',
298
+ id: 'ultra-context-consumer',
299
+ relation: 'consumed_by',
300
+ }],
301
+ provenance: {
302
+ writer: 'decision-records',
303
+ decision_digest: digest,
304
+ owner: value.owner,
305
+ source: value.source,
306
+ },
307
+ metadata: {
308
+ decision_id: value.id,
309
+ status: value.status,
310
+ supersedes_id: value.supersedes_id,
311
+ },
312
+ }, { rootDir });
313
+ ops.appendEventInTx(db, {
314
+ type: 'decision_recorded',
315
+ change_id: scope.type === 'change' ? scope.id : null,
316
+ payload: {
317
+ decision_id: value.id,
318
+ scope_type: scope.type,
319
+ scope_id: scope.id,
320
+ digest,
321
+ artifact_path: relative,
322
+ supersedes_id: value.supersedes_id,
323
+ },
324
+ });
325
+ return readDecision(db, value.id);
326
+ });
327
+ }
328
+
329
+ module.exports = {
330
+ DecisionRecordError,
331
+ normalizeScope,
332
+ readDecision,
333
+ readDecisionArtifact,
334
+ decisionValue,
335
+ listAcceptedDecisions,
336
+ acceptDecision,
337
+ };
@@ -13,8 +13,7 @@ const recovery = require('../../orchestrator/recovery.cjs');
13
13
  const baselines = require('./baseline-workflow.cjs');
14
14
  const changes = require('./change-workflow.cjs');
15
15
  const archiveJournal = require('./archive-journal.cjs');
16
- const workflows = require('./workflow-state.cjs');
17
- const decisions = require('./decision-dialogue.cjs');
16
+ const stageCheckpoints = require('./stage-checkpoints.cjs');
18
17
  const runtimePaths = require('./runtime-paths.cjs');
19
18
  const artifactRegistry = require('./artifact-registry.cjs');
20
19
  const planStore = require('./plan-store.cjs');
@@ -107,6 +106,76 @@ function inspectTeamTaskLedger(db, rootDir) {
107
106
  }
108
107
  }
109
108
 
109
+ function inspectStageCheckpoints(db) {
110
+ const rows = db.prepare(
111
+ `SELECT id, stage, scope_type, scope_id, revision, status, payload_json,
112
+ evidence_json, diagnostics_json, context_envelope_id, digest,
113
+ supersedes_id
114
+ FROM stage_checkpoints ORDER BY stage, scope_type, scope_id, revision`,
115
+ ).all();
116
+ const counts = { draft: 0, accepted: 0, superseded: 0 };
117
+ const issues = [];
118
+ for (const row of rows) {
119
+ counts[row.status] = Number(counts[row.status] || 0) + 1;
120
+ let payload;
121
+ let evidence;
122
+ let diagnostics;
123
+ try {
124
+ payload = JSON.parse(row.payload_json);
125
+ evidence = JSON.parse(row.evidence_json);
126
+ diagnostics = JSON.parse(row.diagnostics_json);
127
+ } catch {
128
+ issues.push({ code: 'CHECKPOINT_JSON_INVALID', checkpoint_id: row.id });
129
+ continue;
130
+ }
131
+ const expected = stageCheckpoints.checkpointDigest({
132
+ stage: row.stage,
133
+ scope_type: row.scope_type,
134
+ scope_id: row.scope_id,
135
+ revision: row.revision,
136
+ payload,
137
+ evidence,
138
+ diagnostics,
139
+ context_envelope_id: row.context_envelope_id,
140
+ supersedes_id: row.supersedes_id,
141
+ });
142
+ if (expected !== row.digest) {
143
+ issues.push({ code: 'CHECKPOINT_DIGEST_MISMATCH', checkpoint_id: row.id });
144
+ }
145
+ }
146
+ return {
147
+ status: issues.length === 0 ? 'pass' : 'fail',
148
+ total: rows.length,
149
+ ...counts,
150
+ issues,
151
+ };
152
+ }
153
+
154
+ function inspectDecisionRecords(db) {
155
+ const rows = db.prepare(
156
+ `SELECT id, status, digest, artifact_path
157
+ FROM decision_records ORDER BY created_at, id`,
158
+ ).all();
159
+ return {
160
+ status: 'pass',
161
+ total: rows.length,
162
+ accepted: rows.filter((row) => row.status === 'accepted').length,
163
+ superseded: rows.filter((row) => row.status === 'superseded').length,
164
+ };
165
+ }
166
+
167
+ function inspectLegacyHistory(db) {
168
+ const count = (table) => db.prepare(`SELECT COUNT(*) AS count FROM ${table}`).get().count;
169
+ return {
170
+ status: 'informational',
171
+ workflow_runs: count('workflow_runs'),
172
+ workflow_steps: count('workflow_steps'),
173
+ decision_threads: count('decision_threads'),
174
+ decision_items: count('decision_items'),
175
+ authority: false,
176
+ };
177
+ }
178
+
110
179
  function inspectSystem(db, { rootDir = process.cwd() } = {}) {
111
180
  const tables = new Set(tableNames(db));
112
181
  const missing = REQUIRED_TABLES.filter((name) => !tables.has(name));
@@ -141,18 +210,21 @@ function inspectSystem(db, { rootDir = process.cwd() } = {}) {
141
210
  const baseline = missing.length === 0
142
211
  ? baselines.inspectBaseline(db, { rootDir })
143
212
  : { status: 'fail', blockers: ['BASELINE_STATE_UNAVAILABLE'], warnings: [], baseline: null };
144
- const workflowHealth = missing.length === 0
145
- ? workflows.inspectWorkflowHealth(db, { rootDir })
146
- : {
147
- status: 'fail', active: 0, blocked: 0, ready: 0, stale_outputs: [],
148
- historical_stale_outputs: [], terminal_authority_runs: [], untracked_active_changes: [],
149
- };
213
+ const checkpointHealth = missing.length === 0
214
+ ? inspectStageCheckpoints(db)
215
+ : { status: 'fail', total: 0, issues: [{ code: 'STATE_DB_UNAVAILABLE' }] };
150
216
  const decisionHealth = missing.length === 0
151
- ? decisions.inspectDecisionHealth(db, { rootDir })
217
+ ? inspectDecisionRecords(db)
218
+ : { status: 'fail', total: 0, accepted: 0, superseded: 0 };
219
+ const legacyHistory = missing.length === 0
220
+ ? inspectLegacyHistory(db)
152
221
  : {
153
- status: 'fail', active: 0, completed: 0, awaiting_owner: 0, awaiting_blocking: 0,
154
- checkpoint_ready: 0,
155
- deferred_blocking: 0, stale_artifacts: [], current: null, current_thread_id: null,
222
+ status: 'informational',
223
+ workflow_runs: 0,
224
+ workflow_steps: 0,
225
+ decision_threads: 0,
226
+ decision_items: 0,
227
+ authority: false,
156
228
  };
157
229
  const artifactHealth = missing.length === 0
158
230
  ? artifactRegistry.inspectArtifactHealth(db, { rootDir })
@@ -170,7 +242,7 @@ function inspectSystem(db, { rootDir = process.cwd() } = {}) {
170
242
  || pending.length > 0 || running.length > 0 || failed.length > 0 || orphanSessions > 0 || activeMissing > 0
171
243
  || sessionCloses.status === 'fail'
172
244
  || archiveIntents.length > 0
173
- || eventCursor > projectedCursor || workflowHealth.status === 'fail'
245
+ || eventCursor > projectedCursor || checkpointHealth.status === 'fail'
174
246
  || decisionHealth.status === 'fail'
175
247
  || artifactHealth.status === 'fail'
176
248
  || planPublications.status === 'fail'
@@ -213,22 +285,9 @@ function inspectSystem(db, { rootDir = process.cwd() } = {}) {
213
285
  blockers: baseline.blockers,
214
286
  warnings: baseline.warnings,
215
287
  },
216
- workflows: {
217
- status: workflowHealth.status === 'fail'
218
- ? 'fail'
219
- : (workflowHealth.blocked > 0
220
- || workflowHealth.historical_stale_outputs.length > 0
221
- || workflowHealth.terminal_authority_runs.length > 0
222
- || workflowHealth.untracked_active_changes.length > 0 ? 'warning' : 'pass'),
223
- active: workflowHealth.active,
224
- blocked: workflowHealth.blocked,
225
- ready: workflowHealth.ready,
226
- stale_outputs: workflowHealth.stale_outputs,
227
- historical_stale_outputs: workflowHealth.historical_stale_outputs,
228
- terminal_authority_runs: workflowHealth.terminal_authority_runs,
229
- untracked_active_changes: workflowHealth.untracked_active_changes,
230
- },
288
+ checkpoints: checkpointHealth,
231
289
  decisions: decisionHealth,
290
+ legacy_history: legacyHistory,
232
291
  external_providers: {
233
292
  status: 'pass', ownership: 'external',
234
293
  note: 'Ultra stores provider metadata references only and never owns memory or code-graph content.',
@@ -469,7 +528,7 @@ async function runDoctor(db, {
469
528
  recovered,
470
529
  plan_publications: deferred,
471
530
  archives: deferred,
472
- workflows: deferred,
531
+ legacy_history: deferred,
473
532
  },
474
533
  };
475
534
  }
@@ -496,7 +555,7 @@ async function runDoctor(db, {
496
555
  recovered,
497
556
  plan_publications: planGate,
498
557
  archives: deferred,
499
- workflows: deferred,
558
+ legacy_history: deferred,
500
559
  spec_events: deferred,
501
560
  interrupted: deferred,
502
561
  requeued: deferred,
@@ -529,7 +588,7 @@ async function runDoctor(db, {
529
588
  recovered,
530
589
  plan_publications: planPublications,
531
590
  archives: archiveGate,
532
- workflows: deferred,
591
+ legacy_history: deferred,
533
592
  spec_events: deferred,
534
593
  interrupted: deferred,
535
594
  requeued: deferred,
@@ -538,7 +597,6 @@ async function runDoctor(db, {
538
597
  },
539
598
  };
540
599
  }
541
- const workflowRecovery = workflows.recoverUntrackedChangeWorkflows(db, { rootDir });
542
600
  const cursor = runtime.readConsumerCursor(db, SPEC_CONSUMER);
543
601
  const consumed = ops.consumeSpecChangedEvents(db, { since_id: cursor, limit: 500 });
544
602
  runtime.writeConsumerCursor(db, SPEC_CONSUMER, consumed.next_since_id);
@@ -555,7 +613,7 @@ async function runDoctor(db, {
555
613
  repair: {
556
614
  close_intents: recovered,
557
615
  plan_publications: planPublications,
558
- archives, workflows: workflowRecovery, recovered, consumed,
616
+ archives, recovered, consumed,
559
617
  interrupted, requeued, ensured, projections,
560
618
  },
561
619
  };