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,169 @@
1
+ /**
2
+ * The marker harvest — the impure half of `./fix-markers.ts` AND of
3
+ * `./pr-notes.ts`.
4
+ *
5
+ * Two things a fix run leaves behind travel this way, and they ride the same
6
+ * `onPhaseEnd` hook on purpose: the two marker lines the agent emits in its
7
+ * OUTPUT, and the journal it appends to a FILE in the checkout
8
+ * (10-pr-memory.md). One hook, one scratch namespace, one merge — a second hook
9
+ * would be a second thing to wire at three call sites and a second thing to
10
+ * forget to wire at the fourth.
11
+ *
12
+ * A fix run's only durable output, besides the commit it may or may not have
13
+ * pushed, is the pair of marker lines the agent emits. Nothing else survives
14
+ * the run boundary: `{{phaseOutputs}}` is empty across runs, and the shared
15
+ * per-PR workspace is `reset --hard`-ed between them. So the harness reads the
16
+ * markers out of each phase's output as it completes and persists them on the
17
+ * run's `scratch`, where the NEXT dispatch's `applyDerivedState` reads them
18
+ * back off `latestForTrigger` (04-retry.md §4.2, 09-state-machine.md §S1).
19
+ *
20
+ * ## Why `scratch` and not `context`
21
+ *
22
+ * `context.prState` is the resolved snapshot, and it is written at DISPATCH —
23
+ * before any phase runs. The harvest is a post-hoc fact about the run that
24
+ * dispatch produced, so it cannot go there without rewriting the record of
25
+ * what the dispatch decision was actually taken on. `scratch` is the run's
26
+ * mutable phase-to-phase channel and already rides back on the same
27
+ * `latestForTrigger` row, so the transport costs no new column, no new query
28
+ * and no second write path.
29
+ *
30
+ * ## Two traps this module exists to absorb
31
+ *
32
+ * - **`phase` is a LABEL, not a phase name.** A `generic_loop` iteration
33
+ * arrives as `fix_iter_1` / `fix_iter_2`, a soft retry as `fix_iter_1_retry`.
34
+ * Keying on `phase === "fix"` would silently harvest nothing the moment the
35
+ * gate loop lands. This module does not key on the phase at all — the marker
36
+ * lines are self-identifying, so every phase of a fix-shaped workflow is
37
+ * scanned and the LAST marker of each kind wins (which is also the right
38
+ * answer for a loop: iteration 2 supersedes iteration 1).
39
+ * - **`mergeScratch` is a TOP-LEVEL shallow merge.** Writing
40
+ * `{ fixMarkers: { diagnosis } }` after a previous write of
41
+ * `{ fixMarkers: { fix } }` would drop the first. Every write here therefore
42
+ * re-reads the namespace and merges into it.
43
+ */
44
+ import type { StateDb } from "../state/db.js";
45
+ import type { WorkflowRun } from "../state/workflow-run-store.js";
46
+ import { type AttemptMarkers } from "./fix-markers.js";
47
+ import { type NoteProvenance, type PrNote } from "./pr-notes.js";
48
+ /**
49
+ * The `scratch` key the harvest owns.
50
+ *
51
+ * Deliberately NOT `fix`: a `generic_loop` declares its own `scratch_key` in
52
+ * YAML, `fix` is the obvious name for the gate loop's slot, and both would be
53
+ * merged into the same top-level object by `mergeScratch`.
54
+ */
55
+ export declare const FIX_HARVEST_SCRATCH_KEY = "fixMarkers";
56
+ /** What one run's harvest records. */
57
+ export interface HarvestedFixMarkers extends AttemptMarkers {
58
+ /**
59
+ * Phase bases the harvest has run over, in order, de-duplicated.
60
+ *
61
+ * Its presence — not the presence of a marker — is what says "the harvest
62
+ * ran on this run". A run row with NO `fixMarkers` key at all is either
63
+ * older than this feature or died before its first phase ended, which
64
+ * `didSpendAttempt` distinguishes.
65
+ */
66
+ phases: string[];
67
+ /** ISO timestamp of the most recent harvest write. */
68
+ at: string;
69
+ /**
70
+ * Notes this run's agent wrote into the journal (10-pr-memory.md). Already
71
+ * sanitized and bounded; `applyDerivedState` folds them onto
72
+ * {@link PrState.notes} for the next dispatch. Empty on every run that wrote
73
+ * none, which is most of them.
74
+ */
75
+ notes: PrNote[];
76
+ /**
77
+ * The push gate this run actually ran — the contents of
78
+ * `.git/lastlight-verify.sh` as the agent wrote it (09-state-machine.md §S1,
79
+ * item 1: *"record the script's contents on the run record, surfaced in the
80
+ * §S3 panel — this is the most useful debugging artifact in the fix loop"*).
81
+ *
82
+ * The gate is a file the agent writes FOR ITSELF, and `until_bash` only reads
83
+ * its exit code. That is a bounded hazard by design (real CI is always the
84
+ * merge authority, so a weak gate costs a wasted attempt, never a bad merge)
85
+ * — but only if the script is *inspectable* afterwards. Without this, "the
86
+ * gate went green and the fix was still wrong" is unanswerable: the workspace
87
+ * is reset on the next attempt and the script goes with it.
88
+ *
89
+ * Deliberately NOT static-validated. 09 §S1 is explicit that checking the
90
+ * script's contents is an arms race against your own agent; recording it lets
91
+ * a human see the problem instead of guessing at it.
92
+ *
93
+ * `null` on every run that wrote no gate — which includes every run on the
94
+ * kubernetes backend, where the harness has no filesystem access to the PVC
95
+ * (the same narrowing the PR journal carries there).
96
+ */
97
+ verifyScript: string | null;
98
+ }
99
+ /**
100
+ * Strip the engine's generated loop suffixes off a phase label.
101
+ *
102
+ * `fix_iter_2` → `fix`, `fix_iter_2_retry` → `fix`, `review_recheck_1` →
103
+ * `review`. Used only for the recorded {@link HarvestedFixMarkers.phases}
104
+ * breadcrumb — the harvest itself is label-agnostic on purpose.
105
+ */
106
+ export declare function phaseBase(label: string): string;
107
+ /**
108
+ * Read a run row's harvested markers, or null when the run has none.
109
+ *
110
+ * Tolerates every shape a `scratch` column can hold, including rows written
111
+ * before this key existed — `null` means "nothing was harvested here", which
112
+ * callers must be able to tell from "harvested, and there was no marker".
113
+ */
114
+ export declare function readHarvestedMarkers(run: Pick<WorkflowRun, "scratch"> | null | undefined): HarvestedFixMarkers | null;
115
+ /**
116
+ * Host path to the checkout a run's journal lives in, or null when the run has
117
+ * no workspace we can name.
118
+ *
119
+ * Resolved from the run row exactly as `createTaskSandbox` / `reapSandboxWorkspace`
120
+ * resolve it — `<sandboxes root>/<taskId>/<repo>` — so the three never disagree.
121
+ * `taskId` and `repo` are both persisted on `workflow_runs.context` at creation.
122
+ * A taskId that escapes the sandboxes root is refused rather than followed, the
123
+ * same guard the reaper applies.
124
+ */
125
+ export declare function prNotesRepoDir(run: Pick<WorkflowRun, "context"> | null | undefined, overrides?: {
126
+ stateDir?: string;
127
+ sandboxDir?: string;
128
+ }): string | null;
129
+ /**
130
+ * Read the push gate the agent wrote for itself, or null when it wrote none.
131
+ *
132
+ * A READ, not a drain (`drainPrNotes` below is the drain): the same file is the
133
+ * live gate `generic_loop.until_bash` runs on the next iteration, so removing
134
+ * it would disarm the loop this harvest is reporting on. The reset that DOES
135
+ * clear it happens once per attempt, at the start, in `./executors/shared.ts`.
136
+ *
137
+ * Never throws: a failed read must not fail the phase that produced it.
138
+ */
139
+ export declare function readVerifyScript(repoDir: string): string | null;
140
+ /**
141
+ * Read the journal and DELETE it — a drain, not a read.
142
+ *
143
+ * The delete is what makes the file a per-phase outbox rather than an
144
+ * accumulator: the harvest runs after every phase, and a file left in place
145
+ * would re-contribute `diagnose`'s notes at the end of `fix`. (`boundNotes`
146
+ * de-duplicates, so a failed delete degrades to "nothing new", never to a
147
+ * duplicated journal.)
148
+ *
149
+ * Never throws: a failed drain must not fail the phase that produced it.
150
+ */
151
+ export declare function drainPrNotes(repoDir: string, provenance: NoteProvenance): PrNote[];
152
+ /**
153
+ * Harvest whatever markers `output` carries — and whatever notes the checkout's
154
+ * journal carries — onto the run's scratch.
155
+ *
156
+ * Wired into `RunnerCallbacks.onPhaseEnd` at all THREE of its call sites —
157
+ * `index.ts` (fresh dispatch) plus both of `resume.ts`'s (GitHub and Slack
158
+ * resume). Harvesting only in the first would silently lose every marker on a
159
+ * run that paused for an approval gate or was resumed after a restart, which
160
+ * is precisely the population whose attempt counter matters most.
161
+ *
162
+ * Never throws: a failed harvest must not fail the phase that produced the
163
+ * output it was reading.
164
+ */
165
+ export declare function harvestFixMarkers(db: StateDb, runId: string, workflowName: string, phase: string, output: string,
166
+ /** Test seam: the checkout to drain the journal from, bypassing the run row. */
167
+ overrides?: {
168
+ repoDir?: string | null;
169
+ }): void;
@@ -0,0 +1,345 @@
1
+ /**
2
+ * The marker harvest — the impure half of `./fix-markers.ts` AND of
3
+ * `./pr-notes.ts`.
4
+ *
5
+ * Two things a fix run leaves behind travel this way, and they ride the same
6
+ * `onPhaseEnd` hook on purpose: the two marker lines the agent emits in its
7
+ * OUTPUT, and the journal it appends to a FILE in the checkout
8
+ * (10-pr-memory.md). One hook, one scratch namespace, one merge — a second hook
9
+ * would be a second thing to wire at three call sites and a second thing to
10
+ * forget to wire at the fourth.
11
+ *
12
+ * A fix run's only durable output, besides the commit it may or may not have
13
+ * pushed, is the pair of marker lines the agent emits. Nothing else survives
14
+ * the run boundary: `{{phaseOutputs}}` is empty across runs, and the shared
15
+ * per-PR workspace is `reset --hard`-ed between them. So the harness reads the
16
+ * markers out of each phase's output as it completes and persists them on the
17
+ * run's `scratch`, where the NEXT dispatch's `applyDerivedState` reads them
18
+ * back off `latestForTrigger` (04-retry.md §4.2, 09-state-machine.md §S1).
19
+ *
20
+ * ## Why `scratch` and not `context`
21
+ *
22
+ * `context.prState` is the resolved snapshot, and it is written at DISPATCH —
23
+ * before any phase runs. The harvest is a post-hoc fact about the run that
24
+ * dispatch produced, so it cannot go there without rewriting the record of
25
+ * what the dispatch decision was actually taken on. `scratch` is the run's
26
+ * mutable phase-to-phase channel and already rides back on the same
27
+ * `latestForTrigger` row, so the transport costs no new column, no new query
28
+ * and no second write path.
29
+ *
30
+ * ## Two traps this module exists to absorb
31
+ *
32
+ * - **`phase` is a LABEL, not a phase name.** A `generic_loop` iteration
33
+ * arrives as `fix_iter_1` / `fix_iter_2`, a soft retry as `fix_iter_1_retry`.
34
+ * Keying on `phase === "fix"` would silently harvest nothing the moment the
35
+ * gate loop lands. This module does not key on the phase at all — the marker
36
+ * lines are self-identifying, so every phase of a fix-shaped workflow is
37
+ * scanned and the LAST marker of each kind wins (which is also the right
38
+ * answer for a loop: iteration 2 supersedes iteration 1).
39
+ * - **`mergeScratch` is a TOP-LEVEL shallow merge.** Writing
40
+ * `{ fixMarkers: { diagnosis } }` after a previous write of
41
+ * `{ fixMarkers: { fix } }` would drop the first. Every write here therefore
42
+ * re-reads the namespace and merges into it.
43
+ */
44
+ import { closeSync, openSync, readFileSync, readSync, rmSync, statSync } from "fs";
45
+ import { join, resolve, sep } from "path";
46
+ import { getRuntimeConfig } from "../config/config.js";
47
+ import { sandboxRoot } from "../sandbox/reap.js";
48
+ import { PR_FIX_SHAPED_WORKFLOWS } from "../workflows/target-policy.js";
49
+ import { parseAttemptMarkers, } from "./fix-markers.js";
50
+ import { PR_NOTES_FILE_NAME, VERIFY_SCRIPT_NAME } from "./fix-scratch.js";
51
+ import { boundNotes, coerceNotes, parseNoteFile, } from "./pr-notes.js";
52
+ /**
53
+ * The `scratch` key the harvest owns.
54
+ *
55
+ * Deliberately NOT `fix`: a `generic_loop` declares its own `scratch_key` in
56
+ * YAML, `fix` is the obvious name for the gate loop's slot, and both would be
57
+ * merged into the same top-level object by `mergeScratch`.
58
+ */
59
+ export const FIX_HARVEST_SCRATCH_KEY = "fixMarkers";
60
+ /**
61
+ * Strip the engine's generated loop suffixes off a phase label.
62
+ *
63
+ * `fix_iter_2` → `fix`, `fix_iter_2_retry` → `fix`, `review_recheck_1` →
64
+ * `review`. Used only for the recorded {@link HarvestedFixMarkers.phases}
65
+ * breadcrumb — the harvest itself is label-agnostic on purpose.
66
+ */
67
+ export function phaseBase(label) {
68
+ return label
69
+ .replace(/_iter_\d+_retry$/, "")
70
+ .replace(/_iter_\d+$/, "")
71
+ .replace(/_fix_\d+$/, "")
72
+ .replace(/_recheck_\d+$/, "");
73
+ }
74
+ /**
75
+ * Read a run row's harvested markers, or null when the run has none.
76
+ *
77
+ * Tolerates every shape a `scratch` column can hold, including rows written
78
+ * before this key existed — `null` means "nothing was harvested here", which
79
+ * callers must be able to tell from "harvested, and there was no marker".
80
+ */
81
+ export function readHarvestedMarkers(run) {
82
+ const slot = run?.scratch?.[FIX_HARVEST_SCRATCH_KEY];
83
+ if (!slot || typeof slot !== "object" || Array.isArray(slot))
84
+ return null;
85
+ const raw = slot;
86
+ return {
87
+ diagnosis: raw.diagnosis ?? null,
88
+ fix: raw.fix ?? null,
89
+ phases: Array.isArray(raw.phases) ? raw.phases.filter((p) => typeof p === "string") : [],
90
+ at: typeof raw.at === "string" ? raw.at : "",
91
+ notes: coerceNotes(raw.notes),
92
+ verifyScript: typeof raw.verifyScript === "string" ? raw.verifyScript : null,
93
+ };
94
+ }
95
+ // ---------------------------------------------------------------------------
96
+ // The journal — where it lives, and why not `../`
97
+ // ---------------------------------------------------------------------------
98
+ /**
99
+ * The journal is a file inside the checkout's own `.git/` directory
100
+ * (`<workspace>/<repo>/.git/lastlight-notes`) on EVERY backend.
101
+ *
102
+ * That is deliberately the same resolution `.git/lastlight-verify.sh` reached
103
+ * (`./executors/shared.ts` → the push gate), and for the same reasons — with one
104
+ * extra:
105
+ *
106
+ * 1. **Git structurally cannot see it.** `.git/` is the repository, not the
107
+ * work tree; no pathspec walk enters it, so `git add -A` cannot commit the
108
+ * journal on any backend, in any `buildAssets` mode, with nothing to
109
+ * register anywhere. That last clause is the whole point: the journal used
110
+ * to sit at the checkout root and depend on each backend adding it to the
111
+ * local `.git/info/exclude`, and the kubernetes backend never got that code
112
+ * (#256). A guarantee that every new backend must re-implement is not a
113
+ * guarantee.
114
+ * 2. **gondolin is the packaged default** (`sandbox.backend: gondolin`) and
115
+ * mounts only cwd, so a workspace-root sibling reached via `../` is simply
116
+ * unreachable inside the guest. A `../` journal would silently never be
117
+ * written on the default backend — the worst possible failure mode for a
118
+ * memory feature, because it looks like "the agent had nothing to say".
119
+ * `.git/` is inside cwd, so it is reachable there.
120
+ * 3. **One uniform path is what makes the prompt and the harvest agree.** The
121
+ * agent is told a bare relative path with its cwd already the checkout; the
122
+ * harvest resolves the same path from the run row. Neither has to know the
123
+ * backend, which is exactly what `artifactIssueDir` DOES have to know — its
124
+ * relocation is conditional on `buildAssets === "server"` AND a non-gondolin
125
+ * backend, so it is not reusable here.
126
+ *
127
+ * `git clean -fdx -e node_modules` on a cross-run workspace refresh does NOT
128
+ * reach inside `.git/`, so the explicit `resetPrNotesJournal` delete is the only
129
+ * thing that clears a file a crashed run left behind — which is the point of it
130
+ * existing. The journal is DRAINED into the run's scratch at the end of every
131
+ * phase, so its durable home is the snapshot either way.
132
+ */
133
+ function isWithin(parent, child) {
134
+ return child === parent || child.startsWith(`${parent}${sep}`);
135
+ }
136
+ /**
137
+ * Host path to the checkout a run's journal lives in, or null when the run has
138
+ * no workspace we can name.
139
+ *
140
+ * Resolved from the run row exactly as `createTaskSandbox` / `reapSandboxWorkspace`
141
+ * resolve it — `<sandboxes root>/<taskId>/<repo>` — so the three never disagree.
142
+ * `taskId` and `repo` are both persisted on `workflow_runs.context` at creation.
143
+ * A taskId that escapes the sandboxes root is refused rather than followed, the
144
+ * same guard the reaper applies.
145
+ */
146
+ export function prNotesRepoDir(run, overrides = {}) {
147
+ const ctx = run?.context;
148
+ const taskId = typeof ctx?.taskId === "string" ? ctx.taskId : "";
149
+ const repo = typeof ctx?.repo === "string" ? ctx.repo : "";
150
+ if (!taskId || !repo)
151
+ return null;
152
+ const rt = getRuntimeConfig();
153
+ const stateDir = overrides.stateDir || rt?.stateDir || process.env.STATE_DIR || "data";
154
+ const base = sandboxRoot(stateDir, overrides.sandboxDir ?? rt?.sandboxDir);
155
+ const dir = resolve(base, taskId, repo);
156
+ if (!isWithin(base, dir))
157
+ return null;
158
+ return dir;
159
+ }
160
+ /**
161
+ * Cap on how much of the journal file is read.
162
+ *
163
+ * The file is written by a language model inside a sandbox, so "it will be a
164
+ * handful of lines" is a hope, not a bound. Reading only the TAIL keeps a
165
+ * runaway loop that appended a gigabyte from being pulled into the harness
166
+ * process, and the tail is the right end to keep: notes are appended, so the
167
+ * newest are last — the same "keep the newest" rule the cap itself uses.
168
+ */
169
+ const MAX_NOTES_FILE_BYTES = 64 * 1024;
170
+ /** Read at most the last {@link MAX_NOTES_FILE_BYTES} of a file, or null. */
171
+ function readTail(path) {
172
+ let size;
173
+ try {
174
+ size = statSync(path).size;
175
+ }
176
+ catch {
177
+ return null; // no journal — the overwhelmingly common case
178
+ }
179
+ if (size <= MAX_NOTES_FILE_BYTES) {
180
+ try {
181
+ return readFileSync(path, "utf8");
182
+ }
183
+ catch {
184
+ return null;
185
+ }
186
+ }
187
+ let fd;
188
+ try {
189
+ fd = openSync(path, "r");
190
+ const buf = Buffer.alloc(MAX_NOTES_FILE_BYTES);
191
+ const read = readSync(fd, buf, 0, MAX_NOTES_FILE_BYTES, size - MAX_NOTES_FILE_BYTES);
192
+ // Drop the first (probably partial) line rather than parsing half a note.
193
+ return buf.subarray(0, read).toString("utf8").replace(/^[^\n]*\n/, "");
194
+ }
195
+ catch {
196
+ return null;
197
+ }
198
+ finally {
199
+ if (fd !== undefined) {
200
+ try {
201
+ closeSync(fd);
202
+ }
203
+ catch {
204
+ /* nothing useful to do */
205
+ }
206
+ }
207
+ }
208
+ }
209
+ /**
210
+ * Cap on how much of the gate script is recorded.
211
+ *
212
+ * Smaller than the journal's cap and taken from the HEAD rather than the tail:
213
+ * a shell script is read top-down, and the interesting part of a runaway one is
214
+ * where it starts, not where it ends.
215
+ */
216
+ const MAX_VERIFY_SCRIPT_BYTES = 8 * 1024;
217
+ /**
218
+ * Read the push gate the agent wrote for itself, or null when it wrote none.
219
+ *
220
+ * A READ, not a drain (`drainPrNotes` below is the drain): the same file is the
221
+ * live gate `generic_loop.until_bash` runs on the next iteration, so removing
222
+ * it would disarm the loop this harvest is reporting on. The reset that DOES
223
+ * clear it happens once per attempt, at the start, in `./executors/shared.ts`.
224
+ *
225
+ * Never throws: a failed read must not fail the phase that produced it.
226
+ */
227
+ export function readVerifyScript(repoDir) {
228
+ const path = join(repoDir, VERIFY_SCRIPT_NAME);
229
+ try {
230
+ const body = readFileSync(path, "utf8");
231
+ if (!body.trim())
232
+ return null;
233
+ return body.length > MAX_VERIFY_SCRIPT_BYTES
234
+ ? `${body.slice(0, MAX_VERIFY_SCRIPT_BYTES)}\n… truncated at ${MAX_VERIFY_SCRIPT_BYTES} bytes`
235
+ : body;
236
+ }
237
+ catch {
238
+ return null; // no gate written yet — the state every run starts in
239
+ }
240
+ }
241
+ /**
242
+ * Read the journal and DELETE it — a drain, not a read.
243
+ *
244
+ * The delete is what makes the file a per-phase outbox rather than an
245
+ * accumulator: the harvest runs after every phase, and a file left in place
246
+ * would re-contribute `diagnose`'s notes at the end of `fix`. (`boundNotes`
247
+ * de-duplicates, so a failed delete degrades to "nothing new", never to a
248
+ * duplicated journal.)
249
+ *
250
+ * Never throws: a failed drain must not fail the phase that produced it.
251
+ */
252
+ export function drainPrNotes(repoDir, provenance) {
253
+ const path = join(repoDir, PR_NOTES_FILE_NAME);
254
+ const body = readTail(path);
255
+ if (body === null)
256
+ return [];
257
+ try {
258
+ rmSync(path, { force: true });
259
+ }
260
+ catch {
261
+ /* de-duplication covers a file we could not remove */
262
+ }
263
+ return parseNoteFile(body, provenance);
264
+ }
265
+ /**
266
+ * Harvest whatever markers `output` carries — and whatever notes the checkout's
267
+ * journal carries — onto the run's scratch.
268
+ *
269
+ * Wired into `RunnerCallbacks.onPhaseEnd` at all THREE of its call sites —
270
+ * `index.ts` (fresh dispatch) plus both of `resume.ts`'s (GitHub and Slack
271
+ * resume). Harvesting only in the first would silently lose every marker on a
272
+ * run that paused for an approval gate or was resumed after a restart, which
273
+ * is precisely the population whose attempt counter matters most.
274
+ *
275
+ * Never throws: a failed harvest must not fail the phase that produced the
276
+ * output it was reading.
277
+ */
278
+ export function harvestFixMarkers(db, runId, workflowName, phase, output,
279
+ /** Test seam: the checkout to drain the journal from, bypassing the run row. */
280
+ overrides = {}) {
281
+ // Only the fix family carries the MARKERS, and only it reads them back. The
282
+ // JOURNAL is wider — see the gate below — so this is no longer an early
283
+ // return for the whole function.
284
+ const wantsMarkers = PR_FIX_SHAPED_WORKFLOWS.has(workflowName);
285
+ try {
286
+ const run = db.runs.getRun(runId);
287
+ // Which runs may write a note? Every PR-SCOPED one — `pr-review` reading
288
+ // what `dependabot-ci-fix` learned is the point of keying on the PR
289
+ // (10-pr-memory.md). Rather than import a second workflow-name set (which
290
+ // would put this module and `./pr-state.ts` in an import cycle), the gate
291
+ // reads the fact at its source: a run carries `context.prState` iff the
292
+ // dispatcher resolved a snapshot for it, which is exactly the definition of
293
+ // PR-scoped. It therefore tracks `prScopedWorkflows()` automatically as
294
+ // that set changes — including a workflow an operator adds by declaring
295
+ // `pr_scoped: true` in an overlay.
296
+ const wantsNotes = !!run?.context?.prState;
297
+ if (!wantsMarkers && !wantsNotes)
298
+ return;
299
+ const parsed = wantsMarkers ? parseAttemptMarkers(output ?? "") : {};
300
+ const current = readHarvestedMarkers(run);
301
+ const base = phaseBase(phase);
302
+ const phases = current?.phases ?? [];
303
+ const at = new Date().toISOString();
304
+ let notes = current?.notes ?? [];
305
+ // The gate script is recorded for the FIX FAMILY only — it is the only
306
+ // family that writes one. Its last non-null reading stands: the file is
307
+ // reset once per attempt, not per phase, so a later phase that cannot see
308
+ // the workspace must not blank the gate an earlier one recorded.
309
+ let verifyScript = current?.verifyScript ?? null;
310
+ if (wantsNotes || wantsMarkers) {
311
+ const repoDir = overrides.repoDir !== undefined ? overrides.repoDir : prNotesRepoDir(run);
312
+ if (repoDir) {
313
+ if (wantsNotes) {
314
+ const fresh = drainPrNotes(repoDir, { at, runId, workflow: workflowName, phase });
315
+ if (fresh.length > 0)
316
+ notes = boundNotes([...notes, ...fresh]);
317
+ }
318
+ if (wantsMarkers)
319
+ verifyScript = readVerifyScript(repoDir) ?? verifyScript;
320
+ }
321
+ }
322
+ // A PR-scoped run that is not fix-shaped and wrote no note has nothing to
323
+ // record — leave its scratch untouched rather than stamping an empty
324
+ // namespace on every `pr-review` phase.
325
+ if (!wantsMarkers && notes.length === 0)
326
+ return;
327
+ const next = {
328
+ // Last marker of each kind wins. A `generic_loop` iteration 2 supersedes
329
+ // iteration 1; a phase that emitted nothing leaves the earlier value
330
+ // standing rather than blanking it.
331
+ diagnosis: parsed.diagnosis ?? current?.diagnosis ?? null,
332
+ fix: parsed.fix ?? current?.fix ?? null,
333
+ phases: phases.includes(base) ? phases : [...phases, base],
334
+ at,
335
+ notes,
336
+ verifyScript,
337
+ };
338
+ db.runs.mergeScratch(runId, { [FIX_HARVEST_SCRATCH_KEY]: next });
339
+ }
340
+ catch (err) {
341
+ const msg = err instanceof Error ? err.message : String(err);
342
+ console.warn(`[fix-harvest] ${workflowName}/${phase} run ${runId}: ${msg}`);
343
+ }
344
+ }
345
+ //# sourceMappingURL=fix-harvest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix-harvest.js","sourceRoot":"","sources":["../../src/engine/fix-harvest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EACL,mBAAmB,GAIpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,UAAU,EACV,WAAW,EACX,aAAa,GAGd,MAAM,eAAe,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;AA8CpD;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK;SACT,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAC/B,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,OAAO,CAAC,WAAW,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