@hearsay-tools/squawk 0.18.0-dev.8189 → 0.18.0-dev.8192
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/dist/automations/tools.d.ts +8 -8
- package/dist/ci-wait/controller.d.ts +7 -7
- package/dist/delegation/routes.d.ts +65 -65
- package/dist/server/forge/github-reviewer-ref.d.ts +11 -0
- package/dist/server/forge/github-reviewer-ref.js +17 -0
- package/dist/server/forge/github-reviewer-ref.js.map +1 -0
- package/dist/server/forge/github.js +23 -35
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/server.d.ts +126 -126
- package/package.json +4 -4
|
@@ -7,6 +7,10 @@ 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
|
+
} | {
|
|
10
14
|
ok: true;
|
|
11
15
|
task: {
|
|
12
16
|
id: string;
|
|
@@ -18,10 +22,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
18
22
|
url?: string | undefined;
|
|
19
23
|
};
|
|
20
24
|
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,6 +31,10 @@ 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
|
+
} | {
|
|
34
38
|
ok: true;
|
|
35
39
|
task: {
|
|
36
40
|
id: string;
|
|
@@ -42,10 +46,6 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
|
|
|
42
46
|
url?: string | undefined;
|
|
43
47
|
};
|
|
44
48
|
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<{
|
|
@@ -119,12 +119,9 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
119
119
|
} & {
|
|
120
120
|
"/api/v1/tools/:name": {
|
|
121
121
|
$post: {
|
|
122
|
-
output:
|
|
123
|
-
code: string;
|
|
124
|
-
message: string;
|
|
125
|
-
};
|
|
122
|
+
output: never;
|
|
126
123
|
outputFormat: "json";
|
|
127
|
-
status:
|
|
124
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
128
125
|
input: {
|
|
129
126
|
json: unknown;
|
|
130
127
|
} & {
|
|
@@ -147,9 +144,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
147
144
|
};
|
|
148
145
|
};
|
|
149
146
|
} | {
|
|
150
|
-
output:
|
|
147
|
+
output: {
|
|
148
|
+
code: string;
|
|
149
|
+
message: string;
|
|
150
|
+
};
|
|
151
151
|
outputFormat: "json";
|
|
152
|
-
status:
|
|
152
|
+
status: 401;
|
|
153
153
|
input: {
|
|
154
154
|
json: unknown;
|
|
155
155
|
} & {
|
|
@@ -27,6 +27,18 @@ export declare function delegationFailure(error: unknown): {
|
|
|
27
27
|
export declare function createDelegationRoutes(service: DelegationService, credentials: CredentialRegistry): import("hono/hono-base").HonoBase<Env, {
|
|
28
28
|
"/list": {
|
|
29
29
|
$get: {
|
|
30
|
+
output: {
|
|
31
|
+
error: string;
|
|
32
|
+
code?: "invalid_input" | undefined;
|
|
33
|
+
};
|
|
34
|
+
outputFormat: "json";
|
|
35
|
+
status: 400;
|
|
36
|
+
input: {
|
|
37
|
+
query: {
|
|
38
|
+
offset?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
30
42
|
output: {
|
|
31
43
|
workers: {
|
|
32
44
|
workerId: string;
|
|
@@ -79,18 +91,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
79
91
|
offset?: string | undefined;
|
|
80
92
|
};
|
|
81
93
|
};
|
|
82
|
-
} | {
|
|
83
|
-
output: {
|
|
84
|
-
error: string;
|
|
85
|
-
code?: "invalid_input" | undefined;
|
|
86
|
-
};
|
|
87
|
-
outputFormat: "json";
|
|
88
|
-
status: 400;
|
|
89
|
-
input: {
|
|
90
|
-
query: {
|
|
91
|
-
offset?: string | undefined;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
} & {
|
|
@@ -677,6 +677,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
677
677
|
} & {
|
|
678
678
|
"/:workerId": {
|
|
679
679
|
$get: {
|
|
680
|
+
output: {
|
|
681
|
+
error: string;
|
|
682
|
+
code?: "invalid_input" | undefined;
|
|
683
|
+
};
|
|
684
|
+
outputFormat: "json";
|
|
685
|
+
status: 400;
|
|
686
|
+
input: {
|
|
687
|
+
param: {
|
|
688
|
+
workerId: string;
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
} | {
|
|
680
692
|
output: {
|
|
681
693
|
workerId: string;
|
|
682
694
|
settled: boolean;
|
|
@@ -801,7 +813,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
801
813
|
workerId: string;
|
|
802
814
|
};
|
|
803
815
|
};
|
|
804
|
-
}
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
} & {
|
|
819
|
+
"/:workerId/collect": {
|
|
820
|
+
$post: {
|
|
805
821
|
output: {
|
|
806
822
|
error: string;
|
|
807
823
|
code?: "invalid_input" | undefined;
|
|
@@ -812,12 +828,10 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
812
828
|
param: {
|
|
813
829
|
workerId: string;
|
|
814
830
|
};
|
|
831
|
+
} & {
|
|
832
|
+
json: Record<string, never>;
|
|
815
833
|
};
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
} & {
|
|
819
|
-
"/:workerId/collect": {
|
|
820
|
-
$post: {
|
|
834
|
+
} | {
|
|
821
835
|
output: {
|
|
822
836
|
workerId: string;
|
|
823
837
|
parentRunId: string;
|
|
@@ -940,7 +954,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
940
954
|
} & {
|
|
941
955
|
json: Record<string, never>;
|
|
942
956
|
};
|
|
943
|
-
}
|
|
957
|
+
};
|
|
958
|
+
};
|
|
959
|
+
} & {
|
|
960
|
+
"/:workerId/steer": {
|
|
961
|
+
$post: {
|
|
944
962
|
output: {
|
|
945
963
|
error: string;
|
|
946
964
|
code?: "invalid_input" | undefined;
|
|
@@ -952,13 +970,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
952
970
|
workerId: string;
|
|
953
971
|
};
|
|
954
972
|
} & {
|
|
955
|
-
json:
|
|
973
|
+
json: {
|
|
974
|
+
text: string;
|
|
975
|
+
};
|
|
956
976
|
};
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
} & {
|
|
960
|
-
"/:workerId/steer": {
|
|
961
|
-
$post: {
|
|
977
|
+
} | {
|
|
962
978
|
output: {
|
|
963
979
|
workerId: string;
|
|
964
980
|
state: "delivered" | "queued";
|
|
@@ -974,7 +990,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
974
990
|
text: string;
|
|
975
991
|
};
|
|
976
992
|
};
|
|
977
|
-
}
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
} & {
|
|
996
|
+
"/:workerId/stop": {
|
|
997
|
+
$post: {
|
|
978
998
|
output: {
|
|
979
999
|
error: string;
|
|
980
1000
|
code?: "invalid_input" | undefined;
|
|
@@ -986,15 +1006,9 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
986
1006
|
workerId: string;
|
|
987
1007
|
};
|
|
988
1008
|
} & {
|
|
989
|
-
json:
|
|
990
|
-
text: string;
|
|
991
|
-
};
|
|
1009
|
+
json: Record<string, never>;
|
|
992
1010
|
};
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
} & {
|
|
996
|
-
"/:workerId/stop": {
|
|
997
|
-
$post: {
|
|
1011
|
+
} | {
|
|
998
1012
|
output: {
|
|
999
1013
|
workerId: string;
|
|
1000
1014
|
state: "stopping" | "terminated";
|
|
@@ -1008,7 +1022,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1008
1022
|
} & {
|
|
1009
1023
|
json: Record<string, never>;
|
|
1010
1024
|
};
|
|
1011
|
-
}
|
|
1025
|
+
};
|
|
1026
|
+
};
|
|
1027
|
+
} & {
|
|
1028
|
+
"/:workerId/destroy": {
|
|
1029
|
+
$post: {
|
|
1012
1030
|
output: {
|
|
1013
1031
|
error: string;
|
|
1014
1032
|
code?: "invalid_input" | undefined;
|
|
@@ -1020,13 +1038,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1020
1038
|
workerId: string;
|
|
1021
1039
|
};
|
|
1022
1040
|
} & {
|
|
1023
|
-
json:
|
|
1041
|
+
json: {
|
|
1042
|
+
discardWork?: true | undefined;
|
|
1043
|
+
};
|
|
1024
1044
|
};
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
} & {
|
|
1028
|
-
"/:workerId/destroy": {
|
|
1029
|
-
$post: {
|
|
1045
|
+
} | {
|
|
1030
1046
|
output: {
|
|
1031
1047
|
workerId: string;
|
|
1032
1048
|
state: "complete" | "incomplete";
|
|
@@ -1055,22 +1071,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1055
1071
|
discardWork?: true | undefined;
|
|
1056
1072
|
};
|
|
1057
1073
|
};
|
|
1058
|
-
} | {
|
|
1059
|
-
output: {
|
|
1060
|
-
error: string;
|
|
1061
|
-
code?: "invalid_input" | undefined;
|
|
1062
|
-
};
|
|
1063
|
-
outputFormat: "json";
|
|
1064
|
-
status: 400;
|
|
1065
|
-
input: {
|
|
1066
|
-
param: {
|
|
1067
|
-
workerId: string;
|
|
1068
|
-
};
|
|
1069
|
-
} & {
|
|
1070
|
-
json: {
|
|
1071
|
-
discardWork?: true | undefined;
|
|
1072
|
-
};
|
|
1073
|
-
};
|
|
1074
1074
|
} | {
|
|
1075
1075
|
output: {
|
|
1076
1076
|
workerId: string;
|
|
@@ -1106,13 +1106,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1106
1106
|
"/:workerId/diff": {
|
|
1107
1107
|
$get: {
|
|
1108
1108
|
output: {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
diff: string;
|
|
1112
|
-
truncated: boolean;
|
|
1109
|
+
error: string;
|
|
1110
|
+
code?: "invalid_input" | undefined;
|
|
1113
1111
|
};
|
|
1114
1112
|
outputFormat: "json";
|
|
1115
|
-
status:
|
|
1113
|
+
status: 400;
|
|
1116
1114
|
input: {
|
|
1117
1115
|
param: {
|
|
1118
1116
|
workerId: string;
|
|
@@ -1120,11 +1118,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1120
1118
|
};
|
|
1121
1119
|
} | {
|
|
1122
1120
|
output: {
|
|
1123
|
-
|
|
1124
|
-
|
|
1121
|
+
workerId: string;
|
|
1122
|
+
baselineSha: string;
|
|
1123
|
+
diff: string;
|
|
1124
|
+
truncated: boolean;
|
|
1125
1125
|
};
|
|
1126
1126
|
outputFormat: "json";
|
|
1127
|
-
status:
|
|
1127
|
+
status: 200;
|
|
1128
1128
|
input: {
|
|
1129
1129
|
param: {
|
|
1130
1130
|
workerId: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
|
|
3
|
+
* covers `Team`; `reviewerKey` folds them into one comparable string. */
|
|
4
|
+
export declare const reviewerRefSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
5
|
+
__typename: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
login: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
slug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
}, z.core.$strip>>>;
|
|
9
|
+
/** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
|
|
10
|
+
* must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
|
|
11
|
+
export declare function reviewerKey(ref: z.infer<typeof reviewerRefSchema>): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
|
|
3
|
+
* covers `Team`; `reviewerKey` folds them into one comparable string. */
|
|
4
|
+
export const reviewerRefSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
__typename: z.string().nullish(),
|
|
7
|
+
login: z.string().nullish(),
|
|
8
|
+
slug: z.string().nullish(),
|
|
9
|
+
})
|
|
10
|
+
.nullish();
|
|
11
|
+
/** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
|
|
12
|
+
* must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
|
|
13
|
+
export function reviewerKey(ref) {
|
|
14
|
+
const name = ref?.login ?? ref?.slug;
|
|
15
|
+
return name ? `${ref?.__typename ?? '?'}:${name}` : null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=github-reviewer-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-reviewer-ref.js","sourceRoot":"","sources":["../../../src/server/forge/github-reviewer-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;0EAC0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC3B,CAAC;KACD,OAAO,EAAE,CAAC;AAEb;kGACkG;AAClG,MAAM,UAAU,WAAW,CAAC,GAAsC;IAChE,MAAM,IAAI,GAAG,GAAG,EAAE,KAAK,IAAI,GAAG,EAAE,IAAI,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { z } from 'zod';
|
|
|
10
10
|
import { githubRequestGate } from './github-request-gate.js';
|
|
11
11
|
import { refStatusQuery } from './github-ref-status-query.js';
|
|
12
12
|
import { mergedPullRequestChunk } from './github-merged-pr-chunk.js';
|
|
13
|
+
import { reviewerKey, reviewerRefSchema } from './github-reviewer-ref.js';
|
|
13
14
|
import { gh, githubContext, parseOwnerName } from './github-cli.js';
|
|
14
15
|
import { canonicalRepoRef, discoverRepoHandle, forgetRepoHandle, forgettingNameOnMiss, resolveRepoHandle, sharedRepoHandle } from './github-repo-handle.js';
|
|
15
16
|
export { parseOwnerName } from './github-cli.js';
|
|
@@ -975,7 +976,7 @@ export function __clearCommentsCacheForTests() {
|
|
|
975
976
|
// answer (an item or a confirmed absence) is cached, never an unavailable one.
|
|
976
977
|
const itemCache = new Map();
|
|
977
978
|
function itemCacheKey(repoRoot, kind, number) {
|
|
978
|
-
return `${repoRoot}\0${kind}#${number}`;
|
|
979
|
+
return `${githubContext(repoRoot).key}\0${kind}#${number}`;
|
|
979
980
|
}
|
|
980
981
|
export function forgetGithubItem(repoRoot, kind, number) {
|
|
981
982
|
itemCache.delete(itemCacheKey(repoRoot, kind, number));
|
|
@@ -1228,7 +1229,7 @@ function mockGithubCommentCounts(kind, numbers) {
|
|
|
1228
1229
|
}
|
|
1229
1230
|
return { available: true, counts };
|
|
1230
1231
|
}
|
|
1231
|
-
// Per-PR checks cache: keyed `
|
|
1232
|
+
// Per-PR checks cache: keyed `githubContext␀number`, same 60 s TTL as the list cache but BOUNDED. Lets
|
|
1232
1233
|
// a repeated visible-window hydration within a minute serve cached glyphs instead of re-querying.
|
|
1233
1234
|
const checksCache = new Map();
|
|
1234
1235
|
const CHECKS_CACHE_MAX = 500;
|
|
@@ -1249,8 +1250,9 @@ export async function fetchGithubChecks(repoRoot, numbers) {
|
|
|
1249
1250
|
const checks = {};
|
|
1250
1251
|
const misses = [];
|
|
1251
1252
|
const now = Date.now();
|
|
1253
|
+
const context = githubContext(repoRoot);
|
|
1252
1254
|
for (const n of wanted) {
|
|
1253
|
-
const hit = checksCache.get(`${
|
|
1255
|
+
const hit = checksCache.get(`${context.key}\0${n}`);
|
|
1254
1256
|
if (hit && now - hit.at < CACHE_MS)
|
|
1255
1257
|
checks[n] = hit.glyph;
|
|
1256
1258
|
else
|
|
@@ -1259,20 +1261,20 @@ export async function fetchGithubChecks(repoRoot, numbers) {
|
|
|
1259
1261
|
if (misses.length === 0)
|
|
1260
1262
|
return { available: true, checks };
|
|
1261
1263
|
try {
|
|
1262
|
-
const repoOut = await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner', '--jq', '.nameWithOwner']);
|
|
1264
|
+
const repoOut = await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner', '--jq', '.nameWithOwner'], undefined, undefined, context);
|
|
1263
1265
|
const ownerName = parseOwnerName(repoOut);
|
|
1264
1266
|
if (!ownerName)
|
|
1265
1267
|
return { available: false, reason: 'repository handle unavailable' };
|
|
1266
1268
|
const runGraphql = (query, variables) => {
|
|
1267
1269
|
const args = ghGraphqlArgs(query, variables);
|
|
1268
|
-
return gh(repoRoot, args);
|
|
1270
|
+
return gh(repoRoot, args, undefined, undefined, context);
|
|
1269
1271
|
};
|
|
1270
1272
|
const fetched = await fetchPrChecks(runGraphql, ownerName.owner, ownerName.name, misses);
|
|
1271
1273
|
for (const n of misses) {
|
|
1272
1274
|
// Absent (unknown/closed PR) caches as `null` so a nonexistent number isn't re-queried.
|
|
1273
1275
|
const glyph = n in fetched ? fetched[n] : null;
|
|
1274
1276
|
checks[n] = glyph;
|
|
1275
|
-
checksCache.set(`${
|
|
1277
|
+
checksCache.set(`${context.key}\0${n}`, { at: now, glyph });
|
|
1276
1278
|
}
|
|
1277
1279
|
while (checksCache.size > CHECKS_CACHE_MAX) {
|
|
1278
1280
|
const oldest = checksCache.keys().next().value;
|
|
@@ -1305,21 +1307,6 @@ function mockGithubChecks(numbers) {
|
|
|
1305
1307
|
* contract rather than restated, because the cockpit caps its batches by the same number and a
|
|
1306
1308
|
* client that guessed high would have every chip in a batch 400 instead of losing its tail. */
|
|
1307
1309
|
export const GH_REF_STATUS_MAX = REFERENCE_STATUS_MAX;
|
|
1308
|
-
/** A requested reviewer, as either connection spells them. `login` covers `User` and `Bot`, `slug`
|
|
1309
|
-
* covers `Team`; `reviewerKey` folds them into one comparable string. */
|
|
1310
|
-
const reviewerRefSchema = z
|
|
1311
|
-
.object({
|
|
1312
|
-
__typename: z.string().nullish(),
|
|
1313
|
-
login: z.string().nullish(),
|
|
1314
|
-
slug: z.string().nullish(),
|
|
1315
|
-
})
|
|
1316
|
-
.nullish();
|
|
1317
|
-
/** One reviewer as a comparable key, or `null` when GitHub named nobody we can match on — which
|
|
1318
|
-
* must never compare equal to another unnamed reviewer, hence `null` rather than a shared "". */
|
|
1319
|
-
function reviewerKey(ref) {
|
|
1320
|
-
const name = ref?.login ?? ref?.slug;
|
|
1321
|
-
return name ? `${ref?.__typename ?? '?'}:${name}` : null;
|
|
1322
|
-
}
|
|
1323
1310
|
const ghRefStatusPrSchema = z
|
|
1324
1311
|
.object({
|
|
1325
1312
|
state: z.string(),
|
|
@@ -1949,7 +1936,7 @@ function mockGithubRefStatus(prs, issues) {
|
|
|
1949
1936
|
*/
|
|
1950
1937
|
function commentsCacheKey(repoRoot, kind, number) {
|
|
1951
1938
|
// NUL separator: cannot appear in a filesystem path, so roots can never alias.
|
|
1952
|
-
return `${repoRoot}\0${kind}#${number}`;
|
|
1939
|
+
return `${githubContext(repoRoot).key}\0${kind}#${number}`;
|
|
1953
1940
|
}
|
|
1954
1941
|
function cachedGithubComments(key, refresh) {
|
|
1955
1942
|
const hit = commentsCache.get(key);
|
|
@@ -2238,18 +2225,18 @@ function mockGithubComments(kind, number) {
|
|
|
2238
2225
|
}
|
|
2239
2226
|
// ---- the driver -------------------------------------------------------------
|
|
2240
2227
|
/**
|
|
2241
|
-
* Cached availability probe so `GET /api/health` never pays a full listing. Keyed by
|
|
2228
|
+
* Cached availability probe so `GET /api/health` never pays a full listing. Keyed by GitHub context (root, host, account):
|
|
2242
2229
|
* every registered project reads its own slot, so the boot project's constant health refresh can't
|
|
2243
2230
|
* evict another project's answer (a single slot made `GET /automations` flap between "still being
|
|
2244
|
-
* checked" and available). One in-flight probe per
|
|
2231
|
+
* checked" and available). One in-flight probe per context dedupes a burst of reads.
|
|
2245
2232
|
*/
|
|
2246
2233
|
const DETECT_CACHE_MAX = 64;
|
|
2247
2234
|
const detectCache = new Map();
|
|
2248
2235
|
const detectInflight = new Map();
|
|
2249
|
-
async function probeGithub(repoRoot) {
|
|
2236
|
+
async function probeGithub(repoRoot, context) {
|
|
2250
2237
|
let result;
|
|
2251
2238
|
try {
|
|
2252
|
-
await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner'], 5_000);
|
|
2239
|
+
await gh(repoRoot, ['repo', 'view', '--json', 'nameWithOwner'], 5_000, undefined, context);
|
|
2253
2240
|
result = { available: true };
|
|
2254
2241
|
}
|
|
2255
2242
|
catch (err) {
|
|
@@ -2261,8 +2248,8 @@ async function probeGithub(repoRoot) {
|
|
|
2261
2248
|
: firstLine(message),
|
|
2262
2249
|
};
|
|
2263
2250
|
}
|
|
2264
|
-
detectCache.delete(
|
|
2265
|
-
detectCache.set(
|
|
2251
|
+
detectCache.delete(context.key); // re-insert so Map order tracks recency
|
|
2252
|
+
detectCache.set(context.key, { at: Date.now(), result });
|
|
2266
2253
|
while (detectCache.size > DETECT_CACHE_MAX) {
|
|
2267
2254
|
const oldest = detectCache.keys().next().value;
|
|
2268
2255
|
if (oldest === undefined)
|
|
@@ -2274,14 +2261,15 @@ async function probeGithub(repoRoot) {
|
|
|
2274
2261
|
async function detectGithub(repoRoot) {
|
|
2275
2262
|
if (productEnv('DRY_RUN') === '1')
|
|
2276
2263
|
return { available: true };
|
|
2277
|
-
const
|
|
2264
|
+
const context = githubContext(repoRoot);
|
|
2265
|
+
const hit = detectCache.get(context.key);
|
|
2278
2266
|
if (hit && Date.now() - hit.at < CACHE_MS)
|
|
2279
2267
|
return hit.result;
|
|
2280
|
-
const pending = detectInflight.get(
|
|
2268
|
+
const pending = detectInflight.get(context.key);
|
|
2281
2269
|
if (pending)
|
|
2282
2270
|
return pending;
|
|
2283
|
-
const probe = probeGithub(repoRoot).finally(() => detectInflight.delete(
|
|
2284
|
-
detectInflight.set(
|
|
2271
|
+
const probe = probeGithub(repoRoot, context).finally(() => detectInflight.delete(context.key));
|
|
2272
|
+
detectInflight.set(context.key, probe);
|
|
2285
2273
|
return probe;
|
|
2286
2274
|
}
|
|
2287
2275
|
/**
|
|
@@ -2306,7 +2294,7 @@ export const HEALTH_AVAILABILITY_TTL_MS = 10 * 60_000;
|
|
|
2306
2294
|
export function detectGithubCached(repoRoot) {
|
|
2307
2295
|
if (productEnv('DRY_RUN') === '1')
|
|
2308
2296
|
return { available: true };
|
|
2309
|
-
const hit = detectCache.get(repoRoot);
|
|
2297
|
+
const hit = detectCache.get(githubContext(repoRoot).key);
|
|
2310
2298
|
const cached = hit?.result ?? null;
|
|
2311
2299
|
const fresh = hit !== undefined && Date.now() - hit.at < HEALTH_AVAILABILITY_TTL_MS;
|
|
2312
2300
|
if (!fresh) {
|
|
@@ -2386,11 +2374,11 @@ export function evictGithubProjectCaches(repoRoot) {
|
|
|
2386
2374
|
mergeStateCache.delete(key);
|
|
2387
2375
|
});
|
|
2388
2376
|
commentsCache.forEach((_value, key) => {
|
|
2389
|
-
if (key.startsWith(`${
|
|
2377
|
+
if (key.startsWith(`${contextKey}\0`))
|
|
2390
2378
|
commentsCache.delete(key);
|
|
2391
2379
|
});
|
|
2392
2380
|
itemCache.forEach((_value, key) => {
|
|
2393
|
-
if (key.startsWith(`${
|
|
2381
|
+
if (key.startsWith(`${contextKey}\0`))
|
|
2394
2382
|
itemCache.delete(key);
|
|
2395
2383
|
});
|
|
2396
2384
|
}
|