ultra-builder-pro-cli 0.20.0 → 0.22.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 (109) hide show
  1. package/.ultra-template/docs/research/README.md +26 -5
  2. package/.ultra-template/specs/discovery.md +1 -1
  3. package/.ultra-template/tasks/tasks.json +10 -3
  4. package/.ultra-template/templates/task-context.md +19 -0
  5. package/CHANGELOG.md +106 -0
  6. package/README.md +215 -41
  7. package/adapters/_shared/codex-assets.cjs +69 -11
  8. package/adapters/_shared/interaction-contract.cjs +36 -3
  9. package/adapters/_shared/runtime-assets.cjs +41 -1
  10. package/adapters/claude.js +7 -5
  11. package/adapters/codex.js +1 -1
  12. package/adapters/kimi.js +2 -8
  13. package/adapters/opencode.js +43 -30
  14. package/bin/orchestrator.js +64 -24
  15. package/docs/AGENT-CONTEXT.md +89 -49
  16. package/docs/ARCHITECTURE.md +112 -45
  17. package/docs/ARTIFACT-AUTHORITY.md +274 -0
  18. package/docs/COMMIT-HASH-BACKFILL.md +33 -90
  19. package/docs/DECISIONS.md +14 -6
  20. package/docs/LEGACY-CLI-CROSSWALK.md +16 -6
  21. package/docs/PLUGIN-ISOLATION-CONTRACT.md +6 -4
  22. package/docs/ROADMAP.md +20 -6
  23. package/docs/RUNTIME-COMPAT-MATRIX.md +29 -16
  24. package/docs/STATE-DB-ACCESS-POLICY.md +43 -13
  25. package/docs/WORKFLOW-LIFECYCLE.md +105 -50
  26. package/hooks/README.md +10 -8
  27. package/hooks/active_task_context.py +105 -18
  28. package/hooks/context_spine.py +16 -4
  29. package/hooks/health_check.py +5 -4
  30. package/hooks/pre_stop_check.py +5 -2
  31. package/hooks/runtime_paths.py +396 -0
  32. package/hooks/subagent_tracker.py +5 -2
  33. package/hooks/workflow_checkpoint.py +16 -3
  34. package/hooks/workflow_context.py +11 -3
  35. package/hooks/workflow_resume.py +7 -4
  36. package/mcp-server/breadcrumb.cjs +20 -2
  37. package/mcp-server/lib/archive-journal.cjs +1026 -111
  38. package/mcp-server/lib/archive-mutation-worker.py +365 -0
  39. package/mcp-server/lib/artifact-registry.cjs +1127 -0
  40. package/mcp-server/lib/baseline-workflow.cjs +69 -28
  41. package/mcp-server/lib/change-packet.cjs +818 -0
  42. package/mcp-server/lib/change-workflow.cjs +932 -176
  43. package/mcp-server/lib/context-paths.cjs +142 -0
  44. package/mcp-server/lib/context-spine.cjs +511 -45
  45. package/mcp-server/lib/decision-dialogue.cjs +345 -3
  46. package/mcp-server/lib/delivery-transaction.cjs +471 -0
  47. package/mcp-server/lib/doctor-backup-worker.cjs +328 -0
  48. package/mcp-server/lib/doctor.cjs +401 -11
  49. package/mcp-server/lib/git-bootstrap.cjs +458 -47
  50. package/mcp-server/lib/init-project.cjs +240 -95
  51. package/mcp-server/lib/plan-publication-worker.cjs +830 -0
  52. package/mcp-server/lib/plan-store.cjs +700 -5
  53. package/mcp-server/lib/project-breadcrumb.cjs +23 -4
  54. package/mcp-server/lib/projector.cjs +211 -42
  55. package/mcp-server/lib/runtime-paths.cjs +1687 -0
  56. package/mcp-server/lib/safe-project-file.cjs +385 -0
  57. package/mcp-server/lib/spec-learning.cjs +28 -12
  58. package/mcp-server/lib/state-authority.cjs +19 -3
  59. package/mcp-server/lib/state-db.cjs +263 -9
  60. package/mcp-server/lib/state-ops.cjs +254 -50
  61. package/mcp-server/lib/task-ledger.cjs +1342 -0
  62. package/mcp-server/lib/telemetry.cjs +12 -3
  63. package/mcp-server/lib/workflow-state.cjs +610 -58
  64. package/mcp-server/server.cjs +423 -42
  65. package/orchestrator/daemon.cjs +2 -10
  66. package/orchestrator/parallel-orchestrator.cjs +314 -50
  67. package/orchestrator/planner/plan-builder.cjs +1 -1
  68. package/orchestrator/recovery.cjs +125 -7
  69. package/orchestrator/session-close-journal-worker.cjs +5 -0
  70. package/orchestrator/session-close-journal.cjs +1014 -0
  71. package/orchestrator/session-runner.cjs +679 -69
  72. package/orchestrator/worktree-manager.cjs +186 -35
  73. package/package.json +2 -3
  74. package/skills/cc-collab/SKILL.md +4 -1
  75. package/skills/codex-collab/SKILL.md +5 -2
  76. package/skills/ultra-change/SKILL.md +34 -8
  77. package/skills/ultra-deliver/SKILL.md +26 -11
  78. package/skills/ultra-dev/SKILL.md +52 -10
  79. package/skills/ultra-doctor/SKILL.md +16 -3
  80. package/skills/ultra-init/SKILL.md +22 -11
  81. package/skills/ultra-plan/SKILL.md +58 -18
  82. package/skills/ultra-research/SKILL.md +37 -35
  83. package/skills/ultra-review/SKILL.md +14 -8
  84. package/skills/ultra-status/SKILL.md +18 -9
  85. package/skills/ultra-test/SKILL.md +11 -5
  86. package/skills/ultra-think/SKILL.md +6 -2
  87. package/skills/ultra-think/references/decision-dialogue.md +17 -6
  88. package/skills/ultra-verify/SKILL.md +4 -1
  89. package/spec/cli-protocol.md +21 -7
  90. package/spec/mcp-tools.yaml +629 -44
  91. package/spec/schemas/change-delta.v1.schema.json +153 -0
  92. package/spec/schemas/context-file.v4.5.schema.json +1 -1
  93. package/spec/schemas/documentation-reconciliation.v1.schema.json +106 -0
  94. package/spec/schemas/mcp-tools.schema.json +1 -1
  95. package/spec/schemas/state-db.sql +51 -14
  96. package/spec/schemas/task-ledger.v1.schema.json +217 -0
  97. package/spec/schemas/tasks.v4.5.schema.json +1 -1
  98. package/ultra-tools/cli.cjs +3 -2
  99. package/ultra-tools/commands/db.cjs +76 -25
  100. package/ultra-tools/commands/migrate.cjs +1000 -82
  101. package/ultra-tools/commands/session.cjs +34 -8
  102. package/ultra-tools/commands/status.cjs +32 -6
  103. package/ultra-tools/commands/system.cjs +129 -22
  104. package/.ultra-template/tasks/contexts/TEMPLATE.md +0 -19
  105. package/commands/learn.md +0 -10
  106. package/orchestrator/skill-miner.cjs +0 -133
  107. package/output-styles/coding-vibes.md +0 -67
  108. package/output-styles/structural-thinking.md +0 -61
  109. package/skills/learn/SKILL.md +0 -58
