@hearsay-tools/squawk 0.19.0-dev.8999 → 0.19.0-dev.9008

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.
@@ -121,12 +121,9 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
121
121
  } & {
122
122
  "/api/v1/tools/:name": {
123
123
  $post: {
124
- output: {
125
- code: string;
126
- message: string;
127
- };
124
+ output: never;
128
125
  outputFormat: "json";
129
- status: 401;
126
+ status: import("hono/utils/http-status").ContentfulStatusCode;
130
127
  input: {
131
128
  json: unknown;
132
129
  } & {
@@ -149,9 +146,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
149
146
  };
150
147
  };
151
148
  } | {
152
- output: never;
149
+ output: {
150
+ code: string;
151
+ message: string;
152
+ };
153
153
  outputFormat: "json";
154
- status: import("hono/utils/http-status").ContentfulStatusCode;
154
+ status: 401;
155
155
  input: {
156
156
  json: unknown;
157
157
  } & {
@@ -135,6 +135,14 @@ export interface ForgeHeadPullRequests {
135
135
  prs: ForgeBranchPullRequest[];
136
136
  incomplete: ReadonlySet<string>;
137
137
  }
138
+ /** The PRs that contain some commits, by commit, whatever their head branch is called. `incomplete`
139
+ * names each commit whose PRs the forge did not return in full. `available` is false once any
140
+ * lookup failed. */
141
+ export interface ForgeCommitPullRequests {
142
+ available: boolean;
143
+ prs: ReadonlyMap<string, ForgeBranchPullRequest[]>;
144
+ incomplete: ReadonlySet<string>;
145
+ }
138
146
  /** The open PRs of the repository whose head branch lives in the repository itself (no fork PRs),
139
147
  * from one listing. `available` is false once the forge did not answer. */
140
148
  export interface ForgeOpenPullRequests {
@@ -183,6 +191,9 @@ export interface ForgeProjectClientOptional {
183
191
  branchPushed?(numbers: readonly number[]): void;
184
192
  /** Every PR whose head is one of `heads` (branch classification). */
185
193
  branchPullRequests?(heads: readonly string[]): Promise<ForgeHeadPullRequests>;
194
+ /** Every PR that contains one of `commits` (full SHAs), under any head name (branch
195
+ * classification). */
196
+ commitPullRequests?(commits: readonly string[]): Promise<ForgeCommitPullRequests>;
186
197
  /** The repository's open PRs from its own branches, in one listing (the All branches rows of
187
198
  * branches outside `cez/*`). */
188
199
  openPullRequests?(): Promise<ForgeOpenPullRequests>;
@@ -1 +1 @@
1
- {"version":3,"file":"forge-registry.js","sourceRoot":"","sources":["../../src/core/forge-registry.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,eAAe,EAA2B,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAoLpD;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,8EAA8E;IACrE,KAAK,CAAqB;IACnC,YAAY,OAAe,EAAE,KAAc,EAAE,OAAsB;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,uGAAuG;AACvG,MAAM,OAAO,oBAAqB,SAAQ,KAAK;CAAG;AAmClD,MAAM,oBAAoB,GAAG,CAAC,aAAa,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,CAAU,CAAC;AAEhJ,MAAM,MAAM,GAAG,mBAAmB,CAA0B;IAC1D,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,yHAAyH;CACpI,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,UAA2B;IAC7C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC5H,IAAI,OAAO,UAAU,CAAC,EAAE,KAAK,QAAQ,IAAI,UAAU,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,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SAAS,CAAC;AAC9I,CAAC"}
@@ -2,6 +2,18 @@ import type { DelegationRoutes } from './routes.ts';
2
2
  export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
3
3
  "/list": {
4
4
  $get: {
5
+ output: {
6
+ error: string;
7
+ code?: "invalid_input" | undefined;
8
+ };
9
+ outputFormat: "json";
10
+ status: 400;
11
+ input: {
12
+ query: {
13
+ offset?: string | undefined;
14
+ };
15
+ };
16
+ } | {
5
17
  output: {
6
18
  workers: {
7
19
  workerId: string;
@@ -54,18 +66,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
54
66
  offset?: string | undefined;
55
67
  };
56
68
  };
57
- } | {
58
- output: {
59
- error: string;
60
- code?: "invalid_input" | undefined;
61
- };
62
- outputFormat: "json";
63
- status: 400;
64
- input: {
65
- query: {
66
- offset?: string | undefined;
67
- };
68
- };
69
69
  };
70
70
  };
71
71
  } & {
@@ -652,6 +652,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
652
652
  } & {
653
653
  "/:workerId": {
654
654
  $get: {
655
+ output: {
656
+ error: string;
657
+ code?: "invalid_input" | undefined;
658
+ };
659
+ outputFormat: "json";
660
+ status: 400;
661
+ input: {
662
+ param: {
663
+ workerId: string;
664
+ };
665
+ };
666
+ } | {
655
667
  output: {
656
668
  workerId: string;
657
669
  settled: boolean;
@@ -776,7 +788,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
776
788
  workerId: string;
777
789
  };
778
790
  };
779
- } | {
791
+ };
792
+ };
793
+ } & {
794
+ "/:workerId/collect": {
795
+ $post: {
780
796
  output: {
781
797
  error: string;
782
798
  code?: "invalid_input" | undefined;
@@ -787,12 +803,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
787
803
  param: {
788
804
  workerId: string;
789
805
  };
806
+ } & {
807
+ json: Record<string, never>;
790
808
  };
791
- };
792
- };
793
- } & {
794
- "/:workerId/collect": {
795
- $post: {
809
+ } | {
796
810
  output: {
797
811
  workerId: string;
798
812
  parentRunId: string;
@@ -915,7 +929,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
915
929
  } & {
916
930
  json: Record<string, never>;
917
931
  };
918
- } | {
932
+ };
933
+ };
934
+ } & {
935
+ "/:workerId/steer": {
936
+ $post: {
919
937
  output: {
920
938
  error: string;
921
939
  code?: "invalid_input" | undefined;
@@ -927,13 +945,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
927
945
  workerId: string;
928
946
  };
929
947
  } & {
930
- json: Record<string, never>;
948
+ json: {
949
+ text: string;
950
+ };
931
951
  };
932
- };
933
- };
934
- } & {
935
- "/:workerId/steer": {
936
- $post: {
952
+ } | {
937
953
  output: {
938
954
  workerId: string;
939
955
  state: "delivered" | "queued";
@@ -949,7 +965,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
949
965
  text: string;
950
966
  };
951
967
  };
952
- } | {
968
+ };
969
+ };
970
+ } & {
971
+ "/:workerId/stop": {
972
+ $post: {
953
973
  output: {
954
974
  error: string;
955
975
  code?: "invalid_input" | undefined;
@@ -961,15 +981,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
961
981
  workerId: string;
962
982
  };
963
983
  } & {
964
- json: {
965
- text: string;
966
- };
984
+ json: Record<string, never>;
967
985
  };
968
- };
969
- };
970
- } & {
971
- "/:workerId/stop": {
972
- $post: {
986
+ } | {
973
987
  output: {
974
988
  workerId: string;
975
989
  state: "stopping" | "terminated";
@@ -983,7 +997,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
983
997
  } & {
984
998
  json: Record<string, never>;
985
999
  };
986
- } | {
1000
+ };
1001
+ };
1002
+ } & {
1003
+ "/:workerId/destroy": {
1004
+ $post: {
987
1005
  output: {
988
1006
  error: string;
989
1007
  code?: "invalid_input" | undefined;
@@ -995,13 +1013,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
995
1013
  workerId: string;
996
1014
  };
997
1015
  } & {
998
- json: Record<string, never>;
1016
+ json: {
1017
+ discardWork?: true | undefined;
1018
+ };
999
1019
  };
1000
- };
1001
- };
1002
- } & {
1003
- "/:workerId/destroy": {
1004
- $post: {
1020
+ } | {
1005
1021
  output: {
1006
1022
  workerId: string;
1007
1023
  state: "complete" | "incomplete";
@@ -1030,22 +1046,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1030
1046
  discardWork?: true | undefined;
1031
1047
  };
1032
1048
  };
1033
- } | {
1034
- output: {
1035
- error: string;
1036
- code?: "invalid_input" | undefined;
1037
- };
1038
- outputFormat: "json";
1039
- status: 400;
1040
- input: {
1041
- param: {
1042
- workerId: string;
1043
- };
1044
- } & {
1045
- json: {
1046
- discardWork?: true | undefined;
1047
- };
1048
- };
1049
1049
  } | {
1050
1050
  output: {
1051
1051
  workerId: string;
@@ -1081,13 +1081,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1081
1081
  "/:workerId/diff": {
1082
1082
  $get: {
1083
1083
  output: {
1084
- workerId: string;
1085
- baselineSha: string;
1086
- diff: string;
1087
- truncated: boolean;
1084
+ error: string;
1085
+ code?: "invalid_input" | undefined;
1088
1086
  };
1089
1087
  outputFormat: "json";
1090
- status: 200;
1088
+ status: 400;
1091
1089
  input: {
1092
1090
  param: {
1093
1091
  workerId: string;
@@ -1095,11 +1093,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
1095
1093
  };
1096
1094
  } | {
1097
1095
  output: {
1098
- error: string;
1099
- code?: "invalid_input" | undefined;
1096
+ workerId: string;
1097
+ baselineSha: string;
1098
+ diff: string;
1099
+ truncated: boolean;
1100
1100
  };
1101
1101
  outputFormat: "json";
1102
- status: 400;
1102
+ status: 200;
1103
1103
  input: {
1104
1104
  param: {
1105
1105
  workerId: string;
@@ -7,10 +7,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
7
7
  }[];
8
8
  isError: boolean;
9
9
  details: {
10
- ok: false;
11
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
12
- message: string;
13
- } | {
14
10
  ok: true;
15
11
  task: {
16
12
  id: string;
@@ -22,6 +18,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
22
18
  url?: string | undefined;
23
19
  };
24
20
  note: string;
21
+ } | {
22
+ ok: false;
23
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
24
+ message: string;
25
25
  };
26
26
  }>;
27
27
  export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof callScheduleTask>>): {
@@ -31,10 +31,6 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
31
31
  }[];
32
32
  isError: boolean;
33
33
  details: {
34
- ok: false;
35
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
36
- message: string;
37
- } | {
38
34
  ok: true;
39
35
  task: {
40
36
  id: string;
@@ -46,6 +42,10 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
46
42
  url?: string | undefined;
47
43
  };
48
44
  note: string;
45
+ } | {
46
+ ok: false;
47
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
48
+ message: string;
49
49
  };
50
50
  };
51
51
  export declare function invokeScheduledTasksTool(input: unknown): Promise<{
@@ -12,14 +12,23 @@ export declare const OPEN_PRS_PAGES_MAX = 10;
12
12
  export declare function fetchOpenPrs(run: GraphqlRunner, owner: string, name: string): Promise<ForgeOpenPullRequests>;
13
13
  /** Heads per GraphQL query, and PRs per head: GitHub caps a connection page at 100. */
14
14
  export declare const HEADS_PER_QUERY = 50;
15
- /** One query for up to `HEADS_PER_QUERY` heads. A head comes back complete with its PRs, or is
16
- * named incomplete; a failed or unreadable reply makes every head of the batch incomplete and
17
- * the batch `failed`. */
18
- export declare function fetchHeadBatch(run: GraphqlRunner, owner: string, name: string, heads: readonly string[]): Promise<{
15
+ /** One batch of a keyed PR lookup: the keys answered in full, the keys answered in part, and
16
+ * whether the query failed. */
17
+ type LookupBatch = {
19
18
  complete: Map<string, ForgePr[]>;
20
19
  incomplete: string[];
21
20
  failed: boolean;
22
- }>;
21
+ };
22
+ /** One query for up to `HEADS_PER_QUERY` heads. A head comes back complete with its PRs, or is
23
+ * named incomplete; a failed or unreadable reply makes every head of the batch incomplete and
24
+ * the batch `failed`. */
25
+ export declare function fetchHeadBatch(run: GraphqlRunner, owner: string, name: string, heads: readonly string[]): Promise<LookupBatch>;
26
+ /** Commits per GraphQL query, and PRs per commit: a commit sits in a handful of PRs at most. */
27
+ export declare const COMMITS_PER_QUERY = 50;
28
+ /** One query for up to `COMMITS_PER_QUERY` commits: every PR that contains each one, under any
29
+ * head name. A commit GitHub does not have comes back complete with no PRs. A failed or unreadable
30
+ * reply makes every commit of the batch incomplete and the batch `failed`. */
31
+ export declare function fetchCommitBatch(run: GraphqlRunner, owner: string, name: string, commits: readonly string[]): Promise<LookupBatch>;
23
32
  export interface GithubBranchForgeDeps {
24
33
  graphql?: (repoRoot: string) => GraphqlRunner;
25
34
  handle?: (repoRoot: string) => Promise<{
@@ -30,8 +39,9 @@ export interface GithubBranchForgeDeps {
30
39
  /** The default forge: the ref-status cache for created PRs, and per-head GraphQL lookups with a
31
40
  * one-minute cache per head. `CEZ_DRY_RUN=1` never shells out. */
32
41
  /** The GitHub branch forge: every listing a branch row reads. */
33
- export type GithubBranchForge = BranchForge & Required<Pick<BranchForge, 'openPrs'>>;
42
+ export type GithubBranchForge = BranchForge & Required<Pick<BranchForge, 'openPrs' | 'prsForCommits'>>;
34
43
  export declare function createGithubBranchForge(deps?: GithubBranchForgeDeps): GithubBranchForge;
35
44
  export declare const githubBranchForge: GithubBranchForge;
36
45
  /** Test-only: forget cached per-head answers. */
37
46
  export declare function __clearPrListCacheForTests(): void;
47
+ export {};
@@ -28,6 +28,10 @@ const headConnectionSchema = z.object({
28
28
  const headReplySchema = z.object({
29
29
  data: z.object({ repository: z.record(z.string(), headConnectionSchema.nullable()).nullable() }),
30
30
  });
31
+ // `object` is null for a commit GitHub does not have; a non-commit object has no field at all.
32
+ const commitReplySchema = z.object({
33
+ data: z.object({ repository: z.record(z.string(), z.object({ associatedPullRequests: headConnectionSchema.optional() }).nullable()).nullable() }),
34
+ });
31
35
  const openNodeSchema = prNodeSchema.extend({ isCrossRepository: z.boolean() });
32
36
  const openReplySchema = z.object({
33
37
  data: z.object({ repository: z.object({ pullRequests: z.object({
@@ -123,6 +127,41 @@ export async function fetchHeadBatch(run, owner, name, heads) {
123
127
  });
124
128
  return { complete, incomplete, failed: false };
125
129
  }
130
+ /** Commits per GraphQL query, and PRs per commit: a commit sits in a handful of PRs at most. */
131
+ export const COMMITS_PER_QUERY = 50;
132
+ const PRS_PER_COMMIT = 20;
133
+ function commitQuery(count) {
134
+ const vars = Array.from({ length: count }, (_, i) => `$c${i}: GitObjectID!`).join(', ');
135
+ const fields = Array.from({ length: count }, (_, i) => `c${i}: object(oid: $c${i}) { ... on Commit { associatedPullRequests(first: ${PRS_PER_COMMIT}) { pageInfo { hasNextPage } nodes { number url headRefName baseRefName headRefOid mergeCommit { oid } state isDraft } } } }`).join('\n ');
136
+ return `query ($owner: String!, $name: String!, ${vars}) {\n repository(owner: $owner, name: $name) {\n ${fields}\n }\n}`;
137
+ }
138
+ /** One query for up to `COMMITS_PER_QUERY` commits: every PR that contains each one, under any
139
+ * head name. A commit GitHub does not have comes back complete with no PRs. A failed or unreadable
140
+ * reply makes every commit of the batch incomplete and the batch `failed`. */
141
+ export async function fetchCommitBatch(run, owner, name, commits) {
142
+ const variables = { owner, name };
143
+ commits.forEach((commit, i) => { variables[`c${i}`] = commit; });
144
+ const complete = new Map();
145
+ let repository = null;
146
+ try {
147
+ repository = commitReplySchema.parse(JSON.parse(await run(commitQuery(commits.length), variables))).data.repository;
148
+ }
149
+ catch {
150
+ // An unreadable reply answers nothing, like no reply.
151
+ }
152
+ if (!repository)
153
+ return { complete, incomplete: [...commits], failed: true };
154
+ const found = repository;
155
+ const incomplete = [];
156
+ commits.forEach((commit, i) => {
157
+ const connection = found[`c${i}`]?.associatedPullRequests;
158
+ if (connection?.pageInfo.hasNextPage)
159
+ incomplete.push(commit);
160
+ else
161
+ complete.set(commit, (connection?.nodes ?? []).map(toForgePr));
162
+ });
163
+ return { complete, incomplete, failed: false };
164
+ }
126
165
  function defaultGraphql(repoRoot) {
127
166
  return async (query, variables) => {
128
167
  const { stdout } = await exec('gh', ghGraphqlArgs(query, variables), { cwd: repoRoot, timeout: 30_000, maxBuffer: 16 * 1024 * 1024 });
@@ -131,8 +170,71 @@ function defaultGraphql(repoRoot) {
131
170
  }
132
171
  const openListings = new Map();
133
172
  const OPEN_LISTING_MAX = 100;
134
- const headFlights = new Map();
135
- const headCache = new Map();
173
+ const headTables = { cache: new Map(), flights: new Map() };
174
+ const commitTables = { cache: new Map(), flights: new Map() };
175
+ /**
176
+ * The PRs of each key: a one-minute cached answer, a batch already in flight for it, or a new
177
+ * batch of at most `perQuery` keys. `open` is called only when some key needs a query; null from it
178
+ * answers null (no repository to ask). `failed` is true when any batch read here failed.
179
+ */
180
+ async function lookupKeys(tables, repoRoot, keys, perQuery, open) {
181
+ const id = (key) => `${repoRoot}\0${key}`;
182
+ const found = new Map();
183
+ const misses = [];
184
+ const now = Date.now();
185
+ for (const key of keys) {
186
+ const hit = tables.cache.get(id(key));
187
+ if (hit && now - hit.at < HEAD_TTL_MS)
188
+ found.set(key, hit.prs);
189
+ else
190
+ misses.push(key);
191
+ }
192
+ if (misses.length === 0)
193
+ return { failed: false, found, incomplete: new Set() };
194
+ const fetchBatch = await open();
195
+ if (!fetchBatch)
196
+ return null;
197
+ const batches = new Set();
198
+ const fresh = misses.filter((key) => {
199
+ const flight = tables.flights.get(id(key));
200
+ if (flight)
201
+ batches.add(flight);
202
+ return !flight;
203
+ });
204
+ for (let i = 0; i < fresh.length; i += perQuery) {
205
+ const chunk = fresh.slice(i, i + perQuery);
206
+ const flight = branchReadQueue(() => fetchBatch(chunk)).then((batch) => {
207
+ for (const [key, prs] of batch.complete) {
208
+ tables.cache.delete(id(key));
209
+ tables.cache.set(id(key), { at: Date.now(), prs });
210
+ }
211
+ while (tables.cache.size > HEAD_CACHE_MAX)
212
+ tables.cache.delete(tables.cache.keys().next().value);
213
+ return batch;
214
+ });
215
+ for (const key of chunk)
216
+ tables.flights.set(id(key), flight);
217
+ batches.add(flight);
218
+ void flight.finally(() => {
219
+ for (const key of chunk)
220
+ if (tables.flights.get(id(key)) === flight)
221
+ tables.flights.delete(id(key));
222
+ });
223
+ }
224
+ const wanted = new Set(keys);
225
+ const incomplete = new Set();
226
+ let failed = false;
227
+ for (const batch of await Promise.all(batches)) {
228
+ failed ||= batch.failed;
229
+ for (const key of batch.incomplete)
230
+ if (wanted.has(key))
231
+ incomplete.add(key);
232
+ for (const [key, prs] of batch.complete)
233
+ if (wanted.has(key))
234
+ found.set(key, prs);
235
+ }
236
+ return { failed, found, incomplete };
237
+ }
136
238
  export function createGithubBranchForge(deps = {}) {
137
239
  const graphql = deps.graphql ?? defaultGraphql;
138
240
  const handleOf = deps.handle ?? ((root) => resolveRepoHandle(root));
@@ -161,70 +263,37 @@ export function createGithubBranchForge(deps = {}) {
161
263
  const wanted = [...new Set(heads)];
162
264
  if (productEnv('DRY_RUN') === '1' || wanted.length === 0)
163
265
  return { available: true, prs: [], incomplete: new Set() };
164
- const prs = [];
165
- const misses = [];
166
- const now = Date.now();
167
- for (const head of wanted) {
168
- const hit = headCache.get(`${repoRoot}\0${head}`);
169
- if (hit && now - hit.at < HEAD_TTL_MS)
170
- prs.push(...hit.prs);
171
- else
172
- misses.push(head);
173
- }
174
- if (misses.length === 0)
175
- return { available: true, prs, incomplete: new Set() };
176
- const handle = await handleOf(repoRoot).catch(() => null);
177
- if (!handle)
266
+ const answer = await lookupKeys(headTables, repoRoot, wanted, HEADS_PER_QUERY, () => batchFetcher(repoRoot, fetchHeadBatch));
267
+ if (!answer)
178
268
  return { available: false, prs: [], incomplete: new Set(wanted) };
179
- const run = graphql(repoRoot);
180
- const incomplete = new Set();
181
- let failed = false;
182
- const batches = new Set();
183
- const fresh = misses.filter((head) => {
184
- const flight = headFlights.get(`${repoRoot}\0${head}`);
185
- if (flight)
186
- batches.add(flight);
187
- return !flight;
188
- });
189
- for (let i = 0; i < fresh.length; i += HEADS_PER_QUERY) {
190
- const chunk = fresh.slice(i, i + HEADS_PER_QUERY);
191
- const flight = branchReadQueue(() => fetchHeadBatch(run, handle.owner, handle.name, chunk)).then((batch) => {
192
- for (const [head, found] of batch.complete) {
193
- headCache.delete(`${repoRoot}\0${head}`);
194
- headCache.set(`${repoRoot}\0${head}`, { at: Date.now(), prs: found });
195
- }
196
- while (headCache.size > HEAD_CACHE_MAX)
197
- headCache.delete(headCache.keys().next().value);
198
- return batch;
199
- });
200
- for (const head of chunk)
201
- headFlights.set(`${repoRoot}\0${head}`, flight);
202
- batches.add(flight);
203
- void flight.finally(() => {
204
- for (const head of chunk)
205
- if (headFlights.get(`${repoRoot}\0${head}`) === flight)
206
- headFlights.delete(`${repoRoot}\0${head}`);
207
- });
208
- }
209
- for (const batch of await Promise.all(batches)) {
210
- failed ||= batch.failed;
211
- for (const head of batch.incomplete)
212
- if (wanted.includes(head))
213
- incomplete.add(head);
214
- for (const [head, found] of batch.complete) {
215
- if (wanted.includes(head))
216
- prs.push(...found);
217
- }
218
- }
219
- return { available: !failed, prs, incomplete };
269
+ return { available: !answer.failed, prs: [...answer.found.values()].flat(), incomplete: answer.incomplete };
270
+ },
271
+ async prsForCommits(repoRoot, commits) {
272
+ const wanted = [...new Set(commits)];
273
+ if (productEnv('DRY_RUN') === '1' || wanted.length === 0)
274
+ return { available: true, prs: new Map(), incomplete: new Set() };
275
+ const answer = await lookupKeys(commitTables, repoRoot, wanted, COMMITS_PER_QUERY, () => batchFetcher(repoRoot, fetchCommitBatch));
276
+ if (!answer)
277
+ return { available: false, prs: new Map(), incomplete: new Set(wanted) };
278
+ return { available: !answer.failed, prs: answer.found, incomplete: answer.incomplete };
220
279
  },
221
280
  };
281
+ /** A batch query bound to the repository's handle, or null when the handle does not resolve. */
282
+ async function batchFetcher(repoRoot, fetch) {
283
+ const handle = await handleOf(repoRoot).catch(() => null);
284
+ if (!handle)
285
+ return null;
286
+ const run = graphql(repoRoot);
287
+ return (chunk) => fetch(run, handle.owner, handle.name, chunk);
288
+ }
222
289
  }
223
290
  export const githubBranchForge = createGithubBranchForge();
224
291
  /** Test-only: forget cached per-head answers. */
225
292
  export function __clearPrListCacheForTests() {
226
- headCache.clear();
293
+ for (const tables of [headTables, commitTables]) {
294
+ tables.cache.clear();
295
+ tables.flights.clear();
296
+ }
227
297
  openListings.clear();
228
- headFlights.clear();
229
298
  }
230
299
  //# sourceMappingURL=github-branch-forge.js.map