@miller-tech/uap 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/bin/cli.js +5 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/deliver.d.ts +5 -0
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +91 -10
- package/dist/cli/deliver.js.map +1 -1
- package/dist/delivery/applier.d.ts +11 -0
- package/dist/delivery/applier.d.ts.map +1 -1
- package/dist/delivery/applier.js +189 -6
- package/dist/delivery/applier.js.map +1 -1
- package/dist/delivery/convergence-loop.d.ts +75 -13
- package/dist/delivery/convergence-loop.d.ts.map +1 -1
- package/dist/delivery/convergence-loop.js +209 -58
- package/dist/delivery/convergence-loop.js.map +1 -1
- package/dist/delivery/critic.d.ts +35 -0
- package/dist/delivery/critic.d.ts.map +1 -0
- package/dist/delivery/critic.js +77 -0
- package/dist/delivery/critic.js.map +1 -0
- package/dist/delivery/escalation.d.ts +66 -0
- package/dist/delivery/escalation.d.ts.map +1 -0
- package/dist/delivery/escalation.js +84 -0
- package/dist/delivery/escalation.js.map +1 -0
- package/dist/delivery/explorer.d.ts +77 -0
- package/dist/delivery/explorer.d.ts.map +1 -0
- package/dist/delivery/explorer.js +166 -0
- package/dist/delivery/explorer.js.map +1 -0
- package/dist/delivery/index.d.ts +7 -2
- package/dist/delivery/index.d.ts.map +1 -1
- package/dist/delivery/index.js +6 -1
- package/dist/delivery/index.js.map +1 -1
- package/dist/delivery/judge.d.ts +33 -0
- package/dist/delivery/judge.d.ts.map +1 -0
- package/dist/delivery/judge.js +70 -0
- package/dist/delivery/judge.js.map +1 -0
- package/dist/delivery/practice.d.ts +72 -0
- package/dist/delivery/practice.d.ts.map +1 -0
- package/dist/delivery/practice.js +185 -0
- package/dist/delivery/practice.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Convergence Loop
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Drives an underlying model through execute → apply → verify → feedback
|
|
5
|
+
* iterations until the project's completion gates (verifier ladder) pass or
|
|
6
|
+
* the turn budget is exhausted.
|
|
7
7
|
*
|
|
8
|
-
* The loop owns
|
|
9
|
-
* changes:
|
|
8
|
+
* The loop owns pluggable seams so phases extend without breaking changes:
|
|
10
9
|
* - executor: how a prompt becomes model output
|
|
11
10
|
* - applier: how model output is materialized into the project tree
|
|
12
|
-
* - promptBuilder: how instruction/feedback/
|
|
13
|
-
*
|
|
14
|
-
* -
|
|
15
|
-
*
|
|
11
|
+
* - promptBuilder: how instruction/feedback/critique compose a prompt
|
|
12
|
+
* - ladderRunner: how gates are verified
|
|
13
|
+
* - explorer (Phase 2): best-of-N candidate exploration with judge tie-break
|
|
14
|
+
* - critic (Phase 3): structured repair plans replacing raw gate dumps
|
|
15
|
+
* - onIteration: per-turn control hook (Phase 5 escalation controllers)
|
|
16
16
|
*/
|
|
17
17
|
import { detectRungs, runLadder } from './verifier-ladder.js';
|
|
18
18
|
import { applyFileBlocks } from './applier.js';
|
|
19
|
+
import { exploreAndCommit } from './explorer.js';
|
|
19
20
|
const DEFAULT_MAX_TURNS = 5;
|
|
20
21
|
const DEFAULT_PREVIOUS_OUTPUT_CHARS = 3_000;
|
|
21
22
|
const OUTPUT_CONTRACT = [
|
|
@@ -34,12 +35,28 @@ function truncateHead(text, maxChars) {
|
|
|
34
35
|
return text;
|
|
35
36
|
return `${text.slice(0, maxChars)}\n…(truncated)…`;
|
|
36
37
|
}
|
|
38
|
+
/** Coerce the onIteration return (void | 'stop' | directive) to a directive. */
|
|
39
|
+
function normalizeDirective(value) {
|
|
40
|
+
if (value === 'stop')
|
|
41
|
+
return { stop: true };
|
|
42
|
+
if (!value)
|
|
43
|
+
return {};
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
/** Render retrieved best-practice cards as a prompt section. */
|
|
47
|
+
function practiceSection(practices) {
|
|
48
|
+
if (!practices || practices.length === 0)
|
|
49
|
+
return [];
|
|
50
|
+
const lines = ['', 'PROVEN PRACTICES for tasks like this — follow them:'];
|
|
51
|
+
practices.forEach((p, i) => lines.push(`${i + 1}. ${p}`));
|
|
52
|
+
return lines;
|
|
53
|
+
}
|
|
37
54
|
/** Default prompt strategy: lean contract + structured retry context. */
|
|
38
55
|
export const defaultPromptBuilder = (ctx) => {
|
|
39
56
|
if (ctx.turn === 1) {
|
|
40
|
-
return [OUTPUT_CONTRACT, '', `TASK: ${ctx.instruction}`].join('\n');
|
|
57
|
+
return [OUTPUT_CONTRACT, ...practiceSection(ctx.practices), '', `TASK: ${ctx.instruction}`].join('\n');
|
|
41
58
|
}
|
|
42
|
-
const sections = [OUTPUT_CONTRACT, '', `TASK: ${ctx.instruction}`, ''];
|
|
59
|
+
const sections = [OUTPUT_CONTRACT, ...practiceSection(ctx.practices), '', `TASK: ${ctx.instruction}`, ''];
|
|
43
60
|
sections.push(`PREVIOUS ATTEMPT (turn ${ctx.turn - 1}):`);
|
|
44
61
|
if (ctx.previousFiles && ctx.previousFiles.length > 0) {
|
|
45
62
|
sections.push(`Files you emitted: ${ctx.previousFiles.join(', ')}`);
|
|
@@ -47,7 +64,15 @@ export const defaultPromptBuilder = (ctx) => {
|
|
|
47
64
|
if (ctx.applyError) {
|
|
48
65
|
sections.push(`Your output could not be applied: ${ctx.applyError}`);
|
|
49
66
|
}
|
|
67
|
+
// A structured repair plan outranks the raw gate dump: one concrete action
|
|
68
|
+
// per line is what small models can actually execute.
|
|
69
|
+
if (ctx.critique && ctx.critique.length > 0) {
|
|
70
|
+
sections.push('');
|
|
71
|
+
sections.push('REPAIR PLAN — apply these fixes exactly:');
|
|
72
|
+
ctx.critique.forEach((step, i) => sections.push(`${i + 1}. ${step}`));
|
|
73
|
+
}
|
|
50
74
|
if (ctx.feedback) {
|
|
75
|
+
sections.push('');
|
|
51
76
|
sections.push(ctx.feedback);
|
|
52
77
|
}
|
|
53
78
|
if (ctx.previousOutput) {
|
|
@@ -72,6 +97,100 @@ export class ConvergenceLoop {
|
|
|
72
97
|
this.applier = seams.applier ?? applyFileBlocks;
|
|
73
98
|
this.promptBuilder = seams.promptBuilder ?? defaultPromptBuilder;
|
|
74
99
|
}
|
|
100
|
+
/** Single-candidate turn: execute → apply → verify. */
|
|
101
|
+
async runSingleTurn(prompt, rungs, executor) {
|
|
102
|
+
let output = '';
|
|
103
|
+
let executorError;
|
|
104
|
+
try {
|
|
105
|
+
output = await executor(prompt);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
executorError = err instanceof Error ? err.message : String(err);
|
|
109
|
+
}
|
|
110
|
+
let applyResult = null;
|
|
111
|
+
let applyError;
|
|
112
|
+
if (!executorError) {
|
|
113
|
+
applyResult = await this.applier(output, this.config.projectRoot);
|
|
114
|
+
if (applyResult.error) {
|
|
115
|
+
applyError = applyResult.error;
|
|
116
|
+
}
|
|
117
|
+
else if (applyResult.rejected.length > 0) {
|
|
118
|
+
applyError = `Rejected blocks: ${applyResult.rejected
|
|
119
|
+
.map((r) => `${r.path} (${r.reason})`)
|
|
120
|
+
.join('; ')}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Verify — only when something was applied; otherwise the tree is
|
|
124
|
+
// unchanged and re-running gates would waste minutes for no signal.
|
|
125
|
+
const filesApplied = applyResult?.filesWritten ?? [];
|
|
126
|
+
let ladder = null;
|
|
127
|
+
if (!executorError && filesApplied.length > 0) {
|
|
128
|
+
ladder = await this.ladderRunner(rungs, this.config.projectRoot, this.config.ladderOptions);
|
|
129
|
+
}
|
|
130
|
+
return { output, filesApplied, ladder, executorError, applyError };
|
|
131
|
+
}
|
|
132
|
+
/** Explorer turn: best-of-N candidates, commit the winner (Phase 2). */
|
|
133
|
+
async runExplorerTurn(instruction, prompt, rungs, settings, executor) {
|
|
134
|
+
const exploration = await exploreAndCommit(instruction, prompt, executor, {
|
|
135
|
+
candidates: settings.candidates,
|
|
136
|
+
seeds: settings.seeds,
|
|
137
|
+
judge: settings.judge,
|
|
138
|
+
projectRoot: this.config.projectRoot,
|
|
139
|
+
rungs,
|
|
140
|
+
ladderOptions: this.config.ladderOptions,
|
|
141
|
+
ladderRunner: this.ladderRunner,
|
|
142
|
+
});
|
|
143
|
+
const summaries = exploration.candidates.map((c) => ({
|
|
144
|
+
id: c.id,
|
|
145
|
+
strategy: c.strategy,
|
|
146
|
+
passed: c.passed,
|
|
147
|
+
score: c.score,
|
|
148
|
+
error: c.error,
|
|
149
|
+
}));
|
|
150
|
+
const winner = exploration.winner;
|
|
151
|
+
if (!winner) {
|
|
152
|
+
// Distinguish executor failure (no usable model output) from apply
|
|
153
|
+
// failure (output produced but no file blocks) so the retry prompt
|
|
154
|
+
// carries the right guidance — matching single-turn feedback quality.
|
|
155
|
+
const execErrors = exploration.candidates.map((c) => c.error).filter(Boolean);
|
|
156
|
+
if (execErrors.length === exploration.candidates.length && execErrors.length > 0) {
|
|
157
|
+
return {
|
|
158
|
+
output: '',
|
|
159
|
+
filesApplied: [],
|
|
160
|
+
ladder: null,
|
|
161
|
+
executorError: execErrors.join('; '),
|
|
162
|
+
candidates: summaries,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const applyErr = exploration.candidates.map((c) => c.applyResult?.error).find(Boolean) ??
|
|
166
|
+
'No candidate produced applicable file blocks.';
|
|
167
|
+
return {
|
|
168
|
+
output: '',
|
|
169
|
+
filesApplied: [],
|
|
170
|
+
ladder: null,
|
|
171
|
+
applyError: applyErr,
|
|
172
|
+
candidates: summaries,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
let applyError;
|
|
176
|
+
if (winner.applyResult?.error) {
|
|
177
|
+
applyError = winner.applyResult.error;
|
|
178
|
+
}
|
|
179
|
+
else if (winner.applyResult && winner.applyResult.rejected.length > 0) {
|
|
180
|
+
applyError = `Rejected blocks: ${winner.applyResult.rejected
|
|
181
|
+
.map((r) => `${r.path} (${r.reason})`)
|
|
182
|
+
.join('; ')}`;
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
output: winner.output,
|
|
186
|
+
filesApplied: winner.applyResult?.filesWritten ?? [],
|
|
187
|
+
ladder: exploration.ladder,
|
|
188
|
+
applyError,
|
|
189
|
+
strategy: winner.strategy,
|
|
190
|
+
candidates: summaries,
|
|
191
|
+
judgeRationale: exploration.judgeRationale,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
75
194
|
/**
|
|
76
195
|
* Run the loop for an instruction until all required gates pass or the
|
|
77
196
|
* turn budget is exhausted. Returns the full iteration history so callers
|
|
@@ -79,16 +198,21 @@ export class ConvergenceLoop {
|
|
|
79
198
|
*/
|
|
80
199
|
async deliver(instruction) {
|
|
81
200
|
const start = Date.now();
|
|
82
|
-
const maxTurns = this.config.maxTurns ?? DEFAULT_MAX_TURNS;
|
|
83
201
|
const rungs = this.config.rungs && this.config.rungs.length > 0
|
|
84
202
|
? this.config.rungs
|
|
85
203
|
: detectRungs(this.config.projectRoot);
|
|
86
204
|
if (rungs.length === 0) {
|
|
87
205
|
throw new Error(`No verifiable gates for ${this.config.projectRoot} — pass explicit rungs or add package.json scripts.`);
|
|
88
206
|
}
|
|
207
|
+
// Mutable run-state — a Phase 5 escalation directive can raise the budget,
|
|
208
|
+
// switch the model, enable exploration, or turn on the critic mid-run.
|
|
209
|
+
let maxTurns = this.config.maxTurns ?? DEFAULT_MAX_TURNS;
|
|
89
210
|
if (!Number.isInteger(maxTurns) || maxTurns < 1) {
|
|
90
211
|
throw new Error(`maxTurns must be a positive integer, got ${String(this.config.maxTurns)}`);
|
|
91
212
|
}
|
|
213
|
+
let executor = this.executor;
|
|
214
|
+
let explorerSettings = this.config.explorer;
|
|
215
|
+
let critic = this.config.critic;
|
|
92
216
|
const history = [];
|
|
93
217
|
const previousOutputChars = this.config.previousOutputChars ?? DEFAULT_PREVIOUS_OUTPUT_CHARS;
|
|
94
218
|
// Baseline: a green tree means there is nothing for the loop to deliver.
|
|
@@ -108,71 +232,98 @@ export class ConvergenceLoop {
|
|
|
108
232
|
};
|
|
109
233
|
}
|
|
110
234
|
}
|
|
235
|
+
// Phase 4: retrieve best-practice cards once — they are task-level and
|
|
236
|
+
// stable across turns. Fail-soft so retrieval never blocks delivery.
|
|
237
|
+
let practices;
|
|
238
|
+
if (this.config.practiceProvider) {
|
|
239
|
+
try {
|
|
240
|
+
const fetched = await this.config.practiceProvider(instruction);
|
|
241
|
+
practices = fetched.length > 0 ? fetched : undefined;
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
practices = undefined;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
111
247
|
let success = false;
|
|
112
248
|
let finalOutput = '';
|
|
113
249
|
let finalFeedback = '';
|
|
114
|
-
let prevContext = {};
|
|
250
|
+
let prevContext = { practices };
|
|
115
251
|
for (let turn = 1; turn <= maxTurns; turn++) {
|
|
116
252
|
const turnStart = Date.now();
|
|
117
253
|
const prompt = this.promptBuilder({ instruction, turn, ...prevContext });
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
catch (err) {
|
|
125
|
-
executorError = err instanceof Error ? err.message : String(err);
|
|
126
|
-
}
|
|
127
|
-
finalOutput = output || finalOutput;
|
|
128
|
-
// Apply
|
|
129
|
-
let applyResult = null;
|
|
130
|
-
let applyError;
|
|
131
|
-
if (!executorError) {
|
|
132
|
-
applyResult = await this.applier(output, this.config.projectRoot);
|
|
133
|
-
if (applyResult.error) {
|
|
134
|
-
applyError = applyResult.error;
|
|
135
|
-
}
|
|
136
|
-
else if (applyResult.rejected.length > 0) {
|
|
137
|
-
applyError = `Rejected blocks: ${applyResult.rejected
|
|
138
|
-
.map((r) => `${r.path} (${r.reason})`)
|
|
139
|
-
.join('; ')}`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// Verify — only when something was applied; otherwise the tree is
|
|
143
|
-
// unchanged and re-running gates would waste minutes for no signal.
|
|
144
|
-
const filesApplied = applyResult?.filesWritten ?? [];
|
|
145
|
-
let ladder = null;
|
|
146
|
-
if (!executorError && filesApplied.length > 0) {
|
|
147
|
-
ladder = await this.ladderRunner(rungs, this.config.projectRoot, this.config.ladderOptions);
|
|
148
|
-
finalFeedback = ladder.feedback;
|
|
254
|
+
const outcome = explorerSettings
|
|
255
|
+
? await this.runExplorerTurn(instruction, prompt, rungs, explorerSettings, executor)
|
|
256
|
+
: await this.runSingleTurn(prompt, rungs, executor);
|
|
257
|
+
finalOutput = outcome.output || finalOutput;
|
|
258
|
+
if (outcome.ladder) {
|
|
259
|
+
finalFeedback = outcome.ladder.feedback;
|
|
149
260
|
}
|
|
150
261
|
const record = {
|
|
151
262
|
turn,
|
|
152
|
-
passed: ladder?.passed ?? false,
|
|
153
|
-
score: ladder?.score ?? 0,
|
|
154
|
-
gateResults: ladder?.results ?? [],
|
|
155
|
-
filesApplied,
|
|
156
|
-
executorError,
|
|
157
|
-
applyError,
|
|
263
|
+
passed: outcome.ladder?.passed ?? false,
|
|
264
|
+
score: outcome.ladder?.score ?? 0,
|
|
265
|
+
gateResults: outcome.ladder?.results ?? [],
|
|
266
|
+
filesApplied: outcome.filesApplied,
|
|
267
|
+
executorError: outcome.executorError,
|
|
268
|
+
applyError: outcome.applyError,
|
|
269
|
+
strategy: outcome.strategy,
|
|
270
|
+
candidates: outcome.candidates,
|
|
271
|
+
judgeRationale: outcome.judgeRationale,
|
|
158
272
|
durationMs: Date.now() - turnStart,
|
|
159
273
|
};
|
|
160
274
|
history.push(record);
|
|
161
|
-
|
|
162
|
-
if (ladder?.passed) {
|
|
275
|
+
if (outcome.ladder?.passed) {
|
|
163
276
|
success = true;
|
|
277
|
+
this.config.onIteration?.(record);
|
|
164
278
|
break;
|
|
165
279
|
}
|
|
166
|
-
|
|
280
|
+
const directive = normalizeDirective(this.config.onIteration?.(record));
|
|
281
|
+
if (directive.stop) {
|
|
167
282
|
break;
|
|
168
283
|
}
|
|
284
|
+
// Apply escalation directives to the run-state for subsequent turns
|
|
285
|
+
if (directive.switchExecutor) {
|
|
286
|
+
executor = directive.switchExecutor;
|
|
287
|
+
}
|
|
288
|
+
if (typeof directive.setCandidates === 'number') {
|
|
289
|
+
explorerSettings = { ...(explorerSettings ?? {}), candidates: directive.setCandidates };
|
|
290
|
+
}
|
|
291
|
+
if (directive.enableCritic && !critic && this.config.criticFactory) {
|
|
292
|
+
// Bind to the current (possibly just-switched) executor, not the base.
|
|
293
|
+
critic = this.config.criticFactory(executor);
|
|
294
|
+
}
|
|
295
|
+
if (typeof directive.raiseMaxTurns === 'number' && directive.raiseMaxTurns > maxTurns) {
|
|
296
|
+
maxTurns = directive.raiseMaxTurns;
|
|
297
|
+
}
|
|
298
|
+
// Phase 3: structured critique of the failed turn (fail-soft). Skipped
|
|
299
|
+
// on the last turn — prevContext is never consumed, so it would waste
|
|
300
|
+
// a model call.
|
|
301
|
+
let critique;
|
|
302
|
+
if (critic && !outcome.executorError && turn < maxTurns) {
|
|
303
|
+
try {
|
|
304
|
+
const result = await critic({
|
|
305
|
+
instruction,
|
|
306
|
+
record,
|
|
307
|
+
feedback: outcome.ladder?.feedback ?? outcome.applyError ?? '',
|
|
308
|
+
attemptOutput: truncateHead(outcome.output, previousOutputChars),
|
|
309
|
+
});
|
|
310
|
+
critique = result.fixList.length > 0 ? result.fixList : undefined;
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
critique = undefined;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
169
316
|
prevContext = {
|
|
170
|
-
previousOutput: executorError
|
|
317
|
+
previousOutput: outcome.executorError
|
|
171
318
|
? undefined
|
|
172
|
-
: truncateHead(output, previousOutputChars),
|
|
173
|
-
feedback: executorError
|
|
174
|
-
|
|
175
|
-
|
|
319
|
+
: truncateHead(outcome.output, previousOutputChars),
|
|
320
|
+
feedback: outcome.executorError
|
|
321
|
+
? `Model call failed: ${outcome.executorError}`
|
|
322
|
+
: outcome.ladder?.feedback,
|
|
323
|
+
applyError: outcome.applyError,
|
|
324
|
+
previousFiles: outcome.filesApplied.length > 0 ? outcome.filesApplied : undefined,
|
|
325
|
+
critique,
|
|
326
|
+
practices,
|
|
176
327
|
};
|
|
177
328
|
}
|
|
178
329
|
let bestScore = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convergence-loop.js","sourceRoot":"","sources":["../../src/delivery/convergence-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqF/C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAE5C,MAAM,eAAe,GAAG;IACtB,sGAAsG;IACtG,EAAE;IACF,yEAAyE;IACzE,yCAAyC;IACzC,uBAAuB;IACvB,KAAK;IACL,iFAAiF;IACjF,qFAAqF;IACrF,6CAA6C;CAC9C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,YAAY,CAAC,IAAY,EAAE,QAAgB;IAClD,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC;AACrD,CAAC;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAkB,CAAC,GAAG,EAAE,EAAE;IACzD,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,eAAe,EAAE,EAAE,EAAE,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,QAAQ,GAAG,CA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CAAC;QAED,OAAO;YACL,OAAO;YACP,gBAAgB,EAAE,KAAK;YACvB,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,SAAS;YACT,QAAQ;YACR,OAAO;YACP,aAAa;YACb,WAAW;YACX,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;SACpC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Critic (Phase 3)
|
|
3
|
+
*
|
|
4
|
+
* Replaces raw gate-output dumps with a decomposed repair plan. After a
|
|
5
|
+
* failed iteration, the critic analyzes the gate feedback through a
|
|
6
|
+
* gate-specific lens and emits a numbered, file-scoped fix list sized for
|
|
7
|
+
* small-model context budgets — one concrete action per line beats a wall
|
|
8
|
+
* of compiler output.
|
|
9
|
+
*/
|
|
10
|
+
import type { LoopExecutor } from './convergence-loop.js';
|
|
11
|
+
import type { IterationRecord } from './convergence-loop.js';
|
|
12
|
+
export interface CritiqueInput {
|
|
13
|
+
instruction: string;
|
|
14
|
+
/** The failed iteration being critiqued */
|
|
15
|
+
record: IterationRecord;
|
|
16
|
+
/** Gate feedback from the ladder (already truncated) */
|
|
17
|
+
feedback: string;
|
|
18
|
+
/** Model output from the failed attempt (already truncated) */
|
|
19
|
+
attemptOutput: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Critique {
|
|
22
|
+
/** Numbered, file-scoped repair steps */
|
|
23
|
+
fixList: string[];
|
|
24
|
+
/** Gate the critique focuses on (first failing required gate) */
|
|
25
|
+
focusGate?: string;
|
|
26
|
+
}
|
|
27
|
+
export type Critic = (input: CritiqueInput) => Promise<Critique>;
|
|
28
|
+
/** Parse numbered lines ("1. ...", "2) ...") out of model output. */
|
|
29
|
+
export declare function parseFixList(text: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Model-backed critic. Fail-soft: on executor error or unparseable output
|
|
32
|
+
* it returns an empty fix list, and the loop falls back to raw feedback.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createModelCritic(executor: LoopExecutor): Critic;
|
|
35
|
+
//# sourceMappingURL=critic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"critic.d.ts","sourceRoot":"","sources":["../../src/delivery/critic.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,yCAAyC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAmDjE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CASnD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAUhE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Critic (Phase 3)
|
|
3
|
+
*
|
|
4
|
+
* Replaces raw gate-output dumps with a decomposed repair plan. After a
|
|
5
|
+
* failed iteration, the critic analyzes the gate feedback through a
|
|
6
|
+
* gate-specific lens and emits a numbered, file-scoped fix list sized for
|
|
7
|
+
* small-model context budgets — one concrete action per line beats a wall
|
|
8
|
+
* of compiler output.
|
|
9
|
+
*/
|
|
10
|
+
/** Gate-specific analyst personas — the lens shapes what the critic looks for. */
|
|
11
|
+
const GATE_PERSONAS = {
|
|
12
|
+
build: 'You are a compiler-error analyst. Map each error to its file and the exact change that resolves it.',
|
|
13
|
+
typecheck: 'You are a TypeScript type-system expert. For each type error, state the file, the conflicting types, and the precise fix.',
|
|
14
|
+
test: 'You are a test-failure analyst. For each failing test, state what behavior it expects, which source file implements that behavior, and what must change.',
|
|
15
|
+
lint: 'You are a code-style reviewer. List the mechanical fixes per file.',
|
|
16
|
+
};
|
|
17
|
+
const DEFAULT_PERSONA = 'You are a senior engineer diagnosing why a change failed verification.';
|
|
18
|
+
const MAX_FIX_STEPS = 8;
|
|
19
|
+
function firstFailingGate(record) {
|
|
20
|
+
return record.gateResults.find((g) => !g.passed && !g.skipped)?.id;
|
|
21
|
+
}
|
|
22
|
+
function buildCriticPrompt(input) {
|
|
23
|
+
const gate = firstFailingGate(input.record);
|
|
24
|
+
const persona = (gate && GATE_PERSONAS[gate]) ?? DEFAULT_PERSONA;
|
|
25
|
+
return [
|
|
26
|
+
persona,
|
|
27
|
+
'',
|
|
28
|
+
`TASK BEING ATTEMPTED: ${input.instruction}`,
|
|
29
|
+
'',
|
|
30
|
+
input.record.filesApplied.length > 0
|
|
31
|
+
? `FILES CHANGED BY THE ATTEMPT: ${input.record.filesApplied.join(', ')}`
|
|
32
|
+
: 'THE ATTEMPT CHANGED NO FILES.',
|
|
33
|
+
'',
|
|
34
|
+
'VERIFICATION FEEDBACK:',
|
|
35
|
+
input.feedback,
|
|
36
|
+
'',
|
|
37
|
+
'THE ATTEMPT (truncated):',
|
|
38
|
+
input.attemptOutput,
|
|
39
|
+
'',
|
|
40
|
+
`Produce a repair plan: at most ${MAX_FIX_STEPS} numbered steps, each naming a specific file and a specific change.`,
|
|
41
|
+
'Format strictly as numbered lines ("1. <file>: <change>"). No prose before or after.',
|
|
42
|
+
].join('\n');
|
|
43
|
+
}
|
|
44
|
+
/** Max characters of critic output parsed (bounds work on untrusted text). */
|
|
45
|
+
const MAX_CRITIC_CHARS = 20_000;
|
|
46
|
+
/** Linear, anchored matcher — no overlapping quantifiers (avoids ReDoS). */
|
|
47
|
+
const FIX_LINE_RE = /^\s{0,8}(\d{1,3})[.)]\s+(\S[^\n]*?)\s*$/;
|
|
48
|
+
/** Parse numbered lines ("1. ...", "2) ...") out of model output. */
|
|
49
|
+
export function parseFixList(text) {
|
|
50
|
+
const steps = [];
|
|
51
|
+
const bounded = text.length > MAX_CRITIC_CHARS ? text.slice(0, MAX_CRITIC_CHARS) : text;
|
|
52
|
+
for (const line of bounded.split('\n')) {
|
|
53
|
+
const match = FIX_LINE_RE.exec(line);
|
|
54
|
+
if (match)
|
|
55
|
+
steps.push(match[2]);
|
|
56
|
+
if (steps.length >= MAX_FIX_STEPS)
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return steps;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Model-backed critic. Fail-soft: on executor error or unparseable output
|
|
63
|
+
* it returns an empty fix list, and the loop falls back to raw feedback.
|
|
64
|
+
*/
|
|
65
|
+
export function createModelCritic(executor) {
|
|
66
|
+
return async (input) => {
|
|
67
|
+
const focusGate = firstFailingGate(input.record);
|
|
68
|
+
try {
|
|
69
|
+
const raw = await executor(buildCriticPrompt(input));
|
|
70
|
+
return { fixList: parseFixList(raw), focusGate };
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return { fixList: [], focusGate };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=critic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"critic.js","sourceRoot":"","sources":["../../src/delivery/critic.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwBH,kFAAkF;AAClF,MAAM,aAAa,GAA2B;IAC5C,KAAK,EACH,qGAAqG;IACvG,SAAS,EACP,2HAA2H;IAC7H,IAAI,EACF,0JAA0J;IAC5J,IAAI,EAAE,oEAAo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AI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxF,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,IAAI,aAAa;YAAE,MAAM;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAsB;IACtD,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;QACpC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation Controller (Phase 5)
|
|
3
|
+
*
|
|
4
|
+
* An onIteration handler that watches for stagnation and climbs an escalation
|
|
5
|
+
* ladder: when the best gate score stops improving for N consecutive turns,
|
|
6
|
+
* advance to the next tier. Tiers escalate cost progressively — widen
|
|
7
|
+
* exploration, enable the critic, raise the turn budget, and finally switch to
|
|
8
|
+
* a stronger model — so cheap strategies are exhausted before expensive ones.
|
|
9
|
+
*
|
|
10
|
+
* The controller is pure policy: it inspects IterationRecords and returns
|
|
11
|
+
* directives. The loop owns all mutation. This keeps escalation testable in
|
|
12
|
+
* isolation and swappable without touching the loop.
|
|
13
|
+
*/
|
|
14
|
+
import type { IterationRecord, IterationDirective, LoopExecutor } from './convergence-loop.js';
|
|
15
|
+
export interface EscalationTier {
|
|
16
|
+
/** Label surfaced in directive notes and logs */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Widen best-of-N exploration to this many candidates */
|
|
19
|
+
setCandidates?: number;
|
|
20
|
+
/** Turn the structured critic on */
|
|
21
|
+
enableCritic?: boolean;
|
|
22
|
+
/** Raise the absolute turn budget */
|
|
23
|
+
raiseMaxTurns?: number;
|
|
24
|
+
/** Escalate to a stronger model */
|
|
25
|
+
switchExecutor?: LoopExecutor;
|
|
26
|
+
}
|
|
27
|
+
export interface EscalationConfig {
|
|
28
|
+
tiers: EscalationTier[];
|
|
29
|
+
/**
|
|
30
|
+
* Consecutive non-improving turns that trigger advancing one tier
|
|
31
|
+
* (default 2). A turn "improves" if its score exceeds the best seen so far.
|
|
32
|
+
*/
|
|
33
|
+
stagnationTurns?: number;
|
|
34
|
+
/** Minimum score delta to count as improvement (default 0.01) */
|
|
35
|
+
improvementEpsilon?: number;
|
|
36
|
+
/** Called whenever a tier is applied (telemetry/logging) */
|
|
37
|
+
onEscalate?: (tier: EscalationTier, turn: number) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface EscalationController {
|
|
40
|
+
onIteration: (record: IterationRecord) => IterationDirective;
|
|
41
|
+
/** Index of the next tier to apply (for inspection/tests) */
|
|
42
|
+
tierIndex(): number;
|
|
43
|
+
}
|
|
44
|
+
export interface DefaultLadderOptions {
|
|
45
|
+
/** Candidates to widen exploration to on the first escalation (default 3) */
|
|
46
|
+
candidates?: number;
|
|
47
|
+
/** Current turn budget; the model-switch tier raises it by +2 */
|
|
48
|
+
maxTurns?: number;
|
|
49
|
+
/** A stronger model executor; when present, adds a final model-switch tier */
|
|
50
|
+
escalateExecutor?: LoopExecutor;
|
|
51
|
+
/** Display name for the stronger model (for the tier label) */
|
|
52
|
+
escalateModelName?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The canonical escalation ladder: exhaust cheap strategies before expensive
|
|
56
|
+
* ones — widen exploration, then enable the critic, then (if configured)
|
|
57
|
+
* switch to a stronger model with a couple extra turns. Library-owned so
|
|
58
|
+
* non-CLI callers get the same policy.
|
|
59
|
+
*/
|
|
60
|
+
export declare function defaultEscalationLadder(options?: DefaultLadderOptions): EscalationTier[];
|
|
61
|
+
/**
|
|
62
|
+
* Build a stagnation-driven escalation controller. Returns an `onIteration`
|
|
63
|
+
* suitable for ConvergenceConfig, plus a `tierIndex` accessor for tests.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createEscalationController(config: EscalationConfig): EscalationController;
|
|
66
|
+
//# sourceMappingURL=escalation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["../../src/delivery/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE/F,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mCAAmC;IACnC,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,CAA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