@@ -27,6 +27,7 @@ families:
27
27
  - { name: change, description: 'continuous post-delivery change lifecycle and convergence', phase: '9' }
28
28
  - { name: decision, description: 'durable owner-agent alignment, one-question presentation, and approved checkpoints', phase: '16' }
29
29
  - { name: workflow, description: 'durable cross-stage run position, evidence, outputs, blockers, and recovery', phase: '13' }
30
+ - { name: artifact, description: 'typed semantic and evidence artifact ownership, digest, provenance, and dependency graph', phase: '20' }
30
31
  - { name: system, description: 'read-only diagnostics and explicit backup-first repair', phase: '9' }
31
32
 
32
33
  tools:
@@ -80,6 +81,11 @@ tools:
80
81
  reason: { type: string, minLength: 1 }
81
82
  kind: { type: string, enum: [spec, source, test, docs, external], default: source }
82
83
  required: { type: boolean, default: true }
84
+ expected_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
85
+ digest: { type: string, pattern: '^[0-9a-f]{64}$', description: 'legacy alias for expected_digest' }
86
+ anchor: { type: string, minLength: 1 }
87
+ scope: { type: string, minLength: 1 }
88
+ freshness_policy: { type: string, enum: [digest, existence, advisory] }
83
89
  docs_impact:
84
90
  type: object
85
91
  required: [status, files, rationale]
@@ -227,6 +233,106 @@ tools:
227
233
  emits_events: []
228
234
  trace_to: '§7.3'
229
235
 
236
+ - name: task.ledger_get
237
+ family: task
238
+ description: Read the Git-facing durable baseline, Change, and task checkpoint ledger and compare it with local SQLite authority.
239
+ phase: '21'
240
+ readonly: true
241
+ writer_role: any
242
+ input_schema:
243
+ type: object
244
+ additionalProperties: false
245
+ output_schema:
246
+ type: object
247
+ required: [ledger, health]
248
+ additionalProperties: false
249
+ properties:
250
+ ledger: { type: ['object', 'null'] }
251
+ health: { type: object }
252
+ errors:
253
+ - { code: TASK_LEDGER_INVALID, description: 'the Git ledger is malformed' }
254
+ - { code: TASK_LEDGER_DIGEST_MISMATCH, description: 'ledger content does not match its digest' }
255
+ - { code: TASK_LEDGER_UNSAFE, description: 'ledger path is a symlink or non-regular file' }
256
+ cli_subcommand: task ledger-get
257
+ emits_events: []
258
+ trace_to: 'docs/ARTIFACT-AUTHORITY.md#team-task-ledger'
259
+
260
+ - name: task.ledger_publish
261
+ family: task
262
+ description: Publish a low-frequency Git-facing baseline, Change, and task checkpoint from local SQLite authority.
263
+ phase: '21'
264
+ writer_role: mcp
265
+ input_schema:
266
+ type: object
267
+ additionalProperties: false
268
+ properties:
269
+ reason:
270
+ type: string
271
+ minLength: 1
272
+ default: manual_checkpoint
273
+ output_schema:
274
+ type: object
275
+ required: [changed, path, generation, state_digest]
276
+ additionalProperties: false
277
+ properties:
278
+ changed: { type: boolean }
279
+ path: { type: string }
280
+ generation: { type: integer, minimum: 0 }
281
+ state_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
282
+ migrated_legacy_projection: { type: boolean }
283
+ legacy_backup_path: { type: string }
284
+ errors:
285
+ - { code: TASK_LEDGER_INVALID, description: 'the prior Git ledger is malformed' }
286
+ - { code: TASK_LEDGER_DIGEST_MISMATCH, description: 'prior ledger content does not match its digest' }
287
+ - { code: TASK_LEDGER_UNSAFE, description: 'ledger path is a symlink or non-regular file' }
288
+ - { code: TASK_LEDGER_CHANGE_MISSING, description: 'a task has no portable owning Change' }
289
+ - { code: TASK_LEDGER_LEGACY_CONFLICT, description: 'the legacy task projection differs from SQLite authority and cannot be replaced automatically' }
290
+ - { code: TASK_LEDGER_REVALIDATION_REQUIRED, description: 'an imported ready baseline must converge in this checkout before publication' }
291
+ cli_subcommand: task ledger-publish
292
+ emits_events: [task_ledger_published]
293
+ trace_to: 'docs/ARTIFACT-AUTHORITY.md#team-task-ledger'
294
+
295
+ - name: task.ledger_import
296
+ family: task
297
+ description: Import a validated Git checkpoint into local SQLite authority with per-baseline, per-Change, and per-task conflict checks.
298
+ phase: '21'
299
+ writer_role: mcp
300
+ input_schema:
301
+ type: object
302
+ additionalProperties: false
303
+ output_schema:
304
+ type: object
305
+ required: [imported, preserved, deleted, imported_changes, preserved_changes, imported_baseline, preserved_baseline, generation, state_digest, requires_plan_revalidation, requires_baseline_revalidation, already_current]
306
+ additionalProperties: false
307
+ properties:
308
+ imported: { type: integer, minimum: 0 }
309
+ preserved: { type: integer, minimum: 0 }
310
+ deleted: { type: integer, minimum: 0 }
311
+ imported_changes: { type: integer, minimum: 0 }
312
+ preserved_changes: { type: integer, minimum: 0 }
313
+ imported_baseline: { type: boolean }
314
+ preserved_baseline: { type: boolean }
315
+ generation: { type: integer, minimum: 0 }
316
+ state_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
317
+ requires_plan_revalidation: { type: boolean }
318
+ requires_baseline_revalidation: { type: boolean }
319
+ already_current: { type: boolean }
320
+ errors:
321
+ - { code: TASK_LEDGER_INVALID, description: 'the Git ledger is malformed' }
322
+ - { code: TASK_LEDGER_DIGEST_MISMATCH, description: 'ledger content does not match its digest' }
323
+ - { code: TASK_LEDGER_UNSAFE, description: 'ledger path is a symlink or non-regular file' }
324
+ - { code: TASK_LEDGER_CONFLICT, description: 'the same task changed locally and in Git' }
325
+ - { code: TASK_LEDGER_ACTIVE_TASK_CONFLICT, description: 'Git changed a task with an active local session' }
326
+ - { code: TASK_LEDGER_STALE, description: 'the Git ledger is older than the last local checkpoint' }
327
+ - { code: TASK_LEDGER_HISTORY_CONFLICT, description: 'the Git ledger does not descend from the last local checkpoint' }
328
+ - { code: TASK_LEDGER_CHANGE_MISSING, description: 'a task references an unavailable Change' }
329
+ - { code: TASK_LEDGER_PARENT_MISSING, description: 'a task references an unavailable parent task' }
330
+ - { code: TASK_LEDGER_CHANGE_CONFLICT, description: 'the same Change changed locally and in Git' }
331
+ - { code: TASK_LEDGER_BASELINE_CONFLICT, description: 'the same baseline changed locally and in Git' }
332
+ cli_subcommand: task ledger-import
333
+ emits_events: [task_ledger_imported]
334
+ trace_to: 'docs/ARTIFACT-AUTHORITY.md#team-task-ledger'
335
+
230
336
  - name: task.switch_tag
231
337
  family: task
232
338
  description: Change a task's tag (branch-scoped context partition, Phase 7.2). Emits task_tag_changed.
@@ -383,6 +489,32 @@ tools:
383
489
  migration_backup_path:
