lastlight-core 0.21.14 → 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.
Files changed (124) hide show
  1. package/config/default.yaml +119 -1
  2. package/dist/admin/routes.js +195 -38
  3. package/dist/admin/routes.js.map +1 -1
  4. package/dist/config/config-resolve.d.ts +38 -1
  5. package/dist/config/config-resolve.js +41 -17
  6. package/dist/config/config-resolve.js.map +1 -1
  7. package/dist/config/config.d.ts +114 -0
  8. package/dist/config/config.js +225 -7
  9. package/dist/config/config.js.map +1 -1
  10. package/dist/config/repo-config.d.ts +120 -0
  11. package/dist/config/repo-config.js +447 -0
  12. package/dist/config/repo-config.js.map +1 -0
  13. package/dist/connectors/github-webhook.d.ts +17 -0
  14. package/dist/connectors/github-webhook.js +150 -17
  15. package/dist/connectors/github-webhook.js.map +1 -1
  16. package/dist/connectors/types.d.ts +48 -1
  17. package/dist/cron/dependabot-discovery.d.ts +68 -11
  18. package/dist/cron/dependabot-discovery.js +78 -20
  19. package/dist/cron/dependabot-discovery.js.map +1 -1
  20. package/dist/cron/fanout.d.ts +10 -0
  21. package/dist/cron/fanout.js +35 -2
  22. package/dist/cron/fanout.js.map +1 -1
  23. package/dist/cron/jobs.d.ts +16 -2
  24. package/dist/cron/jobs.js +69 -9
  25. package/dist/cron/jobs.js.map +1 -1
  26. package/dist/cron/repo-crons.d.ts +110 -0
  27. package/dist/cron/repo-crons.js +169 -0
  28. package/dist/cron/repo-crons.js.map +1 -0
  29. package/dist/cron/review-discovery.d.ts +33 -20
  30. package/dist/cron/review-discovery.js +23 -30
  31. package/dist/cron/review-discovery.js.map +1 -1
  32. package/dist/engine/agent-executor.d.ts +1 -1
  33. package/dist/engine/agent-executor.js +1 -1
  34. package/dist/engine/agent-executor.js.map +1 -1
  35. package/dist/engine/dispatcher.d.ts +98 -1
  36. package/dist/engine/dispatcher.js +248 -231
  37. package/dist/engine/dispatcher.js.map +1 -1
  38. package/dist/engine/executors/orchestrator.js +39 -15
  39. package/dist/engine/executors/orchestrator.js.map +1 -1
  40. package/dist/engine/executors/shared.d.ts +43 -0
  41. package/dist/engine/executors/shared.js +65 -0
  42. package/dist/engine/executors/shared.js.map +1 -1
  43. package/dist/engine/fix-harvest.d.ts +169 -0
  44. package/dist/engine/fix-harvest.js +345 -0
  45. package/dist/engine/fix-harvest.js.map +1 -0
  46. package/dist/engine/fix-markers.d.ts +184 -0
  47. package/dist/engine/fix-markers.js +329 -0
  48. package/dist/engine/fix-markers.js.map +1 -0
  49. package/dist/engine/fix-scratch.d.ts +76 -0
  50. package/dist/engine/fix-scratch.js +77 -0
  51. package/dist/engine/fix-scratch.js.map +1 -0
  52. package/dist/engine/github/github.d.ts +302 -5
  53. package/dist/engine/github/github.js +614 -54
  54. package/dist/engine/github/github.js.map +1 -1
  55. package/dist/engine/github/profiles.d.ts +45 -1
  56. package/dist/engine/github/profiles.js +35 -0
  57. package/dist/engine/github/profiles.js.map +1 -1
  58. package/dist/engine/pr-decisions.d.ts +342 -0
  59. package/dist/engine/pr-decisions.js +721 -0
  60. package/dist/engine/pr-decisions.js.map +1 -0
  61. package/dist/engine/pr-escalation.d.ts +152 -0
  62. package/dist/engine/pr-escalation.js +320 -0
  63. package/dist/engine/pr-escalation.js.map +1 -0
  64. package/dist/engine/pr-notes.d.ts +175 -0
  65. package/dist/engine/pr-notes.js +315 -0
  66. package/dist/engine/pr-notes.js.map +1 -0
  67. package/dist/engine/pr-state.d.ts +313 -0
  68. package/dist/engine/pr-state.js +515 -0
  69. package/dist/engine/pr-state.js.map +1 -0
  70. package/dist/engine/review-check.d.ts +200 -0
  71. package/dist/engine/review-check.js +305 -0
  72. package/dist/engine/review-check.js.map +1 -0
  73. package/dist/engine/router.d.ts +27 -0
  74. package/dist/engine/router.js +156 -22
  75. package/dist/engine/router.js.map +1 -1
  76. package/dist/evals-api.d.ts +10 -0
  77. package/dist/evals-api.js +38 -0
  78. package/dist/evals-api.js.map +1 -1
  79. package/dist/index.js +313 -23
  80. package/dist/index.js.map +1 -1
  81. package/dist/sandbox/index.d.ts +13 -0
  82. package/dist/sandbox/index.js +30 -0
  83. package/dist/sandbox/index.js.map +1 -1
  84. package/dist/sandbox/k8s/init-clone.d.ts +5 -0
  85. package/dist/sandbox/k8s/init-clone.js +27 -0
  86. package/dist/sandbox/k8s/init-clone.js.map +1 -1
  87. package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +26 -1
  88. package/dist/sandbox/k8s/kubernetes-sandbox.js +30 -1
  89. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  90. package/dist/state/execution-store.d.ts +27 -0
  91. package/dist/state/execution-store.js +45 -0
  92. package/dist/state/execution-store.js.map +1 -1
  93. package/dist/state/workflow-run-store.d.ts +73 -0
  94. package/dist/state/workflow-run-store.js +106 -24
  95. package/dist/state/workflow-run-store.js.map +1 -1
  96. package/dist/workflows/pr-scope.d.ts +63 -0
  97. package/dist/workflows/pr-scope.js +113 -0
  98. package/dist/workflows/pr-scope.js.map +1 -0
  99. package/dist/workflows/resume.js +113 -8
  100. package/dist/workflows/resume.js.map +1 -1
  101. package/dist/workflows/runner.d.ts +2 -1
  102. package/dist/workflows/runner.js +143 -10
  103. package/dist/workflows/runner.js.map +1 -1
  104. package/dist/workflows/simple.d.ts +280 -1
  105. package/dist/workflows/simple.js +499 -8
  106. package/dist/workflows/simple.js.map +1 -1
  107. package/dist/workflows/target-policy.d.ts +0 -12
  108. package/dist/workflows/target-policy.js +9 -15
  109. package/dist/workflows/target-policy.js.map +1 -1
  110. package/package.json +4 -4
  111. package/skills/README.md +11 -5
  112. package/skills/dependency-impact/SKILL.md +83 -0
  113. package/skills/fixing/SKILL.md +190 -0
  114. package/skills/pr-review/SKILL.md +26 -9
  115. package/workflows/cron-dependabot-ci-fix.yaml +8 -5
  116. package/workflows/cron-review.yaml +14 -5
  117. package/workflows/dependabot-ci-fix.yaml +86 -2
  118. package/workflows/dependabot-pr-merge.yaml +13 -1
  119. package/workflows/pr-fix.yaml +84 -1
  120. package/workflows/pr-review.yaml +7 -0
  121. package/workflows/prompts/dependabot-ci-fix.md +70 -17
  122. package/workflows/prompts/dependabot-pr-merge.md +203 -80
  123. package/workflows/prompts/diagnose-ci.md +96 -0
  124. package/workflows/prompts/pr-fix.md +63 -4
