@kana-ai/edgar-ext-github 0.1.2 → 0.1.4
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/README.md +130 -74
- package/dist/src/api/app.d.ts +25 -6
- package/dist/src/api/app.js +72 -9
- package/dist/src/api/client.d.ts +9 -6
- package/dist/src/api/client.js +58 -19
- package/dist/src/api/commits.d.ts +4 -0
- package/dist/src/api/commits.js +69 -0
- package/dist/src/api/failures.d.ts +4 -0
- package/dist/src/api/failures.js +14 -1
- package/dist/src/feed/alerts.d.ts +9 -3
- package/dist/src/feed/alerts.js +66 -6
- package/dist/src/feed/service.d.ts +10 -1
- package/dist/src/feed/service.js +79 -16
- package/dist/src/index.d.ts +97 -1
- package/dist/src/index.js +17 -4
- package/dist/src/schemas/config.d.ts +1 -0
- package/dist/src/schemas/config.js +73 -29
- package/dist/src/schemas/github.d.ts +121 -1
- package/dist/src/schemas/github.js +37 -2
- package/dist/src/schemas/tools.d.ts +159 -2
- package/dist/src/schemas/tools.js +129 -6
- package/dist/src/tools/alerts.js +1 -0
- package/dist/src/tools/branch.d.ts +12 -0
- package/dist/src/tools/branch.js +69 -1
- package/dist/src/tools/pull-request.d.ts +55 -7
- package/dist/src/tools/pull-request.js +131 -42
- package/dist/src/tools/revert.d.ts +27 -0
- package/dist/src/tools/revert.js +98 -0
- package/dist/src/tools/screenshot.d.ts +1 -1
- package/dist/src/tools/screenshot.js +25 -11
- package/dist/src/tracker/cards.d.ts +1 -1
- package/dist/src/tracker/cards.js +84 -8
- package/dist/src/tracker/comments.d.ts +14 -2
- package/dist/src/tracker/comments.js +100 -4
- package/dist/src/tracker/port.d.ts +1 -1
- package/dist/src/tracker/port.js +4 -6
- package/dist/src/tracker/read-link.d.ts +2 -0
- package/dist/src/tracker/read-link.js +23 -0
- package/dist/src/tracker/states.d.ts +14 -3
- package/dist/src/tracker/states.js +37 -6
- package/dist/src/tracker/tools.d.ts +27 -0
- package/dist/src/tracker/tools.js +63 -7
- package/dist/src/tracker/transitions.d.ts +14 -3
- package/dist/src/tracker/transitions.js +57 -10
- package/edgar-extension.json +121 -7
- package/package.json +3 -3
- package/schemas/attach_screenshot.in.json +19 -0
- package/schemas/config.json +49 -23
- package/schemas/create_card.in.json +4 -0
- package/schemas/delete_closed_branches.in.json +26 -0
- package/schemas/delete_closed_branches.out.json +22 -0
- package/schemas/find_revert_pull_request.in.json +21 -0
- package/schemas/find_revert_pull_request.out.json +14 -0
- package/schemas/list_pull_requests.out.json +5 -1
- package/schemas/mark_seen.in.json +11 -0
- package/schemas/mark_seen.out.json +10 -0
- package/schemas/merged_pull_request.in.json +17 -0
- package/schemas/merged_pull_request.out.json +18 -0
- package/schemas/open_pull_request.in.json +73 -1
- package/schemas/park.in.json +15 -0
- package/schemas/park.out.json +10 -0
- package/schemas/pull_request_state.out.json +10 -1
- package/schemas/release_follow_ups.in.json +5 -0
- package/schemas/retitle.in.json +16 -0
- package/schemas/retitle.out.json +13 -0
- package/schemas/revert_pull_request.in.json +11 -0
- package/schemas/revert_pull_request.out.json +14 -0
- package/schemas/set_priority.in.json +16 -0
- package/schemas/set_priority.out.json +10 -0
- package/schemas/update_pull_request.in.json +28 -1
- package/schemas/wait_for_review.out.json +10 -1
package/dist/src/api/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Failure, type Result } from "@kana-ai/edgar-sdk";
|
|
1
|
+
import { type Failure, type GitScope, type Result } from "@kana-ai/edgar-sdk";
|
|
2
2
|
/** How long before its expiry a cached installation token is minted again. */
|
|
3
3
|
export declare const RENEW_BEFORE_MS: number;
|
|
4
4
|
/** The `[extensions.github] app` table: the App's id (or client id) and its installation's id. */
|
|
@@ -13,9 +13,28 @@ export interface Held {
|
|
|
13
13
|
}
|
|
14
14
|
/** The JWT that signs the App in, RS256 with its private key, issued a minute back for clock drift and valid for nine minutes; a key that is not a PEM private key is `unauthenticated`. */
|
|
15
15
|
export declare function appJwt(app: App, pem: string, now?: number): Result<string, Failure>;
|
|
16
|
-
/**
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/** What one installation token covers beyond the whole installation: the scope of a git step, or the one repository, as `owner/name`, that an API call reads or writes. */
|
|
17
|
+
export type Cover = {
|
|
18
|
+
readonly kind: "git";
|
|
19
|
+
readonly scope: GitScope;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "api";
|
|
22
|
+
readonly repository: string;
|
|
23
|
+
readonly access: "read" | "write";
|
|
24
|
+
};
|
|
25
|
+
/** The installation token minted for `app` and `cover` that is still good at `now`, past which it is minted again. */
|
|
26
|
+
export declare function heldToken(app: App, now?: number, cover?: Cover): Held | undefined;
|
|
27
|
+
/** Keeps a minted installation token of `cover` in this process's memory until five minutes before `expires_at`. */
|
|
28
|
+
export declare function holdToken(app: App, token: string, expiresAt: string, cover?: Cover): Held;
|
|
29
|
+
/** The permissions GitHub granted an installation, by name, such as `{ contents: "write", workflows: "write" }`. */
|
|
30
|
+
export type Granted = Readonly<Record<string, string>>;
|
|
31
|
+
/** The permissions held for `app`'s installation that are still good at `now`. */
|
|
32
|
+
export declare function heldGranted(app: App, now?: number): Granted | undefined;
|
|
33
|
+
/** Keeps the permissions `app`'s installation was granted in this process's memory for an hour. */
|
|
34
|
+
export declare function holdGranted(app: App, permissions: Granted, now?: number): Granted;
|
|
35
|
+
/** Whether a mint for `cover` needs the installation's granted permissions: a push, to ask for `workflows` when it is granted, and an API read, to ask for each granted permission at `read`. */
|
|
36
|
+
export declare function needsGrant(cover?: Cover): boolean;
|
|
37
|
+
/** What a mint asks GitHub for, from the installation's `permissions` when `needsGrant`. With no cover, the installation's every repository and permission, for a call that spans repositories. For a git step, only its repository, by name, and only the contents access it needs, plus `workflows: write` for a push when the installation holds it, so a change to workflow files still pushes. For an API call, only its repository: at `read` for each granted permission the tools read with, or with every granted permission for a write. */
|
|
38
|
+
export declare function mintBody(cover?: Cover, permissions?: Granted): Record<string, unknown>;
|
|
39
|
+
/** Forgets every held token and grant, for a test that starts clean. */
|
|
21
40
|
export declare function forgetTokens(): void;
|
package/dist/src/api/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPrivateKey, sign } from "node:crypto";
|
|
2
|
-
import { attempt, permanentFailure } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { attempt, permanentFailure, } from "@kana-ai/edgar-sdk";
|
|
3
3
|
/** How long before its expiry a cached installation token is minted again. */
|
|
4
4
|
export const RENEW_BEFORE_MS = 5 * 60_000;
|
|
5
5
|
const held = new Map();
|
|
@@ -16,19 +16,82 @@ export function appJwt(app, pem, now = Date.now()) {
|
|
|
16
16
|
cause: "GITHUB_TOKEN holds the App key when [extensions.github] app is set",
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/** The key of a held token: the App's installation, and what the token covers, or nothing for the installation's token. */
|
|
20
|
+
const keyOf = (app, cover) => {
|
|
21
|
+
const installation = `${String(app.id)}:${String(app.installation)}`;
|
|
22
|
+
if (cover === undefined)
|
|
23
|
+
return installation;
|
|
24
|
+
const repository = cover.kind === "git" ? (cover.scope.repository ?? "*") : cover.repository;
|
|
25
|
+
const access = cover.kind === "git" ? cover.scope.access : cover.access;
|
|
26
|
+
return `${installation}:${cover.kind}:${repository}:${access}`;
|
|
27
|
+
};
|
|
28
|
+
/** The installation token minted for `app` and `cover` that is still good at `now`, past which it is minted again. */
|
|
29
|
+
export function heldToken(app, now = Date.now(), cover) {
|
|
30
|
+
const found = held.get(keyOf(app, cover));
|
|
23
31
|
return found !== undefined && found.expiresAt - RENEW_BEFORE_MS > now ? found : undefined;
|
|
24
32
|
}
|
|
25
|
-
/** Keeps a minted installation token in this process's memory until five minutes before `expires_at`. */
|
|
26
|
-
export function holdToken(app, token, expiresAt) {
|
|
33
|
+
/** Keeps a minted installation token of `cover` in this process's memory until five minutes before `expires_at`. */
|
|
34
|
+
export function holdToken(app, token, expiresAt, cover) {
|
|
27
35
|
const minted = { token, expiresAt: Date.parse(expiresAt) };
|
|
28
|
-
held.set(keyOf(app), minted);
|
|
36
|
+
held.set(keyOf(app, cover), minted);
|
|
29
37
|
return minted;
|
|
30
38
|
}
|
|
31
|
-
/**
|
|
39
|
+
/** How long the permissions an installation was granted are held before they are read again: as long as an installation token lives. */
|
|
40
|
+
const GRANTED_FOR_MS = 60 * 60_000;
|
|
41
|
+
const granted = new Map();
|
|
42
|
+
/** The permissions held for `app`'s installation that are still good at `now`. */
|
|
43
|
+
export function heldGranted(app, now = Date.now()) {
|
|
44
|
+
const found = granted.get(keyOf(app));
|
|
45
|
+
return found !== undefined && found.until > now ? found.permissions : undefined;
|
|
46
|
+
}
|
|
47
|
+
/** Keeps the permissions `app`'s installation was granted in this process's memory for an hour. */
|
|
48
|
+
export function holdGranted(app, permissions, now = Date.now()) {
|
|
49
|
+
granted.set(keyOf(app), { permissions, until: now + GRANTED_FOR_MS });
|
|
50
|
+
return permissions;
|
|
51
|
+
}
|
|
52
|
+
/** The repository permissions the tools read with, each of which GitHub grants at `read`; `workflows`, for one, has no read level. */
|
|
53
|
+
const READABLE = new Set([
|
|
54
|
+
"actions",
|
|
55
|
+
"administration",
|
|
56
|
+
"checks",
|
|
57
|
+
"contents",
|
|
58
|
+
"issues",
|
|
59
|
+
"metadata",
|
|
60
|
+
"pull_requests",
|
|
61
|
+
"security_events",
|
|
62
|
+
"statuses",
|
|
63
|
+
"vulnerability_alerts",
|
|
64
|
+
]);
|
|
65
|
+
/** Whether a mint for `cover` needs the installation's granted permissions: a push, to ask for `workflows` when it is granted, and an API read, to ask for each granted permission at `read`. */
|
|
66
|
+
export function needsGrant(cover) {
|
|
67
|
+
if (cover === undefined)
|
|
68
|
+
return false;
|
|
69
|
+
return cover.kind === "git" ? cover.scope.access === "write" : cover.access === "read";
|
|
70
|
+
}
|
|
71
|
+
const nameOf = (repository) => repository.slice(repository.lastIndexOf("/") + 1);
|
|
72
|
+
/** What a mint asks GitHub for, from the installation's `permissions` when `needsGrant`. With no cover, the installation's every repository and permission, for a call that spans repositories. For a git step, only its repository, by name, and only the contents access it needs, plus `workflows: write` for a push when the installation holds it, so a change to workflow files still pushes. For an API call, only its repository: at `read` for each granted permission the tools read with, or with every granted permission for a write. */
|
|
73
|
+
export function mintBody(cover, permissions) {
|
|
74
|
+
if (cover === undefined)
|
|
75
|
+
return {};
|
|
76
|
+
if (cover.kind === "api") {
|
|
77
|
+
if (cover.access === "write")
|
|
78
|
+
return { repositories: [nameOf(cover.repository)] };
|
|
79
|
+
const readable = Object.keys(permissions ?? {}).filter((name) => READABLE.has(name));
|
|
80
|
+
return {
|
|
81
|
+
repositories: [nameOf(cover.repository)],
|
|
82
|
+
permissions: Object.fromEntries(readable.map((name) => [name, "read"])),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const { scope } = cover;
|
|
86
|
+
const asked = scope.access === "write" && permissions?.["workflows"] === "write"
|
|
87
|
+
? { contents: scope.access, workflows: "write" }
|
|
88
|
+
: { contents: scope.access };
|
|
89
|
+
if (scope.repository === null)
|
|
90
|
+
return { permissions: asked };
|
|
91
|
+
return { repositories: [nameOf(scope.repository)], permissions: asked };
|
|
92
|
+
}
|
|
93
|
+
/** Forgets every held token and grant, for a test that starts clean. */
|
|
32
94
|
export function forgetTokens() {
|
|
33
95
|
held.clear();
|
|
96
|
+
granted.clear();
|
|
34
97
|
}
|
package/dist/src/api/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Ctx, type Failure, type GitToken, type Result } from "@kana-ai/edgar-sdk";
|
|
1
|
+
import { type Ctx, type Failure, type GitScope, type GitToken, type Result } from "@kana-ai/edgar-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { type Cover } from "#api/app";
|
|
3
4
|
/** The secret every GitHub call sends. */
|
|
4
5
|
export declare const TOKEN = "GITHUB_TOKEN";
|
|
5
6
|
/** The host every GitHub call goes to. */
|
|
@@ -14,14 +15,16 @@ export declare const LOG_HOSTS: readonly ["*.blob.core.windows.net", "*.actions.
|
|
|
14
15
|
/** The answer of one GitHub call: the parsed body, or the failure it maps to. */
|
|
15
16
|
export type Reply<T> = Result<T, Failure>;
|
|
16
17
|
type Method = "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
18
|
+
/** What the token of an API call covers: the repository its path names, to read for a `GET` and to write for any other method. A path that names no one repository, such as `/search/issues`, `/users/<login>` or `/graphql`, spans repositories and gets the installation's token. */
|
|
19
|
+
export declare function coverOf(method: Method, path: string): Cover | undefined;
|
|
17
20
|
/** The host whose git EDGAR's own git reaches with a GitHub token. */
|
|
18
21
|
export declare const GIT_HOST = "github.com";
|
|
19
|
-
/** The token EDGAR's own git sends to `github.com`: with `[extensions.github] app`, an installation token and its expiry, minted or held as an API call's is; else `GITHUB_TOKEN` itself, which does not expire. */
|
|
20
|
-
export declare function gitToken(ctx: Ctx<typeof TOKEN>, host: string): Promise<Reply<GitToken>>;
|
|
21
|
-
/** Calls the GitHub REST API and parses the answer with `schema`. */
|
|
22
|
-
export declare function github<T>(ctx: Ctx<typeof TOKEN>, method: Method, path: string, schema: z.ZodType<T>, body?: Readonly<Record<string, unknown
|
|
22
|
+
/** The token EDGAR's own git sends to `github.com` for `scope`: with `[extensions.github] app`, an installation token of only that repository and access, and its expiry, minted or held as an API call's is; else `GITHUB_TOKEN` itself, which does not expire and which no scope narrows. */
|
|
23
|
+
export declare function gitToken(ctx: Ctx<typeof TOKEN>, host: string, scope: GitScope): Promise<Reply<GitToken>>;
|
|
24
|
+
/** Calls the GitHub REST API and parses the answer with `schema`. `on`, a `/repos/<owner>/<name>` path, names the one repository of a call whose own path names none, such as a GraphQL mutation, so its token covers only that repository. */
|
|
25
|
+
export declare function github<T>(ctx: Ctx<typeof TOKEN>, method: Method, path: string, schema: z.ZodType<T>, body?: Readonly<Record<string, unknown>>, on?: string): Promise<Reply<T>>;
|
|
23
26
|
/** Calls the GitHub REST API like `github`, with the requests the token has left from `x-ratelimit-remaining`, 0 when the answer has none. */
|
|
24
|
-
export declare function githubCounted<T>(ctx: Ctx<typeof TOKEN>, method: Method, path: string, schema: z.ZodType<T>, body?: Readonly<Record<string, unknown
|
|
27
|
+
export declare function githubCounted<T>(ctx: Ctx<typeof TOKEN>, method: Method, path: string, schema: z.ZodType<T>, body?: Readonly<Record<string, unknown>>, on?: string): Promise<Reply<{
|
|
25
28
|
value: T;
|
|
26
29
|
remaining: number;
|
|
27
30
|
}>>;
|
package/dist/src/api/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { attemptAsync, err, failure, fetchFailure, limitFromHeaders, ok, permanentFailure, reportLimit, unwrapOr, } from "@kana-ai/edgar-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { appJwt, heldToken, holdToken } from "#api/app";
|
|
3
|
+
import { appJwt, heldGranted, heldToken, holdGranted, holdToken, mintBody, needsGrant, } from "#api/app";
|
|
4
4
|
import { limits, mapFailure } from "#api/failures";
|
|
5
5
|
import { config } from "#schemas/config";
|
|
6
6
|
/** The secret every GitHub call sends. */
|
|
@@ -37,53 +37,92 @@ async function send(ctx, method, path, authorization, body) {
|
|
|
37
37
|
return err(mapFailure(response.status, response.headers, json, context));
|
|
38
38
|
}
|
|
39
39
|
const minted = z.object({ token: z.string().min(1), expires_at: z.iso.datetime() });
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const installation = z.object({ permissions: z.record(z.string(), z.string()) });
|
|
41
|
+
/** The JSON body of `response`, or `null` when it is not JSON. */
|
|
42
|
+
async function bodyOf(response) {
|
|
43
|
+
return unwrapOr(await attemptAsync(async () => await response.json(), () => null), null);
|
|
44
|
+
}
|
|
45
|
+
/** The permissions `app`'s installation was granted: the ones held, or the ones `GET /app/installations/<id>` answers with the App's JWT, then held. */
|
|
46
|
+
async function grantedOf(ctx, app, jwt) {
|
|
47
|
+
const known = heldGranted(app);
|
|
48
|
+
if (known !== undefined)
|
|
49
|
+
return ok(known);
|
|
50
|
+
const path = `/app/installations/${String(app.installation)}`;
|
|
51
|
+
const sent = await send(ctx, "GET", path, `Bearer ${jwt}`);
|
|
52
|
+
if (!sent.ok)
|
|
53
|
+
return sent;
|
|
54
|
+
const parsed = installation.safeParse(await bodyOf(sent.value));
|
|
55
|
+
if (!parsed.success) {
|
|
56
|
+
return err(failure("tool_error", `github GET ${path}: unexpected answer`));
|
|
57
|
+
}
|
|
58
|
+
return ok(holdGranted(app, parsed.data.permissions));
|
|
59
|
+
}
|
|
60
|
+
/** An installation token of `app` that covers `cover`, or the whole installation with none: the one held, or one minted with the App's JWT and then held. */
|
|
61
|
+
async function installationToken(ctx, app, cover) {
|
|
62
|
+
const known = heldToken(app, Date.now(), cover);
|
|
43
63
|
if (known !== undefined)
|
|
44
64
|
return ok(known);
|
|
45
65
|
const jwt = appJwt(app, ctx.secrets.get(TOKEN));
|
|
46
66
|
if (!jwt.ok)
|
|
47
67
|
return jwt;
|
|
68
|
+
const permissions = needsGrant(cover)
|
|
69
|
+
? await grantedOf(ctx, app, jwt.value)
|
|
70
|
+
: ok(undefined);
|
|
71
|
+
if (!permissions.ok)
|
|
72
|
+
return permissions;
|
|
48
73
|
const path = `/app/installations/${String(app.installation)}/access_tokens`;
|
|
49
|
-
const
|
|
74
|
+
const body = mintBody(cover, permissions.value);
|
|
75
|
+
const sent = await send(ctx, "POST", path, `Bearer ${jwt.value}`, body);
|
|
50
76
|
if (!sent.ok)
|
|
51
77
|
return sent;
|
|
52
|
-
const parsed = minted.safeParse(
|
|
78
|
+
const parsed = minted.safeParse(await bodyOf(sent.value));
|
|
53
79
|
if (!parsed.success) {
|
|
54
80
|
return err(failure("tool_error", `github POST ${path}: unexpected answer`));
|
|
55
81
|
}
|
|
56
|
-
return ok(holdToken(app, parsed.data.token, parsed.data.expires_at));
|
|
82
|
+
return ok(holdToken(app, parsed.data.token, parsed.data.expires_at, cover));
|
|
83
|
+
}
|
|
84
|
+
const REPOSITORY_PATH = /^\/repos\/([^/?#]+)\/([^/?#]+)/;
|
|
85
|
+
/** What the token of an API call covers: the repository its path names, to read for a `GET` and to write for any other method. A path that names no one repository, such as `/search/issues`, `/users/<login>` or `/graphql`, spans repositories and gets the installation's token. */
|
|
86
|
+
export function coverOf(method, path) {
|
|
87
|
+
const named = REPOSITORY_PATH.exec(path);
|
|
88
|
+
if (named === null)
|
|
89
|
+
return undefined;
|
|
90
|
+
const [, owner = "", name = ""] = named;
|
|
91
|
+
return {
|
|
92
|
+
kind: "api",
|
|
93
|
+
repository: `${owner}/${name}`,
|
|
94
|
+
access: method === "GET" ? "read" : "write",
|
|
95
|
+
};
|
|
57
96
|
}
|
|
58
|
-
/** The `authorization` of a call
|
|
59
|
-
async function authorizationOf(ctx) {
|
|
97
|
+
/** The `authorization` of a call of `method` on `path`: `GITHUB_TOKEN` as a token, or with `[extensions.github] app` set, an installation token of that App that covers what `coverOf` says, `GITHUB_TOKEN` then holding the App's private key. A secret read outside the call is a bug and throws before the request. */
|
|
98
|
+
async function authorizationOf(ctx, method, path) {
|
|
60
99
|
const app = config.safeParse(ctx.config ?? {}).data?.app;
|
|
61
100
|
if (app === undefined)
|
|
62
101
|
return ok(`Bearer ${ctx.secrets.get(TOKEN)}`);
|
|
63
|
-
const token = await installationToken(ctx, app);
|
|
102
|
+
const token = await installationToken(ctx, app, coverOf(method, path));
|
|
64
103
|
return token.ok ? ok(`Bearer ${token.value.token}`) : token;
|
|
65
104
|
}
|
|
66
105
|
/** The host whose git EDGAR's own git reaches with a GitHub token. */
|
|
67
106
|
export const GIT_HOST = "github.com";
|
|
68
|
-
/** The token EDGAR's own git sends to `github.com`: with `[extensions.github] app`, an installation token and its expiry, minted or held as an API call's is; else `GITHUB_TOKEN` itself, which does not expire. */
|
|
69
|
-
export async function gitToken(ctx, host) {
|
|
107
|
+
/** The token EDGAR's own git sends to `github.com` for `scope`: with `[extensions.github] app`, an installation token of only that repository and access, and its expiry, minted or held as an API call's is; else `GITHUB_TOKEN` itself, which does not expire and which no scope narrows. */
|
|
108
|
+
export async function gitToken(ctx, host, scope) {
|
|
70
109
|
if (host !== GIT_HOST) {
|
|
71
110
|
return err(permanentFailure("invalid", `the GitHub extension mints git tokens for ${GIT_HOST}, not ${host}`));
|
|
72
111
|
}
|
|
73
112
|
const app = config.safeParse(ctx.config ?? {}).data?.app;
|
|
74
113
|
if (app === undefined)
|
|
75
114
|
return ok({ token: ctx.secrets.get(TOKEN), expires_at_ms: null });
|
|
76
|
-
const token = await installationToken(ctx, app);
|
|
115
|
+
const token = await installationToken(ctx, app, { kind: "git", scope });
|
|
77
116
|
return token.ok ? ok({ token: token.value.token, expires_at_ms: token.value.expiresAt }) : token;
|
|
78
117
|
}
|
|
79
|
-
/** Calls the GitHub REST API and parses the answer with `schema`. */
|
|
80
|
-
export async function github(ctx, method, path, schema, body) {
|
|
81
|
-
const read = await githubCounted(ctx, method, path, schema, body);
|
|
118
|
+
/** Calls the GitHub REST API and parses the answer with `schema`. `on`, a `/repos/<owner>/<name>` path, names the one repository of a call whose own path names none, such as a GraphQL mutation, so its token covers only that repository. */
|
|
119
|
+
export async function github(ctx, method, path, schema, body, on) {
|
|
120
|
+
const read = await githubCounted(ctx, method, path, schema, body, on);
|
|
82
121
|
return read.ok ? ok(read.value.value) : read;
|
|
83
122
|
}
|
|
84
123
|
/** Calls the GitHub REST API like `github`, with the requests the token has left from `x-ratelimit-remaining`, 0 when the answer has none. */
|
|
85
|
-
export async function githubCounted(ctx, method, path, schema, body) {
|
|
86
|
-
const authorization = await authorizationOf(ctx);
|
|
124
|
+
export async function githubCounted(ctx, method, path, schema, body, on) {
|
|
125
|
+
const authorization = await authorizationOf(ctx, method, on ?? path);
|
|
87
126
|
if (!authorization.ok)
|
|
88
127
|
return authorization;
|
|
89
128
|
const sent = await send(ctx, method, path, authorization.value, body);
|
|
@@ -105,7 +144,7 @@ export async function githubCounted(ctx, method, path, schema, body) {
|
|
|
105
144
|
}
|
|
106
145
|
/** GETs a text answer, such as a job log behind its redirect; a body that cannot be read is `provider_unavailable`. */
|
|
107
146
|
export async function githubText(ctx, path) {
|
|
108
|
-
const authorization = await authorizationOf(ctx);
|
|
147
|
+
const authorization = await authorizationOf(ctx, "GET", path);
|
|
109
148
|
if (!authorization.ok)
|
|
110
149
|
return authorization;
|
|
111
150
|
const sent = await send(ctx, "GET", path, authorization.value);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type CommitPlan, type Ctx } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { type Reply, type TOKEN } from "#api/client";
|
|
3
|
+
/** Publishes the commits of `plan` through the Git Data API, so GitHub signs them when the extension signs in as a GitHub App: each file's blob once, then each commit's tree on the tree before and the commit with no author, each checked against EDGAR's id, then the branch made or moved without force. Answers the id of each commit made, in order. */
|
|
4
|
+
export declare function publishCommits(ctx: Ctx<typeof TOKEN>, plan: CommitPlan): Promise<Reply<readonly string[]>>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { err, ok, permanentFailure, } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GIT_HOST, github } from "#api/client";
|
|
4
|
+
const object = z.object({ sha: z.string() });
|
|
5
|
+
const commitRead = z.object({ tree: z.object({ sha: z.string() }) });
|
|
6
|
+
/** The entry of `POST /git/trees` for one change: the blob at its mode, or `sha: null`, which takes the path out of the base tree. */
|
|
7
|
+
function entryOf(change) {
|
|
8
|
+
switch (change.kind) {
|
|
9
|
+
case "write":
|
|
10
|
+
return { path: change.path, mode: change.mode, type: "blob", sha: change.blob };
|
|
11
|
+
case "delete":
|
|
12
|
+
return { path: change.path, mode: "100644", type: "blob", sha: null };
|
|
13
|
+
default:
|
|
14
|
+
change;
|
|
15
|
+
throw new Error("unreachable");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The failure of an object GitHub made that differs from EDGAR's; the branch has not moved. */
|
|
19
|
+
const differs = (what) => err(permanentFailure("tool_error", `${what} that GitHub made differs from EDGAR's; nothing was published`));
|
|
20
|
+
/** Publishes the commits of `plan` through the Git Data API, so GitHub signs them when the extension signs in as a GitHub App: each file's blob once, then each commit's tree on the tree before and the commit with no author, each checked against EDGAR's id, then the branch made or moved without force. Answers the id of each commit made, in order. */
|
|
21
|
+
export async function publishCommits(ctx, plan) {
|
|
22
|
+
if (plan.host !== GIT_HOST) {
|
|
23
|
+
return err(permanentFailure("invalid", `the GitHub extension publishes commits for ${GIT_HOST}, not ${plan.host}`));
|
|
24
|
+
}
|
|
25
|
+
const repo = `/repos/${plan.repository}/git`;
|
|
26
|
+
const base = await github(ctx, "GET", `${repo}/commits/${plan.base}`, commitRead);
|
|
27
|
+
if (!base.ok)
|
|
28
|
+
return base;
|
|
29
|
+
let tree = base.value.tree.sha;
|
|
30
|
+
let parent = plan.base;
|
|
31
|
+
const sent = new Set();
|
|
32
|
+
const made = [];
|
|
33
|
+
for (const commit of plan.commits) {
|
|
34
|
+
for (const change of commit.changes) {
|
|
35
|
+
if (change.kind !== "write" || sent.has(change.blob))
|
|
36
|
+
continue;
|
|
37
|
+
const body = { content: change.content, encoding: "base64" };
|
|
38
|
+
const blob = await github(ctx, "POST", `${repo}/blobs`, object, body);
|
|
39
|
+
if (!blob.ok)
|
|
40
|
+
return blob;
|
|
41
|
+
if (blob.value.sha !== change.blob)
|
|
42
|
+
return differs(`the blob of ${change.path}`);
|
|
43
|
+
sent.add(change.blob);
|
|
44
|
+
}
|
|
45
|
+
const entries = { base_tree: tree, tree: commit.changes.map(entryOf) };
|
|
46
|
+
const built = await github(ctx, "POST", `${repo}/trees`, object, entries);
|
|
47
|
+
if (!built.ok)
|
|
48
|
+
return built;
|
|
49
|
+
if (built.value.sha !== commit.tree)
|
|
50
|
+
return differs(`the tree of commit ${commit.id}`);
|
|
51
|
+
const body = { message: commit.message, tree: commit.tree, parents: [parent] };
|
|
52
|
+
const signed = await github(ctx, "POST", `${repo}/commits`, object, body);
|
|
53
|
+
if (!signed.ok)
|
|
54
|
+
return signed;
|
|
55
|
+
made.push(signed.value.sha);
|
|
56
|
+
parent = signed.value.sha;
|
|
57
|
+
tree = commit.tree;
|
|
58
|
+
}
|
|
59
|
+
const moved = plan.from === null
|
|
60
|
+
? await github(ctx, "POST", `${repo}/refs`, z.object({}), {
|
|
61
|
+
ref: `refs/heads/${plan.branch}`,
|
|
62
|
+
sha: parent,
|
|
63
|
+
})
|
|
64
|
+
: await github(ctx, "PATCH", `${repo}/refs/heads/${plan.branch}`, z.object({}), {
|
|
65
|
+
sha: parent,
|
|
66
|
+
force: false,
|
|
67
|
+
});
|
|
68
|
+
return moved.ok ? ok(made) : moved;
|
|
69
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
1
2
|
import { type Failure } from "@kana-ai/edgar-sdk";
|
|
3
|
+
import { type graphqlError } from "#schemas/github";
|
|
2
4
|
/** GitHub reports its rate limits in `x-ratelimit-*` on every answer of its API host. */
|
|
3
5
|
export declare const limits: {
|
|
4
6
|
readonly scheme: "github";
|
|
@@ -6,3 +8,5 @@ export declare const limits: {
|
|
|
6
8
|
};
|
|
7
9
|
/** Maps a GitHub error answer to a failure, a 403 that carries a rate limit first; `cause` holds the status and GitHub's `message`. A `forbidden` answer says what the token needs, from `X-Accepted-GitHub-Permissions` (a fine-grained token or an App) or `X-Accepted-OAuth-Scopes` (a classic token). */
|
|
8
10
|
export declare function mapFailure(status: number, headers: Headers, body: unknown, context: string, now?: number): Failure;
|
|
11
|
+
/** Maps the first error of a GraphQL answer by its `type`: only a rate limit is temporary, and a type that is not in the table, or none, is `tool_error` as `unexpected`. `cause` keeps GitHub's type and message. */
|
|
12
|
+
export declare function graphqlFailure(errors: readonly z.infer<typeof graphqlError>[], context: string): Failure;
|
package/dist/src/api/failures.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vendorFailure } from "@kana-ai/edgar-sdk";
|
|
1
|
+
import { failure, vendorFailure, } from "@kana-ai/edgar-sdk";
|
|
2
2
|
import { errorBody } from "#schemas/github";
|
|
3
3
|
/** GitHub reports its rate limits in `x-ratelimit-*` on every answer of its API host. */
|
|
4
4
|
export const limits = { scheme: "github", source: "api.github.com" };
|
|
@@ -29,3 +29,16 @@ export function mapFailure(status, headers, body, context, now = Date.now()) {
|
|
|
29
29
|
? { ...failed, message: `${failed.message}: the GITHUB_TOKEN needs ${needs}` }
|
|
30
30
|
: failed;
|
|
31
31
|
}
|
|
32
|
+
const graphqlKinds = new Map([
|
|
33
|
+
["NOT_FOUND", "not_found"],
|
|
34
|
+
["FORBIDDEN", "forbidden"],
|
|
35
|
+
["UNPROCESSABLE", "invalid"],
|
|
36
|
+
["RATE_LIMITED", "rate_limited"],
|
|
37
|
+
]);
|
|
38
|
+
/** Maps the first error of a GraphQL answer by its `type`: only a rate limit is temporary, and a type that is not in the table, or none, is `tool_error` as `unexpected`. `cause` keeps GitHub's type and message. */
|
|
39
|
+
export function graphqlFailure(errors, context) {
|
|
40
|
+
const [first] = errors;
|
|
41
|
+
const type = first?.type ?? "unexpected";
|
|
42
|
+
const kind = graphqlKinds.get(type) ?? "tool_error";
|
|
43
|
+
return failure(kind, `${context}: ${kind}`, { cause: `${type}: ${first?.message ?? ""}` });
|
|
44
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type Ctx, type Failure, type Result } from "@kana-ai/edgar-sdk";
|
|
2
2
|
import { type TOKEN } from "#api/client";
|
|
3
3
|
import { type DependabotFeed } from "#schemas/config";
|
|
4
|
-
/**
|
|
4
|
+
/** The card a fingerprint opened, and one alert of it, which is read again when the fingerprint is no longer open. */
|
|
5
|
+
export interface Opened {
|
|
6
|
+
readonly card: string;
|
|
7
|
+
readonly repo: string;
|
|
8
|
+
readonly number: number;
|
|
9
|
+
}
|
|
10
|
+
/** What one process keeps between sweeps: the card of each fingerprint it opened, and what it last said about each repository. */
|
|
5
11
|
export interface Memory {
|
|
6
|
-
readonly opened:
|
|
12
|
+
readonly opened: Map<string, Opened>;
|
|
7
13
|
readonly said: Map<string, string>;
|
|
8
14
|
}
|
|
9
15
|
/** Removes from `opened` each fingerprint that is not in `open`. */
|
|
@@ -20,7 +26,7 @@ export interface Swept {
|
|
|
20
26
|
readonly wait: number;
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
|
-
* One sweep: reads the open alerts and opens at most `max_per_run` cards, the worst first. A fingerprint this process opened is tracked, and EDGAR answers a repeat with the open card that holds it. After a sweep that read every repository, a fingerprint whose alert
|
|
29
|
+
* One sweep: reads the open alerts and opens at most `max_per_run` cards, the worst first. A fingerprint this process opened is tracked, and EDGAR answers a repeat with the open card that holds it. After a sweep that read every repository, the card of a fingerprint whose alert GitHub reports fixed or dismissed is closed, so the memory holds only open alerts.
|
|
24
30
|
* A card the tracker refuses is said and asked for again at the next sweep. When the tracker cannot answer, no other card is asked for in this sweep.
|
|
25
31
|
*/
|
|
26
32
|
export declare function sweepAlerts(ctx: Ctx<typeof TOKEN>, feed: DependabotFeed, memory: Memory): Promise<Result<Swept, Failure>>;
|
package/dist/src/feed/alerts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ok } from "@kana-ai/edgar-sdk";
|
|
1
|
+
import { ok, } from "@kana-ai/edgar-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { github } from "#api/client";
|
|
4
4
|
import { alertCard, alertKey, rankOf } from "#feed/cards";
|
|
@@ -70,12 +70,72 @@ async function readAlerts(ctx, feed, said) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
const cards = [...groups]
|
|
73
|
-
.map(([key,
|
|
73
|
+
.map(([key, { home, alerts }]) => ({
|
|
74
|
+
key,
|
|
75
|
+
card: alertCard(home, alerts),
|
|
76
|
+
repo: home.repo,
|
|
77
|
+
number: alerts[0].number,
|
|
78
|
+
}))
|
|
74
79
|
.sort((a, b) => rankOf(b.card.block.severity ?? "") - rankOf(a.card.block.severity ?? ""));
|
|
75
80
|
return ok({ cards, whole: read === Object.keys(feed.services).length, read, below, wait });
|
|
76
81
|
}
|
|
82
|
+
/** What GitHub says of an alert that left the open ones, for the comment on its card; `undefined` while it is still open. */
|
|
83
|
+
function closing(a) {
|
|
84
|
+
if (a.state === "fixed")
|
|
85
|
+
return `GitHub reports this Dependabot alert fixed, so EDGAR closes the card: ${a.html_url}`;
|
|
86
|
+
if (a.state !== "dismissed" && a.state !== "auto_dismissed")
|
|
87
|
+
return undefined;
|
|
88
|
+
const who = a.state === "auto_dismissed" ? "GitHub dismissed" : "A person dismissed";
|
|
89
|
+
const reason = a.dismissed_reason ?? "";
|
|
90
|
+
const note = a.dismissed_comment ?? "";
|
|
91
|
+
const why = `${reason === "" ? "" : ` as ${reason}`}${note === "" ? "" : `: "${note}"`}`;
|
|
92
|
+
return `${who} this Dependabot alert on GitHub${why}. It is not fixed, so EDGAR closes the card; when the alert opens again, EDGAR files it again: ${a.html_url}`;
|
|
93
|
+
}
|
|
94
|
+
/** Whether a tracker write is finished (`done`, or `skipped` for a card the tracker leaves alone), worth a try at the next sweep, or refused for good; a refusal is said. */
|
|
95
|
+
function settled(ctx, card, wrote) {
|
|
96
|
+
if (wrote.ok && (wrote.value.outcome === "done" || wrote.value.outcome === "skipped"))
|
|
97
|
+
return "finished";
|
|
98
|
+
const again = wrote.ok && (wrote.value.outcome === "temporary_failure" || wrote.value.outcome === "waiting");
|
|
99
|
+
const why = wrote.ok
|
|
100
|
+
? "message" in wrote.value
|
|
101
|
+
? wrote.value.message
|
|
102
|
+
: wrote.value.outcome
|
|
103
|
+
: wrote.error.message;
|
|
104
|
+
ctx.log(`github dependabot: could not close ${card}${again ? " now" : ""}: ${why}`);
|
|
105
|
+
return again ? "again" : "refused";
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Closes the card of each fingerprint that is not in `open` when GitHub reports its alert fixed or dismissed, with a comment that says which. A fingerprint whose alert is still open, such as one past the page read, is only forgotten.
|
|
109
|
+
* A card whose alert read or tracker write failed for now is kept and tried again at the next sweep; one refused for good is forgotten.
|
|
110
|
+
* shortcut: the memory is one process's, so an alert fixed while EDGAR was stopped leaves its card open; upgrade when a service can keep state.
|
|
111
|
+
*/
|
|
112
|
+
async function closeGone(ctx, opened, open) {
|
|
113
|
+
for (const [key, { card, repo, number }] of opened) {
|
|
114
|
+
if (open.has(key))
|
|
115
|
+
continue;
|
|
116
|
+
const read = await github(ctx, "GET", `/repos/${repo}/dependabot/alerts/${String(number)}`, alert);
|
|
117
|
+
if (!read.ok) {
|
|
118
|
+
ctx.log(`github dependabot: could not read alert ${String(number)} of ${repo}: ${read.error.message}`);
|
|
119
|
+
if (read.error.outcome === "permanent_failure")
|
|
120
|
+
opened.delete(key);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const text = closing(read.value);
|
|
124
|
+
if (text !== undefined) {
|
|
125
|
+
const commented = settled(ctx, card, await ctx.tracker.comment({ card, text }));
|
|
126
|
+
if (commented === "again")
|
|
127
|
+
continue;
|
|
128
|
+
if (commented === "finished") {
|
|
129
|
+
const closed = settled(ctx, card, await ctx.tracker.close({ card, reason: text }));
|
|
130
|
+
if (closed === "again")
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
opened.delete(key);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
77
137
|
/**
|
|
78
|
-
* One sweep: reads the open alerts and opens at most `max_per_run` cards, the worst first. A fingerprint this process opened is tracked, and EDGAR answers a repeat with the open card that holds it. After a sweep that read every repository, a fingerprint whose alert
|
|
138
|
+
* One sweep: reads the open alerts and opens at most `max_per_run` cards, the worst first. A fingerprint this process opened is tracked, and EDGAR answers a repeat with the open card that holds it. After a sweep that read every repository, the card of a fingerprint whose alert GitHub reports fixed or dismissed is closed, so the memory holds only open alerts.
|
|
79
139
|
* A card the tracker refuses is said and asked for again at the next sweep. When the tracker cannot answer, no other card is asked for in this sweep.
|
|
80
140
|
*/
|
|
81
141
|
export async function sweepAlerts(ctx, feed, memory) {
|
|
@@ -84,12 +144,12 @@ export async function sweepAlerts(ctx, feed, memory) {
|
|
|
84
144
|
return found;
|
|
85
145
|
const { cards, whole, read, below, wait } = found.value;
|
|
86
146
|
if (whole)
|
|
87
|
-
|
|
147
|
+
await closeGone(ctx, memory.opened, new Set(cards.map(({ key }) => key)));
|
|
88
148
|
let filed = 0;
|
|
89
149
|
let tracked = 0;
|
|
90
150
|
let held = 0;
|
|
91
151
|
let answers = true;
|
|
92
|
-
for (const { key, card } of cards) {
|
|
152
|
+
for (const { key, card, repo, number } of cards) {
|
|
93
153
|
if (memory.opened.has(key)) {
|
|
94
154
|
tracked += 1;
|
|
95
155
|
continue;
|
|
@@ -100,7 +160,7 @@ export async function sweepAlerts(ctx, feed, memory) {
|
|
|
100
160
|
}
|
|
101
161
|
const made = await ctx.cards.open(card);
|
|
102
162
|
if (made.ok && made.value.outcome === "done") {
|
|
103
|
-
memory.opened.
|
|
163
|
+
memory.opened.set(key, { card: made.value.output.id, repo, number });
|
|
104
164
|
filed += 1;
|
|
105
165
|
continue;
|
|
106
166
|
}
|
|
@@ -7,20 +7,29 @@ export interface Swept {
|
|
|
7
7
|
readonly read: number;
|
|
8
8
|
readonly filed: number;
|
|
9
9
|
readonly tracked: number;
|
|
10
|
+
/** The mentions of EDGAR on its own pull requests put on their cards. */
|
|
11
|
+
readonly relayed: number;
|
|
10
12
|
/** The seconds GitHub asks the token to wait, when a rate limit ended the sweep; else 0. */
|
|
11
13
|
readonly wait: number;
|
|
12
14
|
}
|
|
15
|
+
/** What the watch keeps between sweeps to relay mentions: the time the last sweep that read every repository began. */
|
|
16
|
+
export interface Heard {
|
|
17
|
+
since: string;
|
|
18
|
+
}
|
|
13
19
|
/** One sweep over each watched repository; a fingerprint this process opened already is tracked, and EDGAR answers a repeat with the open card that holds it. After a sweep that read every repository on github.com, a fingerprint whose fault is gone is forgotten. A repository that fails is logged and the sweep goes on; a rate limit ends the sweep with its wait, since the limit is the token's; a refused token ends it. */
|
|
14
|
-
export declare function sweep(ctx: Ctx<typeof TOKEN>, settings: Config, watch: Watch, login: string, opened: Set<string
|
|
20
|
+
export declare function sweep(ctx: Ctx<typeof TOKEN>, settings: Config, watch: Watch, login: string, opened: Set<string>, heard?: Heard): Promise<Result<Swept, Failure>>;
|
|
15
21
|
/**
|
|
16
22
|
* The watch: with `[extensions.github.watch]` set, a sweep every `every_seconds` until the engine stops it; without it, it only waits. A refused token ends it with its permanent failure, which opens its breaker; a repository that fails waits for the next sweep, and after a rate limit the next sweep waits as long as GitHub asks.
|
|
17
23
|
* shortcut: what was filed lives in memory, so a restart asks for the open cards again, and EDGAR answers each with the card it has; upgrade when a service can keep state.
|
|
24
|
+
* A comment on one of EDGAR's own pull requests that mentions EDGAR is put on the card that the pull request's branch names, as its author's reply, so the run on that card reads it; only comments made after the watch started count.
|
|
25
|
+
* shortcut: the time of the last read lives in memory, so a mention made while EDGAR was stopped is not read; upgrade when a service can keep state.
|
|
18
26
|
* shortcut: red checks on EDGAR's own pull request open a card that names the pull request's card, since a service cannot comment on a card or start a sub-run; upgrade when the engine takes a comment from a service.
|
|
19
27
|
*/
|
|
20
28
|
export declare function watch(ctx: Ctx<typeof TOKEN>): Promise<Outcome>;
|
|
21
29
|
/**
|
|
22
30
|
* The Dependabot feed: with `[extensions.github.dependabot]` set, a sweep every `every_seconds` until the engine stops it; without it, it only waits. A refused token ends it with its permanent failure, which opens its breaker; a repository that fails waits for the next sweep, and after a rate limit the next sweep waits as long as GitHub asks.
|
|
23
31
|
* shortcut: what was filed lives in memory, so a restart asks for the open cards again, and EDGAR answers each with the card it has; an alert that is still open after its card closed is filed again then. Upgrade when a service can keep state.
|
|
32
|
+
* The card of an alert that GitHub reports fixed or dismissed is closed with a comment, which needs `tracker:write`.
|
|
24
33
|
*/
|
|
25
34
|
export declare function feedAlerts(ctx: Ctx<typeof TOKEN>): Promise<Outcome>;
|
|
26
35
|
/** The one service of the extension: the watch and the Dependabot feed side by side, each off without its table. When one ends with a failure, the other is stopped and the service ends with that failure. */
|