384
490
  type: string
385
491
  description: pre-migration database backup created while resuming an older schema
492
+ runtime_migration_backup_path:
493
+ type: string
494
+ description: verified backup of a legacy runtime layout moved into `.ultra/.runtime/`
495
+ team_checkpoint:
496
+ type: object
497
+ additionalProperties: false
498
+ required: [generation, state_digest, imported_tasks, deleted_tasks, imported_changes, imported_baseline, requires_plan_revalidation, requires_baseline_revalidation, already_current]
499
+ properties:
500
+ generation: { type: integer, minimum: 0 }
501
+ state_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
502
+ imported_tasks: { type: integer, minimum: 0 }
503
+ deleted_tasks: { type: integer, minimum: 0 }
504
+ imported_changes: { type: integer, minimum: 0 }
505
+ imported_baseline: { type: boolean }
506
+ requires_plan_revalidation: { type: boolean }
507
+ requires_baseline_revalidation: { type: boolean }
508
+ already_current: { type: boolean }
509
+ published:
510
+ type: boolean
511
+ description: true when resume replaced a matching legacy task projection with a new team checkpoint
512
+ migrated_legacy_projection:
513
+ type: boolean
514
+ description: true when the prior tracked file used the supported legacy projection format
515
+ legacy_backup_path:
516
+ type: string
517
+ description: exact-byte backup of the replaced legacy task projection
386
518
  errors:
387
519
  - { code: ULTRA_DIR_EXISTS, description: '.ultra/ already exists and overwrite=false' }
388
520
  - { code: TEMPLATE_MISSING, description: 'source_template path does not exist' }
@@ -391,6 +523,7 @@ tools:
391
523
  - { code: LEGACY_STATE_MIGRATION_REQUIRED, description: 'projection-only tasks must be imported before resume' }
392
524
  - { code: STATE_AUTHORITY_CONFLICT, description: 'projection tasks and authoritative state cannot be reconciled automatically' }
393
525
  - { code: STATE_PROJECTION_INVALID, description: 'the existing task projection is malformed' }
526
+ - { code: TASK_LEDGER_LEGACY_CONFLICT, description: 'the legacy task projection differs from SQLite authority and cannot be upgraded automatically' }
394
527
  - { code: GIT_INIT_FAILED, description: 'the local Git repository or Ultra ignore rule could not be initialized' }
395
528
  - { code: GITIGNORE_UNSAFE, description: 'root .gitignore is a symlink or non-file and cannot be updated safely' }
396
529
  - { code: GITIGNORE_INEFFECTIVE, description: 'the effective Git rules still expose the `.ultra` authority' }
@@ -599,7 +732,7 @@ tools:
599
732
  takeover: { type: boolean, default: false, description: 'override active lease (D33 takeover strategy)' }
600
733
  worktree_base:
601
734
  type: string
602
- description: optional path resolving inside the repository `.ultra/worktrees` boundary; outside paths are rejected
735
+ description: optional path resolving inside the repository `.ultra/.runtime/worktrees` boundary; outside paths are rejected
603
736
  output_schema:
604
737
  type: object
605
738
  required: [sid, worktree_path, artifact_dir, lease_expires_at, worktree_created]
@@ -613,6 +746,7 @@ tools:
613
746
  errors:
614
747
  - { code: TASK_NOT_FOUND, description: 'task id missing' }
615
748
  - { code: ADMISSION_DENIED, description: 'active lease exists; choose takeover/resume/abandon' }
749
+ - { code: SESSION_CLOSE_PENDING, description: 'an unfinished durable close intent must recover before spawn or takeover' }
616
750
  - { code: NESTED_SESSION_FORBIDDEN, description: 'an active worker must resume its assigned session instead of recursively spawning another one' }
617
751
  - { code: TAKEOVER_FAILED, description: 'prior owned worker could not be terminated safely' }
618
752
  - { code: TASK_EXECUTION_CONTRACT_INCOMPLETE, description: 'change-owned task contract is incomplete' }
@@ -621,9 +755,12 @@ tools:
621
755
  - { code: WORKFLOW_PLAN_NOT_COMPLETED, description: 'owning change has no healthy completed plan workflow' }
622
756
  - { code: WORKFLOW_PLAN_TASK_SET_STALE, description: 'change task set differs from the current converged plan' }
623
757
  - { code: WORKFLOW_PLAN_TASK_CONTRACT_STALE, description: 'task contract differs from the current converged plan' }
758
+ - { code: WORKFLOW_PLAN_CONTEXT_STALE, description: 'the planning Context no longer matches the current checkout or required references' }
759
+ - { code: WORKFLOW_IMPLEMENTATION_CONTEXT_REQUIRED, description: 'the task has no exact ready implementation Context' }
760
+ - { code: WORKFLOW_IMPLEMENTATION_CONTEXT_STALE, description: 'the task implementation Context is stale, blocked, or bound to different authority' }
624
761
  - { code: WORKTREE_SCOPE_INVALID, description: 'requested worktree base escapes the managed project boundary' }
625
762
  - { code: WORKTREE_FAILED, description: 'Git worktree creation failed or the repository has no usable HEAD' }
626
- - { code: WORKTREE_AUTHORITY_MISSING, description: 'central `.ultra/state.db` disappeared before worktree binding' }
763
+ - { code: WORKTREE_AUTHORITY_MISSING, description: 'central `.ultra/.runtime/state.db` disappeared before worktree binding' }
627
764
  - { code: WORKTREE_AUTHORITY_NOT_IGNORED, description: 'a safe local ignore rule for the `.ultra` authority link could not be established' }
628
765
  - { code: WORKTREE_AUTHORITY_CONFLICT, description: 'the isolated checkout already contains a conflicting `.ultra` entry' }
629
766
  - { code: WORKTREE_AUTHORITY_LINK_FAILED, description: 'the isolated checkout could not be linked to central Ultra authority' }
@@ -642,7 +779,7 @@ tools:
642
779
  additionalProperties: false
643
780
  properties:
644
781
  sid: { type: string }
645
- status: { type: string, enum: [completed, crashed, orphan] }
782
+ status: { type: string, enum: [completed, crashed] }
646
783
  remove_worktree: { type: boolean, default: false }
647
784
  output_schema:
648
785
  type: object
@@ -657,7 +794,7 @@ tools:
657
794
  - { code: SESSION_SCOPE_VIOLATION, description: 'an active worker attempted to close a session it does not own' }
658
795
  - { code: WORKTREE_NOT_INTEGRATED, description: 'Explicit cleanup refused because work is uncommitted, unverified, or not integrated into the current checkout' }
659
796
  cli_subcommand: session close
660
- emits_events: [session_closed, session_crashed, session_orphaned]
797
+ emits_events: [session_closed, session_crashed]
661
798
  trace_to: '§7.3, D32'
662
799
 
663
800
  - name: session.get
@@ -734,7 +871,7 @@ tools:
734
871
  heartbeat_age_ms: { type: integer, minimum: 0 }
735
872
  recommended_action:
736
873
  type: string
737
- enum: [spawn, takeover, resume, abandon, blocked_by_breaker]
874
+ enum: [spawn, takeover, resume, abandon, recover_close, blocked_by_breaker]
738
875
  errors:
739
876
  - { code: TASK_NOT_FOUND, description: 'task id missing' }
