lastlight-core 0.23.3 → 0.23.5

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 (48) hide show
  1. package/config/default.yaml +16 -0
  2. package/dist/admin/routes.d.ts +29 -0
  3. package/dist/admin/routes.js +136 -0
  4. package/dist/admin/routes.js.map +1 -1
  5. package/dist/config/config.d.ts +23 -0
  6. package/dist/config/config.js +25 -0
  7. package/dist/config/config.js.map +1 -1
  8. package/dist/cron/dependabot-discovery.d.ts +43 -4
  9. package/dist/cron/dependabot-discovery.js +47 -7
  10. package/dist/cron/dependabot-discovery.js.map +1 -1
  11. package/dist/engine/dispatcher.d.ts +5 -1
  12. package/dist/engine/dispatcher.js +88 -8
  13. package/dist/engine/dispatcher.js.map +1 -1
  14. package/dist/engine/fix-harvest.d.ts +21 -2
  15. package/dist/engine/fix-harvest.js +25 -2
  16. package/dist/engine/fix-harvest.js.map +1 -1
  17. package/dist/engine/fix-markers.d.ts +27 -0
  18. package/dist/engine/fix-markers.js +31 -0
  19. package/dist/engine/fix-markers.js.map +1 -1
  20. package/dist/engine/github/github.d.ts +1 -1
  21. package/dist/engine/github/github.js +1 -1
  22. package/dist/engine/pr-decisions.d.ts +71 -8
  23. package/dist/engine/pr-decisions.js +121 -24
  24. package/dist/engine/pr-decisions.js.map +1 -1
  25. package/dist/engine/pr-escalation.d.ts +112 -18
  26. package/dist/engine/pr-escalation.js +204 -31
  27. package/dist/engine/pr-escalation.js.map +1 -1
  28. package/dist/engine/pr-state.d.ts +152 -15
  29. package/dist/engine/pr-state.js +351 -94
  30. package/dist/engine/pr-state.js.map +1 -1
  31. package/dist/engine/router.js +116 -4
  32. package/dist/engine/router.js.map +1 -1
  33. package/dist/index.js +12 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/sandbox/index.js +41 -1
  36. package/dist/sandbox/index.js.map +1 -1
  37. package/dist/sandbox/k8s/init-clone.d.ts +7 -4
  38. package/dist/sandbox/k8s/init-clone.js +35 -5
  39. package/dist/sandbox/k8s/init-clone.js.map +1 -1
  40. package/dist/workflows/simple.d.ts +24 -1
  41. package/dist/workflows/simple.js +39 -7
  42. package/dist/workflows/simple.js.map +1 -1
  43. package/package.json +3 -3
  44. package/skills/fixing/SKILL.md +7 -1
  45. package/workflows/dependabot-ci-fix.yaml +15 -1
  46. package/workflows/pr-fix.yaml +6 -1
  47. package/workflows/prompts/dependabot-ci-fix.md +16 -6
  48. package/workflows/prompts/dependabot-pr-merge.md +16 -9
@@ -25,19 +25,18 @@
25
25
  * `escalatedAtSha` is read by `applyDerivedState` off the PRIOR RUN'S persisted
26
26
  * `context.prState`, via `latestForTrigger`. A dispatch-time skip returns
27
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.
28
+ * row-less skip would never persist `escalatedAtSha`, the guard would never
29
+ * bind, and every subsequent event on the same dead PR would escalate again —
30
+ * re-applying the label and posting the comment once per event, which is the
31
+ * one behaviour worse than the silent skip this module replaced.
34
32
  *
35
33
  * That is also why the row is written BEFORE the label. Every ordering has a
36
34
  * 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.
35
+ * an escalation record with no label — the guard still binds off the record, so
36
+ * the PR is quiet and the label lands on the next escalation.
37
+ * Label-then-crash would leave a label with no record: a `requires-human` on the
38
+ * PR that nothing in the code can see, so the next event escalates and comments
39
+ * all over again.
41
40
  *
