@cleocode/contracts 2026.4.96 → 2026.4.97

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 (58) hide show
  1. package/dist/facade.d.ts +63 -1
  2. package/dist/facade.d.ts.map +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/operations/brain.d.ts +579 -0
  7. package/dist/operations/brain.d.ts.map +1 -0
  8. package/dist/operations/brain.js +39 -0
  9. package/dist/operations/brain.js.map +1 -0
  10. package/dist/operations/conduit.d.ts +151 -0
  11. package/dist/operations/conduit.d.ts.map +1 -0
  12. package/dist/operations/conduit.js +29 -0
  13. package/dist/operations/conduit.js.map +1 -0
  14. package/dist/operations/index.d.ts +4 -0
  15. package/dist/operations/index.d.ts.map +1 -1
  16. package/dist/operations/index.js +4 -0
  17. package/dist/operations/index.js.map +1 -1
  18. package/dist/operations/lifecycle.d.ts +29 -1
  19. package/dist/operations/lifecycle.d.ts.map +1 -1
  20. package/dist/operations/memory.d.ts +814 -0
  21. package/dist/operations/memory.d.ts.map +1 -0
  22. package/dist/operations/memory.js +26 -0
  23. package/dist/operations/memory.js.map +1 -0
  24. package/dist/operations/nexus.d.ts +577 -0
  25. package/dist/operations/nexus.d.ts.map +1 -0
  26. package/dist/operations/nexus.js +22 -0
  27. package/dist/operations/nexus.js.map +1 -0
  28. package/dist/operations/orchestrate.d.ts +451 -38
  29. package/dist/operations/orchestrate.d.ts.map +1 -1
  30. package/dist/operations/orchestrate.js +6 -0
  31. package/dist/operations/orchestrate.js.map +1 -1
  32. package/dist/operations/release.d.ts +78 -8
  33. package/dist/operations/release.d.ts.map +1 -1
  34. package/dist/operations/session.d.ts +26 -3
  35. package/dist/operations/session.d.ts.map +1 -1
  36. package/dist/operations/tasks.d.ts +140 -2
  37. package/dist/operations/tasks.d.ts.map +1 -1
  38. package/dist/status-registry.d.ts +1 -1
  39. package/dist/status-registry.d.ts.map +1 -1
  40. package/dist/status-registry.js +3 -0
  41. package/dist/status-registry.js.map +1 -1
  42. package/dist/task.d.ts +66 -0
  43. package/dist/task.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/src/facade.ts +64 -1
  46. package/src/index.ts +5 -0
  47. package/src/operations/brain.ts +635 -0
  48. package/src/operations/conduit.ts +189 -0
  49. package/src/operations/index.ts +4 -0
  50. package/src/operations/lifecycle.ts +29 -1
  51. package/src/operations/memory.ts +959 -0
  52. package/src/operations/nexus.ts +711 -0
  53. package/src/operations/orchestrate.ts +447 -38
  54. package/src/operations/release.ts +77 -7
  55. package/src/operations/session.ts +26 -3
  56. package/src/operations/tasks.ts +141 -3
  57. package/src/status-registry.ts +3 -0
  58. package/src/task.ts +75 -0
@@ -3,23 +3,38 @@
3
3
  *
4
4
  * Query operations: 7
5
5
  * Mutate operations: 6
6
+ *
7
+ * SYNC: Canonical implementations at
8
+ * packages/cleo/src/dispatch/engines/orchestrate-engine.ts
9
+ * packages/core/src/orchestration/*.ts
10
+ *
11
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
6
12
  */
7
13
 
8
14
  /**
9
15
  * Common orchestration types
10
16
  */
11
17
  export interface Wave {
18
+ /** 1-based wave number. @task T963 */
12
19
  wave: number;
20
+ /** Task IDs scheduled in this wave. @task T963 */
13
21
  taskIds: string[];
22
+ /** True when every task in the wave can run in parallel. @task T963 */
14
23
  canRunParallel: boolean;
24
+ /** Upstream wave/task dependencies. @task T963 */
15
25
  dependencies: string[];
16
26
  }