740
877
  - { code: TASK_EXECUTION_CONTRACT_INCOMPLETE, description: 'change-owned task contract is incomplete' }
@@ -743,6 +880,9 @@ tools:
743
880
  - { code: WORKFLOW_PLAN_NOT_COMPLETED, description: 'owning change has no healthy completed plan workflow' }
744
881
  - { code: WORKFLOW_PLAN_TASK_SET_STALE, description: 'change task set differs from the current converged plan' }
745
882
  - { code: WORKFLOW_PLAN_TASK_CONTRACT_STALE, description: 'task contract differs from the current converged plan' }
883
+ - { code: WORKFLOW_PLAN_CONTEXT_STALE, description: 'the planning Context no longer matches the current checkout or required references' }
884
+ - { code: WORKFLOW_IMPLEMENTATION_CONTEXT_REQUIRED, description: 'the task has no exact ready implementation Context' }
885
+ - { code: WORKFLOW_IMPLEMENTATION_CONTEXT_STALE, description: 'the task implementation Context is stale, blocked, or bound to different authority' }
746
886
  cli_subcommand: session admission
747
887
  emits_events: []
748
888
  trace_to: '§7.3, D33'
@@ -1184,7 +1324,7 @@ tools:
1184
1324
 
1185
1325
  - name: change.update
1186
1326
  family: change
1187
- description: Update mutable change authority. Semantic changes invalidate every derived task and compiled context so they must be reconciled before execution.
1327
+ description: Update mutable change authority. Semantic changes invalidate only registered transitive consumers so affected tasks and contexts must be reconciled before execution.
1188
1328
  phase: '9'
1189
1329
  writer_role: mcp
1190
1330
  input_schema:
@@ -1251,6 +1391,197 @@ tools:
1251
1391
  cli_subcommand: change update
1252
1392
  emits_events: [task_stale_marked, change_updated]
1253
1393
 
1394
+ - name: change.delta
1395
+ family: change
1396
+ description: Record the typed Change-owned delta overlay against exact baseline anchors without mutating baseline specifications.
1397
+ phase: '21'
1398
+ writer_role: mcp
1399
+ input_schema:
1400
+ type: object
1401
+ required:
1402
+ [id, baseline_anchor, decisions, non_goals, acceptance, documentation_impact, unknowns, mutations]
1403
+ additionalProperties: false
1404
+ properties:
1405
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1406
+ baseline_anchor:
1407
+ type: object
1408
+ required: [baseline_id, repository_revision, specs]
1409
+ additionalProperties: false
1410
+ properties:
1411
+ baseline_id: { type: string, minLength: 1 }
1412
+ repository_revision: { type: ['string', 'null'] }
1413
+ specs:
1414
+ type: array
1415
+ items:
1416
+ type: object
1417
+ required: [path, digest]
1418
+ additionalProperties: false
1419
+ properties:
1420
+ path: { type: string, minLength: 1 }
1421
+ digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1422
+ decisions:
1423
+ type: array
1424
+ items:
1425
+ type: object
1426
+ required: [id, summary]
1427
+ additionalProperties: false
1428
+ properties:
1429
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1430
+ summary: { type: string, minLength: 1 }
1431
+ rationale: { type: string, minLength: 1 }
1432
+ non_goals: { type: array, uniqueItems: true, items: { type: string, minLength: 1 } }
1433
+ acceptance:
1434
+ type: array
1435
+ minItems: 1
1436
+ items:
1437
+ type: object
1438
+ required: [id, criterion, verification]
1439
+ additionalProperties: false
1440
+ properties:
1441
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1442
+ criterion: { type: string, minLength: 1 }
1443
+ verification: { type: string, minLength: 1 }
1444
+ documentation_impact:
1445
+ type: object
1446
+ required: [status, files, rationale]
1447
+ additionalProperties: false
1448
+ properties:
1449
+ status: { type: string, enum: [none, required] }
1450
+ files: { type: array, uniqueItems: true, items: { type: string, minLength: 1 } }
1451
+ rationale: { type: string, minLength: 3 }
1452
+ unknowns:
1453
+ type: array
1454
+ items:
1455
+ type: object
1456
+ required: [id, summary, blocking]
1457
+ additionalProperties: false
1458
+ properties:
1459
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1460
+ summary: { type: string, minLength: 1 }
1461
+ blocking: { type: boolean }
1462
+ no_semantic_change_reason: { type: string, minLength: 3 }
1463
+ mutations:
1464
+ type: array
1465
+ items:
1466
+ type: object
1467
+ required:
1468
+ [id, action, target_path, overlay_path, before_digest, after_digest, acceptance_refs, documentation_refs]
1469
+ additionalProperties: false
1470
+ properties:
1471
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1472
+ action: { type: string, enum: [add, update] }
1473
+ target_path: { type: string, minLength: 1 }
1474
+ overlay_path: { type: string, minLength: 1 }
1475
+ before_digest: { type: ['string', 'null'], pattern: '^[0-9a-f]{64}$' }
1476
+ after_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1477
+ acceptance_refs: { type: array, minItems: 1, uniqueItems: true, items: { type: string, minLength: 1 } }
1478
+ documentation_refs: { type: array, uniqueItems: true, items: { type: string, minLength: 1 } }
1479
+ allOf:
1480
+ - if:
1481
+ properties:
1482
+ mutations: { maxItems: 0 }
1483
+ then:
1484
+ required: [no_semantic_change_reason]
1485
+ output_schema:
1486
+ type: object
1487
+ required: [delta, artifact, payload_artifacts, progress_artifact]
1488
+ additionalProperties: false
1489
+ properties:
1490
+ delta: { type: object }
1491
+ artifact: { type: object }
1492
+ payload_artifacts: { type: array, items: { type: object } }
1493
+ progress_artifact: { type: object }
1494
+ errors:
1495
+ - { code: CHANGE_NOT_FOUND, description: 'change id does not exist' }
1496
+ - { code: CHANGE_NOT_MUTABLE, description: 'terminal Change authority cannot accept a delta' }
1497
+ - { code: CHANGE_DELTA_INVALID, description: 'delta shape or typed mutation contract is invalid' }
1498
+ - { code: CHANGE_DELTA_CONTRACT_MISMATCH, description: 'delta does not match accepted Change non-goals, acceptance, or documentation impact' }
1499
+ - { code: CHANGE_DELTA_BASELINE_CONFLICT, description: 'baseline id, revision, specification digest, or target bytes changed' }
1500
+ - { code: CHANGE_DELTA_PAYLOAD_MISSING, description: 'a declared Change overlay file is missing' }
1501
+ - { code: CHANGE_DELTA_PAYLOAD_STALE, description: 'a declared Change overlay digest is stale' }
1502
+ cli_subcommand: change delta
1503
+ emits_events: [artifact_recorded, spec_changed, change_delta_recorded]
1504
+
1505
+ - name: change.documentation_reconcile
1506
+ family: change
1507
+ description: Record Change-owned documentation before/after digests, delta and acceptance trace, verification, and explicit consumer or no-consumer evidence.
1508
+ phase: '21'
1509
+ writer_role: mcp
1510
+ input_schema:
1511
+ type: object
1512
+ required: [id, delta_artifact_id, delta_digest, documents]
1513
+ additionalProperties: false
1514
+ properties:
1515
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
1516
+ delta_artifact_id: { type: string, minLength: 1 }
1517
+ delta_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1518
+ no_change_reason: { type: string, minLength: 3 }
1519
+ documents:
1520
+ type: array
1521
+ items:
1522
+ type: object
1523
+ required:
1524
+ [path, action, overlay_path, before_digest, after_digest, delta_refs, acceptance_refs, verification, consumers]
1525
+ additionalProperties: false
1526
+ properties:
1527
+ path: { type: string, minLength: 1 }
1528
+ action: { type: string, enum: [add, update] }
1529
+ overlay_path: { type: string, minLength: 1 }
1530
+ before_digest: { type: ['string', 'null'], pattern: '^[0-9a-f]{64}$' }
1531
+ after_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1532
+ delta_refs: { type: array, minItems: 1, uniqueItems: true, items: { type: string } }
1533
+ acceptance_refs: { type: array, minItems: 1, uniqueItems: true, items: { type: string } }
1534
+ verification:
1535
+ type: array
1536
+ minItems: 1
1537
+ items:
1538
+ type: object
1539
+ required: [command, status, evidence_refs]
1540
+ additionalProperties: false
1541
+ properties:
1542
+ command: { type: string, minLength: 1 }
1543
+ status: { type: string, const: pass }
1544
+ evidence_refs:
1545
+ type: array
1546
+ minItems: 1
1547
+ uniqueItems: true
1548
+ items: { type: string, minLength: 1 }
1549
+ consumers:
1550
+ type: array
1551
+ items:
1552
+ type: object
1553
+ required: [type, id, relation]
1554
+ additionalProperties: false
1555
+ properties:
1556
+ type: { type: string, enum: [artifact, project, baseline, change, task, workflow, external] }
1557
+ id: { type: string, minLength: 1 }
1558
+ relation: { type: string, minLength: 1 }
1559
+ no_consumer_reason: { type: string, minLength: 3 }
1560
+ allOf:
1561
+ - if:
1562
+ properties:
1563
+ documents: { maxItems: 0 }
1564
+ then:
1565
+ required: [no_change_reason]
1566
+ output_schema:
1567
+ type: object
1568
+ required: [reconciliation, artifact, payload_artifacts, progress_artifact]
1569
+ additionalProperties: false
1570
+ properties:
1571
+ reconciliation: { type: object }
1572
+ artifact: { type: object }
1573
+ payload_artifacts: { type: array, items: { type: object } }
1574
+ progress_artifact: { type: object }
1575
+ errors:
1576
+ - { code: CHANGE_NOT_FOUND, description: 'change id does not exist' }
1577
+ - { code: DOCUMENTATION_DELTA_AUTHORITY_INVALID, description: 'documentation is not bound to the current Change delta' }
1578
+ - { code: DOCUMENTATION_RECONCILIATION_INCOMPLETE, description: 'declared documentation impact is not covered exactly' }
1579
+ - { code: DOCUMENTATION_ORPHAN_UNRESOLVED, description: 'a changed document lacks a consumer or explicit no-consumer reason' }
1580
+ - { code: DOCUMENTATION_BASELINE_CONFLICT, description: 'a documentation target changed after its before digest was recorded' }
1581
+ - { code: DOCUMENTATION_EVIDENCE_STALE, description: 'documentation overlay bytes do not match the recorded after digest' }
1582
+ cli_subcommand: change documentation-reconcile
1583
+ emits_events: [artifact_recorded, spec_changed, documentation_reconciliation_recorded]
1584
+
1254
1585
  - name: change.get