@@ -0,0 +1,184 @@
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, type DiagnosisClass } from "lastlight-shared/config-types";
47
+ export { DIAGNOSIS_CLASSES, isDiagnosisClass, type DiagnosisClass };
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 declare const ATTEMPT_FREE_CLASSES: ReadonlySet<DiagnosisClass>;
64
+ /** What the `fix` phase did with the diagnosis. */
65
+ export declare const FIX_OUTCOMES: readonly ["pushed", "no-change", "gave-up"];
66
+ export type FixOutcome = (typeof FIX_OUTCOMES)[number];
67
+ /**
68
+ * The local gate's verdict. `skipped` means no gate ran — which 09 → S1 is
69
+ * explicit never authorises a push, so it is a distinct value rather than
70
+ * being folded into `red`.
71
+ */
72
+ export declare const GATE_RESULTS: readonly ["green", "red", "skipped"];
73
+ export type GateResult = (typeof GATE_RESULTS)[number];
74
+ /** A parsed `DIAGNOSIS_COMPLETE` line. Every field degrades independently. */
75
+ export interface DiagnosisMarker {
76
+ /** PR number the agent believed it was working on, or null when unparseable. */
77
+ pr: number | null;
78
+ /** Attempt number the agent was told it was on. Advisory — ours is authoritative. */
79
+ attempt: number | null;
80
+ /** One of {@link DIAGNOSIS_CLASSES}, or null when absent OR unrecognised. */
81
+ class: DiagnosisClass | null;
82
+ /** The raw `class=` token as written, so an unknown value stays inspectable. */
83
+ rawClass: string | null;
84
+ /** Why CI failed. Free text, clamped. */
85
+ cause: string;
86
+ /** What differs between CI and the sandbox. Free text, clamped. */
87
+ ciVsLocal: string;
88
+ /** Check names the agent could not reproduce here. */
89
+ unreproducible: string[];
90
+ }
91
+ /** A parsed `CI_FIX_COMPLETE` line. */
92
+ export interface FixOutcomeMarker {
93
+ pr: number | null;
94
+ attempt: number | null;
95
+ /** One of {@link FIX_OUTCOMES}, or null when absent OR unrecognised. */
96
+ outcome: FixOutcome | null;
97
+ rawOutcome: string | null;
98
+ /** What the agent tried. Free text, clamped. */
99
+ tried: string;
100
+ /** One of {@link GATE_RESULTS}, or null when absent OR unrecognised. */
101
+ gate: GateResult | null;
102
+ rawGate: string | null;
103
+ }
104
+ /** The pair of markers one attempt can produce. */
105
+ export interface AttemptMarkers {
106
+ diagnosis?: DiagnosisMarker | null;
107
+ fix?: FixOutcomeMarker | null;
108
+ }
109
+ export declare const DIAGNOSIS_MARKER = "DIAGNOSIS_COMPLETE";
110
+ export declare const CI_FIX_MARKER = "CI_FIX_COMPLETE";
111
+ /**
112
+ * What a fix phase's `on_output.requires_marker` must name — the tag **with its
113
+ * colon**, which is the same string {@link lastMarkerLine} looks for.
114
+ *
115
+ * The engine enforces the postcondition as a bare `output.includes(marker)`, so
116
+ * declaring the tag alone made the gate and the parser disagree about what a
117
+ * marker IS. An output that merely *mentions* `DIAGNOSIS_COMPLETE` — an agent
118
+ * narrating "I'll close with DIAGNOSIS_COMPLETE" and then not, or fencing the
119
+ * word in prose — passed the postcondition and parsed to nothing. The phase went
120
+ * green, the harvest recorded a diagnosis of `null`, and the attempt counter
121
+ * never advanced: the PR sat at attempt 1 for its whole life with
122
+ * `fix.maxCostUsd` as the only remaining brake.
123
+ *
124
+ * Requiring the parseable form instead makes a malformed marker fail the phase
125
+ * loudly, which is what a postcondition is for. Exported so the YAML can be
126
+ * asserted against it rather than against a hand-copied literal.
127
+ */
128
+ export declare const DIAGNOSIS_MARKER_POSTCONDITION = "DIAGNOSIS_COMPLETE:";
129
+ export declare const CI_FIX_MARKER_POSTCONDITION = "CI_FIX_COMPLETE:";
130
+ /** Longest whole rendered attempt line. */
131
+ export declare const MAX_ATTEMPT_LINE_CHARS = 200;
132
+ /** How many rendered attempt lines {@link boundAttemptLines} keeps. */
133
+ export declare const MAX_PRIOR_ATTEMPT_LINES = 6;
134
+ /**
135
+ * The LAST line of `output` that carries `<tag>:`, with everything up to and
136
+ * including the tag stripped.
137
+ *
138
+ * The skill says the marker is the last line, and this deliberately does not
139
+ * insist on it. Two real shapes break a strict last-line read: an agent that
140
+ * fences the marker in backticks or prefixes it with a bullet, and a
141
+ * `generic_loop` iteration whose `{{previousOutput}}` replays the PREVIOUS
142
+ * iteration's marker earlier in the same text. Scanning backwards and taking
143
+ * the last hit handles both — the genuine final marker always wins.
144
+ */
145
+ export declare function lastMarkerLine(output: string, tag: string): string | null;
146
+ /**
147
+ * Parse the last `DIAGNOSIS_COMPLETE` line out of a phase's full output.
148
+ *
149
+ * Returns null when there is no marker at all — which is a MEANINGFUL answer,
150
+ * not an error: a run with no `DIAGNOSIS_COMPLETE` spent no attempt (09 → S1,
151
+ * "a crashed run must not consume budget").
152
+ */
153
+ export declare function parseDiagnosisMarker(output: string): DiagnosisMarker | null;
154
+ /** Parse the last `CI_FIX_COMPLETE` line out of a phase's full output. */
155
+ export declare function parseFixOutcomeMarker(output: string): FixOutcomeMarker | null;
156
+ /** Parse both markers out of one phase output. Either half may be null. */
157
+ export declare function parseAttemptMarkers(output: string): AttemptMarkers;
158
+ /**
159
+ * The single line attempt N leaves behind for attempts N+1, N+2, …
160
+ *
161
+ * ```
162
+ * attempt 2: class=env-mismatch cause=CI runs node 22, sandbox node 20 | outcome=pushed gate=green
163
+ * ```
164
+ *
165
+ * One line per attempt, not a transcript — attempt 3 needs to know what was
166
+ * tried and what was ruled out, not to re-read two agent sessions. `tried=` is
167
+ * deliberately NOT rendered: `cause=` plus `outcome=` already answer "what was
168
+ * wrong and did the fix land", and the whole line is replayed into every later
169
+ * prompt, so each extra clause is paid for on every subsequent attempt.
170
+ *
171
+ * Returns null when the attempt produced no marker at all — a crashed run
172
+ * leaves no line, exactly as it consumes no attempt.
173
+ */
174
+ export declare function renderAttemptLine(attempt: number, markers: AttemptMarkers | null): string | null;
175
+ /**
176
+ * Keep the journal bounded: at most {@link MAX_PRIOR_ATTEMPT_LINES} lines,
177
+ * newest kept, oldest dropped, order preserved.
178
+ *
179
+ * A PR can accumulate more RUNS than `fix.maxAttempts` — a `flaky` deferral
180
+ * spends no attempt, and the daily `fix-red-dependency-prs` cron re-picks the
181
+ * PR up every day — so the array needs its own bound rather than inheriting
182
+ * the attempt cap's.
183
+ */
184
+ export declare function boundAttemptLines(lines: string[]): string[];
@@ -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;AAE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+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";