42
41
  * The row is recorded **`succeeded`**, not `failed`: 09 → S1 reserves `failed`
43
42
  * for MALFUNCTION, and correct-but-stopped outcomes record `succeeded`. The run
@@ -50,14 +49,28 @@
50
49
  * Neither `postComment` nor `addLabels` de-duplicates, and no API scan is used
51
50
  * to ask "did we already comment". The once-only property comes from the
52
51
  * 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.
52
+ * `escalatedAtSha` back and takes the `escalated:` skip — which carries no
53
+ * `EscalationCase`, so nothing is applied.
55
54
  * A maintainer's push makes it a fresh problem, the guard falls away, and the
56
55
  * PR is dispatchable again with no label to remove by hand.
56
+ *
57
+ * That property is therefore **entirely dependent on the `escalated:` guard
58
+ * firing first**, and the guard is bypassable: an explicit `@bot` request skips
59
+ * it by design, and a recorded retry consumes the record outright
60
+ * (03-retry-intervention.md). Every bypass lands back here, so `escalatePr`
61
+ * additionally refuses outright when it has already escalated at this exact
62
+ * head. Re-recording would be harmless; re-commenting is #256.
57
63
  */
58
64
  import { randomUUID } from "crypto";
59
- import { prTriggerId } from "./pr-state.js";
60
- import { REQUIRES_HUMAN_LABEL } from "../cron/dependabot-discovery.js";
65
+ import { INTERVENTION_PHASE, interventionKey, prScopedWorkflows, prTriggerId, } from "./pr-state.js";
66
+ import { HOLD_LABEL, REQUIRES_HUMAN_LABEL } from "../cron/dependabot-discovery.js";
67
+ /**
68
+ * The packaged bot handle. Only a FALLBACK: every real call site passes the
69
+ * configured `@${getBotName()}` down, and this exists so a test (or a caller
70
+ * with no boot config) still renders a comment that names a plausible handle
71
+ * rather than `@undefined`.
72
+ */
73
+ const DEFAULT_BOT_HANDLE = "last-light";
61
74
  /**
62
75
  * The phase name the escalation row terminates on. Not a real phase — no
63
76
  * executor ran — but `phase_history` is what the run detail panel renders, and
@@ -87,13 +100,20 @@ export async function escalatePr(workflowName, state, decision, fix, deps) {
87
100
  if (!owner || !name)
88
101
  return null;
89
102
  // 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.
103
+ // read back as an escalation at a head that matches nothing, so the guard
104
+ // would never bind and every later event would escalate — and comment —
105
+ // again. Refuse rather than latch; the next event re-resolves the snapshot
106
+ // and escalates properly.
93
107
  if (!state.headSha) {
94
108
  console.warn(`[escalate] ${state.repo}#${state.prNumber}: ${kase} but the head SHA is unknown — skipping silently`);
95
109
  return null;
96
110
  }
111
+ // The `escalated:` guard is what normally makes this once-only, but it can
112
+ // be bypassed — by an explicit request, by a hand-removed label, or by a
113
+ // retry — and every bypass lands here again. Re-recording is harmless;
114
+ // re-commenting is #256.
115
+ if (state.escalatedAtSha === state.headSha)
116
+ return null;
97
117
  // No client, no label, no comment — so an escalation here would be invisible,
98
118
  // which is the whole thing this exists to prevent. Recording a row alone
99
119
  // would also accumulate one per cron tick, since with no label the guard
@@ -108,11 +128,7 @@ export async function escalatePr(workflowName, state, decision, fix, deps) {
108
128
  // next dispatch sees `requires-human` with no `escalatedAtSha` behind it and
109
129
  // reads our own label as a maintainer's permanent override.
110
130
  const runId = randomUUID();
111
- const recorded = {
112
- ...state,
113
- escalatedAtSha: state.headSha,
114
- escalatedBy: "us",
115
- };
131
+ const recorded = { ...state, escalatedAtSha: state.headSha };
116
132
  try {
117
133
  deps.db.runs.createRun({
118
134
  id: runId,
@@ -162,7 +178,14 @@ export async function escalatePr(workflowName, state, decision, fix, deps) {
162
178
  let commented = false;
163
179
  if (labelled) {
164
180
  try {
165
- await github.postComment(owner, name, state.prNumber, renderEscalationComment(kase, decision.reason, recorded, fix));
181
+ await github.postComment(owner, name, state.prNumber, renderEscalationComment(kase, decision.reason, recorded, fix, {
182
+ // The two operator-configurable names the comment has to speak. Read
183
+ // HERE rather than inside the pure renderer, so the wording stays
184
+ // table-testable and a deployment that renamed either gets a comment
185
+ // naming what it actually renamed them to.
186
+ holdLabel: deps.holdLabel ?? HOLD_LABEL,
187
+ botMention: deps.botMention ?? `@${DEFAULT_BOT_HANDLE}`,
188
+ }));
166
189
  commented = true;
167
190
  }
168
191
  catch (err) {
@@ -283,12 +306,24 @@ const CASE_HEADLINE = {
283
306
  * is re-derived here: the reason comes from the decision, so the log line, this
284
307
  * comment and the admin detail panel are three renderings of ONE source.
285
308
  *
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.
309
+ * ## The closing section is a contract
310
+ *
311
+ * It is the only place most people will ever learn how to un-stick the bot, so
312
+ * **every exit it names has to work and every exit that works has to be named.**
313
+ * It used to fail both halves. It promised *"you can also ask me directly in a
314
+ * comment to override"*, which the code refused — an explicit request cleared
315
+ * the escalation guard and then fell straight into the same budget gate, so the
316
+ * only thing asking achieved was a duplicate copy of this comment — and it did
317
+ * not mention the hold label at all, because it predated it.
318
+ *
319
+ * After 02-hold-label.md and 03-retry-intervention.md the true exits are four,
320
+ * and the split below is the useful one: three of them mean *"go again"* and
321
+ * re-arm both budgets identically (locked decision 7), and the fourth means the
322
+ * opposite. Listing the hold beside them is deliberate — a maintainer reading
323
+ * this is, roughly half the time, someone who wants the bot to stop rather than
324
+ * to try harder, and until now there was nothing here telling them how.
290
325
  */
