effect-ci 0.1.4 → 0.1.6
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/chunks/check-evidence-3YCQB4UF.js +16 -0
- package/dist/chunks/{chunk-QRAH3KJT.js → chunk-GQZMYLA7.js} +122 -39
- package/dist/chunks/{chunk-VWYQILHI.js → chunk-MTN4L6SJ.js} +4 -1
- package/dist/chunks/chunk-ZPGG2RJN.js +84 -0
- package/dist/chunks/{src-IWEQXF4N.js → src-OLOASQSN.js} +50 -46
- package/dist/directory-deployment.js +1 -1
- package/dist/effect-ci.js +6 -1
- package/dist/index.js +1 -1
- package/dist/input-evidence.js +15 -1
- package/dist/types/index.d.ts +11 -3
- package/dist/types/input-evidence-match.d.ts +90 -0
- package/dist/types/input-evidence.d.ts +12 -24
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
environmentCheckCache,
|
|
3
|
+
hostTrustedCheckCache,
|
|
4
|
+
loadTrustedEvidence,
|
|
5
|
+
receiptCheckCache,
|
|
6
|
+
trustedEvidenceCheckCache
|
|
7
|
+
} from "./chunk-ZPGG2RJN.js";
|
|
8
|
+
import "./chunk-GQZMYLA7.js";
|
|
9
|
+
import "./chunk-Q5USMIJ3.js";
|
|
10
|
+
export {
|
|
11
|
+
environmentCheckCache,
|
|
12
|
+
hostTrustedCheckCache,
|
|
13
|
+
loadTrustedEvidence,
|
|
14
|
+
receiptCheckCache,
|
|
15
|
+
trustedEvidenceCheckCache
|
|
16
|
+
};
|
|
@@ -8,6 +8,74 @@ import { createHash, sign, verify } from "node:crypto";
|
|
|
8
8
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
9
9
|
import { relative, resolve } from "node:path";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
|
+
|
|
12
|
+
// ../ci/src/input-evidence-match.ts
|
|
13
|
+
var lockfiles = {
|
|
14
|
+
"pnpm-lock.yaml": "pnpm",
|
|
15
|
+
"package-lock.json": "npm",
|
|
16
|
+
"yarn.lock": "yarn",
|
|
17
|
+
"bun.lock": "bun",
|
|
18
|
+
"bun.lockb": "bun"
|
|
19
|
+
};
|
|
20
|
+
var isInstalledDependency = (path) => path.split("/").includes("node_modules");
|
|
21
|
+
function inputEvidenceMismatch(evidence, fs) {
|
|
22
|
+
const covered = evidence.lockfile !== void 0;
|
|
23
|
+
if (evidence.lockfile) {
|
|
24
|
+
const { path, sha256: sha2562, packageManager: packageManager2 } = evidence.lockfile;
|
|
25
|
+
if (fs.kind(path) !== "file" || fs.sha256(path) !== sha2562) return `lockfile ${path} changed`;
|
|
26
|
+
const current = fs.packageManager();
|
|
27
|
+
if (current !== void 0 && current !== packageManager2) return `package manager ${current}, not ${packageManager2}`;
|
|
28
|
+
}
|
|
29
|
+
for (const [path, input] of Object.entries(evidence.inputs)) {
|
|
30
|
+
if (path === ".." || path.startsWith("../") || path.startsWith("/")) return `outside the root: ${path}`;
|
|
31
|
+
if (covered && path.split("/").includes("node_modules")) continue;
|
|
32
|
+
const kind = fs.kind(path);
|
|
33
|
+
switch (input.type) {
|
|
34
|
+
case "missing":
|
|
35
|
+
if (kind !== "missing") return `${path} exists`;
|
|
36
|
+
break;
|
|
37
|
+
case "file":
|
|
38
|
+
if (kind === "missing") {
|
|
39
|
+
if (!input.mayBeMissing) return `${path} is missing`;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
if (kind !== "file" || fs.sha256(path) !== input.sha256) return `${path} changed`;
|
|
43
|
+
break;
|
|
44
|
+
case "dir": {
|
|
45
|
+
if (kind === "missing") {
|
|
46
|
+
if (!input.mayBeMissing) return `${path} is missing`;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
if (kind !== "dir") return `${path} is not a directory`;
|
|
50
|
+
if (input.entries) {
|
|
51
|
+
const ignored = (entry) => entry === ".git" || path === "." && entry === ".effect-ci";
|
|
52
|
+
const entries = fs.entries(path).filter((entry) => !ignored(entry)).sort();
|
|
53
|
+
const expected = [...input.entries].filter((entry) => !ignored(entry)).sort();
|
|
54
|
+
if (entries.join("\0") !== expected.join("\0")) {
|
|
55
|
+
const added = entries.filter((entry) => !expected.includes(entry));
|
|
56
|
+
const removed = expected.filter((entry) => !entries.includes(entry));
|
|
57
|
+
return `${path} entries changed (+${added.join(",")} -${removed.join(",")})`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const [name, digest] of Object.entries(evidence.env)) {
|
|
64
|
+
if (fs.env(name) !== digest) return `env ${name} changed`;
|
|
65
|
+
}
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
var canonical = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
|
|
69
|
+
var receiptSubject = (request, repo) => request.policy.scope === "inputs" && request.trace ? {
|
|
70
|
+
repo,
|
|
71
|
+
workflowId: request.workflowId.split("/")[0],
|
|
72
|
+
stepId: request.stepId,
|
|
73
|
+
task: request.trace.task,
|
|
74
|
+
command: request.command,
|
|
75
|
+
scope: "inputs"
|
|
76
|
+
} : void 0;
|
|
77
|
+
|
|
78
|
+
// ../ci/src/input-evidence.ts
|
|
11
79
|
var inputEvidenceKey = (request) => JSON.stringify({
|
|
12
80
|
command: request.command,
|
|
13
81
|
repository: request.event.source?.kind === "git" ? request.event.source.repository : void 0,
|
|
@@ -27,9 +95,26 @@ var git = (cwd, args, input) => execFileSync("git", args, {
|
|
|
27
95
|
stdio: ["pipe", "pipe", "ignore"]
|
|
28
96
|
}).trim();
|
|
29
97
|
var keyObject = (cwd, key) => git(cwd, ["hash-object", "--stdin"], key);
|
|
30
|
-
var canonical = (evidence) => JSON.stringify(evidence, (_key, value) => value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : value);
|
|
31
98
|
var leafSteps = (plan) => Object.values(plan).flatMap((task) => task.steps.flatMap((step) => step.plan ? leafSteps(step.plan) : [step]));
|
|
32
99
|
var digestFile = (path) => sha256(readFileSync(path));
|
|
100
|
+
var packageManager = (root) => {
|
|
101
|
+
try {
|
|
102
|
+
const manifest = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8"));
|
|
103
|
+
if (typeof manifest.packageManager === "string" && manifest.packageManager) return manifest.packageManager;
|
|
104
|
+
const engine = manifest.devEngines?.packageManager;
|
|
105
|
+
return typeof engine?.name === "string" && typeof engine.version === "string" ? `${engine.name}@${engine.version}` : void 0;
|
|
106
|
+
} catch {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var lockfileEvidence = (root) => {
|
|
111
|
+
for (const [path, manager] of Object.entries(lockfiles)) {
|
|
112
|
+
const absolute = resolve(root, path);
|
|
113
|
+
if (existsSync(absolute))
|
|
114
|
+
return { path, sha256: digestFile(absolute), packageManager: packageManager(root) ?? manager };
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
};
|
|
33
118
|
var traceRun = (cwd, task) => {
|
|
34
119
|
const body = execFileSync("sh", ["-c", 'PATH="$PATH:$PWD/node_modules/.bin" exec vp run --dry-run --json --cache -vv "$1"', "sh", task], {
|
|
35
120
|
cwd,
|
|
@@ -63,9 +148,14 @@ var traceRun = (cwd, task) => {
|
|
|
63
148
|
}
|
|
64
149
|
const inputs = {};
|
|
65
150
|
const env = {};
|
|
151
|
+
let dependencies = false;
|
|
66
152
|
for (const step of steps) {
|
|
67
153
|
const fingerprint = step.cache?.baseline?.fingerprint;
|
|
68
154
|
for (const [path, input] of Object.entries(fingerprint?.inputs ?? {})) {
|
|
155
|
+
if (isInstalledDependency(path)) {
|
|
156
|
+
dependencies = true;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
69
159
|
const absolute = resolve(plan.workspaceRoot, path);
|
|
70
160
|
if (input.type === "file") {
|
|
71
161
|
if (!existsSync(absolute)) {
|
|
@@ -79,45 +169,31 @@ var traceRun = (cwd, task) => {
|
|
|
79
169
|
env[name] = value === void 0 ? null : sha256(value);
|
|
80
170
|
}
|
|
81
171
|
}
|
|
82
|
-
|
|
172
|
+
const lockfile = dependencies ? lockfileEvidence(plan.workspaceRoot) : void 0;
|
|
173
|
+
if (dependencies && !lockfile) return void 0;
|
|
174
|
+
return {
|
|
175
|
+
root: relative(realpathSync(cwd), realpathSync(plan.workspaceRoot)) || ".",
|
|
176
|
+
inputs,
|
|
177
|
+
env,
|
|
178
|
+
...lockfile ? { lockfile } : {}
|
|
179
|
+
};
|
|
83
180
|
};
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
switch (input.type) {
|
|
92
|
-
case "missing":
|
|
93
|
-
if (exists) return false;
|
|
94
|
-
break;
|
|
95
|
-
case "file":
|
|
96
|
-
if (!exists) {
|
|
97
|
-
if (!input.mayBeMissing) return false;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (!statSync(absolute).isFile() || digestFile(absolute) !== input.sha256) return false;
|
|
101
|
-
break;
|
|
102
|
-
case "dir": {
|
|
103
|
-
if (!exists) {
|
|
104
|
-
if (!input.mayBeMissing) return false;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
if (!statSync(absolute).isDirectory()) return false;
|
|
108
|
-
if (input.entries) {
|
|
109
|
-
const entries = readdirSync(absolute).filter((entry) => entry !== ".git").sort();
|
|
110
|
-
if (entries.join("\0") !== [...input.entries].sort().join("\0")) return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
181
|
+
var localEvidenceFileSystem = (root) => ({
|
|
182
|
+
kind: (path) => {
|
|
183
|
+
try {
|
|
184
|
+
const stat = statSync(resolve(root, path));
|
|
185
|
+
return stat.isFile() ? "file" : stat.isDirectory() ? "dir" : "other";
|
|
186
|
+
} catch {
|
|
187
|
+
return "missing";
|
|
113
188
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
189
|
+
},
|
|
190
|
+
sha256: (path) => digestFile(resolve(root, path)),
|
|
191
|
+
entries: (path) => readdirSync(resolve(root, path)),
|
|
192
|
+
env: (name) => process.env[name] === void 0 ? null : sha256(process.env[name]),
|
|
193
|
+
packageManager: () => packageManager(root)
|
|
194
|
+
});
|
|
195
|
+
var inputEvidenceMismatchAt = (cwd, evidence) => inputEvidenceMismatch(evidence, localEvidenceFileSystem(resolve(cwd, evidence.root)));
|
|
196
|
+
var matchesInputEvidence = (cwd, evidence) => inputEvidenceMismatchAt(cwd, evidence) === void 0;
|
|
121
197
|
var notesRef = (options) => `--ref=${options.ref ?? "effect-ci-inputs"}`;
|
|
122
198
|
var readInputEvidenceRecords = (options, key) => {
|
|
123
199
|
try {
|
|
@@ -160,8 +236,15 @@ var inputEvidenceCheckCache = (options) => ({
|
|
|
160
236
|
});
|
|
161
237
|
|
|
162
238
|
export {
|
|
163
|
-
|
|
239
|
+
lockfiles,
|
|
240
|
+
isInstalledDependency,
|
|
241
|
+
inputEvidenceMismatch,
|
|
164
242
|
canonical,
|
|
243
|
+
receiptSubject,
|
|
244
|
+
inputEvidenceKey,
|
|
245
|
+
traceRun,
|
|
246
|
+
localEvidenceFileSystem,
|
|
247
|
+
inputEvidenceMismatchAt,
|
|
165
248
|
matchesInputEvidence,
|
|
166
249
|
readInputEvidenceRecords,
|
|
167
250
|
writeInputEvidenceRecords,
|
|
@@ -1763,7 +1763,10 @@ var makeRuntime = (workflowId, ci, mode, output, emitEvent, event, approvalHandl
|
|
|
1763
1763
|
});
|
|
1764
1764
|
})() : Effect2.void;
|
|
1765
1765
|
const reuse = definitions.get(stepId)?.options.reuse;
|
|
1766
|
-
const policy = reuse && {
|
|
1766
|
+
const policy = reuse && {
|
|
1767
|
+
scope: reuse === true ? "inputs" : reuse.scope ?? "inputs",
|
|
1768
|
+
...reuse !== true && reuse.agents === false ? { agents: false } : {}
|
|
1769
|
+
};
|
|
1767
1770
|
const checkCacheRequest = policy && !execOptions?.diagnostic ? {
|
|
1768
1771
|
command: command2,
|
|
1769
1772
|
event,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonical,
|
|
3
|
+
inputEvidenceCheckCache,
|
|
4
|
+
inputEvidenceMismatchAt,
|
|
5
|
+
receiptSubject,
|
|
6
|
+
traceRun
|
|
7
|
+
} from "./chunk-GQZMYLA7.js";
|
|
8
|
+
|
|
9
|
+
// ../cli/src/check-evidence.ts
|
|
10
|
+
import { readFileSync, rmSync } from "node:fs";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
var pem = (root, value) => !value ? void 0 : value.includes("-----BEGIN ") ? value : readFileSync(resolve(root, value), "utf8");
|
|
14
|
+
var environmentCheckCache = (root, env = process.env) => {
|
|
15
|
+
const publicKey = pem(root, env.EFFECT_CI_CHECK_PUBLIC_KEY);
|
|
16
|
+
if (!publicKey) return void 0;
|
|
17
|
+
const privateKey = pem(root, env.EFFECT_CI_CHECK_PRIVATE_KEY);
|
|
18
|
+
return inputEvidenceCheckCache({ cwd: root, publicKey, ...privateKey ? { privateKey } : {} });
|
|
19
|
+
};
|
|
20
|
+
var receiptCheckCache = (host, fetchImpl = fetch) => ({
|
|
21
|
+
lookup: () => Effect.succeed(false),
|
|
22
|
+
record: (request) => Effect.gen(function* () {
|
|
23
|
+
const subject = receiptSubject(request, host.repo);
|
|
24
|
+
if (!subject || request.workspace.kind !== "local" || request.policy.agents === false) return;
|
|
25
|
+
const evidence = traceRun(request.workspace.cwd, subject.task);
|
|
26
|
+
if (!evidence) {
|
|
27
|
+
yield* Effect.logWarning(`${request.stepId}: Vite+ did not trace a cached run, so there is no evidence for a receipt`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { repo, ...rest } = subject;
|
|
31
|
+
const response = yield* Effect.tryPromise(async () => fetchImpl(new URL("/receipts", host.url), {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: await host.headers(),
|
|
34
|
+
body: JSON.stringify({ repo, subject: rest, evidence })
|
|
35
|
+
}));
|
|
36
|
+
if (response.status !== 201) {
|
|
37
|
+
yield* Effect.logWarning(`${request.stepId}: the host did not issue a receipt (${response.status} ${(yield* Effect.promise(() => response.text())).slice(0, 200)})`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { claim } = yield* Effect.promise(() => response.json());
|
|
41
|
+
yield* Effect.logWarning(`${request.stepId}: receipt from ${new URL(host.url).host} for ${claim.agent} (evidence ${claim.evidence.slice(0, 12)})`);
|
|
42
|
+
}).pipe(Effect.catch((error) => Effect.logWarning(`${request.stepId}: could not submit evidence for a receipt: ${String(error)}`)))
|
|
43
|
+
});
|
|
44
|
+
var trusted = [];
|
|
45
|
+
var loadTrustedEvidence = (path) => {
|
|
46
|
+
if (!path) return;
|
|
47
|
+
try {
|
|
48
|
+
trusted = JSON.parse(readFileSync(path, "utf8"));
|
|
49
|
+
} catch {
|
|
50
|
+
trusted = [];
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
rmSync(path);
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var trustedEvidenceCheckCache = (entries) => ({
|
|
58
|
+
lookup: (request) => Effect.gen(function* () {
|
|
59
|
+
const subject = receiptSubject(request, "");
|
|
60
|
+
if (!subject || request.workspace.kind !== "local") return false;
|
|
61
|
+
if (request.policy.agents === false) return false;
|
|
62
|
+
const { repo: _, ...check } = subject;
|
|
63
|
+
for (const entry of entries) {
|
|
64
|
+
if (canonical(entry.subject) !== canonical(check)) continue;
|
|
65
|
+
const mismatch = inputEvidenceMismatchAt(request.workspace.cwd, entry.evidence);
|
|
66
|
+
if (mismatch === void 0) {
|
|
67
|
+
yield* Effect.logWarning(`${request.stepId}: verified by the receipt for ${entry.agent} (${entry.issuedAt})`);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
yield* Effect.logWarning(`${request.stepId}: the receipt for ${entry.agent} (${entry.issuedAt}) does not match: ${mismatch}`);
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}),
|
|
74
|
+
record: () => Effect.void
|
|
75
|
+
});
|
|
76
|
+
var hostTrustedCheckCache = () => trusted.length ? trustedEvidenceCheckCache(trusted) : void 0;
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
environmentCheckCache,
|
|
80
|
+
receiptCheckCache,
|
|
81
|
+
loadTrustedEvidence,
|
|
82
|
+
trustedEvidenceCheckCache,
|
|
83
|
+
hostTrustedCheckCache
|
|
84
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
environmentCheckCache,
|
|
3
|
+
hostTrustedCheckCache,
|
|
4
|
+
receiptCheckCache
|
|
5
|
+
} from "./chunk-ZPGG2RJN.js";
|
|
6
|
+
import "./chunk-GQZMYLA7.js";
|
|
4
7
|
import {
|
|
5
8
|
ApprovalError,
|
|
6
9
|
CommandCheckpointError,
|
|
@@ -17,7 +20,7 @@ import {
|
|
|
17
20
|
parallel,
|
|
18
21
|
runPromise,
|
|
19
22
|
workflow
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MTN4L6SJ.js";
|
|
21
24
|
import {
|
|
22
25
|
decodeCommandDiagnostics
|
|
23
26
|
} from "./chunk-WGBTI7DS.js";
|
|
@@ -240,10 +243,10 @@ effect-ci oidc -- <deploy command> Deploy using temporary creden
|
|
|
240
243
|
try {
|
|
241
244
|
const env = { ...process.env, CLOUDFLARE_API_TOKEN: credential.token, CLOUDFLARE_ACCOUNT_ID: credential.accountId };
|
|
242
245
|
delete env.EFFECT_CI_OIDC_TOKEN;
|
|
243
|
-
process.exitCode = await new Promise((
|
|
246
|
+
process.exitCode = await new Promise((resolve3, reject) => {
|
|
244
247
|
const child = spawn(command[0], command.slice(1), { cwd, env, stdio: "inherit" });
|
|
245
248
|
child.on("error", reject);
|
|
246
|
-
child.on("exit", (code) =>
|
|
249
|
+
child.on("exit", (code) => resolve3(code ?? 1));
|
|
247
250
|
});
|
|
248
251
|
} finally {
|
|
249
252
|
const revoked = await fetch(`${issuer}/revoke`, { method: "POST", headers: { authorization: `Bearer ${credential.receipt}` }, redirect: "error", signal: AbortSignal.timeout(15e3) });
|
|
@@ -380,31 +383,20 @@ var vitePlusAvailable = (cwd) => {
|
|
|
380
383
|
}
|
|
381
384
|
};
|
|
382
385
|
|
|
383
|
-
// ../cli/src/check-evidence.ts
|
|
384
|
-
import { readFileSync as readFileSync3 } from "node:fs";
|
|
385
|
-
import { resolve } from "node:path";
|
|
386
|
-
var pem = (root, value) => !value ? void 0 : value.includes("-----BEGIN ") ? value : readFileSync3(resolve(root, value), "utf8");
|
|
387
|
-
var environmentCheckCache = (root, env = process.env) => {
|
|
388
|
-
const publicKey = pem(root, env.EFFECT_CI_CHECK_PUBLIC_KEY);
|
|
389
|
-
if (!publicKey) return void 0;
|
|
390
|
-
const privateKey = pem(root, env.EFFECT_CI_CHECK_PRIVATE_KEY);
|
|
391
|
-
return inputEvidenceCheckCache({ cwd: root, publicKey, ...privateKey ? { privateKey } : {} });
|
|
392
|
-
};
|
|
393
|
-
|
|
394
386
|
// ../cli/src/index.ts
|
|
395
|
-
import { existsSync as existsSync6, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as
|
|
387
|
+
import { existsSync as existsSync6, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync6, realpathSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
396
388
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
397
|
-
import { basename, dirname as dirname4, join as join6, relative, resolve as
|
|
389
|
+
import { basename, dirname as dirname4, join as join6, relative, resolve as resolve2 } from "node:path";
|
|
398
390
|
import { pathToFileURL } from "node:url";
|
|
399
391
|
import { parseArgs as parseArgs2, parseEnv as parseEnv3 } from "node:util";
|
|
400
392
|
|
|
401
393
|
// ../cli/src/project-env.ts
|
|
402
|
-
import { existsSync as existsSync3, readFileSync as
|
|
403
|
-
import { dirname as dirname2, join as join3, resolve
|
|
394
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
395
|
+
import { dirname as dirname2, join as join3, resolve } from "node:path";
|
|
404
396
|
import { parseEnv } from "node:util";
|
|
405
397
|
function projectEnvironment(cwd) {
|
|
406
398
|
const directories = [];
|
|
407
|
-
for (let directory =
|
|
399
|
+
for (let directory = resolve(cwd); ; directory = dirname2(directory)) {
|
|
408
400
|
directories.unshift(directory);
|
|
409
401
|
if (existsSync3(join3(directory, ".git")) || dirname2(directory) === directory) break;
|
|
410
402
|
}
|
|
@@ -412,7 +404,7 @@ function projectEnvironment(cwd) {
|
|
|
412
404
|
for (const directory of directories) {
|
|
413
405
|
for (const name of [".env", ".env.local"]) {
|
|
414
406
|
const path = join3(directory, name);
|
|
415
|
-
if (existsSync3(path)) Object.assign(settings, parseEnv(
|
|
407
|
+
if (existsSync3(path)) Object.assign(settings, parseEnv(readFileSync3(path, "utf8")));
|
|
416
408
|
}
|
|
417
409
|
}
|
|
418
410
|
if (settings.EFFECT_CI_PUBLIC_URL) settings.EFFECT_CI_REMOTE_URL ??= settings.EFFECT_CI_PUBLIC_URL;
|
|
@@ -570,7 +562,7 @@ function makeLocalProjectChecks(options = {}) {
|
|
|
570
562
|
|
|
571
563
|
// ../cli/src/login.ts
|
|
572
564
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
573
|
-
import { chmodSync, existsSync as existsSync4, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as
|
|
565
|
+
import { chmodSync, existsSync as existsSync4, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
574
566
|
import { homedir as homedir2 } from "node:os";
|
|
575
567
|
import { dirname as dirname3, join as join4 } from "node:path";
|
|
576
568
|
var userConfigPath = () => process.env.EFFECT_CI_CONFIG || join4(homedir2(), ".config", "effect-ci", "config.json");
|
|
@@ -578,7 +570,7 @@ var readUserConfig = (path = userConfigPath()) => {
|
|
|
578
570
|
if (!existsSync4(path)) return {};
|
|
579
571
|
const file = lstatSync2(path);
|
|
580
572
|
if (!file.isFile() || file.isSymbolicLink() || file.size > 8192) throw new Error(`Invalid Effect CI config: ${path}`);
|
|
581
|
-
const value = JSON.parse(
|
|
573
|
+
const value = JSON.parse(readFileSync4(path, "utf8"));
|
|
582
574
|
if (value.version !== 1) throw new Error(`Invalid Effect CI config: ${path}`);
|
|
583
575
|
return typeof value.remoteUrl === "string" ? { remoteUrl: remoteOrigin(value.remoteUrl) } : {};
|
|
584
576
|
};
|
|
@@ -643,7 +635,7 @@ setting CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET (an Access service token
|
|
|
643
635
|
};
|
|
644
636
|
|
|
645
637
|
// ../cli/src/remote-config.ts
|
|
646
|
-
import { existsSync as existsSync5, lstatSync as lstatSync3, readFileSync as
|
|
638
|
+
import { existsSync as existsSync5, lstatSync as lstatSync3, readFileSync as readFileSync5 } from "node:fs";
|
|
647
639
|
import { join as join5 } from "node:path";
|
|
648
640
|
import { parseEnv as parseEnv2 } from "node:util";
|
|
649
641
|
var readProjectRemote = (root) => {
|
|
@@ -653,7 +645,7 @@ var readProjectRemote = (root) => {
|
|
|
653
645
|
const stat = lstatSync3(path);
|
|
654
646
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 65536)
|
|
655
647
|
throw new Error("Invalid remote configuration file");
|
|
656
|
-
const values2 = parseEnv2(
|
|
648
|
+
const values2 = parseEnv2(readFileSync5(path, "utf8"));
|
|
657
649
|
return values2;
|
|
658
650
|
};
|
|
659
651
|
const shared = read(".env"), local = read(".env.local");
|
|
@@ -672,7 +664,7 @@ var readProjectOidc = (root) => {
|
|
|
672
664
|
if (!existsSync5(path)) return void 0;
|
|
673
665
|
const file = lstatSync3(path);
|
|
674
666
|
if (!file.isFile() || file.isSymbolicLink() || file.size > 8192) throw new Error("Invalid OIDC configuration file");
|
|
675
|
-
return JSON.parse(
|
|
667
|
+
return JSON.parse(readFileSync5(path, "utf8"));
|
|
676
668
|
};
|
|
677
669
|
|
|
678
670
|
// ../cli/src/remote-diagnostics.ts
|
|
@@ -1128,7 +1120,7 @@ var followRemoteRun = async (connection, format, run) => {
|
|
|
1128
1120
|
);
|
|
1129
1121
|
}
|
|
1130
1122
|
if (format === "text") console.log("Remote logs disconnected; reconnecting to the same Workflow\u2026");
|
|
1131
|
-
await new Promise((
|
|
1123
|
+
await new Promise((resolve3) => setTimeout(resolve3, Math.min(1e3 * interruptions, 5e3)));
|
|
1132
1124
|
}
|
|
1133
1125
|
const terminal = events.at(-1);
|
|
1134
1126
|
if (terminal?.type === "workflow_errored" || terminal?.type === "workflow_terminated") {
|
|
@@ -1242,7 +1234,7 @@ var runPush = async (input, cwd, detected) => {
|
|
|
1242
1234
|
if (response?.status === 400)
|
|
1243
1235
|
throw new CliFailure("CI_REMOTE_FAILED", ExitCode.providerUnavailable, `The push succeeded, but the host could not start its run: ${detail}`, { instanceId });
|
|
1244
1236
|
if (response?.ok || response?.status === 404 || attempt === 4) break;
|
|
1245
|
-
await new Promise((
|
|
1237
|
+
await new Promise((resolve3) => setTimeout(resolve3, 1e3 * (attempt + 1)));
|
|
1246
1238
|
}
|
|
1247
1239
|
const deadline = Date.now() + 6e4;
|
|
1248
1240
|
while (true) {
|
|
@@ -1263,7 +1255,7 @@ var runPush = async (input, cwd, detected) => {
|
|
|
1263
1255
|
`The push succeeded, but no run started for ${revision} within 60 seconds. Check the Artifacts event subscription for ${target.namespace}/${target.repo}.`,
|
|
1264
1256
|
{ instanceId }
|
|
1265
1257
|
);
|
|
1266
|
-
await new Promise((
|
|
1258
|
+
await new Promise((resolve3) => setTimeout(resolve3, 1e3));
|
|
1267
1259
|
}
|
|
1268
1260
|
if (format === "text") console.log(`Remote Workflow ${instanceId}`);
|
|
1269
1261
|
const result = await followRemoteRun(connection, format, run);
|
|
@@ -1424,7 +1416,7 @@ var workflowNames = [
|
|
|
1424
1416
|
"ci.mjs"
|
|
1425
1417
|
];
|
|
1426
1418
|
var findWorkflow = (cwd) => {
|
|
1427
|
-
let directory =
|
|
1419
|
+
let directory = resolve2(cwd);
|
|
1428
1420
|
while (true) {
|
|
1429
1421
|
for (const name of workflowNames) {
|
|
1430
1422
|
const candidate = join6(directory, ".cloudflare", "ci", name);
|
|
@@ -1468,12 +1460,12 @@ var extractWorkflow = (args, cwd) => {
|
|
|
1468
1460
|
remaining.splice(positional, 1);
|
|
1469
1461
|
}
|
|
1470
1462
|
}
|
|
1471
|
-
const path = explicit ?
|
|
1463
|
+
const path = explicit ? resolve2(cwd, explicit) : findWorkflow(cwd);
|
|
1472
1464
|
if (!path || !existsSync6(path)) {
|
|
1473
1465
|
throw new CliFailure(
|
|
1474
1466
|
"CI_WORKFLOW_NOT_FOUND",
|
|
1475
1467
|
ExitCode.usage,
|
|
1476
|
-
explicit ? `Workflow not found: ${
|
|
1468
|
+
explicit ? `Workflow not found: ${resolve2(cwd, explicit)}` : `No .cloudflare/ci/workflow.ts found from ${resolve2(cwd)}`
|
|
1477
1469
|
);
|
|
1478
1470
|
}
|
|
1479
1471
|
return { args: remaining, path };
|
|
@@ -1487,7 +1479,7 @@ var loadProgram = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1487
1479
|
program: inferJavaScriptProgram(selected.path)
|
|
1488
1480
|
};
|
|
1489
1481
|
}
|
|
1490
|
-
if (basename(selected.path).startsWith("ci.") &&
|
|
1482
|
+
if (basename(selected.path).startsWith("ci.") && readFileSync6(selected.path, "utf8").trim() === "") {
|
|
1491
1483
|
return {
|
|
1492
1484
|
args: selected.args,
|
|
1493
1485
|
path: selected.path,
|
|
@@ -1529,7 +1521,7 @@ var inferJavaScriptProgram = (root) => {
|
|
|
1529
1521
|
`Zero-config CI requires a package.json at ${manifestPath}`
|
|
1530
1522
|
);
|
|
1531
1523
|
}
|
|
1532
|
-
const manifest = JSON.parse(
|
|
1524
|
+
const manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
1533
1525
|
let tasks = { names: [], dependencies: {} };
|
|
1534
1526
|
if (manifest.dependencies?.["vite-plus"] || manifest.devDependencies?.["vite-plus"]) {
|
|
1535
1527
|
try {
|
|
@@ -1562,7 +1554,7 @@ var initializeJavaScriptProject = (args, cwd) => {
|
|
|
1562
1554
|
const invocation = parseInvocation(args, void 0, cwd);
|
|
1563
1555
|
if (invocation.help || invocation.command !== "run" || invocation.location !== "local") return void 0;
|
|
1564
1556
|
requireAction(invocation.targets);
|
|
1565
|
-
const program = inferJavaScriptProgram(
|
|
1557
|
+
const program = inferJavaScriptProgram(resolve2(cwd));
|
|
1566
1558
|
selectedWorkflow(program, invocation.targets);
|
|
1567
1559
|
for (const directory of [join6(cwd, ".cloudflare"), join6(cwd, ".cloudflare", "ci")]) {
|
|
1568
1560
|
if (existsSync6(directory)) {
|
|
@@ -1586,7 +1578,19 @@ var printJson = (value) => {
|
|
|
1586
1578
|
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
1587
1579
|
`);
|
|
1588
1580
|
};
|
|
1589
|
-
var projectRoot = (workflowPath) => basename(dirname4(workflowPath)) === "ci" && basename(dirname4(dirname4(workflowPath))) === ".cloudflare" ?
|
|
1581
|
+
var projectRoot = (workflowPath) => basename(dirname4(workflowPath)) === "ci" && basename(dirname4(dirname4(workflowPath))) === ".cloudflare" ? resolve2(dirname4(workflowPath), "../..") : dirname4(workflowPath);
|
|
1582
|
+
var hostReceipts = (root) => {
|
|
1583
|
+
if (process.env.EFFECT_CI_RECEIPTS === "0") return void 0;
|
|
1584
|
+
const target = artifactsTarget(root, "cloudflare");
|
|
1585
|
+
if (!target) return void 0;
|
|
1586
|
+
try {
|
|
1587
|
+
const connection = remoteConnection(root);
|
|
1588
|
+
if (connection.workload || !connection.accessOnly) return void 0;
|
|
1589
|
+
return receiptCheckCache({ url: new URL(connection.remoteUrl).origin, repo: target.repo, headers: connection.requestHeaders });
|
|
1590
|
+
} catch {
|
|
1591
|
+
return void 0;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1590
1594
|
var defaultLocalOptions = (workflowPath) => {
|
|
1591
1595
|
const event = process.env.EFFECT_CI_EVENT ?? process.env.GITHUB_EVENT_NAME;
|
|
1592
1596
|
const revision = process.env.EFFECT_CI_REVISION ?? process.env.GITHUB_SHA;
|
|
@@ -1596,12 +1600,12 @@ var defaultLocalOptions = (workflowPath) => {
|
|
|
1596
1600
|
try {
|
|
1597
1601
|
const path = process.env.GITHUB_EVENT_PATH;
|
|
1598
1602
|
if (path && lstatSync4(path).isFile() && lstatSync4(path).size <= 4194304)
|
|
1599
|
-
payload = JSON.parse(
|
|
1603
|
+
payload = JSON.parse(readFileSync6(path, "utf8"));
|
|
1600
1604
|
} catch {
|
|
1601
1605
|
}
|
|
1602
1606
|
const comparison = process.env.EFFECT_CI_BASE_REVISION ? { base: process.env.EFFECT_CI_BASE_REVISION, ...revision ? { head: revision } : {} } : githubSourceComparison(event ?? "workflow_dispatch", payload, revision);
|
|
1603
1607
|
const approval = decision === "approved" || decision === "rejected" ? { request: () => Effect2.succeed({ decision }) } : void 0;
|
|
1604
|
-
const checkCache = environmentCheckCache(projectRoot(workflowPath));
|
|
1608
|
+
const checkCache = environmentCheckCache(projectRoot(workflowPath)) ?? hostTrustedCheckCache() ?? hostReceipts(projectRoot(workflowPath));
|
|
1605
1609
|
return {
|
|
1606
1610
|
...approval ? { approval } : {},
|
|
1607
1611
|
...checkCache ? { checkCache } : {},
|
|
@@ -1726,7 +1730,7 @@ var list = (program, format) => {
|
|
|
1726
1730
|
if (!program.requiresTarget) console.log(` effect-ci run (whole workflow)`);
|
|
1727
1731
|
for (const target of targets) console.log(` effect-ci run ${target}`);
|
|
1728
1732
|
};
|
|
1729
|
-
var main = async (program, args = process.argv.slice(2), workflowPath =
|
|
1733
|
+
var main = async (program, args = process.argv.slice(2), workflowPath = resolve2(process.cwd(), ".cloudflare/ci/workflow.ts")) => {
|
|
1730
1734
|
let format = detectedFormat();
|
|
1731
1735
|
const logs = [];
|
|
1732
1736
|
try {
|
|
@@ -1886,7 +1890,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1886
1890
|
}
|
|
1887
1891
|
let settings;
|
|
1888
1892
|
try {
|
|
1889
|
-
settings = parseEnv3(
|
|
1893
|
+
settings = parseEnv3(readFileSync6(resolve2(cwd, path), "utf8"));
|
|
1890
1894
|
} catch {
|
|
1891
1895
|
throw new CliFailure("CI_USAGE_ERROR", ExitCode.usage, `Cannot read environment file: ${path}`);
|
|
1892
1896
|
}
|
|
@@ -1927,7 +1931,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1927
1931
|
{ workflow: workflow("hosted", function* () {
|
|
1928
1932
|
}) },
|
|
1929
1933
|
args,
|
|
1930
|
-
|
|
1934
|
+
resolve2(cwd, ".cloudflare/ci/workflow.ts")
|
|
1931
1935
|
);
|
|
1932
1936
|
return;
|
|
1933
1937
|
}
|
|
@@ -1940,7 +1944,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1940
1944
|
}, cwd);
|
|
1941
1945
|
if (!invocation.help && invocation.command === "run" && !invocation.targets.length) {
|
|
1942
1946
|
const path = findWorkflow(cwd);
|
|
1943
|
-
if (!path || basename(path).startsWith("ci.") &&
|
|
1947
|
+
if (!path || basename(path).startsWith("ci.") && readFileSync6(path, "utf8").trim() === "") {
|
|
1944
1948
|
requireAction(invocation.targets);
|
|
1945
1949
|
}
|
|
1946
1950
|
}
|
|
@@ -1949,7 +1953,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1949
1953
|
{ workflow: workflow("hosted", function* () {
|
|
1950
1954
|
}) },
|
|
1951
1955
|
args,
|
|
1952
|
-
|
|
1956
|
+
resolve2(cwd, ".cloudflare/ci/workflow.ts")
|
|
1953
1957
|
);
|
|
1954
1958
|
return;
|
|
1955
1959
|
}
|
|
@@ -1961,7 +1965,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1961
1965
|
if (invocation.location === "local" && (invocation.help || invocation.command !== "run")) {
|
|
1962
1966
|
let program;
|
|
1963
1967
|
try {
|
|
1964
|
-
program = inferJavaScriptProgram(
|
|
1968
|
+
program = inferJavaScriptProgram(resolve2(cwd));
|
|
1965
1969
|
} catch (error) {
|
|
1966
1970
|
if (invocation.help && error instanceof CliFailure && ["CI_ZERO_CONFIG_UNSUPPORTED", "CI_ZERO_CONFIG_NO_TASKS"].includes(error.code)) {
|
|
1967
1971
|
console.log(help("no workflow selected"));
|
|
@@ -1970,7 +1974,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
|
|
|
1970
1974
|
}
|
|
1971
1975
|
throw error;
|
|
1972
1976
|
}
|
|
1973
|
-
process.exitCode = await main(program, args,
|
|
1977
|
+
process.exitCode = await main(program, args, resolve2(cwd, ".cloudflare/ci/ci.ts"));
|
|
1974
1978
|
return;
|
|
1975
1979
|
}
|
|
1976
1980
|
}
|
package/dist/effect-ci.js
CHANGED
|
@@ -39,5 +39,10 @@ registerHooks({
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
// ../cli/src/effect-ci.ts
|
|
42
|
-
|
|
42
|
+
if (process.env.EFFECT_CI_TRUSTED_EVIDENCE) {
|
|
43
|
+
const { loadTrustedEvidence } = await import("./chunks/check-evidence-3YCQB4UF.js");
|
|
44
|
+
loadTrustedEvidence(process.env.EFFECT_CI_TRUSTED_EVIDENCE);
|
|
45
|
+
delete process.env.EFFECT_CI_TRUSTED_EVIDENCE;
|
|
46
|
+
}
|
|
47
|
+
var { runCli } = await import("./chunks/src-OLOASQSN.js");
|
|
43
48
|
await runCli();
|
package/dist/index.js
CHANGED
package/dist/input-evidence.js
CHANGED
|
@@ -2,16 +2,30 @@ import {
|
|
|
2
2
|
canonical,
|
|
3
3
|
inputEvidenceCheckCache,
|
|
4
4
|
inputEvidenceKey,
|
|
5
|
+
inputEvidenceMismatch,
|
|
6
|
+
inputEvidenceMismatchAt,
|
|
7
|
+
isInstalledDependency,
|
|
8
|
+
localEvidenceFileSystem,
|
|
9
|
+
lockfiles,
|
|
5
10
|
matchesInputEvidence,
|
|
6
11
|
readInputEvidenceRecords,
|
|
12
|
+
receiptSubject,
|
|
13
|
+
traceRun,
|
|
7
14
|
writeInputEvidenceRecords
|
|
8
|
-
} from "./chunks/chunk-
|
|
15
|
+
} from "./chunks/chunk-GQZMYLA7.js";
|
|
9
16
|
import "./chunks/chunk-Q5USMIJ3.js";
|
|
10
17
|
export {
|
|
11
18
|
canonical,
|
|
12
19
|
inputEvidenceCheckCache,
|
|
13
20
|
inputEvidenceKey,
|
|
21
|
+
inputEvidenceMismatch,
|
|
22
|
+
inputEvidenceMismatchAt,
|
|
23
|
+
isInstalledDependency,
|
|
24
|
+
localEvidenceFileSystem,
|
|
25
|
+
lockfiles,
|
|
14
26
|
matchesInputEvidence,
|
|
15
27
|
readInputEvidenceRecords,
|
|
28
|
+
receiptSubject,
|
|
29
|
+
traceRun,
|
|
16
30
|
writeInputEvidenceRecords
|
|
17
31
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -30,11 +30,18 @@ export type StepOptions = WorkflowStepConfig;
|
|
|
30
30
|
* `commit`: reuse a pass only for the same commit.
|
|
31
31
|
*/
|
|
32
32
|
export type CheckReuseScope = "commit" | "inputs";
|
|
33
|
+
export interface CheckReuse {
|
|
34
|
+
readonly scope?: CheckReuseScope;
|
|
35
|
+
/**
|
|
36
|
+
* `false`: never reuse a pass an agent reported (a host receipt for an agent's run).
|
|
37
|
+
* Use it for checks that gate deploys or security: they always run on the host.
|
|
38
|
+
* Agents do not submit evidence for them.
|
|
39
|
+
*/
|
|
40
|
+
readonly agents?: false;
|
|
41
|
+
}
|
|
33
42
|
export interface CheckOptions extends StepOptions {
|
|
34
43
|
/** Allow a trusted runner to reuse this side-effect-free check. `true` reuses by inputs. */
|
|
35
|
-
readonly reuse?: true |
|
|
36
|
-
readonly scope?: CheckReuseScope;
|
|
37
|
-
};
|
|
44
|
+
readonly reuse?: true | CheckReuse;
|
|
38
45
|
}
|
|
39
46
|
/** How a tool can report what a command read. Vite+ traces the files a task reads with fspy. */
|
|
40
47
|
export interface CommandTrace {
|
|
@@ -570,6 +577,7 @@ export interface CheckCacheRequest {
|
|
|
570
577
|
readonly event: WorkflowEventShape;
|
|
571
578
|
readonly policy: {
|
|
572
579
|
readonly scope: CheckReuseScope;
|
|
580
|
+
readonly agents?: false;
|
|
573
581
|
};
|
|
574
582
|
readonly stepId: string;
|
|
575
583
|
/** What the command reports about its reads, when a tool traces them. */
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CheckCacheRequest } from "./index.js";
|
|
2
|
+
/** What a passing run read, as Vite+ traced it, with content digests Effect CI computes. */
|
|
3
|
+
export type PathEvidence = {
|
|
4
|
+
readonly type: "file";
|
|
5
|
+
readonly sha256: string;
|
|
6
|
+
readonly mayBeMissing?: true;
|
|
7
|
+
} | {
|
|
8
|
+
readonly type: "dir";
|
|
9
|
+
readonly entries?: ReadonlyArray<string>;
|
|
10
|
+
readonly mayBeMissing?: true;
|
|
11
|
+
} | {
|
|
12
|
+
readonly type: "missing";
|
|
13
|
+
};
|
|
14
|
+
/** `node_modules` stands for what a frozen-lockfile install of this lockfile produces. */
|
|
15
|
+
export interface LockfileEvidence {
|
|
16
|
+
/** Relative to the evidence root, such as `pnpm-lock.yaml`. */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly sha256: string;
|
|
19
|
+
/** `package.json#packageManager` or `devEngines.packageManager` (such as `pnpm@10.18.0`),
|
|
20
|
+
* else the manager the lockfile names. */
|
|
21
|
+
readonly packageManager: string;
|
|
22
|
+
}
|
|
23
|
+
export interface InputEvidence {
|
|
24
|
+
/** The Vite+ workspace root, relative to the check's working directory. */
|
|
25
|
+
readonly root: string;
|
|
26
|
+
readonly inputs: Readonly<Record<string, PathEvidence>>;
|
|
27
|
+
/** SHA-256 of each env var value the run's cache key includes. */
|
|
28
|
+
readonly env: Readonly<Record<string, string | null>>;
|
|
29
|
+
/** Present when the run read `node_modules`: those reads are covered by this instead. */
|
|
30
|
+
readonly lockfile?: LockfileEvidence;
|
|
31
|
+
}
|
|
32
|
+
export interface SignedInputEvidence {
|
|
33
|
+
readonly evidence: InputEvidence;
|
|
34
|
+
readonly signature: string;
|
|
35
|
+
}
|
|
36
|
+
/** How the matcher reads a workspace. Paths are relative to the evidence root. */
|
|
37
|
+
export interface EvidenceFileSystem {
|
|
38
|
+
readonly kind: (path: string) => "file" | "dir" | "missing" | "other";
|
|
39
|
+
readonly sha256: (path: string) => string;
|
|
40
|
+
readonly entries: (path: string) => ReadonlyArray<string>;
|
|
41
|
+
/** SHA-256 of the env var's value, or null when it is unset. */
|
|
42
|
+
readonly env: (name: string) => string | null;
|
|
43
|
+
readonly packageManager: () => string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export declare const lockfiles: {
|
|
46
|
+
readonly "pnpm-lock.yaml": "pnpm";
|
|
47
|
+
readonly "package-lock.json": "npm";
|
|
48
|
+
readonly "yarn.lock": "yarn";
|
|
49
|
+
readonly "bun.lock": "bun";
|
|
50
|
+
readonly "bun.lockb": "bun";
|
|
51
|
+
};
|
|
52
|
+
/** Whether a traced path is inside an installed `node_modules`. */
|
|
53
|
+
export declare const isInstalledDependency: (path: string) => boolean;
|
|
54
|
+
/** Why the workspace no longer has every input exactly as the passing run read it, or
|
|
55
|
+
* undefined when it does. */
|
|
56
|
+
export declare function inputEvidenceMismatch(evidence: InputEvidence, fs: EvidenceFileSystem): string | undefined;
|
|
57
|
+
export declare const canonical: (value: unknown) => string;
|
|
58
|
+
/** What a receipt is for: one check in one repository, keyed by what ran, never by commit. */
|
|
59
|
+
export interface ReceiptSubject {
|
|
60
|
+
readonly repo: string;
|
|
61
|
+
readonly workflowId: string;
|
|
62
|
+
readonly stepId: string;
|
|
63
|
+
readonly task: string;
|
|
64
|
+
readonly command: string;
|
|
65
|
+
readonly scope: "inputs";
|
|
66
|
+
}
|
|
67
|
+
export declare const receiptSubject: (request: CheckCacheRequest, repo: string) => ReceiptSubject | undefined;
|
|
68
|
+
/** What the host signs. The evidence itself is bound by its digest. */
|
|
69
|
+
export interface ReceiptClaim {
|
|
70
|
+
readonly version: 1;
|
|
71
|
+
readonly subject: ReceiptSubject;
|
|
72
|
+
/** SHA-256 of `canonical(evidence)`. */
|
|
73
|
+
readonly evidence: string;
|
|
74
|
+
/** The Access identity that submitted it: an email, or a service token's client ID. */
|
|
75
|
+
readonly agent: string;
|
|
76
|
+
readonly issuedAt: string;
|
|
77
|
+
}
|
|
78
|
+
export interface CheckReceipt {
|
|
79
|
+
readonly claim: ReceiptClaim;
|
|
80
|
+
/** Ed25519 over `canonical(claim)`, base64url, by the host's receipt key. */
|
|
81
|
+
readonly signature: string;
|
|
82
|
+
readonly evidence: InputEvidence;
|
|
83
|
+
}
|
|
84
|
+
/** A receipt's check and evidence, after the host verified its own signature. */
|
|
85
|
+
export interface TrustedEvidence {
|
|
86
|
+
readonly subject: Omit<ReceiptSubject, "repo">;
|
|
87
|
+
readonly evidence: InputEvidence;
|
|
88
|
+
readonly agent: string;
|
|
89
|
+
readonly issuedAt: string;
|
|
90
|
+
}
|
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import type { CheckCache, CheckCacheRequest } from "./index.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
readonly type: "file";
|
|
5
|
-
readonly sha256: string;
|
|
6
|
-
readonly mayBeMissing?: true;
|
|
7
|
-
} | {
|
|
8
|
-
readonly type: "dir";
|
|
9
|
-
readonly entries?: ReadonlyArray<string>;
|
|
10
|
-
readonly mayBeMissing?: true;
|
|
11
|
-
} | {
|
|
12
|
-
readonly type: "missing";
|
|
13
|
-
};
|
|
14
|
-
export interface InputEvidence {
|
|
15
|
-
/** The Vite+ workspace root, relative to the check's working directory. */
|
|
16
|
-
readonly root: string;
|
|
17
|
-
readonly inputs: Readonly<Record<string, PathEvidence>>;
|
|
18
|
-
/** SHA-256 of each env var value the run's cache key includes. */
|
|
19
|
-
readonly env: Readonly<Record<string, string | null>>;
|
|
20
|
-
}
|
|
21
|
-
export interface SignedInputEvidence {
|
|
22
|
-
readonly evidence: InputEvidence;
|
|
23
|
-
readonly signature: string;
|
|
24
|
-
}
|
|
2
|
+
import { type EvidenceFileSystem, type InputEvidence, type SignedInputEvidence } from "./input-evidence-match.js";
|
|
3
|
+
export * from "./input-evidence-match.js";
|
|
25
4
|
export interface InputEvidenceCheckCacheOptions {
|
|
26
5
|
/** A Git checkout whose notes ref stores the evidence. Push the ref to share it. */
|
|
27
6
|
readonly cwd: string;
|
|
@@ -31,7 +10,16 @@ export interface InputEvidenceCheckCacheOptions {
|
|
|
31
10
|
}
|
|
32
11
|
/** Evidence is keyed by what ran, never by commit, so it survives rebases and squashes. */
|
|
33
12
|
export declare const inputEvidenceKey: (request: CheckCacheRequest) => string;
|
|
34
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Ask Vite+ what the run it just cached read. Undefined when any step is not cached.
|
|
15
|
+
* Reads inside `node_modules` are replaced by the lockfile's digest and the package
|
|
16
|
+
* manager, so evidence from macOS matches a Linux install of the same lockfile.
|
|
17
|
+
*/
|
|
18
|
+
export declare const traceRun: (cwd: string, task: string) => InputEvidence | undefined;
|
|
19
|
+
/** A local checkout as the matcher sees it. */
|
|
20
|
+
export declare const localEvidenceFileSystem: (root: string) => EvidenceFileSystem;
|
|
21
|
+
/** Why the checkout no longer has every input as the passing run read it, if it does not. */
|
|
22
|
+
export declare const inputEvidenceMismatchAt: (cwd: string, evidence: InputEvidence) => string | undefined;
|
|
35
23
|
/** Whether the workspace still has every input exactly as the passing run read it. */
|
|
36
24
|
export declare const matchesInputEvidence: (cwd: string, evidence: InputEvidence) => boolean;
|
|
37
25
|
/** The signed records stored for one evidence key, newest first. */
|