lastlight-core 0.32.1 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/default.yaml +81 -0
- package/dist/admin/board-cache.d.ts +81 -0
- package/dist/admin/board-cache.js +301 -0
- package/dist/admin/board-cache.js.map +1 -0
- package/dist/admin/board-stream.d.ts +47 -0
- package/dist/admin/board-stream.js +45 -0
- package/dist/admin/board-stream.js.map +1 -0
- package/dist/admin/board.d.ts +264 -0
- package/dist/admin/board.js +376 -0
- package/dist/admin/board.js.map +1 -0
- package/dist/admin/routes.js +943 -13
- package/dist/admin/routes.js.map +1 -1
- package/dist/config/config.d.ts +88 -0
- package/dist/config/config.js +163 -0
- package/dist/config/config.js.map +1 -1
- package/dist/connectors/github-webhook.d.ts +16 -0
- package/dist/connectors/github-webhook.js +104 -8
- package/dist/connectors/github-webhook.js.map +1 -1
- package/dist/connectors/types.d.ts +9 -2
- package/dist/cron/issue-discovery.d.ts +120 -0
- package/dist/cron/issue-discovery.js +127 -0
- package/dist/cron/issue-discovery.js.map +1 -0
- package/dist/cron/runner.d.ts +25 -1
- package/dist/cron/runner.js +53 -10
- package/dist/cron/runner.js.map +1 -1
- package/dist/engine/build-decisions.d.ts +91 -0
- package/dist/engine/build-decisions.js +295 -0
- package/dist/engine/build-decisions.js.map +1 -0
- package/dist/engine/build-gate.d.ts +78 -0
- package/dist/engine/build-gate.js +355 -0
- package/dist/engine/build-gate.js.map +1 -0
- package/dist/engine/executors/shared.d.ts +1 -0
- package/dist/engine/executors/shared.js +13 -2
- package/dist/engine/executors/shared.js.map +1 -1
- package/dist/engine/github/github-app-client.js +25 -1
- package/dist/engine/github/github-app-client.js.map +1 -1
- package/dist/engine/github/github.d.ts +195 -6
- package/dist/engine/github/github.js +331 -6
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/pr-decisions.d.ts +23 -0
- package/dist/engine/pr-decisions.js.map +1 -1
- package/dist/engine/router.js +108 -1
- package/dist/engine/router.js.map +1 -1
- package/dist/engine/stage-advance.d.ts +92 -0
- package/dist/engine/stage-advance.js +129 -0
- package/dist/engine/stage-advance.js.map +1 -0
- package/dist/engine/stage-labels.d.ts +57 -0
- package/dist/engine/stage-labels.js +58 -0
- package/dist/engine/stage-labels.js.map +1 -0
- package/dist/engine/stage-observer.d.ts +79 -0
- package/dist/engine/stage-observer.js +221 -0
- package/dist/engine/stage-observer.js.map +1 -0
- package/dist/index.js +110 -2
- package/dist/index.js.map +1 -1
- package/dist/logging/phase-log.d.ts +6 -0
- package/dist/logging/phase-log.js +16 -0
- package/dist/logging/phase-log.js.map +1 -1
- package/dist/state/activity-store.d.ts +45 -1
- package/dist/state/activity-store.js +44 -0
- package/dist/state/activity-store.js.map +1 -1
- package/dist/state/execution-store.d.ts +48 -0
- package/dist/state/execution-store.js +112 -0
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/schema/pg.d.ts +2 -2
- package/dist/state/schema/sqlite.d.ts +2 -2
- package/dist/state/workflow-run-store.d.ts +51 -0
- package/dist/state/workflow-run-store.js +98 -0
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/simple.d.ts +40 -1
- package/dist/workflows/simple.js +113 -2
- package/dist/workflows/simple.js.map +1 -1
- package/package.json +4 -4
- package/workflows/cron-autonomy.yaml +24 -0
- package/workflows/prompts/pr.md +18 -1
package/dist/cron/runner.js
CHANGED
|
@@ -214,8 +214,25 @@ async function fire(workflowName, context, deps) {
|
|
|
214
214
|
// discovery calls, no dispatches, no failure. A cheap no-op tick. The
|
|
215
215
|
// discoverer's `log` callback carries per-repo diagnostics that can fire once
|
|
216
216
|
// per managed repo per tick, so it stays `.debug`.
|
|
217
|
-
const
|
|
218
|
-
const contexts =
|
|
217
|
+
const found = github && repos.length ? await discoverer(repos, github, { log: (m) => log.debug(m) }) : [];
|
|
218
|
+
const contexts = found.map((c) => (c.issueNumber !== undefined ? issueContext(c) : prContext(c, discoverKey)));
|
|
219
|
+
const { dispatched, failures } = await fanOutContexts(workflowName, contexts, dispatch);
|
|
220
|
+
return {
|
|
221
|
+
reposEligible: candidates.length,
|
|
222
|
+
reposScanned: repos.length,
|
|
223
|
+
discovered: found.length,
|
|
224
|
+
dispatched,
|
|
225
|
+
failures,
|
|
226
|
+
discoverKey,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The PR dispatch context — byte-for-byte what it was before issue candidates
|
|
231
|
+
* existed. Extracted, not rewritten: the three PR discovery crons are live in
|
|
232
|
+
* production and this is the shared fan-out path they all cross.
|
|
233
|
+
*/
|
|
234
|
+
function prContext(pr, discoverKey) {
|
|
235
|
+
return {
|
|
219
236
|
_triggerType: "cron",
|
|
220
237
|
repo: pr.repo,
|
|
221
238
|
prNumber: pr.prNumber,
|
|
@@ -232,15 +249,41 @@ async function fire(workflowName, context, deps) {
|
|
|
232
249
|
// chain ended without pushing — no new commit exists, so no further
|
|
233
250
|
// `check_suite` will ever fire for it (09 → S2).
|
|
234
251
|
...(discoverKey === "prs-awaiting-review" ? { _reviewRoute: "sweep" } : {}),
|
|
235
|
-
}
|
|
236
|
-
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The ISSUE dispatch context — the autonomy backstop sweep (`cron-autonomy.yaml`).
|
|
256
|
+
*
|
|
257
|
+
* Shaped to match what the `issue.labeled` webhook route emits, because both
|
|
258
|
+
* reach `applyBuildDispatchGate` at the `dispatchWorkflow` choke point and the
|
|
259
|
+
* gate must not be able to tell a difference that matters. `_stage` is what
|
|
260
|
+
* puts the dispatch INTO that gate at all (the gate fails closed on a stage it
|
|
261
|
+
* cannot resolve), and `labels` is what its hold check and its
|
|
262
|
+
* budget-comment de-duplication read.
|
|
263
|
+
*
|
|
264
|
+
* **`_senderIsBot` is explicitly `false`.** A sweep has no sender — nobody
|
|
265
|
+
* applied a label, the cron simply noticed one that was already there. That
|
|
266
|
+
* matters because the gate's `already-built` branch is ASYMMETRIC on this flag:
|
|
267
|
+
* a bot sender is a hard skip (it is the harness's own label write echoing
|
|
268
|
+
* back), while a human sender is an explicit retry instruction and is allowed
|
|
269
|
+
* through, subject to every budget. Stamping `true` would be a lie that reads
|
|
270
|
+
* as a loop guard; omitting it lands on the same place (`=== true` is false),
|
|
271
|
+
* but saying it out loud is the point — this is the one key on this context
|
|
272
|
+
* whose wrong value would be silently safe today and silently wrong the moment
|
|
273
|
+
* anyone inverts that test.
|
|
274
|
+
*
|
|
275
|
+
* The `route: "sweep"` the gate logs is derived from `_triggerType: "cron"`,
|
|
276
|
+
* not passed separately.
|
|
277
|
+
*/
|
|
278
|
+
function issueContext(c) {
|
|
237
279
|
return {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
280
|
+
_triggerType: "cron",
|
|
281
|
+
repo: c.repo,
|
|
282
|
+
issueNumber: c.issueNumber,
|
|
283
|
+
title: c.title,
|
|
284
|
+
labels: c.labels ?? [],
|
|
285
|
+
...(c.stage ? { _stage: c.stage } : {}),
|
|
286
|
+
_senderIsBot: false,
|
|
244
287
|
};
|
|
245
288
|
}
|
|
246
289
|
//# sourceMappingURL=runner.js.map
|
package/dist/cron/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/cron/runner.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAuB,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBA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C;KAC5E,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,YAAY,CAAC,CAAgB;IACpC,OAAO;QACL,YAAY,EAAE,MAAM;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;QACtB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BUILD trigger decision — the issue-side equivalent of the PR dispatch
|
|
3
|
+
* gate in `./pr-decisions.ts`.
|
|
4
|
+
*
|
|
5
|
+
* An issue labelled `ready-for-agent` dispatches a gated `build` workflow, and
|
|
6
|
+
* the label can be applied from three places that share nothing else: a webhook
|
|
7
|
+
* (a human, OR our own triage bot), the backstop cron sweep, and `/api/run`.
|
|
8
|
+
* Three surfaces, one policy — so the policy is a PURE function every one of
|
|
9
|
+
* them crosses, rather than three enforcement points free to disagree. That is
|
|
10
|
+
* the same split `resolveReviewTrigger` makes (DISCOVERY vs POLICY): the sweep
|
|
11
|
+
* finds candidates and knows nothing about autonomy, holds or idempotency,
|
|
12
|
+
* while this function decides.
|
|
13
|
+
*
|
|
14
|
+
* It returns **`{ decision, reason, inputs }`**, never a bare enum, for the
|
|
15
|
+
* reason the module header of `pr-decisions.ts` gives: the reason string is
|
|
16
|
+
* rendered in three places — the log line, the issue comment and the dashboard
|
|
17
|
+
* run panel — so there is ONE source and three renderings rather than three
|
|
18
|
+
* prose variants that drift. The reason is written `"<case>: <explanation>"` so
|
|
19
|
+
* the case stays greppable without a parallel enum to keep in sync, and
|
|
20
|
+
* `inputs` records every field the decision read so the panel can show WHY
|
|
21
|
+
* without re-deriving anything.
|
|
22
|
+
*
|
|
23
|
+
* Purity is the point: the whole of this module's verification is a table test
|
|
24
|
+
* over literal input records — no GitHub mock, no sandbox, no harness. Nothing
|
|
25
|
+
* here logs; the CALLER logs the decision, exactly as the dispatch sites do for
|
|
26
|
+
* `resolveReviewTrigger`.
|
|
27
|
+
*/
|
|
28
|
+
import type { AutonomyBudgetConfig } from "../config/config.js";
|
|
29
|
+
import type { Decision } from "./pr-decisions.js";
|
|
30
|
+
/**
|
|
31
|
+
* Run the gated build, or don't.
|
|
32
|
+
*
|
|
33
|
+
* Two-valued, deliberately — unlike `ReviewTriggerDecision`, there is no
|
|
34
|
+
* `defer` here. `defer` exists on the review path because a deferral posts a
|
|
35
|
+
* placeholder `last-light/review` check that says "not yet, ask me"; a build has
|
|
36
|
+
* no such projection, so a "come back later" and a "no" are the same answer to
|
|
37
|
+
* the only question the caller asks. The DISTINCTION is preserved in the reason
|
|
38
|
+
* prose instead (`run-in-flight:` is transient, `not-autonomous:` is not), which
|
|
39
|
+
* is what the comment and the panel render.
|
|
40
|
+
*/
|
|
41
|
+
export type BuildTriggerDecision = "dispatch" | "skip";
|
|
42
|
+
/** Everything the build gate reads. Resolved once by the caller, per dispatch. */
|
|
43
|
+
export interface BuildTriggerInputs {
|
|
44
|
+
/** `"owner/repo"`. */
|
|
45
|
+
repo: string;
|
|
46
|
+
issueNumber: number;
|
|
47
|
+
/** The issue's CURRENT labels — the hold check reads this, not `addedLabel`. */
|
|
48
|
+
labels: readonly string[];
|
|
49
|
+
/** The label whose application triggered this, when one did (the `labeled` route). */
|
|
50
|
+
addedLabel?: string;
|
|
51
|
+
/** Which surface this dispatch arrived on. */
|
|
52
|
+
route: "labeled" | "sweep" | "api";
|
|
53
|
+
/** Did OUR bot apply the label (vs a human)? Drives the already-built asymmetry. */
|
|
54
|
+
senderIsBot: boolean;
|
|
55
|
+
/** Is this repo on the operator's autonomy allow-list? */
|
|
56
|
+
autonomyEnabled: boolean;
|
|
57
|
+
/** `db.runs.hasRunForTrigger(triggerId, "build")` — the idempotency key. */
|
|
58
|
+
alreadyBuilt: boolean;
|
|
59
|
+
/** A live (queued/running/paused) run exists for this trigger. */
|
|
60
|
+
runInFlight: boolean;
|
|
61
|
+
holdLabel: string;
|
|
62
|
+
/** Autonomous build runs in flight right now, HARNESS-WIDE (every repo). */
|
|
63
|
+
concurrentAutonomousBuilds: number;
|
|
64
|
+
/** Build runs started for THIS repo so far today (UTC). */
|
|
65
|
+
buildsForRepoToday: number;
|
|
66
|
+
/** Harness-wide model spend so far today (UTC), in USD. */
|
|
67
|
+
spendTodayUsd: number;
|
|
68
|
+
/** This repo's share of that spend, in USD. */
|
|
69
|
+
repoSpendTodayUsd: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The universal subject key: `owner/repo#N`. Matches what
|
|
73
|
+
* `workflow_runs.triggerId` stores.
|
|
74
|
+
*
|
|
75
|
+
* Verified byte-for-byte against the two places that already mint it —
|
|
76
|
+
* `src/workflows/simple.ts` (`${owner}/${repo}#${number}`, the id every
|
|
77
|
+
* issue/PR-scoped run is recorded under) and the router's re-triage branch
|
|
78
|
+
* (`${envelope.repo}#${envelope.issueNumber}`, where `envelope.repo` is already
|
|
79
|
+
* `owner/repo`). It has to match exactly: `alreadyBuilt` is a lookup on this
|
|
80
|
+
* string, so a single character of drift means the idempotency key silently
|
|
81
|
+
* never matches and the loop this gate exists to stop runs forever.
|
|
82
|
+
*/
|
|
83
|
+
export declare function issueTriggerId(repo: string, issueNumber: number): string;
|
|
84
|
+
/**
|
|
85
|
+
* One resolver, every route.
|
|
86
|
+
*
|
|
87
|
+
* The branch ORDER below is the design, not an accident of how it was written.
|
|
88
|
+
* Each branch sits where it does because of what outranks it, and the reasons
|
|
89
|
+
* are recorded inline.
|
|
90
|
+
*/
|
|
91
|
+
export declare function resolveBuildTrigger(inputs: BuildTriggerInputs, budget: AutonomyBudgetConfig): Decision<BuildTriggerDecision>;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BUILD trigger decision — the issue-side equivalent of the PR dispatch
|
|
3
|
+
* gate in `./pr-decisions.ts`.
|
|
4
|
+
*
|
|
5
|
+
* An issue labelled `ready-for-agent` dispatches a gated `build` workflow, and
|
|
6
|
+
* the label can be applied from three places that share nothing else: a webhook
|
|
7
|
+
* (a human, OR our own triage bot), the backstop cron sweep, and `/api/run`.
|
|
8
|
+
* Three surfaces, one policy — so the policy is a PURE function every one of
|
|
9
|
+
* them crosses, rather than three enforcement points free to disagree. That is
|
|
10
|
+
* the same split `resolveReviewTrigger` makes (DISCOVERY vs POLICY): the sweep
|
|
11
|
+
* finds candidates and knows nothing about autonomy, holds or idempotency,
|
|
12
|
+
* while this function decides.
|
|
13
|
+
*
|
|
14
|
+
* It returns **`{ decision, reason, inputs }`**, never a bare enum, for the
|
|
15
|
+
* reason the module header of `pr-decisions.ts` gives: the reason string is
|
|
16
|
+
* rendered in three places — the log line, the issue comment and the dashboard
|
|
17
|
+
* run panel — so there is ONE source and three renderings rather than three
|
|
18
|
+
* prose variants that drift. The reason is written `"<case>: <explanation>"` so
|
|
19
|
+
* the case stays greppable without a parallel enum to keep in sync, and
|
|
20
|
+
* `inputs` records every field the decision read so the panel can show WHY
|
|
21
|
+
* without re-deriving anything.
|
|
22
|
+
*
|
|
23
|
+
* Purity is the point: the whole of this module's verification is a table test
|
|
24
|
+
* over literal input records — no GitHub mock, no sandbox, no harness. Nothing
|
|
25
|
+
* here logs; the CALLER logs the decision, exactly as the dispatch sites do for
|
|
26
|
+
* `resolveReviewTrigger`.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The universal subject key: `owner/repo#N`. Matches what
|
|
30
|
+
* `workflow_runs.triggerId` stores.
|
|
31
|
+
*
|
|
32
|
+
* Verified byte-for-byte against the two places that already mint it —
|
|
33
|
+
* `src/workflows/simple.ts` (`${owner}/${repo}#${number}`, the id every
|
|
34
|
+
* issue/PR-scoped run is recorded under) and the router's re-triage branch
|
|
35
|
+
* (`${envelope.repo}#${envelope.issueNumber}`, where `envelope.repo` is already
|
|
36
|
+
* `owner/repo`). It has to match exactly: `alreadyBuilt` is a lookup on this
|
|
37
|
+
* string, so a single character of drift means the idempotency key silently
|
|
38
|
+
* never matches and the loop this gate exists to stop runs forever.
|
|
39
|
+
*/
|
|
40
|
+
export function issueTriggerId(repo, issueNumber) {
|
|
41
|
+
return `${repo}#${issueNumber}`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One resolver, every route.
|
|
45
|
+
*
|
|
46
|
+
* The branch ORDER below is the design, not an accident of how it was written.
|
|
47
|
+
* Each branch sits where it does because of what outranks it, and the reasons
|
|
48
|
+
* are recorded inline.
|
|
49
|
+
*/
|
|
50
|
+
export function resolveBuildTrigger(inputs, budget) {
|
|
51
|
+
// The full input record travels on EVERY returned decision — the same rule
|
|
52
|
+
// `resolveReviewTrigger` follows. A decision whose justification you cannot
|
|
53
|
+
// reconstruct is a decision you cannot debug six weeks later, and the panel
|
|
54
|
+
// must never re-derive a field the gate already read.
|
|
55
|
+
const record = {
|
|
56
|
+
repo: inputs.repo,
|
|
57
|
+
issueNumber: inputs.issueNumber,
|
|
58
|
+
labels: [...inputs.labels],
|
|
59
|
+
addedLabel: inputs.addedLabel ?? null,
|
|
60
|
+
route: inputs.route,
|
|
61
|
+
senderIsBot: inputs.senderIsBot,
|
|
62
|
+
autonomyEnabled: inputs.autonomyEnabled,
|
|
63
|
+
alreadyBuilt: inputs.alreadyBuilt,
|
|
64
|
+
runInFlight: inputs.runInFlight,
|
|
65
|
+
holdLabel: inputs.holdLabel,
|
|
66
|
+
concurrentAutonomousBuilds: inputs.concurrentAutonomousBuilds,
|
|
67
|
+
buildsForRepoToday: inputs.buildsForRepoToday,
|
|
68
|
+
spendTodayUsd: inputs.spendTodayUsd,
|
|
69
|
+
repoSpendTodayUsd: inputs.repoSpendTodayUsd,
|
|
70
|
+
// The CEILINGS travel too, not just the readings. A panel showing "3 builds
|
|
71
|
+
// today" cannot tell you whether that was refused without knowing the limit
|
|
72
|
+
// it was measured against, and re-reading the config later answers a
|
|
73
|
+
// different question: what the limit is NOW, not what it was when we
|
|
74
|
+
// decided.
|
|
75
|
+
budget: { ...budget },
|
|
76
|
+
};
|
|
77
|
+
const triggerId = issueTriggerId(inputs.repo, inputs.issueNumber);
|
|
78
|
+
// ── 1. THE HOLD LABEL ────────────────────────────────────────────────────
|
|
79
|
+
//
|
|
80
|
+
// Top of the order, above even the autonomy check, because a hold is the one
|
|
81
|
+
// instruction that means "you, the bot, are off this subject entirely" — it
|
|
82
|
+
// cannot be outranked by a verdict about anything else without ceasing to
|
|
83
|
+
// mean that.
|
|
84
|
+
//
|
|
85
|
+
// Belt-and-braces: the router already refuses a held subject, so on the
|
|
86
|
+
// `labeled` route this branch is unreachable. It is NOT unreachable on the
|
|
87
|
+
// sweep route, which never crosses the router at all — the cron reads issues
|
|
88
|
+
// straight out of GitHub and calls the dispatch choke point. A guard that
|
|
89
|
+
// lives only in the router is a guard only one of our three routes obeys,
|
|
90
|
+
// which is exactly the failure `resolveReviewTrigger`'s run-lock header
|
|
91
|
+
// records.
|
|
92
|
+
//
|
|
93
|
+
// SILENT. No comment, no label, no escalation: a hold is an instruction we are
|
|
94
|
+
// obeying, not a verdict about the issue, and there is nothing to tell anybody
|
|
95
|
+
// that the label already on the issue does not say. It carries `onHold` for
|
|
96
|
+
// the same reason the PR side does — the one thing a caller may do with this
|
|
97
|
+
// is NAME the label to a human who asked, and the name is
|
|
98
|
+
// operator-configurable, so it cannot be a literal at the call site.
|
|
99
|
+
if (inputs.labels.includes(inputs.holdLabel)) {
|
|
100
|
+
return {
|
|
101
|
+
decision: "skip",
|
|
102
|
+
reason: `on-hold: \`${inputs.holdLabel}\` is applied to ${triggerId}`,
|
|
103
|
+
inputs: record,
|
|
104
|
+
onHold: { label: inputs.holdLabel },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// ── 2. AUTONOMY ──────────────────────────────────────────────────────────
|
|
108
|
+
//
|
|
109
|
+
// Below the hold and above everything else. This is the operator's master
|
|
110
|
+
// switch for "may this repo have work done on it unattended", so it must
|
|
111
|
+
// outrank every question about THIS issue — there is no state an individual
|
|
112
|
+
// issue can be in that earns it an autonomous build on a repo the operator
|
|
113
|
+
// never opted in.
|
|
114
|
+
//
|
|
115
|
+
// It sits below the hold only because the hold is the more specific
|
|
116
|
+
// instruction and produces the more useful message: telling somebody who just
|
|
117
|
+
// applied a hold that the repo is not autonomous answers a question they did
|
|
118
|
+
// not ask.
|
|
119
|
+
if (!inputs.autonomyEnabled) {
|
|
120
|
+
return {
|
|
121
|
+
decision: "skip",
|
|
122
|
+
reason: `not-autonomous: ${inputs.repo} is not on the autonomy allow-list, so a labelled issue does not dispatch a build`,
|
|
123
|
+
inputs: record,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// ── 3. ALREADY BUILT — the idempotency key, and the one deliberate asymmetry ─
|
|
127
|
+
//
|
|
128
|
+
// `alreadyBuilt` is `hasRunForTrigger(triggerId, "build")`: we have run a
|
|
129
|
+
// build for this issue before. What that FACT means depends entirely on who
|
|
130
|
+
// re-applied the label, and the two answers are opposite.
|
|
131
|
+
//
|
|
132
|
+
// BOT → HARD SKIP. This is the guard that stops a label loop. Our own triage
|
|
133
|
+
// workflow applies `ready-for-agent`; a build can re-triage, or a failure can
|
|
134
|
+
// route back through triage, and the label goes on again. Each cycle would
|
|
135
|
+
// dispatch a full build. Nothing in that loop involves a human deciding
|
|
136
|
+
// anything, so an automated re-label can NEVER re-spend — there is no amount
|
|
137
|
+
// of machine confidence that turns a repeat into a new instruction.
|
|
138
|
+
//
|
|
139
|
+
// HUMAN → FALL THROUGH AND DISPATCH. A maintainer re-applying
|
|
140
|
+
// `ready-for-agent` to an issue whose build failed or got blocked is an
|
|
141
|
+
// explicit retry instruction, and the only reading of it that makes sense.
|
|
142
|
+
// Refusing would leave every failed build with no restart path except the CLI,
|
|
143
|
+
// which is the same dead end `pr-escalation.ts` exists to avoid on the PR
|
|
144
|
+
// side: a subject that is stuck, with nothing on it explaining how to unstick
|
|
145
|
+
// it, is strictly worse than one that is merely wrong.
|
|
146
|
+
//
|
|
147
|
+
// This mirrors `resolveReviewTrigger`'s explicit-request branch verbatim in
|
|
148
|
+
// its reasoning — there, `@bot review` sits ABOVE the per-head dedup because a
|
|
149
|
+
// human's ask outranks a dedup that exists to stop MACHINES looping. Same
|
|
150
|
+
// shape here: the dedup is aimed at the bot, so it binds the bot.
|
|
151
|
+
//
|
|
152
|
+
// THE RISK WE ARE ACCEPTING, named: a maintainer can re-label the same issue
|
|
153
|
+
// repeatedly and buy a full build each time, and nothing in this function
|
|
154
|
+
// bounds that spend. That is deliberate — an explicit human instruction is not
|
|
155
|
+
// a loop — but it does mean the cost ceiling for this path is a person, not a
|
|
156
|
+
// counter. The Phase 2 budget branches below are where that gets a number.
|
|
157
|
+
const humanRetry = inputs.alreadyBuilt && !inputs.senderIsBot;
|
|
158
|
+
if (inputs.alreadyBuilt && inputs.senderIsBot) {
|
|
159
|
+
return {
|
|
160
|
+
decision: "skip",
|
|
161
|
+
reason: `already-built: a build run already exists for ${triggerId} and the label was re-applied by us, not by a human`,
|
|
162
|
+
inputs: record,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// ── 4. A RUN IS ALREADY IN FLIGHT ────────────────────────────────────────
|
|
166
|
+
//
|
|
167
|
+
// Below the human retry on purpose: a retry instruction is still refused while
|
|
168
|
+
// a run is live, because this is not a policy question. Two builds on one
|
|
169
|
+
// issue means two agents cloning and pushing the same branch, which is a
|
|
170
|
+
// physical constraint no instruction can override — the same reason the
|
|
171
|
+
// PR-scoped run lock sits above `resolveReviewTrigger`'s explicit-request
|
|
172
|
+
// branch.
|
|
173
|
+
//
|
|
174
|
+
// A "come back later", NOT a verdict. Nothing is wrong with the issue and
|
|
175
|
+
// nothing about this answer is terminal; the work simply cannot start while
|
|
176
|
+
// another run owns it. Dropping rather than queueing is only sound because the
|
|
177
|
+
// backstop sweep is the re-pickup — it is the release mechanism for every
|
|
178
|
+
// issue dropped here, since the label is already applied and no further
|
|
179
|
+
// `labeled` webhook will ever fire for it. A future phase that converts
|
|
180
|
+
// drop-on-lock into queue-on-lock must land before that sweep is removed.
|
|
181
|
+
if (inputs.runInFlight) {
|
|
182
|
+
return {
|
|
183
|
+
decision: "skip",
|
|
184
|
+
reason: `run-in-flight: a build run for ${triggerId} is already queued, running or paused`,
|
|
185
|
+
inputs: record,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// ── 5. THE BUDGET CEILINGS ───────────────────────────────────────────────
|
|
189
|
+
//
|
|
190
|
+
// Three branches, all below every correctness gate above (a build we must not
|
|
191
|
+
// run AT ALL is never a budget question) and all above the dispatch below (a
|
|
192
|
+
// build we may run is still subject to a ceiling).
|
|
193
|
+
//
|
|
194
|
+
// ## Why they need no new decision value
|
|
195
|
+
//
|
|
196
|
+
// Every one of them is a "come back later", exactly like `run-in-flight`:
|
|
197
|
+
// nothing is wrong with the issue, and nothing about the answer is a verdict
|
|
198
|
+
// on it. Concurrency frees itself when another run finishes; both day-scoped
|
|
199
|
+
// ceilings free themselves at UTC midnight. The release mechanism is the same
|
|
200
|
+
// one `run-in-flight` already depends on — the Phase 4 backstop sweep — so
|
|
201
|
+
// adding a third decision value would buy a distinction no caller could act
|
|
202
|
+
// on. The distinction that DOES matter is in the consequence, and that is the
|
|
203
|
+
// caller's business, not this function's: `build-gate.ts` logs the first,
|
|
204
|
+
// records an activity row for the second, and comments once for the third.
|
|
205
|
+
//
|
|
206
|
+
// ## Why this order
|
|
207
|
+
//
|
|
208
|
+
// Cheapest and most transient first. When several ceilings are true at once
|
|
209
|
+
// the one worth reporting is the one that will clear soonest, because that is
|
|
210
|
+
// the one a human reading the reason can wait out — telling somebody their
|
|
211
|
+
// repo is out of budget for the day when the true answer is "two builds are
|
|
212
|
+
// running, try in ten minutes" is a worse answer, and it is the one that
|
|
213
|
+
// would trigger a comment and a label that then have to be undone.
|
|
214
|
+
//
|
|
215
|
+
// ## `>=`, and why a configured `0` has to work
|
|
216
|
+
//
|
|
217
|
+
// The limit is the number of builds (or dollars) ALLOWED, so a repo that has
|
|
218
|
+
// had its three has had its three — `>` would silently grant one more than
|
|
219
|
+
// the operator asked for at every ceiling. It is also what makes a configured
|
|
220
|
+
// `0` mean "refuse everything", which is the only reading of it that makes
|
|
221
|
+
// sense and the one an operator reaches for to stop the pipeline dead without
|
|
222
|
+
// un-configuring it. `normalizeAutonomyBudget` deliberately keeps a `0` as a
|
|
223
|
+
// real setting (only a negative or non-numeric value falls back to the
|
|
224
|
+
// packaged default), so a `0` that arrived here is one somebody meant.
|
|
225
|
+
// 5a. CONCURRENCY — harness-wide, and the one that clears by itself soonest.
|
|
226
|
+
//
|
|
227
|
+
// Counted across every repo, not per-repo: the constraint is this
|
|
228
|
+
// deployment's capacity to have agents running at once, which a second repo
|
|
229
|
+
// consumes exactly as much as the first. Autonomous runs only — a build a
|
|
230
|
+
// human asked for by comment is not spending the unattended budget and must
|
|
231
|
+
// not be refused by it.
|
|
232
|
+
if (inputs.concurrentAutonomousBuilds >= budget.maxConcurrentBuilds) {
|
|
233
|
+
return {
|
|
234
|
+
decision: "skip",
|
|
235
|
+
reason: `concurrency-exhausted: ${inputs.concurrentAutonomousBuilds} autonomous build run(s) are already in flight, at the harness ceiling of ${budget.maxConcurrentBuilds}`,
|
|
236
|
+
inputs: record,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
// 5b. THE PER-REPO DAY QUOTA — the blast-radius bound.
|
|
240
|
+
//
|
|
241
|
+
// This is guard 4 of the four-guard loop-safety argument, and the one that
|
|
242
|
+
// bounds the damage if guards 1-3 all fail: however badly the label logic
|
|
243
|
+
// misbehaves, one repo buys at most N builds a day. It counts runs STARTED,
|
|
244
|
+
// in every status, because a build that failed still spent the money — a
|
|
245
|
+
// repo whose builds keep crashing is precisely the case where an unbounded
|
|
246
|
+
// retry loop is most expensive.
|
|
247
|
+
if (inputs.buildsForRepoToday >= budget.maxBuildsPerRepoPerDay) {
|
|
248
|
+
return {
|
|
249
|
+
decision: "skip",
|
|
250
|
+
reason: `repo-quota-exhausted: ${inputs.repo} has started ${inputs.buildsForRepoToday} build run(s) today, at its daily ceiling of ${budget.maxBuildsPerRepoPerDay} — it resets at midnight UTC`,
|
|
251
|
+
inputs: record,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// 5c. SPEND — the last ceiling, and the only one owed a human an explanation.
|
|
255
|
+
//
|
|
256
|
+
// Two ceilings in one branch because they answer the same question ("is there
|
|
257
|
+
// money for this today?") and produce the same consequence. The HARNESS
|
|
258
|
+
// ceiling is checked first when both are blown: it is the broader fact, and
|
|
259
|
+
// the more useful one to put in front of somebody — a repo told it is over
|
|
260
|
+
// its own limit would go and raise that limit to no effect.
|
|
261
|
+
//
|
|
262
|
+
// It carries `budgetExhausted` so the caller can key on a TYPED field rather
|
|
263
|
+
// than on this sentence. That matters more here than anywhere else in this
|
|
264
|
+
// function, because this is the one skip with a terminal-for-today
|
|
265
|
+
// consequence — a label and a comment — and a consequence gated on prose
|
|
266
|
+
// stops firing the day somebody rewords the prose.
|
|
267
|
+
const harnessOverspent = inputs.spendTodayUsd >= budget.dailyUsd;
|
|
268
|
+
const repoOverspent = inputs.repoSpendTodayUsd >= budget.repoDailyUsd;
|
|
269
|
+
if (harnessOverspent || repoOverspent) {
|
|
270
|
+
const scope = harnessOverspent ? "harness" : "repo";
|
|
271
|
+
const limitUsd = harnessOverspent ? budget.dailyUsd : budget.repoDailyUsd;
|
|
272
|
+
const spentUsd = harnessOverspent ? inputs.spendTodayUsd : inputs.repoSpendTodayUsd;
|
|
273
|
+
const subject = harnessOverspent ? "this deployment" : inputs.repo;
|
|
274
|
+
return {
|
|
275
|
+
decision: "skip",
|
|
276
|
+
reason: `budget-exhausted: ${subject} has spent $${spentUsd.toFixed(2)} of its $${limitUsd.toFixed(2)} daily model budget — it resets at midnight UTC`,
|
|
277
|
+
inputs: record,
|
|
278
|
+
budgetExhausted: { scope, limitUsd, spentUsd },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
// ── 6. DISPATCH ──────────────────────────────────────────────────────────
|
|
282
|
+
//
|
|
283
|
+
// Two reasons, not one: the clean first build and the human retry reach the
|
|
284
|
+
// same decision by different arguments, and the reason string is the record of
|
|
285
|
+
// WHICH — so a re-spend that should never have happened is greppable after the
|
|
286
|
+
// fact instead of indistinguishable from a first run.
|
|
287
|
+
return {
|
|
288
|
+
decision: "dispatch",
|
|
289
|
+
reason: humanRetry
|
|
290
|
+
? `retry: a maintainer re-applied \`${inputs.addedLabel ?? "the build label"}\` to ${triggerId}, which already has a build run — treating it as an explicit retry`
|
|
291
|
+
: `ready: ${triggerId} is labelled for the agent and nothing blocks the build`,
|
|
292
|
+
inputs: record,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=build-decisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-decisions.js","sourceRoot":"","sources":["../../src/engine/build-decisions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA6DH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,WAAmB;IAC9D,OAAO,GAAG,IAAI,IAAI,WAAW,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA0B,EAC1B,MAA4B;IAE5B,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,sDAAsD;IACtD,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAC1B,UAA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,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE;SAC/C,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,EAAE;IACF,4EAA4E;IAC5E,+EAA+E;IAC/E,+EAA+E;IAC/E,sDAAsD;IACtD,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,UAAU;YAChB,CAAC,CAAC,oCAAoC,MAAM,CAAC,UAAU,IAAI,iBAAiB,SAAS,SAAS,oEAAoE;YAClK,CAAC,CAAC,UAAU,SAAS,yDAAyD;QAChF,MAAM,EAAE,MAAM;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BUILD dispatch gate — the IMPURE half of `./build-decisions.ts`.
|
|
3
|
+
*
|
|
4
|
+
* `resolveBuildTrigger` is a pure function over one resolved input record. This
|
|
5
|
+
* module is what stands between it and the world: it RESOLVES those inputs from
|
|
6
|
+
* the config and the state DB, logs the verdict, and applies the one consequence
|
|
7
|
+
* that belongs to the DECISION rather than to the route. Nothing here re-decides
|
|
8
|
+
* anything — every branch of the policy lives in the pure function, and a second
|
|
9
|
+
* copy of any of it here is the exact drift the pure/impure split exists to stop.
|
|
10
|
+
*
|
|
11
|
+
* It is the issue-side mirror of `applyPrDispatchGate` (`./dispatcher.ts`), and
|
|
12
|
+
* the header there states the rule this one also follows: a consequence that
|
|
13
|
+
* belongs to the decision is applied HERE, so no caller can forget it. On this
|
|
14
|
+
* path that consequence is the stage-label advance, which is not decoration —
|
|
15
|
+
* it is **guard 2** of the four-guard loop-safety argument
|
|
16
|
+
* (`./build-decisions.ts`, `./stage-advance.ts`).
|
|
17
|
+
*
|
|
18
|
+
* **Why its own module rather than `dispatcher.ts`.** The PR gate lives there
|
|
19
|
+
* because the dispatcher is where the webhook route decides for itself. Nothing
|
|
20
|
+
* on the issue side needs that: the gate has exactly one caller today
|
|
21
|
+
* (`dispatchWorkflow`) and the two Phase 4 surfaces — the backstop sweep and
|
|
22
|
+
* `/api/run` — reach the same choke point. Keeping it out of a 1,000-line module
|
|
23
|
+
* keeps the footprint of this feature small enough to read in one sitting.
|
|
24
|
+
*/
|
|
25
|
+
import type { StateDb } from "../state/db.js";
|
|
26
|
+
import type { GitHubClient } from "./github/github.js";
|
|
27
|
+
/** What {@link applyBuildDispatchGate} was asked to decide. */
|
|
28
|
+
export interface BuildGateArgs {
|
|
29
|
+
/** `"owner/repo"`. */
|
|
30
|
+
repo: string;
|
|
31
|
+
issueNumber: number;
|
|
32
|
+
/** The issue's CURRENT labels — what the hold check reads. */
|
|
33
|
+
labels: readonly string[];
|
|
34
|
+
/** The label whose application triggered this, when one did. */
|
|
35
|
+
addedLabel?: string;
|
|
36
|
+
/** Which surface this dispatch arrived on. */
|
|
37
|
+
route: "labeled" | "sweep" | "api";
|
|
38
|
+
/** Did OUR bot apply the label? Drives the already-built asymmetry. */
|
|
39
|
+
senderIsBot: boolean;
|
|
40
|
+
/** Stage name from `autonomy.stages`, e.g. "build". */
|
|
41
|
+
stage: string;
|
|
42
|
+
}
|
|
43
|
+
export interface BuildGateDeps {
|
|
44
|
+
db: StateDb;
|
|
45
|
+
/** `null` in chat-only mode — there is then no label to advance. */
|
|
46
|
+
github: GitHubClient | null;
|
|
47
|
+
}
|
|
48
|
+
export interface BuildGateResult {
|
|
49
|
+
decision: "dispatch" | "skip";
|
|
50
|
+
reason: string;
|
|
51
|
+
/**
|
|
52
|
+
* The stage's approval gates, for the caller to union onto the run's
|
|
53
|
+
* effective approval map. Only ever present on a `dispatch`.
|
|
54
|
+
*/
|
|
55
|
+
gates?: Record<string, boolean>;
|
|
56
|
+
}
|
|
57
|
+
export declare function applyBuildDispatchGate(args: BuildGateArgs, deps: BuildGateDeps): Promise<BuildGateResult>;
|
|
58
|
+
/**
|
|
59
|
+
* The budget-exhausted comment. Pure, so its wording is table-testable — the
|
|
60
|
+
* same split `renderEscalationComment` makes.
|
|
61
|
+
*
|
|
62
|
+
* Three things it has to say, and nothing else. **Which ceiling**, with the
|
|
63
|
+
* configured number, because "I am out of budget" is unactionable and "I have
|
|
64
|
+
* spent $10.40 of this repo's $10.00" tells somebody exactly what to change.
|
|
65
|
+
* **When it resets**, because the default assumption is that a blocked bot
|
|
66
|
+
* stays blocked. And **both exits**, because this comment is the only place
|
|
67
|
+
* most people will ever learn there are any — the `pr-escalation.ts` rule that
|
|
68
|
+
* every exit which works must be named, and every exit named must work.
|
|
69
|
+
*
|
|
70
|
+
* Short on purpose: it is an interruption on somebody's issue, not a report.
|
|
71
|
+
*/
|
|
72
|
+
export declare function renderBudgetExhaustedComment(args: {
|
|
73
|
+
scope: "harness" | "repo";
|
|
74
|
+
limitUsd: number;
|
|
75
|
+
spentUsd: number;
|
|
76
|
+
repo: string;
|
|
77
|
+
blockedLabel: string;
|
|
78
|
+
}): string;
|