@cleocode/core 2026.3.57 → 2026.3.59

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 (136) hide show
  1. package/dist/agents/agent-registry.d.ts +206 -0
  2. package/dist/agents/agent-registry.d.ts.map +1 -0
  3. package/dist/agents/agent-schema.d.ts.map +1 -1
  4. package/dist/agents/execution-learning.d.ts +223 -0
  5. package/dist/agents/execution-learning.d.ts.map +1 -0
  6. package/dist/agents/health-monitor.d.ts +161 -0
  7. package/dist/agents/health-monitor.d.ts.map +1 -0
  8. package/dist/agents/index.d.ts +4 -1
  9. package/dist/agents/index.d.ts.map +1 -1
  10. package/dist/agents/retry.d.ts +57 -4
  11. package/dist/agents/retry.d.ts.map +1 -1
  12. package/dist/backfill/index.d.ts +83 -0
  13. package/dist/backfill/index.d.ts.map +1 -0
  14. package/dist/bootstrap.d.ts +1 -1
  15. package/dist/config.d.ts +47 -0
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +6985 -5068
  20. package/dist/index.js.map +4 -4
  21. package/dist/intelligence/adaptive-validation.d.ts +151 -0
  22. package/dist/intelligence/adaptive-validation.d.ts.map +1 -0
  23. package/dist/intelligence/impact.d.ts +34 -1
  24. package/dist/intelligence/impact.d.ts.map +1 -1
  25. package/dist/intelligence/index.d.ts +7 -2
  26. package/dist/intelligence/index.d.ts.map +1 -1
  27. package/dist/intelligence/types.d.ts +60 -0
  28. package/dist/intelligence/types.d.ts.map +1 -1
  29. package/dist/internal.d.ts +8 -4
  30. package/dist/internal.d.ts.map +1 -1
  31. package/dist/lib/index.d.ts +10 -0
  32. package/dist/lib/index.d.ts.map +1 -0
  33. package/dist/lib/retry.d.ts +128 -0
  34. package/dist/lib/retry.d.ts.map +1 -0
  35. package/dist/nexus/sharing/index.d.ts +48 -2
  36. package/dist/nexus/sharing/index.d.ts.map +1 -1
  37. package/dist/sessions/session-enforcement.d.ts.map +1 -1
  38. package/dist/stats/index.d.ts +1 -0
  39. package/dist/stats/index.d.ts.map +1 -1
  40. package/dist/stats/workflow-telemetry.d.ts +89 -0
  41. package/dist/stats/workflow-telemetry.d.ts.map +1 -0
  42. package/dist/store/brain-schema.d.ts.map +1 -1
  43. package/dist/store/converters.d.ts.map +1 -1
  44. package/dist/store/cross-db-cleanup.d.ts +93 -0
  45. package/dist/store/cross-db-cleanup.d.ts.map +1 -0
  46. package/dist/store/db-helpers.d.ts.map +1 -1
  47. package/dist/store/migration-sqlite.d.ts.map +1 -1
  48. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  49. package/dist/store/sqlite.d.ts.map +1 -1
  50. package/dist/store/task-store.d.ts.map +1 -1
  51. package/dist/store/tasks-schema.d.ts +18 -3
  52. package/dist/store/tasks-schema.d.ts.map +1 -1
  53. package/dist/store/validation-schemas.d.ts +32 -0
  54. package/dist/store/validation-schemas.d.ts.map +1 -1
  55. package/dist/tasks/add.d.ts +10 -1
  56. package/dist/tasks/add.d.ts.map +1 -1
  57. package/dist/tasks/complete.d.ts.map +1 -1
  58. package/dist/tasks/enforcement.d.ts +22 -0
  59. package/dist/tasks/enforcement.d.ts.map +1 -0
  60. package/dist/tasks/epic-enforcement.d.ts +199 -0
  61. package/dist/tasks/epic-enforcement.d.ts.map +1 -0
  62. package/dist/tasks/index.d.ts +1 -1
  63. package/dist/tasks/index.d.ts.map +1 -1
  64. package/dist/tasks/pipeline-stage.d.ts +181 -0
  65. package/dist/tasks/pipeline-stage.d.ts.map +1 -0
  66. package/dist/tasks/update.d.ts +2 -0
  67. package/dist/tasks/update.d.ts.map +1 -1
  68. package/migrations/drizzle-brain/20260321000001_t033-brain-indexes/migration.sql +12 -0
  69. package/migrations/drizzle-brain/20260321000001_t033-brain-indexes/snapshot.json +1232 -0
  70. package/migrations/drizzle-tasks/20260321000000_t033-connection-health/migration.sql +518 -0
  71. package/migrations/drizzle-tasks/20260321000000_t033-connection-health/snapshot.json +4312 -0
  72. package/migrations/drizzle-tasks/20260321000002_t060-pipeline-stage-binding/migration.sql +82 -0
  73. package/migrations/drizzle-tasks/20260321000002_t060-pipeline-stage-binding/snapshot.json +9 -0
  74. package/package.json +5 -5
  75. package/schemas/config.schema.json +37 -1547
  76. package/src/__tests__/sharing.test.ts +24 -0
  77. package/src/agents/__tests__/agent-registry.test.ts +351 -0
  78. package/src/agents/__tests__/execution-learning.test.ts +684 -0
  79. package/src/agents/__tests__/health-monitor.test.ts +332 -0
  80. package/src/agents/__tests__/registry.test.ts +30 -2
  81. package/src/agents/agent-registry.ts +394 -0
  82. package/src/agents/agent-schema.ts +5 -0
  83. package/src/agents/execution-learning.ts +675 -0
  84. package/src/agents/health-monitor.ts +279 -0
  85. package/src/agents/index.ts +37 -1
  86. package/src/agents/retry.ts +57 -4
  87. package/src/backfill/index.ts +309 -0
  88. package/src/bootstrap.ts +1 -1
  89. package/src/config.ts +126 -0
  90. package/src/index.ts +8 -1
  91. package/src/intelligence/__tests__/adaptive-validation.test.ts +694 -0
  92. package/src/intelligence/__tests__/impact.test.ts +165 -1
  93. package/src/intelligence/adaptive-validation.ts +764 -0
  94. package/src/intelligence/impact.ts +203 -0
  95. package/src/intelligence/index.ts +19 -0
  96. package/src/intelligence/types.ts +76 -0
  97. package/src/internal.ts +39 -0
  98. package/src/lib/__tests__/retry.test.ts +321 -0
  99. package/src/lib/index.ts +16 -0
  100. package/src/lib/retry.ts +224 -0
  101. package/src/lifecycle/__tests__/chain-store.test.ts +7 -0
  102. package/src/lifecycle/__tests__/tessera-engine.test.ts +52 -0
  103. package/src/nexus/sharing/index.ts +142 -2
  104. package/src/sessions/__tests__/session-edge-cases.test.ts +24 -1
  105. package/src/sessions/session-enforcement.ts +13 -2
  106. package/src/stats/index.ts +7 -0
  107. package/src/stats/workflow-telemetry.ts +502 -0
  108. package/src/store/__tests__/migration-safety.test.ts +3 -0
  109. package/src/store/__tests__/session-store.test.ts +132 -1
  110. package/src/store/__tests__/task-store.test.ts +22 -1
  111. package/src/store/__tests__/test-db-helper.ts +29 -2
  112. package/src/store/brain-schema.ts +4 -1
  113. package/src/store/converters.ts +2 -0
  114. package/src/store/cross-db-cleanup.ts +192 -0
  115. package/src/store/db-helpers.ts +2 -0
  116. package/src/store/migration-sqlite.ts +6 -0
  117. package/src/store/sqlite-data-accessor.ts +20 -28
  118. package/src/store/sqlite.ts +14 -2
  119. package/src/store/task-store.ts +6 -0
  120. package/src/store/tasks-schema.ts +59 -20
  121. package/src/tasks/__tests__/add.test.ts +16 -0
  122. package/src/tasks/__tests__/complete-unblocks.test.ts +10 -1
  123. package/src/tasks/__tests__/complete.test.ts +11 -2
  124. package/src/tasks/__tests__/epic-enforcement.test.ts +909 -0
  125. package/src/tasks/__tests__/minimal-test.test.ts +28 -0
  126. package/src/tasks/__tests__/pipeline-stage.test.ts +403 -0
  127. package/src/tasks/__tests__/update.test.ts +40 -6
  128. package/src/tasks/add.ts +128 -2
  129. package/src/tasks/complete.ts +29 -17
  130. package/src/tasks/enforcement.ts +127 -0
  131. package/src/tasks/epic-enforcement.ts +364 -0
  132. package/src/tasks/index.ts +1 -0
  133. package/src/tasks/pipeline-stage.ts +293 -0
  134. package/src/tasks/update.ts +62 -0
  135. package/templates/config.template.json +34 -111
  136. package/templates/global-config.template.json +24 -40
