@patronage/factory-ci 1.0.0-alpha.47 → 1.0.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/.build-fingerprint.json +1 -1
- package/dist/alchemy/index.d.ts +2 -2
- package/dist/alchemy/index.js +20 -10
- package/dist/{bundle-alchemy-entry-Ba1Ebp91.js → bundle-alchemy-entry-CcxZTIqt.js} +4 -5
- package/dist/{execute-alchemy-entry-CxQrjSg8.js → execute-alchemy-entry-D-dMPvaC.js} +1 -1
- package/dist/index.d.ts +51 -17
- package/dist/index.js +221 -31
- package/package.json +10 -8
- package/src/alchemy/destroy-postcondition.ts +12 -4
- package/src/alchemy/evaluate-stack.ts +5 -0
- package/src/alchemy/lifecycle.ts +6 -4
- package/src/alchemy/state-tree.ts +6 -4
- package/src/github-transport.ts +1 -1
- package/src/index.ts +1 -0
- package/src/proof-reuse-gate.ts +207 -24
- package/src/proof-reuse-presentation.ts +19 -4
- package/src/vitest-profile-reader.ts +1 -1
- package/src/vitest-profile.ts +5 -2
package/README.md
CHANGED
|
@@ -455,9 +455,10 @@ const coreCommands = profile.verification.commands.filter(
|
|
|
455
455
|
);
|
|
456
456
|
|
|
457
457
|
const core = job("core", {
|
|
458
|
-
// `checks: read` is
|
|
459
|
-
//
|
|
460
|
-
|
|
458
|
+
// `checks: read` is what the gate needs on a pull request. On a
|
|
459
|
+
// default-branch push the merge fallback also reads the producing pull
|
|
460
|
+
// request and two commit objects (#1658).
|
|
461
|
+
permissions: { checks: "read", contents: "read", "pull-requests": "read" },
|
|
461
462
|
steps: [
|
|
462
463
|
step(factoryProofGateStep({ commands: coreCommands, surface: "core" })),
|
|
463
464
|
step(factoryProofTimingStartStep()),
|
|
@@ -469,9 +470,11 @@ const core = job("core", {
|
|
|
469
470
|
|
|
470
471
|
The **proof-reuse gate** decides whether a hosted job may reuse the local verification the factory already published for this exact head (ADR 0022). Refusing runs hosted CI; it never fails the candidate. The App identity, check name, step id, output names, guard, and every trust predicate are fixed here rather than consumer-configurable — three repositories had grown three answers to the same question and had already drifted.
|
|
471
472
|
|
|
472
|
-
**The gate runs on pull requests
|
|
473
|
+
**The gate runs on pull requests and on pushes to the default branch** (#1658). A merge target's guarantee is about the whole tree, not the diff, and a candidate proof's impact-stamp releases bind only the diff that candidate was scoped to. On a push, coverage is therefore `executedCommands` alone, and only from a proof recording `runScope: "whole-tree"`: no release counts, and neither does a diff-scoped run, whose commands may have scoped themselves to the diff through the run context (`psf affected`). #931 is the defect this answers: a `main` push reused an impact-scoped candidate proof, executed no command, and left a red package unnoticed for three days.
|
|
473
474
|
|
|
474
|
-
|
|
475
|
+
A squash merge mints a new commit, so a push usually finds no proof at its own head. The **merge fallback** then looks up the single merged pull request whose merge commit is the pushed head and reuses that pull request head's proof, only when the merge commit's tree id equals the proven head's tree id and that proof meets the push rule above. That makes the pushed content byte-identical to what was verified: a clean squash of a head that already contained the previous default-branch tip. Patch identity was rejected as the comparator: `git patch-id` normalizes whitespace and ignores base motion, so an identical patch can still integrate into a tree nothing verified. No unique producing pull request, an unreadable commit, a proof that is anything but proven, an executed set that does not cover the surface, or tree drift from a dirty or stale merge all leave the direct `none` refusal standing and run the full suite. The step summary names the pull request, the proven head, the tree and the reused check run, and the `source-head` output carries the proven head. The fallback needs `pull-requests: read` and `contents: read` on the job in addition to `checks: read`; a job that grants less loses only the fallback.
|
|
476
|
+
|
|
477
|
+
There is no mode to choose. The emitted condition is a trust predicate, so the package owns it.
|
|
475
478
|
|
|
476
479
|
A proof is reusable only when the complete Checks API result (`filter=all`, every page) establishes one unambiguous newest generation, produced by the pinned App for the exact repository and head, completed successfully with `outcome: passed`, whose verification started after every other run at that head was posted, and covering every command identity the guarded surface requires. A pass is ordered at its typed proof's start, never later than its own `started_at`, and every other run at its `started_at`; the doc comment above `GATE_JQ` in `src/proof-reuse-gate.ts` states the full rule (#1490, #1506). Coverage is the union of `executedCommands` and commands released by `notRequiredCommands` only after the gate validates each release against that same proof binding's command-to-target map and identity-bound impact stamp. Missing, malformed, duplicated, affected, unknown, or differently bound release data refuses reuse and runs the hosted surface. `mode` is reported as diagnostic metadata, never authorized on: a reduced-mode proof whose executed and stamp-authorized released commands cover a surface is reusable.
|
|
477
480
|
|
package/dist/alchemy/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-D75saOiE.js";
|
|
2
1
|
import * as Alchemy from "alchemy";
|
|
2
|
+
import { ProviderServices } from "alchemy/Stack";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Layer from "effect/Layer";
|
|
5
5
|
import { StateService } from "alchemy/State";
|
|
6
|
-
import {
|
|
6
|
+
import { n as ExecuteAlchemyEntryOptions } from "../execute-alchemy-entry-D75saOiE.js";
|
|
7
7
|
interface EvaluatedResource {
|
|
8
8
|
id: string;
|
|
9
9
|
type: string;
|
package/dist/alchemy/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-CxQrjSg8.js";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { appendFileSync, closeSync, openSync, readFileSync } from "node:fs";
|
|
6
|
-
import { setTimeout } from "node:timers/promises";
|
|
7
1
|
import * as Alchemy from "alchemy";
|
|
8
2
|
import * as Output from "alchemy/Output";
|
|
9
3
|
import { tryFindProviderByType } from "alchemy/Provider";
|
|
10
4
|
import * as Effect from "effect/Effect";
|
|
11
5
|
import * as Layer from "effect/Layer";
|
|
12
6
|
import * as Option from "effect/Option";
|
|
7
|
+
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-D-dMPvaC.js";
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
13
9
|
import { State } from "alchemy/State";
|
|
14
10
|
import { allStages, deleteState } from "alchemy/State/Tree";
|
|
11
|
+
import { appendFileSync, closeSync, openSync, readFileSync } from "node:fs";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { setTimeout } from "node:timers/promises";
|
|
15
15
|
import { isDeepStrictEqual } from "node:util";
|
|
16
16
|
// src/alchemy/evaluate-stack.ts
|
|
17
17
|
var EvaluationProviders = class extends Alchemy.ProviderCollection()("factory-ci/evaluate-stack") {};
|
|
@@ -517,6 +517,12 @@ const localEmulationEnvironment = (options) => {
|
|
|
517
517
|
};
|
|
518
518
|
// src/alchemy/destroy-postcondition.ts
|
|
519
519
|
/**
|
|
520
|
+
* Whether a reader's answer is a list of resource identifiers. The reader's
|
|
521
|
+
* type promises one, but it is the project's code, so the postcondition
|
|
522
|
+
* checks the value it actually returned.
|
|
523
|
+
*/
|
|
524
|
+
const isResourceIdList = (value) => Array.isArray(value) && value.every((resource) => typeof resource === "string" && resource.trim() !== "");
|
|
525
|
+
/**
|
|
520
526
|
* Read the state store through the project's reader.
|
|
521
527
|
*
|
|
522
528
|
* A reader addresses a state store with a credential, and its failure can
|
|
@@ -548,7 +554,7 @@ const assertDestroyLeftNothing = async ({ stack, stage, stateReader }) => {
|
|
|
548
554
|
stack,
|
|
549
555
|
stage
|
|
550
556
|
});
|
|
551
|
-
if (!
|
|
557
|
+
if (!isResourceIdList(listed)) throw new Error(`The destroy postcondition for ${stack} into ${stage} could not read a resource list from the state store.`);
|
|
552
558
|
const remaining = [...listed].toSorted();
|
|
553
559
|
if (remaining.length > 0) throw new Error(`Alchemy destroy left ${remaining.length} resource registered for ${stack} in ${stage}: ${remaining.join(", ")}`);
|
|
554
560
|
};
|
|
@@ -1270,6 +1276,8 @@ const isAlchemyLifecycleError = (error) => error instanceof AlchemyLifecycleErro
|
|
|
1270
1276
|
* deletes the stage it is given.
|
|
1271
1277
|
*/
|
|
1272
1278
|
const isRecord$1 = (value) => typeof value === "object" && value !== null;
|
|
1279
|
+
/** Whether a stage view's `resources` is a list of non-empty FQNs. */
|
|
1280
|
+
const isFqnList$1 = (value) => Array.isArray(value) && value.every((fqn) => typeof fqn === "string" && fqn !== "");
|
|
1273
1281
|
/**
|
|
1274
1282
|
* Refuse a stack or stage name that does not address exactly one scope.
|
|
1275
1283
|
*
|
|
@@ -1323,7 +1331,7 @@ const readStageSnapshot = async (state, target) => {
|
|
|
1323
1331
|
stage: target.stage
|
|
1324
1332
|
};
|
|
1325
1333
|
const view = await Effect.runPromise(state.snapshotStage(scope));
|
|
1326
|
-
if (!
|
|
1334
|
+
if (!isFqnList$1(view.resources)) throw new Error(`The state layer returned no resource list for ${target.stack} in ${target.stage}.`);
|
|
1327
1335
|
const resources = await Promise.all([...view.resources].toSorted().map(async (fqn) => ({
|
|
1328
1336
|
...scope,
|
|
1329
1337
|
fqn,
|
|
@@ -1461,6 +1469,8 @@ const ownershipRefusal = (error) => {
|
|
|
1461
1469
|
if (typeof error === "object" && error !== null && "_tag" in error && error._tag === "StageOwnershipError" && "reason" in error && (error.reason === "held" || error.reason === "lost")) return error.reason;
|
|
1462
1470
|
};
|
|
1463
1471
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1472
|
+
/** Whether a stage view's `resources` is a list of non-empty FQNs. */
|
|
1473
|
+
const isFqnList = (value) => Array.isArray(value) && value.every((fqn) => typeof fqn === "string" && fqn !== "");
|
|
1464
1474
|
/**
|
|
1465
1475
|
* The `version` of the `alchemy` manifest that owns `cliPath`: the nearest
|
|
1466
1476
|
* `package.json` above it whose `name` is `alchemy`. Throws when none is
|
|
@@ -1622,7 +1632,7 @@ var LifecycleRun = class {
|
|
|
1622
1632
|
return;
|
|
1623
1633
|
}
|
|
1624
1634
|
try {
|
|
1625
|
-
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-
|
|
1635
|
+
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-CcxZTIqt.js").then((n) => n.n);
|
|
1626
1636
|
this.bundledEntry = await bundleAlchemyEntry(this.entry.bundle);
|
|
1627
1637
|
} catch {
|
|
1628
1638
|
throw this.fail("PREPARATION_FAILED", "admission");
|
|
@@ -1712,7 +1722,7 @@ var LifecycleRun = class {
|
|
|
1712
1722
|
/** Every resource record and the stack output. Call under the lease. */
|
|
1713
1723
|
async readPersistedState(phase) {
|
|
1714
1724
|
const view = await this.fromStore(phase, this.state.snapshotStage(this.target));
|
|
1715
|
-
if (!
|
|
1725
|
+
if (!isFqnList(view.resources)) throw this.fail("STATE_STORE_INVALID", phase);
|
|
1716
1726
|
const records = await Promise.all([...view.resources].toSorted().map(async (fqn) => ({
|
|
1717
1727
|
fqn,
|
|
1718
1728
|
state: await this.fromStore(phase, this.state.get({
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import "node:module";
|
|
2
1
|
import { mkdir } from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { build } from "esbuild";
|
|
5
4
|
// \0rolldown/runtime.js
|
|
6
5
|
var __defProp = Object.defineProperty;
|
|
7
|
-
var __exportAll = (all,
|
|
8
|
-
let target = {};
|
|
6
|
+
var __exportAll = (all, flags) => {
|
|
7
|
+
let target = Object.setPrototypeOf({}, null);
|
|
9
8
|
for (var name in all) __defProp(target, name, {
|
|
10
9
|
get: all[name],
|
|
11
10
|
enumerable: true
|
|
12
11
|
});
|
|
13
|
-
if (!
|
|
14
|
-
return target;
|
|
12
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
15
14
|
};
|
|
16
15
|
// src/bundle-alchemy-entry.ts
|
|
17
16
|
var bundle_alchemy_entry_exports = /* @__PURE__ */ __exportAll({ bundleAlchemyEntry: () => bundleAlchemyEntry });
|
|
@@ -111,7 +111,7 @@ let spawnImplementation = spawnSync;
|
|
|
111
111
|
const resolveAlchemyChildCwd = (options) => options.cwd ?? options.bundle?.absWorkingDir ?? process.cwd();
|
|
112
112
|
const resolveBundledEntry = async (options) => {
|
|
113
113
|
if (options.bundledEntry === void 0) {
|
|
114
|
-
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-
|
|
114
|
+
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-CcxZTIqt.js").then((n) => n.n);
|
|
115
115
|
return await bundleAlchemyEntry(options.bundle);
|
|
116
116
|
}
|
|
117
117
|
return path.resolve(options.cwd ?? process.cwd(), options.bundledEntry);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@patronage/factory-ci` — the CI and deploy building blocks that already
|
|
3
|
+
* repeat across Patronage factory projects (#266, #268).
|
|
4
|
+
*
|
|
5
|
+
* A pure library: no `bin`, no `alchemy` or `effect` dependency, no config
|
|
6
|
+
* surface of its own. Everything takes plain typed values; callers pass
|
|
7
|
+
* canonical policy from `software-factory.profile.json` without this package
|
|
8
|
+
* loading or owning that profile (ADR 0021).
|
|
9
|
+
*/
|
|
1
10
|
import { a as BundleAlchemyEntryOptions, i as executeAlchemyEntry, n as ExecuteAlchemyEntryOptions, o as bundleAlchemyEntry, r as ExecuteAlchemyEntryResult, t as EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER } from "./execute-alchemy-entry-D75saOiE.js";
|
|
2
11
|
import { StdioOptions } from "node:child_process";
|
|
3
12
|
/**
|
|
@@ -626,9 +635,14 @@ export declare const mintInstallationToken: (input: {
|
|
|
626
635
|
*
|
|
627
636
|
* It answers one question, before checkout and before install: may this job
|
|
628
637
|
* reuse the local verification the factory already published for *this exact
|
|
629
|
-
* head*?
|
|
630
|
-
*
|
|
631
|
-
*
|
|
638
|
+
* head*? On a pull request the head is the PR branch tip. On a push to the
|
|
639
|
+
* default branch, a **merge fallback** extends "this exact head" to "this
|
|
640
|
+
* exact tree": a merge whose tree is byte-identical to the producing pull
|
|
641
|
+
* request's proven head tree reuses that head's proof, but only when the proof
|
|
642
|
+
* is a whole-tree run that *executed* every command the surface requires
|
|
643
|
+
* (#1658). Impact-stamp releases and diff-scoped runs never count on a push,
|
|
644
|
+
* because a merge target is owed the whole tree (#931). Refusing runs hosted
|
|
645
|
+
* CI; it never fails the candidate.
|
|
632
646
|
*
|
|
633
647
|
* What a consumer chooses is only *what its guarded surface requires*: the
|
|
634
648
|
* plain profile command objects that surface selects. Everything else below is
|
|
@@ -696,27 +710,44 @@ export declare const FACTORY_PROOF_GATE_REASON_OUTPUT = "reason";
|
|
|
696
710
|
export declare const FACTORY_PROOF_GATE_MODE_OUTPUT = "mode";
|
|
697
711
|
/** Exact Checks API URL of the proof generation selected by the gate. */
|
|
698
712
|
export declare const FACTORY_PROOF_GATE_SOURCE_URL_OUTPUT = "source-check-url";
|
|
713
|
+
/**
|
|
714
|
+
* The commit whose proof was reused, when the gate reused one. On a pull
|
|
715
|
+
* request it is the head itself; on a merge-target push it is the producing
|
|
716
|
+
* pull request's head, a different commit than the pushed one (#1658). Empty
|
|
717
|
+
* on every refusal.
|
|
718
|
+
*/
|
|
719
|
+
export declare const FACTORY_PROOF_GATE_SOURCE_HEAD_OUTPUT = "source-head";
|
|
699
720
|
/**
|
|
700
721
|
* Guard for every step the gate protects. Deliberately `!= 'true'` and not
|
|
701
722
|
* `== 'false'`: an unset, empty, or garbled output must run the suite.
|
|
702
723
|
*/
|
|
703
724
|
export declare const FACTORY_PROOF_GATE_GUARD = "steps.factory-proof.outputs.reuse-proof != 'true'";
|
|
704
725
|
/**
|
|
705
|
-
* Pull requests
|
|
706
|
-
*
|
|
726
|
+
* Pull requests, plus pushes to the default branch (#611, #1658) — the gate's
|
|
727
|
+
* single condition.
|
|
728
|
+
*
|
|
729
|
+
* A merge target's guarantee is about the whole tree, not the diff. A squash
|
|
730
|
+
* merge mints a new commit, so no proof is ever written for the merged SHA;
|
|
731
|
+
* the push path exists only for the merge fallback, which reuses the
|
|
732
|
+
* producing pull request's head proof when the merge tree *is* that head's
|
|
733
|
+
* tree and the proof's whole-tree run executed every command the surface
|
|
734
|
+
* requires.
|
|
707
735
|
*
|
|
708
|
-
*
|
|
709
|
-
* candidate proof
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
* proof
|
|
736
|
+
* #931 is why both conditions are load-bearing. A `main` push once reused an
|
|
737
|
+
* impact-scoped candidate proof, executed no command for an untouched
|
|
738
|
+
* package, and left that package red for three days. An impact-scoped proof
|
|
739
|
+
* is a sound gate for the candidate and an unsound one for the merge target,
|
|
740
|
+
* so a push credits no `notRequiredCommands` release. The same holds for a
|
|
741
|
+
* command that ran but scoped itself to the diff through the run context
|
|
742
|
+
* (`psf affected`): only a proof recording `runScope: "whole-tree"` counts.
|
|
743
|
+
* Anything else runs the full battery.
|
|
715
744
|
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
745
|
+
* The push side is deliberately the default branch only. Which branches
|
|
746
|
+
* trigger a workflow at all stays repository-owned; this condition only keeps
|
|
747
|
+
* the gate from consulting proof on pushes that are not merges into the
|
|
748
|
+
* default branch.
|
|
718
749
|
*/
|
|
719
|
-
export declare const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request'";
|
|
750
|
+
export declare const FACTORY_PROOF_GATE_IF = "github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch))";
|
|
720
751
|
/**
|
|
721
752
|
* The complete refusal vocabulary: the only distinctions the gate can make
|
|
722
753
|
* from its Checks API reads.
|
|
@@ -812,8 +843,11 @@ interface FactoryProofGateStep {
|
|
|
812
843
|
* The step itself, structurally accepted by gagen's `step()` without adding a
|
|
813
844
|
* gagen runtime dependency. It belongs first in the job it guards: a few API
|
|
814
845
|
* reads with the default `GITHUB_TOKEN`, no checkout, no install, so a proven
|
|
815
|
-
* head costs a runner nothing beyond job startup.
|
|
816
|
-
*
|
|
846
|
+
* head costs a runner nothing beyond job startup. A pull request read needs
|
|
847
|
+
* only `checks: read`. The merge fallback on a default-branch push also reads
|
|
848
|
+
* the producing pull request (`pull-requests: read`) and the two commit
|
|
849
|
+
* objects whose tree ids it compares (`contents: read`). A job that grants
|
|
850
|
+
* less loses only the fallback: the failed read degrades to the full suite.
|
|
817
851
|
*
|
|
818
852
|
* A **step, not a job**, and that is not a style preference. A separate gate
|
|
819
853
|
* job that errored would leave the guarded job `skipped`, and a summary job
|