291
- export function renderEscalationComment(kase, reason, state, fix) {
326
+ export function renderEscalationComment(kase, reason, state, fix, vocab) {
292
327
  const lines = [];
293
328
  lines.push(`**${CASE_HEADLINE[kase]}**, so I've applied \`${REQUIRES_HUMAN_LABEL}\` and stopped.`);
294
329
  lines.push("");
@@ -312,9 +347,147 @@ export function renderEscalationComment(kase, reason, state, fix) {
312
347
  lines.push("I have no per-attempt notes for this PR — no run got as far as a diagnosis.");
313
348
  }
314
349
  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.");
350
+ lines.push(`**How to un-stick this.** Any one of these three re-arms the attempt counter and the cost ` +
351
+ `budget for this pull request — they do exactly the same thing, so pick whichever is least ` +
352
+ `effort:`);
353
+ lines.push("");
354
+ lines.push(`- **Push a commit to this branch.** A new head from anyone but me is a fresh problem, so I ` +
355
+ `pick it up on the next event. You don't need to remove \`${REQUIRES_HUMAN_LABEL}\` by hand.`);
356
+ lines.push(`- **Comment \`${vocab.botMention} retry\`.** Anything you add after it — ` +
357
+ `\`${vocab.botMention} retry the arm64 runner was flaky\` — is recorded against the PR and ` +
358
+ `handed to the next attempt.`);
359
+ lines.push(`- **Remove the \`${REQUIRES_HUMAN_LABEL}\` label.** I read that as "have another go" and ` +
360
+ `start a fresh window at this same commit.`);
361
+ lines.push("");
362
+ lines.push(`If you'd rather I stayed off this pull request entirely, apply \`${vocab.holdLabel}\` — ` +
363
+ `nothing of mine runs on it until that label comes off.`);
318
364
  return lines.join("\n");
319
365
  }
366
+ // ---------------------------------------------------------------------------
367
+ // The retry record — the other half of the same mechanism
368
+ // ---------------------------------------------------------------------------
369
+ /**
370
+ * The phase name a standalone intervention row terminates on. Same non-phase
371
+ * convention as {@link ESCALATION_PHASE} and {@link FORK_NOTICE_PHASE} — with
372
+ * one difference that moves where it is declared: `pr-state.ts` has to
373
+ * RECOGNISE this row when it derives `assessedHeadShaByWorkflow`, so the
374
+ * constant is defined there (this module already imports that one, and the
375
+ * reverse edge would be a cycle) and re-exported here, which is where every
376
+ * caller expects to find it.
377
+ */
378
+ export { INTERVENTION_PHASE };
379
+ /**
380
+ * Persist a retry that produced **no run**, so it is not silently lost.
381
+ *
382
+ * ## Where the record normally lives — and why this is the exception
383
+ *
384
+ * A retry that is immediately followed by a dispatch needs no row of its own:
385
+ * `dispatchWorkflow` persists the whole resolved snapshot on the run's
386
+ * `context.prState`, so the dispatched run itself carries the intervention and
387
+ * the next dispatch reads it back exactly as it reads `escalatedAtSha`. That is
388
+ * the common path and it is free.
389
+ *
390
+ * The exception is a retry the gate then skips for an unrelated reason — most
391
+ * usefully `upstream-broken`, where the base branch is red at the moment the
392
+ * maintainer asks. A skip returns `{ kind: "skipped" }` and writes NO row (09 →
393
+ * D1), so without this the ask evaporates: the base goes green an hour later,
394
+ * the PR is picked up, and the budget is still exhausted, so it escalates again
395
+ * and the maintainer's retry never happened.
396
+ *
397
+ * Same shape and same ordering as {@link escalatePr} — the record first, before
398
+ * any GitHub write — even though the crash window here is gentler (worst case a
399
+ * retry is lost and the maintainer asks again). Two mechanisms with the same
400
+ * shape and different orderings is how the next reader gets it wrong. There is
401
+ * no GitHub write at all today; the ordering is stated so that adding one later
402
+ * cannot get it backwards.
403
+ *
404
+ * ## The seam the admin API and the CLI use
405
+ *
406
+ * `lastlight pr retry <owner/repo#N>` is a thin client over an admin endpoint,
407
+ * and the endpoint is exactly this pair of calls:
408
+ *
409
+ * ```ts
410
+ * const state = await resolvePrState(owner, repo, prNumber, {
411
+ * github, db, botLogin,
412
+ * intervention: { via: "api", by: session.login, note: reason },
413
+ * });
414
+ * const outcome = await recordIntervention(workflowName, state, { db, github });
415
+ * ```
416
+ *
417
+ * `resolvePrState` stamps `at`/`atSha` and re-arms the snapshot; this persists
418
+ * it. The route may then dispatch immediately (in which case this row is
419
+ * redundant but harmless — the guard below makes the pair idempotent) or leave
420
+ * the next cron tick to pick the PR up.
421
+ *
422
+ * Never throws.
423
+ */
424
+ export async function recordIntervention(workflowName, state, deps) {
425
+ const intervention = state.intervention;
426
+ if (!intervention)
427
+ return null;
428
+ const [owner, name] = state.repo.split("/");
429
+ if (!owner || !name)
430
+ return null;
431
+ // Same refusal as `escalatePr`'s: the head SHA is the record's idempotency
432
+ // key, and one keyed to `""` would match nothing and re-arm forever.
433
+ if (!state.headSha)
434
+ return null;
435
+ // Already persisted. `resolvePrState` folds an intervention forward off the
436
+ // prior row, so a redelivered webhook (or a route that both records and
437
+ // dispatches) resolves the SAME record rather than a new one — and this is
438
+ // what stops a second row being written for it.
439
+ const triggerId = prTriggerId(state.repo, state.prNumber);
440
+ const prior = deps.db.runs.latestForTrigger([...prScopedWorkflows()], triggerId);
441
+ const seen = priorIntervention(prior?.context);
442
+ if (seen && interventionKey(seen) === interventionKey(intervention))
443
+ return null;
444
+ const runId = randomUUID();
445
+ try {
446
+ deps.db.runs.createRun({
447
+ id: runId,
448
+ workflowName,
449
+ triggerId,
450
+ owner,
451
+ repo: name,
452
+ issueNumber: state.prNumber,
453
+ currentPhase: INTERVENTION_PHASE,
454
+ status: "running",
455
+ triggeredBy: intervention.by || "last-light",
456
+ // `system` and not `github`/`cli`: the row is the harness recording a
457
+ // fact, not a person's run. WHO asked is on the record itself, which is
458
+ // the one place it is allowed to be read from — for display.
459
+ triggerActorType: "system",
460
+ context: { prState: state, intervention },
461
+ startedAt: new Date().toISOString(),
462
+ });
463
+ deps.db.runs.finishRun(runId, "succeeded", {
464
+ terminalMarker: {
465
+ phase: INTERVENTION_PHASE,
466
+ summary: `retry requested via ${intervention.via}${intervention.by ? ` by ${intervention.by}` : ""}`,
467
+ },
468
+ });
469
+ }
470
+ catch (err) {
471
+ const msg = err instanceof Error ? err.message : String(err);
472
+ console.warn(`[retry] ${state.repo}#${state.prNumber}: could not record the retry (${msg}) — ` +
473
+ `it will be lost, and the maintainer will have to ask again`);
474
+ return null;
475
+ }
476
+ console.log(`[retry] ${workflowName} ${state.repo}#${state.prNumber}: recorded a ${intervention.via} retry ` +
477
+ `at ${state.headSha.slice(0, 7)} (run ${runId})`);
478
+ return { runId, via: intervention.via, at: intervention.at };
479
+ }
480
+ /** The intervention on a stored run context, if any. Tolerates old rows. */
481
+ function priorIntervention(context) {
482
+ if (!context || typeof context !== "object")
483
+ return null;
484
+ const snap = context.prState;
485
+ if (!snap || typeof snap !== "object")
486
+ return null;
487
+ const rec = snap.intervention;
488
+ if (!rec || typeof rec !== "object")
489
+ return null;
490
+ const at = rec.at;
491
+ return typeof at === "string" && at ? rec : null;
492
+ }
320
493
  //# sourceMappingURL=pr-escalation.js.map
@@ -1 +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,6EAA6E;IAC7E,kEAAkE;IAClE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CACV,cAAc,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,kDAAkD,CACtG,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8EAA8E;IAC9E,yEAAyE;IACzE,yEAAyE;IACzE,eAAe;IACf,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC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AAO,IAAI,CAAC;IACnD,MAAM,GAAG,GAAI,IAAgC,CAAC,YAAY,CAAC;IAC3D,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,EAAE,GAAI,GAA+B,CAAC,EAAE,CAAC;IAC/C,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAE,GAAiC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClF,CAAC"}
@@ -26,6 +26,60 @@ import { type DiagnosisClass } from "./fix-markers.js";
26
26
  import { type PrNote } from "./pr-notes.js";
27
27
  /** Aggregate check state for a ref, as {@link GitHubClient.getChecksConclusion} reports it. */
28
28
  export type ChecksState = "passing" | "failing" | "pending" | "none";
29
+ /**
30
+ * How a retry arrived. Three surfaces, ONE record (03-retry-intervention.md).
31
+ *
32
+ * - `comment` — `@<bot> retry [reason]`, already maintainer-gated by the
33
+ * `author_association` check that governs the whole `@`-mention path.
34
+ * - `label` — a human took `requires-human` off. Maintainer-gated for free:
35
+ * GitHub requires triage permission to change a label.
36
+ * - `api` — the admin endpoint behind `lastlight pr retry`, gated by the
37
+ * authenticated admin session.
38
+ */
39
+ export type InterventionVia = "comment" | "label" | "api";
40
+ /**
41
+ * The last time a human told us to try again — the one thing that makes an
42
+ * escalated problem dispatchable without a new commit.
43
+ *
44
+ * `by` and `note` are recorded for DISPLAY and for the journal. **No decision
45
+ * function reads either** — the same rule {@link PrNote} lives under. Capability
46
+ * is checked at the surface (`author_association`, GitHub's own label
47
+ * permissions, or the admin session); identity is never a decision input
48
+ * (locked decision 5). There is no precedence between two maintainers either:
49
+ * last one wins (locked decision 6), which is what one nullable field with a
50
+ * timestamp gives for free.
51
+ */
52
+ export interface PrIntervention {
53
+ at: string;
54
+ /** The head SHA the retry was asked for — the retry's own idempotency key. */
55
+ atSha: string;
56
+ /** How it arrived: a comment, a label removal, or the admin API. */
57
+ via: InterventionVia;
58
+ by?: string;
59
+ note?: string;
60
+ }
61
+ /**
62
+ * What a SURFACE hands in. `at` and `atSha` are stamped by
63
+ * {@link applyDerivedState}, so no caller can date a retry itself or key one to
64
+ * a head SHA it did not read.
65
+ */
66
+ export interface InterventionRequest {
67
+ via: InterventionVia;
68
+ by?: string;
69
+ /** Free text from the comment / CLI. Sanitized on the way in; never trusted. */
70
+ note?: string;
71
+ }
72
+ /**
73
+ * The phase a STANDALONE retry record terminates on — `recordIntervention`'s row
74
+ * (`./pr-escalation.ts`, which re-exports this as its public name).
75
+ *
76
+ * Defined HERE, at the reading end, because the value is load-bearing on this
77
+ * side: {@link applyDerivedState} has to recognise the row to keep it out of
78
+ * {@link PrState.assessedHeadShaByWorkflow}. Importing it from
79
+ * `./pr-escalation.ts` would close a module cycle (that module already imports
80
+ * this one), so the definition lives on the side with no outbound edge.
81
+ */
82
+ export declare const INTERVENTION_PHASE = "retry-requested";
29
83
  /**
30
84
  * Everything the harness knows about one pull request at one moment.
31
85
  *
@@ -64,8 +118,8 @@ export interface PrState {
64
118
  * Derived here rather than left to each call site so the decision functions
65
119
  * stay pure over the snapshot and never need the bot identity. It is the
66
120
  * discriminator behind both the attempt table (our push = same problem;
67
- * anyone else's = the world moved) and the stateful `requires-human` guard
68
- * (our own commit on top of an escalation does not count as intervention).
121
+ * anyone else's = the world moved) and the {@link escalatedAtSha} guard (our
122
+ * own commit on top of an escalation does not count as intervention).
69
123
  */
70
124
  headIsOurs: boolean;
71
125
  /** The PR's head branch — what a fix run clones and pushes to. */
@@ -137,18 +191,58 @@ export interface PrState {
137
191
  attempt: number;
138
192
  /** Consecutive `flaky` diagnoses so far, bounded by `fix.maxFlakyDeferrals`. */
139
193
  flakyDeferrals: number;
140
- /** Head SHA at which one of OUR runs escalated this PR, or null. */
194
+ /**
195
+ * Head SHA at which one of OUR runs escalated this PR, or null.
196
+ *
197
+ * The WHOLE of the escalation state. There is no companion "who applied the
198
+ * label" field, and its absence is the point: `requires-human` is a
199
+ * notification, read by nothing, so `escalatedAtSha !== null` is the only
200
+ * question a decision asks — "did a run of ours stop here, and is this still
201
+ * the head it stopped at?". A maintainer who wants the bot off a PR applies
202
+ * the HOLD label instead, which is an instruction rather than something
203
+ * inferred from a label we also write ourselves (02-hold-label.md).
204
+ *
205
+ * Written by `./pr-escalation.ts` and by nothing else, which is why that
206
+ * module records a run row BEFORE it labels: a skip writes no row, so an
207
+ * escalation that stayed a row-less skip would never persist this and would
208
+ * re-comment on every subsequent event.
209
+ *
210
+ * **Consumed by an {@link intervention}.** A recorded retry clears this back
211
+ * to null — that is how a re-arm becomes visible to the pure decision
212
+ * functions, which see only the snapshot. The mechanism stays bounded because
213
+ * the next escalation writes a fresh value at the same head while the
214
+ * intervention is by then the one the prior run already saw.
215
+ */
141
216
  escalatedAtSha: string | null;
142
217
  /**
143
- * Who put `requires-human` on this PR:
144
- * - `"us"` — a run of ours escalated it (we know the SHA, so a later push
145
- * clears the guard automatically).
146
- * - `"human"` — the label is present but no run of ours escalated: a
147
- * maintainer applied it to mean "bot, stay out". A hard, permanent
148
- * override.
149
- * - `null` — not escalated.
218
+ * The last time a human told us to try again, or null — the RETRY direction
219
+ * of human intent, and the counterpart to {@link escalatedAtSha}
220
+ * (03-retry-intervention.md).
221
+ *
222
+ * Before this field the state machine modelled *the PR's problem* precisely
223
+ * and *human intent* not at all: the only way to say "a human intervened" was
224
+ * that the head SHA changed and we did not author it, which is an INFERENCE
225
+ * FROM A COMMIT rather than a record of a decision. Two of the three things a
226
+ * maintainer would naturally try — commenting, removing the label — cleared
227
+ * the escalation guard without moving the budget window, so both fell straight
228
+ * back through `budget-exhausted` and posted a duplicate escalation comment.
229
+ *
230
+ * Recording it fixes both halves at once: `sameProblem` reads it, so a retry
231
+ * re-arms the attempt counter AND the cost baseline exactly as a push does
232
+ * (locked decision 7), and the record is what makes the re-arm ONCE-ONLY —
233
+ * the next dispatch reads the same intervention back off the prior run's
234
+ * snapshot and does not re-arm again.
235
+ *
236
+ * `by` and `note` are for display and for the journal. **No decision function
237
+ * reads either** — see {@link PrIntervention}.
238
+ *
239
+ * Written wherever the retry is recorded: on the dispatched run's own
240
+ * snapshot when the retry results in a run, and on a standalone row
241
+ * (`recordIntervention`, `./pr-escalation.ts`) when it does not — the same
242
+ * "a skip writes no row, so the record must" reasoning `escalatePr` is built
243
+ * on.
150
244
  */
151
- escalatedBy: "us" | "human" | null;
245
+ intervention: PrIntervention | null;
152
246
  /**
153
247
  * Head SHA at which we told this PR's author we cannot fix a fork, or null.
154
248
  *
@@ -198,10 +292,22 @@ export interface PrState {
198
292
  * is fresh.
199
293
  *
200
294
  * Deliberately NOT carried across a run that diagnosed nothing — unlike
201
- * {@link flakyDeferrals}, which persists. That asymmetry is what keeps the
202
- * manual exit working: a maintainer who removes `requires-human` by hand is
203
- * asking for another try, and a remembered `infra-dependent` would re-escalate
204
- * on the next event and put the label straight back.
295
+ * {@link flakyDeferrals}, which persists — and cleared outright by a fresh
296
+ * problem, whether the freshness came from a push or from an
297
+ * {@link intervention}. Both halves exist so that a remembered
298
+ * `infra-dependent` cannot re-escalate on the next event and put the label
299
+ * straight back.
300
+ *
301
+ * That was written as *"what keeps the manual exit working"*, and until
302
+ * 03-retry-intervention.md it only described one of the three cases. Removing
303
+ * `requires-human` by hand did clear a remembered `not-retryable` — but
304
+ * `budget-exhausted` and `attempts-exhausted` do not read this field at all,
305
+ * so the label removal cleared the guard, the budget gate fired anyway, and
306
+ * the label went straight back with a duplicate comment. **The manual exit
307
+ * now works for all three**, because it is no longer this field that carries
308
+ * it: a retry is a RECORD ({@link intervention}), it re-arms the counter and
309
+ * the cost baseline together, and this field being null is one consequence of
310
+ * that rather than the whole mechanism.
205
311
  */
206
312
  priorDiagnosisClass: DiagnosisClass | null;
207
313
  /**
@@ -241,6 +347,12 @@ export interface PrState {
241
347
  * works because correct-but-stopped outcomes (`flaky`, `infra-dependent`,
242
348
  * `upstream-broken`) now record `succeeded`: before that, the dedup did not
243
349
  * fire for exactly the cases that must not be re-attempted.
350
+ *
351
+ * A `retry-requested` row is the one `succeeded` row that never counts — it
352
+ * records a dispatch that did NOT happen, which is the opposite of the claim
353
+ * this field makes — and the fix family's entries are dropped entirely while a
354
+ * retry asked at this head is still waiting for a run to serve it. See
355
+ * `unassessForPendingRetry`.
244
356
  */
245
357
  assessedHeadShaByWorkflow: Record<string, string>;
246
358
  /**
@@ -293,6 +405,17 @@ export interface PrStateDeps {
293
405
  * existing test) still gets the exclusion.
294
406
  */
295
407
  botName?: string;
408
+ /**
409
+ * A retry that arrived WITH this event — `@<bot> retry` on the comment route,
410
+ * or `lastlight pr retry` on the admin route.
411
+ *
412
+ * Handed to the resolver rather than written by the caller afterwards, because
413
+ * the whole point of the record is that `sameProblem` reads it: an
414
+ * intervention applied after the snapshot was derived would re-arm nothing.
415
+ * The `label` surface needs no equivalent — its evidence is the live label
416
+ * read, which is already here.
417
+ */
418
+ intervention?: InterventionRequest;
296
419
  }
297
420
  /**
298
421
  * Resolve the whole snapshot. Called ONCE per dispatch, at the
@@ -311,3 +434,17 @@ export declare function resolvePrState(owner: string, repo: string, prNumber: nu
311
434
  * table without touching GitHub.
312
435
  */
313
436
  export declare function applyDerivedState(state: PrState, deps: PrStateDeps): void;
437
+ /**
438
+ * The identity of one ask — "is this the same retry the prior run already
439
+ * consumed, or a new one?".
440
+ *
441
+ * The timestamp alone is not enough, and the reason is a real one rather than a
442
+ * theoretical one: `at` has millisecond resolution, so two asks that land in the
443
+ * same millisecond read as one and the second silently re-arms nothing. The
444
+ * whole tuple is what a human actually varied — when, how, who, and why — and
445
+ * two asks identical on all four are the same ask for every purpose this has.
446
+ *
447
+ * Shared with `recordIntervention` (`./pr-escalation.ts`), so the row-writing
448
+ * side and the folding side cannot disagree about what "already recorded" means.
449
+ */
450
+ export declare function interventionKey(intervention: PrIntervention | null | undefined): string | null;