@intentius/chant 0.124.9 → 0.124.11
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/cli/handlers/gate-resume.d.ts +85 -10
- package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/gate-resume-run.d.ts +87 -0
- package/dist/gate-resume-run.d.ts.map +1 -0
- package/dist/lifecycle/gate-applied.d.ts +44 -1
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/lifecycle/gate-audit.d.ts +6 -0
- package/dist/lifecycle/gate-audit.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts +1 -1
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/op/gate-resume-plan.d.ts +113 -0
- package/dist/op/gate-resume-plan.d.ts.map +1 -0
- package/dist/op/gate-resume.d.ts +8 -64
- package/dist/op/gate-resume.d.ts.map +1 -1
- package/dist/op/gate-run-locator.d.ts +1 -1
- package/dist/op/index.d.ts +2 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/point-decision.d.ts +11 -0
- package/dist/point-decision.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/handlers/gate-resume.test.ts +140 -2
- package/src/cli/handlers/gate-resume.ts +174 -65
- package/src/cli/main.ts +8 -3
- package/src/codegen/pinned-upgrade.test.ts +8 -1
- package/src/codegen/publish-order.test.ts +20 -4
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/gate-resume-run-bundle.test.ts +49 -0
- package/src/gate-resume-run.ts +171 -0
- package/src/lifecycle/gate-applied.ts +63 -1
- package/src/lifecycle/gate-audit.test.ts +6 -0
- package/src/lifecycle/gate-audit.ts +8 -2
- package/src/lifecycle/gate-ledger.test.ts +7 -1
- package/src/lifecycle/gate-ledger.ts +1 -1
- package/src/op/gate-resume-plan-bundle.test.ts +49 -0
- package/src/op/gate-resume-plan.test.ts +107 -0
- package/src/op/gate-resume-plan.ts +228 -0
- package/src/op/gate-resume.test.ts +18 -0
- package/src/op/gate-resume.ts +16 -150
- package/src/op/gate-run-locator.ts +1 -1
- package/src/op/gate.ts +1 -1
- package/src/op/index.ts +2 -0
- package/src/op/op-waves-point-mcp.e2e.test.ts +148 -0
- package/src/op/op-waves-point.test.ts +60 -2
- package/src/op/op-waves-run.ts +6 -2
- package/src/op/op-waves.test.ts +5 -1
- package/src/point-decision.ts +19 -2
|
@@ -10,22 +10,58 @@
|
|
|
10
10
|
* question has an answer that passes the gate (`pointGateResumable`, #3835),
|
|
11
11
|
* and `chant workspace points answer --resume` resumes the job right after
|
|
12
12
|
* the answer.
|
|
13
|
+
*
|
|
14
|
+
* What to resume is decided from the ledger by `planGateResumes`
|
|
15
|
+
* (`../../op/gate-resume-plan.ts`, #3858): an approval a wave already applied
|
|
16
|
+
* under is spent and resumes nothing, and an apply under an approval that
|
|
17
|
+
* stopped (an applied line with a run locator and no finished line) resumes
|
|
18
|
+
* once the forge says its run is gone.
|
|
13
19
|
*/
|
|
14
20
|
import { type GateResolutionRecord, type PendingGateRecord } from "../../lifecycle/gate-ledger.js";
|
|
21
|
+
import { type AppliedGateLine, type FinishedGateRecord } from "../../lifecycle/gate-applied.js";
|
|
15
22
|
import { type GateResumeOutcome } from "../../op/gate-resume.js";
|
|
16
|
-
import { type
|
|
23
|
+
import { type GateResumeCandidate, type GateResumeReason } from "../../op/gate-resume-plan.js";
|
|
24
|
+
import type { GateRunLocator } from "../../op/gate-run-locator.js";
|
|
25
|
+
import type { PointQuestionState } from "../../point-decision.js";
|
|
17
26
|
import type { ForgeFetch } from "../../pr-forge.js";
|
|
18
27
|
import type { CommandContext } from "../registry.js";
|
|
19
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* One gate a resume looked at and what it did. With `--json`, `chant run
|
|
30
|
+
* resume` prints these as `{ reports }`; under `--dry-run` it starts nothing,
|
|
31
|
+
* so a product that resumes in its own job reads `resumable` and `reason`
|
|
32
|
+
* (#3858).
|
|
33
|
+
*/
|
|
20
34
|
export interface GateResumeReport {
|
|
21
35
|
op: string;
|
|
22
36
|
gate: string;
|
|
23
37
|
environment?: string;
|
|
24
|
-
/**
|
|
25
|
-
|
|
38
|
+
/** A standing pending fact, or an apply under an approval that stopped (#3858). */
|
|
39
|
+
source: GateResumeCandidate["source"];
|
|
40
|
+
/**
|
|
41
|
+
* What happened. `resumed`, `skipped` and `would-resume` (`--dry-run`) come
|
|
42
|
+
* from the forge; the rest are decided before any call.
|
|
43
|
+
*/
|
|
44
|
+
status: GateResumeOutcome["status"] | "not-approved" | "spent" | "no-job" | "no-token" | "failed";
|
|
45
|
+
/** Why, from the ledger: `approved`, `answered`, `not-approved`, `spent` or `stopped`. */
|
|
46
|
+
reason: GateResumeReason;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the gate's job should start again: an approval or a passing
|
|
49
|
+
* answer stands and is not spent, or an apply stopped and the run that
|
|
50
|
+
* applied is gone. A product that applies in its own job acts on these.
|
|
51
|
+
*/
|
|
52
|
+
resumable: boolean;
|
|
26
53
|
message: string;
|
|
54
|
+
planDigest?: string;
|
|
27
55
|
approvedBy?: string;
|
|
56
|
+
approvedAt?: string;
|
|
28
57
|
url?: string;
|
|
58
|
+
/** The job a resume starts again. */
|
|
59
|
+
run?: GateRunLocator;
|
|
60
|
+
spent?: GateResumeCandidate["spent"];
|
|
61
|
+
/** `runGone` is what the forge said about the run that applied; absent when it was not asked. */
|
|
62
|
+
stopped?: GateResumeCandidate["stopped"] & {
|
|
63
|
+
runGone?: boolean;
|
|
64
|
+
};
|
|
29
65
|
}
|
|
30
66
|
export interface ResumeGateOptions {
|
|
31
67
|
env?: Record<string, string | undefined>;
|
|
@@ -38,12 +74,30 @@ export interface ResumeGateOptions {
|
|
|
38
74
|
* when a fact needs them and none are given.
|
|
39
75
|
*/
|
|
40
76
|
questions?: ReadonlyMap<string, PointQuestionState>;
|
|
77
|
+
/** The lines of `_gates/<op>/applied.jsonl` (#3858). Read from `chant/lifecycle` by {@link resumeOpGates} when not given. */
|
|
78
|
+
applied?: readonly AppliedGateLine[];
|
|
79
|
+
finished?: readonly FinishedGateRecord[];
|
|
41
80
|
}
|
|
42
81
|
/** Every question the workspace at `cwd` lists, by id, the lifecycle ledger's included. Empty when the workspace can't be read. */
|
|
43
82
|
export declare function workspaceQuestions(cwd: string): Promise<Map<string, PointQuestionState>>;
|
|
44
|
-
/** Resume the job behind one standing pending fact, when an approval answers it. */
|
|
83
|
+
/** Resume the job behind one standing pending fact, when an approval answers it and is not spent. */
|
|
45
84
|
export declare function resumeStanding(standing: PendingGateRecord, resolutions: readonly GateResolutionRecord[], opts?: ResumeGateOptions, pending?: readonly PendingGateRecord[]): Promise<GateResumeReport>;
|
|
46
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Act on one candidate {@link planGateResumes} decided: start its job again
|
|
87
|
+
* through the forge, or under `dryRun` ask the forge whether it would. A
|
|
88
|
+
* stopped apply is resumed only once the forge says its run is gone.
|
|
89
|
+
*/
|
|
90
|
+
export declare function resumeCandidate(c: GateResumeCandidate, opts?: ResumeGateOptions): Promise<GateResumeReport>;
|
|
91
|
+
/** The `applied` and `finished` lines of `_gates/<op>/applied.jsonl` on `chant/lifecycle`. */
|
|
92
|
+
export declare function readAppliedGateFile(op: string): Promise<{
|
|
93
|
+
applied: AppliedGateLine[];
|
|
94
|
+
finished: FinishedGateRecord[];
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Resume every job waiting on `op`'s gates (or one gate) whose approval
|
|
98
|
+
* arrived and is not spent, and every apply under an approval that stopped
|
|
99
|
+
* once its run is gone (#3858).
|
|
100
|
+
*/
|
|
47
101
|
export declare function resumeOpGates(op: string, gate: string | undefined, opts?: ResumeGateOptions): Promise<GateResumeReport[]>;
|
|
48
102
|
/**
|
|
49
103
|
* What `chant approve --resume` runs once the approval is recorded and
|
|
@@ -65,11 +119,32 @@ export declare function resumeAfterAnswer(question: {
|
|
|
65
119
|
subject: string | null;
|
|
66
120
|
ledger: string | null;
|
|
67
121
|
}, cwd?: string): Promise<number>;
|
|
122
|
+
/** What {@link resumeWaitingGates} reads. */
|
|
123
|
+
export interface ResumeWaitingOptions extends ResumeGateOptions {
|
|
124
|
+
/** One op's gate ledger; absent, every gate ledger on `chant/lifecycle`. */
|
|
125
|
+
op?: string;
|
|
126
|
+
/** Only this gate's waiting job (#3854); absent, every gate's. */
|
|
127
|
+
gate?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* What `chant run resume` does, callable in process: read the gate ledgers
|
|
131
|
+
* (`op`'s alone, when given) and start again each CI job that waits at a
|
|
132
|
+
* gate an approval now answers. With `gate`, only that gate's job is touched,
|
|
133
|
+
* so a caller that just approved one wave resumes that wave's job and no
|
|
134
|
+
* other (#3854). The lifecycle ledger has to be readable
|
|
135
|
+
* (`requireLifecycleLedger`).
|
|
136
|
+
*/
|
|
137
|
+
export declare function resumeWaitingGates(opts?: ResumeWaitingOptions): Promise<GateResumeReport[]>;
|
|
68
138
|
/**
|
|
69
|
-
* `chant run resume [--op <op>] [--dry-run] [--json]`: the
|
|
70
|
-
* Reads every gate ledger on `chant/lifecycle` (or `--op`'s),
|
|
71
|
-
* again each CI job that waits at a gate
|
|
72
|
-
* gate whose decision point now has an
|
|
139
|
+
* `chant run resume [--op <op>] [--gate <gate>] [--dry-run] [--json]`: the
|
|
140
|
+
* scheduled job. Reads every gate ledger on `chant/lifecycle` (or `--op`'s),
|
|
141
|
+
* and starts again each CI job that waits at a gate (or at `--gate` alone)
|
|
142
|
+
* an approval now answers, or at a gate whose decision point now has an
|
|
143
|
+
* answer that passes it (#3835), unless a wave already applied under that
|
|
144
|
+
* approval (#3858). It also starts again the run of an apply under an
|
|
145
|
+
* approval that stopped, once that run is gone. `--dry-run --json` starts
|
|
146
|
+
* nothing and says, per gate, whether it would resume and why, for a product
|
|
147
|
+
* that resumes in its own job.
|
|
73
148
|
*/
|
|
74
149
|
export declare function runResumeCommand(ctx: CommandContext): Promise<number>;
|
|
75
150
|
//# sourceMappingURL=gate-resume.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/gate-resume.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/gate-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAyC,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGpI,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAmB,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtC;;;OAGG;IACH,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;IAClG,0FAA0F;IAC1F,MAAM,EAAE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G,OAAO,CAAC,MAAM,CAAC,CAsB3E"}
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAkB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AA2G9E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA4rBpD;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAkB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AA2G9E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA4rBpD;AAm8BD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBzE;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,EA2KvC,CAAC;AAqLF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5E"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume the job that waits at a gate (#3683), bundle-safe (#3854).
|
|
3
|
+
*
|
|
4
|
+
* A CI job that reaches a gate nobody approved records a pending fact on
|
|
5
|
+
* `chant/lifecycle` and exits 3. Nothing re-runs it when the approval lands,
|
|
6
|
+
* because a push to the ledger branch starts no pipeline. This module closes
|
|
7
|
+
* that loop through the forge's API.
|
|
8
|
+
*
|
|
9
|
+
* When the job runs in CI, the pending fact it records carries a
|
|
10
|
+
* {@link GateRunLocator}, read from the job's environment by
|
|
11
|
+
* {@link resolveGateRunLocator}: which forge, the API base, the repository,
|
|
12
|
+
* the run, and what the forge needs to start it again. After an approval,
|
|
13
|
+
* {@link resumeGateRun} starts it again:
|
|
14
|
+
*
|
|
15
|
+
* | Forge | Call | Token |
|
|
16
|
+
* |---|---|---|
|
|
17
|
+
* | GitHub | `POST /repos/{repo}/actions/runs/{run}/rerun-failed-jobs` | `actions: write` (the job's `GITHUB_TOKEN` with that permission, or a fine-grained token with Actions read and write) |
|
|
18
|
+
* | GitLab | `POST /projects/{id}/jobs/{job}/retry` | a project or personal access token with the `api` scope and the Developer role; `CI_JOB_TOKEN` cannot retry jobs |
|
|
19
|
+
* | Forgejo | `POST /repos/{repo}/actions/workflows/{file}/dispatches` on the run's branch | a token with the `write:repository` scope; Forgejo has no API to re-run a run, so it starts a new run of the workflow |
|
|
20
|
+
*
|
|
21
|
+
* GitHub re-runs the failed job and the jobs that need it, at the same
|
|
22
|
+
* commit. GitLab retries the job, and the jobs it skipped run after it. A
|
|
23
|
+
* Forgejo dispatch runs the whole workflow again at the branch's head, so the
|
|
24
|
+
* jobs before the gate run again too; they must be safe to repeat (a wave
|
|
25
|
+
* whose runs already applied plans nothing and applies nothing new).
|
|
26
|
+
*
|
|
27
|
+
* Resuming approves nothing. The resumed job decides the gate again from the
|
|
28
|
+
* ledger, so resuming a run whose approval does not count only makes it wait
|
|
29
|
+
* again. {@link resumeGateRun} skips a run that is still going, that ended
|
|
30
|
+
* well, or that was already resumed (a later GitHub attempt, a newer GitLab
|
|
31
|
+
* job of the same name, a newer Forgejo run of the workflow), so a scheduled
|
|
32
|
+
* resume job can call it every few minutes without starting a run twice.
|
|
33
|
+
*
|
|
34
|
+
* This module imports no workspace, ledger, schema or git code, so a product
|
|
35
|
+
* that ships one bundled file (terragucci) can import it as
|
|
36
|
+
* `@intentius/chant/gate-resume-run` and resume a job in process. Which
|
|
37
|
+
* approval answers a pending fact is `./op/gate-resume.ts`'s
|
|
38
|
+
* `resolutionAnswering`, which reads the gate's quorum rules and does pull the
|
|
39
|
+
* workspace in; that module re-exports everything here.
|
|
40
|
+
*/
|
|
41
|
+
import { type ForgeFetch, type ForgeKind } from "./pr-forge.js";
|
|
42
|
+
import type { GateRunLocator } from "./op/gate-run-locator.js";
|
|
43
|
+
export { isGateRunLocator, resolveGateRunLocator, type GateRunLocator } from "./op/gate-run-locator.js";
|
|
44
|
+
/** What {@link resumeGateRun} did. */
|
|
45
|
+
export type GateResumeOutcome = {
|
|
46
|
+
status: "resumed";
|
|
47
|
+
forge: ForgeKind;
|
|
48
|
+
how: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
} | {
|
|
51
|
+
status: "skipped";
|
|
52
|
+
forge: ForgeKind;
|
|
53
|
+
reason: string;
|
|
54
|
+
url?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Under `dryRun` (#3858): the run is gone and would be started again; nothing was started. */
|
|
57
|
+
| {
|
|
58
|
+
status: "would-resume";
|
|
59
|
+
forge: ForgeKind;
|
|
60
|
+
how: string;
|
|
61
|
+
url?: string;
|
|
62
|
+
};
|
|
63
|
+
export interface ResumeGateRunOptions {
|
|
64
|
+
token: string;
|
|
65
|
+
/** The approval's time. A Forgejo run of the workflow created after it means the run was already resumed. */
|
|
66
|
+
since?: string;
|
|
67
|
+
fetch?: ForgeFetch;
|
|
68
|
+
/**
|
|
69
|
+
* Read the run as a resume would, and start nothing (#3858): say
|
|
70
|
+
* `would-resume` where it would start it. The calls are reads, so a token
|
|
71
|
+
* with read access to the forge's runs is enough.
|
|
72
|
+
*/
|
|
73
|
+
dryRun?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Start the job a pending fact's locator names again, or say why not. Throws
|
|
77
|
+
* {@link ForgeApiError} when the forge refuses a call, such as a token
|
|
78
|
+
* without the access the table in the module doc lists.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resumeGateRun(loc: GateRunLocator, opts: ResumeGateRunOptions): Promise<GateResumeOutcome>;
|
|
81
|
+
/**
|
|
82
|
+
* The token a resume uses: `CHANT_FORGE_TOKEN`, else the forge's own
|
|
83
|
+
* (`GITHUB_TOKEN` or `GH_TOKEN` on GitHub and Forgejo, `GITLAB_TOKEN` on
|
|
84
|
+
* GitLab), the same order the pull-request loop reads (`../pr-forge.ts`).
|
|
85
|
+
*/
|
|
86
|
+
export declare function resumeTokenFromEnv(forge: ForgeKind, env?: Record<string, string | undefined>): string | undefined;
|
|
87
|
+
//# sourceMappingURL=gate-resume-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-resume-run.d.ts","sourceRoot":"","sources":["../src/gate-resume-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAErG,sCAAsC;AACtC,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE;AACvE,+FAA+F;GAC7F;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,6GAA6G;IAC7G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAyBD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkE/G;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,GAAG,SAAS,CAG9H"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* Pure: no git, no clock, no file. It bundles into `@intentius/chant/gate-decision`.
|
|
18
18
|
*/
|
|
19
19
|
import type { GateAuditApply } from "./gate-audit.js";
|
|
20
|
+
import type { GateRunLocator } from "../op/gate-run-locator.js";
|
|
20
21
|
/** One approval a wave applied under: the approval of `planDigest` made at `approvedAt` was used. */
|
|
21
22
|
export interface AppliedGateRecord {
|
|
22
23
|
version: 1;
|
|
@@ -41,6 +42,37 @@ export interface AppliedGateRecord {
|
|
|
41
42
|
};
|
|
42
43
|
runId?: string;
|
|
43
44
|
commit?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Where the run applying runs (#3858), as a pending fact's `resume` names
|
|
47
|
+
* it. A line that carries one and has no {@link FinishedGateRecord} is an
|
|
48
|
+
* apply that may have stopped: `chant run resume` starts that run again
|
|
49
|
+
* once it is gone, and the wave applies the rest under the same approval.
|
|
50
|
+
*/
|
|
51
|
+
resume?: GateRunLocator;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A line of `applied.jsonl` that a wave applying under an approval writes
|
|
55
|
+
* (#3858): chant's own `applied` line, or a product's `changes` line beside
|
|
56
|
+
* it (terragucci's, which names the changes the approved plans make). Both
|
|
57
|
+
* name the approval the apply ran under.
|
|
58
|
+
*/
|
|
59
|
+
export type AppliedGateLine = Omit<AppliedGateRecord, "kind"> & {
|
|
60
|
+
kind: "applied" | "changes";
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* How the apply an applied line names ended, in the same file (#3858). A
|
|
64
|
+
* product writes it when the apply finishes; an apply that was killed writes
|
|
65
|
+
* none. `applied` is that line's `timestamp`.
|
|
66
|
+
*/
|
|
67
|
+
export interface FinishedGateRecord {
|
|
68
|
+
version: 1;
|
|
69
|
+
kind: "finished";
|
|
70
|
+
op: string;
|
|
71
|
+
gate: string;
|
|
72
|
+
planDigest: string;
|
|
73
|
+
applied: string;
|
|
74
|
+
result: "applied" | "failed";
|
|
75
|
+
timestamp: string;
|
|
44
76
|
}
|
|
45
77
|
/** Where the applied lines of `op` live on `chant/lifecycle`: the directory and the file, as `writeBlobToPath` takes them. */
|
|
46
78
|
export declare function appliedGatePath(op: string): {
|
|
@@ -49,6 +81,17 @@ export declare function appliedGatePath(op: string): {
|
|
|
49
81
|
};
|
|
50
82
|
/** The applied lines of an `applied.jsonl` file, oldest first. A line that is not one is skipped. */
|
|
51
83
|
export declare function parseAppliedGateLines(text: string): AppliedGateRecord[];
|
|
84
|
+
/**
|
|
85
|
+
* Every line of an `applied.jsonl` file a resume reads (#3858): the
|
|
86
|
+
* `applied` and `changes` lines, and the `finished` lines that say how an
|
|
87
|
+
* apply ended. Oldest first; a line that is none of them is skipped.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseAppliedGateFile(text: string): {
|
|
90
|
+
applied: AppliedGateLine[];
|
|
91
|
+
finished: FinishedGateRecord[];
|
|
92
|
+
};
|
|
93
|
+
/** The finished line for the apply `line` names, or undefined while it has none. */
|
|
94
|
+
export declare function finishedApply(finished: readonly FinishedGateRecord[], line: Pick<AppliedGateLine, "gate" | "planDigest" | "timestamp">): FinishedGateRecord | undefined;
|
|
52
95
|
/**
|
|
53
96
|
* Whether an approval is spent: a wave applied under an approval of the same
|
|
54
97
|
* gate and digest made at or after it. One that names no digest is never
|
|
@@ -57,7 +100,7 @@ export declare function parseAppliedGateLines(text: string): AppliedGateRecord[]
|
|
|
57
100
|
* head, so the review cannot be recorded again to pass the digest twice. A
|
|
58
101
|
* review not yet recorded has no `timestamp`.
|
|
59
102
|
*/
|
|
60
|
-
export declare function isApprovalSpent(applied: readonly AppliedGateRecord[], approval: {
|
|
103
|
+
export declare function isApprovalSpent(applied: readonly Pick<AppliedGateRecord, "gate" | "planDigest" | "approvedAt" | "review">[], approval: {
|
|
61
104
|
gate: string;
|
|
62
105
|
planDigest?: string;
|
|
63
106
|
timestamp?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-applied.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"gate-applied.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qGAAqG;AACrG,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,6HAA6H;IAC7H,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,C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C,GAAG,kBAAkB,GAAG,SAAS,CAEvK;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC,EAAE,EAC5F,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC3G,OAAO,CAUT;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,CAiBxG"}
|
|
@@ -105,6 +105,12 @@ export interface GateAuditEntry {
|
|
|
105
105
|
runId?: string;
|
|
106
106
|
expiresAt?: string;
|
|
107
107
|
description?: string;
|
|
108
|
+
/** Pending facts an op wave wrote for a policy denial or a hold (#3839): the wave they belong to. */
|
|
109
|
+
wave?: {
|
|
110
|
+
number: number;
|
|
111
|
+
name: string;
|
|
112
|
+
op?: string;
|
|
113
|
+
};
|
|
108
114
|
/** Overrides: the rules the denial named (from the denial line when there is one). */
|
|
109
115
|
rules?: string[];
|
|
110
116
|
/** A revoked entry: what was revoked. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-audit.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-audit.ts"],"names":[],"mappings":"AAgFA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,gBAAgB,YAC3B,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,gBAAgB,CACR,CAAC;AACX,MAAM,M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E,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAOjI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GateOrigin } from "./gate-origin.js";
|
|
2
2
|
import type { GateApprover, GatePolicyDecision, ResolvedGateApproval } from "../op/gate-approval.js";
|
|
3
|
-
import type { GateRunLocator } from "../op/gate-
|
|
3
|
+
import type { GateRunLocator } from "../op/gate-run-locator.js";
|
|
4
4
|
export { DEFAULT_GATE_EXPIRY, isApprovalUrl, resolveApprovalUrl } from "./gate-pending.js";
|
|
5
5
|
export { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, latestResolutionSince, type PlanBoundResolution, } from "./gate-ledger-select.js";
|
|
6
6
|
/** The directory on the `chant/lifecycle` branch that holds gate ledgers, under a member's prefix when it has one. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-ledger.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-ledger.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"gate-ledger.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-ledger.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGxF,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,E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E,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAmD1F;AAED,oNAAoN;AACpN,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC;IAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAGjE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a resume would start again, decided from the ledger alone (#3858).
|
|
3
|
+
*
|
|
4
|
+
* `chant run resume` starts again the CI job behind a gate an approval now
|
|
5
|
+
* answers (`./gate-resume.ts`). A product that resumes in its own job, such
|
|
6
|
+
* as terragucci's GitHub and Forgejo resume job, which applies the waves
|
|
7
|
+
* itself from wave 1 with a read-only token, needs the same decision without
|
|
8
|
+
* the forge call. {@link planGateResumes} makes it, per gate:
|
|
9
|
+
*
|
|
10
|
+
* - A standing pending fact (the newest per gate and environment, not
|
|
11
|
+
* expired) is resumable when an approval answers it, or when the decision
|
|
12
|
+
* point it cites has an answer the gate passes on. One whose answering
|
|
13
|
+
* approval a wave already applied under (`approvals.spend`,
|
|
14
|
+
* `_gates/<op>/applied.jsonl`, #3784) is `spent`: that apply ran, so there
|
|
15
|
+
* is nothing to resume, and a resumed run would only wait again.
|
|
16
|
+
* - An apply that stopped: the newest applied line of a gate carries a run
|
|
17
|
+
* locator (`resume`), no `finished` line says how it ended, and no pending
|
|
18
|
+
* fact of the gate is newer. It is resumable once the run that applied is
|
|
19
|
+
* gone, which only the forge can say: the caller checks that
|
|
20
|
+
* (`resumeGateRun` does, and `chant run resume --dry-run` asks it without
|
|
21
|
+
* starting anything). The resumed wave applies the rest under the same
|
|
22
|
+
* approval.
|
|
23
|
+
*
|
|
24
|
+
* Pure: no git, no forge, no clock, no Ajv. It imports the run locator's
|
|
25
|
+
* check, the ledger's selection rules and `pointGateResumable`, all of which
|
|
26
|
+
* bundle on their own, so a product can bundle
|
|
27
|
+
* `@intentius/chant/op/gate-resume-plan` (`gate-resume-plan-bundle.test.ts`).
|
|
28
|
+
*/
|
|
29
|
+
import type { GateResolutionRecord, PendingGateRecord } from "../lifecycle/gate-ledger.js";
|
|
30
|
+
import { type AppliedGateLine, type FinishedGateRecord } from "../lifecycle/gate-applied.js";
|
|
31
|
+
import { type PointQuestionState } from "../point-decision.js";
|
|
32
|
+
import { type GateRunLocator } from "./gate-run-locator.js";
|
|
33
|
+
/**
|
|
34
|
+
* Why a gate would or would not resume:
|
|
35
|
+
*
|
|
36
|
+
* - `approved`: an approval answers its standing pending fact, and no wave applied under it yet.
|
|
37
|
+
* - `answered`: the decision point it waits on has an answer the gate passes on.
|
|
38
|
+
* - `not-approved`: nothing answers it yet.
|
|
39
|
+
* - `spent`: the approval that answers it is spent; a wave already applied under it.
|
|
40
|
+
* - `stopped`: an apply under an approval stopped before it said how it ended.
|
|
41
|
+
*/
|
|
42
|
+
export type GateResumeReason = "approved" | "answered" | "not-approved" | "spent" | "stopped";
|
|
43
|
+
/** One gate a resume looks at, and what the ledger says about it. */
|
|
44
|
+
export interface GateResumeCandidate {
|
|
45
|
+
/** A standing pending fact, or an apply under an approval that stopped. */
|
|
46
|
+
source: "pending" | "stopped";
|
|
47
|
+
op: string;
|
|
48
|
+
gate: string;
|
|
49
|
+
environment?: string;
|
|
50
|
+
planDigest?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The ledger says to resume it. For `stopped`, only once the run that
|
|
53
|
+
* applied is gone, which the caller checks with the forge.
|
|
54
|
+
*/
|
|
55
|
+
resumable: boolean;
|
|
56
|
+
reason: GateResumeReason;
|
|
57
|
+
message: string;
|
|
58
|
+
approvedBy?: string;
|
|
59
|
+
/** The answering approval's timestamp, or the answer's date. A Forgejo run created after it was already resumed. */
|
|
60
|
+
approvedAt?: string;
|
|
61
|
+
/** The job to start again: the pending fact's `resume`, or the stopped apply's. */
|
|
62
|
+
run?: GateRunLocator;
|
|
63
|
+
/** The wave applied under the answering approval at `appliedAt`. */
|
|
64
|
+
spent?: {
|
|
65
|
+
appliedAt: string;
|
|
66
|
+
approvedAt: string;
|
|
67
|
+
wave?: {
|
|
68
|
+
number: number;
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/** The apply that stopped: when it began, the approval it ran under, and its wave. */
|
|
73
|
+
stopped?: {
|
|
74
|
+
appliedAt: string;
|
|
75
|
+
approvedAt: string;
|
|
76
|
+
kind: AppliedGateLine["kind"];
|
|
77
|
+
wave?: {
|
|
78
|
+
number: number;
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/** The standing pending fact, for a product that reads its own fields (a commit, a description). */
|
|
83
|
+
pending?: PendingGateRecord;
|
|
84
|
+
}
|
|
85
|
+
/** The resolution that answers `standing` under its approval block (`resolutionAnswering` in `./gate-resume.ts`). */
|
|
86
|
+
export type GateAnswering = (resolutions: readonly GateResolutionRecord[], standing: PendingGateRecord, pending: readonly PendingGateRecord[]) => GateResolutionRecord | undefined;
|
|
87
|
+
export interface PlanGateResumesInput {
|
|
88
|
+
/** The op whose ledger these are. */
|
|
89
|
+
op: string;
|
|
90
|
+
pending: readonly PendingGateRecord[];
|
|
91
|
+
resolutions: readonly GateResolutionRecord[];
|
|
92
|
+
/** The `applied` and `changes` lines of `_gates/<op>/applied.jsonl` (`parseAppliedGateFile`). */
|
|
93
|
+
applied?: readonly AppliedGateLine[];
|
|
94
|
+
/** Its `finished` lines. */
|
|
95
|
+
finished?: readonly FinishedGateRecord[];
|
|
96
|
+
now: string;
|
|
97
|
+
/** Only this gate. */
|
|
98
|
+
gate?: string;
|
|
99
|
+
/** The workspace's questions by id, for a fact that cites a decision point. */
|
|
100
|
+
questions?: ReadonlyMap<string, PointQuestionState>;
|
|
101
|
+
/**
|
|
102
|
+
* Which resolution answers a fact. Default: the newest approval of its plan
|
|
103
|
+
* since the fact. A fact with an `approval` block (a quorum, a policy)
|
|
104
|
+
* needs chant's tally: pass `resolutionAnswering` from
|
|
105
|
+
* `@intentius/chant/op/gate-resume`, which `chant run resume` uses.
|
|
106
|
+
*/
|
|
107
|
+
answering?: GateAnswering;
|
|
108
|
+
}
|
|
109
|
+
/** The newest pending fact per gate and environment: the facts a run still waits on. */
|
|
110
|
+
export declare function standingGateFacts(pending: readonly PendingGateRecord[], gate?: string): PendingGateRecord[];
|
|
111
|
+
/** Decide, for each standing pending fact and each stopped apply of an op, whether a resume would start its job again and why. */
|
|
112
|
+
export declare function planGateResumes(input: PlanGateResumesInput): GateResumeCandidate[];
|
|
113
|
+
//# sourceMappingURL=gate-resume-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-resume-plan.d.ts","sourceRoot":"","sources":["../../src/op/gate-resume-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,EAAkC,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE1H,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9F,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAClC,2EAA2E;IAC3E,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;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AAE,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACpD;;;;;OAKG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAID,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAS3G;AAiBD,kIAAkI;AAClI,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,EAAE,CA8DlF"}
|
package/dist/op/gate-resume.d.ts
CHANGED
|
@@ -1,64 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resume the job that waits at a gate (#3683).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* When the job runs in CI, the pending fact it records carries a
|
|
10
|
-
* {@link GateRunLocator}, read from the job's environment by
|
|
11
|
-
* {@link resolveGateRunLocator}: which forge, the API base, the repository,
|
|
12
|
-
* the run, and what the forge needs to start it again. After an approval,
|
|
13
|
-
* {@link resumeGateRun} starts it again:
|
|
14
|
-
*
|
|
15
|
-
* | Forge | Call | Token |
|
|
16
|
-
* |---|---|---|
|
|
17
|
-
* | GitHub | `POST /repos/{repo}/actions/runs/{run}/rerun-failed-jobs` | `actions: write` (the job's `GITHUB_TOKEN` with that permission, or a fine-grained token with Actions read and write) |
|
|
18
|
-
* | GitLab | `POST /projects/{id}/jobs/{job}/retry` | a project or personal access token with the `api` scope and the Developer role; `CI_JOB_TOKEN` cannot retry jobs |
|
|
19
|
-
* | Forgejo | `POST /repos/{repo}/actions/workflows/{file}/dispatches` on the run's branch | a token with the `write:repository` scope; Forgejo has no API to re-run a run, so it starts a new run of the workflow |
|
|
20
|
-
*
|
|
21
|
-
* GitHub re-runs the failed job and the jobs that need it, at the same
|
|
22
|
-
* commit. GitLab retries the job, and the jobs it skipped run after it. A
|
|
23
|
-
* Forgejo dispatch runs the whole workflow again at the branch's head, so the
|
|
24
|
-
* jobs before the gate run again too; they must be safe to repeat (a wave
|
|
25
|
-
* whose runs already applied plans nothing and applies nothing new).
|
|
26
|
-
*
|
|
27
|
-
* Resuming approves nothing. The resumed job decides the gate again from the
|
|
28
|
-
* ledger, so resuming a run whose approval does not count only makes it wait
|
|
29
|
-
* again. {@link resumeGateRun} skips a run that is still going, that ended
|
|
30
|
-
* well, or that was already resumed (a later GitHub attempt, a newer GitLab
|
|
31
|
-
* job of the same name, a newer Forgejo run of the workflow), so a scheduled
|
|
32
|
-
* resume job can call it every few minutes without starting a run twice.
|
|
2
|
+
* Resume the job that waits at a gate (#3683). The forge calls,
|
|
3
|
+
* {@link resumeGateRun} and {@link resumeTokenFromEnv}, live in
|
|
4
|
+
* `../gate-resume-run.ts`, which bundles without the workspace code (#3854),
|
|
5
|
+
* and are re-exported here so `@intentius/chant/op/gate-resume` keeps working.
|
|
6
|
+
* This module adds {@link resolutionAnswering}, which decides whether an
|
|
7
|
+
* approval answers a pending fact the way a run decides the gate, and so reads
|
|
8
|
+
* `./gate`'s quorum rules.
|
|
33
9
|
*/
|
|
34
|
-
import { type ForgeFetch, type ForgeKind } from "../pr-forge.js";
|
|
35
10
|
import type { GateResolutionRecord, PendingGateRecord } from "../lifecycle/gate-ledger.js";
|
|
36
|
-
|
|
37
|
-
export { isGateRunLocator, resolveGateRunLocator, type GateRunLocator } from "./gate-run-locator.js";
|
|
38
|
-
/** What {@link resumeGateRun} did. */
|
|
39
|
-
export type GateResumeOutcome = {
|
|
40
|
-
status: "resumed";
|
|
41
|
-
forge: ForgeKind;
|
|
42
|
-
how: string;
|
|
43
|
-
url?: string;
|
|
44
|
-
} | {
|
|
45
|
-
status: "skipped";
|
|
46
|
-
forge: ForgeKind;
|
|
47
|
-
reason: string;
|
|
48
|
-
url?: string;
|
|
49
|
-
};
|
|
50
|
-
export interface ResumeGateRunOptions {
|
|
51
|
-
token: string;
|
|
52
|
-
/** The approval's time. A Forgejo run of the workflow created after it means the run was already resumed. */
|
|
53
|
-
since?: string;
|
|
54
|
-
fetch?: ForgeFetch;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Start the job a pending fact's locator names again, or say why not. Throws
|
|
58
|
-
* {@link ForgeApiError} when the forge refuses a call, such as a token
|
|
59
|
-
* without the access the table in the module doc lists.
|
|
60
|
-
*/
|
|
61
|
-
export declare function resumeGateRun(loc: GateRunLocator, opts: ResumeGateRunOptions): Promise<GateResumeOutcome>;
|
|
11
|
+
export { isGateRunLocator, resolveGateRunLocator, resumeGateRun, resumeTokenFromEnv, type GateResumeOutcome, type GateRunLocator, type ResumeGateRunOptions, } from "../gate-resume-run.js";
|
|
62
12
|
/**
|
|
63
13
|
* The resolution that answers `standing`, read the way a run decides the gate
|
|
64
14
|
* (the plan, the environment, the quorum), or undefined. `pending` is the
|
|
@@ -68,10 +18,4 @@ export declare function resumeGateRun(loc: GateRunLocator, opts: ResumeGateRunOp
|
|
|
68
18
|
* waits again when the approval does not count.
|
|
69
19
|
*/
|
|
70
20
|
export declare function resolutionAnswering(resolutions: readonly GateResolutionRecord[], standing: PendingGateRecord, pending?: readonly PendingGateRecord[]): GateResolutionRecord | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* The token a resume uses: `CHANT_FORGE_TOKEN`, else the forge's own
|
|
73
|
-
* (`GITHUB_TOKEN` or `GH_TOKEN` on GitHub and Forgejo, `GITLAB_TOKEN` on
|
|
74
|
-
* GitLab), the same order the pull-request loop reads (`../pr-forge.ts`).
|
|
75
|
-
*/
|
|
76
|
-
export declare function resumeTokenFromEnv(forge: ForgeKind, env?: Record<string, string | undefined>): string | undefined;
|
|
77
21
|
//# sourceMappingURL=gate-resume.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../src/op/gate-resume.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../src/op/gate-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIxF,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,SAAS,oBAAoB,EAAE,EAC5C,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,SAAS,iBAAiB,EAAe,GACjD,oBAAoB,GAAG,SAAS,CASlC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Where a CI job that waits at a gate runs, and what its forge needs to start
|
|
3
3
|
* it again (#3683). Read from the job's environment when a pending fact is
|
|
4
|
-
* recorded;
|
|
4
|
+
* recorded; `../gate-resume-run.ts` uses it to resume the job. It imports nothing
|
|
5
5
|
* at run time, so `@intentius/chant/point-decision` records it on the pending
|
|
6
6
|
* fact of a gate that asks a decision point too (#3835).
|
|
7
7
|
*/
|
package/dist/op/index.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export type { OpRunContext, PassedGate } from "./run-context.js";
|
|
|
40
40
|
export { evaluateGate, gitGateLedgerPort, memoryGateLedgerPort, approveCommand, describeGateMismatch, gateIsSealed } from "./gate.js";
|
|
41
41
|
export type { GateLedgerPort, GateCheck, GateCheckInput, PendingGatePush, GateDigestMismatch, GateQuorumProgress, GateTally } from "./gate.js";
|
|
42
42
|
export { tallyGateApprovals, humanQuorumSince, approverOf } from "./gate.js";
|
|
43
|
+
export { planGateResumes, standingGateFacts } from "./gate-resume-plan.js";
|
|
44
|
+
export type { GateResumeCandidate, GateResumeReason, GateAnswering, PlanGateResumesInput } from "./gate-resume-plan.js";
|
|
43
45
|
export { gateApprovalProblems, gateContextDigest, gatePolicyRequest, gatePolicyVersion, isGatePolicyRef, loadGatePolicyEvaluator, GATE_APPROVAL_MODES, } from "./gate-approval.js";
|
|
44
46
|
export type { GateApproval, GateApprovalMode, GateApprover, GateContextValue, GatePolicyAnswer, GatePolicyDecision, GatePolicyEvaluator, GatePolicyRef, GatePolicyRequest, GateQuorum, ResolvedGateApproval, } from "./gate-approval.js";
|
|
45
47
|
export { gatePlanSummary, gatePlanSummaryOfResult, changeSetOfResult, GATE_PLAN_CONTEXT_KEY, GATE_PLAN_ADDRESS_LIMIT, } from "./gate-plan-context.js";
|