lastlight-core 0.22.0 → 0.23.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/config/default.yaml +70 -2
- package/dist/config/config.d.ts +35 -0
- package/dist/config/config.js +152 -3
- package/dist/config/config.js.map +1 -1
- package/dist/config/repo-config.d.ts +7 -0
- package/dist/config/repo-config.js +15 -0
- package/dist/config/repo-config.js.map +1 -1
- package/dist/connectors/github-webhook.d.ts +17 -0
- package/dist/connectors/github-webhook.js +150 -17
- package/dist/connectors/github-webhook.js.map +1 -1
- package/dist/connectors/types.d.ts +48 -1
- package/dist/cron/dependabot-discovery.d.ts +68 -11
- package/dist/cron/dependabot-discovery.js +78 -20
- package/dist/cron/dependabot-discovery.js.map +1 -1
- package/dist/cron/jobs.d.ts +4 -0
- package/dist/cron/jobs.js +38 -4
- package/dist/cron/jobs.js.map +1 -1
- package/dist/cron/review-discovery.d.ts +33 -20
- package/dist/cron/review-discovery.js +23 -30
- package/dist/cron/review-discovery.js.map +1 -1
- package/dist/engine/agent-executor.d.ts +1 -1
- package/dist/engine/agent-executor.js +1 -1
- package/dist/engine/agent-executor.js.map +1 -1
- package/dist/engine/dispatcher.d.ts +98 -1
- package/dist/engine/dispatcher.js +248 -231
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/executors/shared.d.ts +43 -0
- package/dist/engine/executors/shared.js +65 -0
- package/dist/engine/executors/shared.js.map +1 -1
- package/dist/engine/fix-harvest.d.ts +169 -0
- package/dist/engine/fix-harvest.js +345 -0
- package/dist/engine/fix-harvest.js.map +1 -0
- package/dist/engine/fix-markers.d.ts +184 -0
- package/dist/engine/fix-markers.js +329 -0
- package/dist/engine/fix-markers.js.map +1 -0
- package/dist/engine/fix-scratch.d.ts +76 -0
- package/dist/engine/fix-scratch.js +77 -0
- package/dist/engine/fix-scratch.js.map +1 -0
- package/dist/engine/github/github.d.ts +212 -5
- package/dist/engine/github/github.js +481 -54
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/pr-decisions.d.ts +342 -0
- package/dist/engine/pr-decisions.js +721 -0
- package/dist/engine/pr-decisions.js.map +1 -0
- package/dist/engine/pr-escalation.d.ts +152 -0
- package/dist/engine/pr-escalation.js +320 -0
- package/dist/engine/pr-escalation.js.map +1 -0
- package/dist/engine/pr-notes.d.ts +175 -0
- package/dist/engine/pr-notes.js +315 -0
- package/dist/engine/pr-notes.js.map +1 -0
- package/dist/engine/pr-state.d.ts +313 -0
- package/dist/engine/pr-state.js +515 -0
- package/dist/engine/pr-state.js.map +1 -0
- package/dist/engine/review-check.d.ts +200 -0
- package/dist/engine/review-check.js +305 -0
- package/dist/engine/review-check.js.map +1 -0
- package/dist/engine/router.d.ts +27 -0
- package/dist/engine/router.js +156 -22
- package/dist/engine/router.js.map +1 -1
- package/dist/evals-api.d.ts +7 -0
- package/dist/evals-api.js +30 -0
- package/dist/evals-api.js.map +1 -1
- package/dist/index.js +268 -20
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +13 -0
- package/dist/sandbox/index.js +30 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/k8s/init-clone.d.ts +5 -0
- package/dist/sandbox/k8s/init-clone.js +27 -0
- package/dist/sandbox/k8s/init-clone.js.map +1 -1
- package/dist/state/execution-store.d.ts +27 -0
- package/dist/state/execution-store.js +45 -0
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +73 -0
- package/dist/state/workflow-run-store.js +106 -24
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/pr-scope.d.ts +63 -0
- package/dist/workflows/pr-scope.js +113 -0
- package/dist/workflows/pr-scope.js.map +1 -0
- package/dist/workflows/resume.js +17 -4
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/simple.d.ts +94 -1
- package/dist/workflows/simple.js +206 -3
- package/dist/workflows/simple.js.map +1 -1
- package/dist/workflows/target-policy.d.ts +0 -12
- package/dist/workflows/target-policy.js +9 -15
- package/dist/workflows/target-policy.js.map +1 -1
- package/package.json +4 -4
- package/skills/README.md +11 -5
- package/skills/dependency-impact/SKILL.md +83 -0
- package/skills/fixing/SKILL.md +190 -0
- package/skills/pr-review/SKILL.md +26 -9
- package/workflows/cron-dependabot-ci-fix.yaml +8 -5
- package/workflows/cron-review.yaml +14 -5
- package/workflows/dependabot-ci-fix.yaml +86 -2
- package/workflows/dependabot-pr-merge.yaml +13 -1
- package/workflows/pr-fix.yaml +84 -1
- package/workflows/pr-review.yaml +7 -0
- package/workflows/prompts/dependabot-ci-fix.md +70 -17
- package/workflows/prompts/dependabot-pr-merge.md +203 -80
- package/workflows/prompts/diagnose-ci.md +96 -0
- package/workflows/prompts/pr-fix.md +63 -4
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two fix-family marker grammars, parsed.
|
|
3
|
+
*
|
|
4
|
+
* `skills/fixing/SKILL.md` asks the agent to end the `diagnose` and `fix`
|
|
5
|
+
* phases with exactly one machine-readable line:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* DIAGNOSIS_COMPLETE: pr=<N> attempt=<K> class=<…> cause=<one line> ci_vs_local=<one line> unreproducible=<a,b>
|
|
9
|
+
* CI_FIX_COMPLETE: pr=<N> attempt=<K> outcome=<pushed|no-change|gave-up> tried=<one line> gate=<green|red|skipped>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Those lines are the ONLY thing that survives a run boundary:
|
|
13
|
+
* `{{phaseOutputs}}` is empty across runs and the per-PR workspace is
|
|
14
|
+
* `reset --hard`-ed between them, so cross-attempt memory has to be small and
|
|
15
|
+
* persisted (04-retry.md §4.2). One parsed line per attempt is replayed into
|
|
16
|
+
* every later attempt's prompt, and the `class=` token decides whether an
|
|
17
|
+
* attempt was spent at all (09-state-machine.md §S1).
|
|
18
|
+
*
|
|
19
|
+
* Three properties this module is written for, in priority order:
|
|
20
|
+
*
|
|
21
|
+
* 1. **It can never throw.** A malformed marker is agent output, which is to
|
|
22
|
+
* say untrusted text produced under time pressure by a language model. It
|
|
23
|
+
* must degrade to "we learned nothing from this run", never to a crashed
|
|
24
|
+
* harvest that fails the run that produced it.
|
|
25
|
+
* 2. **Values are free text, not tokens.** `cause=` is a sentence and may
|
|
26
|
+
* contain `=` and spaces, so the fields are split on the NEXT KNOWN KEY
|
|
27
|
+
* rather than on whitespace. Naive whitespace splitting truncates every
|
|
28
|
+
* cause to its first word.
|
|
29
|
+
* 3. **An unrecognised enum value is `null`, never coerced.** `class=probably-flaky`
|
|
30
|
+
* must not silently become `flaky` and defer the PR forever; it is an
|
|
31
|
+
* unknown class, which the deferral counter treats as "not flaky".
|
|
32
|
+
*
|
|
33
|
+
* Pure: no I/O, no clock, no DB. `./fix-harvest.ts` is the impure half.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* The five diagnosis classes (09 → S1, `skills/fixing/SKILL.md`).
|
|
37
|
+
*
|
|
38
|
+
* Defined in `lastlight-shared` and re-exported here, where every reader of the
|
|
39
|
+
* marker grammar looks for them. They moved because `fix.retryableClasses` is a
|
|
40
|
+
* config leaf naming members of this enum, and both places that validate it —
|
|
41
|
+
* the boot normaliser in core and the repo-layer clamp compiled into the CLI —
|
|
42
|
+
* need it. `shared` is the only package both may reach, and a second hand-kept
|
|
43
|
+
* copy of a closed enum is exactly how `retryableClasses` came to accept
|
|
44
|
+
* `reproducable` in the first place (#256).
|
|
45
|
+
*/
|
|
46
|
+
import { DIAGNOSIS_CLASSES, isDiagnosisClass, } from "lastlight-shared/config-types";
|
|
47
|
+
export { DIAGNOSIS_CLASSES, isDiagnosisClass };
|
|
48
|
+
/**
|
|
49
|
+
* The two classes that cost NO attempt, per 09-state-machine.md §S1's class
|
|
50
|
+
* table.
|
|
51
|
+
*
|
|
52
|
+
* - `flaky` — by its own definition there is nothing to fix, so it never
|
|
53
|
+
* reaches the `fix` phase. It is bounded by `fix.maxFlakyDeferrals` instead,
|
|
54
|
+
* and that cap only exists BECAUSE it does not spend an attempt; if it did,
|
|
55
|
+
* `maxAttempts` would already bound it and the counter would be dead code.
|
|
56
|
+
* - `upstream-broken` — not this PR's fault. It self-heals the moment the base
|
|
57
|
+
* goes green, and charging the PR for its base branch being red would leave
|
|
58
|
+
* it with no attempts left at the moment it becomes fixable.
|
|
59
|
+
*
|
|
60
|
+
* `infra-dependent` is deliberately NOT here: it costs an attempt and escalates
|
|
61
|
+
* immediately, which is the whole point of not spending the other two on it.
|
|
62
|
+
*/
|
|
63
|
+
export const ATTEMPT_FREE_CLASSES = new Set([
|
|
64
|
+
"flaky",
|
|
65
|
+
"upstream-broken",
|
|
66
|
+
]);
|
|
67
|
+
/** What the `fix` phase did with the diagnosis. */
|
|
68
|
+
export const FIX_OUTCOMES = ["pushed", "no-change", "gave-up"];
|
|
69
|
+
/**
|
|
70
|
+
* The local gate's verdict. `skipped` means no gate ran — which 09 → S1 is
|
|
71
|
+
* explicit never authorises a push, so it is a distinct value rather than
|
|
72
|
+
* being folded into `red`.
|
|
73
|
+
*/
|
|
74
|
+
export const GATE_RESULTS = ["green", "red", "skipped"];
|
|
75
|
+
export const DIAGNOSIS_MARKER = "DIAGNOSIS_COMPLETE";
|
|
76
|
+
export const CI_FIX_MARKER = "CI_FIX_COMPLETE";
|
|
77
|
+
/**
|
|
78
|
+
* What a fix phase's `on_output.requires_marker` must name — the tag **with its
|
|
79
|
+
* colon**, which is the same string {@link lastMarkerLine} looks for.
|
|
80
|
+
*
|
|
81
|
+
* The engine enforces the postcondition as a bare `output.includes(marker)`, so
|
|
82
|
+
* declaring the tag alone made the gate and the parser disagree about what a
|
|
83
|
+
* marker IS. An output that merely *mentions* `DIAGNOSIS_COMPLETE` — an agent
|
|
84
|
+
* narrating "I'll close with DIAGNOSIS_COMPLETE" and then not, or fencing the
|
|
85
|
+
* word in prose — passed the postcondition and parsed to nothing. The phase went
|
|
86
|
+
* green, the harvest recorded a diagnosis of `null`, and the attempt counter
|
|
87
|
+
* never advanced: the PR sat at attempt 1 for its whole life with
|
|
88
|
+
* `fix.maxCostUsd` as the only remaining brake.
|
|
89
|
+
*
|
|
90
|
+
* Requiring the parseable form instead makes a malformed marker fail the phase
|
|
91
|
+
* loudly, which is what a postcondition is for. Exported so the YAML can be
|
|
92
|
+
* asserted against it rather than against a hand-copied literal.
|
|
93
|
+
*/
|
|
94
|
+
export const DIAGNOSIS_MARKER_POSTCONDITION = `${DIAGNOSIS_MARKER}:`;
|
|
95
|
+
export const CI_FIX_MARKER_POSTCONDITION = `${CI_FIX_MARKER}:`;
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Bounds
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
//
|
|
100
|
+
// Every bound here exists because the rendered line is replayed into EVERY
|
|
101
|
+
// later attempt's prompt. 09 → S1 is explicit that this memory "must not
|
|
102
|
+
// grow": an agent that writes a three-paragraph `cause=` would otherwise buy
|
|
103
|
+
// itself a larger prompt on attempt 2 and a larger one still on attempt 3.
|
|
104
|
+
/** Longest free-text field value kept from a marker. */
|
|
105
|
+
const MAX_FIELD_CHARS = 160;
|
|
106
|
+
/** Longest whole rendered attempt line. */
|
|
107
|
+
export const MAX_ATTEMPT_LINE_CHARS = 200;
|
|
108
|
+
/** Longest `cause=` clause inside a rendered attempt line. */
|
|
109
|
+
const MAX_RENDERED_CAUSE_CHARS = 110;
|
|
110
|
+
/** How many `unreproducible=` check names are kept. */
|
|
111
|
+
const MAX_UNREPRODUCIBLE = 6;
|
|
112
|
+
/** How many rendered attempt lines {@link boundAttemptLines} keeps. */
|
|
113
|
+
export const MAX_PRIOR_ATTEMPT_LINES = 6;
|
|
114
|
+
/** Clamp free text to `max` characters, marking the truncation. */
|
|
115
|
+
function clamp(value, max) {
|
|
116
|
+
const flat = value.replace(/\s+/g, " ").trim();
|
|
117
|
+
return flat.length <= max ? flat : `${flat.slice(0, max - 1).trimEnd()}…`;
|
|
118
|
+
}
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Parsing
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
/**
|
|
123
|
+
* The LAST line of `output` that carries `<tag>:`, with everything up to and
|
|
124
|
+
* including the tag stripped.
|
|
125
|
+
*
|
|
126
|
+
* The skill says the marker is the last line, and this deliberately does not
|
|
127
|
+
* insist on it. Two real shapes break a strict last-line read: an agent that
|
|
128
|
+
* fences the marker in backticks or prefixes it with a bullet, and a
|
|
129
|
+
* `generic_loop` iteration whose `{{previousOutput}}` replays the PREVIOUS
|
|
130
|
+
* iteration's marker earlier in the same text. Scanning backwards and taking
|
|
131
|
+
* the last hit handles both — the genuine final marker always wins.
|
|
132
|
+
*/
|
|
133
|
+
export function lastMarkerLine(output, tag) {
|
|
134
|
+
if (typeof output !== "string" || !output)
|
|
135
|
+
return null;
|
|
136
|
+
const needle = `${tag}:`;
|
|
137
|
+
const lines = output.split(/\r?\n/);
|
|
138
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
139
|
+
const idx = lines[i].indexOf(needle);
|
|
140
|
+
if (idx < 0)
|
|
141
|
+
continue;
|
|
142
|
+
// Strip a trailing code fence / emphasis run so a fenced marker parses.
|
|
143
|
+
return lines[i].slice(idx + needle.length).replace(/[`*_\s]+$/, "").trim();
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Split a marker body into `key → value`, where each value runs to the start
|
|
149
|
+
* of the NEXT KNOWN KEY rather than to the next space.
|
|
150
|
+
*
|
|
151
|
+
* This is the whole reason the parser is not two lines of `split(" ")`:
|
|
152
|
+
* `cause=the lockfile is stale vs package.json` is one value containing three
|
|
153
|
+
* spaces, and `ci_vs_local=CI runs node 22, sandbox node 20` contains a comma
|
|
154
|
+
* and a digit. Only a key from `keys`, at a word boundary, ends a value.
|
|
155
|
+
*
|
|
156
|
+
* First occurrence wins — a key repeated later in the line (an agent echoing
|
|
157
|
+
* itself) cannot overwrite the first, well-formed one.
|
|
158
|
+
*/
|
|
159
|
+
function parseFields(body, keys) {
|
|
160
|
+
const out = {};
|
|
161
|
+
// `(?:^|\s)` anchors the key to a token start, so `expr=` does not match
|
|
162
|
+
// `pr=` and a `cause=` value mentioning `foo_class=bar` does not end it.
|
|
163
|
+
const re = new RegExp(`(?:^|\\s)(${keys.join("|")})=`, "g");
|
|
164
|
+
const hits = [];
|
|
165
|
+
for (let m = re.exec(body); m !== null; m = re.exec(body)) {
|
|
166
|
+
// `m.index` points at the leading whitespace (or 0); the key itself starts
|
|
167
|
+
// `m[0].length - m[1].length - 1` characters later.
|
|
168
|
+
hits.push({
|
|
169
|
+
key: m[1],
|
|
170
|
+
keyStart: m.index + (m[0].length - m[1].length - 1),
|
|
171
|
+
valueStart: m.index + m[0].length,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
for (let i = 0; i < hits.length; i++) {
|
|
175
|
+
if (hits[i].key in out)
|
|
176
|
+
continue;
|
|
177
|
+
const end = i + 1 < hits.length ? hits[i + 1].keyStart : body.length;
|
|
178
|
+
out[hits[i].key] = clamp(body.slice(hits[i].valueStart, end), MAX_FIELD_CHARS);
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
/** A positive integer, or null. */
|
|
183
|
+
function parseCount(value) {
|
|
184
|
+
if (!value)
|
|
185
|
+
return null;
|
|
186
|
+
const m = /^\d+/.exec(value.trim());
|
|
187
|
+
if (!m)
|
|
188
|
+
return null;
|
|
189
|
+
const n = Number(m[0]);
|
|
190
|
+
return Number.isSafeInteger(n) && n >= 0 ? n : null;
|
|
191
|
+
}
|
|
192
|
+
/** `value` if it is one of `allowed`, else null — never coerced. */
|
|
193
|
+
function parseEnum(value, allowed) {
|
|
194
|
+
if (!value)
|
|
195
|
+
return null;
|
|
196
|
+
const token = value.trim().toLowerCase().split(/\s/)[0];
|
|
197
|
+
return allowed.includes(token) ? token : null;
|
|
198
|
+
}
|
|
199
|
+
const DIAGNOSIS_KEYS = ["pr", "attempt", "class", "cause", "ci_vs_local", "unreproducible"];
|
|
200
|
+
const FIX_KEYS = ["pr", "attempt", "outcome", "tried", "gate"];
|
|
201
|
+
/**
|
|
202
|
+
* Parse the last `DIAGNOSIS_COMPLETE` line out of a phase's full output.
|
|
203
|
+
*
|
|
204
|
+
* Returns null when there is no marker at all — which is a MEANINGFUL answer,
|
|
205
|
+
* not an error: a run with no `DIAGNOSIS_COMPLETE` spent no attempt (09 → S1,
|
|
206
|
+
* "a crashed run must not consume budget").
|
|
207
|
+
*/
|
|
208
|
+
export function parseDiagnosisMarker(output) {
|
|
209
|
+
try {
|
|
210
|
+
const body = lastMarkerLine(output, DIAGNOSIS_MARKER);
|
|
211
|
+
if (body === null)
|
|
212
|
+
return null;
|
|
213
|
+
const f = parseFields(body, DIAGNOSIS_KEYS);
|
|
214
|
+
const rawClass = f.class ? f.class.trim().split(/\s/)[0] : null;
|
|
215
|
+
return {
|
|
216
|
+
pr: parseCount(f.pr),
|
|
217
|
+
attempt: parseCount(f.attempt),
|
|
218
|
+
class: parseEnum(f.class, DIAGNOSIS_CLASSES),
|
|
219
|
+
rawClass: rawClass || null,
|
|
220
|
+
cause: f.cause ?? "",
|
|
221
|
+
ciVsLocal: f.ci_vs_local ?? "",
|
|
222
|
+
unreproducible: parseList(f.unreproducible),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Unreachable by construction, but the harvest runs inside a phase
|
|
227
|
+
// callback: a throw here would surface as a failed phase on a run that
|
|
228
|
+
// otherwise succeeded. Never worth it for a parse.
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Parse the last `CI_FIX_COMPLETE` line out of a phase's full output. */
|
|
233
|
+
export function parseFixOutcomeMarker(output) {
|
|
234
|
+
try {
|
|
235
|
+
const body = lastMarkerLine(output, CI_FIX_MARKER);
|
|
236
|
+
if (body === null)
|
|
237
|
+
return null;
|
|
238
|
+
const f = parseFields(body, FIX_KEYS);
|
|
239
|
+
const rawOutcome = f.outcome ? f.outcome.trim().split(/\s/)[0] : null;
|
|
240
|
+
const rawGate = f.gate ? f.gate.trim().split(/\s/)[0] : null;
|
|
241
|
+
return {
|
|
242
|
+
pr: parseCount(f.pr),
|
|
243
|
+
attempt: parseCount(f.attempt),
|
|
244
|
+
outcome: parseEnum(f.outcome, FIX_OUTCOMES),
|
|
245
|
+
rawOutcome: rawOutcome || null,
|
|
246
|
+
tried: f.tried ?? "",
|
|
247
|
+
gate: parseEnum(f.gate, GATE_RESULTS),
|
|
248
|
+
rawGate: rawGate || null,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** `a, b, c` → `["a","b","c"]`, with the `none` sentinel treated as empty. */
|
|
256
|
+
function parseList(value) {
|
|
257
|
+
if (!value)
|
|
258
|
+
return [];
|
|
259
|
+
const items = value
|
|
260
|
+
.split(",")
|
|
261
|
+
.map((s) => s.trim())
|
|
262
|
+
.filter((s) => s.length > 0 && s.toLowerCase() !== "none");
|
|
263
|
+
return items.slice(0, MAX_UNREPRODUCIBLE);
|
|
264
|
+
}
|
|
265
|
+
/** Parse both markers out of one phase output. Either half may be null. */
|
|
266
|
+
export function parseAttemptMarkers(output) {
|
|
267
|
+
return {
|
|
268
|
+
diagnosis: parseDiagnosisMarker(output),
|
|
269
|
+
fix: parseFixOutcomeMarker(output),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// ---------------------------------------------------------------------------
|
|
273
|
+
// Rendering — the one bounded line per attempt (04-retry.md §4.2)
|
|
274
|
+
// ---------------------------------------------------------------------------
|
|
275
|
+
/**
|
|
276
|
+
* The single line attempt N leaves behind for attempts N+1, N+2, …
|
|
277
|
+
*
|
|
278
|
+
* ```
|
|
279
|
+
* attempt 2: class=env-mismatch cause=CI runs node 22, sandbox node 20 | outcome=pushed gate=green
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* One line per attempt, not a transcript — attempt 3 needs to know what was
|
|
283
|
+
* tried and what was ruled out, not to re-read two agent sessions. `tried=` is
|
|
284
|
+
* deliberately NOT rendered: `cause=` plus `outcome=` already answer "what was
|
|
285
|
+
* wrong and did the fix land", and the whole line is replayed into every later
|
|
286
|
+
* prompt, so each extra clause is paid for on every subsequent attempt.
|
|
287
|
+
*
|
|
288
|
+
* Returns null when the attempt produced no marker at all — a crashed run
|
|
289
|
+
* leaves no line, exactly as it consumes no attempt.
|
|
290
|
+
*/
|
|
291
|
+
export function renderAttemptLine(attempt, markers) {
|
|
292
|
+
const diagnosis = markers?.diagnosis ?? null;
|
|
293
|
+
const fix = markers?.fix ?? null;
|
|
294
|
+
if (!diagnosis && !fix)
|
|
295
|
+
return null;
|
|
296
|
+
const parts = [];
|
|
297
|
+
if (diagnosis) {
|
|
298
|
+
// An unrecognised class renders as `unknown` rather than as the raw token:
|
|
299
|
+
// the line is read by a language model on the next attempt, and echoing an
|
|
300
|
+
// invented class back at it teaches it the invention.
|
|
301
|
+
parts.push(`class=${diagnosis.class ?? "unknown"}`);
|
|
302
|
+
if (diagnosis.cause)
|
|
303
|
+
parts.push(`cause=${clamp(diagnosis.cause, MAX_RENDERED_CAUSE_CHARS)}`);
|
|
304
|
+
}
|
|
305
|
+
const tail = [];
|
|
306
|
+
if (fix) {
|
|
307
|
+
tail.push(`outcome=${fix.outcome ?? "unknown"}`);
|
|
308
|
+
tail.push(`gate=${fix.gate ?? "unknown"}`);
|
|
309
|
+
}
|
|
310
|
+
const head = `attempt ${attempt}: ${parts.join(" ")}`.trimEnd();
|
|
311
|
+
const line = tail.length > 0 ? `${head} | ${tail.join(" ")}` : head;
|
|
312
|
+
return clamp(line, MAX_ATTEMPT_LINE_CHARS);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Keep the journal bounded: at most {@link MAX_PRIOR_ATTEMPT_LINES} lines,
|
|
316
|
+
* newest kept, oldest dropped, order preserved.
|
|
317
|
+
*
|
|
318
|
+
* A PR can accumulate more RUNS than `fix.maxAttempts` — a `flaky` deferral
|
|
319
|
+
* spends no attempt, and the daily `fix-red-dependency-prs` cron re-picks the
|
|
320
|
+
* PR up every day — so the array needs its own bound rather than inheriting
|
|
321
|
+
* the attempt cap's.
|
|
322
|
+
*/
|
|
323
|
+
export function boundAttemptLines(lines) {
|
|
324
|
+
const clean = lines.filter((l) => typeof l === "string" && l.length > 0);
|
|
325
|
+
return clean.length <= MAX_PRIOR_ATTEMPT_LINES
|
|
326
|
+
? clean
|
|
327
|
+
: clean.slice(clean.length - MAX_PRIOR_ATTEMPT_LINES);
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=fix-markers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-markers.js","sourceRoot":"","sources":["../../src/engine/fix-markers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;;;;;GAUG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAuB,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgC,IAAI,GAAG,CAAiB;IACvF,OAAO;IACP,iBAAiB;CAClB,CAAC,CAAC;AAEH,mDAAmD;AACnD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAIxE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAU,CAAC;AA0CjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C;;;;;;;;;;;;;;;;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AAI,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,OAAO,KAAK,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtF,OAAO,KAAK,CAAC,MAAM,IAAI,uBAAuB;QAC5C,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two files the harness owns inside a PR checkout — the fix loop's push
|
|
3
|
+
* gate and the PR journal — and the one argument that places both.
|
|
4
|
+
*
|
|
5
|
+
* ## They live under `.git/`, and that is the guarantee
|
|
6
|
+
*
|
|
7
|
+
* `.git/` is the repository, not the work tree. No pathspec walk enters it, so
|
|
8
|
+
* `git add -A`, `git add .` and `git commit -a` cannot see either file — on
|
|
9
|
+
* every backend, in every `buildAssets` mode, with nothing to register
|
|
10
|
+
* anywhere. That last clause is the point.
|
|
11
|
+
*
|
|
12
|
+
* Both files used to sit at the ROOT OF THE CHECKOUT and stay out of the pull
|
|
13
|
+
* request because each backend added them to the checkout's local
|
|
14
|
+
* `.git/info/exclude`. The kubernetes backend never got that code, so on k8s
|
|
15
|
+
* the harness's own scratch files were committed into the dependency PR by the
|
|
16
|
+
* agent's `git add -A` (issue #256). A guarantee that every new backend has to
|
|
17
|
+
* re-implement is not a guarantee; a path git structurally cannot reach is.
|
|
18
|
+
* The failure mode of a backend forgetting is now a STALE GATE, which is
|
|
19
|
+
* recoverable and locally visible, rather than a COMMITTED FILE, which is
|
|
20
|
+
* neither.
|
|
21
|
+
*
|
|
22
|
+
* ## Why not a sibling of the checkout
|
|
23
|
+
*
|
|
24
|
+
* gondolin is the packaged default (`sandbox.backend: gondolin`) and mounts
|
|
25
|
+
* only cwd, so a workspace-root sibling reached via `../` is unreachable inside
|
|
26
|
+
* the guest — the gate would silently never run and the journal would silently
|
|
27
|
+
* never be written on the default backend. `.git/` is inside cwd, so it is
|
|
28
|
+
* reachable there. (This is also why `artifactIssueDir`'s relocation could not
|
|
29
|
+
* be reused: it is conditional on `buildAssets === "server"` AND a non-gondolin
|
|
30
|
+
* backend, and these two must be placed correctly everywhere.)
|
|
31
|
+
*
|
|
32
|
+
* ## Why one uniform path
|
|
33
|
+
*
|
|
34
|
+
* The prompts state a bare relative path with the agent's cwd already the
|
|
35
|
+
* checkout, and the harness resolves the same path from the run row. Neither
|
|
36
|
+
* has to know the backend. It also keeps `generic_loop.until_bash` a LITERAL
|
|
37
|
+
* string, which the engine's `validateShellCommand` requires — it rejects any
|
|
38
|
+
* command containing `{{`, so the gate path cannot be templated per backend.
|
|
39
|
+
* `tests/workflows/pr-fix.test.ts` pins the YAML literal to
|
|
40
|
+
* {@link VERIFY_SCRIPT_NAME} so the two cannot drift.
|
|
41
|
+
*
|
|
42
|
+
* ## What still has to happen per run
|
|
43
|
+
*
|
|
44
|
+
* `git clean -fdx` does not enter `.git/` either, so the explicit deletes in
|
|
45
|
+
* `./executors/shared.ts` (`resetVerifyScript`, `resetPrNotesJournal`) are the
|
|
46
|
+
* ONLY thing that clears a file an earlier attempt left behind. On the
|
|
47
|
+
* kubernetes backend the harness has no filesystem access to the PVC, so the
|
|
48
|
+
* clone init container does it instead (`../sandbox/k8s/init-clone.ts`).
|
|
49
|
+
*
|
|
50
|
+
* Pure: two strings and no I/O, so the pure decision modules
|
|
51
|
+
* (`./pr-decisions.ts`, `./pr-notes.ts`) can project them onto the prompt
|
|
52
|
+
* context without importing the executor layer.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* The within-run push gate (04-retry.md §4.5, 09-state-machine.md §S1).
|
|
56
|
+
*
|
|
57
|
+
* The right gate command is not statically knowable — the package manager comes
|
|
58
|
+
* from the lockfile and the commands from the repo's own CI workflow — so
|
|
59
|
+
* `skills/fixing/SKILL.md` has the agent write it here, and the fix loop runs
|
|
60
|
+
* it through `generic_loop.until_bash`; exit 0 ends the loop.
|
|
61
|
+
*
|
|
62
|
+
* A STALE gate is worse than no gate: it passes green against the wrong
|
|
63
|
+
* commands and authorises a push. That is what `resetVerifyScript` exists for,
|
|
64
|
+
* and it matters because the fix FAMILY shares ONE workspace per PR (§S4) — a
|
|
65
|
+
* gate written by a superseded diagnosis, possibly by the *other* fix workflow,
|
|
66
|
+
* outlives the run that wrote it.
|
|
67
|
+
*/
|
|
68
|
+
export declare const VERIFY_SCRIPT_NAME = ".git/lastlight-verify.sh";
|
|
69
|
+
/**
|
|
70
|
+
* The PR journal — the agent's outbox for `PrState.notes` (10-pr-memory.md).
|
|
71
|
+
*
|
|
72
|
+
* Drained into the run's scratch at the end of every phase (`./fix-harvest.ts`
|
|
73
|
+
* → `drainPrNotes`), so its durable home is the snapshot; the file itself is a
|
|
74
|
+
* per-phase outbox, never an accumulator.
|
|
75
|
+
*/
|
|
76
|
+
export declare const PR_NOTES_FILE_NAME = ".git/lastlight-notes";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two files the harness owns inside a PR checkout — the fix loop's push
|
|
3
|
+
* gate and the PR journal — and the one argument that places both.
|
|
4
|
+
*
|
|
5
|
+
* ## They live under `.git/`, and that is the guarantee
|
|
6
|
+
*
|
|
7
|
+
* `.git/` is the repository, not the work tree. No pathspec walk enters it, so
|
|
8
|
+
* `git add -A`, `git add .` and `git commit -a` cannot see either file — on
|
|
9
|
+
* every backend, in every `buildAssets` mode, with nothing to register
|
|
10
|
+
* anywhere. That last clause is the point.
|
|
11
|
+
*
|
|
12
|
+
* Both files used to sit at the ROOT OF THE CHECKOUT and stay out of the pull
|
|
13
|
+
* request because each backend added them to the checkout's local
|
|
14
|
+
* `.git/info/exclude`. The kubernetes backend never got that code, so on k8s
|
|
15
|
+
* the harness's own scratch files were committed into the dependency PR by the
|
|
16
|
+
* agent's `git add -A` (issue #256). A guarantee that every new backend has to
|
|
17
|
+
* re-implement is not a guarantee; a path git structurally cannot reach is.
|
|
18
|
+
* The failure mode of a backend forgetting is now a STALE GATE, which is
|
|
19
|
+
* recoverable and locally visible, rather than a COMMITTED FILE, which is
|
|
20
|
+
* neither.
|
|
21
|
+
*
|
|
22
|
+
* ## Why not a sibling of the checkout
|
|
23
|
+
*
|
|
24
|
+
* gondolin is the packaged default (`sandbox.backend: gondolin`) and mounts
|
|
25
|
+
* only cwd, so a workspace-root sibling reached via `../` is unreachable inside
|
|
26
|
+
* the guest — the gate would silently never run and the journal would silently
|
|
27
|
+
* never be written on the default backend. `.git/` is inside cwd, so it is
|
|
28
|
+
* reachable there. (This is also why `artifactIssueDir`'s relocation could not
|
|
29
|
+
* be reused: it is conditional on `buildAssets === "server"` AND a non-gondolin
|
|
30
|
+
* backend, and these two must be placed correctly everywhere.)
|
|
31
|
+
*
|
|
32
|
+
* ## Why one uniform path
|
|
33
|
+
*
|
|
34
|
+
* The prompts state a bare relative path with the agent's cwd already the
|
|
35
|
+
* checkout, and the harness resolves the same path from the run row. Neither
|
|
36
|
+
* has to know the backend. It also keeps `generic_loop.until_bash` a LITERAL
|
|
37
|
+
* string, which the engine's `validateShellCommand` requires — it rejects any
|
|
38
|
+
* command containing `{{`, so the gate path cannot be templated per backend.
|
|
39
|
+
* `tests/workflows/pr-fix.test.ts` pins the YAML literal to
|
|
40
|
+
* {@link VERIFY_SCRIPT_NAME} so the two cannot drift.
|
|
41
|
+
*
|
|
42
|
+
* ## What still has to happen per run
|
|
43
|
+
*
|
|
44
|
+
* `git clean -fdx` does not enter `.git/` either, so the explicit deletes in
|
|
45
|
+
* `./executors/shared.ts` (`resetVerifyScript`, `resetPrNotesJournal`) are the
|
|
46
|
+
* ONLY thing that clears a file an earlier attempt left behind. On the
|
|
47
|
+
* kubernetes backend the harness has no filesystem access to the PVC, so the
|
|
48
|
+
* clone init container does it instead (`../sandbox/k8s/init-clone.ts`).
|
|
49
|
+
*
|
|
50
|
+
* Pure: two strings and no I/O, so the pure decision modules
|
|
51
|
+
* (`./pr-decisions.ts`, `./pr-notes.ts`) can project them onto the prompt
|
|
52
|
+
* context without importing the executor layer.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* The within-run push gate (04-retry.md §4.5, 09-state-machine.md §S1).
|
|
56
|
+
*
|
|
57
|
+
* The right gate command is not statically knowable — the package manager comes
|
|
58
|
+
* from the lockfile and the commands from the repo's own CI workflow — so
|
|
59
|
+
* `skills/fixing/SKILL.md` has the agent write it here, and the fix loop runs
|
|
60
|
+
* it through `generic_loop.until_bash`; exit 0 ends the loop.
|
|
61
|
+
*
|
|
62
|
+
* A STALE gate is worse than no gate: it passes green against the wrong
|
|
63
|
+
* commands and authorises a push. That is what `resetVerifyScript` exists for,
|
|
64
|
+
* and it matters because the fix FAMILY shares ONE workspace per PR (§S4) — a
|
|
65
|
+
* gate written by a superseded diagnosis, possibly by the *other* fix workflow,
|
|
66
|
+
* outlives the run that wrote it.
|
|
67
|
+
*/
|
|
68
|
+
export const VERIFY_SCRIPT_NAME = ".git/lastlight-verify.sh";
|
|
69
|
+
/**
|
|
70
|
+
* The PR journal — the agent's outbox for `PrState.notes` (10-pr-memory.md).
|
|
71
|
+
*
|
|
72
|
+
* Drained into the run's scratch at the end of every phase (`./fix-harvest.ts`
|
|
73
|
+
* → `drainPrNotes`), so its durable home is the snapshot; the file itself is a
|
|
74
|
+
* per-phase outbox, never an accumulator.
|
|
75
|
+
*/
|
|
76
|
+
export const PR_NOTES_FILE_NAME = ".git/lastlight-notes";
|
|
77
|
+
//# sourceMappingURL=fix-scratch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-scratch.js","sourceRoot":"","sources":["../../src/engine/fix-scratch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC"}
|