lastlight-core 0.21.14 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/config/default.yaml +119 -1
  2. package/dist/admin/routes.js +195 -38
  3. package/dist/admin/routes.js.map +1 -1
  4. package/dist/config/config-resolve.d.ts +38 -1
  5. package/dist/config/config-resolve.js +41 -17
  6. package/dist/config/config-resolve.js.map +1 -1
  7. package/dist/config/config.d.ts +114 -0
  8. package/dist/config/config.js +225 -7
  9. package/dist/config/config.js.map +1 -1
  10. package/dist/config/repo-config.d.ts +120 -0
  11. package/dist/config/repo-config.js +447 -0
  12. package/dist/config/repo-config.js.map +1 -0
  13. package/dist/connectors/github-webhook.d.ts +17 -0
  14. package/dist/connectors/github-webhook.js +150 -17
  15. package/dist/connectors/github-webhook.js.map +1 -1
  16. package/dist/connectors/types.d.ts +48 -1
  17. package/dist/cron/dependabot-discovery.d.ts +68 -11
  18. package/dist/cron/dependabot-discovery.js +78 -20
  19. package/dist/cron/dependabot-discovery.js.map +1 -1
  20. package/dist/cron/fanout.d.ts +10 -0
  21. package/dist/cron/fanout.js +35 -2
  22. package/dist/cron/fanout.js.map +1 -1
  23. package/dist/cron/jobs.d.ts +16 -2
  24. package/dist/cron/jobs.js +69 -9
  25. package/dist/cron/jobs.js.map +1 -1
  26. package/dist/cron/repo-crons.d.ts +110 -0
  27. package/dist/cron/repo-crons.js +169 -0
  28. package/dist/cron/repo-crons.js.map +1 -0
  29. package/dist/cron/review-discovery.d.ts +33 -20
  30. package/dist/cron/review-discovery.js +23 -30
  31. package/dist/cron/review-discovery.js.map +1 -1
  32. package/dist/engine/agent-executor.d.ts +1 -1
  33. package/dist/engine/agent-executor.js +1 -1
  34. package/dist/engine/agent-executor.js.map +1 -1
  35. package/dist/engine/dispatcher.d.ts +98 -1
  36. package/dist/engine/dispatcher.js +248 -231
  37. package/dist/engine/dispatcher.js.map +1 -1
  38. package/dist/engine/executors/orchestrator.js +39 -15
  39. package/dist/engine/executors/orchestrator.js.map +1 -1
  40. package/dist/engine/executors/shared.d.ts +43 -0
  41. package/dist/engine/executors/shared.js +65 -0
  42. package/dist/engine/executors/shared.js.map +1 -1
  43. package/dist/engine/fix-harvest.d.ts +169 -0
  44. package/dist/engine/fix-harvest.js +345 -0
  45. package/dist/engine/fix-harvest.js.map +1 -0
  46. package/dist/engine/fix-markers.d.ts +184 -0
  47. package/dist/engine/fix-markers.js +329 -0
  48. package/dist/engine/fix-markers.js.map +1 -0
  49. package/dist/engine/fix-scratch.d.ts +76 -0
  50. package/dist/engine/fix-scratch.js +77 -0
  51. package/dist/engine/fix-scratch.js.map +1 -0
  52. package/dist/engine/github/github.d.ts +302 -5
  53. package/dist/engine/github/github.js +614 -54
  54. package/dist/engine/github/github.js.map +1 -1
  55. package/dist/engine/github/profiles.d.ts +45 -1
  56. package/dist/engine/github/profiles.js +35 -0
  57. package/dist/engine/github/profiles.js.map +1 -1
  58. package/dist/engine/pr-decisions.d.ts +342 -0
  59. package/dist/engine/pr-decisions.js +721 -0
  60. package/dist/engine/pr-decisions.js.map +1 -0
  61. package/dist/engine/pr-escalation.d.ts +152 -0
  62. package/dist/engine/pr-escalation.js +320 -0
  63. package/dist/engine/pr-escalation.js.map +1 -0
  64. package/dist/engine/pr-notes.d.ts +175 -0
  65. package/dist/engine/pr-notes.js +315 -0
  66. package/dist/engine/pr-notes.js.map +1 -0
  67. package/dist/engine/pr-state.d.ts +313 -0
  68. package/dist/engine/pr-state.js +515 -0
  69. package/dist/engine/pr-state.js.map +1 -0
  70. package/dist/engine/review-check.d.ts +200 -0
  71. package/dist/engine/review-check.js +305 -0
  72. package/dist/engine/review-check.js.map +1 -0
  73. package/dist/engine/router.d.ts +27 -0
  74. package/dist/engine/router.js +156 -22
  75. package/dist/engine/router.js.map +1 -1
  76. package/dist/evals-api.d.ts +10 -0
  77. package/dist/evals-api.js +38 -0
  78. package/dist/evals-api.js.map +1 -1
  79. package/dist/index.js +313 -23
  80. package/dist/index.js.map +1 -1
  81. package/dist/sandbox/index.d.ts +13 -0
  82. package/dist/sandbox/index.js +30 -0
  83. package/dist/sandbox/index.js.map +1 -1
  84. package/dist/sandbox/k8s/init-clone.d.ts +5 -0
  85. package/dist/sandbox/k8s/init-clone.js +27 -0
  86. package/dist/sandbox/k8s/init-clone.js.map +1 -1
  87. package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +26 -1
  88. package/dist/sandbox/k8s/kubernetes-sandbox.js +30 -1
  89. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -1
  90. package/dist/state/execution-store.d.ts +27 -0
  91. package/dist/state/execution-store.js +45 -0
  92. package/dist/state/execution-store.js.map +1 -1
  93. package/dist/state/workflow-run-store.d.ts +73 -0
  94. package/dist/state/workflow-run-store.js +106 -24
  95. package/dist/state/workflow-run-store.js.map +1 -1
  96. package/dist/workflows/pr-scope.d.ts +63 -0
  97. package/dist/workflows/pr-scope.js +113 -0
  98. package/dist/workflows/pr-scope.js.map +1 -0
  99. package/dist/workflows/resume.js +113 -8
  100. package/dist/workflows/resume.js.map +1 -1
  101. package/dist/workflows/runner.d.ts +2 -1
  102. package/dist/workflows/runner.js +143 -10
  103. package/dist/workflows/runner.js.map +1 -1
  104. package/dist/workflows/simple.d.ts +280 -1
  105. package/dist/workflows/simple.js +499 -8
  106. package/dist/workflows/simple.js.map +1 -1
  107. package/dist/workflows/target-policy.d.ts +0 -12
  108. package/dist/workflows/target-policy.js +9 -15
  109. package/dist/workflows/target-policy.js.map +1 -1
  110. package/package.json +4 -4
  111. package/skills/README.md +11 -5
  112. package/skills/dependency-impact/SKILL.md +83 -0
  113. package/skills/fixing/SKILL.md +190 -0
  114. package/skills/pr-review/SKILL.md +26 -9
  115. package/workflows/cron-dependabot-ci-fix.yaml +8 -5
  116. package/workflows/cron-review.yaml +14 -5
  117. package/workflows/dependabot-ci-fix.yaml +86 -2
  118. package/workflows/dependabot-pr-merge.yaml +13 -1
  119. package/workflows/pr-fix.yaml +84 -1
  120. package/workflows/pr-review.yaml +7 -0
  121. package/workflows/prompts/dependabot-ci-fix.md +70 -17
  122. package/workflows/prompts/dependabot-pr-merge.md +203 -80
  123. package/workflows/prompts/diagnose-ci.md +96 -0
  124. package/workflows/prompts/pr-fix.md +63 -4
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Per-repository configuration — the `repo` config layer (issue #180).
3
+ *
4
+ * A managed repo may commit a `.lastlight/` directory that overrides a BOUNDED
5
+ * subset of Last Light's config for runs against that repo. The directory
6
+ * mirrors a deployment overlay's on-disk shape exactly:
7
+ *
8
+ * .lastlight/
9
+ * lastlight.yml # the config override
10
+ * workflows/prompts/*.md # prompt overrides
11
+ * skills/<name>/SKILL.md # skill overrides
12
+ * agent-context/*.md # persona/rules additions
13
+ *
14
+ * so the unpacked cache directory can be handed to the same layer-aware asset
15
+ * loader the instance overlay uses, with no second code path.
16
+ *
17
+ * ── The trust rule ────────────────────────────────────────────────────────
18
+ * The layer is ALWAYS read from the repo's **default branch**, resolved live
19
+ * from the repo metadata. Never a PR head. Never the sandbox checkout. This is
20
+ * the entire security model: without it, a pull request could commit a
21
+ * `.lastlight/lastlight.yml` that re-points the model, disables the review
22
+ * workflow and drops the approval gates of the very agent reviewing it. The
23
+ * default branch is the one ref that has already passed the repo's own review
24
+ * and branch-protection rules.
25
+ *
26
+ * ── The failure rule ──────────────────────────────────────────────────────
27
+ * Warn, drop the bad bits, run anyway. A repo's config file must never fail a
28
+ * run. Invalid YAML drops the whole file; an unknown or out-of-bounds key drops
29
+ * just that key; a fetch error falls back to the last good cached copy (or to
30
+ * no layer at all). Every rejection becomes a structured `RepoConfigWarning`
31
+ * so the dashboard/CLI can report it back to the repo's owners.
32
+ *
33
+ * ── Layout ────────────────────────────────────────────────────────────────
34
+ * This module owns the IMPURE half: the GitHub round-trip, the on-disk unpack
35
+ * and the TTL cache. The pure half — the schema, the operator bounds, and every
36
+ * validator/merger that enforces them — lives in
37
+ * `packages/shared/src/repo-config-schema.ts`, because the `lastlight` CLI
38
+ * needs exactly the same answers offline (`lastlight repo config validate`)
39
+ * and may never gain a dependency edge to core. It is **re-exported wholesale**
40
+ * below, so `src/config/repo-config.js` remains the single import surface for
41
+ * everything about the repo layer.
42
+ */
43
+ import { type RepoConfigBase, type RepoConfigPolicy, type RepoLayer } from "lastlight-shared/repo-config-schema";
44
+ import { GitHubClient } from "../engine/github/github.js";
45
+ import { type LastLightConfig } from "./config.js";
46
+ /**
47
+ * The pure half, re-exported so every existing `src/config/repo-config.js`
48
+ * import (`resolveRepoConfig`, `sanitizeRepoFiles`, `RepoConfigWarning`, the
49
+ * bounds constants, …) keeps resolving unchanged after the move to
50
+ * `lastlight-shared`.
51
+ */
52
+ export * from "lastlight-shared/repo-config-schema";
53
+ /** How long a fetched layer is trusted before we re-check with a conditional request. */
54
+ export declare const REPO_CONFIG_TTL_MS = 60000;
55
+ /** Options for {@link fetchRepoLayer}. */
56
+ export interface FetchRepoLayerOptions {
57
+ /** GitHub client to fetch through. Defaults to the harness client from runtime config. */
58
+ client?: GitHubClient;
59
+ /** Operator bounds. Defaults to {@link repoConfigPolicy}. */
60
+ policy?: RepoConfigPolicy;
61
+ /** Skip the TTL and issue the conditional request now. */
62
+ force?: boolean;
63
+ /** Cache root override. Defaults to `<stateDir>/repo-config`. */
64
+ cacheRoot?: string;
65
+ }
66
+ /**
67
+ * The operator's bounds from runtime config, with the shipped defaults when
68
+ * config isn't loaded (unit tests, pre-boot code paths). Never throws.
69
+ */
70
+ export declare function repoConfigPolicy(): RepoConfigPolicy;
71
+ /**
72
+ * Project the boot config into the {@link RepoConfigBase} the pure resolver
73
+ * takes. `publicConfig.sources` is the provenance tree `loadConfig` already
74
+ * built, so a leaf the repo does NOT override keeps its real boot provenance
75
+ * ("overlay", "env", …) rather than being flattened to "default".
76
+ *
77
+ * EVERY repo-settable block must appear in BOTH `value` and `sources`. A block
78
+ * missing from `value` has no operator value to merge onto or clamp against at
79
+ * resolve time (the clamps then fall back to the shipped defaults, silently
80
+ * ignoring an operator's own overlay); one missing from `sources` loses its
81
+ * provenance. Adding a key to `repoConfig.allowKeys` without adding it here is
82
+ * the quiet half of that mistake.
83
+ */
84
+ export declare function repoConfigBaseFromRuntime(config: LastLightConfig): RepoConfigBase;
85
+ /**
86
+ * Fetch (or serve from cache) a repo's `.lastlight/` layer.
87
+ *
88
+ * Never throws and never rejects: a GitHub failure degrades to the last good
89
+ * cached layer, or to `undefined`. `undefined` means "no repo layer applies" —
90
+ * the feature is off, the repo has no `.lastlight/`, there's no GitHub auth, or
91
+ * the fetch failed with nothing cached.
92
+ *
93
+ * Cache behaviour: within {@link REPO_CONFIG_TTL_MS} the cached answer is
94
+ * returned untouched. After that a CONDITIONAL request goes out; a
95
+ * "not modified" answer just refreshes the timestamp, so the steady-state cost
96
+ * of a cron fanning out over N repos is N conditional requests and zero
97
+ * downloads.
98
+ */
99
+ export declare function fetchRepoLayer(repo: string, options?: FetchRepoLayerOptions): Promise<RepoLayer | undefined>;
100
+ /**
101
+ * Force a refresh now, bypassing the TTL. `GET /admin/api/repos/:owner/:repo/config?refresh=1`
102
+ * (and so `lastlight repo config show --refresh`) hangs off this — an operator
103
+ * who has just merged a `.lastlight/` change shouldn't wait out the TTL.
104
+ */
105
+ export declare function refreshRepoLayer(repo: string, options?: FetchRepoLayerOptions): Promise<RepoLayer | undefined>;
106
+ /**
107
+ * Drop a repo's cached layer (or every repo's, with no argument). The next
108
+ * {@link fetchRepoLayer} re-checks. Cheap — the unpacked files and sidecar stay
109
+ * on disk, so the re-check is still conditional.
110
+ */
111
+ export declare function invalidateRepoLayer(repo?: string): void;
112
+ /** The cached layer without touching the network — for read-only surfaces (dashboard, CLI). */
113
+ export declare function getCachedRepoLayer(repo: string): RepoLayer | undefined;
114
+ /** Test-only: clear the in-memory cache. Matches the `resetXForTests()` convention. */
115
+ export declare function resetRepoConfigForTests(): void;
116
+ /**
117
+ * List the unpacked layer's asset paths (relative to `root`). Handy for the
118
+ * admin/CLI views that show what a repo actually contributed.
119
+ */
120
+ export declare function listRepoLayerAssets(root: string): string[];
@@ -0,0 +1,447 @@
1
+ /**
2
+ * Per-repository configuration — the `repo` config layer (issue #180).
3
+ *
4
+ * A managed repo may commit a `.lastlight/` directory that overrides a BOUNDED
5
+ * subset of Last Light's config for runs against that repo. The directory
6
+ * mirrors a deployment overlay's on-disk shape exactly:
7
+ *
8
+ * .lastlight/
9
+ * lastlight.yml # the config override
10
+ * workflows/prompts/*.md # prompt overrides
11
+ * skills/<name>/SKILL.md # skill overrides
12
+ * agent-context/*.md # persona/rules additions
13
+ *
14
+ * so the unpacked cache directory can be handed to the same layer-aware asset
15
+ * loader the instance overlay uses, with no second code path.
16
+ *
17
+ * ── The trust rule ────────────────────────────────────────────────────────
18
+ * The layer is ALWAYS read from the repo's **default branch**, resolved live
19
+ * from the repo metadata. Never a PR head. Never the sandbox checkout. This is
20
+ * the entire security model: without it, a pull request could commit a
21
+ * `.lastlight/lastlight.yml` that re-points the model, disables the review
22
+ * workflow and drops the approval gates of the very agent reviewing it. The
23
+ * default branch is the one ref that has already passed the repo's own review
24
+ * and branch-protection rules.
25
+ *
26
+ * ── The failure rule ──────────────────────────────────────────────────────
27
+ * Warn, drop the bad bits, run anyway. A repo's config file must never fail a
28
+ * run. Invalid YAML drops the whole file; an unknown or out-of-bounds key drops
29
+ * just that key; a fetch error falls back to the last good cached copy (or to
30
+ * no layer at all). Every rejection becomes a structured `RepoConfigWarning`
31
+ * so the dashboard/CLI can report it back to the repo's owners.
32
+ *
33
+ * ── Layout ────────────────────────────────────────────────────────────────
34
+ * This module owns the IMPURE half: the GitHub round-trip, the on-disk unpack
35
+ * and the TTL cache. The pure half — the schema, the operator bounds, and every
36
+ * validator/merger that enforces them — lives in
37
+ * `packages/shared/src/repo-config-schema.ts`, because the `lastlight` CLI
38
+ * needs exactly the same answers offline (`lastlight repo config validate`)
39
+ * and may never gain a dependency edge to core. It is **re-exported wholesale**
40
+ * below, so `src/config/repo-config.js` remains the single import surface for
41
+ * everything about the repo layer.
42
+ */
43
+ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
44
+ import { dirname, join, resolve, sep } from "path";
45
+ import { DEFAULT_REPO_CONFIG_ALLOW_KEYS, REPO_CONFIG_FILE, REPO_CONFIG_MAX_BYTES, REPO_CONFIG_MAX_FILES, isConfigSource, isRepoWorkflowPath, parseRepoConfigYaml, repoLayerPathKind, sanitizeRepoFiles, } from "lastlight-shared/repo-config-schema";
46
+ import { GitHubClient } from "../engine/github/github.js";
47
+ import { getRuntimeConfig } from "./config.js";
48
+ /**
49
+ * The pure half, re-exported so every existing `src/config/repo-config.js`
50
+ * import (`resolveRepoConfig`, `sanitizeRepoFiles`, `RepoConfigWarning`, the
51
+ * bounds constants, …) keeps resolving unchanged after the move to
52
+ * `lastlight-shared`.
53
+ */
54
+ export * from "lastlight-shared/repo-config-schema";
55
+ // ---------------------------------------------------------------------------
56
+ // Bounds (cache-only — the rest live with the schema in lastlight-shared)
57
+ // ---------------------------------------------------------------------------
58
+ /** How long a fetched layer is trusted before we re-check with a conditional request. */
59
+ export const REPO_CONFIG_TTL_MS = 60_000;
60
+ // ---------------------------------------------------------------------------
61
+ // Policy access
62
+ // ---------------------------------------------------------------------------
63
+ /**
64
+ * The operator's bounds from runtime config, with the shipped defaults when
65
+ * config isn't loaded (unit tests, pre-boot code paths). Never throws.
66
+ */
67
+ export function repoConfigPolicy() {
68
+ return (getRuntimeConfig()?.repoConfig ?? {
69
+ enabled: true,
70
+ allowKeys: [...DEFAULT_REPO_CONFIG_ALLOW_KEYS],
71
+ allowedModels: null,
72
+ allowAssets: true,
73
+ });
74
+ }
75
+ /**
76
+ * Project the boot config into the {@link RepoConfigBase} the pure resolver
77
+ * takes. `publicConfig.sources` is the provenance tree `loadConfig` already
78
+ * built, so a leaf the repo does NOT override keeps its real boot provenance
79
+ * ("overlay", "env", …) rather than being flattened to "default".
80
+ *
81
+ * EVERY repo-settable block must appear in BOTH `value` and `sources`. A block
82
+ * missing from `value` has no operator value to merge onto or clamp against at
83
+ * resolve time (the clamps then fall back to the shipped defaults, silently
84
+ * ignoring an operator's own overlay); one missing from `sources` loses its
85
+ * provenance. Adding a key to `repoConfig.allowKeys` without adding it here is
86
+ * the quiet half of that mistake.
87
+ */
88
+ export function repoConfigBaseFromRuntime(config) {
89
+ const bootSources = isPlainObject(config.publicConfig?.sources) ? config.publicConfig.sources : {};
90
+ return {
91
+ value: {
92
+ models: { ...config.models },
93
+ variants: { ...config.variants },
94
+ disabled: { ...config.disabled },
95
+ approval: { ...(config.approval ?? {}) },
96
+ fix: { ...config.fix },
97
+ dependencies: { ...config.dependencies },
98
+ review: { ...config.review },
99
+ },
100
+ sources: {
101
+ models: expandSourceNode(bootSources.models, Object.keys(config.models)),
102
+ variants: expandSourceNode(bootSources.variants, Object.keys(config.variants)),
103
+ disabled: expandSourceNode(bootSources.disabled, Object.keys(config.disabled)),
104
+ approval: expandSourceNode(bootSources.approval, Object.keys(config.approval ?? {})),
105
+ // `?? {}` guards the partially-built configs tests cast into place; a real
106
+ // boot config always carries all three blocks.
107
+ fix: expandSourceNode(bootSources.fix, Object.keys(config.fix ?? {})),
108
+ dependencies: expandSourceNode(bootSources.dependencies, Object.keys(config.dependencies ?? {})),
109
+ review: expandSourceNode(bootSources.review, Object.keys(config.review ?? {})),
110
+ },
111
+ };
112
+ }
113
+ /**
114
+ * Normalize one provenance sub-tree. `loadConfig` collapses a node to a single
115
+ * source string when env replaced it wholesale (APPROVAL_GATES does exactly
116
+ * this) — expand that back to per-key leaves so the repo merge attributes
117
+ * key-by-key like every other node.
118
+ */
119
+ function expandSourceNode(node, keys) {
120
+ const out = {};
121
+ const flat = isConfigSource(node) ? node : undefined;
122
+ for (const key of keys)
123
+ out[key] = flat ?? "default";
124
+ if (!flat && isPlainObject(node)) {
125
+ for (const [k, v] of Object.entries(node))
126
+ if (isConfigSource(v))
127
+ out[k] = v;
128
+ }
129
+ return out;
130
+ }
131
+ function isPlainObject(value) {
132
+ return typeof value === "object" && value !== null && !Array.isArray(value);
133
+ }
134
+ /** True when `filePath` resolves inside `root`. The last gate before {@link unpack} writes. */
135
+ function isInside(filePath, root) {
136
+ const r = resolve(root);
137
+ const f = resolve(filePath);
138
+ return f === r || f.startsWith(r + sep);
139
+ }
140
+ const memoryCache = new Map();
141
+ /**
142
+ * Fetch (or serve from cache) a repo's `.lastlight/` layer.
143
+ *
144
+ * Never throws and never rejects: a GitHub failure degrades to the last good
145
+ * cached layer, or to `undefined`. `undefined` means "no repo layer applies" —
146
+ * the feature is off, the repo has no `.lastlight/`, there's no GitHub auth, or
147
+ * the fetch failed with nothing cached.
148
+ *
149
+ * Cache behaviour: within {@link REPO_CONFIG_TTL_MS} the cached answer is
150
+ * returned untouched. After that a CONDITIONAL request goes out; a
151
+ * "not modified" answer just refreshes the timestamp, so the steady-state cost
152
+ * of a cron fanning out over N repos is N conditional requests and zero
153
+ * downloads.
154
+ */
155
+ export async function fetchRepoLayer(repo, options = {}) {
156
+ const policy = options.policy ?? repoConfigPolicy();
157
+ if (!policy.enabled)
158
+ return undefined;
159
+ const slug = parseRepoSlug(repo);
160
+ if (!slug) {
161
+ console.warn(`[repo-config] Ignoring malformed repo name: ${repo}`);
162
+ return undefined;
163
+ }
164
+ const now = Date.now();
165
+ const cached = memoryCache.get(repo);
166
+ if (cached && !options.force && now - cached.checkedAt < REPO_CONFIG_TTL_MS)
167
+ return cached.layer;
168
+ const dir = repoCacheDir(repo, options.cacheRoot);
169
+ // On a cold process the in-memory cache is empty but the sidecar isn't — read
170
+ // it so the first request after a restart is still conditional.
171
+ const prior = cached?.layer ?? readSidecar(dir);
172
+ // Chat-only mode (no App, no PAT): there's nothing to fetch through. Serve
173
+ // whatever is already unpacked rather than silently dropping the layer.
174
+ const client = options.client ?? resolveRepoConfigClient();
175
+ if (!client)
176
+ return hydrate(repo, dir, prior);
177
+ let result;
178
+ try {
179
+ result = await client.fetchRepoConfigTree(slug.owner, slug.repo, {
180
+ etag: prior?.etag,
181
+ treeSha: prior?.treeSha,
182
+ maxFiles: REPO_CONFIG_MAX_FILES,
183
+ maxBytes: REPO_CONFIG_MAX_BYTES,
184
+ // Don't spend the byte budget on build-handoff docs, which share
185
+ // `.lastlight/` in `buildAssets.location: repo` mode. Workflow YAML is
186
+ // pulled in deliberately: it's rejected with a warning, not ignored.
187
+ includePath: (p) => repoLayerPathKind(p) !== null || isRepoWorkflowPath(p),
188
+ });
189
+ }
190
+ catch (err) {
191
+ // Warn, keep the last good layer, run anyway.
192
+ const message = err instanceof Error ? err.message : String(err);
193
+ console.warn(`[repo-config] ${repo}: .lastlight/ fetch failed (${message}) — using the cached layer if any`);
194
+ const fallback = hydrate(repo, dir, prior);
195
+ if (fallback) {
196
+ fallback.warnings = [
197
+ ...fallback.warnings,
198
+ {
199
+ code: "fetch-failed",
200
+ repo,
201
+ path: ".lastlight",
202
+ message: `Could not refresh .lastlight/ from the default branch (${message}); using the last cached copy.`,
203
+ },
204
+ ];
205
+ }
206
+ memoryCache.set(repo, { layer: fallback, checkedAt: now });
207
+ return fallback;
208
+ }
209
+ if (result.status === "absent") {
210
+ clearRepoCacheDir(dir);
211
+ memoryCache.set(repo, { layer: undefined, checkedAt: now });
212
+ return undefined;
213
+ }
214
+ if (result.status === "not-modified") {
215
+ const layer = hydrate(repo, dir, prior);
216
+ memoryCache.set(repo, { layer, checkedAt: now });
217
+ return layer;
218
+ }
219
+ const { accepted, warnings } = sanitizeRepoFiles(result.files, policy, repo);
220
+ if (result.truncated) {
221
+ warnings.push({
222
+ code: "size-cap",
223
+ repo,
224
+ path: ".lastlight",
225
+ message: `.lastlight/ was truncated at ${REPO_CONFIG_MAX_FILES} files / ${REPO_CONFIG_MAX_BYTES} bytes — ` +
226
+ `some of it was not read.`,
227
+ });
228
+ }
229
+ const root = unpack(dir, accepted);
230
+ const configFile = accepted.find((f) => f.path === REPO_CONFIG_FILE);
231
+ const parsed = configFile
232
+ ? parseRepoConfigYaml(configFile.content.toString("utf-8"), repo)
233
+ : { warnings: [] };
234
+ warnings.push(...parsed.warnings);
235
+ const layer = {
236
+ repo,
237
+ defaultBranch: result.defaultBranch,
238
+ treeSha: result.treeSha,
239
+ etag: result.etag,
240
+ fetchedAt: new Date().toISOString(),
241
+ root,
242
+ config: parsed.config,
243
+ assets: accepted.filter((f) => f.path !== REPO_CONFIG_FILE).map((f) => f.path),
244
+ warnings,
245
+ };
246
+ writeSidecar(dir, layer);
247
+ memoryCache.set(repo, { layer, checkedAt: now });
248
+ return layer;
249
+ }
250
+ /**
251
+ * Force a refresh now, bypassing the TTL. `GET /admin/api/repos/:owner/:repo/config?refresh=1`
252
+ * (and so `lastlight repo config show --refresh`) hangs off this — an operator
253
+ * who has just merged a `.lastlight/` change shouldn't wait out the TTL.
254
+ */
255
+ export function refreshRepoLayer(repo, options = {}) {
256
+ return fetchRepoLayer(repo, { ...options, force: true });
257
+ }
258
+ /**
259
+ * Drop a repo's cached layer (or every repo's, with no argument). The next
260
+ * {@link fetchRepoLayer} re-checks. Cheap — the unpacked files and sidecar stay
261
+ * on disk, so the re-check is still conditional.
262
+ */
263
+ export function invalidateRepoLayer(repo) {
264
+ if (repo)
265
+ memoryCache.delete(repo);
266
+ else
267
+ memoryCache.clear();
268
+ }
269
+ /** The cached layer without touching the network — for read-only surfaces (dashboard, CLI). */
270
+ export function getCachedRepoLayer(repo) {
271
+ return memoryCache.get(repo)?.layer;
272
+ }
273
+ /** Test-only: clear the in-memory cache. Matches the `resetXForTests()` convention. */
274
+ export function resetRepoConfigForTests() {
275
+ memoryCache.clear();
276
+ }
277
+ // ---------------------------------------------------------------------------
278
+ // Fetch/cache internals
279
+ // ---------------------------------------------------------------------------
280
+ /**
281
+ * The harness GitHub client, or `undefined` in chat-only mode. Config-first
282
+ * (never live `process.env`) for the same reason `resolveReviewGitHubClient` is:
283
+ * boot config can't be raced by anything mutating the env mid-run.
284
+ */
285
+ function resolveRepoConfigClient() {
286
+ const cfg = getRuntimeConfig();
287
+ if (cfg?.githubApp)
288
+ return new GitHubClient(cfg.githubApp);
289
+ if (cfg?.githubToken)
290
+ return GitHubClient.withToken(cfg.githubToken);
291
+ return undefined;
292
+ }
293
+ /** Split `owner/repo`, rejecting anything that couldn't be a path segment. */
294
+ function parseRepoSlug(repo) {
295
+ const parts = repo.split("/");
296
+ if (parts.length !== 2)
297
+ return undefined;
298
+ const [owner, name] = parts;
299
+ const safe = /^[A-Za-z0-9._-]+$/;
300
+ if (!safe.test(owner) || !safe.test(name) || owner === "." || owner === ".." || name === "." || name === "..") {
301
+ return undefined;
302
+ }
303
+ return { owner, repo: name };
304
+ }
305
+ /**
306
+ * On-disk cache root. `<stateDir>/repo-config/<owner>/<repo>/` holds
307
+ * `meta.json` (the sidecar) beside `files/` (the unpacked `.lastlight/` tree).
308
+ * Keeping the sidecar OUT of `files/` means a repo can't shadow it by
309
+ * committing its own `meta.json`.
310
+ */
311
+ function repoCacheDir(repo, cacheRoot) {
312
+ const root = cacheRoot ?? join(getRuntimeConfig()?.stateDir ?? resolve(process.env.STATE_DIR || "./data"), "repo-config");
313
+ return join(root, repo);
314
+ }
315
+ function readSidecar(dir) {
316
+ const file = join(dir, "meta.json");
317
+ try {
318
+ if (!existsSync(file))
319
+ return undefined;
320
+ const parsed = JSON.parse(readFileSync(file, "utf-8"));
321
+ return typeof parsed?.treeSha === "string" ? parsed : undefined;
322
+ }
323
+ catch {
324
+ return undefined;
325
+ }
326
+ }
327
+ function writeSidecar(dir, layer) {
328
+ const sidecar = {
329
+ repo: layer.repo,
330
+ defaultBranch: layer.defaultBranch,
331
+ treeSha: layer.treeSha,
332
+ etag: layer.etag,
333
+ fetchedAt: layer.fetchedAt,
334
+ assets: layer.assets,
335
+ warnings: layer.warnings,
336
+ };
337
+ try {
338
+ mkdirSync(dir, { recursive: true });
339
+ writeFileSync(join(dir, "meta.json"), JSON.stringify(sidecar, null, 2));
340
+ }
341
+ catch (err) {
342
+ console.warn(`[repo-config] Could not persist ${layer.repo} cache sidecar: ${err.message}`);
343
+ }
344
+ }
345
+ /**
346
+ * Rebuild a {@link RepoLayer} from the on-disk cache — the "not modified" path,
347
+ * and the path a restarted process takes before anything has changed upstream.
348
+ * Re-parses `lastlight.yml` from disk rather than trusting a serialized copy, so
349
+ * the cache holds bytes, not decisions.
350
+ */
351
+ function hydrate(repo, dir, sidecar) {
352
+ if (!sidecar)
353
+ return undefined;
354
+ const root = join(dir, "files");
355
+ if (!existsSync(root))
356
+ return undefined;
357
+ const configPath = join(root, REPO_CONFIG_FILE);
358
+ let config;
359
+ const warnings = [...(sidecar.warnings ?? [])];
360
+ if (existsSync(configPath)) {
361
+ const parsed = parseRepoConfigYaml(readFileSync(configPath, "utf-8"), repo);
362
+ config = parsed.config;
363
+ // The sidecar already carries the parse warning from the original fetch —
364
+ // don't double-report it.
365
+ if (!warnings.some((w) => w.code === "invalid-yaml" || w.code === "not-a-mapping")) {
366
+ warnings.push(...parsed.warnings);
367
+ }
368
+ }
369
+ return {
370
+ repo,
371
+ defaultBranch: sidecar.defaultBranch,
372
+ treeSha: sidecar.treeSha,
373
+ etag: sidecar.etag,
374
+ fetchedAt: sidecar.fetchedAt,
375
+ root,
376
+ config,
377
+ assets: sidecar.assets ?? [],
378
+ warnings,
379
+ };
380
+ }
381
+ /**
382
+ * Materialize the accepted files under `<dir>/files/`, replacing whatever was
383
+ * there. Built in a sibling `files.tmp` and renamed into place so a crash
384
+ * mid-unpack can never leave a half-written layer that a run would then read.
385
+ * Every write is re-checked against the root — the belt to `sanitizeRepoFiles`'s
386
+ * braces, since this is the moment a bad path would actually escape.
387
+ */
388
+ function unpack(dir, files) {
389
+ const root = join(dir, "files");
390
+ const tmp = join(dir, "files.tmp");
391
+ try {
392
+ mkdirSync(dir, { recursive: true });
393
+ rmSync(tmp, { recursive: true, force: true });
394
+ mkdirSync(tmp, { recursive: true });
395
+ for (const file of files) {
396
+ const target = join(tmp, file.path);
397
+ if (!isInside(target, tmp))
398
+ continue;
399
+ mkdirSync(dirname(target), { recursive: true });
400
+ writeFileSync(target, file.content);
401
+ }
402
+ rmSync(root, { recursive: true, force: true });
403
+ renameSync(tmp, root);
404
+ }
405
+ catch (err) {
406
+ console.warn(`[repo-config] Could not unpack ${dir}: ${err.message}`);
407
+ }
408
+ return root;
409
+ }
410
+ function clearRepoCacheDir(dir) {
411
+ try {
412
+ if (existsSync(dir) && statSync(dir).isDirectory())
413
+ rmSync(dir, { recursive: true, force: true });
414
+ }
415
+ catch {
416
+ // Best-effort — a stale cache dir is harmless once the memory entry is negative.
417
+ }
418
+ }
419
+ /**
420
+ * List the unpacked layer's asset paths (relative to `root`). Handy for the
421
+ * admin/CLI views that show what a repo actually contributed.
422
+ */
423
+ export function listRepoLayerAssets(root) {
424
+ const out = [];
425
+ const walk = (dir, prefix) => {
426
+ let entries;
427
+ try {
428
+ entries = readdirSync(dir, { withFileTypes: true });
429
+ }
430
+ catch {
431
+ return;
432
+ }
433
+ for (const entry of entries) {
434
+ // Never follow a symlink out of the cache, even one we didn't write.
435
+ if (entry.isSymbolicLink())
436
+ continue;
437
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
438
+ if (entry.isDirectory())
439
+ walk(join(dir, entry.name), rel);
440
+ else if (entry.isFile() && rel !== REPO_CONFIG_FILE)
441
+ out.push(rel);
442
+ }
443
+ };
444
+ walk(root, "");
445
+ return out.sort();
446
+ }
447
+ //# sourceMappingURL=repo-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-config.js","sourceRoot":"","sources":["../../src/config/repo-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,E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AAK,CAAC,cAAc,EAAE;gBAAE,SAAS;YACrC,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YAC5D,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;iBACrD,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,KAAK,gBAAgB;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACf,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC"}
@@ -29,6 +29,17 @@ export interface GitHubWebhookConfig {
29
29
  * its legacy per-suite behaviour.
30
30
  */
31
31
  getChecksConclusion?: (owner: string, repo: string, ref: string) => Promise<"passing" | "failing" | "pending" | "none">;
32
+ /**
33
+ * The OPERATOR's `review.trigger`, read live.
34
+ *
35
+ * `check_suite.completed` is broadened past dependency PRs — to
36
+ * `pr.checks_settled` — only under `after-checks`, because that is the only
37
+ * mode with a consumer. Emitting is what costs event volume, and a repo that
38
+ * opts itself into `after-checks` under an `eager` operator is covered by the
39
+ * 30-minute `check-prs-awaiting-review` sweep. Unset (standalone unit tests)
40
+ * reads as "not after-checks".
41
+ */
42
+ reviewTrigger?: () => "eager" | "after-checks" | "on-request";
32
43
  }
33
44
  export declare class GitHubWebhookConnector extends EventEmitter implements Connector {
34
45
  readonly name = "github";
@@ -57,6 +68,12 @@ export declare class GitHubWebhookConnector extends EventEmitter implements Conn
57
68
  * genuine event.
58
69
  */
59
70
  private settledConclusion;
71
+ /**
72
+ * Is the operator running `review.trigger: after-checks`? Only then does a
73
+ * settled check suite on a PR neither check-outcome route claimed become a
74
+ * `pr.checks_settled` event; every other mode has no consumer for it.
75
+ */
76
+ private afterChecks;
60
77
  private verifySignature;
61
78
  private normalize;
62
79
  start(): Promise<void>;