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 @@
1
+ {"version":3,"file":"pr-decisions.js","sourceRoot":"","sources":["../../src/engine/pr-decisions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmG1E,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,gBAAgB,CAAI,QAAW,EAAE,KAAc,EAAE,MAA+B;IACvF,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC9E,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO;QACL,QAAQ;QACR,MAAM,EACJ,mDAAmD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B;YAC9F,gDAAgD;QAClD,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE;QACzC,YAAY,EAAE,IAAI;KACnB,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAI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GAAG,CAAC,iBAAiB;KACrE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Escalation — what a terminal skip DOES to the pull request.
3
+ *
4
+ * `resolveFixDisposition` decides; this applies. Three of its skips are
5
+ * terminal for the current problem (see `EscalationCase`), and before this
6
+ * module all three were silent: the dispatch returned `{ kind: "skipped" }`
7
+ * with a reason in the server log and *nothing at all* on the PR. 04-retry.md
8
+ * §4.3 calls that strictly worse than being visible — a maintainer looking at a
9
+ * red dependency PR that the bot has quietly abandoned has no way to learn that
10
+ * it was abandoned, let alone why.
11
+ *
12
+ * So an escalating skip does three things, in this order:
13
+ *
14
+ * 1. **records a run row** (why it must, below)
15
+ * 2. **applies `requires-human`**
16
+ * 3. **posts ONE comment** naming the case, the attempt count and each
17
+ * attempt's `class=` / `cause=`.
18
+ *
19
+ * ## Why the row, and why FIRST
20
+ *
21
+ * This is the crux, and it is not an implementation detail — it is 09 → D1's
22
+ * general rule: *no prior-run verdict may gate dispatch unless the skipping
23
+ * path writes a run row.*
24
+ *
25
+ * `escalatedAtSha` is read by `applyDerivedState` off the PRIOR RUN'S persisted
26
+ * `context.prState`, via `latestForTrigger`. A dispatch-time skip returns
27
+ * `{ kind: "skipped" }` and writes no row. So an escalation that stayed a
28
+ * row-less skip would never persist `escalatedAtSha`, and the next dispatch
29
+ * would see `requires-human` present with `escalatedAtSha: null` — which
30
+ * `applyDerivedState` classifies as `escalatedBy: "human"`, **a permanent hard
31
+ * override**. The bot would mistake its own escalation for a maintainer's "stay
32
+ * out" and latch the PR dead: exactly the one-way door 09 → S1 set out to
33
+ * remove, reintroduced by the feature meant to remove it.
34
+ *
35
+ * That is also why the row is written BEFORE the label. Every ordering has a
36
+ * crash window; this one chooses the harmless side of it. Row-then-crash leaves
37
+ * an escalation record with no label — the guard reads `escalatedBy: null`, so
38
+ * the next event simply escalates again and the label lands on the retry.
39
+ * Label-then-crash would leave a label with no record, which is precisely the
40
+ * "human applied it" misclassification above, and it is permanent.
41
+ *
42
+ * The row is recorded **`succeeded`**, not `failed`: 09 → S1 reserves `failed`
43
+ * for MALFUNCTION, and correct-but-stopped outcomes record `succeeded`. The run
44
+ * did its job — it correctly determined the PR cannot be fixed here. `failed`
45
+ * would post `messages.on_failure` on the PR, offer a dashboard Retry that
46
+ * cannot succeed, and pollute the cost/failure stats.
47
+ *
48
+ * ## Once, and only once
49
+ *
50
+ * Neither `postComment` nor `addLabels` de-duplicates, and no API scan is used
51
+ * to ask "did we already comment". The once-only property comes from the
52
+ * persisted record instead: the next dispatch at the same head reads
53
+ * `escalatedAtSha` back, resolves `escalatedBy: "us"`, and takes the
54
+ * `escalated:` skip — which carries no `EscalationCase`, so nothing is applied.
55
+ * A maintainer's push makes it a fresh problem, the guard falls away, and the
56
+ * PR is dispatchable again with no label to remove by hand.
57
+ */
58
+ import type { StateDb } from "../state/db.js";
59
+ import type { GitHubClient } from "./github/github.js";
60
+ import type { FixConfig } from "../config/config.js";
61
+ import type { Decision, EscalationCase, FixDisposition } from "./pr-decisions.js";
62
+ import { type PrState } from "./pr-state.js";
63
+ /** Collaborators {@link escalatePr} needs. `github` is null in chat-only mode. */
64
+ export interface EscalationDeps {
65
+ db: StateDb;
66
+ github: GitHubClient | null;
67
+ }
68
+ /**
69
+ * The phase name the escalation row terminates on. Not a real phase — no
70
+ * executor ran — but `phase_history` is what the run detail panel renders, and
71
+ * a run whose only entry says `escalated` reads correctly beside runs whose
72
+ * entries say `diagnose` / `fix`.
73
+ */
74
+ export declare const ESCALATION_PHASE = "escalated";
75
+ /** What {@link escalatePr} did, for the caller's log line and for tests. */
76
+ export interface EscalationOutcome {
77
+ case: EscalationCase;
78
+ runId: string;
79
+ labelled: boolean;
80
+ commented: boolean;
81
+ }
82
+ /**
83
+ * Apply the escalation for a skip that carries one; do nothing otherwise.
84
+ *
85
+ * Called from BOTH dispatch gates — `dispatcher.ts` (webhook / comment routes)
86
+ * and `dispatchWorkflow` (cron fan-out, `/api/run`). One helper rather than two
87
+ * call-site implementations, because a skip that escalates on one route and
88
+ * stays silent on the other is the exact divergence the PR state machine exists
89
+ * to remove: the daily `fix-red-dependency-prs` sweep is the route that reaches
90
+ * most exhausted PRs.
91
+ *
92
+ * Never throws. Every GitHub write is independently best-effort — a failure
93
+ * degrades the escalation's VISIBILITY, never the dispatch outcome, and the
94
+ * caller skips either way.
95
+ */
96
+ export declare function escalatePr(workflowName: string, state: PrState, decision: Decision<FixDisposition>, fix: FixConfig, deps: EscalationDeps): Promise<EscalationOutcome | null>;
97
+ /**
98
+ * The phase name the fork-notice row terminates on. Same non-phase convention
99
+ * as {@link ESCALATION_PHASE}, so the run detail panel reads correctly.
100
+ */
101
+ export declare const FORK_NOTICE_PHASE = "fork-pr";
102
+ /** What {@link noticeForkPr} did, for the caller's log line and for tests. */
103
+ export interface ForkNoticeOutcome {
104
+ runId: string;
105
+ commented: boolean;
106
+ }
107
+ /**
108
+ * Tell a fork PR's author, ONCE, why we cannot help — and record that we did.
109
+ *
110
+ * Their change is fine; its head branch simply lives on a repo we have no write
111
+ * access to (and its head ref isn't on origin), so there is nothing for a fix
112
+ * run to clone or push to.
113
+ *
114
+ * ## Once per PR, and why the row
115
+ *
116
+ * The old notice had no de-duplication at all and keyed on `state.isFork`
117
+ * rather than on the `fork-pr` decision, so a fork PR earned this comment on
118
+ * every skip of any kind, once per skip (#256). Both halves are fixed: the
119
+ * caller keys on `Decision.forkPr`, and the once-only property comes from the
120
+ * persisted record exactly as it does for {@link escalatePr} — the next
121
+ * dispatch reads `forkNoticedAtSha` back off the prior run's `context.prState`
122
+ * and does not call this again. No API scan, no comment-body marker.
123
+ *
124
+ * The row therefore has to be written BEFORE the comment, for the same reason
125
+ * and with the same crash-window reasoning: row-then-crash leaves a record with
126
+ * no comment, so the author is told on the next event; comment-then-crash would
127
+ * repeat the comment forever, which is the failure being fixed.
128
+ *
129
+ * Unlike an escalation this records no label and is never invalidated by a
130
+ * push. A fork stays a fork.
131
+ *
132
+ * Never throws. The comment is best-effort; the record is not optional.
133
+ */
134
+ export declare function noticeForkPr(workflowName: string, state: PrState, deps: EscalationDeps): Promise<ForkNoticeOutcome | null>;
135
+ /** The fork-PR notice. Pure, so its wording is table-testable. */
136
+ export declare function renderForkNotice(state: PrState): string;
137
+ /**
138
+ * The escalation comment. Pure, so its wording is table-testable.
139
+ *
140
+ * 04-retry.md §4.3 fixes the contents: **which escalation case this is, the
141
+ * attempt count, and each attempt's `class=` + `cause=`.** The last of those is
142
+ * `state.priorAttempts` — already rendered, already bounded (`fix-markers.ts`),
143
+ * already the exact text the next attempt's prompt would have replayed. Nothing
144
+ * is re-derived here: the reason comes from the decision, so the log line, this
145
+ * comment and the admin detail panel are three renderings of ONE source.
146
+ *
147
+ * The closing paragraph is the anti-latch property, stated to the person who
148
+ * has to act on it: pushing is the exit, and removing the label by hand is not
149
+ * required. Saying so is what stops `requires-human` reading as the one-way
150
+ * door it used to be.
151
+ */
152
+ export declare function renderEscalationComment(kase: EscalationCase, reason: string, state: PrState, fix: FixConfig): string;
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Escalation — what a terminal skip DOES to the pull request.
3
+ *
4
+ * `resolveFixDisposition` decides; this applies. Three of its skips are
5
+ * terminal for the current problem (see `EscalationCase`), and before this
6
+ * module all three were silent: the dispatch returned `{ kind: "skipped" }`
7
+ * with a reason in the server log and *nothing at all* on the PR. 04-retry.md
8
+ * §4.3 calls that strictly worse than being visible — a maintainer looking at a
9
+ * red dependency PR that the bot has quietly abandoned has no way to learn that
10
+ * it was abandoned, let alone why.
11
+ *
12
+ * So an escalating skip does three things, in this order:
13
+ *
14
+ * 1. **records a run row** (why it must, below)
15
+ * 2. **applies `requires-human`**
16
+ * 3. **posts ONE comment** naming the case, the attempt count and each
17
+ * attempt's `class=` / `cause=`.
18
+ *
19
+ * ## Why the row, and why FIRST
20
+ *
21
+ * This is the crux, and it is not an implementation detail — it is 09 → D1's
22
+ * general rule: *no prior-run verdict may gate dispatch unless the skipping
23
+ * path writes a run row.*
24
+ *
25
+ * `escalatedAtSha` is read by `applyDerivedState` off the PRIOR RUN'S persisted
26
+ * `context.prState`, via `latestForTrigger`. A dispatch-time skip returns
27
+ * `{ kind: "skipped" }` and writes no row. So an escalation that stayed a
28
+ * row-less skip would never persist `escalatedAtSha`, and the next dispatch
29
+ * would see `requires-human` present with `escalatedAtSha: null` — which
30
+ * `applyDerivedState` classifies as `escalatedBy: "human"`, **a permanent hard
31
+ * override**. The bot would mistake its own escalation for a maintainer's "stay
32
+ * out" and latch the PR dead: exactly the one-way door 09 → S1 set out to
33
+ * remove, reintroduced by the feature meant to remove it.
34
+ *
35
+ * That is also why the row is written BEFORE the label. Every ordering has a
36
+ * crash window; this one chooses the harmless side of it. Row-then-crash leaves
37
+ * an escalation record with no label — the guard reads `escalatedBy: null`, so
38
+ * the next event simply escalates again and the label lands on the retry.
39
+ * Label-then-crash would leave a label with no record, which is precisely the
40
+ * "human applied it" misclassification above, and it is permanent.
41
+ *
42
+ * The row is recorded **`succeeded`**, not `failed`: 09 → S1 reserves `failed`
43
+ * for MALFUNCTION, and correct-but-stopped outcomes record `succeeded`. The run
44
+ * did its job — it correctly determined the PR cannot be fixed here. `failed`
45
+ * would post `messages.on_failure` on the PR, offer a dashboard Retry that
46
+ * cannot succeed, and pollute the cost/failure stats.
47
+ *
48
+ * ## Once, and only once
49
+ *
50
+ * Neither `postComment` nor `addLabels` de-duplicates, and no API scan is used
51
+ * to ask "did we already comment". The once-only property comes from the
52
+ * persisted record instead: the next dispatch at the same head reads
53
+ * `escalatedAtSha` back, resolves `escalatedBy: "us"`, and takes the
54
+ * `escalated:` skip — which carries no `EscalationCase`, so nothing is applied.
55
+ * A maintainer's push makes it a fresh problem, the guard falls away, and the
56
+ * PR is dispatchable again with no label to remove by hand.
57
+ */
58
+ import { randomUUID } from "crypto";
59
+ import { prTriggerId } from "./pr-state.js";
60
+ import { REQUIRES_HUMAN_LABEL } from "../cron/dependabot-discovery.js";
61
+ /**
62
+ * The phase name the escalation row terminates on. Not a real phase — no
63
+ * executor ran — but `phase_history` is what the run detail panel renders, and
64
+ * a run whose only entry says `escalated` reads correctly beside runs whose
65
+ * entries say `diagnose` / `fix`.
66
+ */
67
+ export const ESCALATION_PHASE = "escalated";
68
+ /**
69
+ * Apply the escalation for a skip that carries one; do nothing otherwise.
70
+ *
71
+ * Called from BOTH dispatch gates — `dispatcher.ts` (webhook / comment routes)
72
+ * and `dispatchWorkflow` (cron fan-out, `/api/run`). One helper rather than two
73
+ * call-site implementations, because a skip that escalates on one route and
74
+ * stays silent on the other is the exact divergence the PR state machine exists
75
+ * to remove: the daily `fix-red-dependency-prs` sweep is the route that reaches
76
+ * most exhausted PRs.
77
+ *
78
+ * Never throws. Every GitHub write is independently best-effort — a failure
79
+ * degrades the escalation's VISIBILITY, never the dispatch outcome, and the
80
+ * caller skips either way.
81
+ */
82
+ export async function escalatePr(workflowName, state, decision, fix, deps) {
83
+ const kase = decision.escalation;
84
+ if (!kase || decision.decision !== "skip")
85
+ return null;
86
+ const [owner, name] = state.repo.split("/");
87
+ if (!owner || !name)
88
+ return null;
89
+ // No head SHA means the PR read failed. Recording `escalatedAtSha: ""` would
90
+ // read back as falsy, which `applyDerivedState` resolves to
91
+ // `escalatedBy: "human"` — the permanent override. Refuse rather than latch;
92
+ // the next event re-resolves the snapshot and escalates properly.
93
+ if (!state.headSha) {
94
+ console.warn(`[escalate] ${state.repo}#${state.prNumber}: ${kase} but the head SHA is unknown — skipping silently`);
95
+ return null;
96
+ }
97
+ // No client, no label, no comment — so an escalation here would be invisible,
98
+ // which is the whole thing this exists to prevent. Recording a row alone
99
+ // would also accumulate one per cron tick, since with no label the guard
100
+ // never binds.
101
+ if (!deps.github)
102
+ return null;
103
+ const github = deps.github;
104
+ // ── 1. The record. Written FIRST — see the module header. ────────────────
105
+ //
106
+ // A failure here ABORTS the escalation rather than falling through to the
107
+ // label. Labelling without a record is the one combination that latches: the
108
+ // next dispatch sees `requires-human` with no `escalatedAtSha` behind it and
109
+ // reads our own label as a maintainer's permanent override.
110
+ const runId = randomUUID();
111
+ const recorded = {
112
+ ...state,
113
+ escalatedAtSha: state.headSha,
114
+ escalatedBy: "us",
115
+ };
116
+ try {
117
+ deps.db.runs.createRun({
118
+ id: runId,
119
+ workflowName,
120
+ triggerId: prTriggerId(state.repo, state.prNumber),
121
+ owner,
122
+ repo: name,
123
+ issueNumber: state.prNumber,
124
+ currentPhase: ESCALATION_PHASE,
125
+ status: "running",
126
+ triggeredBy: "last-light",
127
+ triggerActorType: "system",
128
+ context: {
129
+ // The snapshot the NEXT dispatch reads back — `escalatedAtSha` above is
130
+ // the whole point of the row.
131
+ prState: recorded,
132
+ // …and the human-readable half of the same fact, for the detail panel.
133
+ escalation: { case: kase, reason: decision.reason, at: new Date().toISOString() },
134
+ },
135
+ startedAt: new Date().toISOString(),
136
+ });
137
+ // `succeeded`, not `failed`: 09 → S1 reserves `failed` for malfunction.
138
+ deps.db.runs.finishRun(runId, "succeeded", {
139
+ terminalMarker: { phase: ESCALATION_PHASE, summary: decision.reason },
140
+ });
141
+ }
142
+ catch (err) {
143
+ const msg = err instanceof Error ? err.message : String(err);
144
+ console.warn(`[escalate] ${state.repo}#${state.prNumber}: could not record the escalation (${msg}) — ` +
145
+ `applying no label, since a label with no record reads as a human's permanent hold`);
146
+ return null;
147
+ }
148
+ // ── 2. The label. ────────────────────────────────────────────────────────
149
+ let labelled = false;
150
+ try {
151
+ await github.addLabels(owner, name, state.prNumber, [REQUIRES_HUMAN_LABEL]);
152
+ labelled = true;
153
+ }
154
+ catch (err) {
155
+ const msg = err instanceof Error ? err.message : String(err);
156
+ console.warn(`[escalate] ${state.repo}#${state.prNumber}: could not apply the label: ${msg}`);
157
+ }
158
+ // ── 3. The comment. Only behind a label that actually landed. ────────────
159
+ //
160
+ // Without the label the guard cannot bind, so the next event will escalate
161
+ // again — and commenting now would mean commenting once per retry.
162
+ let commented = false;
163
+ if (labelled) {
164
+ try {
165
+ await github.postComment(owner, name, state.prNumber, renderEscalationComment(kase, decision.reason, recorded, fix));
166
+ commented = true;
167
+ }
168
+ catch (err) {
169
+ const msg = err instanceof Error ? err.message : String(err);
170
+ console.warn(`[escalate] ${state.repo}#${state.prNumber}: could not post the comment: ${msg}`);
171
+ }
172
+ }
173
+ console.log(`[escalate] ${workflowName} ${state.repo}#${state.prNumber}: ${kase} at ` +
174
+ `${state.headSha.slice(0, 7)} (run ${runId}, label=${labelled}, comment=${commented})`);
175
+ return { case: kase, runId, labelled, commented };
176
+ }
177
+ /**
178
+ * The phase name the fork-notice row terminates on. Same non-phase convention
179
+ * as {@link ESCALATION_PHASE}, so the run detail panel reads correctly.
180
+ */
181
+ export const FORK_NOTICE_PHASE = "fork-pr";
182
+ /**
183
+ * Tell a fork PR's author, ONCE, why we cannot help — and record that we did.
184
+ *
185
+ * Their change is fine; its head branch simply lives on a repo we have no write
186
+ * access to (and its head ref isn't on origin), so there is nothing for a fix
187
+ * run to clone or push to.
188
+ *
189
+ * ## Once per PR, and why the row
190
+ *
191
+ * The old notice had no de-duplication at all and keyed on `state.isFork`
192
+ * rather than on the `fork-pr` decision, so a fork PR earned this comment on
193
+ * every skip of any kind, once per skip (#256). Both halves are fixed: the
194
+ * caller keys on `Decision.forkPr`, and the once-only property comes from the
195
+ * persisted record exactly as it does for {@link escalatePr} — the next
196
+ * dispatch reads `forkNoticedAtSha` back off the prior run's `context.prState`
197
+ * and does not call this again. No API scan, no comment-body marker.
198
+ *
199
+ * The row therefore has to be written BEFORE the comment, for the same reason
200
+ * and with the same crash-window reasoning: row-then-crash leaves a record with
201
+ * no comment, so the author is told on the next event; comment-then-crash would
202
+ * repeat the comment forever, which is the failure being fixed.
203
+ *
204
+ * Unlike an escalation this records no label and is never invalidated by a
205
+ * push. A fork stays a fork.
206
+ *
207
+ * Never throws. The comment is best-effort; the record is not optional.
208
+ */
209
+ export async function noticeForkPr(workflowName, state, deps) {
210
+ const [owner, name] = state.repo.split("/");
211
+ if (!owner || !name || !deps.github)
212
+ return null;
213
+ // Already told them. The whole point.
214
+ if (state.forkNoticedAtSha)
215
+ return null;
216
+ // No head SHA means the PR read failed — but the dispatch gate refuses a
217
+ // degraded read before it ever reaches here, so this is belt: recording
218
+ // `forkNoticedAtSha: ""` would read back as falsy and re-notice forever.
219
+ if (!state.headSha)
220
+ return null;
221
+ const runId = randomUUID();
222
+ const recorded = { ...state, forkNoticedAtSha: state.headSha };
223
+ try {
224
+ deps.db.runs.createRun({
225
+ id: runId,
226
+ workflowName,
227
+ triggerId: prTriggerId(state.repo, state.prNumber),
228
+ owner,
229
+ repo: name,
230
+ issueNumber: state.prNumber,
231
+ currentPhase: FORK_NOTICE_PHASE,
232
+ status: "running",
233
+ triggeredBy: "last-light",
234
+ triggerActorType: "system",
235
+ context: { prState: recorded },
236
+ startedAt: new Date().toISOString(),
237
+ });
238
+ deps.db.runs.finishRun(runId, "succeeded", {
239
+ terminalMarker: { phase: FORK_NOTICE_PHASE, summary: "fork-pr: told the author once" },
240
+ });
241
+ }
242
+ catch (err) {
243
+ const msg = err instanceof Error ? err.message : String(err);
244
+ console.warn(`[fork-notice] ${state.repo}#${state.prNumber}: could not record the notice (${msg}) — ` +
245
+ `saying nothing, since a comment with no record would repeat on every event`);
246
+ return null;
247
+ }
248
+ let commented = false;
249
+ try {
250
+ await deps.github.postComment(owner, name, state.prNumber, renderForkNotice(state));
251
+ commented = true;
252
+ }
253
+ catch (err) {
254
+ const msg = err instanceof Error ? err.message : String(err);
255
+ console.warn(`[fork-notice] ${state.repo}#${state.prNumber}: comment failed: ${msg}`);
256
+ }
257
+ console.log(`[fork-notice] ${workflowName} ${state.repo}#${state.prNumber}: ` +
258
+ `at ${state.headSha.slice(0, 7)} (run ${runId}, comment=${commented})`);
259
+ return { runId, commented };
260
+ }
261
+ /** The fork-PR notice. Pure, so its wording is table-testable. */
262
+ export function renderForkNotice(state) {
263
+ const source = state.headRepoFullName
264
+ ? `from \`${state.headRepoFullName}\``
265
+ : "from a now-deleted fork";
266
+ return (`I can't apply fixes to this PR — it comes ${source}, and I have no write access to the ` +
267
+ `source branch (nor is its head ref on \`${state.repo}\`). Re-create the change on a ` +
268
+ `branch in \`${state.repo}\` and I'll fix it there.`);
269
+ }
270
+ /** One-line human summary per case, for the comment's opening sentence. */
271
+ const CASE_HEADLINE = {
272
+ "attempts-exhausted": "I've used every attempt I'm allowed on this pull request",
273
+ "budget-exhausted": "I've spent the cost budget allowed for this pull request",
274
+ "not-retryable": "The last diagnosis says another attempt can't help",
275
+ };
276
+ /**
277
+ * The escalation comment. Pure, so its wording is table-testable.
278
+ *
279
+ * 04-retry.md §4.3 fixes the contents: **which escalation case this is, the
280
+ * attempt count, and each attempt's `class=` + `cause=`.** The last of those is
281
+ * `state.priorAttempts` — already rendered, already bounded (`fix-markers.ts`),
282
+ * already the exact text the next attempt's prompt would have replayed. Nothing
283
+ * is re-derived here: the reason comes from the decision, so the log line, this
284
+ * comment and the admin detail panel are three renderings of ONE source.
285
+ *
286
+ * The closing paragraph is the anti-latch property, stated to the person who
287
+ * has to act on it: pushing is the exit, and removing the label by hand is not
288
+ * required. Saying so is what stops `requires-human` reading as the one-way
289
+ * door it used to be.
290
+ */
291
+ export function renderEscalationComment(kase, reason, state, fix) {
292
+ const lines = [];
293
+ lines.push(`**${CASE_HEADLINE[kase]}**, so I've applied \`${REQUIRES_HUMAN_LABEL}\` and stopped.`);
294
+ lines.push("");
295
+ lines.push(`- **Why:** ${reason}`);
296
+ lines.push(`- **Attempts:** ${Math.max(state.attempt - 1, 0)} of ${fix.maxAttempts} spent`);
297
+ if (fix.maxCostUsd !== null) {
298
+ lines.push(`- **Cost so far:** $${state.cumulativeCostUsd.toFixed(2)} of $${fix.maxCostUsd.toFixed(2)}`);
299
+ }
300
+ lines.push(`- **Head:** \`${state.headSha.slice(0, 7)}\``);
301
+ lines.push("");
302
+ if (state.priorAttempts.length > 0) {
303
+ lines.push("What each attempt found:");
304
+ lines.push("");
305
+ for (const line of state.priorAttempts)
306
+ lines.push(`- \`${line}\``);
307
+ }
308
+ else {
309
+ // A crash never spends an attempt and leaves no marker, so an escalation
310
+ // with an empty journal is a real (if rare) state — say so rather than
311
+ // rendering an empty bullet list.
312
+ lines.push("I have no per-attempt notes for this PR — no run got as far as a diagnosis.");
313
+ }
314
+ lines.push("");
315
+ lines.push("**Push a commit to this branch and I'll pick it up again** — a new head from anyone but me " +
316
+ "is a fresh problem, so the attempt counter resets and this label stops holding me off. " +
317
+ "You don't need to remove it by hand. You can also ask me directly in a comment to override.");
318
+ return lines.join("\n");
319
+ }
320
+ //# sourceMappingURL=pr-escalation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-escalation.js","sourceRoot":"","sources":["../../src/engine/pr-escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAE,WAAW,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAQvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAU5C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,YAAoB,EACpB,KAAc,EACd,QAAkC,EAClC,GAAc,EACd,IAAoB;IAEpB,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC;IACjC,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAEvD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEjC,6EAA6E;IAC7E,4DAA4D;IAC5D,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