@cleocode/contracts 2026.5.2 → 2026.5.4

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 (46) hide show
  1. package/dist/index.d.ts +5 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/lafs.d.ts +16 -143
  5. package/dist/lafs.d.ts.map +1 -1
  6. package/dist/lafs.js +11 -4
  7. package/dist/lafs.js.map +1 -1
  8. package/dist/operations/conduit.d.ts +15 -3
  9. package/dist/operations/conduit.d.ts.map +1 -1
  10. package/dist/operations/docs.d.ts +18 -15
  11. package/dist/operations/docs.d.ts.map +1 -1
  12. package/dist/operations/index.d.ts +5 -0
  13. package/dist/operations/index.d.ts.map +1 -1
  14. package/dist/operations/index.js +5 -0
  15. package/dist/operations/index.js.map +1 -1
  16. package/dist/operations/lifecycle.d.ts +3 -4
  17. package/dist/operations/lifecycle.d.ts.map +1 -1
  18. package/dist/operations/nexus.d.ts +341 -34
  19. package/dist/operations/nexus.d.ts.map +1 -1
  20. package/dist/operations/session.d.ts +201 -9
  21. package/dist/operations/session.d.ts.map +1 -1
  22. package/dist/operations/tasks.d.ts +381 -35
  23. package/dist/operations/tasks.d.ts.map +1 -1
  24. package/dist/operations/tasks.js +4 -3
  25. package/dist/operations/tasks.js.map +1 -1
  26. package/dist/tasks.d.ts +357 -0
  27. package/dist/tasks.d.ts.map +1 -0
  28. package/dist/tasks.js +18 -0
  29. package/dist/tasks.js.map +1 -0
  30. package/package.json +4 -2
  31. package/schemas/acceptance-gate.schema.json +484 -5
  32. package/schemas/attachment.schema.json +210 -5
  33. package/schemas/gate-result-details.schema.json +174 -5
  34. package/schemas/gate-result.schema.json +236 -5
  35. package/schemas/task-evidence.schema.json +199 -5
  36. package/schemas/task.schema.json +568 -5
  37. package/src/index.ts +37 -7
  38. package/src/lafs.ts +34 -162
  39. package/src/operations/conduit.ts +16 -3
  40. package/src/operations/docs.ts +22 -16
  41. package/src/operations/index.ts +5 -0
  42. package/src/operations/lifecycle.ts +3 -5
  43. package/src/operations/nexus.ts +355 -34
  44. package/src/operations/session.ts +213 -10
  45. package/src/operations/tasks.ts +377 -36
  46. package/src/tasks.ts +413 -0