17
27
 
18
28
  export interface SkillDefinition {
29
+ /** Skill name. @task T963 */
19
30
  name: string;
31
+ /** Skill description. @task T963 */
20
32
  description: string;
33
+ /** Skill tags. @task T963 */
21
34
  tags: string[];
35
+ /** Preferred model. @task T963 */
22
36
  model?: string;
37
+ /** Supported protocol phases. @task T963 */
23
38
  protocols: string[];
24
39
  }
25
40
 
@@ -28,88 +43,281 @@ export interface SkillDefinition {
28
43
  */
29
44
 
30
45
  // orchestrate.status
46
+ /**
47
+ * Parameters for `orchestrate.status`.
48
+ *
49
+ * @remarks
50
+ * Re-synced to match `orchestrateStatus(epicId?, projectRoot?)` in
51
+ * `packages/cleo/src/dispatch/engines/orchestrate-engine.ts`. When `epicId`
52
+ * is omitted, the engine returns an overall status envelope across all
53
+ * tasks in the project.
54
+ *
55
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
56
+ */
31
57
  export interface OrchestrateStatusParams {
32
- epicId: string;
58
+ /** Epic to scope the status to. Omit for project-wide status. @task T963 */
59
+ epicId?: string;
60
+ }
61
+ /** Per-status task counts. @task T963 */
62
+ export interface OrchestrateStatusCounts {
63
+ /** Pending tasks. @task T963 */
64
+ pending: number;
65
+ /** Active tasks. @task T963 */
66
+ active: number;
67
+ /** Blocked tasks. @task T963 */
68
+ blocked: number;
69
+ /** Completed tasks. @task T963 */
70
+ done: number;
71
+ /** Cancelled tasks (epic scope only). @task T963 */
72
+ cancelled?: number;
33
73
  }
34
- export interface OrchestrateStatusResult {
74
+ /**
75
+ * Epic-scoped status (returned when `epicId` is supplied). Mirrors
76
+ * `EpicStatus` in `packages/core/src/orchestration/status.ts`.
77
+ * @task T963
78
+ */
79
+ export interface OrchestrateEpicStatus {
80
+ /** Epic task id. @task T963 */
35
81
  epicId: string;
82
+ /** Epic title. @task T963 */
83
+ epicTitle: string;
84
+ /** Count of direct children. @task T963 */
36
85
  totalTasks: number;
37
- completedTasks: number;
38
- pendingTasks: number;
39
- blockedTasks: number;
40
- currentWave: number;
41
- totalWaves: number;
42
- parallelCapacity: number;
86
+ /** Per-status breakdown of the children. @task T963 */
87
+ byStatus: OrchestrateStatusCounts;
88
+ /** Total wave count computed for the epic. @task T963 */
89
+ waves: number;
90
+ /** First non-completed wave number, or `null` when all waves done. @task T963 */
91
+ currentWave: number | null;
43
92
  }
93
+ /**
94
+ * Project-wide status (returned when `epicId` is omitted). Mirrors
95
+ * `OverallStatus` in `packages/core/src/orchestration/status.ts`.
96
+ * @task T963
97
+ */
98
+ export interface OrchestrateOverallStatus {
99
+ /** Count of detected root epics. @task T963 */
100
+ totalEpics: number;
101
+ /** Total tasks in the project. @task T963 */
102
+ totalTasks: number;
103
+ /** Per-status breakdown of the project. @task T963 */
104
+ byStatus: OrchestrateStatusCounts;
105
+ }
106
+ /** Result of `orchestrate.status` — union of epic-scoped and overall. @task T963 */
107
+ export type OrchestrateStatusResult = OrchestrateEpicStatus | OrchestrateOverallStatus;
44
108
 
45
109
  // orchestrate.next
110
+ /** Parameters for `orchestrate.next`. @task T963 */
46
111
  export interface OrchestrateNextParams {
112
+ /** Epic to pull the next task from (required). @task T963 */
47
113
  epicId: string;
48
114
  }
115
+ /**
116
+ * Result of `orchestrate.next`.
117
+ *
118
+ * @remarks
119
+ * Re-synced to match `orchestrateNext(epicId, projectRoot?)` in the engine.
120
+ * The legacy `{taskId, title, recommendedSkill, reasoning}` shape was never
121
+ * implemented — the engine returns a `nextTask | null` + alternatives
122
+ * envelope.
123
+ *
124
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
125
+ */
49
126
  export interface OrchestrateNextResult {
50
- taskId: string;
51
- title: string;
52
- recommendedSkill: string;
53
- reasoning: string;
127
+ /** Epic id that was queried. @task T963 */
128
+ epicId: string;
129
+ /** Next task to work on, or `null` when nothing ready. @task T963 */
130
+ nextTask: {
131
+ /** Task id. @task T963 */
132
+ id: string;
133
+ /** Task title. @task T963 */
134
+ title: string;
135
+ /** Priority rollup from the engine. @task T963 */
136
+ priority: string;
137
+ } | null;
138
+ /** Other ready alternatives (up to 3). Absent when `nextTask` is null. @task T963 */
139
+ alternatives?: Array<{ id: string; title: string; priority: string }>;
140
+ /** Total ready tasks for the epic. Absent when `nextTask` is null. @task T963 */
141
+ totalReady?: number;
142
+ /** Human-readable hint when nothing is ready. @task T963 */
143
+ message?: string;
54
144
  }
55
145
 
56
146
  // orchestrate.ready
147
+ /** Parameters for `orchestrate.ready`. @task T963 */
57
148
  export interface OrchestrateReadyParams {
149
+ /** Epic to compute the ready set for (required). @task T963 */
58
150
  epicId: string;
59
151
  }
152
+ /**
153
+ * A single ready-task descriptor as returned by `orchestrate.ready`.
154
+ * @task T963
155
+ */
156
+ export interface OrchestrateReadyTask {
157
+ /** Task id. @task T963 */
158
+ id: string;
159
+ /** Task title. @task T963 */
160
+ title: string;
161
+ /** Engine-rolled priority. @task T963 */
162
+ priority: string;
163
+ /** IDs of tasks this one depends on (blocker/depends chain). @task T963 */
164
+ depends: string[];
165
+ }
166
+ /**
167
+ * Result of `orchestrate.ready`.
168
+ *
169
+ * @remarks
170
+ * Re-synced to match `orchestrateReady(epicId, projectRoot?)`. Returns
171
+ * the filtered ready set from `getReadyTasks` + a diagnostic `reason`
172
+ * when empty.
173
+ *
174
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
175
+ */
60
176
  export interface OrchestrateReadyResult {
61
- wave: number;
62
- taskIds: string[];
63
- parallelSafe: boolean;
177
+ /** Epic id that was queried. @task T963 */
178
+ epicId: string;
179
+ /** Ready task set (filtered to `ready === true`). @task T963 */
180
+ readyTasks: OrchestrateReadyTask[];
181
+ /** Count of ready tasks (may be zero). @task T963 */
182
+ total: number;
183
+ /** Diagnostic reason populated when `total === 0`. @task T963 */
184
+ reason?: string;
64
185
  }
65
186
 
66
187
  // orchestrate.analyze
188
+ /**
189
+ * Parameters for `orchestrate.analyze`.
190
+ *
191
+ * @remarks
192
+ * Re-synced: engine signature is
193
+ * `orchestrateAnalyze(epicId?, projectRoot?, mode?)`. Mode
194
+ * `critical-path` delegates to `orchestrateCriticalPath` — callers may
195
+ * branch on `mode` at the dispatch layer.
196
+ *
197
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
198
+ */
67
199
  export interface OrchestrateAnalyzeParams {
68
- epicId: string;
200
+ /**
201
+ * Epic to analyze. Required for standard mode; optional for
202
+ * `mode: 'critical-path'` which operates across the whole project.
203
+ * @task T963
204
+ */
205
+ epicId?: string;
206
+ /** Analysis mode — `undefined` | `'critical-path'`. @task T963 */
207
+ mode?: 'critical-path';
69
208
  }
209
+ /**
210
+ * Result of `orchestrate.analyze` (standard mode).
211
+ *
212
+ * @remarks
213
+ * Returns the wave plan + dependency diagnostics from
214
+ * `analyzeEpic` + `analyzeDependencies`.
215
+ *
216
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
217
+ */
70
218
  export interface OrchestrateAnalyzeResult {
219
+ /** Epic task id that was analyzed. @task T963 */
220
+ epicId: string;
221
+ /** Epic title (falls back to `epicId` when title unresolvable). @task T963 */
222
+ epicTitle: string;
223
+ /** Count of direct children. @task T963 */
224
+ totalTasks: number;
225
+ /** Computed wave plan. @task T963 */
71
226
  waves: Wave[];
72
- criticalPath: string[];
73
- estimatedParallelism: number;
74
- bottlenecks: string[];
227
+ /** Detected circular dependency chains. @task T963 */
228
+ circularDependencies: string[][];
229
+ /** Dependencies that point at nonexistent task ids. @task T963 */
230
+ missingDependencies: string[];
231
+ /**
232
+ * Adjacency-list dependency graph (taskId → depends-on ids).
233
+ * @task T963
234
+ */
235
+ dependencyGraph: Record<string, string[]>;
75
236
  }
76
237
 
77
238
  // orchestrate.context
239
+ /**
240
+ * Parameters for `orchestrate.context`.
241
+ *
242
+ * @remarks
243
+ * Re-synced to match `orchestrateContext(epicId?, projectRoot?)` in the
244
+ * engine. The legacy `tokens` field was unused; the real parameter is
245
+ * an optional `epicId` that scopes the task-count basis of the estimate.
246
+ *
247
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
248
+ */
78
249
  export interface OrchestrateContextParams {
79
- tokens?: number;
250
+ /** Epic id to scope the context estimate. Omit for project-wide. @task T963 */
251
+ epicId?: string;
80
252
  }
253
+ /**
254
+ * Result of `orchestrate.context`.
255
+ *
256
+ * @remarks
257
+ * Mirrors `ContextEstimation` in `packages/core/src/orchestration/context.ts`.
258
+ *
259
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
260
+ */
81
261
  export interface OrchestrateContextResult {
82
- currentTokens: number;
83
- maxTokens: number;
84
- percentUsed: number;
85
- level: 'safe' | 'medium' | 'high' | 'critical';
262
+ /** Epic id the estimate was scoped to, or `null` for project-wide. @task T963 */
263
+ epicId: string | null;
264
+ /** Count of tasks included in the estimate. @task T963 */
265
+ taskCount: number;
266
+ /** Count of MANIFEST.jsonl entries. @task T963 */
267
+ manifestEntries: number;
268
+ /** Rough estimated token count (taskCount * per-task weight). @task T963 */
269
+ estimatedTokens: number;
270
+ /** Human-readable recommendation. @task T963 */
86
271
  recommendation: string;
272
+ /** Context budget limits + current usage. @task T963 */
273
+ limits: {
274
+ /** Maximum orchestrator context budget. @task T963 */
275
+ orchestratorBudget: number;
276
+ /** Max files a single agent should read. @task T963 */
277
+ maxFilesPerAgent: number;
278
+ /** Current token usage (mirrors `estimatedTokens`). @task T963 */
279
+ currentUsage: number;
280
+ };
87
281
  }
88
282
 
89
283
  // orchestrate.waves
284
+ /** Parameters for `orchestrate.waves`. @task T963 */
90
285
  export interface OrchestrateWavesParams {
286
+ /** Epic to compute waves for. @task T963 */
91
287
  epicId: string;
92
288
  }
93
289
  export type OrchestrateWavesResult = Wave[];
94
290
 
95
291
  // orchestrate.skill.list
292
+ /** Parameters for `orchestrate.skill.list`. @task T963 */
96
293
  export interface OrchestrateSkillListParams {
294
+ /** Free-text filter across skill name/tags. @task T963 */
97
295
  filter?: string;
98
296
  }
99
297
  export type OrchestrateSkillListResult = SkillDefinition[];
100
298
 
101
299
  // orchestrate.bootstrap
300
+ /** Parameters for `orchestrate.bootstrap`. @task T963 */
102
301
  export interface OrchestrateBootstrapParams {
302
+ /** Bootstrap verbosity mode. @task T963 */
103
303
  speed?: 'fast' | 'full' | 'complete';
104
304
  }
105
305
  export interface BrainState {
306
+ /** Currently active session summary. @task T963 */
106
307
  session?: { id: string; name: string; status: string; startedAt: string };
308
+ /** Current task context. @task T963 */
107
309
  currentTask?: { id: string; title: string; status: string };
310
+ /** Suggested next task with score. @task T963 */
108
311
  nextSuggestion?: { id: string; title: string; score: number };
312
+ /** Recent decisions for the brain-state rollup. @task T963 */
109
313
  recentDecisions?: Array<{ id: string; decision: string; timestamp: string }>;
314
+ /** Blockers currently affecting progress. @task T963 */
110
315
  blockers?: Array<{ taskId: string; title: string; blockedBy: string[] }>;
316
+ /** Progress rollup. @task T963 */
111
317
  progress?: { total: number; done: number; active: number; blocked: number; pending: number };
318
+ /** Context drift score + contributing factors. @task T963 */
112
319
  contextDrift?: { score: number; factors: string[] };
320
+ /** Bootstrap envelope metadata. @task T963 */
113
321
  _meta: { speed: 'fast' | 'full' | 'complete'; generatedAt: string; version: string };
114
322
  }
115
323
 
@@ -118,82 +326,283 @@ export interface BrainState {
118
326
  */
119
327
 
120
328
  // orchestrate.startup
329
+ /** Parameters for `orchestrate.startup`. @task T963 */
121
330
  export interface OrchestrateStartupParams {
331
+ /** Epic id to initialize. @task T963 */
122
332
  epicId: string;
123
333
  }
334
+ /**
335
+ * Result of `orchestrate.startup`.
336
+ *
337
+ * @remarks
338
+ * Re-synced to match `orchestrateStartup(epicId, projectRoot?)` + the
339
+ * `computeStartupSummary` output + auto-init fields. The legacy shape
340
+ * assumed nested status/analysis/firstTask envelopes; the engine actually
341
+ * returns a flat summary + auto-init metadata.
342
+ *
343
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
344
+ */
124
345
  export interface OrchestrateStartupResult {
346
+ /** Epic id that was initialized. @task T963 */
125
347
  epicId: string;
126
- status: OrchestrateStatusResult;
127
- analysis: OrchestrateAnalyzeResult;
128
- firstTask: OrchestrateNextResult;
348
+ /** Epic title. @task T963 */
349
+ epicTitle: string;
350
+ /** Always true once startup reaches return — pipeline + research stage recorded. @task T963 */
351
+ initialized: true;
352
+ /** Summary rollup of the epic's children. @task T963 */
353
+ summary: {
354
+ /** Total child count. @task T963 */
355
+ totalTasks: number;
356
+ /** Wave count. @task T963 */
357
+ totalWaves: number;
358
+ /** Count of tasks ready to spawn. @task T963 */
359
+ readyTasks: number;
360
+ /** Per-status breakdown. @task T963 */
361
+ byStatus: OrchestrateStatusCounts;
362
+ };
363
+ /** First wave payload, or `null` when epic has no children. @task T963 */
364
+ firstWave: Wave | null;
365
+ /**
366
+ * True when this startup call auto-initialized the lifecycle to the
367
+ * `research` stage. False when the epic already had a pipeline.
368
+ * @task T963
369
+ */
370
+ autoInitialized: boolean;
371
+ /**
372
+ * Current pipeline stage after startup — `research` when auto-initialized,
373
+ * `already-initialized` marker string otherwise.
374
+ * @task T963
375
+ */
376
+ currentStage: string;
129
377
  }
130
378
 
131
379
  // orchestrate.spawn
380
+ /**
381
+ * Parameters for `orchestrate.spawn` (T882 canonical spawn contract).
382
+ *
383
+ * @remarks
384
+ * Re-synced to match `orchestrateSpawn(taskId, protocolType, projectRoot, tier)`
385
+ * in `packages/cleo/src/dispatch/engines/orchestrate-engine.ts`. The legacy
386
+ * `{skill, model}` fields from earlier drafts were never implemented — the
387
+ * T882 rebuild (v2026.4.85) introduced `protocolType` + `tier` as the
388
+ * authoritative inputs.
389
+ *
390
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
391
+ * @task T882 — canonical spawn-prompt rebuild
392
+ */
132
393
  export interface OrchestrateSpawnParams {
394
+ /** Task ID to spawn a worker for (required). @task T963 */
133
395
  taskId: string;
134
- skill?: string;
135
- model?: string;
396
+ /**
397
+ * Protocol phase dispatched to the worker (e.g. `'research'`,
398
+ * `'implementation'`, `'validation'`). When omitted, the composer runs
399
+ * `autoDispatch` to classify the task.
400
+ * @task T963
401
+ */
402
+ protocolType?: string;
403
+ /**
404
+ * Spawn prompt tier per T882 (0=minimal, 1=standard with CLEO-INJECTION
405
+ * embed, 2=full with skill excerpts + SUBAGENT-PROTOCOL-BLOCK). When
406
+ * omitted, resolved from the agent role (orchestrator=2, lead=1, worker=0).
407
+ * @task T963
408
+ */
409
+ tier?: 0 | 1 | 2;
136
410
  }
411
+ /**
412
+ * Result of `orchestrate.spawn`.
413
+ *
414
+ * @remarks
415
+ * Re-synced to match the T932 `composeSpawnForTask` payload envelope returned
416
+ * by the orchestrate engine (prompt + atomicity verdict + traceability meta).
417
+ * Mirrors `SpawnPayload` in `packages/core/src/orchestration/spawn.ts`.
418
+ *
419
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
420
+ */
137
421
  export interface OrchestrateSpawnResult {
422
+ /** Task ID the spawn is about (mirrors `task.id`). @task T963 */
138
423
  taskId: string;
139
- skill: string;
140
- model: string;
424
+ /**
425
+ * Fully-resolved spawn prompt, copy-pastable into any LLM runtime
426
+ * (Claude, GPT-4, Gemini, open-source). Primary payload every caller
427
+ * should consume.
428
+ * @task T963
429
+ */
141
430
  prompt: string;
142
- metadata: {
143
- tokensUsed: number;
144
- protocolsInjected: string[];
145
- dependencies: string[];
431
+ /** Agent id the spawn is routed to. @task T963 */
432
+ agentId: string;
433
+ /** Role the agent will execute as (`orchestrator` | `lead` | `worker`). @task T963 */
434
+ role: string;
435
+ /** Tier of the rendered prompt (0/1/2). @task T963 */
436
+ tier: 0 | 1 | 2;
437
+ /** Harness hint driving dedup decisions (`claude-code` | `generic` | `bare`). @task T963 */
438
+ harnessHint: string;
439
+ /**
440
+ * Atomicity gate verdict from the worker file-scope guard. When
441
+ * `allowed=false`, the spawn was rejected and the orchestrate engine
442
+ * surfaces an `E_ATOMICITY_VIOLATION` error envelope.
443
+ * @task T963
444
+ */
445
+ atomicity: {
446
+ /** Whether the spawn is permitted. @task T963 */
447
+ allowed: boolean;
448
+ /** Error code when the spawn was rejected. @task T963 */
449
+ code?: string;
450
+ /** Diagnostic message. @task T963 */
451
+ message?: string;
452
+ /** Fix hint for the violation. @task T963 */
453
+ fixHint?: string;
454
+ };
455
+ /**
456
+ * Traceability / accounting metadata. Mirrors `SpawnPayloadMeta` —
457
+ * pinned `composerVersion: '3.0.0'` on every call.
458
+ * @task T963
459
+ */
460
+ meta: {
461
+ /** Tier the resolved agent was sourced from. @task T963 */
462
+ sourceTier: string;
463
+ /** Characters saved by skipping the tier-1 CLEO-INJECTION embed. @task T963 */
464
+ dedupSavedChars: number;
465
+ /** Character length of the final prompt. @task T963 */
466
+ promptChars: number;
467
+ /** Protocol phase the prompt was rendered for. @task T963 */
468
+ protocol: string;
469
+ /** ISO 8601 timestamp when the payload was generated. @task T963 */
470
+ generatedAt: string;
471
+ /** Pinned composer contract version. @task T963 */
472
+ composerVersion: '3.0.0';
473
+ };
474
+ /**
475
+ * Mirror of `meta.protocol` at the top level for legacy callers. Equals
476
+ * the resolved protocol phase (from `protocolType` param or auto-dispatch).
477
+ * @task T963
478
+ */
479
+ protocolType: string;
480
+ /**
481
+ * Active session id threaded into the prompt, or `null` when the
482
+ * orchestrator had no active session at spawn time.
483
+ * @task T963
484
+ */
485
+ sessionId: string | null;
486
+ /**
487
+ * Legacy mirror of the prompt/protocolType/tier bundle for readers that
488
+ * still consume `spawnContext.*`.
489
+ * @task T963
490
+ */
491
+ spawnContext: {
492
+ /** Task id mirrored from top level. @task T963 */
493
+ taskId: string;
494
+ /** Protocol string from the composer. @task T963 */
495
+ protocol: string;
496
+ /** Resolved protocol type. @task T963 */
497
+ protocolType: string;
498
+ /** Tier mirror. @task T963 */
499
+ tier: 0 | 1 | 2;
500
+ /** Prompt mirror. @task T963 */
501
+ prompt: string;
146
502
  };
147
503
  }
148
504
 
149
505
  // orchestrate.handoff
506
+ /** Parameters for `orchestrate.handoff`. @task T963 */
150
507
  export interface OrchestrateHandoffParams {
508
+ /** Task id to hand off to. @task T963 */
151
509
  taskId: string;
510
+ /** Protocol phase for the successor spawn. @task T963 */
152
511
  protocolType: string;
512
+ /** Free-form session-end note. @task T963 */
153
513
  note?: string;
514
+ /** Next-action hint for the successor. @task T963 */
154
515
  nextAction?: string;
516
+ /** Context injection variant (skill preset). @task T963 */
155
517
  variant?: string;
518
+ /** Tier override for the spawn prompt. @task T963 */
156
519
  tier?: 0 | 1 | 2;
520
+ /** Client-supplied idempotency key for handoff retries. @task T963 */
157
521
  idempotencyKey?: string;
158
522
  }
523
+ /** Result of `orchestrate.handoff`. @task T963 */
159
524
  export interface OrchestrateHandoffResult {
525
+ /** Task id that was handed off to. @task T963 */
160
526
  taskId: string;
527
+ /** Session id that was active before handoff. @task T963 */
161
528
  predecessorSessionId: string;
529
+ /** Session id that was ended. @task T963 */
162
530
  endedSessionId: string;
531
+ /** Protocol type resolved for the successor. @task T963 */
163
532
  protocolType: string;
164
533
  }
165
534
 
166
535
  // orchestrate.validate
536
+ /** Validation issue surfaced by `orchestrate.validate`. @task T963 */
537
+ export interface OrchestrateValidationIssue {
538
+ /** Stable issue code (e.g. `V_NOT_FOUND`, `V_UNMET_DEP`, `V_MISSING_TITLE`). @task T963 */
539
+ code: string;
540
+ /** Human-readable diagnostic message. @task T963 */
541
+ message: string;
542
+ /** Issue severity (`error` | `warning` | `info`). @task T963 */
543
+ severity: string;
544
+ }
545
+ /** Parameters for `orchestrate.validate`. @task T963 */
167
546
  export interface OrchestrateValidateParams {
547
+ /** Task id to validate. @task T963 */
168
548
  taskId: string;
169
549
  }
550
+ /**
551
+ * Result of `orchestrate.validate`.
552
+ *
553
+ * @remarks
554
+ * Re-synced to match `validateSpawnReadiness` in
555
+ * `packages/core/src/orchestration/validate-spawn.ts`. The legacy shape
556
+ * (`{blockers, lifecycleGate, recommendations}`) never matched the engine;
557
+ * the real output is a `{ready, issues}` envelope.
558
+ *
559
+ * @task T963 — contract↔impl drift reconciliation (T910 audit)
560
+ */
170
561
  export interface OrchestrateValidateResult {
562
+ /** Task id that was validated. @task T963 */
171
563
  taskId: string;
564
+ /** Task title snapshot. @task T963 */
565
+ title: string;
566
+ /** True when the task passed every readiness check. @task T963 */
172
567
  ready: boolean;
173
- blockers: string[];
174
- lifecycleGate: 'passed' | 'failed' | 'pending';
175
- recommendations: string[];
568
+ /** Issues preventing spawn (empty array when `ready === true`). @task T963 */
569
+ issues: OrchestrateValidationIssue[];
176
570
  }
177
571
 
178
572
  // orchestrate.parallel.start
573
+ /** Parameters for `orchestrate.parallel.start`. @task T963 */
179
574
  export interface OrchestrateParallelStartParams {
575
+ /** Epic id. @task T963 */
180
576
  epicId: string;
577
+ /** Wave number to launch. @task T963 */
181
578
  wave: number;
182
579
  }
580
+ /** Result of `orchestrate.parallel.start`. @task T963 */
183
581
  export interface OrchestrateParallelStartResult {
582
+ /** Wave number launched. @task T963 */
184
583
  wave: number;
584
+ /** Task IDs in the wave. @task T963 */
185
585
  taskIds: string[];
586
+ /** ISO 8601 start timestamp. @task T963 */
186
587
  started: string;
187
588
  }
188
589
 
189
590
  // orchestrate.parallel.end
591
+ /** Parameters for `orchestrate.parallel.end`. @task T963 */
190
592
  export interface OrchestrateParallelEndParams {
593
+ /** Epic id. @task T963 */
191
594
  epicId: string;
595
+ /** Wave number that ended. @task T963 */
192
596
  wave: number;
193
597
  }
598
+ /** Result of `orchestrate.parallel.end`. @task T963 */
194
599
  export interface OrchestrateParallelEndResult {
600
+ /** Wave number. @task T963 */
195
601
  wave: number;
602
+ /** Tasks that completed successfully. @task T963 */
196
603
  completed: number;
604
+ /** Tasks that failed. @task T963 */
197
605
  failed: number;
606
+ /** Wave duration (ISO 8601 duration string). @task T963 */
198
607
  duration: string;
199
608
  }