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.
- package/config/default.yaml +119 -1
- package/dist/admin/routes.js +195 -38
- package/dist/admin/routes.js.map +1 -1
- package/dist/config/config-resolve.d.ts +38 -1
- package/dist/config/config-resolve.js +41 -17
- package/dist/config/config-resolve.js.map +1 -1
- package/dist/config/config.d.ts +114 -0
- package/dist/config/config.js +225 -7
- package/dist/config/config.js.map +1 -1
- package/dist/config/repo-config.d.ts +120 -0
- package/dist/config/repo-config.js +447 -0
- package/dist/config/repo-config.js.map +1 -0
- package/dist/connectors/github-webhook.d.ts +17 -0
- package/dist/connectors/github-webhook.js +150 -17
- package/dist/connectors/github-webhook.js.map +1 -1
- package/dist/connectors/types.d.ts +48 -1
- package/dist/cron/dependabot-discovery.d.ts +68 -11
- package/dist/cron/dependabot-discovery.js +78 -20
- package/dist/cron/dependabot-discovery.js.map +1 -1
- package/dist/cron/fanout.d.ts +10 -0
- package/dist/cron/fanout.js +35 -2
- package/dist/cron/fanout.js.map +1 -1
- package/dist/cron/jobs.d.ts +16 -2
- package/dist/cron/jobs.js +69 -9
- package/dist/cron/jobs.js.map +1 -1
- package/dist/cron/repo-crons.d.ts +110 -0
- package/dist/cron/repo-crons.js +169 -0
- package/dist/cron/repo-crons.js.map +1 -0
- package/dist/cron/review-discovery.d.ts +33 -20
- package/dist/cron/review-discovery.js +23 -30
- package/dist/cron/review-discovery.js.map +1 -1
- package/dist/engine/agent-executor.d.ts +1 -1
- package/dist/engine/agent-executor.js +1 -1
- package/dist/engine/agent-executor.js.map +1 -1
- package/dist/engine/dispatcher.d.ts +98 -1
- package/dist/engine/dispatcher.js +248 -231
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/executors/orchestrator.js +39 -15
- package/dist/engine/executors/orchestrator.js.map +1 -1
- package/dist/engine/executors/shared.d.ts +43 -0
- package/dist/engine/executors/shared.js +65 -0
- package/dist/engine/executors/shared.js.map +1 -1
- package/dist/engine/fix-harvest.d.ts +169 -0
- package/dist/engine/fix-harvest.js +345 -0
- package/dist/engine/fix-harvest.js.map +1 -0
- package/dist/engine/fix-markers.d.ts +184 -0
- package/dist/engine/fix-markers.js +329 -0
- package/dist/engine/fix-markers.js.map +1 -0
- package/dist/engine/fix-scratch.d.ts +76 -0
- package/dist/engine/fix-scratch.js +77 -0
- package/dist/engine/fix-scratch.js.map +1 -0
- package/dist/engine/github/github.d.ts +302 -5
- package/dist/engine/github/github.js +614 -54
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/profiles.d.ts +45 -1
- package/dist/engine/github/profiles.js +35 -0
- package/dist/engine/github/profiles.js.map +1 -1
- package/dist/engine/pr-decisions.d.ts +342 -0
- package/dist/engine/pr-decisions.js +721 -0
- package/dist/engine/pr-decisions.js.map +1 -0
- package/dist/engine/pr-escalation.d.ts +152 -0
- package/dist/engine/pr-escalation.js +320 -0
- package/dist/engine/pr-escalation.js.map +1 -0
- package/dist/engine/pr-notes.d.ts +175 -0
- package/dist/engine/pr-notes.js +315 -0
- package/dist/engine/pr-notes.js.map +1 -0
- package/dist/engine/pr-state.d.ts +313 -0
- package/dist/engine/pr-state.js +515 -0
- package/dist/engine/pr-state.js.map +1 -0
- package/dist/engine/review-check.d.ts +200 -0
- package/dist/engine/review-check.js +305 -0
- package/dist/engine/review-check.js.map +1 -0
- package/dist/engine/router.d.ts +27 -0
- package/dist/engine/router.js +156 -22
- package/dist/engine/router.js.map +1 -1
- package/dist/evals-api.d.ts +10 -0
- package/dist/evals-api.js +38 -0
- package/dist/evals-api.js.map +1 -1
- package/dist/index.js +313 -23
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +13 -0
- package/dist/sandbox/index.js +30 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/k8s/init-clone.d.ts +5 -0
- package/dist/sandbox/k8s/init-clone.js +27 -0
- package/dist/sandbox/k8s/init-clone.js.map +1 -1
- package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +26 -1
- package/dist/sandbox/k8s/kubernetes-sandbox.js +30 -1
- package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
- package/dist/state/execution-store.d.ts +27 -0
- package/dist/state/execution-store.js +45 -0
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +73 -0
- package/dist/state/workflow-run-store.js +106 -24
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/pr-scope.d.ts +63 -0
- package/dist/workflows/pr-scope.js +113 -0
- package/dist/workflows/pr-scope.js.map +1 -0
- package/dist/workflows/resume.js +113 -8
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/runner.d.ts +2 -1
- package/dist/workflows/runner.js +143 -10
- package/dist/workflows/runner.js.map +1 -1
- package/dist/workflows/simple.d.ts +280 -1
- package/dist/workflows/simple.js +499 -8
- package/dist/workflows/simple.js.map +1 -1
- package/dist/workflows/target-policy.d.ts +0 -12
- package/dist/workflows/target-policy.js +9 -15
- package/dist/workflows/target-policy.js.map +1 -1
- package/package.json +4 -4
- package/skills/README.md +11 -5
- package/skills/dependency-impact/SKILL.md +83 -0
- package/skills/fixing/SKILL.md +190 -0
- package/skills/pr-review/SKILL.md +26 -9
- package/workflows/cron-dependabot-ci-fix.yaml +8 -5
- package/workflows/cron-review.yaml +14 -5
- package/workflows/dependabot-ci-fix.yaml +86 -2
- package/workflows/dependabot-pr-merge.yaml +13 -1
- package/workflows/pr-fix.yaml +84 -1
- package/workflows/pr-review.yaml +7 -0
- package/workflows/prompts/dependabot-ci-fix.md +70 -17
- package/workflows/prompts/dependabot-pr-merge.md +203 -80
- package/workflows/prompts/diagnose-ci.md +96 -0
- package/workflows/prompts/pr-fix.md +63 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-repository cron participation (issue #180).
|
|
3
|
+
*
|
|
4
|
+
* A cron is scheduled ONCE globally but fans out into one run per managed repo
|
|
5
|
+
* (`src/cron/fanout.ts`). This module decides, at tick time, WHICH repos that
|
|
6
|
+
* fan-out covers — reading the `crons:` block each repo may commit to its
|
|
7
|
+
* `.lastlight/lastlight.yml`:
|
|
8
|
+
*
|
|
9
|
+
* crons:
|
|
10
|
+
* enable: [security-scan] # run this cron against me even when it's off globally
|
|
11
|
+
* disable: [repo-health] # skip me on this cron
|
|
12
|
+
*
|
|
13
|
+
* ── Why at tick time ──────────────────────────────────────────────────────
|
|
14
|
+
* The alternative — resolving participation when jobs are registered — would
|
|
15
|
+
* mean a repo editing its `lastlight.yml` needs the croner jobs re-registered
|
|
16
|
+
* to take effect (a config-change watcher, or a restart). Resolving here
|
|
17
|
+
* instead makes a repo's edit take effect on the next tick with no scheduler
|
|
18
|
+
* churn, at the cost of a cheap no-op tick when nothing resolves.
|
|
19
|
+
*
|
|
20
|
+
* ── Cost ──────────────────────────────────────────────────────────────────
|
|
21
|
+
* A fan-out over N repos must not become N blocking network calls. The cached
|
|
22
|
+
* layer is used when one is in memory; only cache misses go through
|
|
23
|
+
* {@link fetchRepoLayer}, concurrently, and that call is itself TTL'd +
|
|
24
|
+
* conditional (see `src/config/repo-config.ts`). One repo's failure never
|
|
25
|
+
* aborts the tick: an unreadable config falls back to the repo's inherited
|
|
26
|
+
* (global) behaviour.
|
|
27
|
+
*
|
|
28
|
+
* ── Bounds ────────────────────────────────────────────────────────────────
|
|
29
|
+
* The repo layer only gets a vote when the operator's `repoConfig.allowKeys`
|
|
30
|
+
* admits `crons` (or the legacy `disabled.crons`). Removing it is the operator's
|
|
31
|
+
* kill switch: `crons.disable` in the operator's config then cannot be
|
|
32
|
+
* overridden by any repo, and this module short-circuits with zero fetches.
|
|
33
|
+
*/
|
|
34
|
+
import { getRuntimeConfig } from "../config/config.js";
|
|
35
|
+
import { fetchRepoLayer, getCachedRepoLayer, repoConfigPolicy } from "../config/repo-config.js";
|
|
36
|
+
/**
|
|
37
|
+
* Context keys the cron tick carries from {@link import("./jobs.js").getJobs}
|
|
38
|
+
* to the fan-out. Underscore-prefixed like `_triggerType`, and stripped by the
|
|
39
|
+
* fan-out before dispatch so a workflow run's context looks exactly as it did
|
|
40
|
+
* before this feature existed.
|
|
41
|
+
*
|
|
42
|
+
* They travel in the context because that's the only channel the scheduler
|
|
43
|
+
* gives a job (`runner(job.workflow, job.context)`) — the cron's own NAME isn't
|
|
44
|
+
* otherwise recoverable from the workflow name (several crons may share one
|
|
45
|
+
* workflow).
|
|
46
|
+
*/
|
|
47
|
+
export const CRON_NAME_KEY = "_cronName";
|
|
48
|
+
export const CRON_GLOBALLY_ENABLED_KEY = "_cronGloballyEnabled";
|
|
49
|
+
/**
|
|
50
|
+
* The repos a cron tick should actually fan out over.
|
|
51
|
+
*
|
|
52
|
+
* Never throws: every per-repo failure degrades to that repo's inherited
|
|
53
|
+
* behaviour. An empty result is a legitimate answer (a globally-off cron no
|
|
54
|
+
* repo opted into) and the caller treats it as a no-op tick.
|
|
55
|
+
*/
|
|
56
|
+
export async function resolveCronRepos(options) {
|
|
57
|
+
const { cron, repos, globallyEnabled } = options;
|
|
58
|
+
const policy = options.policy ?? repoConfigPolicy();
|
|
59
|
+
const inherited = globallyEnabled ? [...repos] : [];
|
|
60
|
+
// Fast path: the repo layer has no say here (feature off, or the operator
|
|
61
|
+
// narrowed `allowKeys`). Zero fetches, and the operator's word is final.
|
|
62
|
+
if (!repoLayerMayVote(policy))
|
|
63
|
+
return { repos: inherited, optedOut: [], optedIn: [] };
|
|
64
|
+
const lookup = options.layerFor ?? defaultLayerFor;
|
|
65
|
+
const decisions = await Promise.all(repos.map(async (repo) => {
|
|
66
|
+
try {
|
|
67
|
+
const layer = await lookup(repo);
|
|
68
|
+
return [repo, cronVote(cron, repoCronPrefs(layer?.config, policy))];
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
// `fetchRepoLayer` doesn't reject, but a caller-supplied lookup might —
|
|
72
|
+
// and one repo's bad day must never cost the other repos their tick.
|
|
73
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
74
|
+
console.warn(`[cron] ${cron}: could not read ${repo}'s .lastlight/ config (${message}) — using the global setting`);
|
|
75
|
+
return [repo, undefined];
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
const out = { repos: [], optedOut: [], optedIn: [] };
|
|
79
|
+
for (const [repo, vote] of decisions) {
|
|
80
|
+
if (vote === "disable") {
|
|
81
|
+
if (globallyEnabled)
|
|
82
|
+
out.optedOut.push(repo);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (vote === "enable" && !globallyEnabled)
|
|
86
|
+
out.optedIn.push(repo);
|
|
87
|
+
if (vote === "enable" || globallyEnabled)
|
|
88
|
+
out.repos.push(repo);
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Apply one layer's {@link CronsConfig} to one cron name. DISABLE WINS: a name
|
|
94
|
+
* in both lists doesn't run. Fail safe — a repo that contradicts itself gets
|
|
95
|
+
* the outcome that can't surprise anybody.
|
|
96
|
+
*/
|
|
97
|
+
export function cronVote(cron, prefs) {
|
|
98
|
+
if (prefs.disable.includes(cron))
|
|
99
|
+
return "disable";
|
|
100
|
+
if (prefs.enable.includes(cron))
|
|
101
|
+
return "enable";
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read the `crons:` block (plus the legacy `disabled.crons` alias) out of a
|
|
106
|
+
* repo's RAW, unvalidated `lastlight.yml`, keeping only what the operator's
|
|
107
|
+
* `allowKeys` admits.
|
|
108
|
+
*
|
|
109
|
+
* Bounded here rather than by `resolveRepoConfig`'s sanitizer because cron
|
|
110
|
+
* participation isn't part of the merged per-run config shape — it's consumed
|
|
111
|
+
* by the scheduler, before any run exists. Same house rules as that sanitizer:
|
|
112
|
+
* pure, lenient, drop what doesn't fit and carry on.
|
|
113
|
+
*/
|
|
114
|
+
export function repoCronPrefs(raw, policy) {
|
|
115
|
+
const empty = { enable: [], disable: [] };
|
|
116
|
+
if (!isPlainObject(raw))
|
|
117
|
+
return empty;
|
|
118
|
+
const block = isPlainObject(raw.crons) ? raw.crons : {};
|
|
119
|
+
const enable = allows(policy, "crons.enable") ? cronNames(block.enable) : [];
|
|
120
|
+
const disable = allows(policy, "crons.disable") ? cronNames(block.disable) : [];
|
|
121
|
+
// Legacy alias, unioned in exactly as it is at the operator layer.
|
|
122
|
+
const legacyRaw = isPlainObject(raw.disabled) ? raw.disabled.crons : undefined;
|
|
123
|
+
const legacy = allows(policy, "disabled.crons") ? cronNames(legacyRaw) : [];
|
|
124
|
+
return { enable, disable: [...new Set([...disable, ...legacy])] };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Whether any repo could influence cron participation at all. `false` short-
|
|
128
|
+
* circuits the whole resolution — no cache reads, no fetches, operator's word
|
|
129
|
+
* final. This is the documented kill switch: drop `crons` from
|
|
130
|
+
* `repoConfig.allowKeys`.
|
|
131
|
+
*/
|
|
132
|
+
export function repoLayerMayVote(policy) {
|
|
133
|
+
return (policy.enabled &&
|
|
134
|
+
(allows(policy, "crons.enable") || allows(policy, "crons.disable") || allows(policy, "disabled.crons")));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The operator's cron block from runtime config, or an inert one when config
|
|
138
|
+
* isn't loaded (unit tests, pre-boot paths). Mirrors `repoConfigPolicy()`.
|
|
139
|
+
*/
|
|
140
|
+
export function operatorCrons() {
|
|
141
|
+
return getRuntimeConfig()?.crons ?? { enable: [], disable: [] };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Cached-first layer lookup. `getCachedRepoLayer` can't distinguish "checked,
|
|
145
|
+
* has no `.lastlight/`" from "never checked", so a miss falls through to
|
|
146
|
+
* `fetchRepoLayer` — which is TTL-guarded (a warm negative entry answers from
|
|
147
|
+
* memory) and never throws.
|
|
148
|
+
*/
|
|
149
|
+
function defaultLayerFor(repo) {
|
|
150
|
+
return getCachedRepoLayer(repo) ?? fetchRepoLayer(repo);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Same admit rule as the repo-config sanitizer's: an allow-list entry admits
|
|
154
|
+
* itself and everything beneath it, so `crons` admits `crons.enable` while
|
|
155
|
+
* `disabled.workflows` admits neither.
|
|
156
|
+
*/
|
|
157
|
+
function allows(policy, path) {
|
|
158
|
+
return policy.allowKeys.some((allowed) => path === allowed || path.startsWith(`${allowed}.`));
|
|
159
|
+
}
|
|
160
|
+
/** Trimmed non-empty names from a YAML list; anything else contributes nothing. */
|
|
161
|
+
function cronNames(raw) {
|
|
162
|
+
if (!Array.isArray(raw))
|
|
163
|
+
return [];
|
|
164
|
+
return raw.filter((v) => typeof v === "string" && v.trim().length > 0).map((v) => v.trim());
|
|
165
|
+
}
|
|
166
|
+
function isPlainObject(value) {
|
|
167
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=repo-crons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-crons.js","sourceRoot":"","sources":["../../src/cron/repo-crons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,gBAAgB,EAA2C,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAkB,MAAM,0BAA0B,CAAC;AAEhH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AA2BhE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgC;IACrE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAA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C,UAAU,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,mFAAmF;AACnF,SAAS,SAAS,CAAC,GAAY;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CANDIDATE FINDER for the pr-review cron (`check-prs-awaiting-review`).
|
|
3
3
|
*
|
|
4
|
-
* Finds the open PRs that
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Finds the open PRs across `repos` that could plausibly want a review, in code
|
|
5
|
+
* (no LLM). The caller fans out one bounded single-PR `pr-review` run per
|
|
6
|
+
* result, with `prNumber` + head ref set (see `src/index.ts`) — the exact shape
|
|
7
|
+
* the `pr.opened` webhook produces: a fresh per-repo scoped token, a pre-clone
|
|
8
|
+
* of the PR head, and a real PR number for `post-review` to post to.
|
|
9
|
+
*
|
|
10
|
+
* **It holds no policy** (09-state-machine.md → S2). It used to filter drafts
|
|
11
|
+
* and call `getLatestBotReview` per candidate, which made it a third
|
|
12
|
+
* implementation of `review.trigger` alongside the webhook gate and the comment
|
|
13
|
+
* path's silent bypass — in a plan whose whole thesis is "make the policy
|
|
14
|
+
* configurable rather than hardcoded". The split is DISCOVERY vs POLICY, not
|
|
15
|
+
* cron vs webhook: draft, already-reviewed-at-this-head, run-in-flight and the
|
|
16
|
+
* trigger mode are all fields of the `PrState` snapshot that
|
|
17
|
+
* `resolveReviewTrigger` decides over, once, at the dispatch choke point every
|
|
18
|
+
* route crosses.
|
|
19
|
+
*
|
|
20
|
+
* The one filter that stays is not policy but arithmetic: GitHub 422s an
|
|
21
|
+
* attempt to review your own pull request, so a bot-authored PR is not a
|
|
22
|
+
* candidate in the first place.
|
|
10
23
|
*
|
|
11
24
|
* This replaces the old `mode: scan` run, whose single agent listed and reviewed
|
|
12
25
|
* PRs itself inside the sandbox — which couldn't reliably auth (a static token
|
|
@@ -27,27 +40,27 @@ export interface ReviewDiscoveryClient {
|
|
|
27
40
|
headRef: string;
|
|
28
41
|
headSha: string;
|
|
29
42
|
}>>;
|
|
30
|
-
/** The bot's most recent review on this PR's CURRENT head SHA, or null when
|
|
31
|
-
* the bot hasn't reviewed this SHA yet (re-pushes invalidate a stale review). */
|
|
32
|
-
getLatestBotReview(owner: string, repo: string, pullNumber: number, headSha: string, botLogin?: string): Promise<{
|
|
33
|
-
state: string;
|
|
34
|
-
} | null>;
|
|
35
43
|
}
|
|
36
44
|
export interface ReviewDiscoverOptions {
|
|
37
45
|
log?: (msg: string) => void;
|
|
38
46
|
/**
|
|
39
47
|
* Bot login incl. the `[bot]` suffix (e.g. `last-light[bot]`). The bot's own
|
|
40
|
-
* PRs are
|
|
41
|
-
*
|
|
42
|
-
*
|
|
48
|
+
* PRs are not candidates — GitHub refuses a self-review outright. Defaults to
|
|
49
|
+
* `last-light[bot]`; the caller passes the configured `botLogin` so a renamed
|
|
50
|
+
* App slug matches.
|
|
43
51
|
*/
|
|
44
52
|
botLogin?: string;
|
|
45
53
|
/**
|
|
46
|
-
* Cap the
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
54
|
+
* Cap the candidates offered per repo per tick, so one busy repo can't spin
|
|
55
|
+
* hundreds of dispatches at once. Oldest-first, so the cap is stable across
|
|
56
|
+
* ticks rather than starving the same tail every time.
|
|
57
|
+
*
|
|
58
|
+
* This used to cap runs DISPATCHED, walking every open PR and stopping after
|
|
59
|
+
* N *unreviewed* ones. That distinction died with the per-candidate
|
|
60
|
+
* `getLatestBotReview` call: the dispatch gate now answers "already reviewed
|
|
61
|
+
* at this head" from the one `PrState` snapshot it resolves anyway, so a
|
|
62
|
+
* candidate that turns out to be reviewed is a cheap gate skip, not a run.
|
|
63
|
+
* Runs also queue against the global admission cap. Default 25.
|
|
51
64
|
*/
|
|
52
65
|
maxPerRepo?: number;
|
|
53
66
|
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CANDIDATE FINDER for the pr-review cron (`check-prs-awaiting-review`).
|
|
3
3
|
*
|
|
4
|
-
* Finds the open PRs that
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Finds the open PRs across `repos` that could plausibly want a review, in code
|
|
5
|
+
* (no LLM). The caller fans out one bounded single-PR `pr-review` run per
|
|
6
|
+
* result, with `prNumber` + head ref set (see `src/index.ts`) — the exact shape
|
|
7
|
+
* the `pr.opened` webhook produces: a fresh per-repo scoped token, a pre-clone
|
|
8
|
+
* of the PR head, and a real PR number for `post-review` to post to.
|
|
9
|
+
*
|
|
10
|
+
* **It holds no policy** (09-state-machine.md → S2). It used to filter drafts
|
|
11
|
+
* and call `getLatestBotReview` per candidate, which made it a third
|
|
12
|
+
* implementation of `review.trigger` alongside the webhook gate and the comment
|
|
13
|
+
* path's silent bypass — in a plan whose whole thesis is "make the policy
|
|
14
|
+
* configurable rather than hardcoded". The split is DISCOVERY vs POLICY, not
|
|
15
|
+
* cron vs webhook: draft, already-reviewed-at-this-head, run-in-flight and the
|
|
16
|
+
* trigger mode are all fields of the `PrState` snapshot that
|
|
17
|
+
* `resolveReviewTrigger` decides over, once, at the dispatch choke point every
|
|
18
|
+
* route crosses.
|
|
19
|
+
*
|
|
20
|
+
* The one filter that stays is not policy but arithmetic: GitHub 422s an
|
|
21
|
+
* attempt to review your own pull request, so a bot-authored PR is not a
|
|
22
|
+
* candidate in the first place.
|
|
10
23
|
*
|
|
11
24
|
* This replaces the old `mode: scan` run, whose single agent listed and reviewed
|
|
12
25
|
* PRs itself inside the sandbox — which couldn't reliably auth (a static token
|
|
@@ -38,31 +51,11 @@ export async function discoverPrsAwaitingReview(repos, gh, opts = {}) {
|
|
|
38
51
|
continue;
|
|
39
52
|
}
|
|
40
53
|
const candidates = open
|
|
41
|
-
.filter((pr) =>
|
|
42
|
-
.sort((a, b) => a.number - b.number)
|
|
43
|
-
|
|
44
|
-
// once we've queued `maxPerRepo` UNreviewed ones. Slicing before the review
|
|
45
|
-
// check would starve unreviewed PRs behind a block of already-reviewed ones
|
|
46
|
-
// (the steady state), deferring them indefinitely.
|
|
47
|
-
let dispatched = 0;
|
|
54
|
+
.filter((pr) => pr.authorLogin !== botLogin)
|
|
55
|
+
.sort((a, b) => a.number - b.number) // oldest first — deterministic, fair
|
|
56
|
+
.slice(0, maxPerRepo);
|
|
48
57
|
for (const pr of candidates) {
|
|
49
|
-
if (dispatched >= maxPerRepo)
|
|
50
|
-
break;
|
|
51
|
-
let reviewed;
|
|
52
|
-
try {
|
|
53
|
-
reviewed = !!(await gh.getLatestBotReview(owner, repo, pr.number, pr.headSha, botLogin));
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
// Can't tell → skip this tick rather than risk a duplicate review. The
|
|
57
|
-
// next tick retries, and `post-review` is itself idempotent on the head
|
|
58
|
-
// SHA, so a missed check here can't cause a double-post downstream.
|
|
59
|
-
opts.log?.(`[review-discovery] ${full}#${pr.number}: review lookup failed — ${String(err)}`);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (reviewed)
|
|
63
|
-
continue; // already reviewed at the current head SHA
|
|
64
58
|
out.push({ repo: full, prNumber: pr.number, title: pr.title, branch: pr.headRef });
|
|
65
|
-
dispatched++;
|
|
66
59
|
}
|
|
67
60
|
}
|
|
68
61
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-discovery.js","sourceRoot":"","sources":["../../src/cron/review-discovery.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"review-discovery.js","sourceRoot":"","sources":["../../src/cron/review-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA8CH,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAAe,EACf,EAAyB,EACzB,OAA8B,EAAE;IAEhC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,oBAAoB,CAAC;IAC3D,MAAM,GAAG,GAAmB,EAAE,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,EAAE,CAAC,+CAA+C,IAAI,GAAG,CAAC,CAAC;YACnE,SAAS;QACX,CAAC;QAED,IAAI,IAAwE,CAAC;QAC7E,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,EAAE,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,2EAA2E;YAC3E,+BAA+B;YAC/B,IAAI,CAAC,GAAG,EAAE,CAAC,sBAAsB,IAAI,0BAA0B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9E,SAAS;QACX,CAAC;QAED,MAAM,UAAU,GAAG,IAAI;aACpB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,KAAK,QAAQ,CAAC;aAC3C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,qCAAqC;aACzE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAExB,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ExecutorConfig, type ExecutionResult, type GitSandboxAccess } from "./github/profiles.js";
|
|
2
2
|
import type { SandboxFactory } from "../sandbox/sandbox.js";
|
|
3
3
|
import { type CommandSpec } from "./executors/orchestrator.js";
|
|
4
|
-
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, detectAccountError, mapStopReason, reclassifySuccess } from "./executors/shared.js";
|
|
4
|
+
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, resetVerifyScript, VERIFY_SCRIPT_NAME, detectAccountError, mapStopReason, reclassifySuccess } from "./executors/shared.js";
|
|
5
5
|
export type { CommandSpec } from "./executors/orchestrator.js";
|
|
6
6
|
export declare function executeAgent(prompt: string, config: ExecutorConfig, opts?: {
|
|
7
7
|
taskId?: string;
|
|
@@ -11,7 +11,7 @@ import { OAUTH_ONLY_PROVIDERS, oauthEnvVarForProvider, oauthProviderIdForModel,
|
|
|
11
11
|
import { runSandboxedAgent, runSandboxedCommand, } from "./executors/orchestrator.js";
|
|
12
12
|
// Re-exported for back-compat with existing importers (tests, dashboards,
|
|
13
13
|
// workflow phase executor).
|
|
14
|
-
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, detectAccountError, mapStopReason, reclassifySuccess } from "./executors/shared.js";
|
|
14
|
+
export { RunResultAccumulator, stageSkillBundle, excludeFromGit, resetVerifyScript, VERIFY_SCRIPT_NAME, detectAccountError, mapStopReason, reclassifySuccess } from "./executors/shared.js";
|
|
15
15
|
/**
|
|
16
16
|
* Resolve the App credentials to mint with from **boot config**, falling back to
|
|
17
17
|
* `process.env` only when no config has been loaded (unit tests, embedders).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-executor.js","sourceRoot":"","sources":["../../src/engine/agent-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAuB,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OA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IAEH,MAAM,GAAG,GAAsB;QAC7B,MAAM;QACN,MAAM;QACN,QAAQ;QACR,OAAO;QACP,GAAG,EAAE,KAAK;QACV,WAAW;QACX,MAAM;QACN,WAAW,EAAE,IAAI,EAAE,WAAW;QAC9B,cAAc,EAAE,IAAI,EAAE,cAAc;KACrC,CAAC;IACF,OAAO,QAAQ,CAAC,2BAA2B,EAAE,SAAS,EAAE,GAAG,EAAE,CAC3D,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE;QAC7B,cAAc,EAAE,IAAI,EAAE,cAAc;QACpC,UAAU,EAAE,IAAI,EAAE,UAAU;QAC5B,YAAY,EAAE,IAAI,EAAE,YAAY;KACjC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,9 @@ import type { StateDb } from "../state/db.js";
|
|
|
4
4
|
import type { GitHubClient } from "./github/github.js";
|
|
5
5
|
import type { ChatResult } from "./chat/chat.js";
|
|
6
6
|
import { type Route, type RouterDeps } from "./router.js";
|
|
7
|
+
import { type PrState } from "./pr-state.js";
|
|
8
|
+
import { type Decision, type FixDisposition, type PrPolicyConfig, type ReviewTriggerOptions } from "./pr-decisions.js";
|
|
9
|
+
import { type EscalationDeps } from "./pr-escalation.js";
|
|
7
10
|
/**
|
|
8
11
|
* Hand a workflow to the runner. Matches `dispatchWorkflow` in index.ts — the
|
|
9
12
|
* dispatcher names workflows and accumulates their outcome but owns none of the
|
|
@@ -29,9 +32,40 @@ export interface DispatchDeps {
|
|
|
29
32
|
sessionManager: SessionManager;
|
|
30
33
|
runChat: RunChatFn;
|
|
31
34
|
route?: (envelope: EventEnvelope, deps: RouterDeps) => Promise<Route>;
|
|
32
|
-
reviewPostsCheck: boolean;
|
|
33
35
|
publicUrl?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the target repo's `.lastlight/` POLICY layer for this dispatch.
|
|
38
|
+
*
|
|
39
|
+
* INJECTED rather than imported so the dispatcher keeps no edge to the runner
|
|
40
|
+
* (`resolveRepoRunConfig` lives in `workflows/simple.ts`, which drags the
|
|
41
|
+
* loader, the sandbox and the artifact store in with it). `main()` wires the
|
|
42
|
+
* very same call `dispatchWorkflow` makes one level down, so both gates read
|
|
43
|
+
* ONE config.
|
|
44
|
+
*
|
|
45
|
+
* Without it the dispatcher read the OPERATOR's values while `dispatchWorkflow`
|
|
46
|
+
* read the repo-clamped ones, and the webhook route always hands `_prState`
|
|
47
|
+
* down — so on EVERY webhook-originated PR dispatch a managed repo's clamped
|
|
48
|
+
* `fix.maxAttempts` / `fix.maxCostUsd` / `fix.retryableClasses` /
|
|
49
|
+
* `dependencies.requireSettledChecks` / `review.trigger` / `skipDraft` /
|
|
50
|
+
* `postsCheck` were silently not applied, while `renderContext` rendered them
|
|
51
|
+
* to the prompt and `lastlight repo config show` reported them. Only the cron
|
|
52
|
+
* sweep and `/api/run` honoured them.
|
|
53
|
+
*
|
|
54
|
+
* Cheap: `fetchRepoLayer` memoises per repo for 60 s, so this call and
|
|
55
|
+
* `dispatchWorkflow`'s are one conditional request per repo per minute
|
|
56
|
+
* between them, and this one usually warms the cache for that one.
|
|
57
|
+
*
|
|
58
|
+
* Omitted (chat-only wiring, tests) means "no repo layer" — the operator's
|
|
59
|
+
* config, which is what the layer clamps toward anyway.
|
|
60
|
+
*/
|
|
61
|
+
resolveRepoPolicy?: ResolveRepoPolicyFn;
|
|
34
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The three policy blocks a repo's `.lastlight/` layer may clamp, or undefined
|
|
65
|
+
* when no layer applies. Structurally the `RunRepoConfig` `resolveRepoRunConfig`
|
|
66
|
+
* returns, narrowed to what the gate reads.
|
|
67
|
+
*/
|
|
68
|
+
export type ResolveRepoPolicyFn = (workflowName: string, context: Record<string, unknown>) => Promise<Partial<PrPolicyConfig> | undefined>;
|
|
35
69
|
/**
|
|
36
70
|
* The typed result of dispatching one event. Handlers return an outcome rather
|
|
37
71
|
* than only producing side effects, so each branch is assertable through the
|
|
@@ -70,6 +104,69 @@ export type DispatchOutcome = {
|
|
|
70
104
|
* former `registry.onEvent` closure so every event branch is testable.
|
|
71
105
|
*/
|
|
72
106
|
export declare function dispatch(envelope: EventEnvelope, deps: DispatchDeps): Promise<DispatchOutcome>;
|
|
107
|
+
/**
|
|
108
|
+
* The three policy blocks the dispatch gate reads — the operator's config with
|
|
109
|
+
* the target repo's `.lastlight/` layer folded in.
|
|
110
|
+
*
|
|
111
|
+
* ONE config, one decision, every route. This used to be operator-only in the
|
|
112
|
+
* dispatcher and repo-clamped in `dispatchWorkflow`, which failed silently and
|
|
113
|
+
* asymmetrically: the gate used one number while `renderContext` rendered
|
|
114
|
+
* another to the prompt and `lastlight repo config show` reported the same one
|
|
115
|
+
* the prompt got. The repo layer may only ever clamp TIGHTER (add-only, see
|
|
116
|
+
* `packages/shared/src/repo-config-schema.ts`), so the old seam always erred by
|
|
117
|
+
* letting a run through the repo would have refused — which is exactly the
|
|
118
|
+
* direction a budget cap must not err in.
|
|
119
|
+
*
|
|
120
|
+
* `layer` comes from {@link DispatchDeps.resolveRepoPolicy}, which is the same
|
|
121
|
+
* `resolveRepoRunConfig` call `dispatchWorkflow` makes; the `?? operator`
|
|
122
|
+
* fallbacks mirror its `repoConfig?.fix ?? config.fix` exactly.
|
|
123
|
+
*/
|
|
124
|
+
export declare function prPolicyConfig(layer?: Partial<PrPolicyConfig>): PrPolicyConfig;
|
|
125
|
+
/** Everything {@link applyPrDispatchGate} needs to act on its own verdict. */
|
|
126
|
+
export interface PrGateDeps extends EscalationDeps {
|
|
127
|
+
/** `<botName>[bot]`. Defaults to the boot config's. */
|
|
128
|
+
botLogin?: string;
|
|
129
|
+
/** `@<botName>`, for the `on-request` placeholder's instructions. */
|
|
130
|
+
botMention?: string;
|
|
131
|
+
}
|
|
132
|
+
/** What {@link applyPrDispatchGate} was asked to decide. */
|
|
133
|
+
export interface PrGateArgs {
|
|
134
|
+
workflowName: string;
|
|
135
|
+
state: PrState;
|
|
136
|
+
/** Already repo-clamped — see {@link prPolicyConfig}. */
|
|
137
|
+
policy: PrPolicyConfig;
|
|
138
|
+
explicitRequest?: boolean;
|
|
139
|
+
route: NonNullable<ReviewTriggerOptions["route"]>;
|
|
140
|
+
/** `[event]` (webhook/comment) or `[dispatch]` (cron, `/api/run`). */
|
|
141
|
+
logPrefix: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* THE dispatch gate — decide, log, and apply the decision's own consequences.
|
|
145
|
+
*
|
|
146
|
+
* Both routes call this one function: the dispatcher for webhook/comment
|
|
147
|
+
* events, and `dispatchWorkflow` for the cron fan-out, `/api/run` and resume.
|
|
148
|
+
* They used to carry two hand-kept-in-step copies of it, reading two different
|
|
149
|
+
* configs (see {@link prPolicyConfig}) and diverging on which side effects a
|
|
150
|
+
* skip earns.
|
|
151
|
+
*
|
|
152
|
+
* The two consequences that belong to the DECISION rather than to the route are
|
|
153
|
+
* applied here, so neither can be forgotten by one caller:
|
|
154
|
+
*
|
|
155
|
+
* - a **deferred review** leaves the placeholder check that says "not yet"
|
|
156
|
+
* (itself route-limited inside `postReviewCheckForSkip` — a statement about a
|
|
157
|
+
* head SHA belongs on PR attention, not on every sweep tick);
|
|
158
|
+
* - a skip that is **terminal for this problem** is labelled and explained, and
|
|
159
|
+
* RECORDS A RUN ROW without which `escalatedAtSha` never persists and the next
|
|
160
|
+
* dispatch reads our own label as a human's permanent hold (09 → D1).
|
|
161
|
+
*
|
|
162
|
+
* What is NOT applied here is the route's own courtesy: replying to the human
|
|
163
|
+
* whose request was dropped, and the fork-PR notice. Both are answers to a
|
|
164
|
+
* person who is watching, so they belong to the route that has one — a daily
|
|
165
|
+
* cron re-posting a fork notice for the life of the PR is spam, not
|
|
166
|
+
* transparency. The caller keys them on the TYPED fields the deciding branch
|
|
167
|
+
* set (`decision.runInFlight`, `state.isFork`), never on the reason prose.
|
|
168
|
+
*/
|
|
169
|
+
export declare function applyPrDispatchGate(args: PrGateArgs, deps: PrGateDeps): Promise<Decision<FixDisposition>>;
|
|
73
170
|
/**
|
|
74
171
|
* Run one chat turn end-to-end: record the execution, run the model, persist a
|
|
75
172
|
* freshly-minted agent session id for resume, and post the reply (apologizing
|