1255
1586
  family: change
1256
1587
  description: Read one continuous change unit and its specification-learning candidates from authoritative state.
@@ -1306,12 +1637,28 @@ tools:
1306
1637
  type: object
1307
1638
  required: [id]
1308
1639
  additionalProperties: false
1640
+ not:
1641
+ required: [context_refs, spec_refs]
1309
1642
  properties:
1310
1643
  id: { type: string }
1311
1644
  task_id: { type: string }
1312
1645
  role: { type: string, enum: [plan, implement, check, review] }
1313
1646
  gate: { type: string, enum: [alignment, planning, implementation, verification, review, convergence, recovery] }
1314
- spec_refs: { type: array, items: { type: object } }
1647
+ spec_refs:
1648
+ type: array
1649
+ maxItems: 64
1650
+ items:
1651
+ type: object
1652
+ required: [ref]
1653
+ additionalProperties: false
1654
+ properties:
1655
+ ref: { type: string, minLength: 1, maxLength: 2048 }
1656
+ reason: { type: string, minLength: 1, maxLength: 2048 }
1657
+ required: { type: boolean, default: true }
1658
+ expected_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1659
+ anchor: { type: string, minLength: 1, maxLength: 512 }
1660
+ scope: { type: string, minLength: 1, maxLength: 512 }
1661
+ freshness_policy: { type: string, enum: [digest, existence, advisory] }
1315
1662
  context_refs:
1316
1663
  type: array
1317
1664
  maxItems: 64
@@ -1320,11 +1667,15 @@ tools:
1320
1667
  required: [ref, reason]
1321
1668
  additionalProperties: false
1322
1669
  properties:
1323
- ref: { type: string, minLength: 1 }
1670
+ ref: { type: string, minLength: 1, maxLength: 2048 }
1324
1671
  kind: { type: string, enum: [spec, source, test, docs, external], default: source }
1325
- reason: { type: string, minLength: 3 }
1672
+ reason: { type: string, minLength: 3, maxLength: 2048 }
1326
1673
  required: { type: boolean, default: true }
1327
1674
  digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1675
+ expected_digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1676
+ anchor: { type: string, minLength: 1, maxLength: 512 }
1677
+ scope: { type: string, minLength: 1, maxLength: 512 }
1678
+ freshness_policy: { type: string, enum: [digest, existence, advisory] }
1328
1679
  budget:
1329
1680
  type: object
1330
1681
  additionalProperties: false
@@ -1336,21 +1687,6 @@ tools:
1336
1687
  additionalProperties: false
1337
1688
  properties:
1338
1689
  context_budget_percent: { type: integer, minimum: 1, maximum: 100, default: 40 }
1339
- provider_refs:
1340
- type: object
1341
- additionalProperties: false
1342
- properties:
1343
- memory:
1344
- type: object
1345
- required: [provider]
1346
- additionalProperties: false
1347
- properties:
1348
- provider: { type: string }
1349
- project: { type: string }
1350
- reference: { type: string }
1351
- revision: { type: string }
1352
- indexed_head: { type: string }
1353
- status: { type: string, enum: [available, unavailable, fresh, stale, unknown] }
1354
1690
  recommendation:
1355
1691
  type: object
1356
1692
  required: [workflow, rationale]
@@ -1358,17 +1694,6 @@ tools:
1358
1694
  properties:
1359
1695
  workflow: { type: string, minLength: 1 }
1360
1696
  rationale: { type: string, minLength: 3 }
1361
- code_graph:
1362
- type: object
1363
- required: [provider]
1364
- additionalProperties: false
1365
- properties:
1366
- provider: { type: string }
1367
- project: { type: string }
1368
- reference: { type: string }
1369
- revision: { type: string }
1370
- indexed_head: { type: string }
1371
- status: { type: string, enum: [available, unavailable, fresh, stale, unknown] }
1372
1697
  output_schema:
1373
1698
  type: object
1374
1699
  required: [manifest_path, manifest_hash, manifest]
