@cleocode/core 2026.3.58 → 2026.3.60
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.
- package/dist/agents/agent-registry.d.ts +206 -0
- package/dist/agents/agent-registry.d.ts.map +1 -0
- package/dist/agents/agent-registry.js +288 -0
- package/dist/agents/agent-registry.js.map +1 -0
- package/dist/agents/agent-schema.js +5 -0
- package/dist/agents/agent-schema.js.map +1 -1
- package/dist/agents/execution-learning.js +474 -0
- package/dist/agents/execution-learning.js.map +1 -0
- package/dist/agents/health-monitor.d.ts +161 -0
- package/dist/agents/health-monitor.d.ts.map +1 -0
- package/dist/agents/health-monitor.js +217 -0
- package/dist/agents/health-monitor.js.map +1 -0
- package/dist/agents/index.d.ts +3 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +9 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/retry.d.ts +57 -4
- package/dist/agents/retry.d.ts.map +1 -1
- package/dist/agents/retry.js +57 -4
- package/dist/agents/retry.js.map +1 -1
- package/dist/backfill/index.d.ts +27 -0
- package/dist/backfill/index.d.ts.map +1 -1
- package/dist/backfill/index.js +229 -0
- package/dist/backfill/index.js.map +1 -0
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +135 -28
- package/dist/bootstrap.js.map +1 -1
- package/dist/cleo.d.ts +40 -0
- package/dist/cleo.d.ts.map +1 -1
- package/dist/config.js +83 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1036 -536
- package/dist/index.js.map +4 -4
- package/dist/intelligence/adaptive-validation.js +497 -0
- package/dist/intelligence/adaptive-validation.js.map +1 -0
- package/dist/intelligence/impact.d.ts +34 -1
- package/dist/intelligence/impact.d.ts.map +1 -1
- package/dist/intelligence/impact.js +176 -0
- package/dist/intelligence/impact.js.map +1 -1
- package/dist/intelligence/index.d.ts +2 -2
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +6 -1
- package/dist/intelligence/index.js.map +1 -1
- package/dist/intelligence/types.d.ts +60 -0
- package/dist/intelligence/types.d.ts.map +1 -1
- package/dist/internal.d.ts +5 -4
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +11 -2
- package/dist/internal.js.map +1 -1
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +10 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/retry.d.ts +128 -0
- package/dist/lib/retry.d.ts.map +1 -0
- package/dist/lib/retry.js +152 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/nexus/sharing/index.d.ts +48 -2
- package/dist/nexus/sharing/index.d.ts.map +1 -1
- package/dist/nexus/sharing/index.js +110 -1
- package/dist/nexus/sharing/index.js.map +1 -1
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +22 -2
- package/dist/scaffold.js.map +1 -1
- package/dist/sessions/session-enforcement.js +4 -0
- package/dist/sessions/session-enforcement.js.map +1 -1
- package/dist/stats/index.js +2 -0
- package/dist/stats/index.js.map +1 -1
- package/dist/stats/workflow-telemetry.d.ts +15 -0
- package/dist/stats/workflow-telemetry.d.ts.map +1 -1
- package/dist/stats/workflow-telemetry.js +400 -0
- package/dist/stats/workflow-telemetry.js.map +1 -0
- package/dist/store/brain-schema.js +4 -1
- package/dist/store/brain-schema.js.map +1 -1
- package/dist/store/converters.js +2 -0
- package/dist/store/converters.js.map +1 -1
- package/dist/store/cross-db-cleanup.d.ts +35 -0
- package/dist/store/cross-db-cleanup.d.ts.map +1 -1
- package/dist/store/cross-db-cleanup.js +169 -0
- package/dist/store/cross-db-cleanup.js.map +1 -0
- package/dist/store/db-helpers.js +2 -0
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/migration-sqlite.js +5 -0
- package/dist/store/migration-sqlite.js.map +1 -1
- package/dist/store/sqlite-data-accessor.js +20 -28
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.js +13 -2
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/task-store.js +4 -0
- package/dist/store/task-store.js.map +1 -1
- package/dist/store/tasks-schema.js +50 -20
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/tasks/add.js +87 -3
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +15 -4
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/enforcement.d.ts.map +1 -1
- package/dist/tasks/enforcement.js +8 -1
- package/dist/tasks/enforcement.js.map +1 -1
- package/dist/tasks/epic-enforcement.d.ts +61 -0
- package/dist/tasks/epic-enforcement.d.ts.map +1 -1
- package/dist/tasks/epic-enforcement.js +294 -0
- package/dist/tasks/epic-enforcement.js.map +1 -0
- package/dist/tasks/index.js +1 -1
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/pipeline-stage.d.ts +70 -1
- package/dist/tasks/pipeline-stage.d.ts.map +1 -1
- package/dist/tasks/pipeline-stage.js +248 -0
- package/dist/tasks/pipeline-stage.js.map +1 -0
- package/dist/tasks/update.js +28 -0
- package/dist/tasks/update.js.map +1 -1
- package/package.json +5 -5
- package/schemas/config.schema.json +37 -1547
- package/src/__tests__/sharing.test.ts +24 -0
- package/src/agents/__tests__/agent-registry.test.ts +351 -0
- package/src/agents/__tests__/health-monitor.test.ts +332 -0
- package/src/agents/agent-registry.ts +394 -0
- package/src/agents/health-monitor.ts +279 -0
- package/src/agents/index.ts +24 -1
- package/src/agents/retry.ts +57 -4
- package/src/backfill/index.ts +27 -0
- package/src/bootstrap.ts +171 -30
- package/src/cleo.ts +103 -2
- package/src/config.ts +3 -3
- package/src/index.ts +1 -0
- package/src/intelligence/__tests__/impact.test.ts +165 -1
- package/src/intelligence/impact.ts +203 -0
- package/src/intelligence/index.ts +3 -0
- package/src/intelligence/types.ts +76 -0
- package/src/internal.ts +20 -0
- package/src/lib/__tests__/retry.test.ts +321 -0
- package/src/lib/index.ts +16 -0
- package/src/lib/retry.ts +224 -0
- package/src/nexus/sharing/index.ts +142 -2
- package/src/scaffold.ts +24 -2
- package/src/stats/workflow-telemetry.ts +15 -0
- package/src/store/__tests__/session-store.test.ts +43 -7
- package/src/store/__tests__/task-store.test.ts +1 -1
- package/src/store/__tests__/test-db-helper.ts +7 -3
- package/src/store/cross-db-cleanup.ts +35 -0
- package/src/tasks/__tests__/epic-enforcement.test.ts +9 -4
- package/src/tasks/__tests__/minimal-test.test.ts +2 -2
- package/src/tasks/__tests__/update.test.ts +25 -25
- package/src/tasks/complete.ts +11 -6
- package/src/tasks/enforcement.ts +6 -3
- package/src/tasks/epic-enforcement.ts +61 -0
- package/src/tasks/pipeline-stage.ts +70 -1
- package/templates/config.template.json +5 -116
- package/templates/global-config.template.json +2 -44
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Validation module for the CLEO Intelligence dimension.
|
|
3
|
+
*
|
|
4
|
+
* Extends the prediction layer with:
|
|
5
|
+
* - Gate-level failure tracking: which verification gates fail most for which task types
|
|
6
|
+
* - Adaptive focus suggestions: recommend which gates to pay attention to given task attributes
|
|
7
|
+
* - Confidence scoring: compute and persist a 0-1 confidence score after task verification
|
|
8
|
+
* - Prediction storage: persist quality predictions back to brain as observations so
|
|
9
|
+
* subsequent sessions can learn from them
|
|
10
|
+
*
|
|
11
|
+
* All storage goes to existing brain tables (brain_observations, brain_learnings,
|
|
12
|
+
* brain_patterns). No new tables required.
|
|
13
|
+
*
|
|
14
|
+
* @task T035
|
|
15
|
+
* @epic T029
|
|
16
|
+
* @module intelligence
|
|
17
|
+
*/
|
|
18
|
+
import { randomBytes } from 'node:crypto';
|
|
19
|
+
import { predictValidationOutcome } from './prediction.js';
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Constants
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Ordered list of all supported verification gates.
|
|
25
|
+
* Order reflects typical RCASD pipeline sequence.
|
|
26
|
+
*/
|
|
27
|
+
const ALL_GATES = [
|
|
28
|
+
'implemented',
|
|
29
|
+
'testsPassed',
|
|
30
|
+
'qaPassed',
|
|
31
|
+
'cleanupDone',
|
|
32
|
+
'securityPassed',
|
|
33
|
+
'documented',
|
|
34
|
+
];
|
|
35
|
+
/** Minimum confidence threshold to consider a gate "high-risk" for focus. */
|
|
36
|
+
const GATE_RISK_THRESHOLD = 0.3;
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Adaptive Validation Gate Focus
|
|
39
|
+
// ============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Suggest which verification gates to focus on for a task, ordered by risk.
|
|
42
|
+
*
|
|
43
|
+
* Uses:
|
|
44
|
+
* - Historical failure patterns from brain_patterns filtered by task type/labels
|
|
45
|
+
* - Task characteristics (size, type, labels, priority) to weight gate risk
|
|
46
|
+
* - Existing gate state from task.verification to skip already-passed gates
|
|
47
|
+
*
|
|
48
|
+
* @param taskId - The task to analyze
|
|
49
|
+
* @param taskAccessor - DataAccessor for tasks.db
|
|
50
|
+
* @param brainAccessor - BrainDataAccessor for brain.db
|
|
51
|
+
* @returns Ordered gate focus recommendations and overall confidence
|
|
52
|
+
*/
|
|
53
|
+
export async function suggestGateFocus(taskId, taskAccessor, brainAccessor) {
|
|
54
|
+
const task = await taskAccessor.loadSingleTask(taskId);
|
|
55
|
+
if (!task) {
|
|
56
|
+
return {
|
|
57
|
+
taskId,
|
|
58
|
+
gateFocus: [],
|
|
59
|
+
overallConfidence: 0,
|
|
60
|
+
tips: [`Task ${taskId} not found — cannot generate gate focus suggestions.`],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const gateFocus = await computeGateFocusRecommendations(task, brainAccessor);
|
|
64
|
+
const overallConfidence = computeOverallConfidenceFromGates(gateFocus);
|
|
65
|
+
const tips = buildAdaptiveTips(task, gateFocus);
|
|
66
|
+
return {
|
|
67
|
+
taskId,
|
|
68
|
+
gateFocus,
|
|
69
|
+
overallConfidence: Math.round(overallConfidence * 1000) / 1000,
|
|
70
|
+
tips,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Confidence Scoring for Verification Gates
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Compute a confidence score for a completed verification round and persist
|
|
78
|
+
* it to brain.db as an observation and learning.
|
|
79
|
+
*
|
|
80
|
+
* Called after `cleo verify` gates are set. Stores:
|
|
81
|
+
* - A `brain_observations` row (type: 'discovery') with score, gates, task metadata
|
|
82
|
+
* - A `brain_learnings` row if the result is notable (high pass or high failure)
|
|
83
|
+
*
|
|
84
|
+
* @param taskId - The task that was verified
|
|
85
|
+
* @param verification - The task's current verification state
|
|
86
|
+
* @param taskAccessor - DataAccessor for tasks.db
|
|
87
|
+
* @param brainAccessor - BrainDataAccessor for brain.db
|
|
88
|
+
* @param options - Persistence and session options
|
|
89
|
+
* @returns Computed confidence score with optional persisted observation/learning IDs
|
|
90
|
+
*/
|
|
91
|
+
export async function scoreVerificationConfidence(taskId, verification, taskAccessor, brainAccessor, options = {}) {
|
|
92
|
+
const task = await taskAccessor.loadSingleTask(taskId);
|
|
93
|
+
const gatesPassed = [];
|
|
94
|
+
const gatesFailed = [];
|
|
95
|
+
for (const gate of ALL_GATES) {
|
|
96
|
+
const gateValue = verification.gates[gate];
|
|
97
|
+
if (gateValue === true) {
|
|
98
|
+
gatesPassed.push(gate);
|
|
99
|
+
}
|
|
100
|
+
else if (gateValue === false || gateValue === null) {
|
|
101
|
+
gatesFailed.push(gate);
|
|
102
|
+
}
|
|
103
|
+
// undefined gates are ignored (not required)
|
|
104
|
+
}
|
|
105
|
+
const confidenceScore = computeVerificationConfidence(verification, gatesPassed, gatesFailed);
|
|
106
|
+
if (options.dryRun) {
|
|
107
|
+
return {
|
|
108
|
+
taskId,
|
|
109
|
+
confidenceScore,
|
|
110
|
+
passed: verification.passed,
|
|
111
|
+
gatesPassed,
|
|
112
|
+
gatesFailed,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// Persist observation to brain
|
|
116
|
+
const observationId = await persistVerificationObservation(taskId, task, verification, confidenceScore, gatesPassed, gatesFailed, brainAccessor, options);
|
|
117
|
+
// Extract learning if notable
|
|
118
|
+
const learningId = await maybeExtractLearning(taskId, task, verification, confidenceScore, gatesPassed, gatesFailed, brainAccessor);
|
|
119
|
+
return {
|
|
120
|
+
taskId,
|
|
121
|
+
confidenceScore,
|
|
122
|
+
passed: verification.passed,
|
|
123
|
+
gatesPassed,
|
|
124
|
+
gatesFailed,
|
|
125
|
+
observationId,
|
|
126
|
+
learningId,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// Quality Prediction Storage
|
|
131
|
+
// ============================================================================
|
|
132
|
+
/**
|
|
133
|
+
* Store a validation prediction as a brain observation for future learning.
|
|
134
|
+
*
|
|
135
|
+
* Saves the full `ValidationPrediction` to brain_observations so that
|
|
136
|
+
* accumulated predictions can later be analyzed to improve gate pass rates.
|
|
137
|
+
*
|
|
138
|
+
* @param prediction - The prediction to persist
|
|
139
|
+
* @param brainAccessor - BrainDataAccessor for brain.db
|
|
140
|
+
* @param options - Dry-run and session options
|
|
141
|
+
* @returns The created brain observation ID (or undefined on dry run)
|
|
142
|
+
*/
|
|
143
|
+
export async function storePrediction(prediction, brainAccessor, options = {}) {
|
|
144
|
+
if (options.dryRun)
|
|
145
|
+
return undefined;
|
|
146
|
+
const id = `O-pred-${randomBytes(4).toString('hex')}`;
|
|
147
|
+
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
148
|
+
const facts = [
|
|
149
|
+
`taskId: ${prediction.taskId}`,
|
|
150
|
+
`stage: ${prediction.stage}`,
|
|
151
|
+
`passLikelihood: ${prediction.passLikelihood}`,
|
|
152
|
+
`blockers: ${prediction.blockers.length}`,
|
|
153
|
+
`suggestions: ${prediction.suggestions.length}`,
|
|
154
|
+
];
|
|
155
|
+
await brainAccessor.addObservation({
|
|
156
|
+
id,
|
|
157
|
+
type: 'discovery',
|
|
158
|
+
title: `Quality prediction: ${prediction.taskId} at ${prediction.stage} stage`,
|
|
159
|
+
subtitle: `Pass likelihood: ${Math.round(prediction.passLikelihood * 100)}%`,
|
|
160
|
+
narrative: prediction.blockers.length > 0
|
|
161
|
+
? `Blockers: ${prediction.blockers.join('; ')}`
|
|
162
|
+
: 'No blockers identified.',
|
|
163
|
+
factsJson: JSON.stringify(facts),
|
|
164
|
+
conceptsJson: JSON.stringify(['quality-prediction', 'adaptive-validation', prediction.stage]),
|
|
165
|
+
project: options.project ?? null,
|
|
166
|
+
filesReadJson: null,
|
|
167
|
+
filesModifiedJson: null,
|
|
168
|
+
sourceSessionId: options.sessionId ?? null,
|
|
169
|
+
sourceType: 'agent',
|
|
170
|
+
contentHash: null,
|
|
171
|
+
discoveryTokens: null,
|
|
172
|
+
createdAt: now,
|
|
173
|
+
updatedAt: null,
|
|
174
|
+
});
|
|
175
|
+
return id;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Compute a prediction for a task and immediately persist it to brain.
|
|
179
|
+
*
|
|
180
|
+
* Convenience wrapper combining `predictValidationOutcome` and `storePrediction`.
|
|
181
|
+
*
|
|
182
|
+
* @param taskId - The task to predict and record
|
|
183
|
+
* @param stage - The lifecycle stage being predicted
|
|
184
|
+
* @param taskAccessor - DataAccessor for tasks.db
|
|
185
|
+
* @param brainAccessor - BrainDataAccessor for brain.db
|
|
186
|
+
* @param options - Dry-run and session options
|
|
187
|
+
* @returns The prediction with optional stored observation ID
|
|
188
|
+
*/
|
|
189
|
+
export async function predictAndStore(taskId, stage, taskAccessor, brainAccessor, options = {}) {
|
|
190
|
+
const prediction = await predictValidationOutcome(taskId, stage, taskAccessor, brainAccessor);
|
|
191
|
+
const observationId = await storePrediction(prediction, brainAccessor, options);
|
|
192
|
+
return { ...prediction, observationId };
|
|
193
|
+
}
|
|
194
|
+
// ============================================================================
|
|
195
|
+
// Internal: Gate Focus Computation
|
|
196
|
+
// ============================================================================
|
|
197
|
+
async function computeGateFocusRecommendations(task, brainAccessor) {
|
|
198
|
+
const existingGates = task.verification?.gates ?? {};
|
|
199
|
+
const taskLabels = new Set((task.labels ?? []).map((l) => l.toLowerCase()));
|
|
200
|
+
const taskTitle = task.title.toLowerCase();
|
|
201
|
+
// Load failure patterns to detect which gates commonly fail for similar tasks
|
|
202
|
+
const failurePatterns = await brainAccessor.findPatterns({ type: 'failure', limit: 100 });
|
|
203
|
+
const blockerPatterns = await brainAccessor.findPatterns({ type: 'blocker', limit: 50 });
|
|
204
|
+
const allNegativePatterns = [...failurePatterns, ...blockerPatterns];
|
|
205
|
+
const recommendations = [];
|
|
206
|
+
for (const gate of ALL_GATES) {
|
|
207
|
+
// Skip gates already passed
|
|
208
|
+
if (existingGates[gate] === true)
|
|
209
|
+
continue;
|
|
210
|
+
const gateRisk = computeGateRisk(gate, task, taskLabels, taskTitle, allNegativePatterns);
|
|
211
|
+
const rationale = buildGateRationale(gate, gateRisk, task, existingGates[gate]);
|
|
212
|
+
const mitigation = findGateMitigation(gate, taskLabels, taskTitle, allNegativePatterns);
|
|
213
|
+
const priority = gateRisk >= 0.6 ? 'high' : gateRisk >= GATE_RISK_THRESHOLD ? 'medium' : 'low';
|
|
214
|
+
recommendations.push({
|
|
215
|
+
gate,
|
|
216
|
+
priority,
|
|
217
|
+
rationale: mitigation ? `${rationale} Suggestion: ${mitigation}` : rationale,
|
|
218
|
+
estimatedPassLikelihood: gateRisk > 0 ? Math.round((1 - gateRisk) * 1000) / 1000 : null,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// Sort: high first, then medium, then low; within same priority sort by risk desc
|
|
222
|
+
const priorityOrder = {
|
|
223
|
+
high: 0,
|
|
224
|
+
medium: 1,
|
|
225
|
+
low: 2,
|
|
226
|
+
};
|
|
227
|
+
recommendations.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority] ||
|
|
228
|
+
(a.estimatedPassLikelihood ?? 0.5) - (b.estimatedPassLikelihood ?? 0.5));
|
|
229
|
+
return recommendations;
|
|
230
|
+
}
|
|
231
|
+
function computeGateRisk(gate, task, taskLabels, taskTitle, negativePatterns) {
|
|
232
|
+
let risk = 0;
|
|
233
|
+
// Base risk by gate type + task attributes
|
|
234
|
+
risk += getBaseGateRisk(gate, task);
|
|
235
|
+
// Historical pattern risk: patterns that mention this gate and this task
|
|
236
|
+
let matchCount = 0;
|
|
237
|
+
let totalFailureRate = 0;
|
|
238
|
+
for (const p of negativePatterns) {
|
|
239
|
+
const patternText = p.pattern.toLowerCase();
|
|
240
|
+
const contextText = p.context.toLowerCase();
|
|
241
|
+
const gateText = gate.toLowerCase();
|
|
242
|
+
const gateMatch = patternText.includes(gateText) || contextText.includes(gateText);
|
|
243
|
+
const labelMatch = taskLabels.size > 0 &&
|
|
244
|
+
[...taskLabels].some((l) => patternText.includes(l) || contextText.includes(l));
|
|
245
|
+
const titleMatch = taskTitle
|
|
246
|
+
.split(/\s+/)
|
|
247
|
+
.filter((w) => w.length > 3)
|
|
248
|
+
.some((w) => patternText.includes(w) || contextText.includes(w));
|
|
249
|
+
if (gateMatch && (labelMatch || titleMatch)) {
|
|
250
|
+
matchCount++;
|
|
251
|
+
const failureRate = p.successRate !== null ? 1 - p.successRate : 0.5;
|
|
252
|
+
totalFailureRate += failureRate;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (matchCount > 0) {
|
|
256
|
+
const avgHistoricalFailureRate = totalFailureRate / matchCount;
|
|
257
|
+
// Blend 30% base risk, 70% historical
|
|
258
|
+
risk = risk * 0.3 + avgHistoricalFailureRate * 0.7;
|
|
259
|
+
}
|
|
260
|
+
return Math.min(Math.max(risk, 0), 1);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Intrinsic risk per gate based on task characteristics alone (no history).
|
|
264
|
+
*/
|
|
265
|
+
function getBaseGateRisk(gate, task) {
|
|
266
|
+
const size = task.size ?? 'medium';
|
|
267
|
+
const sizeFactor = size === 'large' ? 0.3 : size === 'medium' ? 0.2 : 0.1;
|
|
268
|
+
const hasAcceptance = (task.acceptance?.length ?? 0) > 0;
|
|
269
|
+
const isHighPriority = task.priority === 'critical' || task.priority === 'high';
|
|
270
|
+
switch (gate) {
|
|
271
|
+
case 'implemented':
|
|
272
|
+
// Low intrinsic risk if task is active/done
|
|
273
|
+
return task.status === 'active' ? 0.2 : 0.15;
|
|
274
|
+
case 'testsPassed':
|
|
275
|
+
// Higher risk for large tasks or tasks without acceptance criteria
|
|
276
|
+
return sizeFactor + (hasAcceptance ? 0 : 0.1) + (isHighPriority ? 0.1 : 0);
|
|
277
|
+
case 'qaPassed':
|
|
278
|
+
// Higher risk for large/complex tasks
|
|
279
|
+
return sizeFactor + (isHighPriority ? 0.15 : 0.05);
|
|
280
|
+
case 'cleanupDone':
|
|
281
|
+
// Moderate risk — often overlooked
|
|
282
|
+
return 0.15 + sizeFactor;
|
|
283
|
+
case 'securityPassed': // Security-related labels increase risk significantly
|
|
284
|
+
{
|
|
285
|
+
const securityLabels = ['auth', 'security', 'crypto', 'permission', 'access'];
|
|
286
|
+
const matchingLabels = (task.labels ?? []).filter((l) => securityLabels.includes(l.toLowerCase()));
|
|
287
|
+
// Each security-related label increases risk; 2+ labels → high risk (>= 0.6)
|
|
288
|
+
if (matchingLabels.length >= 2)
|
|
289
|
+
return 0.65;
|
|
290
|
+
if (matchingLabels.length === 1)
|
|
291
|
+
return 0.45;
|
|
292
|
+
return 0.1;
|
|
293
|
+
}
|
|
294
|
+
case 'documented':
|
|
295
|
+
// Large tasks and those with many acceptance criteria need more docs
|
|
296
|
+
return sizeFactor + ((task.acceptance?.length ?? 0) >= 3 ? 0.1 : 0);
|
|
297
|
+
default:
|
|
298
|
+
return 0.2;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function buildGateRationale(gate, risk, task, currentValue) {
|
|
302
|
+
if (currentValue === false) {
|
|
303
|
+
return `Gate "${gate}" previously failed. High priority to address before retry.`;
|
|
304
|
+
}
|
|
305
|
+
const riskPercent = Math.round(risk * 100);
|
|
306
|
+
switch (gate) {
|
|
307
|
+
case 'implemented':
|
|
308
|
+
return `Verify core implementation is complete (estimated ${riskPercent}% failure risk).`;
|
|
309
|
+
case 'testsPassed':
|
|
310
|
+
return `Confirm all tests pass; ${(task.size ?? 'medium') === 'large' ? 'large task increases test surface area. ' : ''}Estimated ${riskPercent}% failure risk.`;
|
|
311
|
+
case 'qaPassed':
|
|
312
|
+
return `QA review required${task.priority === 'critical' ? ' — critical priority task needs thorough QA' : ''}. Estimated ${riskPercent}% failure risk.`;
|
|
313
|
+
case 'cleanupDone':
|
|
314
|
+
return `Ensure code cleanup is complete (dead code, lint, formatting). Estimated ${riskPercent}% failure risk.`;
|
|
315
|
+
case 'securityPassed':
|
|
316
|
+
return `Security review${(task.labels ?? []).some((l) => ['auth', 'security'].includes(l.toLowerCase()))
|
|
317
|
+
? ' — security-related labels detected; review is high priority'
|
|
318
|
+
: ''}. Estimated ${riskPercent}% failure risk.`;
|
|
319
|
+
case 'documented':
|
|
320
|
+
return `Ensure documentation is updated. Estimated ${riskPercent}% failure risk.`;
|
|
321
|
+
default:
|
|
322
|
+
return `Gate "${gate}" check required. Estimated ${riskPercent}% failure risk.`;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function findGateMitigation(gate, taskLabels, taskTitle, negativePatterns) {
|
|
326
|
+
for (const p of negativePatterns) {
|
|
327
|
+
if (!p.mitigation)
|
|
328
|
+
continue;
|
|
329
|
+
const patternText = p.pattern.toLowerCase();
|
|
330
|
+
const contextText = p.context.toLowerCase();
|
|
331
|
+
const gateText = gate.toLowerCase();
|
|
332
|
+
const gateMatch = patternText.includes(gateText) || contextText.includes(gateText);
|
|
333
|
+
const labelMatch = taskLabels.size > 0 &&
|
|
334
|
+
[...taskLabels].some((l) => patternText.includes(l) || contextText.includes(l));
|
|
335
|
+
const titleMatch = taskTitle
|
|
336
|
+
.split(/\s+/)
|
|
337
|
+
.filter((w) => w.length > 3)
|
|
338
|
+
.some((w) => patternText.includes(w));
|
|
339
|
+
if (gateMatch && (labelMatch || titleMatch)) {
|
|
340
|
+
return p.mitigation;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
function computeOverallConfidenceFromGates(recommendations) {
|
|
346
|
+
if (recommendations.length === 0)
|
|
347
|
+
return 1.0;
|
|
348
|
+
// Weighted average: high-priority gates drag confidence down more
|
|
349
|
+
const weights = {
|
|
350
|
+
high: 3,
|
|
351
|
+
medium: 2,
|
|
352
|
+
low: 1,
|
|
353
|
+
};
|
|
354
|
+
let totalWeight = 0;
|
|
355
|
+
let weightedLikelihood = 0;
|
|
356
|
+
for (const rec of recommendations) {
|
|
357
|
+
const w = weights[rec.priority];
|
|
358
|
+
const likelihood = rec.estimatedPassLikelihood ?? 0.5;
|
|
359
|
+
totalWeight += w;
|
|
360
|
+
weightedLikelihood += likelihood * w;
|
|
361
|
+
}
|
|
362
|
+
return totalWeight > 0 ? weightedLikelihood / totalWeight : 0.5;
|
|
363
|
+
}
|
|
364
|
+
function buildAdaptiveTips(task, recommendations) {
|
|
365
|
+
const tips = [];
|
|
366
|
+
const highPriority = recommendations.filter((r) => r.priority === 'high');
|
|
367
|
+
if (highPriority.length > 0) {
|
|
368
|
+
tips.push(`Focus first on high-risk gates: ${highPriority.map((r) => r.gate).join(', ')}.`);
|
|
369
|
+
}
|
|
370
|
+
if ((task.acceptance?.length ?? 0) === 0) {
|
|
371
|
+
tips.push('Add acceptance criteria to improve gate prediction accuracy.');
|
|
372
|
+
}
|
|
373
|
+
if ((task.labels?.length ?? 0) === 0) {
|
|
374
|
+
tips.push('Adding labels will improve historical pattern matching for future predictions.');
|
|
375
|
+
}
|
|
376
|
+
const alreadyFailed = recommendations.filter((r) => r.rationale.includes('previously failed'));
|
|
377
|
+
if (alreadyFailed.length > 0) {
|
|
378
|
+
tips.push(`${alreadyFailed.length} gate(s) failed in a previous round — address these before re-running verification.`);
|
|
379
|
+
}
|
|
380
|
+
return tips;
|
|
381
|
+
}
|
|
382
|
+
// ============================================================================
|
|
383
|
+
// Internal: Confidence Score Computation
|
|
384
|
+
// ============================================================================
|
|
385
|
+
function computeVerificationConfidence(verification, gatesPassed, gatesFailed) {
|
|
386
|
+
// Component 1: Gates passed ratio (up to 0.6)
|
|
387
|
+
const totalGatesTracked = gatesPassed.length + gatesFailed.length;
|
|
388
|
+
const gateRatio = totalGatesTracked > 0 ? gatesPassed.length / totalGatesTracked : 0.5;
|
|
389
|
+
const gateScore = gateRatio * 0.6;
|
|
390
|
+
// Component 2: Failure log penalty (up to 0.2; fewer failures = higher score)
|
|
391
|
+
const failureCount = verification.failureLog?.length ?? 0;
|
|
392
|
+
// Score decreases 0.04 per logged failure, capped at 0.2 deduction
|
|
393
|
+
const failurePenalty = Math.min(failureCount * 0.04, 0.2);
|
|
394
|
+
const failureScore = 0.2 - failurePenalty;
|
|
395
|
+
// Component 3: Round penalty (up to 0.2; fewer rounds = higher score)
|
|
396
|
+
const round = verification.round ?? 1;
|
|
397
|
+
// Round 1 = full 0.2; each extra round deducts 0.05
|
|
398
|
+
const roundPenalty = Math.min((round - 1) * 0.05, 0.2);
|
|
399
|
+
const roundScore = 0.2 - roundPenalty;
|
|
400
|
+
const total = gateScore + failureScore + roundScore;
|
|
401
|
+
return Math.round(Math.min(Math.max(total, 0), 1) * 1000) / 1000;
|
|
402
|
+
}
|
|
403
|
+
// ============================================================================
|
|
404
|
+
// Internal: Brain Persistence Helpers
|
|
405
|
+
// ============================================================================
|
|
406
|
+
async function persistVerificationObservation(taskId, task, verification, confidenceScore, gatesPassed, gatesFailed, brainAccessor, options) {
|
|
407
|
+
const id = `O-vconf-${randomBytes(4).toString('hex')}`;
|
|
408
|
+
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
409
|
+
const facts = [
|
|
410
|
+
`taskId: ${taskId}`,
|
|
411
|
+
`confidenceScore: ${confidenceScore}`,
|
|
412
|
+
`passed: ${verification.passed}`,
|
|
413
|
+
`round: ${verification.round}`,
|
|
414
|
+
`gatesPassed: ${gatesPassed.join(', ') || 'none'}`,
|
|
415
|
+
`gatesFailed: ${gatesFailed.join(', ') || 'none'}`,
|
|
416
|
+
`failureLogEntries: ${verification.failureLog?.length ?? 0}`,
|
|
417
|
+
];
|
|
418
|
+
if (task) {
|
|
419
|
+
facts.push(`taskSize: ${task.size ?? 'unspecified'}`);
|
|
420
|
+
facts.push(`taskPriority: ${task.priority}`);
|
|
421
|
+
if (task.labels?.length) {
|
|
422
|
+
facts.push(`labels: ${task.labels.join(', ')}`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const title = verification.passed
|
|
426
|
+
? `Verification passed: ${taskId} (confidence: ${Math.round(confidenceScore * 100)}%)`
|
|
427
|
+
: `Verification failed: ${taskId} (confidence: ${Math.round(confidenceScore * 100)}%)`;
|
|
428
|
+
await brainAccessor.addObservation({
|
|
429
|
+
id,
|
|
430
|
+
type: 'discovery',
|
|
431
|
+
title,
|
|
432
|
+
subtitle: `Round ${verification.round} — gates: ${gatesPassed.length} passed, ${gatesFailed.length} failed`,
|
|
433
|
+
narrative: gatesFailed.length > 0
|
|
434
|
+
? `Failed gates: ${gatesFailed.join(', ')}. Consider addressing these before next round.`
|
|
435
|
+
: 'All tracked gates passed.',
|
|
436
|
+
factsJson: JSON.stringify(facts),
|
|
437
|
+
conceptsJson: JSON.stringify([
|
|
438
|
+
'verification',
|
|
439
|
+
'confidence-score',
|
|
440
|
+
'gate-tracking',
|
|
441
|
+
verification.passed ? 'pass' : 'fail',
|
|
442
|
+
]),
|
|
443
|
+
project: options.project ?? null,
|
|
444
|
+
filesReadJson: null,
|
|
445
|
+
filesModifiedJson: null,
|
|
446
|
+
sourceSessionId: options.sessionId ?? null,
|
|
447
|
+
sourceType: 'agent',
|
|
448
|
+
contentHash: null,
|
|
449
|
+
discoveryTokens: null,
|
|
450
|
+
createdAt: now,
|
|
451
|
+
updatedAt: null,
|
|
452
|
+
});
|
|
453
|
+
return id;
|
|
454
|
+
}
|
|
455
|
+
async function maybeExtractLearning(taskId, task, verification, confidenceScore, gatesPassed, gatesFailed, brainAccessor) {
|
|
456
|
+
// Only extract a learning when the result is notable:
|
|
457
|
+
// - High confidence pass (>= 0.8) on first round: positive learning
|
|
458
|
+
// - Low confidence or multiple failures: negative learning for future avoidance
|
|
459
|
+
const isNotable = (verification.passed && confidenceScore >= 0.8 && verification.round === 1) ||
|
|
460
|
+
(!verification.passed && gatesFailed.length >= 2) ||
|
|
461
|
+
(!verification.passed && (verification.failureLog?.length ?? 0) >= 3);
|
|
462
|
+
if (!isNotable)
|
|
463
|
+
return undefined;
|
|
464
|
+
const id = `L-vconf-${randomBytes(4).toString('hex')}`;
|
|
465
|
+
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
466
|
+
const taskLabels = task?.labels ?? [];
|
|
467
|
+
const taskSize = task?.size ?? 'medium';
|
|
468
|
+
const taskType = task?.type ?? 'task';
|
|
469
|
+
let insight;
|
|
470
|
+
let actionable;
|
|
471
|
+
let confidence;
|
|
472
|
+
if (verification.passed && confidenceScore >= 0.8) {
|
|
473
|
+
insight = `High-confidence verification pass for ${taskSize} ${taskType} task${taskLabels.length ? ` with labels [${taskLabels.join(', ')}]` : ''}. Pattern: ${gatesPassed.join(', ')} all passed on round ${verification.round}.`;
|
|
474
|
+
actionable = false;
|
|
475
|
+
confidence = confidenceScore;
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
insight = `Verification failure pattern: ${gatesFailed.join(', ')} failed${taskLabels.length ? ` for tasks with labels [${taskLabels.join(', ')}]` : ''}. Failures logged: ${verification.failureLog?.length ?? 0}. Address these gates early.`;
|
|
479
|
+
actionable = true;
|
|
480
|
+
confidence = Math.max(0.5, 1 - confidenceScore);
|
|
481
|
+
}
|
|
482
|
+
await brainAccessor.addLearning({
|
|
483
|
+
id,
|
|
484
|
+
insight,
|
|
485
|
+
source: `verification-confidence:${taskId}`,
|
|
486
|
+
confidence,
|
|
487
|
+
actionable,
|
|
488
|
+
application: actionable
|
|
489
|
+
? `Focus on ${gatesFailed.join(', ')} gates for similar ${taskSize} tasks`
|
|
490
|
+
: null,
|
|
491
|
+
applicableTypesJson: JSON.stringify([taskType]),
|
|
492
|
+
createdAt: now,
|
|
493
|
+
updatedAt: null,
|
|
494
|
+
});
|
|
495
|
+
return id;
|
|
496
|
+
}
|
|
497
|
+
//# sourceMappingURL=adaptive-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptive-validation.js","sourceRoot":"","sources":["../../src/intelligence/adaptive-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,SAAS,GAAuB;IACpC,aAAa;IACb,aAAa;IACb,UAAU;IACV,aAAa;IACb,gBAAgB;IAChB,YAAY;CACb,CAAC;AAEF,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAkFhC,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,YAA0B,EAC1B,aAAgC;IAEhC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;YACL,MAAM;YACN,SAAS,EAAE,EAAE;YACb,iBAAiB,EAAE,CAAC;YACpB,IAAI,EAAE,CAAC,QAAQ,MAAM,sDAAsD,C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AAC;QAClB,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,aAAa,CAAC,WAAW,CAAC;QAC9B,EAAE;QACF,OAAO;QACP,MAAM,EAAE,2BAA2B,MAAM,EAAE;QAC3C,UAAU;QACV,UAAU;QACV,WAAW,EAAE,UAAU;YACrB,CAAC,CAAC,YAAY,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,QAAQ,QAAQ;YAC1E,CAAC,CAAC,IAAI;QACR,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC/C,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* - Task impact assessment (direct + transitive dependents)
|
|
7
7
|
* - Change impact prediction (cancel, block, complete, reprioritize)
|
|
8
8
|
* - Blast radius calculation (scope quantification)
|
|
9
|
+
* - Free-text impact prediction (predictImpact) — T043
|
|
9
10
|
*
|
|
10
11
|
* @module intelligence
|
|
11
12
|
*/
|
|
12
13
|
import type { DataAccessor } from '../store/data-accessor.js';
|
|
13
|
-
import type { BlastRadius, ChangeImpact, ChangeType, ImpactAssessment } from './types.js';
|
|
14
|
+
import type { BlastRadius, ChangeImpact, ChangeType, ImpactAssessment, ImpactReport } from './types.js';
|
|
14
15
|
/**
|
|
15
16
|
* Analyze the full downstream impact of a task.
|
|
16
17
|
*
|
|
@@ -48,4 +49,36 @@ export declare function analyzeChangeImpact(taskId: string, changeType: ChangeTy
|
|
|
48
49
|
* @returns Blast radius metrics
|
|
49
50
|
*/
|
|
50
51
|
export declare function calculateBlastRadius(taskId: string, accessor?: DataAccessor, cwd?: string): Promise<BlastRadius>;
|
|
52
|
+
/**
|
|
53
|
+
* Predict the downstream impact of a free-text change description.
|
|
54
|
+
*
|
|
55
|
+
* Uses fuzzy keyword matching to identify candidate tasks that relate to
|
|
56
|
+
* the change, then walks the reverse dependency graph to enumerate all
|
|
57
|
+
* downstream tasks that may be affected.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* The matching is purely lexical (no embeddings). Tasks are ranked by
|
|
61
|
+
* how many tokens from the change description appear in their title and
|
|
62
|
+
* description. The top `matchLimit` (default: 5) matched tasks are used
|
|
63
|
+
* as seeds for downstream dependency tracing.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { predictImpact } from '@cleocode/core';
|
|
68
|
+
*
|
|
69
|
+
* const report = await predictImpact('Modify authentication flow', process.cwd());
|
|
70
|
+
* console.log(report.summary);
|
|
71
|
+
* // "3 tasks matched 'Modify authentication flow'; 7 downstream tasks affected."
|
|
72
|
+
* for (const task of report.affectedTasks) {
|
|
73
|
+
* console.log(`${task.id} (${task.exposure}): ${task.reason}`);
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param change - Free-text description of the proposed change (e.g. "Modify X")
|
|
78
|
+
* @param cwd - Working directory used to locate the tasks database
|
|
79
|
+
* @param accessor - Optional pre-created DataAccessor (useful in tests)
|
|
80
|
+
* @param matchLimit - Maximum number of seed tasks to match (default: 5)
|
|
81
|
+
* @returns Full impact prediction report
|
|
82
|
+
*/
|
|
83
|
+
export declare function predictImpact(change: string, cwd?: string, accessor?: DataAccessor, matchLimit?: number): Promise<ImpactReport>;
|
|
51
84
|
//# sourceMappingURL=impact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impact.d.ts","sourceRoot":"","sources":["../../src/intelligence/impact.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"impact.d.ts","sourceRoot":"","sources":["../../src/intelligence/impact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,OAAO,KAAK,EAEV,WAAW,EAEX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAEhB,YAAY,EACb,MAAM,YAAY,CAAC;AA6KpB;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,YAAY,EACvB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAyC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,YAAY,EACvB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,CAkDvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,YAAY,EACvB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,CAAC,CAoBtB;AA+UD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,YAAY,EACvB,UAAU,SAAI,GACb,OAAO,CAAC,YAAY,CAAC,CA2GvB"}
|