effect-ci 0.1.2 → 0.1.3

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.
@@ -0,0 +1,169 @@
1
+ import {
2
+ untracedHits
3
+ } from "./chunk-Q5USMIJ3.js";
4
+
5
+ // ../ci/src/input-evidence.ts
6
+ import { execFileSync } from "node:child_process";
7
+ import { createHash, sign, verify } from "node:crypto";
8
+ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
9
+ import { relative, resolve } from "node:path";
10
+ import * as Effect from "effect/Effect";
11
+ var inputEvidenceKey = (request) => JSON.stringify({
12
+ command: request.command,
13
+ repository: request.event.source?.kind === "git" ? request.event.source.repository : void 0,
14
+ scope: request.policy.scope,
15
+ stepId: request.stepId,
16
+ task: request.trace?.task,
17
+ workflowId: request.workflowId
18
+ });
19
+ var maximumRecords = 20;
20
+ var sha256 = (value) => createHash("sha256").update(value).digest("hex");
21
+ var git = (cwd, args, input) => execFileSync("git", args, {
22
+ cwd,
23
+ encoding: "utf8",
24
+ input,
25
+ // Notes hold every traced file's digest: often several MB, past the 1 MB default.
26
+ maxBuffer: 256 * 1024 * 1024,
27
+ stdio: ["pipe", "pipe", "ignore"]
28
+ }).trim();
29
+ 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
+ var leafSteps = (plan) => Object.values(plan).flatMap((task) => task.steps.flatMap((step) => step.plan ? leafSteps(step.plan) : [step]));
32
+ var digestFile = (path) => sha256(readFileSync(path));
33
+ var traceRun = (cwd, task) => {
34
+ const body = execFileSync("sh", ["-c", 'PATH="$PATH:$PWD/node_modules/.bin" exec vp run --dry-run --json --cache -vv "$1"', "sh", task], {
35
+ cwd,
36
+ encoding: "utf8",
37
+ stdio: ["ignore", "pipe", "ignore"],
38
+ maxBuffer: 16 * 1024 * 1024
39
+ });
40
+ const plan = JSON.parse(body);
41
+ if (plan.version !== 1 || untracedHits(body).length > 0) return void 0;
42
+ const steps = leafSteps(plan.plan);
43
+ if (steps.length === 0) return void 0;
44
+ const written = [];
45
+ let writtenKnown = true;
46
+ for (const step of steps) {
47
+ const baseline = step.cache?.baseline;
48
+ if (step.cache?.status === "unknown") {
49
+ const reads = Object.entries(baseline?.fingerprint?.inputs ?? {});
50
+ if (!writtenKnown || reads.length === 0) return void 0;
51
+ const readsWritten = ([path, input]) => written.some((output) => {
52
+ if (output === path) return true;
53
+ const below = path === "." ? output : output.startsWith(`${path}/`) ? output.slice(path.length + 1) : void 0;
54
+ if (below === void 0) return false;
55
+ if (input.type !== "dir") return true;
56
+ const [child] = below.split("/");
57
+ return input.entries !== void 0 && !input.entries.includes(child);
58
+ });
59
+ if (reads.some(readsWritten)) return void 0;
60
+ } else if (step.cache?.status !== "hit") return void 0;
61
+ if (Array.isArray(baseline?.outputs)) written.push(...baseline.outputs);
62
+ else writtenKnown = false;
63
+ }
64
+ const inputs = {};
65
+ const env = {};
66
+ for (const step of steps) {
67
+ const fingerprint = step.cache?.baseline?.fingerprint;
68
+ for (const [path, input] of Object.entries(fingerprint?.inputs ?? {})) {
69
+ const absolute = resolve(plan.workspaceRoot, path);
70
+ if (input.type === "file") {
71
+ if (!existsSync(absolute)) {
72
+ if (!input.mayBeMissing) return void 0;
73
+ inputs[path] = { type: "missing" };
74
+ } else inputs[path] = { type: "file", sha256: digestFile(absolute), ...input.mayBeMissing ? { mayBeMissing: true } : {} };
75
+ } else inputs[path] = input;
76
+ }
77
+ for (const name of fingerprint?.env ?? []) {
78
+ const value = process.env[name];
79
+ env[name] = value === void 0 ? null : sha256(value);
80
+ }
81
+ }
82
+ return { root: relative(realpathSync(cwd), realpathSync(plan.workspaceRoot)) || ".", inputs, env };
83
+ };
84
+ var matchesInputEvidence = (cwd, evidence) => {
85
+ const root = resolve(cwd, evidence.root);
86
+ for (const [path, input] of Object.entries(evidence.inputs)) {
87
+ const absolute = resolve(root, path);
88
+ const relativePath = relative(root, absolute);
89
+ if (relativePath.startsWith("..")) return false;
90
+ const exists = existsSync(absolute);
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
+ }
113
+ }
114
+ }
115
+ for (const [name, digest] of Object.entries(evidence.env)) {
116
+ const value = process.env[name];
117
+ if ((value === void 0 ? null : sha256(value)) !== digest) return false;
118
+ }
119
+ return true;
120
+ };
121
+ var notesRef = (options) => `--ref=${options.ref ?? "effect-ci-inputs"}`;
122
+ var readInputEvidenceRecords = (options, key) => {
123
+ try {
124
+ return JSON.parse(git(options.cwd, ["notes", notesRef(options), "show", keyObject(options.cwd, key)]));
125
+ } catch {
126
+ return [];
127
+ }
128
+ };
129
+ var writeInputEvidenceRecords = (options, key, records) => {
130
+ const identity = (() => {
131
+ try {
132
+ git(options.cwd, ["var", "GIT_COMMITTER_IDENT"]);
133
+ return [];
134
+ } catch {
135
+ return ["-c", "user.name=Effect CI", "-c", "user.email=effect-ci@localhost"];
136
+ }
137
+ })();
138
+ git(
139
+ options.cwd,
140
+ [...identity, "notes", notesRef(options), "add", "--force", "--file", "-", keyObject(options.cwd, key)],
141
+ JSON.stringify(records)
142
+ );
143
+ };
144
+ var inputEvidenceCheckCache = (options) => ({
145
+ lookup: (request) => Effect.sync(() => {
146
+ if (request.policy.scope !== "inputs" || !request.trace || request.workspace.kind !== "local") return false;
147
+ return readInputEvidenceRecords(options, inputEvidenceKey(request)).some(({ evidence, signature }) => verify(null, Buffer.from(canonical(evidence)), options.publicKey, Buffer.from(signature, "base64url")) && matchesInputEvidence(request.workspace.cwd, evidence));
148
+ }),
149
+ record: (request) => Effect.sync(() => {
150
+ if (request.policy.scope !== "inputs" || !request.trace || !options.privateKey || request.workspace.kind !== "local") return;
151
+ const evidence = traceRun(request.workspace.cwd, request.trace.task);
152
+ if (!evidence) return;
153
+ const signature = Buffer.from(sign(null, Buffer.from(canonical(evidence)), options.privateKey)).toString("base64url");
154
+ const key = inputEvidenceKey(request);
155
+ writeInputEvidenceRecords(options, key, [
156
+ { evidence, signature },
157
+ ...readInputEvidenceRecords(options, key).filter((record) => canonical(record.evidence) !== canonical(evidence))
158
+ ].slice(0, maximumRecords));
159
+ })
160
+ });
161
+
162
+ export {
163
+ inputEvidenceKey,
164
+ canonical,
165
+ matchesInputEvidence,
166
+ readInputEvidenceRecords,
167
+ writeInputEvidenceRecords,
168
+ inputEvidenceCheckCache
169
+ };
@@ -1,3 +1,6 @@
1
+ import {
2
+ inputEvidenceCheckCache
3
+ } from "./chunk-QRAH3KJT.js";
1
4
  import {
2
5
  ApprovalError,
3
6
  CommandCheckpointError,
@@ -237,10 +240,10 @@ effect-ci oidc -- <deploy command> Deploy using temporary creden
237
240
  try {
238
241
  const env = { ...process.env, CLOUDFLARE_API_TOKEN: credential.token, CLOUDFLARE_ACCOUNT_ID: credential.accountId };
239
242
  delete env.EFFECT_CI_OIDC_TOKEN;
240
- process.exitCode = await new Promise((resolve3, reject) => {
243
+ process.exitCode = await new Promise((resolve4, reject) => {
241
244
  const child = spawn(command[0], command.slice(1), { cwd, env, stdio: "inherit" });
242
245
  child.on("error", reject);
243
- child.on("exit", (code) => resolve3(code ?? 1));
246
+ child.on("exit", (code) => resolve4(code ?? 1));
244
247
  });
245
248
  } finally {
246
249
  const revoked = await fetch(`${issuer}/revoke`, { method: "POST", headers: { authorization: `Bearer ${credential.receipt}` }, redirect: "error", signal: AbortSignal.timeout(15e3) });
@@ -373,20 +376,31 @@ var vitePlusAvailable = (cwd) => {
373
376
  }
374
377
  };
375
378
 
379
+ // ../cli/src/check-evidence.ts
380
+ import { readFileSync as readFileSync3 } from "node:fs";
381
+ import { resolve } from "node:path";
382
+ var pem = (root, value) => !value ? void 0 : value.includes("-----BEGIN ") ? value : readFileSync3(resolve(root, value), "utf8");
383
+ var environmentCheckCache = (root, env = process.env) => {
384
+ const publicKey = pem(root, env.EFFECT_CI_CHECK_PUBLIC_KEY);
385
+ if (!publicKey) return void 0;
386
+ const privateKey = pem(root, env.EFFECT_CI_CHECK_PRIVATE_KEY);
387
+ return inputEvidenceCheckCache({ cwd: root, publicKey, ...privateKey ? { privateKey } : {} });
388
+ };
389
+
376
390
  // ../cli/src/index.ts
377
- import { existsSync as existsSync6, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync6, realpathSync, writeFileSync as writeFileSync3 } from "node:fs";
391
+ import { existsSync as existsSync6, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, realpathSync, writeFileSync as writeFileSync3 } from "node:fs";
378
392
  import { execFileSync as execFileSync5 } from "node:child_process";
379
- import { basename, dirname as dirname4, join as join6, relative, resolve as resolve2 } from "node:path";
393
+ import { basename, dirname as dirname4, join as join6, relative, resolve as resolve3 } from "node:path";
380
394
  import { pathToFileURL } from "node:url";
381
395
  import { parseArgs as parseArgs2, parseEnv as parseEnv3 } from "node:util";
382
396
 
383
397
  // ../cli/src/project-env.ts
384
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
385
- import { dirname as dirname2, join as join3, resolve } from "node:path";
398
+ import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
399
+ import { dirname as dirname2, join as join3, resolve as resolve2 } from "node:path";
386
400
  import { parseEnv } from "node:util";
387
401
  function projectEnvironment(cwd) {
388
402
  const directories = [];
389
- for (let directory = resolve(cwd); ; directory = dirname2(directory)) {
403
+ for (let directory = resolve2(cwd); ; directory = dirname2(directory)) {
390
404
  directories.unshift(directory);
391
405
  if (existsSync3(join3(directory, ".git")) || dirname2(directory) === directory) break;
392
406
  }
@@ -394,7 +408,7 @@ function projectEnvironment(cwd) {
394
408
  for (const directory of directories) {
395
409
  for (const name of [".env", ".env.local"]) {
396
410
  const path = join3(directory, name);
397
- if (existsSync3(path)) Object.assign(settings, parseEnv(readFileSync3(path, "utf8")));
411
+ if (existsSync3(path)) Object.assign(settings, parseEnv(readFileSync4(path, "utf8")));
398
412
  }
399
413
  }
400
414
  if (settings.EFFECT_CI_PUBLIC_URL) settings.EFFECT_CI_REMOTE_URL ??= settings.EFFECT_CI_PUBLIC_URL;
@@ -552,7 +566,7 @@ function makeLocalProjectChecks(options = {}) {
552
566
 
553
567
  // ../cli/src/login.ts
554
568
  import { spawnSync as spawnSync2 } from "node:child_process";
555
- import { chmodSync, existsSync as existsSync4, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "node:fs";
569
+ import { chmodSync, existsSync as existsSync4, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
556
570
  import { homedir as homedir2 } from "node:os";
557
571
  import { dirname as dirname3, join as join4 } from "node:path";
558
572
  var userConfigPath = () => process.env.EFFECT_CI_CONFIG || join4(homedir2(), ".config", "effect-ci", "config.json");
@@ -560,7 +574,7 @@ var readUserConfig = (path = userConfigPath()) => {
560
574
  if (!existsSync4(path)) return {};
561
575
  const file = lstatSync2(path);
562
576
  if (!file.isFile() || file.isSymbolicLink() || file.size > 8192) throw new Error(`Invalid Effect CI config: ${path}`);
563
- const value = JSON.parse(readFileSync4(path, "utf8"));
577
+ const value = JSON.parse(readFileSync5(path, "utf8"));
564
578
  if (value.version !== 1) throw new Error(`Invalid Effect CI config: ${path}`);
565
579
  return typeof value.remoteUrl === "string" ? { remoteUrl: remoteOrigin(value.remoteUrl) } : {};
566
580
  };
@@ -625,7 +639,7 @@ setting CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET (an Access service token
625
639
  };
626
640
 
627
641
  // ../cli/src/remote-config.ts
628
- import { existsSync as existsSync5, lstatSync as lstatSync3, readFileSync as readFileSync5 } from "node:fs";
642
+ import { existsSync as existsSync5, lstatSync as lstatSync3, readFileSync as readFileSync6 } from "node:fs";
629
643
  import { join as join5 } from "node:path";
630
644
  import { parseEnv as parseEnv2 } from "node:util";
631
645
  var readProjectRemote = (root) => {
@@ -635,7 +649,7 @@ var readProjectRemote = (root) => {
635
649
  const stat = lstatSync3(path);
636
650
  if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 65536)
637
651
  throw new Error("Invalid remote configuration file");
638
- const values2 = parseEnv2(readFileSync5(path, "utf8"));
652
+ const values2 = parseEnv2(readFileSync6(path, "utf8"));
639
653
  return values2;
640
654
  };
641
655
  const shared = read(".env"), local = read(".env.local");
@@ -654,7 +668,7 @@ var readProjectOidc = (root) => {
654
668
  if (!existsSync5(path)) return void 0;
655
669
  const file = lstatSync3(path);
656
670
  if (!file.isFile() || file.isSymbolicLink() || file.size > 8192) throw new Error("Invalid OIDC configuration file");
657
- return JSON.parse(readFileSync5(path, "utf8"));
671
+ return JSON.parse(readFileSync6(path, "utf8"));
658
672
  };
659
673
 
660
674
  // ../cli/src/remote-diagnostics.ts
@@ -1110,7 +1124,7 @@ var followRemoteRun = async (connection, format, run) => {
1110
1124
  );
1111
1125
  }
1112
1126
  if (format === "text") console.log("Remote logs disconnected; reconnecting to the same Workflow\u2026");
1113
- await new Promise((resolve3) => setTimeout(resolve3, Math.min(1e3 * interruptions, 5e3)));
1127
+ await new Promise((resolve4) => setTimeout(resolve4, Math.min(1e3 * interruptions, 5e3)));
1114
1128
  }
1115
1129
  const terminal = events.at(-1);
1116
1130
  if (terminal?.type === "workflow_errored" || terminal?.type === "workflow_terminated") {
@@ -1224,7 +1238,7 @@ var runPush = async (input, cwd, detected) => {
1224
1238
  if (response?.status === 400)
1225
1239
  throw new CliFailure("CI_REMOTE_FAILED", ExitCode.providerUnavailable, `The push succeeded, but the host could not start its run: ${detail}`, { instanceId });
1226
1240
  if (response?.ok || response?.status === 404 || attempt === 4) break;
1227
- await new Promise((resolve3) => setTimeout(resolve3, 1e3 * (attempt + 1)));
1241
+ await new Promise((resolve4) => setTimeout(resolve4, 1e3 * (attempt + 1)));
1228
1242
  }
1229
1243
  const deadline = Date.now() + 6e4;
1230
1244
  while (true) {
@@ -1245,7 +1259,7 @@ var runPush = async (input, cwd, detected) => {
1245
1259
  `The push succeeded, but no run started for ${revision} within 60 seconds. Check the Artifacts event subscription for ${target.namespace}/${target.repo}.`,
1246
1260
  { instanceId }
1247
1261
  );
1248
- await new Promise((resolve3) => setTimeout(resolve3, 1e3));
1262
+ await new Promise((resolve4) => setTimeout(resolve4, 1e3));
1249
1263
  }
1250
1264
  if (format === "text") console.log(`Remote Workflow ${instanceId}`);
1251
1265
  const result = await followRemoteRun(connection, format, run);
@@ -1406,7 +1420,7 @@ var workflowNames = [
1406
1420
  "ci.mjs"
1407
1421
  ];
1408
1422
  var findWorkflow = (cwd) => {
1409
- let directory = resolve2(cwd);
1423
+ let directory = resolve3(cwd);
1410
1424
  while (true) {
1411
1425
  for (const name of workflowNames) {
1412
1426
  const candidate = join6(directory, ".cloudflare", "ci", name);
@@ -1450,12 +1464,12 @@ var extractWorkflow = (args, cwd) => {
1450
1464
  remaining.splice(positional, 1);
1451
1465
  }
1452
1466
  }
1453
- const path = explicit ? resolve2(cwd, explicit) : findWorkflow(cwd);
1467
+ const path = explicit ? resolve3(cwd, explicit) : findWorkflow(cwd);
1454
1468
  if (!path || !existsSync6(path)) {
1455
1469
  throw new CliFailure(
1456
1470
  "CI_WORKFLOW_NOT_FOUND",
1457
1471
  ExitCode.usage,
1458
- explicit ? `Workflow not found: ${resolve2(cwd, explicit)}` : `No .cloudflare/ci/workflow.ts found from ${resolve2(cwd)}`
1472
+ explicit ? `Workflow not found: ${resolve3(cwd, explicit)}` : `No .cloudflare/ci/workflow.ts found from ${resolve3(cwd)}`
1459
1473
  );
1460
1474
  }
1461
1475
  return { args: remaining, path };
@@ -1469,7 +1483,7 @@ var loadProgram = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1469
1483
  program: inferJavaScriptProgram(selected.path)
1470
1484
  };
1471
1485
  }
1472
- if (basename(selected.path).startsWith("ci.") && readFileSync6(selected.path, "utf8").trim() === "") {
1486
+ if (basename(selected.path).startsWith("ci.") && readFileSync7(selected.path, "utf8").trim() === "") {
1473
1487
  return {
1474
1488
  args: selected.args,
1475
1489
  path: selected.path,
@@ -1511,7 +1525,7 @@ var inferJavaScriptProgram = (root) => {
1511
1525
  `Zero-config CI requires a package.json at ${manifestPath}`
1512
1526
  );
1513
1527
  }
1514
- const manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
1528
+ const manifest = JSON.parse(readFileSync7(manifestPath, "utf8"));
1515
1529
  let tasks = { names: [], dependencies: {} };
1516
1530
  if (manifest.dependencies?.["vite-plus"] || manifest.devDependencies?.["vite-plus"]) {
1517
1531
  try {
@@ -1544,7 +1558,7 @@ var initializeJavaScriptProject = (args, cwd) => {
1544
1558
  const invocation = parseInvocation(args, void 0, cwd);
1545
1559
  if (invocation.help || invocation.command !== "run" || invocation.location !== "local") return void 0;
1546
1560
  requireAction(invocation.targets);
1547
- const program = inferJavaScriptProgram(resolve2(cwd));
1561
+ const program = inferJavaScriptProgram(resolve3(cwd));
1548
1562
  selectedWorkflow(program, invocation.targets);
1549
1563
  for (const directory of [join6(cwd, ".cloudflare"), join6(cwd, ".cloudflare", "ci")]) {
1550
1564
  if (existsSync6(directory)) {
@@ -1568,7 +1582,7 @@ var printJson = (value) => {
1568
1582
  process.stdout.write(`${JSON.stringify(value, null, 2)}
1569
1583
  `);
1570
1584
  };
1571
- var projectRoot = (workflowPath) => basename(dirname4(workflowPath)) === "ci" && basename(dirname4(dirname4(workflowPath))) === ".cloudflare" ? resolve2(dirname4(workflowPath), "../..") : dirname4(workflowPath);
1585
+ var projectRoot = (workflowPath) => basename(dirname4(workflowPath)) === "ci" && basename(dirname4(dirname4(workflowPath))) === ".cloudflare" ? resolve3(dirname4(workflowPath), "../..") : dirname4(workflowPath);
1572
1586
  var defaultLocalOptions = (workflowPath) => {
1573
1587
  const event = process.env.EFFECT_CI_EVENT ?? process.env.GITHUB_EVENT_NAME;
1574
1588
  const revision = process.env.EFFECT_CI_REVISION ?? process.env.GITHUB_SHA;
@@ -1578,13 +1592,15 @@ var defaultLocalOptions = (workflowPath) => {
1578
1592
  try {
1579
1593
  const path = process.env.GITHUB_EVENT_PATH;
1580
1594
  if (path && lstatSync4(path).isFile() && lstatSync4(path).size <= 4194304)
1581
- payload = JSON.parse(readFileSync6(path, "utf8"));
1595
+ payload = JSON.parse(readFileSync7(path, "utf8"));
1582
1596
  } catch {
1583
1597
  }
1584
1598
  const comparison = process.env.EFFECT_CI_BASE_REVISION ? { base: process.env.EFFECT_CI_BASE_REVISION, ...revision ? { head: revision } : {} } : githubSourceComparison(event ?? "workflow_dispatch", payload, revision);
1585
1599
  const approval = decision === "approved" || decision === "rejected" ? { request: () => Effect2.succeed({ decision }) } : void 0;
1600
+ const checkCache = environmentCheckCache(projectRoot(workflowPath));
1586
1601
  return {
1587
1602
  ...approval ? { approval } : {},
1603
+ ...checkCache ? { checkCache } : {},
1588
1604
  env: process.env.NODE_ENV ?? (process.env.CI ? "test" : "development"),
1589
1605
  event: {
1590
1606
  type: event ?? "workflow_dispatch",
@@ -1706,7 +1722,7 @@ var list = (program, format) => {
1706
1722
  if (!program.requiresTarget) console.log(` effect-ci run (whole workflow)`);
1707
1723
  for (const target of targets) console.log(` effect-ci run ${target}`);
1708
1724
  };
1709
- var main = async (program, args = process.argv.slice(2), workflowPath = resolve2(process.cwd(), ".cloudflare/ci/workflow.ts")) => {
1725
+ var main = async (program, args = process.argv.slice(2), workflowPath = resolve3(process.cwd(), ".cloudflare/ci/workflow.ts")) => {
1710
1726
  let format = detectedFormat();
1711
1727
  const logs = [];
1712
1728
  try {
@@ -1866,7 +1882,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1866
1882
  }
1867
1883
  let settings;
1868
1884
  try {
1869
- settings = parseEnv3(readFileSync6(resolve2(cwd, path), "utf8"));
1885
+ settings = parseEnv3(readFileSync7(resolve3(cwd, path), "utf8"));
1870
1886
  } catch {
1871
1887
  throw new CliFailure("CI_USAGE_ERROR", ExitCode.usage, `Cannot read environment file: ${path}`);
1872
1888
  }
@@ -1907,7 +1923,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1907
1923
  { workflow: workflow("hosted", function* () {
1908
1924
  }) },
1909
1925
  args,
1910
- resolve2(cwd, ".cloudflare/ci/workflow.ts")
1926
+ resolve3(cwd, ".cloudflare/ci/workflow.ts")
1911
1927
  );
1912
1928
  return;
1913
1929
  }
@@ -1920,7 +1936,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1920
1936
  }, cwd);
1921
1937
  if (!invocation.help && invocation.command === "run" && !invocation.targets.length) {
1922
1938
  const path = findWorkflow(cwd);
1923
- if (!path || basename(path).startsWith("ci.") && readFileSync6(path, "utf8").trim() === "") {
1939
+ if (!path || basename(path).startsWith("ci.") && readFileSync7(path, "utf8").trim() === "") {
1924
1940
  requireAction(invocation.targets);
1925
1941
  }
1926
1942
  }
@@ -1929,7 +1945,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1929
1945
  { workflow: workflow("hosted", function* () {
1930
1946
  }) },
1931
1947
  args,
1932
- resolve2(cwd, ".cloudflare/ci/workflow.ts")
1948
+ resolve3(cwd, ".cloudflare/ci/workflow.ts")
1933
1949
  );
1934
1950
  return;
1935
1951
  }
@@ -1941,7 +1957,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1941
1957
  if (invocation.location === "local" && (invocation.help || invocation.command !== "run")) {
1942
1958
  let program;
1943
1959
  try {
1944
- program = inferJavaScriptProgram(resolve2(cwd));
1960
+ program = inferJavaScriptProgram(resolve3(cwd));
1945
1961
  } catch (error) {
1946
1962
  if (invocation.help && error instanceof CliFailure && ["CI_ZERO_CONFIG_UNSUPPORTED", "CI_ZERO_CONFIG_NO_TASKS"].includes(error.code)) {
1947
1963
  console.log(help("no workflow selected"));
@@ -1950,7 +1966,7 @@ var runCli = async (args = process.argv.slice(2), cwd = process.cwd()) => {
1950
1966
  }
1951
1967
  throw error;
1952
1968
  }
1953
- process.exitCode = await main(program, args, resolve2(cwd, ".cloudflare/ci/ci.ts"));
1969
+ process.exitCode = await main(program, args, resolve3(cwd, ".cloudflare/ci/ci.ts"));
1954
1970
  return;
1955
1971
  }
1956
1972
  }
package/dist/effect-ci.js CHANGED
@@ -39,5 +39,5 @@ registerHooks({
39
39
  });
40
40
 
41
41
  // ../cli/src/effect-ci.ts
42
- var { runCli } = await import("./chunks/src-ZJD4AHNT.js");
42
+ var { runCli } = await import("./chunks/src-L5DEQ3MF.js");
43
43
  await runCli();
@@ -0,0 +1,17 @@
1
+ import {
2
+ canonical,
3
+ inputEvidenceCheckCache,
4
+ inputEvidenceKey,
5
+ matchesInputEvidence,
6
+ readInputEvidenceRecords,
7
+ writeInputEvidenceRecords
8
+ } from "./chunks/chunk-QRAH3KJT.js";
9
+ import "./chunks/chunk-Q5USMIJ3.js";
10
+ export {
11
+ canonical,
12
+ inputEvidenceCheckCache,
13
+ inputEvidenceKey,
14
+ matchesInputEvidence,
15
+ readInputEvidenceRecords,
16
+ writeInputEvidenceRecords
17
+ };
@@ -0,0 +1,48 @@
1
+ import type { CheckCache, 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
+ 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
+ }
25
+ export interface InputEvidenceCheckCacheOptions {
26
+ /** A Git checkout whose notes ref stores the evidence. Push the ref to share it. */
27
+ readonly cwd: string;
28
+ readonly privateKey?: string;
29
+ readonly publicKey: string;
30
+ readonly ref?: string;
31
+ }
32
+ /** Evidence is keyed by what ran, never by commit, so it survives rebases and squashes. */
33
+ export declare const inputEvidenceKey: (request: CheckCacheRequest) => string;
34
+ export declare const canonical: (evidence: InputEvidence) => string;
35
+ /** Whether the workspace still has every input exactly as the passing run read it. */
36
+ export declare const matchesInputEvidence: (cwd: string, evidence: InputEvidence) => boolean;
37
+ /** The signed records stored for one evidence key, newest first. */
38
+ export declare const readInputEvidenceRecords: (options: Pick<InputEvidenceCheckCacheOptions, "cwd" | "ref">, key: string) => ReadonlyArray<SignedInputEvidence>;
39
+ /** Replace the records for one evidence key. Records go on stdin, never argv: a traced
40
+ * `node_modules` makes each one hundreds of KB, past Linux's 128 KB per-argument limit
41
+ * and, after a few records, macOS's 1 MB ARG_MAX. */
42
+ export declare const writeInputEvidenceRecords: (options: Pick<InputEvidenceCheckCacheOptions, "cwd" | "ref">, key: string, records: ReadonlyArray<SignedInputEvidence>) => void;
43
+ /**
44
+ * Reuses a passing Vite+ check when every file and env var it read is unchanged, on any
45
+ * commit. A trusted writer signs what Vite+ traced; a reader recomputes each digest.
46
+ * Commands without a Vite+ trace and checks reused by commit always run.
47
+ */
48
+ export declare const inputEvidenceCheckCache: (options: InputEvidenceCheckCacheOptions) => CheckCache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-ci",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Effect CI: typed CI workflows you run locally, in agents, or on your own Cloudflare host",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,6 +41,10 @@
41
41
  "types": "./dist/types/vite-plus.d.ts",
42
42
  "default": "./dist/vite-plus.js"
43
43
  },
44
+ "./input-evidence": {
45
+ "types": "./dist/types/input-evidence.d.ts",
46
+ "default": "./dist/input-evidence.js"
47
+ },
44
48
  "./package.json": "./package.json"
45
49
  },
46
50
  "files": [