@@ -1385,7 +1710,7 @@ tools:
1385
1710
  - { code: EXECUTION_CONTRACT_CONFLICT, description: 'Prompt input attempted to override the DB-backed task seam or verification command' }
1386
1711
  - { code: EXECUTION_CONTEXT_REFS_CONFLICT, description: 'Prompt input attempted to override DB-backed task context references' }
1387
1712
  - { code: CONTEXT_LEGACY_NEXT_ACTION_UNSUPPORTED, description: 'a canonical next action is not an MCP authority field; use a non-authoritative host recommendation' }
1388
- - { code: PROVIDER_CONTENT_FORBIDDEN, description: 'provider payload content must remain external' }
1713
+ - { code: CONTEXT_PROVIDER_REFS_MUTATION_UNSUPPORTED, description: 'provider references must be updated through change.update before context compilation' }
1389
1714
  cli_subcommand: change context
1390
1715
  emits_events: [context_updated]
1391
1716
 
@@ -1800,6 +2125,36 @@ tools:
1800
2125
  properties:
1801
2126
  id: { type: string, minLength: 1 }
1802
2127
  summary: { type: string, minLength: 1 }
2128
+ applied_refs:
2129
+ type: array
2130
+ maxItems: 20
2131
+ items:
2132
+ type: object
2133
+ required: [kind, ref]
2134
+ additionalProperties: false
2135
+ allOf:
2136
+ - if:
2137
+ properties:
2138
+ kind: { enum: [baseline, change, workflow, task] }
2139
+ required: [kind]
2140
+ then:
2141
+ required: [field, value]
2142
+ - if:
2143
+ properties:
2144
+ kind: { enum: [spec, artifact] }
2145
+ required: [kind]
2146
+ then:
2147
+ required: [digest]
2148
+ not:
2149
+ anyOf:
2150
+ - { required: [field] }
2151
+ - { required: [value] }
2152
+ properties:
2153
+ kind: { type: string, enum: [baseline, change, workflow, task, spec, artifact] }
2154
+ ref: { type: string, minLength: 1 }
2155
+ field: { type: string, minLength: 1 }
2156
+ value: {}
2157
+ digest: { type: string, pattern: '^[0-9a-f]{64}$' }
1803
2158
  output_schema:
1804
2159
  type: object
1805
2160
  required: [thread]
@@ -1811,7 +2166,11 @@ tools:
1811
2166
  - { code: DECISION_THREAD_NOT_MUTABLE, description: 'the decision thread is already terminal' }
1812
2167
  - { code: DECISION_CHECKPOINT_PENDING, description: 'a prepared artifact checkpoint must be confirmed or revised first' }
1813
2168
  - { code: DECISION_ALIGNMENT_BLOCKING, description: 'an unanswered question or blocking deferral prevents completion' }
1814
- - { code: VALIDATION_ERROR, description: 'the completion summary is missing' }
2169
+ - { code: DECISION_APPLIED_REF_NOT_FOUND, description: 'an applied authority reference cannot be read back from the current project state' }
2170
+ - { code: DECISION_APPLIED_REF_FIELD_NOT_FOUND, description: 'a row-backed applied authority field does not exist' }
2171
+ - { code: DECISION_APPLIED_REF_VALUE_MISMATCH, description: 'a row-backed applied authority value does not match current state' }
2172
+ - { code: DECISION_APPLIED_REF_STALE, description: 'an applied field, specification, or artifact digest does not match current content' }
2173
+ - { code: VALIDATION_ERROR, description: 'the completion summary or applied authority references are invalid' }
1815
2174
  cli_subcommand: decision complete
1816
2175
  emits_events: [decision_thread_completed]
1817
2176
 
@@ -1902,6 +2261,7 @@ tools:
1902
2261
  - { code: DUPLICATE_WORKFLOW_ID, description: 'workflow id already exists' }
1903
2262
  - { code: WORKFLOW_IN_PROGRESS, description: 'the same authority already has an active workflow of this kind' }
1904
2263
  - { code: WORKFLOW_CHANGE_NOT_FOUND, description: 'the requested change authority does not exist' }
2264
+ - { code: WORKFLOW_SCOPE_INVALID, description: 'the workflow kind received a task or change scope that it does not own' }
1905
2265
  - { code: WORKFLOW_CHANGE_RUN_REQUIRED, description: 'change-bound stages require the owning durable change workflow; legacy gaps route through doctor repair' }
1906
2266
  - { code: WORKFLOW_BASELINE_MISMATCH, description: 'a supplied stage baseline differs from the baseline bound by the owning change workflow' }
1907
2267
  - { code: WORKFLOW_BASELINE_NOT_READY, description: 'the baseline bound to the change is no longer ready' }
@@ -2047,6 +2407,7 @@ tools:
2047
2407
  - { code: WORKFLOW_EVIDENCE_REQUIRED, description: 'the step cannot complete without evidence' }
2048
2408
  - { code: WORKFLOW_OUTPUT_REQUIRED, description: 'the step cannot complete without a durable output' }
2049
2409
  - { code: WORKFLOW_OUTPUT_MISSING, description: 'a declared output file is missing' }
2410
+ - { code: WORKFLOW_ARTIFACT_SCOPE_INVALID, description: 'a Change-bound semantic or evidence artifact escaped its owning Change root' }
2050
2411
  - { code: WORKFLOW_RESEARCH_REPORT_REQUIRED, description: 'a research step requires its immutable workflow-and-step-bound report path' }
2051
2412
  - { code: WORKFLOW_RESEARCH_REPORT_INVALID, description: 'the research report is missing its required evidence structure' }
2052
2413
  - { code: WORKFLOW_RESEARCH_SYNTHESIS_INCOMPLETE, description: 'full or adoption synthesis did not bind all baseline specifications and the distillate' }
@@ -2070,6 +2431,65 @@ tools:
2070
2431
  cli_subcommand: workflow step
2071
2432
  emits_events: [workflow_step_updated, workflow_blocked]
2072
2433
 