@@ -9,6 +9,7 @@ import type { Task, TaskPriority, TaskSize, TaskStatus, TaskType } from '@cleoco
9
9
  import { ExitCode } from '@cleocode/contracts';
10
10
  import { loadConfig } from '../config.js';
11
11
  import { CleoError } from '../errors.js';
12
+ import { requireActiveSession } from '../sessions/session-enforcement.js';
12
13
  import type { DataAccessor } from '../store/data-accessor.js';
13
14
  import { getAccessor } from '../store/data-accessor.js';
14
15
  import {
@@ -20,7 +21,14 @@ import {
20
21
  validateTitle,
21
22
  } from './add.js';
22
23
  import { completeTask } from './complete.js';
24
+ import { createAcceptanceEnforcement } from './enforcement.js';
25
+ import {
26
+ findEpicAncestor,
27
+ validateChildStageCeiling,
28
+ validateEpicStageAdvancement,
29
+ } from './epic-enforcement.js';
23
30
  import { resolveHierarchyPolicy } from './hierarchy-policy.js';
31
+ import { validatePipelineTransition } from './pipeline-stage.js';
24
32
 
25
33
  const NON_STATUS_DONE_FIELDS: Array<keyof Omit<UpdateTaskOptions, 'taskId' | 'status'>> = [
26
34
  'title',
@@ -41,6 +49,7 @@ const NON_STATUS_DONE_FIELDS: Array<keyof Omit<UpdateTaskOptions, 'taskId' | 'st
41
49
  'blockedBy',
42
50
  'parentId',
43
51
  'noAutoComplete',
52
+ 'pipelineStage',
44
53
  ];
45
54
 
46
55
  function hasNonStatusDoneFields(options: UpdateTaskOptions): boolean {
@@ -69,6 +78,8 @@ export interface UpdateTaskOptions {
69
78
  blockedBy?: string;
70
79
  parentId?: string | null;
71
80
  noAutoComplete?: boolean;
81
+ /** RCASD-IVTR+C pipeline stage transition target. Must be >= current stage. @task T060 */
82
+ pipelineStage?: string;
72
83
  }
73
84
 
74
85
  /** Result of updating a task. */
@@ -93,6 +104,9 @@ export async function updateTask(
93
104
  fix: `Use 'cleo find "${options.taskId}"' to search`,
94
105
  });
95
106
  }
