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,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two files the harness owns inside a PR checkout — the fix loop's push
|
|
3
|
+
* gate and the PR journal — and the one argument that places both.
|
|
4
|
+
*
|
|
5
|
+
* ## They live under `.git/`, and that is the guarantee
|
|
6
|
+
*
|
|
7
|
+
* `.git/` is the repository, not the work tree. No pathspec walk enters it, so
|
|
8
|
+
* `git add -A`, `git add .` and `git commit -a` cannot see either file — on
|
|
9
|
+
* every backend, in every `buildAssets` mode, with nothing to register
|
|
10
|
+
* anywhere. That last clause is the point.
|
|
11
|
+
*
|
|
12
|
+
* Both files used to sit at the ROOT OF THE CHECKOUT and stay out of the pull
|
|
13
|
+
* request because each backend added them to the checkout's local
|
|
14
|
+
* `.git/info/exclude`. The kubernetes backend never got that code, so on k8s
|
|
15
|
+
* the harness's own scratch files were committed into the dependency PR by the
|
|
16
|
+
* agent's `git add -A` (issue #256). A guarantee that every new backend has to
|
|
17
|
+
* re-implement is not a guarantee; a path git structurally cannot reach is.
|
|
18
|
+
* The failure mode of a backend forgetting is now a STALE GATE, which is
|
|
19
|
+
* recoverable and locally visible, rather than a COMMITTED FILE, which is
|
|
20
|
+
* neither.
|
|
21
|
+
*
|
|
22
|
+
* ## Why not a sibling of the checkout
|
|
23
|
+
*
|
|
24
|
+
* gondolin is the packaged default (`sandbox.backend: gondolin`) and mounts
|
|
25
|
+
* only cwd, so a workspace-root sibling reached via `../` is unreachable inside
|
|
26
|
+
* the guest — the gate would silently never run and the journal would silently
|
|
27
|
+
* never be written on the default backend. `.git/` is inside cwd, so it is
|
|
28
|
+
* reachable there. (This is also why `artifactIssueDir`'s relocation could not
|
|
29
|
+
* be reused: it is conditional on `buildAssets === "server"` AND a non-gondolin
|
|
30
|
+
* backend, and these two must be placed correctly everywhere.)
|
|
31
|
+
*
|
|
32
|
+
* ## Why one uniform path
|
|
33
|
+
*
|
|
34
|
+
* The prompts state a bare relative path with the agent's cwd already the
|
|
35
|
+
* checkout, and the harness resolves the same path from the run row. Neither
|
|
36
|
+
* has to know the backend. It also keeps `generic_loop.until_bash` a LITERAL
|
|
37
|
+
* string, which the engine's `validateShellCommand` requires — it rejects any
|
|
38
|
+
* command containing `{{`, so the gate path cannot be templated per backend.
|
|
39
|
+
* `tests/workflows/pr-fix.test.ts` pins the YAML literal to
|
|
40
|
+
* {@link VERIFY_SCRIPT_NAME} so the two cannot drift.
|
|
41
|
+
*
|
|
42
|
+
* ## What still has to happen per run
|
|
43
|
+
*
|
|
44
|
+
* `git clean -fdx` does not enter `.git/` either, so the explicit deletes in
|
|
45
|
+
* `./executors/shared.ts` (`resetVerifyScript`, `resetPrNotesJournal`) are the
|
|
46
|
+
* ONLY thing that clears a file an earlier attempt left behind. On the
|
|
47
|
+
* kubernetes backend the harness has no filesystem access to the PVC, so the
|
|
48
|
+
* clone init container does it instead (`../sandbox/k8s/init-clone.ts`).
|
|
49
|
+
*
|
|
50
|
+
* Pure: two strings and no I/O, so the pure decision modules
|
|
51
|
+
* (`./pr-decisions.ts`, `./pr-notes.ts`) can project them onto the prompt
|
|
52
|
+
* context without importing the executor layer.
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* The within-run push gate (04-retry.md §4.5, 09-state-machine.md §S1).
|
|
56
|
+
*
|
|
57
|
+
* The right gate command is not statically knowable — the package manager comes
|
|
58
|
+
* from the lockfile and the commands from the repo's own CI workflow — so
|
|
59
|
+
* `skills/fixing/SKILL.md` has the agent write it here, and the fix loop runs
|
|
60
|
+
* it through `generic_loop.until_bash`; exit 0 ends the loop.
|
|
61
|
+
*
|
|
62
|
+
* A STALE gate is worse than no gate: it passes green against the wrong
|
|
63
|
+
* commands and authorises a push. That is what `resetVerifyScript` exists for,
|
|
64
|
+
* and it matters because the fix FAMILY shares ONE workspace per PR (§S4) — a
|
|
65
|
+
* gate written by a superseded diagnosis, possibly by the *other* fix workflow,
|
|
66
|
+
* outlives the run that wrote it.
|
|
67
|
+
*/
|
|
68
|
+
export const VERIFY_SCRIPT_NAME = ".git/lastlight-verify.sh";
|
|
69
|
+
/**
|
|
70
|
+
* The PR journal — the agent's outbox for `PrState.notes` (10-pr-memory.md).
|
|
71
|
+
*
|
|
72
|
+
* Drained into the run's scratch at the end of every phase (`./fix-harvest.ts`
|
|
73
|
+
* → `drainPrNotes`), so its durable home is the snapshot; the file itself is a
|
|
74
|
+
* per-phase outbox, never an accumulator.
|
|
75
|
+
*/
|
|
76
|
+
export const PR_NOTES_FILE_NAME = ".git/lastlight-notes";
|
|
77
|
+
//# sourceMappingURL=fix-scratch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-scratch.js","sourceRoot":"","sources":["../../src/engine/fix-scratch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC"}
|
|
@@ -2,6 +2,154 @@ import { type GitHubAppClientConfig } from "./github-app-client.js";
|
|
|
2
2
|
import type { InlineComment, ReviewEvent } from "./review-poster.js";
|
|
3
3
|
/** GitHub reaction emoji values accepted by the reactions API. */
|
|
4
4
|
export type ReactionContent = "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes";
|
|
5
|
+
/**
|
|
6
|
+
* One file fetched out of a repo's `.lastlight/` subtree.
|
|
7
|
+
*
|
|
8
|
+
* `path` is relative to `.lastlight/` itself (`lastlight.yml`,
|
|
9
|
+
* `workflows/prompts/plan.md`, …) so the result drops straight onto disk in the
|
|
10
|
+
* same shape as a deployment overlay. `mode` is the raw git filemode from the
|
|
11
|
+
* tree entry — kept verbatim so the consumer can reject symlinks (`120000`)
|
|
12
|
+
* without a second round-trip.
|
|
13
|
+
*/
|
|
14
|
+
export interface RepoConfigFile {
|
|
15
|
+
path: string;
|
|
16
|
+
mode: string;
|
|
17
|
+
size: number;
|
|
18
|
+
content: Buffer;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of {@link GitHubClient.fetchRepoConfigTree}. Three outcomes, none of
|
|
22
|
+
* them exceptional:
|
|
23
|
+
* - `absent` — the repo has no `.lastlight/` (the common case; cheap).
|
|
24
|
+
* - `not-modified` — the caller's `etag`/`treeSha` still matches, so nothing
|
|
25
|
+
* was downloaded and the caller's cached copy stands.
|
|
26
|
+
* - `ok` — the subtree, fully materialized.
|
|
27
|
+
*
|
|
28
|
+
* `defaultBranch` is always reported because it IS the trust boundary: the
|
|
29
|
+
* subtree only ever comes from there.
|
|
30
|
+
*/
|
|
31
|
+
export type RepoConfigTreeResult = {
|
|
32
|
+
status: "absent";
|
|
33
|
+
defaultBranch: string;
|
|
34
|
+
} | {
|
|
35
|
+
status: "not-modified";
|
|
36
|
+
defaultBranch: string;
|
|
37
|
+
treeSha: string;
|
|
38
|
+
etag?: string;
|
|
39
|
+
} | {
|
|
40
|
+
status: "ok";
|
|
41
|
+
defaultBranch: string;
|
|
42
|
+
treeSha: string;
|
|
43
|
+
etag?: string;
|
|
44
|
+
files: RepoConfigFile[];
|
|
45
|
+
/** GitHub truncated the subtree listing — treat the result as incomplete. */
|
|
46
|
+
truncated: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** Options for {@link GitHubClient.fetchRepoConfigTree}. */
|
|
49
|
+
export interface RepoConfigTreeOptions {
|
|
50
|
+
/** ETag of the root-tree read from the previous fetch — enables a 304. */
|
|
51
|
+
etag?: string;
|
|
52
|
+
/** `.lastlight/` tree SHA from the previous fetch — a content-exact conditional. */
|
|
53
|
+
treeSha?: string;
|
|
54
|
+
/** Hard cap on files materialized (default 200). Extra entries are skipped. */
|
|
55
|
+
maxFiles?: number;
|
|
56
|
+
/** Hard cap on total bytes downloaded (default 2 MiB). Oversized entries are skipped. */
|
|
57
|
+
maxBytes?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Blob filter applied BEFORE downloading, on the path relative to
|
|
60
|
+
* `.lastlight/`. Matters because `.lastlight/` is shared real estate: in
|
|
61
|
+
* `buildAssets.location: repo` mode the build workflow commits its handoff
|
|
62
|
+
* docs to `.lastlight/<issueKey>/*.md` there too. Without a filter those docs
|
|
63
|
+
* would eat the byte budget and crowd out the config layer.
|
|
64
|
+
*/
|
|
65
|
+
includePath?: (path: string) => boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One failed check run, resolved as far as the App's permissions allow.
|
|
69
|
+
*
|
|
70
|
+
* The optional fields are exactly the ones that need `Actions: read`. They are
|
|
71
|
+
* the difference between "CI is red" and "CI is red *here*, in *this* step of
|
|
72
|
+
* *this* workflow file" — `workflowPath` is what lets a fix agent open the CI
|
|
73
|
+
* definition in its checkout and compare CI's toolchain against the sandbox's.
|
|
74
|
+
*/
|
|
75
|
+
export interface CiJobFailure {
|
|
76
|
+
/** Check-run name, e.g. `CI / build (22)`. */
|
|
77
|
+
name: string;
|
|
78
|
+
/** `failure` | `timed_out` — the conclusions {@link GitHubClient.getChecksConclusion} calls red. */
|
|
79
|
+
conclusion: string;
|
|
80
|
+
/** e.g. `.github/workflows/ci.yml`. Undefined for non-Actions checks or when Actions is unreadable. */
|
|
81
|
+
workflowPath?: string;
|
|
82
|
+
/** Name of the step that failed, from the job's `steps[]`. Same availability as `workflowPath`. */
|
|
83
|
+
failingStep?: string;
|
|
84
|
+
/** {@link extractErrorExcerpt} over the real job log, or the annotation fallback. */
|
|
85
|
+
logExcerpt: string;
|
|
86
|
+
/** The check run's `details_url` — where an agent can dig further via `github_get_job_logs`. */
|
|
87
|
+
jobUrl?: string;
|
|
88
|
+
/** True only when `logExcerpt` came from the REAL Actions job log. */
|
|
89
|
+
logsAvailable: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* WHY the real log is missing, when it is. Set only for an Actions job we
|
|
92
|
+
* actually tried to read — see {@link CiLogUnavailableCause}.
|
|
93
|
+
*/
|
|
94
|
+
logUnavailableCause?: CiLogUnavailableCause;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Why an Actions job log could not be used as evidence.
|
|
98
|
+
*
|
|
99
|
+
* Every one of these used to collapse into a single `.catch(() => null)`, and
|
|
100
|
+
* the banner then asserted the one cause we had never checked ("the App lacks
|
|
101
|
+
* `Actions: read`"). Telling an operator to grant a permission they already
|
|
102
|
+
* granted is a smaller version of exactly the damage issue #251's Finding 1 was
|
|
103
|
+
* about: a degradation that reads as normal operation. So the cause is
|
|
104
|
+
* CLASSIFIED at the point of failure and rendered verbatim.
|
|
105
|
+
*
|
|
106
|
+
* - `forbidden` — HTTP 403. The genuine missing-permission case, and the
|
|
107
|
+
* only one where "grant Actions: read" is the fix. App-wide,
|
|
108
|
+
* so one job saying it settles it for the whole report.
|
|
109
|
+
* - `expired` — HTTP 410 Gone. Actions retains logs for a bounded window;
|
|
110
|
+
* on an older PR this is the COMMON case, and there is
|
|
111
|
+
* nothing to grant.
|
|
112
|
+
* - `unavailable` — anything else: 429/secondary rate limit, 5xx, the report
|
|
113
|
+
* deadline firing, or a body we could not decode. Transient.
|
|
114
|
+
* - `empty` — the download succeeded and carried nothing usable. Not a
|
|
115
|
+
* fetch problem at all.
|
|
116
|
+
*/
|
|
117
|
+
export type CiLogUnavailableCause = "forbidden" | "expired" | "unavailable" | "empty";
|
|
118
|
+
/** Structured result of {@link GitHubClient.getCiFailureReport}. */
|
|
119
|
+
export interface CiFailureReport {
|
|
120
|
+
jobs: CiJobFailure[];
|
|
121
|
+
/** False when NO job could supply a real log — everything below is annotations. */
|
|
122
|
+
logsAvailable: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The cause the banner speaks with when `logsAvailable` is false — the most
|
|
125
|
+
* actionable one across the jobs (see {@link dominantLogUnavailableCause}).
|
|
126
|
+
* Undefined when logs were available or when no Actions job was even tried.
|
|
127
|
+
*/
|
|
128
|
+
logUnavailableCause?: CiLogUnavailableCause;
|
|
129
|
+
}
|
|
130
|
+
/** Options shared by the three settle-aware check queries. */
|
|
131
|
+
export interface ChecksQueryOptions {
|
|
132
|
+
/**
|
|
133
|
+
* Drop check runs produced by this GitHub App slug — in practice always our
|
|
134
|
+
* own `botName`.
|
|
135
|
+
*
|
|
136
|
+
* **This is the self-gating deadlock fix** (07-review-triggers.md §7.2). The
|
|
137
|
+
* aggregate is computed over *every* check run on the head SHA, ours
|
|
138
|
+
* included, so a `last-light/review` check sitting `queued` (waiting for CI,
|
|
139
|
+
* under `review.trigger: after-checks`) or `in_progress` (a review actually
|
|
140
|
+
* running) makes the aggregate permanently `pending`. The settle event then
|
|
141
|
+
* never fires, the review never runs, the check never concludes — and if the
|
|
142
|
+
* repo made it a *required* check, the PR is unmergeable forever. The same
|
|
143
|
+
* loop reaches `pr.checks_passed` on a Dependabot PR whose review check is
|
|
144
|
+
* still open, so the rule is uniform: **exclude our own checks from every
|
|
145
|
+
* TRIGGER-side settle computation**, and let GitHub's required-check gate do
|
|
146
|
+
* the real merge gating.
|
|
147
|
+
*
|
|
148
|
+
* It is deliberately opt-in rather than always-on: a caller reporting check
|
|
149
|
+
* state to a *human* (or to the merge prompt) should show what GitHub shows.
|
|
150
|
+
*/
|
|
151
|
+
excludeApp?: string;
|
|
152
|
+
}
|
|
5
153
|
/**
|
|
6
154
|
* GitHub client for the harness — uses GitHub App auth.
|
|
7
155
|
* Used by the orchestrator to post comments, not by agent sessions.
|
|
@@ -25,6 +173,24 @@ export declare class GitHubClient {
|
|
|
25
173
|
* just post a one-off comment can ignore the return.
|
|
26
174
|
*/
|
|
27
175
|
postComment(owner: string, repo: string, issueNumber: number, body: string): Promise<number>;
|
|
176
|
+
/**
|
|
177
|
+
* Add labels to an issue/PR, leaving existing labels alone.
|
|
178
|
+
*
|
|
179
|
+
* The only harness-side label WRITE. Every other label mutation in the system
|
|
180
|
+
* happens INSIDE the sandbox, through agentic-pi's `github_*` tools driven
|
|
181
|
+
* from a prompt — which is the right place for a label whose value is an
|
|
182
|
+
* agent's judgement (`dependency-trivial`, the triage vocabulary). This one
|
|
183
|
+
* is different in kind: the dispatch-time escalation
|
|
184
|
+
* (`../pr-escalation.ts`) fires precisely when we have decided NOT to
|
|
185
|
+
* provision a sandbox, so there is no agent to ask.
|
|
186
|
+
*
|
|
187
|
+
* GitHub's own endpoint creates a label that does not exist yet (with an
|
|
188
|
+
* arbitrary colour), so there is no `ensureLabels` companion to write.
|
|
189
|
+
* Idempotent by construction — re-adding a present label is a no-op — but
|
|
190
|
+
* that is NOT what makes the escalation post one comment; see
|
|
191
|
+
* `../pr-escalation.ts` for the record that does.
|
|
192
|
+
*/
|
|
193
|
+
addLabels(owner: string, repo: string, issueNumber: number, labels: string[]): Promise<void>;
|
|
28
194
|
/**
|
|
29
195
|
* List every repository the App installation can access, as `owner/repo`
|
|
30
196
|
* full names. Used at boot to seed the managed-repo list from the App grant
|
|
@@ -1145,6 +1311,34 @@ export declare class GitHubClient {
|
|
|
1145
1311
|
* reviewer runs. See the `baseBranch` plumbing in src/index.ts.
|
|
1146
1312
|
*/
|
|
1147
1313
|
getDefaultBranch(owner: string, repo: string): Promise<string>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Fetch a repo's committed `.lastlight/` subtree — its per-repo configuration
|
|
1316
|
+
* layer (issue #180) — from the repo's **default branch**.
|
|
1317
|
+
*
|
|
1318
|
+
* SECURITY — the default branch is the entire trust model here. This subtree
|
|
1319
|
+
* can re-point models, disable workflows and add approval gates for every run
|
|
1320
|
+
* against the repo, so it must only ever be read from a ref that already
|
|
1321
|
+
* passed the repo's own review/branch-protection. It is resolved live from the
|
|
1322
|
+
* repo metadata on every call (never assumed to be `main`), and NEVER read
|
|
1323
|
+
* from a PR head or from the sandbox checkout — otherwise a pull request could
|
|
1324
|
+
* rewrite the configuration of the agent reviewing it.
|
|
1325
|
+
*
|
|
1326
|
+
* Cheap by design, because a cron fanning out over N repos calls this N times:
|
|
1327
|
+
* - `options.etag` (the previous call's root-tree ETag) short-circuits an
|
|
1328
|
+
* untouched repo at a conditional 304 — 2 requests, no downloads.
|
|
1329
|
+
* - `options.treeSha` (the previous `.lastlight/` tree SHA) short-circuits a
|
|
1330
|
+
* repo that has committed elsewhere since. A git tree SHA is the content
|
|
1331
|
+
* hash of the whole subtree, so equality means byte-identical.
|
|
1332
|
+
* - a repo with no `.lastlight/` returns `{ status: "absent" }` — the common
|
|
1333
|
+
* case is a normal negative result, not an exception.
|
|
1334
|
+
* Only when both conditionals miss does it download blobs, bounded by
|
|
1335
|
+
* `maxFiles` / `maxBytes` so a hostile repo can't make the harness pull an
|
|
1336
|
+
* unbounded tree.
|
|
1337
|
+
*
|
|
1338
|
+
* Lives on the client (rather than raw octokit at the call site) because the
|
|
1339
|
+
* evals harness swaps this whole seam for fixtures.
|
|
1340
|
+
*/
|
|
1341
|
+
fetchRepoConfigTree(owner: string, repo: string, options?: RepoConfigTreeOptions): Promise<RepoConfigTreeResult>;
|
|
1148
1342
|
/** Convenience: fetch only the PR's head commit SHA. Used by check-run code. */
|
|
1149
1343
|
getPullRequestHeadSha(owner: string, repo: string, pullNumber: number): Promise<string>;
|
|
1150
1344
|
/**
|
|
@@ -1154,8 +1348,16 @@ export declare class GitHubClient {
|
|
|
1154
1348
|
* `name` in their list will gate merges on the eventual conclusion.
|
|
1155
1349
|
*
|
|
1156
1350
|
* Requires the GitHub App to have `Checks: Read and write` permission.
|
|
1351
|
+
*
|
|
1352
|
+
* `status` defaults to `in_progress` (the historical behaviour). The other
|
|
1353
|
+
* two exist for the review PLACEHOLDERS: `queued` says "waiting for CI"
|
|
1354
|
+
* under `review.trigger: after-checks`, and `completed` + `conclusion:
|
|
1355
|
+
* neutral` says "available on request" under `on-request` — see
|
|
1356
|
+
* `reviewCheckPlacement` in ../pr-decisions.ts.
|
|
1157
1357
|
*/
|
|
1158
1358
|
createCheckRun(owner: string, repo: string, headSha: string, name: string, options?: {
|
|
1359
|
+
status?: "queued" | "in_progress" | "completed";
|
|
1360
|
+
conclusion?: "success" | "failure" | "neutral" | "cancelled" | "timed_out" | "action_required" | "skipped";
|
|
1159
1361
|
detailsUrl?: string;
|
|
1160
1362
|
output?: {
|
|
1161
1363
|
title: string;
|
|
@@ -1233,12 +1435,86 @@ export declare class GitHubClient {
|
|
|
1233
1435
|
* discovery and the fix prompt agree on what "red" means.
|
|
1234
1436
|
* "passing" — there ARE checks/statuses and none are failing or pending.
|
|
1235
1437
|
*/
|
|
1236
|
-
getChecksConclusion(owner: string, repo: string, ref: string): Promise<"passing" | "failing" | "pending" | "none">;
|
|
1438
|
+
getChecksConclusion(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<"passing" | "failing" | "pending" | "none">;
|
|
1439
|
+
/**
|
|
1440
|
+
* {@link getChecksConclusion} plus the COUNT of checks behind the verdict, in
|
|
1441
|
+
* the same two API calls.
|
|
1442
|
+
*
|
|
1443
|
+
* `settledCount` exists because "passing" alone is not evidence of anything:
|
|
1444
|
+
* on a repo with no CI at all, `getChecksConclusion` returns `"none"` and a
|
|
1445
|
+
* repo with one trivial check returns `"passing"` — and the auto-merge
|
|
1446
|
+
* decision needs to tell "CI approved this" from "nothing looked at it"
|
|
1447
|
+
* (`dependencies.minSettledChecks`; see `mayMerge` in ../pr-decisions.ts and
|
|
1448
|
+
* 09-state-machine.md → D10). Deriving it in the client rather than at the
|
|
1449
|
+
* call site keeps it to ONE round trip: recomputing the count from a second
|
|
1450
|
+
* `listForRef` would double the cost of every PR-state resolution.
|
|
1451
|
+
*
|
|
1452
|
+
* A check run counts as settled when it has left queued/in_progress —
|
|
1453
|
+
* whatever it concluded. Status contexts are settled unless the combined
|
|
1454
|
+
* state is `pending`.
|
|
1455
|
+
*/
|
|
1456
|
+
getChecksSummary(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<{
|
|
1457
|
+
state: "passing" | "failing" | "pending" | "none";
|
|
1458
|
+
settledCount: number;
|
|
1459
|
+
pendingCount: number;
|
|
1460
|
+
}>;
|
|
1461
|
+
/**
|
|
1462
|
+
* The git AUTHOR NAME on a commit — not a GitHub login.
|
|
1463
|
+
*
|
|
1464
|
+
* This is the discriminator the fix state machine uses to answer "did WE push
|
|
1465
|
+
* this head, or did the world move?" (09-state-machine.md → S1, the attempt
|
|
1466
|
+
* table). It has to be the git author name because that is what
|
|
1467
|
+
* `git-auth.ts` stamps on the agent's own commits (`user.name = botLogin`),
|
|
1468
|
+
* and it is the same field `check_suite.head_commit.author.name` carries on
|
|
1469
|
+
* the webhook path — so the webhook and the cron agree by construction.
|
|
1470
|
+
*
|
|
1471
|
+
* Returns `""` when GitHub reports no author name, so callers get a value
|
|
1472
|
+
* that simply never equals `botLogin` rather than a null to branch on.
|
|
1473
|
+
*/
|
|
1474
|
+
getCommitAuthorName(owner: string, repo: string, ref: string): Promise<string>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Check state of a PR's BASE branch head — a branch name is a valid `ref` for
|
|
1477
|
+
* the checks API, so this is {@link getChecksConclusion} pointed at the base
|
|
1478
|
+
* tip.
|
|
1479
|
+
*
|
|
1480
|
+
* It has its own name because the *question* is different: "is the PR at
|
|
1481
|
+
* fault, or was `main` already red?". A red base makes retrying the PR
|
|
1482
|
+
* pointless, and call sites asking that shouldn't have to know it's the same
|
|
1483
|
+
* query as "is this PR red".
|
|
1484
|
+
*/
|
|
1485
|
+
getBaseChecksState(owner: string, repo: string, baseRef: string, opts?: ChecksQueryOptions): Promise<"passing" | "failing" | "pending" | "none">;
|
|
1486
|
+
/**
|
|
1487
|
+
* Structured CI failure evidence for a ref — the HEAVY counterpart to
|
|
1488
|
+
* {@link getChecksConclusion}: one Actions job-log download per failed check
|
|
1489
|
+
* run, plus the job and workflow-run metadata that says *where* it failed.
|
|
1490
|
+
*
|
|
1491
|
+
* Every Actions read here needs the App's optional `Actions: read`
|
|
1492
|
+
* permission. None of them is required: each degrades independently to
|
|
1493
|
+
* `undefined` / the annotation fallback, and the per-job + report-level
|
|
1494
|
+
* `logsAvailable` flags are what let the renderer say so out loud instead of
|
|
1495
|
+
* passing annotations off as job logs (issue #251).
|
|
1496
|
+
*
|
|
1497
|
+
* Throws if the check-run listing itself fails — a report cannot represent
|
|
1498
|
+
* "I couldn't look". {@link getFailedChecks} catches that for prompt callers.
|
|
1499
|
+
*
|
|
1500
|
+
* **Bounded on purpose.** `resolvePrState` awaits this synchronously on the
|
|
1501
|
+
* dispatch path a webhook handler takes, BEFORE any disposition is taken — so
|
|
1502
|
+
* it is paid in full even on dispatches that go on to skip as
|
|
1503
|
+
* `already-reviewed` / `human-hold` / `run-in-flight`. `checks.listForRef`
|
|
1504
|
+
* returns up to 30 runs, and the first cut of this method downloaded every
|
|
1505
|
+
* failed one's FULL log concurrently, uncapped and with no deadline: thirty
|
|
1506
|
+
* multi-megabyte strings resident at once, on a host with a 2 GB agent cap and
|
|
1507
|
+
* no swap. Hence {@link CI_LOG_FETCH_CONCURRENCY},
|
|
1508
|
+
* {@link CI_REPORT_DEADLINE_MS} and the byte cap inside
|
|
1509
|
+
* {@link extractErrorExcerpt}.
|
|
1510
|
+
*/
|
|
1511
|
+
getCiFailureReport(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<CiFailureReport>;
|
|
1237
1512
|
/**
|
|
1238
|
-
* Get failed check runs for a PR's head SHA
|
|
1239
|
-
*
|
|
1513
|
+
* Get failed check runs for a PR's head SHA as the markdown blob
|
|
1514
|
+
* `{{ciSection}}` has always carried — a thin renderer over
|
|
1515
|
+
* {@link getCiFailureReport}, kept so prompt-only callers are unchanged.
|
|
1240
1516
|
*/
|
|
1241
|
-
getFailedChecks(owner: string, repo: string, ref: string): Promise<string>;
|
|
1517
|
+
getFailedChecks(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<string>;
|
|
1242
1518
|
}
|
|
1243
1519
|
/**
|
|
1244
1520
|
* Parse the Actions job id from a check-run's `details_url`.
|
|
@@ -1246,9 +1522,30 @@ export declare class GitHubClient {
|
|
|
1246
1522
|
* Returns `null` for non-Actions checks or unparseable URLs.
|
|
1247
1523
|
*/
|
|
1248
1524
|
export declare function actionsJobIdFromDetailsUrl(url: string | null | undefined): number | null;
|
|
1525
|
+
/**
|
|
1526
|
+
* Parse the Actions *run* id out of the same `details_url`. The run — not the
|
|
1527
|
+
* job — is what knows the workflow file's `path`, and the URL already carries
|
|
1528
|
+
* it, so resolving `workflowPath` costs no extra lookup to discover the id.
|
|
1529
|
+
* Returns `null` for non-Actions checks or unparseable URLs.
|
|
1530
|
+
*/
|
|
1531
|
+
export declare function actionsRunIdFromDetailsUrl(url: string | null | undefined): number | null;
|
|
1532
|
+
/**
|
|
1533
|
+
* Render a {@link CiFailureReport} as the markdown `{{ciSection}}` carries.
|
|
1534
|
+
*
|
|
1535
|
+
* The "No failed checks found." sentinel is load-bearing: `dispatchWorkflow`
|
|
1536
|
+
* tests the rendered string for `"No failed checks"` to decide whether to
|
|
1537
|
+
* populate `ciSection` at all.
|
|
1538
|
+
*/
|
|
1539
|
+
export declare function renderCiFailureReport(report: CiFailureReport): string;
|
|
1249
1540
|
/**
|
|
1250
1541
|
* Given the full text of an Actions job log, return a compact excerpt
|
|
1251
1542
|
* highlighting the real error lines with surrounding context.
|
|
1252
1543
|
* Timestamps are stripped; pure noise lines are deprioritised.
|
|
1544
|
+
*
|
|
1545
|
+
* Bounded in BYTES as well as lines ({@link MAX_CI_LOG_EXCERPT_BYTES}), because
|
|
1546
|
+
* the line bounds below are no bound at all on a log whose failure is one
|
|
1547
|
+
* 8 MB minified line — and this excerpt is held on `PrState.ciReport` and
|
|
1548
|
+
* rendered into a prompt. The cap is applied here rather than at the call site
|
|
1549
|
+
* so every caller is bounded by construction.
|
|
1253
1550
|
*/
|
|
1254
|
-
export declare function extractErrorExcerpt(fullLog: string): string;
|
|
1551
|
+
export declare function extractErrorExcerpt(fullLog: string, maxBytes?: number): string;
|