2434
+ - name: workflow.revise
2435
+ family: workflow
2436
+ description: Create a candidate revision of a completed workflow while preserving the accepted run and its provenance.
2437
+ phase: '21'
2438
+ writer_role: mcp
2439
+ input_schema:
2440
+ type: object
2441
+ required: [id, replacement_id, subject, reason]
2442
+ additionalProperties: false
2443
+ properties:
2444
+ id: { type: string, minLength: 1 }
2445
+ replacement_id: { type: string, minLength: 1 }
2446
+ subject: { type: string, minLength: 1 }
2447
+ reason: { type: string, minLength: 3 }
2448
+ output_schema:
2449
+ type: object
2450
+ required: [workflow]
2451
+ additionalProperties: false
2452
+ properties:
2453
+ workflow: { type: object }
2454
+ errors:
2455
+ - { code: WORKFLOW_NOT_FOUND, description: 'prior workflow id does not exist' }
2456
+ - { code: WORKFLOW_REVISION_SOURCE_NOT_ACCEPTED, description: 'only a completed workflow can be revised' }
2457
+ - { code: WORKFLOW_ALREADY_SUPERSEDED, description: 'the prior workflow already has a replacement authority' }
2458
+ - { code: WORKFLOW_IN_PROGRESS, description: 'a competing active workflow owns the same scope' }
2459
+ cli_subcommand: workflow revise
2460
+ emits_events: [workflow_started, workflow_revision_started]
2461
+
2462
+ - name: workflow.supersede
2463
+ family: workflow
2464
+ description: Promote a completed candidate revision to current authority and invalidate only its transitive registry consumers.
2465
+ phase: '21'
2466
+ writer_role: mcp
2467
+ input_schema:
2468
+ type: object
2469
+ required: [id, replacement_id, reason]
2470
+ additionalProperties: false
2471
+ properties:
2472
+ id: { type: string, minLength: 1 }
2473
+ replacement_id: { type: string, minLength: 1 }
2474
+ reason: { type: string, minLength: 3 }
2475
+ output_schema:
2476
+ type: object
2477
+ required: [superseded, workflow, invalidated, idempotent]
2478
+ additionalProperties: false
2479
+ properties:
2480
+ superseded: { type: object }
2481
+ workflow: { type: object }
2482
+ invalidated: { type: array, items: { type: object } }
2483
+ idempotent: { type: boolean }
2484
+ errors:
2485
+ - { code: WORKFLOW_NOT_FOUND, description: 'prior or replacement workflow id does not exist' }
2486
+ - { code: WORKFLOW_SUPERSESSION_NOT_ACCEPTED, description: 'both workflow revisions must be completed' }
2487
+ - { code: WORKFLOW_SUPERSESSION_AUTHORITY_MISMATCH, description: 'replacement binding or revision provenance differs' }
2488
+ - { code: WORKFLOW_OUTPUT_STALE, description: 'replacement output authority is stale' }
2489
+ - { code: WORKFLOW_ALREADY_SUPERSEDED, description: 'another replacement already owns authority' }
2490
+ cli_subcommand: workflow supersede
2491
+ emits_events: [workflow_superseded, workflow_invalidated, task_stale_marked]
2492
+
2073
2493
  - name: workflow.complete
2074
2494
  family: workflow
2075
2495
  description: Complete a ready workflow only when every selected step is complete and every recorded output digest remains current. Plan approval is optional unless the host identified a material owner decision.
@@ -2135,6 +2555,7 @@ tools:
2135
2555
  - { code: WORKFLOW_TEST_NOT_PASSED, description: 'the current change-level test gate did not pass' }
2136
2556
  - { code: WORKFLOW_SESSION_ACTIVE, description: 'delivery cannot converge while an execution session remains active' }
2137
2557
  - { code: WORKFLOW_CONTEXT_NOT_READY, description: 'delivery evidence lacks a current ready context manifest' }
2558
+ - { code: WORKFLOW_CONTEXT_STALE, description: 'a required Context reference or bound task/change authority changed after compilation; optional drift remains a summary warning' }
2138
2559
  - { code: WORKFLOW_DELIVERY_CHECK_FAILED, description: 'one or more local delivery checks did not pass' }
2139
2560
  - { code: WORKFLOW_CHANGE_NOT_ARCHIVED, description: 'delivery completion requires an archived change' }
2140
2561
  - { code: WORKFLOW_RELEASE_AUTHORITY_MISMATCH, description: 'a local delivery report attempted to claim external release authority' }
@@ -2142,6 +2563,162 @@ tools:
2142
2563
  cli_subcommand: workflow complete
2143
2564
  emits_events: [workflow_completed, plan_approved]
2144
2565
 
2566
+ # ───────────────────────── artifact family ─────────────────────────────
2567
+ - name: artifact.record
2568
+ family: artifact
2569
+ description: Register the current bytes of one semantic or evidence file, replace its dependency edges transactionally, and invalidate exact downstream consumers when its digest changes.
2570
+ phase: '20'
2571
+ writer_role: mcp
2572
+ input_schema:
2573
+ type: object
2574
+ required: [owner_type, owner_id, kind, path, provenance, source_refs, consumer_refs]
2575
+ additionalProperties: false
2576
+ properties:
2577
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
2578
+ owner_type: { type: string, enum: [project, baseline, change, task, workflow] }
2579
+ owner_id: { type: string, minLength: 1 }
2580
+ kind: { type: string, minLength: 1 }
2581
+ path: { type: string, minLength: 1 }
2582
+ status: { type: string, enum: [current, stale, terminal, archived], default: current }
2583
+ expected_before_digest:
2584
+ type: [string, 'null']
2585
+ pattern: '^[a-f0-9]{64}$'
2586
+ provenance: { type: object, additionalProperties: true }
2587
+ metadata: { type: object, additionalProperties: true }
2588
+ source_refs:
2589
+ type: array
2590
+ items:
2591
+ type: object
2592
+ required: [type, id, relation]
2593
+ additionalProperties: false
2594
+ properties:
2595
+ type: { type: string, enum: [artifact, project, baseline, change, task, workflow, external] }
2596
+ id: { type: string, minLength: 1 }
2597
+ relation: { type: string, minLength: 1 }
2598
+ consumer_refs:
2599
+ type: array
2600
+ items:
2601
+ type: object
2602
+ required: [type, id, relation]
2603
+ additionalProperties: false
2604
+ properties:
2605
+ type: { type: string, enum: [artifact, project, baseline, change, task, workflow, external] }
2606
+ id: { type: string, minLength: 1 }
2607
+ relation: { type: string, minLength: 1 }
2608
+ output_schema:
2609
+ type: object
2610
+ required: [artifact, changed, invalidated]
2611
+ additionalProperties: false
2612
+ properties:
2613
+ artifact:
2614
+ type: object
2615
+ required: [id, owner_type, owner_id, kind, path, digest, before_digest, after_digest, managed, status, provenance, metadata, source_refs, consumer_refs, created_at, updated_at]
2616
+ additionalProperties: false
2617
+ properties:
2618
+ id: { type: string }
2619
+ owner_type: { type: string, enum: [project, baseline, change, task, workflow] }
2620
+ owner_id: { type: string }
2621
+ kind: { type: string }
2622
+ path: { type: string }
2623
+ digest: { type: [string, 'null'] }
2624
+ before_digest: { type: [string, 'null'] }
2625
+ after_digest: { type: [string, 'null'] }
2626
+ managed: { type: boolean }
2627
+ status: { type: string, enum: [current, stale, terminal, archived] }
2628
+ provenance: { type: object }
2629
+ metadata: { type: object }
2630
+ source_refs:
2631
+ type: array
2632
+ items:
2633
+ type: object
2634
+ required: [type, id, relation]
2635
+ additionalProperties: false
2636
+ properties:
2637
+ type: { type: string }
2638
+ id: { type: string }
2639
+ relation: { type: string }
2640
+ consumer_refs:
2641
+ type: array
2642
+ items:
2643
+ type: object
2644
+ required: [type, id, relation]
2645
+ additionalProperties: false
2646
+ properties:
2647
+ type: { type: string }
2648
+ id: { type: string }
2649
+ relation: { type: string }
2650
+ created_at: { type: string }
2651
+ updated_at: { type: string }
2652
+ changed: { type: boolean }
2653
+ invalidated:
2654
+ type: array
2655
+ items:
2656
+ type: object
2657
+ required: [type, id]
2658
+ additionalProperties: false
2659
+ properties:
2660
+ type: { type: string }
2661
+ id: { type: string }
2662
+ errors:
2663
+ - { code: ARTIFACT_FILE_MISSING, description: 'declared artifact file does not exist' }
2664
+ - { code: ARTIFACT_PATH_INVALID, description: 'artifact path escapes the project or is not a regular file' }
2665
+ - { code: ARTIFACT_PATH_EXEMPT, description: 'runtime, scratch, or generated projection path cannot become semantic authority' }
2666
+ - { code: ARTIFACT_OWNER_MISSING, description: 'typed artifact owner does not exist' }
2667
+ - { code: ARTIFACT_ENDPOINT_MISSING, description: 'a dependency endpoint does not exist' }
2668
+ - { code: ARTIFACT_DIGEST_CONFLICT, description: 'expected prior digest does not match current registry authority' }
2669
+ - { code: ARTIFACT_AUTHORITY_CONFLICT, description: 'artifact id is bound to another authority or the canonical path already has an active authority' }
2670
+ - { code: ARTIFACT_GRAPH_SELF_EDGE, description: 'an artifact cannot directly depend on itself' }
2671
+ - { code: ARTIFACT_GRAPH_CYCLE, description: 'replacement edges would create a dependency cycle' }
2672
+ cli_subcommand: artifact record
2673
+ emits_events: [artifact_recorded, spec_changed, task_stale_marked]
2674
+
2675
+ - name: artifact.get
2676
+ family: artifact
2677
+ description: Read one registered artifact together with its typed ownership, provenance, and normalized source and consumer edges.
2678
+ phase: '20'
2679
+ readonly: true
2680
+ input_schema:
2681
+ type: object
2682
+ additionalProperties: false
2683
+ oneOf:
2684
+ - required: [id]
2685
+ - required: [path]
2686
+ properties:
2687
+ id: { type: string, minLength: 1 }
2688
+ path: { type: string, minLength: 1 }
2689
+ output_schema:
2690
+ type: object
2691
+ required: [artifact]
2692
+ additionalProperties: false
2693
+ properties:
2694
+ artifact:
2695
+ type: object
2696
+ required: [id, owner_type, owner_id, kind, path, digest, before_digest, after_digest, managed, status, provenance, metadata, source_refs, consumer_refs, created_at, updated_at]
2697
+ additionalProperties: false
2698
+ properties:
2699
+ id: { type: string }
2700
+ owner_type: { type: string, enum: [project, baseline, change, task, workflow] }
2701
+ owner_id: { type: string }
2702
+ kind: { type: string }
2703
+ path: { type: string }
2704
+ digest: { type: [string, 'null'] }
2705
+ before_digest: { type: [string, 'null'] }
2706
+ after_digest: { type: [string, 'null'] }
2707
+ managed: { type: boolean }
2708
+ status: { type: string, enum: [current, stale, terminal, archived] }
2709
+ provenance: { type: object }
2710
+ metadata: { type: object }
2711
+ source_refs: { type: array, items: { type: object } }
2712
+ consumer_refs: { type: array, items: { type: object } }
2713
+ created_at: { type: string }
2714
+ updated_at: { type: string }
2715
+ errors:
2716
+ - { code: ARTIFACT_NOT_FOUND, description: 'artifact id or path is not registered' }
2717
+ - { code: ARTIFACT_DUPLICATE_AUTHORITY, description: 'path lookup resolves to multiple active authorities and requires an id' }
2718
+ - { code: VALIDATION_ERROR, description: 'exactly one lookup key is required' }
2719
+ cli_subcommand: artifact get
2720
+ emits_events: []
2721
+
2145
2722
  # ────────────────────────── system family ──────────────────────────────