package/src/tasks.ts ADDED
@@ -0,0 +1,413 @@
1
+ /**
2
+ * Shared task-domain result shapes for the operations layer.
3
+ *
4
+ * Defines types that are:
5
+ * - produced by core functions in `packages/core/src/tasks/`
6
+ * - consumed by the dispatch layer
7
+ * - exposed as `Result` types in `operations/tasks.ts`
8
+ *
9
+ * These types are the single source of truth for the wire-format shapes.
10
+ * Core functions import them here (via `@cleocode/contracts`) rather than
11
+ * defining inline interfaces.
12
+ *
13
+ * @module tasks
14
+ * @task T1703 — Fill 20 Result=unknown stubs in operations/tasks.ts
15
+ * @epic T1688
16
+ */
17
+
18
+ import type { TaskPriority, TaskStatus } from './task.js';
19
+
20
+ // ---------------------------------------------------------------------------
21
+ // TaskView types (canonical task projection consumed by SDK, CLI, and REST)
22
+ // ---------------------------------------------------------------------------
23
+
24
+ /**
25
+ * RCASD-IVTR+C pipeline stage values valid for `TaskView.pipelineStage`.
26
+ *
27
+ * Mirrors `TaskViewPipelineStage` from `packages/core/src/tasks/compute-task-view.ts`.
28
+ *
29
+ * @task T1703
30
+ */
31
+ export type TaskViewPipelineStage =
32
+ | 'research'
33
+ | 'specification'
34
+ | 'decomposition'
35
+ | 'implementation'
36
+ | 'validation'
37
+ | 'testing'
38
+ | 'release'
39
+ | 'contribution';
40
+
41
+ /**
42
+ * Canonical next-action tokens emitted by `TaskView.nextAction`.
43
+ *
44
+ * Consumers pattern-match on these to drive agent guidance without
45
+ * duplicating the priority-ladder logic in core.
46
+ *
47
+ * @task T1703
48
+ */
49
+ export type TaskViewNextAction =
50
+ | 'verify'
51
+ | 'advance-lifecycle'
52
+ | 'spawn-worker'
53
+ | 'blocked-on-deps'
54
+ | 'awaiting-children'
55
+ | 'already-complete'
56
+ | 'no-action';
57
+
58
+ /**
59
+ * Lifecycle progress derived from `lifecycle_pipelines` + `lifecycle_stages`.
60
+ *
61
+ * All fields are empty / null when the task has no pipeline record.
62
+ *
63
+ * @task T1703
64
+ */
65
+ export interface TaskViewLifecycleProgress {
66
+ /** Stage names whose DB status is `completed`. */
67
+ stagesCompleted: string[];
68
+ /** Stage names whose DB status is `skipped`. */
69
+ stagesSkipped: string[];
70
+ /**
71
+ * The pipeline's `currentStageId` resolved to a stage name, or `null` when
72
+ * the task has no pipeline or the current stage has not been set.
73
+ */
74
+ currentStage: string | null;
75
+ }
76
+
77
+ /**
78
+ * Verification gate status derived from `tasks.verification.gates`.
79
+ *
80
+ * Required gates are always present; `documented` is `undefined` when not recorded.
81
+ *
82
+ * @task T1703
83
+ */
84
+ export interface TaskViewGatesStatus {
85
+ /** Whether the `implemented` gate has passed. */
86
+ implemented: boolean;
87
+ /** Whether the `testsPassed` gate has passed. */
88
+ testsPassed: boolean;
89
+ /** Whether the `qaPassed` gate has passed. */
90
+ qaPassed: boolean;
91
+ /** Whether the `documented` gate has passed, or `undefined` if absent. */
92
+ documented?: boolean;
93
+ }
94
+
95
+ /**
96
+ * Direct-child rollup counts for the task (archived children excluded).
97
+ *
98
+ * @task T1703
99
+ */
100
+ export interface TaskViewChildRollup {
101
+ /** Total non-archived direct children. */
102
+ total: number;
103
+ /** Non-archived children with `status = 'done'`. */
104
+ done: number;
105
+ /** Non-archived children with `status = 'blocked'`. */
106
+ blocked: number;
107
+ /** Non-archived children with `status = 'active'`. */
108
+ active: number;
109
+ }
110
+
111
+ /**
112
+ * Canonical task view — the unified projection consumed by SDK, CLI, and REST.
113
+ *
114
+ * Produced exclusively by `computeTaskView` in core. All surfaces that
115
+ * previously derived their own view of a task now go through this type so
116
+ * they cannot disagree.
117
+ *
118
+ * @task T1703
119
+ */
120
+ export interface TaskView {
121
+ /** Task identifier (e.g. `T123`). */
122
+ id: string;
123
+ /** Task title. */
124
+ title: string;
125
+ /** Canonical execution status. Mirrors `tasks.status`. */
126
+ status: TaskStatus;
127
+ /**
128
+ * RCASD-IVTR+C pipeline stage this task is parked on.
129
+ * Reads `tasks.pipelineStage` directly. `null` when not yet assigned.
130
+ */
131
+ pipelineStage: string | null;
132
+ /**
133
+ * Lifecycle progress derived from `lifecycle_pipelines` / `lifecycle_stages`.
134
+ * Empty default when the task has no pipeline record.
135
+ */
136
+ lifecycleProgress: TaskViewLifecycleProgress;
137
+ /** Aggregated counts of non-archived direct children. */
138
+ childRollup: TaskViewChildRollup;
139
+ /**
140
+ * Verification gate status derived from `tasks.verification`.
141
+ * Defaults to all `false` when the task has no verification record.
142
+ */
143
+ gatesStatus: TaskViewGatesStatus;
144
+ /**
145
+ * Whether the task is ready to be marked complete.
146
+ * True when: required gates all green AND no unresolved blocking deps AND
147
+ * status is not already a terminal value.
148
+ */
149
+ readyToComplete: boolean;
150
+ /**
151
+ * Suggested next action for an agent working this task.
152
+ * Derived via a priority ladder in `computeTaskView`.
153
+ */
154
+ nextAction: TaskViewNextAction;
155
+ }
156
+
157
+ // ---------------------------------------------------------------------------
158
+ // Task tree node (used by tasks.tree operation)
159
+ // ---------------------------------------------------------------------------
160
+
161
+ /**
162
+ * A single node in the flat task hierarchy tree returned by `tasks.tree`.
163
+ *
164
+ * Mirrors `FlatTreeNode` from `packages/core/src/tasks/task-ops.ts`.
165
+ *
166
+ * @task T1703
167
+ */
168
+ export interface TaskTreeNode {
169
+ /** Unique task identifier (e.g. "T001"). */
170
+ id: string;
171
+ /** Human-readable task title. */
172
+ title: string;
173
+ /** Current task status. */
174
+ status: string;
175
+ /** Task type classification. @defaultValue "task" */
176
+ type?: string;
177
+ /** Child nodes in the hierarchy tree. */
178
+ children: TaskTreeNode[];
179
+ /** Task priority level. @defaultValue "medium" */
180
+ priority: TaskPriority;
181
+ /** Direct dependency IDs for this task. */
182
+ depends: string[];
183
+ /** Open (unresolved) dependency IDs that are currently blocking this task. */
184
+ blockedBy: string[];
185
+ /**
186
+ * Whether this task is immediately actionable.
187
+ * True when `blockedBy` is empty AND status is `"pending"` or `"active"`.
188
+ */
189
+ ready: boolean;
190
+ /**
191
+ * Full transitive blocker chain. Only populated when `withBlockers` is
192
+ * requested at tree-build time.
193
+ * @defaultValue undefined
194
+ */
195
+ blockerChain?: string[];
196
+ /**
197
+ * Leaf-level blockers — the root-cause tasks that must be resolved first.
198
+ * Only populated when `withBlockers` is requested at tree-build time.
199
+ * @defaultValue undefined
200
+ */
201
+ leafBlockers?: string[];
202
+ }
203
+
204
+ // ---------------------------------------------------------------------------
205
+ // Task plan types (used by tasks.plan operation)
206
+ // ---------------------------------------------------------------------------
207
+
208
+ /**
209
+ * An in-progress epic returned by the plan operation.
210
+ *
211
+ * Mirrors `InProgressEpic` from `packages/core/src/tasks/plan.ts`.
212
+ *
213
+ * @task T1703
214
+ */
215
+ export interface TaskPlanInProgressEpic {
216
+ /** Epic task ID. */
217
+ epicId: string;
218
+ /** Epic title. */
219
+ epicTitle: string;
220
+ /** Number of active child tasks. */
221
+ activeTasks: number;
222
+ /** Completion percentage (0–100). */
223
+ completionPercent: number;
224
+ }
225
+
226
+ /**
227
+ * A ready task entry with leverage analysis returned by the plan operation.
228
+ *
229
+ * Mirrors `ReadyTask` from `packages/core/src/tasks/plan.ts`.
230
+ *
231
+ * @task T1703
232
+ */
233
+ export interface TaskPlanReadyTask {
234
+ /** Task identifier. */
235
+ id: string;
236
+ /** Task title. */
237
+ title: string;
238
+ /** Task priority. */
239
+ priority: TaskPriority;
240
+ /** Parent epic ID. */
241
+ epicId: string;
242
+ /** Leverage score (higher = more impactful). */
243
+ leverage: number;
244
+ /** Overall planning score. */
245
+ score: number;
246
+ /** Human-readable reasons this task is recommended. */
247
+ reasons: string[];
248
+ }
249
+
250
+ /**
251
+ * A blocked task entry returned by the plan operation.
252
+ *
253
+ * Mirrors `BlockedTask` from `packages/core/src/tasks/plan.ts`.
254
+ *
255
+ * @task T1703
256
+ */
257
+ export interface TaskPlanBlockedTask {
258
+ /** Task identifier. */
259
+ id: string;
260
+ /** Task title. */
261
+ title: string;
262
+ /** IDs of tasks blocking this task. */
263
+ blockedBy: string[];
264
+ /** Number of tasks this task is blocking. */
265
+ blocksCount: number;
266
+ }
267
+
268
+ /**
269
+ * An open bug entry returned by the plan operation.
270
+ *
271
+ * Mirrors `OpenBug` from `packages/core/src/tasks/plan.ts`.
272
+ *
273
+ * @task T1703
274
+ */
275
+ export interface TaskPlanOpenBug {
276
+ /** Task identifier. */
277
+ id: string;
278
+ /** Task title. */
279
+ title: string;
280
+ /** Task priority. */
281
+ priority: TaskPriority;
282
+ /** Parent epic ID. */
283
+ epicId: string;
284
+ }
285
+
286
+ /**
287
+ * Planning metrics summary.
288
+ *
289
+ * Mirrors `PlanMetrics` from `packages/core/src/tasks/plan.ts`.
290
+ *
291
+ * @task T1703
292
+ */
293
+ export interface TaskPlanMetrics {
294
+ /** Total number of epics. */
295
+ totalEpics: number;
296
+ /** Number of currently active epics. */
297
+ activeEpics: number;
298
+ /** Total number of tasks across all epics. */
299
+ totalTasks: number;
300
+ /** Number of tasks that are ready to work on. */
301
+ actionable: number;
302
+ /** Number of tasks that are blocked. */
303
+ blocked: number;
304
+ /** Number of open bug tasks. */
305
+ openBugs: number;
306
+ /** Average leverage score across actionable tasks. */
307
+ avgLeverage: number;
308
+ }
309
+
310
+ /**
311
+ * Composite planning view result returned by `tasks.plan`.
312
+ *
313
+ * Mirrors `PlanResult` from `packages/core/src/tasks/plan.ts`.
314
+ *
315
+ * @task T1703
316
+ */
317
+ export interface TaskPlanResult {
318
+ /** Epics currently being worked on. */
319
+ inProgress: TaskPlanInProgressEpic[];
320
+ /** Tasks ready to be started. */
321
+ ready: TaskPlanReadyTask[];
322
+ /** Tasks blocked by dependencies. */
323
+ blocked: TaskPlanBlockedTask[];
324
+ /** Open bug tasks. */
325
+ openBugs: TaskPlanOpenBug[];
326
+ /** Aggregate planning metrics. */
327
+ metrics: TaskPlanMetrics;
328
+ }
329
+
330
+ // ---------------------------------------------------------------------------
331
+ // Label info (used by tasks.label.list operation)
332
+ // ---------------------------------------------------------------------------
333
+
334
+ /**
335
+ * Label entry with task counts and status breakdown.
336
+ *
337
+ * Mirrors the private `LabelInfo` from `packages/core/src/tasks/labels.ts`.
338
+ *
339
+ * @task T1703
340
+ */
341
+ export interface TaskLabelInfo {
342
+ /** Label text. */
343
+ label: string;
344
+ /** Total number of tasks with this label. */
345
+ count: number;
346
+ /** Breakdown of task counts by status. */
347
+ statuses: Record<string, number>;
348
+ }
349
+
350
+ // ---------------------------------------------------------------------------
351
+ // Complexity factor (used by tasks.complexity.estimate operation)
352
+ // ---------------------------------------------------------------------------
353
+
354
+ /**
355
+ * A single factor contributing to a task's complexity score.
356
+ *
357
+ * Mirrors `ComplexityFactor` from `packages/core/src/tasks/task-ops.ts`.
358
+ *
359
+ * @task T1703
360
+ */
361
+ export interface TaskComplexityFactor {
362
+ /** Factor name (e.g. "descriptionLength", "dependencyDepth"). */
363
+ name: string;
364
+ /** Numeric score contribution from this factor. */
365
+ value: number;
366
+ /** Human-readable explanation of the score. */
367
+ detail: string;
368
+ }
369
+
370
+ // ---------------------------------------------------------------------------
371
+ // Depends result shape (used by tasks.depends operation)
372
+ // ---------------------------------------------------------------------------
373
+
374
+ /**
375
+ * A compact task reference in dependency results.
376
+ * Alias kept here for operations layer use.
377
+ */
378
+ export interface TaskDependsRef {
379
+ /** Task identifier. */
380
+ id: string;
381
+ /** Task title. */
382
+ title: string;
383
+ /** Current task status string. */
384
+ status: string;
385
+ }
386
+
387
+ /**
388
+ * Full result shape returned by `tasks.depends`.
389
+ *
390
+ * Mirrors the return of `coreTaskDepends` from `packages/core/src/tasks/task-ops.ts`.
391
+ *
392
+ * @task T1703
393
+ */
394
+ export interface TaskDependsResult {
395
+ /** The task ID whose dependencies were analyzed. */
396
+ taskId: string;
397
+ /** Direction of analysis: upstream | downstream | both. */
398
+ direction: string;
399
+ /** Tasks that this task depends on (upstream dependencies). */
400
+ upstream: TaskDependsRef[];
401
+ /** Tasks that depend on this task (downstream dependents). */
402
+ downstream: TaskDependsRef[];
403
+ /** Count of transitive unresolved dependencies. */
404
+ unresolvedChain: number;
405
+ /** Leaf-level blockers — root-cause tasks that must be resolved first. */
406
+ leafBlockers: TaskDependsRef[];
407
+ /** Whether all declared dependencies are in a terminal status. */
408
+ allDepsReady: boolean;
409
+ /** Optional hint for the next CLI command to run. @defaultValue undefined */
410
+ hint?: string;
411
+ /** Optional upstream dependency tree (only when `tree: true` was requested). @defaultValue undefined */
412
+ upstreamTree?: TaskTreeNode[];
413
+ }