@app-vitals/agent-admin 1.84.2 → 1.86.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/openapi.platform.json +71 -0
- package/package.json +2 -2
- package/src/admin-ui-installation-repos-pages.ts +114 -22
- package/src/admin-ui-installation-repos-pages.unit.test.ts +268 -0
- package/src/admin-ui-installation-repos.smoke.test.ts +26 -2
- package/src/admin-ui-pages.ts +1 -1
- package/src/admin-ui.ts +3 -1
- package/src/agents-api.smoke.test.ts +39 -0
- package/src/agents-api.ts +31 -1
- package/src/github-installation-wiring.ts +2 -0
- package/src/github-installation-wiring.unit.test.ts +1 -1
- package/src/github-repo-cache.ts +2 -0
- package/src/github-sync-cache.integration.test.ts +1 -1
- package/src/github-sync-cached-access.ts +53 -1
- package/src/github-sync-cached-access.unit.test.ts +114 -0
- package/src/github-sync.ts +30 -4
- package/src/github-sync.unit.test.ts +195 -0
- package/src/repo-access-rules.ts +3 -0
- package/src/user-repo-access-resolver.ts +27 -0
|
@@ -305,6 +305,30 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
305
305
|
expect(html.match(/id="github-sync-confirm-btn"/g)?.length).toBe(1);
|
|
306
306
|
});
|
|
307
307
|
|
|
308
|
+
it("renders skipped-org detail in the preview", async () => {
|
|
309
|
+
const { app } = setup({
|
|
310
|
+
agentsApi: () =>
|
|
311
|
+
json({
|
|
312
|
+
...PREVIEW,
|
|
313
|
+
skippedOrgs: [
|
|
314
|
+
{
|
|
315
|
+
org: "zed",
|
|
316
|
+
reason: "access listing is incomplete",
|
|
317
|
+
detail: {
|
|
318
|
+
lookupSnapshotFound: true,
|
|
319
|
+
crawls: [{ completedAt: "2026-01-01T00:00:00.000Z" }],
|
|
320
|
+
totalRepos: 31,
|
|
321
|
+
reposMissingAnswer: 30,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
}),
|
|
326
|
+
});
|
|
327
|
+
const html = await (await get(app, "/github-sync/confirm")).text();
|
|
328
|
+
expect(html).toContain("Lookup crawl complete (31 repos).");
|
|
329
|
+
expect(html).toContain("30 repos have no access answer yet.");
|
|
330
|
+
});
|
|
331
|
+
|
|
308
332
|
it("shows the reason for a skipped preview", async () => {
|
|
309
333
|
const { app } = setup({
|
|
310
334
|
agentsApi: () => json({ status: "skipped", reason: "user not found" }),
|
|
@@ -461,7 +485,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
461
485
|
);
|
|
462
486
|
expect(html).toContain('data-installation-sync="complete"');
|
|
463
487
|
expect(html).toContain("2 of 2 repos");
|
|
464
|
-
expect(html).toContain("
|
|
488
|
+
expect(html).toContain("Synced Nov 20, 2:00 AM PST");
|
|
465
489
|
expect(html).toContain('id="repos-uncovered-warning"');
|
|
466
490
|
// The page reads the cached view only: no GitHub-backed route.
|
|
467
491
|
expect(
|
|
@@ -490,7 +514,7 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
490
514
|
);
|
|
491
515
|
expect(html).toContain("GitHub said <no>");
|
|
492
516
|
expect(html).toContain("rate limit resets");
|
|
493
|
-
expect(html).toContain("
|
|
517
|
+
expect(html).toContain("resets Nov 20, 3:00 AM PST");
|
|
494
518
|
expect(html).not.toContain("repos-uncovered-warning");
|
|
495
519
|
});
|
|
496
520
|
|
package/src/admin-ui-pages.ts
CHANGED
|
@@ -1749,7 +1749,7 @@ export function renderAgentDetailPage(
|
|
|
1749
1749
|
<button type="submit" class="btn btn-primary">Add</button>
|
|
1750
1750
|
</div>
|
|
1751
1751
|
</form>
|
|
1752
|
-
${opts?.installationSync ? renderInstallationSyncStatus(opts.installationSync) : ""}
|
|
1752
|
+
${opts?.installationSync ? renderInstallationSyncStatus(opts.installationSync, timezone) : ""}
|
|
1753
1753
|
<div class="data-table-wrapper">
|
|
1754
1754
|
<table class="data-table">
|
|
1755
1755
|
<thead>
|
package/src/admin-ui.ts
CHANGED
|
@@ -2270,7 +2270,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2270
2270
|
}
|
|
2271
2271
|
}
|
|
2272
2272
|
}
|
|
2273
|
-
return html(renderInstallationReposBody(view, { appIdMismatch }));
|
|
2273
|
+
return html(renderInstallationReposBody(view, { appIdMismatch, timezone }));
|
|
2274
2274
|
});
|
|
2275
2275
|
|
|
2276
2276
|
// IRM-3.2: the single Sync confirm (over the IRM-3.1 preview) and its apply.
|
|
@@ -2288,6 +2288,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2288
2288
|
renderSyncConfirm(
|
|
2289
2289
|
c.req.param("id") ?? "",
|
|
2290
2290
|
(await res.json()) as GithubSyncPreviewView,
|
|
2291
|
+
timezone,
|
|
2291
2292
|
),
|
|
2292
2293
|
);
|
|
2293
2294
|
});
|
|
@@ -2357,6 +2358,7 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
2357
2358
|
warnings,
|
|
2358
2359
|
)
|
|
2359
2360
|
: [],
|
|
2361
|
+
timezone,
|
|
2360
2362
|
),
|
|
2361
2363
|
);
|
|
2362
2364
|
},
|
|
@@ -7722,6 +7722,45 @@ describe("admin API — agent App installation repos and GitHub Sync (IRM-1.2, I
|
|
|
7722
7722
|
expect(state.repos).toEqual(["acme-eng/repo-2"]);
|
|
7723
7723
|
});
|
|
7724
7724
|
|
|
7725
|
+
it("sync preview and apply carry skippedOrgs detail next to the unchanged reason", async () => {
|
|
7726
|
+
const accessRows = [
|
|
7727
|
+
{ ...accessRow("repo-1", "ok", true), checkedAt: T0, attempts: 0 },
|
|
7728
|
+
{
|
|
7729
|
+
...accessRow("repo-2", "error"),
|
|
7730
|
+
checkedAt: T0,
|
|
7731
|
+
attempts: 2,
|
|
7732
|
+
lastError: "rate limited",
|
|
7733
|
+
},
|
|
7734
|
+
];
|
|
7735
|
+
const expected = {
|
|
7736
|
+
org: "acme-eng",
|
|
7737
|
+
reason: "access data is incomplete",
|
|
7738
|
+
detail: {
|
|
7739
|
+
lookupSnapshotFound: true,
|
|
7740
|
+
totalRepos: 3,
|
|
7741
|
+
reposWithOkAccess: 1,
|
|
7742
|
+
reposMissingAnswer: 2,
|
|
7743
|
+
errorRows: 1,
|
|
7744
|
+
terminalRows: 0,
|
|
7745
|
+
maxAttempts: 2,
|
|
7746
|
+
rowErrors: ["rate limited"],
|
|
7747
|
+
},
|
|
7748
|
+
};
|
|
7749
|
+
const { app } = setup({ accessRows });
|
|
7750
|
+
const pre = (await (
|
|
7751
|
+
await app.request(previewUrl, { headers: asAdmin })
|
|
7752
|
+
).json()) as { skippedOrgs: unknown[]; warnings: string[] };
|
|
7753
|
+
expect(pre.skippedOrgs).toMatchObject([expected]);
|
|
7754
|
+
expect(pre.warnings).toEqual([
|
|
7755
|
+
"acme-eng: skipped (access data is incomplete)",
|
|
7756
|
+
]);
|
|
7757
|
+
const { app: app2 } = setup({ accessRows });
|
|
7758
|
+
const applied = (await (
|
|
7759
|
+
await apply(app2, { appRemoves: ["acme-eng/repo-2"] })
|
|
7760
|
+
).json()) as { skippedOrgs: unknown[] };
|
|
7761
|
+
expect(applied.skippedOrgs).toMatchObject([expected]);
|
|
7762
|
+
});
|
|
7763
|
+
|
|
7725
7764
|
it("sync preview reports a failing open-work port as a warning", async () => {
|
|
7726
7765
|
const { app } = setup({
|
|
7727
7766
|
openWork: {
|
package/src/agents-api.ts
CHANGED
|
@@ -722,8 +722,38 @@ const OpenWorkItemSchema = z.object({
|
|
|
722
722
|
title: z.string().optional(),
|
|
723
723
|
});
|
|
724
724
|
|
|
725
|
+
const OrgSkipDetailSchema = z
|
|
726
|
+
.object({
|
|
727
|
+
lookupSnapshotFound: z.boolean().optional(),
|
|
728
|
+
crawls: z
|
|
729
|
+
.array(
|
|
730
|
+
z.object({
|
|
731
|
+
completedAt: z.string().nullable(),
|
|
732
|
+
lastError: z.string().nullable().optional(),
|
|
733
|
+
rateLimitResetAt: z.string().nullable().optional(),
|
|
734
|
+
}),
|
|
735
|
+
)
|
|
736
|
+
.optional(),
|
|
737
|
+
totalRepos: z.number().int().optional(),
|
|
738
|
+
reposWithOkAccess: z.number().int().optional(),
|
|
739
|
+
reposMissingAnswer: z.number().int().optional(),
|
|
740
|
+
errorRows: z.number().int().optional(),
|
|
741
|
+
terminalRows: z.number().int().optional(),
|
|
742
|
+
maxAttempts: z.number().int().optional(),
|
|
743
|
+
rowErrors: z.array(z.string()).optional(),
|
|
744
|
+
oldestCheckedAt: z.string().optional(),
|
|
745
|
+
})
|
|
746
|
+
.openapi("GithubSyncOrgSkipDetail");
|
|
747
|
+
|
|
725
748
|
const SkippedOrgsSchema = z.array(
|
|
726
|
-
z.object({
|
|
749
|
+
z.object({
|
|
750
|
+
org: z.string(),
|
|
751
|
+
reason: z.string(),
|
|
752
|
+
detail: OrgSkipDetailSchema.optional().openapi({
|
|
753
|
+
description:
|
|
754
|
+
"Why the org was skipped, for cached data: whether the lookup snapshot was found, each crawl's completedAt/lastError/rateLimitResetAt, repo and access-row counts, and the oldest-checked time when stale.",
|
|
755
|
+
}),
|
|
756
|
+
}),
|
|
727
757
|
);
|
|
728
758
|
|
|
729
759
|
const GithubSyncPreviewSchema = z
|
|
@@ -254,7 +254,7 @@ describe("createGithubSync lookup snapshot read", () => {
|
|
|
254
254
|
const { svc } = build(null, [lookupAcme("some-other-account")]);
|
|
255
255
|
const preview = await svc.preview("a1");
|
|
256
256
|
if (preview.status !== "previewed") throw new Error(preview.status);
|
|
257
|
-
expect(preview.plan.skippedOrgs).
|
|
257
|
+
expect(preview.plan.skippedOrgs).toMatchObject([
|
|
258
258
|
{ org: "acme", reason: "access data is incomplete" },
|
|
259
259
|
]);
|
|
260
260
|
});
|
package/src/github-repo-cache.ts
CHANGED
|
@@ -69,7 +69,7 @@ describe("sync preview over the cache", () => {
|
|
|
69
69
|
const r = await preview(cache, now);
|
|
70
70
|
if (r.status !== "previewed") throw new Error(r.status);
|
|
71
71
|
expect(r.plan.removedRepos).toEqual([]);
|
|
72
|
-
expect(r.plan.skippedOrgs).
|
|
72
|
+
expect(r.plan.skippedOrgs).toMatchObject([
|
|
73
73
|
{ org: "acme", reason: "access data is incomplete" },
|
|
74
74
|
]);
|
|
75
75
|
});
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
canPushForRole,
|
|
23
23
|
type OrgAccessResult,
|
|
24
|
+
type OrgSkipDetail,
|
|
24
25
|
type ResolvedRepoAccess,
|
|
25
26
|
type UserRepoAccessResult,
|
|
26
27
|
} from "./user-repo-access-resolver.ts";
|
|
@@ -29,7 +30,13 @@ import type { RepoRole } from "./github-lookup-client.ts";
|
|
|
29
30
|
export interface CachedOrgInput {
|
|
30
31
|
org: string;
|
|
31
32
|
/** completedAt of each crawl snapshot this org depends on; null = not completed. Empty = none needed. */
|
|
32
|
-
crawls: {
|
|
33
|
+
crawls: {
|
|
34
|
+
completedAt: Date | null;
|
|
35
|
+
lastError?: string | null;
|
|
36
|
+
rateLimitResetAt?: Date | null;
|
|
37
|
+
}[];
|
|
38
|
+
/** Whether the lookup crawl snapshot was found (omit when no lookup source is wired). */
|
|
39
|
+
lookupSnapshotFound?: boolean;
|
|
33
40
|
/** True when a crawl snapshot that must exist does not. */
|
|
34
41
|
crawlMissing?: boolean;
|
|
35
42
|
/** Every repo (full name) that needs an answer. */
|
|
@@ -50,6 +57,49 @@ const ROLES = new Set<string>([
|
|
|
50
57
|
const nameOf = (fullName: string): string =>
|
|
51
58
|
fullName.slice(fullName.indexOf("/") + 1).toLowerCase();
|
|
52
59
|
|
|
60
|
+
function skipDetail(
|
|
61
|
+
o: CachedOrgInput,
|
|
62
|
+
answers: { row?: CachedAccessRow }[],
|
|
63
|
+
oldest?: Date,
|
|
64
|
+
): OrgSkipDetail {
|
|
65
|
+
const rows = answers.flatMap((a) => (a.row ? [a.row] : []));
|
|
66
|
+
const ok = rows.filter((r) => r.status === "ok").length;
|
|
67
|
+
const attempts = rows.flatMap((r) =>
|
|
68
|
+
r.attempts === undefined ? [] : [r.attempts],
|
|
69
|
+
);
|
|
70
|
+
const rowErrors = [
|
|
71
|
+
...new Set(
|
|
72
|
+
rows.flatMap((r) =>
|
|
73
|
+
r.status !== "ok" && r.lastError ? [r.lastError] : [],
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
].slice(0, 3);
|
|
77
|
+
return {
|
|
78
|
+
...(o.lookupSnapshotFound === undefined
|
|
79
|
+
? {}
|
|
80
|
+
: { lookupSnapshotFound: o.lookupSnapshotFound }),
|
|
81
|
+
crawls: o.crawls.map((c) => ({
|
|
82
|
+
completedAt: c.completedAt ? c.completedAt.toISOString() : null,
|
|
83
|
+
...(c.lastError === undefined ? {} : { lastError: c.lastError }),
|
|
84
|
+
...(c.rateLimitResetAt === undefined
|
|
85
|
+
? {}
|
|
86
|
+
: {
|
|
87
|
+
rateLimitResetAt: c.rateLimitResetAt
|
|
88
|
+
? c.rateLimitResetAt.toISOString()
|
|
89
|
+
: null,
|
|
90
|
+
}),
|
|
91
|
+
})),
|
|
92
|
+
totalRepos: o.repos.length,
|
|
93
|
+
reposWithOkAccess: ok,
|
|
94
|
+
reposMissingAnswer: answers.length - ok,
|
|
95
|
+
errorRows: rows.filter((r) => r.status === "error").length,
|
|
96
|
+
terminalRows: rows.filter((r) => r.status === "terminal").length,
|
|
97
|
+
...(attempts.length > 0 ? { maxAttempts: Math.max(...attempts) } : {}),
|
|
98
|
+
...(rowErrors.length > 0 ? { rowErrors } : {}),
|
|
99
|
+
...(oldest ? { oldestCheckedAt: oldest.toISOString() } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
53
103
|
export function buildCachedAccess(opts: {
|
|
54
104
|
username: string;
|
|
55
105
|
now: Date;
|
|
@@ -76,6 +126,7 @@ export function buildCachedAccess(opts: {
|
|
|
76
126
|
repos: [],
|
|
77
127
|
unresolved: missing.length,
|
|
78
128
|
reason: INCOMPLETE_ACCESS_REASON,
|
|
129
|
+
detail: skipDetail(o, answers),
|
|
79
130
|
});
|
|
80
131
|
continue;
|
|
81
132
|
}
|
|
@@ -93,6 +144,7 @@ export function buildCachedAccess(opts: {
|
|
|
93
144
|
repos: [],
|
|
94
145
|
unresolved: 0,
|
|
95
146
|
reason: staleAccessReason(unknownTime ? undefined : oldest),
|
|
147
|
+
detail: skipDetail(o, answers, unknownTime ? undefined : oldest),
|
|
96
148
|
});
|
|
97
149
|
continue;
|
|
98
150
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { buildCachedAccess } from "./github-sync-cached-access.ts";
|
|
3
|
+
|
|
4
|
+
const NOW = new Date("2026-11-20T12:00:00.000Z");
|
|
5
|
+
const HOUR = 3_600_000;
|
|
6
|
+
const build = (o: Parameters<typeof buildCachedAccess>[0]["orgs"][number]) =>
|
|
7
|
+
buildCachedAccess({
|
|
8
|
+
username: "octo",
|
|
9
|
+
now: NOW,
|
|
10
|
+
maxAgeMs: 24 * HOUR,
|
|
11
|
+
orgs: [o],
|
|
12
|
+
}).orgs[0];
|
|
13
|
+
|
|
14
|
+
const row = (repo: string, over: Record<string, unknown> = {}) => ({
|
|
15
|
+
repo,
|
|
16
|
+
status: "ok",
|
|
17
|
+
canPush: true,
|
|
18
|
+
checkedAt: new Date(NOW.getTime() - HOUR),
|
|
19
|
+
...over,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe("buildCachedAccess skip detail", () => {
|
|
23
|
+
it("reports a missing lookup snapshot", () => {
|
|
24
|
+
const r = build({
|
|
25
|
+
org: "acme",
|
|
26
|
+
crawls: [],
|
|
27
|
+
crawlMissing: true,
|
|
28
|
+
lookupSnapshotFound: false,
|
|
29
|
+
repos: [],
|
|
30
|
+
rows: [],
|
|
31
|
+
});
|
|
32
|
+
expect(r?.reason).toBe("access data is incomplete");
|
|
33
|
+
expect(r?.detail).toMatchObject({
|
|
34
|
+
lookupSnapshotFound: false,
|
|
35
|
+
totalRepos: 0,
|
|
36
|
+
reposWithOkAccess: 0,
|
|
37
|
+
reposMissingAnswer: 0,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("reports an incomplete crawl with its lastError and rateLimitResetAt", () => {
|
|
42
|
+
const reset = new Date("2026-11-20T13:00:00.000Z");
|
|
43
|
+
const r = build({
|
|
44
|
+
org: "acme",
|
|
45
|
+
crawls: [
|
|
46
|
+
{ completedAt: null, lastError: "boom", rateLimitResetAt: reset },
|
|
47
|
+
],
|
|
48
|
+
lookupSnapshotFound: true,
|
|
49
|
+
repos: ["acme/a"],
|
|
50
|
+
rows: [row("a")],
|
|
51
|
+
});
|
|
52
|
+
expect(r?.detail?.lookupSnapshotFound).toBe(true);
|
|
53
|
+
expect(r?.detail?.crawls).toEqual([
|
|
54
|
+
{
|
|
55
|
+
completedAt: null,
|
|
56
|
+
lastError: "boom",
|
|
57
|
+
rateLimitResetAt: reset.toISOString(),
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("counts repos without an ok row, error and terminal rows", () => {
|
|
63
|
+
const r = build({
|
|
64
|
+
org: "acme",
|
|
65
|
+
crawls: [{ completedAt: NOW }],
|
|
66
|
+
repos: ["acme/a", "acme/b", "acme/c", "acme/d"],
|
|
67
|
+
rows: [
|
|
68
|
+
row("a"),
|
|
69
|
+
row("b", { status: "error", attempts: 3, lastError: "rate limited" }),
|
|
70
|
+
row("c", { status: "terminal", attempts: 5, lastError: "gone" }),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
expect(r?.reason).toBe("access data is incomplete");
|
|
74
|
+
expect(r?.detail).toMatchObject({
|
|
75
|
+
totalRepos: 4,
|
|
76
|
+
reposWithOkAccess: 1,
|
|
77
|
+
reposMissingAnswer: 3,
|
|
78
|
+
errorRows: 1,
|
|
79
|
+
terminalRows: 1,
|
|
80
|
+
maxAttempts: 5,
|
|
81
|
+
rowErrors: ["rate limited", "gone"],
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("reports the oldest-checked time for stale data", () => {
|
|
86
|
+
const old = new Date(NOW.getTime() - 48 * HOUR);
|
|
87
|
+
const r = build({
|
|
88
|
+
org: "acme",
|
|
89
|
+
crawls: [{ completedAt: NOW }],
|
|
90
|
+
repos: ["acme/a"],
|
|
91
|
+
rows: [row("a", { checkedAt: old })],
|
|
92
|
+
});
|
|
93
|
+
expect(r?.reason).toBe(
|
|
94
|
+
`access data is stale (checked ${old.toISOString()})`,
|
|
95
|
+
);
|
|
96
|
+
expect(r?.detail).toMatchObject({
|
|
97
|
+
oldestCheckedAt: old.toISOString(),
|
|
98
|
+
totalRepos: 1,
|
|
99
|
+
reposWithOkAccess: 1,
|
|
100
|
+
reposMissingAnswer: 0,
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("has no detail for a usable org", () => {
|
|
105
|
+
const r = build({
|
|
106
|
+
org: "acme",
|
|
107
|
+
crawls: [{ completedAt: NOW }],
|
|
108
|
+
repos: ["acme/a"],
|
|
109
|
+
rows: [row("a")],
|
|
110
|
+
});
|
|
111
|
+
expect(r?.status).toBe("ok");
|
|
112
|
+
expect(r?.detail).toBeUndefined();
|
|
113
|
+
});
|
|
114
|
+
});
|
package/src/github-sync.ts
CHANGED
|
@@ -56,7 +56,10 @@ import {
|
|
|
56
56
|
previewRepoRemovalWork,
|
|
57
57
|
repoLostAccessBlockReason,
|
|
58
58
|
} from "./repo-removal-open-work.ts";
|
|
59
|
-
import type {
|
|
59
|
+
import type {
|
|
60
|
+
OrgSkipDetail,
|
|
61
|
+
UserRepoAccessResult,
|
|
62
|
+
} from "./user-repo-access-resolver.ts";
|
|
60
63
|
|
|
61
64
|
/** `planHash` of the audit row a sync apply writes. */
|
|
62
65
|
export const GITHUB_SYNC_AUDIT_PLAN_HASH = "sync:apply";
|
|
@@ -163,6 +166,7 @@ export function planGithubSync(input: GithubSyncPlanInput): GithubSyncPlan {
|
|
|
163
166
|
: [...configured.values()];
|
|
164
167
|
|
|
165
168
|
const skipReasons = new Map<string, string>();
|
|
169
|
+
const skipDetails = new Map<string, OrgSkipDetail>();
|
|
166
170
|
const notApplied = new Map<string, NotAppliedRepo>();
|
|
167
171
|
const leave = (repo: string, reason: string) => {
|
|
168
172
|
if (requested)
|
|
@@ -171,9 +175,11 @@ export function planGithubSync(input: GithubSyncPlanInput): GithubSyncPlan {
|
|
|
171
175
|
// Unknown is never none: false (with the reason recorded) for a skipped org.
|
|
172
176
|
const orgUsable = (repo: string): boolean => {
|
|
173
177
|
const org = repoOrg(repo);
|
|
174
|
-
const
|
|
178
|
+
const result = orgResults.get(lower(org));
|
|
179
|
+
const reason = orgSkipReason(result);
|
|
175
180
|
if (!reason) return true;
|
|
176
181
|
skipReasons.set(org, reason);
|
|
182
|
+
if (result?.detail) skipDetails.set(org, result.detail);
|
|
177
183
|
leave(repo, `skipped for org: ${reason}`);
|
|
178
184
|
return false;
|
|
179
185
|
};
|
|
@@ -224,6 +230,7 @@ export function planGithubSync(input: GithubSyncPlanInput): GithubSyncPlan {
|
|
|
224
230
|
const skippedOrgs = sorted(skipReasons.keys()).map((org) => ({
|
|
225
231
|
org,
|
|
226
232
|
reason: skipReasons.get(org) as string,
|
|
233
|
+
...(skipDetails.has(org) ? { detail: skipDetails.get(org) } : {}),
|
|
227
234
|
}));
|
|
228
235
|
return {
|
|
229
236
|
skipped: false,
|
|
@@ -244,6 +251,8 @@ export interface CachedLookupOrg {
|
|
|
244
251
|
org: string;
|
|
245
252
|
completedAt: Date | null;
|
|
246
253
|
repos: readonly string[];
|
|
254
|
+
lastError?: string | null;
|
|
255
|
+
rateLimitResetAt?: Date | null;
|
|
247
256
|
}
|
|
248
257
|
|
|
249
258
|
/** Default freshness bound: the refresher's staleness cap (the longest data is left unrefreshed). */
|
|
@@ -501,8 +510,22 @@ export class GithubSyncService {
|
|
|
501
510
|
repos.set(key(r), r);
|
|
502
511
|
}
|
|
503
512
|
const crawls = [
|
|
504
|
-
...(inst && snap
|
|
505
|
-
|
|
513
|
+
...(inst && snap
|
|
514
|
+
? [
|
|
515
|
+
{
|
|
516
|
+
completedAt: snap.completedAt,
|
|
517
|
+
lastError: snap.lastError,
|
|
518
|
+
rateLimitResetAt: snap.rateLimitResetAt,
|
|
519
|
+
},
|
|
520
|
+
]
|
|
521
|
+
: []),
|
|
522
|
+
...lk.map((l) => ({
|
|
523
|
+
completedAt: l.completedAt,
|
|
524
|
+
...(l.lastError === undefined ? {} : { lastError: l.lastError }),
|
|
525
|
+
...(l.rateLimitResetAt === undefined
|
|
526
|
+
? {}
|
|
527
|
+
: { rateLimitResetAt: l.rateLimitResetAt }),
|
|
528
|
+
})),
|
|
506
529
|
];
|
|
507
530
|
let rows: Awaited<ReturnType<InstallationCachePort["getAccessRows"]>> =
|
|
508
531
|
[];
|
|
@@ -522,6 +545,9 @@ export class GithubSyncService {
|
|
|
522
545
|
inputs.push({
|
|
523
546
|
org,
|
|
524
547
|
crawls,
|
|
548
|
+
...(this.deps.lookupRepos !== undefined
|
|
549
|
+
? { lookupSnapshotFound: lk.length > 0 }
|
|
550
|
+
: {}),
|
|
525
551
|
// A read failure, an installed org with no crawl, or a lookup source with no crawl of this org.
|
|
526
552
|
crawlMissing:
|
|
527
553
|
failed ||
|