2146
2723
  - name: system.doctor
2147
2724
  family: system
@@ -2172,29 +2749,35 @@ tools:
2172
2749
  # ────────────────────────── plan family (D34) ───────────────────────────
2173
2750
  - name: plan.export
2174
2751
  family: plan
2175
- description: Render the current execution-plan artifact to disk (waves + ownership + conflict surface).
2752
+ description: Render deterministic plan.json and plan.md under the owning Change artifact root from the current planning Context Manifest.
2176
2753
  phase: '8a'
2177
2754
  writer_role: mcp
2178
2755
  input_schema:
2179
2756
  type: object
2180
- required: [change_id, out_path]
2757
+ required: [change_id]
2181
2758
  additionalProperties: false
2182
2759
  properties:
2183
- format: { type: string, enum: [json, md], default: json }
2184
2760
  change_id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
2185
- out_path: { type: string }
2186
- tag: { type: string }
2187
2761
  output_schema:
2188
2762
  type: object
2189
- required: [plan_path, wave_count]
2763
+ required: [plan_path, plan_md_path, wave_count]
2190
2764
  additionalProperties: false
2191
2765
  properties:
2192
2766
  plan_path: { type: string }
2767
+ plan_md_path: { type: string }
2193
2768
  wave_count: { type: integer, minimum: 0 }
2194
2769
  errors:
2195
2770
  - { code: NO_TASKS, description: 'no tasks to plan' }
2196
2771
  - { code: CHANGE_NOT_FOUND, description: 'owning change does not exist' }
2197
2772
  - { code: CHANGE_NOT_MUTABLE, description: 'owning change no longer accepts planning output' }
2773
+ - { code: PLAN_CONTEXT_REQUIRED, description: 'the owning Change has no plan/planning Context Manifest' }
2774
+ - { code: PLAN_CONTEXT_STALE, description: 'the plan/planning Context Manifest is stale or blocked' }
2775
+ - { code: PLAN_ARTIFACT_PATH_UNSAFE, description: 'the Change artifact root, an ancestor, or a plan target is a symlink or escapes the physical project root' }
2776
+ - { code: PLAN_PUBLISH_CONFLICT, description: 'plan.json or plan.md changed after publication preparation; concurrent bytes are preserved' }
2777
+ - { code: PLAN_PUBLISH_FAILED, description: 'the journaled plan.json and plan.md publication could not complete and was rolled back' }
2778
+ - { code: PLAN_RECOVERY_REQUIRED, description: 'an interrupted plan publication must be recovered before state mutation continues' }
2779
+ - { code: ARTIFACT_AUTHORITY_CONFLICT, description: 'plan.json or plan.md already has another active registry authority' }
2780
+ - { code: ARTIFACT_DIGEST_CONFLICT, description: 'the registered plan authority changed before publication' }
2198
2781
  - { code: WRITE_FAILED, description: 'cannot write plan file' }
2199
2782
  cli_subcommand: plan export
2200
2783
  emits_events: [plan_exported]
@@ -2202,7 +2785,7 @@ tools:
2202
2785
 
2203
2786
  - name: plan.get
2204
2787
  family: plan
2205
- description: Read a section of the current project's persisted .ultra/execution-plan.json artifact.
2788
+ description: Read a section of the owning Change's persisted plan.json artifact.
2206
2789
  phase: '8a'
2207
2790
  readonly: true
2208
2791
  input_schema:
@@ -2220,7 +2803,9 @@ tools:
2220
2803
  plan: { type: object }
2221
2804
  errors:
2222
2805
  - { code: NO_PLAN, description: 'no plan has been computed yet' }
2806
+ - { code: CHANGE_NOT_FOUND, description: 'owning change does not exist' }
2223
2807
  - { code: PLAN_CHANGE_MISMATCH, description: 'current plan artifact belongs to another change' }
2808
+ - { code: PLAN_ARTIFACT_INVALID, description: 'plan.json is unsafe, malformed, stale, or does not match the current Change-owned registry authority' }
2224
2809
  cli_subcommand: plan get
2225
2810
  emits_events: []
2226
2811
  trace_to: '§7.3, D34'