@bendyline/gezel-script-stdlib 1.0.10 → 1.1.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/package.json +2 -2
- package/scripts/checkFixReview.ts +76 -9
- package/scripts/storeRecords.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-script-stdlib",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Standard gate-script library packed into the app. Plain defineScript sources resolved in place by the script runner (scope: 'standard'); read-only, trusted, versioned with the app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"!scripts/**/*.test.ts"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@bendyline/gezel-sdk": "1.0
|
|
44
|
+
"@bendyline/gezel-sdk": "1.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^24.13.3",
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
-
import { gateResult } from '@bendyline/gezel-sdk/checks';
|
|
2
|
+
import { type GateScriptResult, gateResult } from '@bendyline/gezel-sdk/checks';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Fix-review gate (the enforceable `evaluate` step of the tactical fleet):
|
|
6
6
|
* the reviewer's artifact at `<task.dir>/review.md` is well-formed and its
|
|
7
7
|
* verdict actually routes the loop. `Verdict: PASS` advances; a well-formed
|
|
8
8
|
* `Verdict: REVISE` rejects WITH `goto` back to the fix step, carrying the
|
|
9
|
-
* findings as the prescriptive message
|
|
10
|
-
* so the reviewer repairs the report rather
|
|
9
|
+
* findings as the prescriptive message until the revision budget is spent; a
|
|
10
|
+
* malformed report rejects in place so the reviewer repairs the report rather
|
|
11
|
+
* than the fixer thrashing. The budget is based on the evaluate step's durable
|
|
12
|
+
* activation count, so routing through a separate fix step cannot reset it.
|
|
11
13
|
*
|
|
12
14
|
* Anti-fabrication: every file the review cites must exist — probed by
|
|
13
15
|
* reading each path (workspace, the task's diffpack overlay when drafting,
|
|
@@ -17,7 +19,7 @@ import { gateResult } from '@bendyline/gezel-sdk/checks';
|
|
|
17
19
|
export const meta = defineScript({
|
|
18
20
|
name: 'checkFixReview',
|
|
19
21
|
description:
|
|
20
|
-
'Gate: a fix/improvement review artifact is well-formed — a `Verdict: PASS` or `Verdict: REVISE` line, severities from critical/major/minor/nit, every cited file exists (workspace, draft overlay, or artifacts), critical/major findings force REVISE — and a REVISE verdict routes the task back to the fix step with the findings as the message.',
|
|
22
|
+
'Gate: a fix/improvement review artifact is well-formed — a `Verdict: PASS` or `Verdict: REVISE` line, severities from critical/major/minor/nit, every cited file exists (workspace, draft overlay, or artifacts), critical/major findings force REVISE — and a REVISE verdict routes the task back to the fix step with the findings as the message, up to a bounded number of review rounds.',
|
|
21
23
|
kind: 'gate',
|
|
22
24
|
inputs: {
|
|
23
25
|
taskRef: {
|
|
@@ -38,6 +40,19 @@ export const meta = defineScript({
|
|
|
38
40
|
type: 'string',
|
|
39
41
|
description: "Step to route a REVISE verdict back to. Defaults to 'fix'.",
|
|
40
42
|
},
|
|
43
|
+
maxReviewRounds: {
|
|
44
|
+
type: 'number',
|
|
45
|
+
description:
|
|
46
|
+
'Maximum evaluate-step activations that may route REVISE back to the fixer. Defaults to 3.',
|
|
47
|
+
default: 3,
|
|
48
|
+
integer: true,
|
|
49
|
+
min: 1,
|
|
50
|
+
},
|
|
51
|
+
needsUserStepId: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description:
|
|
54
|
+
"Optional terminal escalation step used when the review budget is spent. When omitted, a terminal 'needs-user' step is discovered automatically; otherwise the gate rejects in place so its ordinary maxAttempts budget can pause the task.",
|
|
55
|
+
},
|
|
41
56
|
},
|
|
42
57
|
outputs: {
|
|
43
58
|
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
@@ -60,6 +75,12 @@ interface TaskView {
|
|
|
60
75
|
diffpackId?: string;
|
|
61
76
|
}
|
|
62
77
|
|
|
78
|
+
interface TaskStepView {
|
|
79
|
+
id: string;
|
|
80
|
+
attemptCount?: number;
|
|
81
|
+
terminal?: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
const input = gezel.input as InferredInput<typeof meta>;
|
|
64
85
|
|
|
65
86
|
/** Strip citation decoration so `./src/x.ts`, `a/src/x.ts`, `src/x.ts` compare equal. */
|
|
@@ -76,6 +97,52 @@ const task = (await gezel.task.get(input.taskRef ?? '').catch(() => null)) as Ta
|
|
|
76
97
|
const taskDir = task?.artifactDir ?? (task?.num !== undefined ? `tasks/${task.num}` : undefined);
|
|
77
98
|
const reviewPath = input.reviewPath ?? (taskDir ? `${taskDir}/review.md` : undefined);
|
|
78
99
|
const fixStepId = input.fixStepId ?? 'fix';
|
|
100
|
+
const maxReviewRounds = input.maxReviewRounds ?? 3;
|
|
101
|
+
|
|
102
|
+
async function reviseDecision(message: string): Promise<GateScriptResult> {
|
|
103
|
+
const currentStep = (await gezel.task
|
|
104
|
+
.currentStep(input.taskRef ?? '')
|
|
105
|
+
.catch(() => null)) as TaskStepView | null;
|
|
106
|
+
|
|
107
|
+
// Fail closed if the durable counter cannot be read. Routing to the fixer
|
|
108
|
+
// without it would recreate the unbounded evaluate -> fix -> evaluate loop
|
|
109
|
+
// this budget exists to prevent. Rejecting in place leaves the gate's own
|
|
110
|
+
// maxAttempts counter intact, so the normal runtime pause remains available.
|
|
111
|
+
if (!currentStep) {
|
|
112
|
+
return gateResult(
|
|
113
|
+
false,
|
|
114
|
+
`${message}\n\nThe review needs revision, but the gate could not read the current step's review-round counter. It refused to start an unbounded repair loop; retry review or ask a user to intervene.`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const reviewRound = Math.max(1, currentStep.attemptCount ?? 1);
|
|
119
|
+
if (reviewRound < maxReviewRounds) {
|
|
120
|
+
return {
|
|
121
|
+
decision: 'reject',
|
|
122
|
+
goto: fixStepId,
|
|
123
|
+
message: `${message}\n\nReview round ${reviewRound} of ${maxReviewRounds}; return to ${fixStepId} for another bounded repair pass.`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const steps = (await gezel.task.steps(input.taskRef ?? '').catch(() => [])) as TaskStepView[];
|
|
128
|
+
const requestedEscalation = input.needsUserStepId?.trim();
|
|
129
|
+
const escalationStep = requestedEscalation
|
|
130
|
+
? steps.find((step) => step.id === requestedEscalation && step.terminal)
|
|
131
|
+
: steps.find((step) => step.id === 'needs-user' && step.terminal);
|
|
132
|
+
const exhausted = `${message}\n\nReview budget exhausted after ${reviewRound} of ${maxReviewRounds} round(s). Stop the automatic repair loop and report DONE_WITH_CONCERNS with the unresolved findings.`;
|
|
133
|
+
|
|
134
|
+
if (escalationStep) {
|
|
135
|
+
return { decision: 'reject', goto: escalationStep.id, message: exhausted };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// No safe terminal route is present in older/custom books. Stay on the
|
|
139
|
+
// gated evaluate step instead of jumping to the fixer again. The gate's
|
|
140
|
+
// existing maxAttempts budget will then pause the task deterministically.
|
|
141
|
+
return gateResult(
|
|
142
|
+
false,
|
|
143
|
+
`${exhausted} No terminal escalation step is configured, so the gate is holding this evaluate step for user intervention.`,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
79
146
|
|
|
80
147
|
/**
|
|
81
148
|
* A cited path exists when it reads from ANY surface the review may talk
|
|
@@ -238,11 +305,11 @@ if (!reviewPath) {
|
|
|
238
305
|
`- [${r.severity || 'finding'}] ${r.file}${r.problem ? ` — ${r.problem}` : ''}${r.fix ? ` → ${r.fix}` : ''}`,
|
|
239
306
|
)
|
|
240
307
|
.join('\n');
|
|
241
|
-
gezel.output(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
308
|
+
gezel.output(
|
|
309
|
+
await reviseDecision(
|
|
310
|
+
`Reviewer verdict: REVISE. Address these findings, then bring the work back through review:\n${summary}${rows.length > 6 ? `\n…and ${rows.length - 6} more in ${reviewPath}.` : ''}`,
|
|
311
|
+
),
|
|
312
|
+
);
|
|
246
313
|
} else {
|
|
247
314
|
gezel.output(
|
|
248
315
|
gateResult(
|
package/scripts/storeRecords.ts
CHANGED
|
@@ -383,4 +383,6 @@ async function run(): Promise<Fields> {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
|
|
386
|
+
// Every declared output is stamped on every action, including inapplicable fields.
|
|
387
|
+
// The shared runner validates the complete contract before accepting a run.
|
|
388
|
+
gezel.output({ id: null, record: null, records: [], total: null, ...(await run()) });
|