107
+
108
+ await requireActiveSession('tasks.update', cwd);
109
+
96
110
  const changes: string[] = [];
97
111
  const now = new Date().toISOString();
98
112
 
@@ -114,6 +128,17 @@ export async function updateTask(
114
128
  );
115
129
  }
116
130
 
131
+ // Enforce Acceptance Criteria on Update
132
+ const enforcement = await createAcceptanceEnforcement(cwd);
133
+ const updateValidation = enforcement.validateUpdate(task, { acceptance: options.acceptance });
134
+ if (!updateValidation.valid) {
135
+ throw new CleoError(
136
+ updateValidation.exitCode ?? ExitCode.VALIDATION_ERROR,
137
+ updateValidation.error!,
138
+ { fix: updateValidation.fix },
139
+ );
140
+ }
141
+
117
142
  // Update fields
118
143
  if (options.title !== undefined) {
119
144
  validateTitle(options.title);
@@ -230,6 +255,43 @@ export async function updateTask(
230
255
  changes.push('noAutoComplete');
231
256
  }
232
257
 
258
+ // Pipeline stage transition — forward-only (T060)
259
+ if (options.pipelineStage !== undefined) {
260
+ validatePipelineTransition(task.pipelineStage, options.pipelineStage);
261
+
262
+ // Epic stage advancement gate (T062): block advancement if children are in-flight
263
+ // at the current stage.
264
+ if (task.type === 'epic' && task.pipelineStage) {
265
+ await validateEpicStageAdvancement(
266
+ {
267
+ epicId: task.id,
268
+ currentStage: task.pipelineStage,
269
+ newStage: options.pipelineStage,
270
+ },
271
+ acc,
272
+ cwd,
273
+ );
274
+ }
275
+
276
+ // Child stage ceiling (T062): non-epic tasks cannot advance past their epic ancestor.
277
+ if (task.type !== 'epic') {
278
+ const epicAncestor = task.parentId ? await findEpicAncestor(task.parentId, acc) : null;
279
+ // Also check if the direct parent is an epic
280
+ const directParent = task.parentId ? await acc.loadSingleTask(task.parentId) : null;
281
+ const epicToCheck = directParent?.type === 'epic' ? directParent : epicAncestor;
282
+ if (epicToCheck) {
283
+ await validateChildStageCeiling(
284
+ { childStage: options.pipelineStage, epicId: epicToCheck.id },
285
+ acc,
286
+ cwd,
287
+ );
288
+ }
289
+ }
290
+
291
+ task.pipelineStage = options.pipelineStage;
292
+ changes.push('pipelineStage');
293
+ }
294
+
233
295
  // Handle parentId change (reparent) using targeted queries
234
296
  // Supports: parentId="T001" to set parent, parentId=null or parentId="" to promote to root
235
297
  if (options.parentId !== undefined) {
@@ -16,48 +16,46 @@
16
16
  "autoArchiveOnComplete": false
17
17
  },
18
18
 
19
- "logging": {
19
+ "enforcement": {
20
+ "acceptance": {
21
+ "mode": "block",
22
+ "requiredForPriorities": ["critical", "high", "medium", "low"],
23
+ "minimumCriteria": 3
24
+ },
25
+ "session": {
26
+ "requiredForMutate": true
27
+ },
28
+ "pipeline": {
29
+ "bindTasksToStage": true
30
+ }
31
+ },
32
+
33
+ "verification": {
20
34
  "enabled": true,
21
- "retentionDays": 30,
22
- "level": "standard",
23
- "logSessionEvents": true
35
+ "requiredForTypes": ["epic", "task", "subtask"],
36
+ "autoInitialize": true,
37
+ "maxRounds": 5,
38
+ "requiredGates": ["implemented", "testsPassed", "qaPassed"],
39
+ "autoSetImplementedOnComplete": true,
40
+ "requireForParentAutoComplete": true,
41
+ "allowManualOverride": true
24
42
  },
25
43
 
26
- "validation": {
27
- "strictMode": false,
28
- "checksumEnabled": true,
29
- "enforceAcceptance": true,
30
- "requireDescription": false,
31
- "maxActiveTasks": 1,
32
- "validateDependencies": true,
33
- "detectCircularDeps": true
44
+ "lifecycle": {
45
+ "mode": "strict"
34
46
  },
35
47
 
36
- "defaults": {
37
- "priority": "medium",
38
- "phase": "core",
39
- "labels": []
48
+ "hierarchy": {
49
+ "maxDepth": 3,
50
+ "maxSiblings": 0
40
51
  },
41
52
 
42
- "session": {
43
- "requireSession": true,
44
- "requireSessionNote": true,
45
- "requireNotesOnComplete": true,
46
- "warnOnNoFocus": true,
47
- "allowNestedSessions": true,
48
- "allowParallelAgents": true,
49
- "autoStartSession": true,
50
- "autoDiscoveryOnStart": true,
51
- "sessionTimeoutHours": 72
53
+ "defaults": {
54
+ "priority": "medium"
52
55
  },
53
56
 
54
- "multiSession": {
55
- "enabled": true,
56
- "maxConcurrentSessions": 5,
57
- "maxActiveTasksPerScope": 1,
58
- "scopeValidation": "strict",
59
- "allowNestedScopes": true,
60
- "allowScopeOverlap": false
57
+ "session": {
58
+ "enforcement": "strict"
61
59
  },
62
60
 
63
61
  "release": {
@@ -70,43 +68,12 @@
70
68
  }
71
69
  },
72
70
 
73
- "display": {
74
- "showArchiveCount": true,
75
- "showLogSummary": true,
76
- "warnStaleDays": 30
77
- },
78
-
79
71
  "output": {
80
72
  "defaultFormat": "text",
81
73
  "showColor": true,
82
74
  "showUnicode": true,
83
75
  "showProgressBars": true,
84
- "csvDelimiter": ",",
85
- "dateFormat": "iso8601",
86
- "showCompactTitles": false,
87
- "maxTitleLength": 80
88
- },
89
-
90
- "cli": {
91
- "aliases": {
92
- "ls": "list",
93
- "done": "complete",
94
- "new": "add",
95
- "edit": "update",
96
- "rm": "archive",
97
- "check": "validate"
98
- },
99
- "plugins": {
100
- "enabled": true,
101
- "directories": ["~/.cleo/plugins", "./.cleo/plugins"],
102
- "autoDiscover": true
103
- },
104
- "debug": {
105
- "enabled": true,
106
- "validateMappings": true,
107
- "checksumVerify": true,
108
- "showTimings": false
109
- }
76
+ "dateFormat": "iso8601"
110
77
  },
111
78
 
112
79
  "backup": {
@@ -119,17 +86,8 @@
119
86
  "safetyRetentionDays": 7
120
87
  },
121
88
 
122
- "cancellation": {
123
- "cascadeConfirmThreshold": 10,
124
- "requireReason": true,
125
- "daysUntilArchive": 3,
126
- "allowCascade": true,
127
- "defaultChildStrategy": "block"
128
- },
129
-
130
89
  "contextAlerts": {
131
90
  "enabled": true,
132
- "minThreshold": "warning",
133
91
  "triggerCommands": ["complete", "start", "stop", "add", "session"],
134
92
  "suppressDuration": 0
135
93
  },
@@ -138,50 +96,15 @@
138
96
  "contextThresholds": {
139
97
  "warning": 70,
140
98
  "critical": 80
141
- },
142
- "autoStopOnCritical": true,
143
- "hitlSummaryOnPause": true
99
+ }
144
100
  },
145
101
 
146
102
  "agentOutputs": {
147
103
  "directory": ".cleo/agent-outputs",
148
- "manifestFile": "MANIFEST.jsonl",
149
- "archiveDir": "archive",
150
- "archiveDays": 30
104
+ "manifestFile": "MANIFEST.jsonl"
151
105
  },
152
106
 
153
107
  "retention": {
154
- "maxArchivedSessions": 100,
155
- "autoArchiveEndedAfterDays": 30,
156
- "autoDeleteArchivedAfterDays": 90,
157
- "contextStateRetentionDays": 7,
158
- "cleanupOnSessionEnd": true,
159
- "dryRunByDefault": true,
160
- "maxSessionsInMemory": 100,
161
108
  "autoEndActiveAfterDays": 7
162
- },
163
-
164
- "project": {
165
- "status": {
166
- "health": "unknown",
167
- "lastCheck": null,
168
- "schemaVersions": {
169
- "todo": "{{SCHEMA_VERSION_TODO}}",
170
- "config": "{{SCHEMA_VERSION_CONFIG}}",
171
- "archive": "{{SCHEMA_VERSION_ARCHIVE}}",
172
- "log": "{{SCHEMA_VERSION_LOG}}"
173
- },
174
- "validation": {
175
- "lastValidated": null,
176
- "passed": false,
177
- "errors": [],
178
- "warnings": []
179
- },
180
- "injection": {
181
- "CLAUDE.md": "not_found",
182
- "AGENTS.md": "not_found",
183
- "GEMINI.md": "not_found"
184
- }
185
- }
186
109
  }
187
110
  }
@@ -6,51 +6,35 @@
6
6
  "showColor": true,
7
7
  "showUnicode": true,
8
8
  "showProgressBars": true,
9
- "dateFormat": "iso8601",
10
- "showCompactTitles": false,
11
- "maxTitleLength": 80
9
+ "dateFormat": "iso8601"
12
10
  },
13
- "display": {
14
- "showArchiveCount": true,
15
- "showLogSummary": true,
16
- "warnStaleDays": 30
17
- },
18
- "cli": {
19
- "aliases": {
20
- "ls": "list",
21
- "done": "complete",
22
- "new": "add",
23
- "edit": "update",
24
- "rm": "archive",
25
- "check": "validate",
26
- "tags": "labels",
27
- "overview": "dash"
11
+ "enforcement": {
12
+ "acceptance": {
13
+ "mode": "block",
14
+ "requiredForPriorities": ["critical", "high", "medium", "low"],
15
+ "minimumCriteria": 3
28
16
  },
29
- "plugins": {
30
- "enabled": true,
31
- "directories": [
32
- "~/.cleo/plugins",
33
- "./.cleo/plugins"
34
- ],
35
- "autoDiscover": true
17
+ "session": {
18
+ "requiredForMutate": true
36
19
  },
37
- "debug": {
38
- "enabled": false,
39
- "validateMappings": true,
40
- "checksumVerify": true,
41
- "showTimings": false
20
+ "pipeline": {
21
+ "bindTasksToStage": true
42
22
  }
43
23
  },
44
- "defaults": {
45
- "priority": "medium",
46
- "labels": []
47
- },
48
- "multiSession": {
24
+ "verification": {
49
25
  "enabled": true,
50
- "maxConcurrentSessions": 5,
51
- "maxActiveTasksPerScope": 1,
52
- "scopeValidation": "strict",
53
- "allowNestedScopes": true,
54
- "allowScopeOverlap": false
26
+ "requiredForTypes": ["epic", "task", "subtask"],
27
+ "autoInitialize": true,
28
+ "maxRounds": 5,
29
+ "requiredGates": ["implemented", "testsPassed", "qaPassed"],
30
+ "autoSetImplementedOnComplete": true,
31
+ "requireForParentAutoComplete": true,
32
+ "allowManualOverride": true
33
+ },
34
+ "lifecycle": {
35
+ "mode": "strict"
36
+ },
37
+ "defaults": {
38
+ "priority": "medium"
55
39
  }
56
40
  }