@patronage/software-factory 1.0.0-alpha.45 → 1.0.0-alpha.46
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 +2 -2
- package/dist/cli.js +1 -2
- package/dist/index.d.ts +755 -621
- package/dist/index.js +564 -573
- package/dist/{chunk-pbuEa-1d.js → rolldown-runtime-D8jQpDG7.js} +1 -2
- package/dist/schemas.d.ts +146 -143
- package/dist/schemas.js +39 -41
- package/package.json +19 -18
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Command, InvalidArgumentError } from "commander";
|
|
4
4
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -8,10 +8,10 @@ import { accessSync, appendFileSync, closeSync, constants, cpSync, existsSync, f
|
|
|
8
8
|
import { FACTORY_APP_BROKER_ORIGIN, FACTORY_APP_BROKER_PATH, FACTORY_CURSOR_OIDC_AUDIENCE, FACTORY_PROOF_GATE_APP_ID, FACTORY_PROOF_GATE_STEP_NAME, FACTORY_PR_STATUS_HUD_JOB_NAME, GitHubApiError, assertPreviewCleanupStackPolicy, assertPreviewCleanupTargetsAbsent, discoverOrphanedPreviewCleanupTargets, discoverPreviewCleanupTargets, mintInstallationToken, parsePreviewCleanupResidue, parsePreviewCleanupTargets, previewCleanupGithubOutput, previewCleanupResiduePullRequests, previewProofInventory, productionImpactTargetOutput, readPullRequestStates, readVitestProfileDocument, recordPreviewCleanupOutcome } from "@patronage/factory-ci";
|
|
9
9
|
import http from "node:http";
|
|
10
10
|
import { isDeepStrictEqual, promisify } from "node:util";
|
|
11
|
-
import os, { homedir, tmpdir } from "node:os";
|
|
11
|
+
import os, { availableParallelism, homedir, tmpdir } from "node:os";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
import picomatch from "picomatch";
|
|
14
|
-
import { parse } from "yaml";
|
|
14
|
+
import { parse, parseAllDocuments } from "yaml";
|
|
15
15
|
import crypto, { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
16
16
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
17
17
|
import { link, lstat, mkdir, open, readFile, readdir, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
@@ -20,12 +20,11 @@ import { setImmediate as setImmediate$1, setTimeout as setTimeout$1 } from "node
|
|
|
20
20
|
import { Worker } from "node:worker_threads";
|
|
21
21
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
22
22
|
import { pathToFileURL } from "node:url";
|
|
23
|
-
|
|
23
|
+
// package.json
|
|
24
24
|
var name = "@patronage/software-factory";
|
|
25
|
-
var version = "1.0.0-alpha.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const VALUE_TAKING_GIT_OPTIONS = new Set([
|
|
25
|
+
var version = "1.0.0-alpha.46";
|
|
26
|
+
// src/git-globals-parse.ts
|
|
27
|
+
const VALUE_TAKING_GIT_OPTIONS = /* @__PURE__ */ new Set([
|
|
29
28
|
"-C",
|
|
30
29
|
"-c",
|
|
31
30
|
"--git-dir",
|
|
@@ -57,8 +56,7 @@ function parseGitGlobalsAndSubcommand(args) {
|
|
|
57
56
|
}
|
|
58
57
|
return { globals: args };
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/worker-checkout-guard.ts
|
|
59
|
+
// src/worker-checkout-guard.ts
|
|
62
60
|
function normalizeGitPath(dir) {
|
|
63
61
|
const resolved = path.resolve(dir).replace(/\/+$/u, "");
|
|
64
62
|
try {
|
|
@@ -151,7 +149,7 @@ function assertWorkerCheckoutAllowed({ cwd, operation, probe = defaultCheckoutDi
|
|
|
151
149
|
operation
|
|
152
150
|
}));
|
|
153
151
|
}
|
|
154
|
-
const GIT_TRACKED_MUTATION_SUBCOMMANDS = new Set([
|
|
152
|
+
const GIT_TRACKED_MUTATION_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
155
153
|
"add",
|
|
156
154
|
"am",
|
|
157
155
|
"cherry-pick",
|
|
@@ -166,13 +164,13 @@ const GIT_TRACKED_MUTATION_SUBCOMMANDS = new Set([
|
|
|
166
164
|
"rm",
|
|
167
165
|
"switch"
|
|
168
166
|
]);
|
|
169
|
-
const APPLY_READ_ONLY_FLAGS = new Set([
|
|
167
|
+
const APPLY_READ_ONLY_FLAGS = /* @__PURE__ */ new Set([
|
|
170
168
|
"--check",
|
|
171
169
|
"--stat",
|
|
172
170
|
"--numstat",
|
|
173
171
|
"--summary"
|
|
174
172
|
]);
|
|
175
|
-
const BRANCH_MUTATING_FLAGS = new Set([
|
|
173
|
+
const BRANCH_MUTATING_FLAGS = /* @__PURE__ */ new Set([
|
|
176
174
|
"-d",
|
|
177
175
|
"-D",
|
|
178
176
|
"--delete",
|
|
@@ -189,7 +187,7 @@ const BRANCH_MUTATING_FLAGS = new Set([
|
|
|
189
187
|
"--unset-upstream",
|
|
190
188
|
"--edit-description"
|
|
191
189
|
]);
|
|
192
|
-
const BRANCH_LIST_SELECTOR_FLAGS = new Set([
|
|
190
|
+
const BRANCH_LIST_SELECTOR_FLAGS = /* @__PURE__ */ new Set([
|
|
193
191
|
"-l",
|
|
194
192
|
"--list",
|
|
195
193
|
"-a",
|
|
@@ -215,7 +213,7 @@ function isBranchMutation(rest) {
|
|
|
215
213
|
if (rest.some((token) => !token.startsWith("-"))) return true;
|
|
216
214
|
return false;
|
|
217
215
|
}
|
|
218
|
-
const TAG_MUTATING_FLAGS = new Set([
|
|
216
|
+
const TAG_MUTATING_FLAGS = /* @__PURE__ */ new Set([
|
|
219
217
|
"-a",
|
|
220
218
|
"--annotate",
|
|
221
219
|
"-s",
|
|
@@ -234,7 +232,7 @@ const TAG_MUTATING_FLAGS = new Set([
|
|
|
234
232
|
"--local-user",
|
|
235
233
|
"--create-reflog"
|
|
236
234
|
]);
|
|
237
|
-
const TAG_READ_MODE_FLAGS = new Set([
|
|
235
|
+
const TAG_READ_MODE_FLAGS = /* @__PURE__ */ new Set([
|
|
238
236
|
"-l",
|
|
239
237
|
"--list",
|
|
240
238
|
"--contains",
|
|
@@ -326,8 +324,7 @@ function assertNoWorkerControlCheckoutMutation({ command, args, cwd, env, probe
|
|
|
326
324
|
}));
|
|
327
325
|
}
|
|
328
326
|
}
|
|
329
|
-
|
|
330
|
-
//#region src/stash-guard.ts
|
|
327
|
+
// src/stash-guard.ts
|
|
331
328
|
var StashGuardError = class extends Error {
|
|
332
329
|
constructor(message) {
|
|
333
330
|
super(message);
|
|
@@ -390,8 +387,7 @@ function assertNoSharedStash({ args, command, cwd, env, probe = defaultStashRole
|
|
|
390
387
|
if (workTreeRole === "linked") throw new StashGuardError(stashGuardMessage({ cwd: dirs.topLevel }));
|
|
391
388
|
}
|
|
392
389
|
}
|
|
393
|
-
|
|
394
|
-
//#region src/git.ts
|
|
390
|
+
// src/git.ts
|
|
395
391
|
const REPOSITORY_LOCAL_GIT_ENV = [
|
|
396
392
|
"GIT_COMMON_DIR",
|
|
397
393
|
"GIT_DIR",
|
|
@@ -590,7 +586,7 @@ function listDirtyTrackedFiles(cwd) {
|
|
|
590
586
|
"--cached",
|
|
591
587
|
"--name-status"
|
|
592
588
|
], cwd).stdout);
|
|
593
|
-
return [
|
|
589
|
+
return [.../* @__PURE__ */ new Set([...unstaged, ...staged])];
|
|
594
590
|
}
|
|
595
591
|
/**
|
|
596
592
|
* Tracked, changed files considered "in scope" for verification gates
|
|
@@ -610,7 +606,7 @@ function changedFiles(cwd, base) {
|
|
|
610
606
|
"--name-status",
|
|
611
607
|
`${resolveDiffBase(cwd, base)}...HEAD`
|
|
612
608
|
], cwd).stdout);
|
|
613
|
-
return [
|
|
609
|
+
return [.../* @__PURE__ */ new Set([...committed, ...listDirtyTrackedFiles(cwd)])].toSorted();
|
|
614
610
|
}
|
|
615
611
|
/**
|
|
616
612
|
* The heads this branch actually had on top of `base`, newest first. Used to
|
|
@@ -731,8 +727,7 @@ function remoteDefaultBranchRef(cwd) {
|
|
|
731
727
|
const ref = result.stdout.trim();
|
|
732
728
|
return ref.length > 0 ? ref : void 0;
|
|
733
729
|
}
|
|
734
|
-
|
|
735
|
-
//#region src/checkout-repository.ts
|
|
730
|
+
// src/checkout-repository.ts
|
|
736
731
|
function normalizeRepositoryIdentity(repository) {
|
|
737
732
|
return {
|
|
738
733
|
name: repository.name.replace(/\.git$/iu, "").toLowerCase(),
|
|
@@ -800,8 +795,7 @@ const repositorySlug = (repository) => {
|
|
|
800
795
|
const normalized = normalizeRepositoryIdentity(repository);
|
|
801
796
|
return `${normalized.owner}/${normalized.name}`;
|
|
802
797
|
};
|
|
803
|
-
|
|
804
|
-
//#region src/cursor-oidc-mint.ts
|
|
798
|
+
// src/cursor-oidc-mint.ts
|
|
805
799
|
const DEFAULT_CURSOR_AGENT_SOCKET = "/run/cursor/api.sock";
|
|
806
800
|
const DEFAULT_TIMEOUT_MS = 5e3;
|
|
807
801
|
const cursorAgentSocketPath = (env = process.env) => {
|
|
@@ -888,8 +882,7 @@ const mintCursorOidcToken = (options = {}) => new Promise((resolve, reject) => {
|
|
|
888
882
|
req.write(body);
|
|
889
883
|
req.end();
|
|
890
884
|
});
|
|
891
|
-
|
|
892
|
-
//#region src/pr-verify-status.ts
|
|
885
|
+
// src/pr-verify-status.ts
|
|
893
886
|
const PR_VERIFY_STATUS_CONTEXT = "patronage-factory/pr-verify";
|
|
894
887
|
const GITHUB_PUBLISH_TIMEOUT_MS = 5e3;
|
|
895
888
|
/**
|
|
@@ -946,8 +939,7 @@ function createGhCommitStatusPoster(output, run = runGhStatus) {
|
|
|
946
939
|
runDetachedBestEffort(publish);
|
|
947
940
|
};
|
|
948
941
|
}
|
|
949
|
-
|
|
950
|
-
//#region src/factory-app-broker-client.ts
|
|
942
|
+
// src/factory-app-broker-client.ts
|
|
951
943
|
const FACTORY_APP_BROKER_URL = `${FACTORY_APP_BROKER_ORIGIN}${FACTORY_APP_BROKER_PATH}`;
|
|
952
944
|
/**
|
|
953
945
|
* The opt-in broker permission set (#1360): `actions: read`, `checks: read`,
|
|
@@ -1020,8 +1012,7 @@ const exchangeFactoryAppInstallationToken = async (input) => {
|
|
|
1020
1012
|
if (body === null || typeof body !== "object" || typeof body.token !== "string" || body.token.length === 0) throw new FactoryAppBrokerError("Factory App broker exchange omitted token");
|
|
1021
1013
|
return body.token;
|
|
1022
1014
|
};
|
|
1023
|
-
|
|
1024
|
-
//#region src/user-config.ts
|
|
1015
|
+
// src/user-config.ts
|
|
1025
1016
|
const FACTORY_USER_CONFIG_SCHEMA_VERSION = 2;
|
|
1026
1017
|
const githubAppConfigSchema = z.object({
|
|
1027
1018
|
appId: z.union([z.string().min(1), z.number().int().positive()]),
|
|
@@ -1120,8 +1111,7 @@ function tryUserConfig(input = {}) {
|
|
|
1120
1111
|
function formatUserConfigError(configPath, error) {
|
|
1121
1112
|
return `User config is invalid: ${configPath}: ${formatZodIssues(error)}`;
|
|
1122
1113
|
}
|
|
1123
|
-
|
|
1124
|
-
//#region src/github-app-access.ts
|
|
1114
|
+
// src/github-app-access.ts
|
|
1125
1115
|
const NO_APP_SKIP_MESSAGE = "no factory GitHub App configured; skipping durable check-run republish.\n";
|
|
1126
1116
|
/**
|
|
1127
1117
|
* Fail-closed App credential mint/exchange that never completed. Distinct from
|
|
@@ -1265,8 +1255,7 @@ const resolveFactoryAppAccess = async (repository, dependencies = {}) => {
|
|
|
1265
1255
|
message: NO_APP_SKIP_MESSAGE
|
|
1266
1256
|
};
|
|
1267
1257
|
};
|
|
1268
|
-
|
|
1269
|
-
//#region src/app-token-exec.ts
|
|
1258
|
+
// src/app-token-exec.ts
|
|
1270
1259
|
/**
|
|
1271
1260
|
* `app-token:exec` (#1426): run one child command with a fresh Factory App
|
|
1272
1261
|
* installation token in `FACTORY_GITHUB_APP_TOKEN`.
|
|
@@ -1280,12 +1269,13 @@ const resolveFactoryAppAccess = async (repository, dependencies = {}) => {
|
|
|
1280
1269
|
*/
|
|
1281
1270
|
/** The child's exit status; a child killed by a signal reads as 1. */
|
|
1282
1271
|
const runInheritedChild = async ({ args, command, cwd, env }) => {
|
|
1283
|
-
const
|
|
1272
|
+
const child = spawn(command, args, {
|
|
1284
1273
|
cwd,
|
|
1285
1274
|
env,
|
|
1286
1275
|
shell: false,
|
|
1287
1276
|
stdio: "inherit"
|
|
1288
|
-
})
|
|
1277
|
+
});
|
|
1278
|
+
const [code] = await once(child, "close");
|
|
1289
1279
|
return code ?? 1;
|
|
1290
1280
|
};
|
|
1291
1281
|
/**
|
|
@@ -1324,8 +1314,7 @@ async function runAppTokenExec(args, dependencies = {}) {
|
|
|
1324
1314
|
}
|
|
1325
1315
|
});
|
|
1326
1316
|
}
|
|
1327
|
-
|
|
1328
|
-
//#region src/command-options.ts
|
|
1317
|
+
// src/command-options.ts
|
|
1329
1318
|
function positiveInteger$1(name) {
|
|
1330
1319
|
return (value) => {
|
|
1331
1320
|
const parsed = Number(value);
|
|
@@ -1362,8 +1351,7 @@ function resolveProofOutputPaths(cwd, defaultPath, requested) {
|
|
|
1362
1351
|
canonical: resolveCheckoutPath(cwd, defaultPath)
|
|
1363
1352
|
};
|
|
1364
1353
|
}
|
|
1365
|
-
|
|
1366
|
-
//#region src/app-token-exec-command.ts
|
|
1354
|
+
// src/app-token-exec-command.ts
|
|
1367
1355
|
function createAppTokenExecCommand(action = runAppTokenExec) {
|
|
1368
1356
|
return markCwdOptionDefault(new Command("app-token:exec").description("Run a command with a fresh Factory App installation token for this checkout's repository in FACTORY_GITHUB_APP_TOKEN; exits 1 without running it when no token resolves, else with the command's exit code").usage("[options] -- <command> [args...]").argument("<command...>", "the command to run, after `--`").option("--cwd <path>", "checkout to scope the token to and run in", collectCwdOption).action(async (command, options) => {
|
|
1369
1357
|
const exitCode = await action({
|
|
@@ -1373,8 +1361,7 @@ function createAppTokenExecCommand(action = runAppTokenExec) {
|
|
|
1373
1361
|
if (exitCode !== 0) process.exitCode = exitCode;
|
|
1374
1362
|
}));
|
|
1375
1363
|
}
|
|
1376
|
-
|
|
1377
|
-
//#region src/cli-entry.ts
|
|
1364
|
+
// src/cli-entry.ts
|
|
1378
1365
|
/**
|
|
1379
1366
|
* The path of the module that runs a factory command.
|
|
1380
1367
|
*
|
|
@@ -1389,8 +1376,7 @@ function createAppTokenExecCommand(action = runAppTokenExec) {
|
|
|
1389
1376
|
* development, `cli.js` in the built package.
|
|
1390
1377
|
*/
|
|
1391
1378
|
const factoryCliEntry = () => path.join(import.meta.dirname, `cli${path.extname(import.meta.filename)}`);
|
|
1392
|
-
|
|
1393
|
-
//#region src/glob-match.ts
|
|
1379
|
+
// src/glob-match.ts
|
|
1394
1380
|
function isValidGlob(pattern) {
|
|
1395
1381
|
try {
|
|
1396
1382
|
picomatch(pattern, { strictBrackets: true });
|
|
@@ -1409,8 +1395,7 @@ function isValidRepoRelativeGlob(pattern) {
|
|
|
1409
1395
|
function matchesAnyGlob(patterns, file) {
|
|
1410
1396
|
return patterns.length > 0 && picomatch.isMatch(file, [...patterns]);
|
|
1411
1397
|
}
|
|
1412
|
-
|
|
1413
|
-
//#region src/impact-stamp.ts
|
|
1398
|
+
// src/impact-stamp.ts
|
|
1414
1399
|
const LOCKFILE_PATH = "pnpm-lock.yaml";
|
|
1415
1400
|
const SUPPORTED_LOCKFILE_VERSION = "9.0";
|
|
1416
1401
|
const impactStampTargetSchema = z.object({
|
|
@@ -1588,11 +1573,25 @@ const canonical = (value) => {
|
|
|
1588
1573
|
return value;
|
|
1589
1574
|
};
|
|
1590
1575
|
const stableStringify$1 = (value) => JSON.stringify(canonical(value));
|
|
1576
|
+
const PACKAGE_MANAGER_IMPORTER_KEYS = /* @__PURE__ */ new Set(["configDependencies", "packageManagerDependencies"]);
|
|
1577
|
+
const isPackageManagerLockfile = (value) => {
|
|
1578
|
+
if (!isRecord$2(value) || !isRecord$2(value.importers)) return false;
|
|
1579
|
+
const importerPaths = Object.keys(value.importers);
|
|
1580
|
+
const root = value.importers["."];
|
|
1581
|
+
return importerPaths.length === 1 && isRecord$2(root) && Object.keys(root).every((key) => PACKAGE_MANAGER_IMPORTER_KEYS.has(key));
|
|
1582
|
+
};
|
|
1591
1583
|
const parseLockfile = (content) => {
|
|
1592
1584
|
try {
|
|
1593
|
-
const
|
|
1594
|
-
if (!
|
|
1595
|
-
const
|
|
1585
|
+
const documents = parseAllDocuments(content);
|
|
1586
|
+
if (!Array.isArray(documents) || documents.some((document) => document.errors.length > 0)) return;
|
|
1587
|
+
const values = documents.map((document) => document.toJS());
|
|
1588
|
+
const [first, second] = values;
|
|
1589
|
+
const project = values.length === 2 ? second : first;
|
|
1590
|
+
if (values.length === 0 || values.length > 2 || values.length === 2 && !isPackageManagerLockfile(first) || !isRecord$2(project)) return;
|
|
1591
|
+
const validated = pnpmLockfileSchema.safeParse(values.length === 2 ? {
|
|
1592
|
+
...project,
|
|
1593
|
+
packageManagerLockfile: first
|
|
1594
|
+
} : project);
|
|
1596
1595
|
return validated.success ? validated.data : void 0;
|
|
1597
1596
|
} catch {
|
|
1598
1597
|
return;
|
|
@@ -1600,7 +1599,7 @@ const parseLockfile = (content) => {
|
|
|
1600
1599
|
};
|
|
1601
1600
|
const nonGraphSections = ({ importers: _importers, packages: _packages, snapshots: _snapshots, ...rest }) => rest;
|
|
1602
1601
|
const changedSectionKeys = (before, after) => {
|
|
1603
|
-
return [
|
|
1602
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})])].filter((key) => stableStringify$1(before?.[key]) !== stableStringify$1(after?.[key]));
|
|
1604
1603
|
};
|
|
1605
1604
|
const linkTarget = (importerPath, version) => {
|
|
1606
1605
|
if (!version.startsWith("link:")) return;
|
|
@@ -1619,7 +1618,7 @@ const linkTarget = (importerPath, version) => {
|
|
|
1619
1618
|
};
|
|
1620
1619
|
const importerMatchesTarget = (importerPath, importerRoots) => importerRoots.some((root) => importerPath === root || importerPath.startsWith(`${root}/`));
|
|
1621
1620
|
const workspaceClosure = (lockfile, importerRoots) => {
|
|
1622
|
-
const closure = new Set(["."]);
|
|
1621
|
+
const closure = /* @__PURE__ */ new Set(["."]);
|
|
1623
1622
|
const queue = Object.keys(lockfile.importers ?? {}).filter((importerPath) => importerMatchesTarget(importerPath, importerRoots));
|
|
1624
1623
|
while (queue.length > 0) {
|
|
1625
1624
|
const importerPath = queue.pop();
|
|
@@ -1859,7 +1858,8 @@ const unionTargetImpact = (source, lockfile) => {
|
|
|
1859
1858
|
const computeImpactStampOrThrow = ({ changedFiles, profile, profilePath = "software-factory.profile.json", readLockfile }, targets) => {
|
|
1860
1859
|
const { dependencyLocalGlobs, inertGlobs } = declaredOwnershipGlobs(profile);
|
|
1861
1860
|
if (targets.length === 0) {
|
|
1862
|
-
const
|
|
1861
|
+
const sourceFiles = changedFiles.filter((file) => file !== "pnpm-lock.yaml" && isRepoRelativePath(file));
|
|
1862
|
+
const { inertPaths, unsubscribedPaths } = partitionUnownedSourcePaths(sourceFiles, [], inertGlobs);
|
|
1863
1863
|
return {
|
|
1864
1864
|
basis: "conservative",
|
|
1865
1865
|
inertPaths,
|
|
@@ -1939,7 +1939,7 @@ const lockfileImporterScope = (readLockfile) => {
|
|
|
1939
1939
|
reason: `${LOCKFILE_PATH} changes the root importer's dependencies`
|
|
1940
1940
|
};
|
|
1941
1941
|
const resolvedBy = [...new Set(sides.parsed.flatMap((lockfile) => Object.keys(lockfile.importers)))].map((importerPath) => {
|
|
1942
|
-
const keys = new Set(sides.parsed.flatMap((lockfile) => [...snapshotClosure(lockfile, new Set([importerPath]))]));
|
|
1942
|
+
const keys = new Set(sides.parsed.flatMap((lockfile) => [...snapshotClosure(lockfile, /* @__PURE__ */ new Set([importerPath]))]));
|
|
1943
1943
|
return {
|
|
1944
1944
|
bare: new Set([...keys].map(withoutPeerSuffix)),
|
|
1945
1945
|
importerPath,
|
|
@@ -1965,15 +1965,13 @@ const lockfileImporterScope = (readLockfile) => {
|
|
|
1965
1965
|
kind: "scoped"
|
|
1966
1966
|
};
|
|
1967
1967
|
};
|
|
1968
|
-
|
|
1969
|
-
//#region src/diff-classification.ts
|
|
1968
|
+
// src/diff-classification.ts
|
|
1970
1969
|
const DIFF_CLASSIFICATIONS = [
|
|
1971
1970
|
"docs/process-only",
|
|
1972
1971
|
"trivial",
|
|
1973
1972
|
"non-trivial"
|
|
1974
1973
|
];
|
|
1975
|
-
|
|
1976
|
-
//#region src/required-check-policy.ts
|
|
1974
|
+
// src/required-check-policy.ts
|
|
1977
1975
|
const EVIDENCE_CHECK_TYPES = ["review", "verify"];
|
|
1978
1976
|
const requiredCheckScopeSchema = z.object({ classifications: z.array(z.enum(DIFF_CLASSIFICATIONS)).min(1) }).strict();
|
|
1979
1977
|
const requiredCheckInScope = ({ context, scope }) => {
|
|
@@ -1994,8 +1992,7 @@ const requiredCheckInScope = ({ context, scope }) => {
|
|
|
1994
1992
|
reason: `out of scope — classification "${context.classification}" is not one of: ${scope.classifications.join(", ")}`
|
|
1995
1993
|
};
|
|
1996
1994
|
};
|
|
1997
|
-
|
|
1998
|
-
//#region src/profile.ts
|
|
1995
|
+
// src/profile.ts
|
|
1999
1996
|
const DEFAULT_FACTORY_REPOSITORY = "unknown/unknown";
|
|
2000
1997
|
/**
|
|
2001
1998
|
* The shapes v6 replaced. Not loadable — {@link legacyProfileMigration} turns
|
|
@@ -2336,8 +2333,7 @@ function formatProfileError(profilePath, error) {
|
|
|
2336
2333
|
return `${issue.path.length > 0 ? issue.path.join(".") : "root"}: ${issue.message}`;
|
|
2337
2334
|
}).join("; ")}`;
|
|
2338
2335
|
}
|
|
2339
|
-
|
|
2340
|
-
//#region src/verification-run-context.ts
|
|
2336
|
+
// src/verification-run-context.ts
|
|
2341
2337
|
const FACTORY_BASE_REF_ENV = "FACTORY_BASE_REF";
|
|
2342
2338
|
const FACTORY_CHANGED_FILES_ENV = "FACTORY_CHANGED_FILES";
|
|
2343
2339
|
const FACTORY_CHANGED_FILES_FILE_ENV = "FACTORY_CHANGED_FILES_FILE";
|
|
@@ -2420,9 +2416,8 @@ function createVerificationRunContext(input) {
|
|
|
2420
2416
|
}
|
|
2421
2417
|
};
|
|
2422
2418
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
const JS_MODULE_EXTENSIONS = new Set([
|
|
2419
|
+
// src/affected.ts
|
|
2420
|
+
const JS_MODULE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
2426
2421
|
".cjs",
|
|
2427
2422
|
".cts",
|
|
2428
2423
|
".js",
|
|
@@ -2495,7 +2490,7 @@ const listPnpmProjects = (cwd, selection, env) => {
|
|
|
2495
2490
|
cwd,
|
|
2496
2491
|
encoding: "utf-8",
|
|
2497
2492
|
env,
|
|
2498
|
-
maxBuffer:
|
|
2493
|
+
maxBuffer: 67108864,
|
|
2499
2494
|
shell: false
|
|
2500
2495
|
});
|
|
2501
2496
|
if (result.error || result.status !== 0) throw new Error(`pnpm ls ${selection.join(" ")} failed in ${cwd}: ${result.error?.message ?? result.stderr.trim()}`);
|
|
@@ -2706,12 +2701,13 @@ const resolveVitestBin = (cwd) => {
|
|
|
2706
2701
|
return path.join(root, bin);
|
|
2707
2702
|
};
|
|
2708
2703
|
const runInherited = async (invocation, env) => {
|
|
2709
|
-
const
|
|
2704
|
+
const child = spawn(invocation.command, invocation.args, {
|
|
2710
2705
|
cwd: invocation.cwd,
|
|
2711
2706
|
env,
|
|
2712
2707
|
shell: false,
|
|
2713
2708
|
stdio: "inherit"
|
|
2714
|
-
})
|
|
2709
|
+
});
|
|
2710
|
+
const [code] = await once(child, "close");
|
|
2715
2711
|
return code ?? 1;
|
|
2716
2712
|
};
|
|
2717
2713
|
/**
|
|
@@ -2818,8 +2814,7 @@ const runAffected = async (args, dependencies) => {
|
|
|
2818
2814
|
}
|
|
2819
2815
|
return 0;
|
|
2820
2816
|
};
|
|
2821
|
-
|
|
2822
|
-
//#region src/commands/affected.ts
|
|
2817
|
+
// src/commands/affected.ts
|
|
2823
2818
|
const selectedRunner = (options) => {
|
|
2824
2819
|
if (options.pnpm === options.vitest) throw new Error("psf affected needs exactly one runner: --pnpm or --vitest");
|
|
2825
2820
|
return options.pnpm ? "pnpm" : "vitest";
|
|
@@ -2840,8 +2835,7 @@ function createAffectedCommand(output) {
|
|
|
2840
2835
|
}, { write: (text) => output.stdout.write(text) });
|
|
2841
2836
|
}));
|
|
2842
2837
|
}
|
|
2843
|
-
|
|
2844
|
-
//#region src/admission-credential.ts
|
|
2838
|
+
// src/admission-credential.ts
|
|
2845
2839
|
const OPERATION_LABELS = {
|
|
2846
2840
|
"create-pull-request": "creating the pull request",
|
|
2847
2841
|
"edit-pull-request-body": "editing the pull request body",
|
|
@@ -2921,16 +2915,14 @@ const createAdmissionCredential = (dependencies = {}) => {
|
|
|
2921
2915
|
};
|
|
2922
2916
|
/** The admission credential this process mints once, when first needed. */
|
|
2923
2917
|
const processAdmissionCredential = createAdmissionCredential();
|
|
2924
|
-
|
|
2925
|
-
//#region src/review-rungs.ts
|
|
2918
|
+
// src/review-rungs.ts
|
|
2926
2919
|
const EVIDENCE_REVIEW_RUNGS = [
|
|
2927
2920
|
"independent-model",
|
|
2928
2921
|
"oracle",
|
|
2929
2922
|
"human"
|
|
2930
2923
|
];
|
|
2931
2924
|
const RUNG_ORDER = Object.fromEntries(EVIDENCE_REVIEW_RUNGS.map((rung, index) => [rung, index]));
|
|
2932
|
-
|
|
2933
|
-
//#region src/boundary-manifest.ts
|
|
2925
|
+
// src/boundary-manifest.ts
|
|
2934
2926
|
var boundary_manifest_exports = /* @__PURE__ */ __exportAll({
|
|
2935
2927
|
BOUNDARY_CLOSEOUT_DEFAULT_RUNG: () => BOUNDARY_CLOSEOUT_DEFAULT_RUNG,
|
|
2936
2928
|
BOUNDARY_MANIFEST_SCHEMA_VERSION: () => 1,
|
|
@@ -3042,8 +3034,7 @@ const parseBoundaryManifest = (issueBody) => {
|
|
|
3042
3034
|
};
|
|
3043
3035
|
};
|
|
3044
3036
|
const closeoutRungFor = (manifest) => manifest.closeout?.review ?? "oracle";
|
|
3045
|
-
|
|
3046
|
-
//#region src/comment-provenance.ts
|
|
3037
|
+
// src/comment-provenance.ts
|
|
3047
3038
|
var comment_provenance_exports = /* @__PURE__ */ __exportAll({
|
|
3048
3039
|
SHA_MATCH_MIN_LENGTH: () => 7,
|
|
3049
3040
|
isBotLogin: () => isBotLogin,
|
|
@@ -3055,8 +3046,7 @@ const sameHeadSha = (left, right) => {
|
|
|
3055
3046
|
if (Math.min(left.length, right.length) < 7) return false;
|
|
3056
3047
|
return left.startsWith(right) || right.startsWith(left);
|
|
3057
3048
|
};
|
|
3058
|
-
|
|
3059
|
-
//#region src/boundary-membership-graph.ts
|
|
3049
|
+
// src/boundary-membership-graph.ts
|
|
3060
3050
|
const DEFAULT_TERMINAL_BASE = "main";
|
|
3061
3051
|
/** Every child issue the manifest declares, across waves. */
|
|
3062
3052
|
const declaredIssueSet = (manifest) => new Set(manifest.waves.flatMap((wave) => wave.issues));
|
|
@@ -3224,8 +3214,7 @@ const coveredSetDivergences = (computed, proof) => {
|
|
|
3224
3214
|
for (const reviewed of proof.coveredSet) if (!liveKeys.has(membershipKey(reviewed))) divergences.push(`${membershipLabel(reviewed)} was covered by the proof but is no longer in the delivery boundary's live covered set`);
|
|
3225
3215
|
return divergences;
|
|
3226
3216
|
};
|
|
3227
|
-
|
|
3228
|
-
//#region src/boundary-review-proof.ts
|
|
3217
|
+
// src/boundary-review-proof.ts
|
|
3229
3218
|
var boundary_review_proof_exports = /* @__PURE__ */ __exportAll({
|
|
3230
3219
|
BOUNDARY_REVIEW_PROOF_KIND: () => BOUNDARY_REVIEW_PROOF_KIND$1,
|
|
3231
3220
|
boundaryReviewProofAuthorsSeen: () => boundaryReviewProofAuthorsSeen,
|
|
@@ -3342,8 +3331,7 @@ const boundaryReviewProofAuthorsSeen = (comments, boundary) => {
|
|
|
3342
3331
|
};
|
|
3343
3332
|
const boundaryReviewProofParseFailures = (comments, boundary) => scanBoundaryReviewProofs(comments, boundary).failed;
|
|
3344
3333
|
const undispositionedBlockingFindings = (proof) => proof.findings.filter((finding) => (finding.category !== "maintainability" || finding.blockingAfterCap === true) && finding.disposition === void 0).map((finding) => `boundary finding "${finding.title}" (category ${finding.category ?? "unknown"}) has no disposition; fix it or record waived / follow-up-filed`);
|
|
3345
|
-
|
|
3346
|
-
//#region src/boundary-topology.ts
|
|
3334
|
+
// src/boundary-topology.ts
|
|
3347
3335
|
const eachToEpicBranch = (manifest) => manifest.topology === "each-to-epic" ? manifest.integrationBranch : void 0;
|
|
3348
3336
|
/**
|
|
3349
3337
|
* Validate only the current member during admission. This deliberately does
|
|
@@ -3462,8 +3450,7 @@ const boundaryTopologyReasons = ({ manifest, pullRequests, terminalBase = DEFAUL
|
|
|
3462
3450
|
if (admittedReleaseMembers.length > 1) reasons.push(`each-to-epic admits at most one post-terminal release member targeting ${terminalBase}; found ${admittedReleaseMembers.length}: ${admittedReleaseMembers.map((member) => `PR #${member.number}`).join(", ")}.`);
|
|
3463
3451
|
return reasons;
|
|
3464
3452
|
};
|
|
3465
|
-
|
|
3466
|
-
//#region src/closing-keywords.ts
|
|
3453
|
+
// src/closing-keywords.ts
|
|
3467
3454
|
const CLOSING_KEYWORD = new RegExp(`(?<![A-Za-z0-9#/-])(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)(?::\\s*|\\s+)(?:(?<owner>[\\w.-]+)/(?<repo>[\\w.-]+)#|#)(?<number>\\d+)(?![A-Za-z0-9])`, "giu");
|
|
3468
3455
|
const blankNonNewlines = (text) => text.replaceAll(/[^\n]/gu, " ");
|
|
3469
3456
|
const FENCE_LINE = /^(?:[ \t>]*(?:(?:[-+*]|\d{1,9}[.)])[ \t]+)?)(?<fence>`{3,}|~{3,})(?<rest>[^\r\n]*)(?:\r?\n|$)/gmu;
|
|
@@ -3551,8 +3538,7 @@ const issuesNamedByClosingKeywords = (body, delivery) => {
|
|
|
3551
3538
|
};
|
|
3552
3539
|
/** Body-named issues that sit in the boundary's declared child set. */
|
|
3553
3540
|
const declaredChildrenNamedInBody = (body, delivery, declaredIssues) => issuesNamedByClosingKeywords(body, delivery).filter((issue) => declaredIssues.has(issue));
|
|
3554
|
-
|
|
3555
|
-
//#region src/demand-keys.ts
|
|
3541
|
+
// src/demand-keys.ts
|
|
3556
3542
|
/** The demands that exist at most once per candidate. */
|
|
3557
3543
|
const DEMAND_KEYS = {
|
|
3558
3544
|
/**
|
|
@@ -3718,8 +3704,7 @@ const demandKeySchema = z.string().refine((value) => {
|
|
|
3718
3704
|
* reports it as an unapplied waiver — so nothing is admitted by accepting it.
|
|
3719
3705
|
*/
|
|
3720
3706
|
const waiverDemandKeySchema = z.string().regex(/^[a-z][a-z0-9-]*(?::[A-Za-z0-9._%/-]+)?$/u, "A demand key is a lowercase family, optionally qualified by its resolved value (e.g. review-rung:human).");
|
|
3721
|
-
|
|
3722
|
-
//#region src/factory-session.ts
|
|
3707
|
+
// src/factory-session.ts
|
|
3723
3708
|
const FACTORY_SESSION_ID_ENV = "FACTORY_SESSION_ID";
|
|
3724
3709
|
const UNKNOWN_AUTHORING_SESSION = "unknown";
|
|
3725
3710
|
const normalizeSessionId = (value) => {
|
|
@@ -3736,8 +3721,7 @@ const resolveAuthoringSessionIds = ({ override, recorded }) => {
|
|
|
3736
3721
|
const normalizedRecorded = normalizeSessionId(recorded);
|
|
3737
3722
|
return normalizedRecorded && normalizedRecorded !== "unknown" ? [normalizedRecorded] : [];
|
|
3738
3723
|
};
|
|
3739
|
-
|
|
3740
|
-
//#region src/demand-waiver.ts
|
|
3724
|
+
// src/demand-waiver.ts
|
|
3741
3725
|
const DEMAND_WAIVER_SCHEMA_VERSION$1 = 1;
|
|
3742
3726
|
const DEFAULT_DEMAND_WAIVER_PATH = ".factory-memory/demand-waivers.json";
|
|
3743
3727
|
const shaSchema$5 = z.string().regex(/^[0-9a-f]{40}$/u);
|
|
@@ -3849,8 +3833,7 @@ const authorizeDemandWaiver = ({ authenticatedLogin, session }) => {
|
|
|
3849
3833
|
...normalizedSession && normalizedSession !== "unknown" ? { session: normalizedSession } : {}
|
|
3850
3834
|
} };
|
|
3851
3835
|
};
|
|
3852
|
-
|
|
3853
|
-
//#region src/sha256-hex.ts
|
|
3836
|
+
// src/sha256-hex.ts
|
|
3854
3837
|
const ROUND_CONSTANTS = new Uint32Array([
|
|
3855
3838
|
1116352408,
|
|
3856
3839
|
1899447441,
|
|
@@ -3995,10 +3978,9 @@ const sha256Hex = (input) => {
|
|
|
3995
3978
|
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) compress(state, view, offset);
|
|
3996
3979
|
return toHex(state);
|
|
3997
3980
|
};
|
|
3998
|
-
|
|
3999
|
-
//#region src/review-finding-identity.ts
|
|
3981
|
+
// src/review-finding-identity.ts
|
|
4000
3982
|
const normalizeCitedSpan = (text) => text.split(/\r?\n/u).map((line) => line.trim().replaceAll(/\s+/gu, " ")).filter((line) => line.length > 0).join("\n");
|
|
4001
|
-
const PRESCRIBED_ACTION_STOPWORDS = new Set([
|
|
3983
|
+
const PRESCRIBED_ACTION_STOPWORDS = /* @__PURE__ */ new Set([
|
|
4002
3984
|
"a",
|
|
4003
3985
|
"an",
|
|
4004
3986
|
"the",
|
|
@@ -4065,11 +4047,12 @@ const findingKey = (finding) => {
|
|
|
4065
4047
|
const normalizedSpan = normalizeCitedSpan(finding.citedSpan ?? "");
|
|
4066
4048
|
const actionTokens = tokenizePrescribedAction(finding.prescribedAction ?? "");
|
|
4067
4049
|
const legacyDiscriminator = normalizedSpan.length > 0 || actionTokens.length > 0 ? "" : normalizeTitle(finding.title ?? "");
|
|
4068
|
-
|
|
4050
|
+
const spanDigest = sha256Hex(normalizedSpan);
|
|
4051
|
+
const actionJoined = actionTokens.join(" ");
|
|
4052
|
+
return sha256Hex(`${path}\0${spanDigest}\0${actionJoined}\0${legacyDiscriminator}`);
|
|
4069
4053
|
};
|
|
4070
4054
|
const declarationMatchesEntry = (entry, target) => normalizeTitle(entry.title) === normalizeTitle(target.title) && (target.file === void 0 || entry.file !== void 0 && normalizeFile(entry.file) === normalizeFile(target.file));
|
|
4071
|
-
|
|
4072
|
-
//#region src/review-ladder-policy.ts
|
|
4055
|
+
// src/review-ladder-policy.ts
|
|
4073
4056
|
const REVIEW_SEVERITIES = [
|
|
4074
4057
|
"critical",
|
|
4075
4058
|
"high",
|
|
@@ -4145,8 +4128,7 @@ const FACTORY_REVIEW_CYCLE_CAP = 5;
|
|
|
4145
4128
|
*/
|
|
4146
4129
|
const reviewRoundCount = (cycles) => new Set(cycles.map((cycle, index) => cycle.identity?.patchId ?? `unidentified:${index}`)).size;
|
|
4147
4130
|
const resolveReviewLadderPolicy = () => ({ gate: { cap: FACTORY_REVIEW_CYCLE_CAP } });
|
|
4148
|
-
|
|
4149
|
-
//#region src/review-ladder-ledger.ts
|
|
4131
|
+
// src/review-ladder-ledger.ts
|
|
4150
4132
|
const OCCURRENCE_ADDRESS_PATTERN = /^c[1-9][0-9]*f[1-9][0-9]*$/u;
|
|
4151
4133
|
const occurrenceAddress = (cycle, finding) => `c${cycle}f${finding}`;
|
|
4152
4134
|
/** The 1-based recording position an address names. */
|
|
@@ -4273,8 +4255,7 @@ const openLadderFindings = (ledger) => ledger.filter((entry) => entry.dispositio
|
|
|
4273
4255
|
const occurrenceBlocks = (occurrence) => occurrence.disposition === "open" && resolveFindingBlocking(occurrence.finding, "open");
|
|
4274
4256
|
const blockingLadderFindings = (ledger) => ledger.filter((entry) => entry.occurrences.some(occurrenceBlocks));
|
|
4275
4257
|
const staleRepeatLadderFindings = (ledger) => ledger.filter((entry) => entry.disposition === "stale-repeat");
|
|
4276
|
-
|
|
4277
|
-
//#region src/review-recording-schema.ts
|
|
4258
|
+
// src/review-recording-schema.ts
|
|
4278
4259
|
const ABSENT_PROOF_DIGEST = "absent";
|
|
4279
4260
|
const sha256Pattern = /^[0-9a-f]{64}$/u;
|
|
4280
4261
|
const occurrenceAddressSchema$1 = z.string().regex(OCCURRENCE_ADDRESS_PATTERN);
|
|
@@ -4312,8 +4293,7 @@ const reviewCycleRecordingSchema = z.object({
|
|
|
4312
4293
|
findingsDigest: z.string().regex(sha256Pattern),
|
|
4313
4294
|
recordingId: z.string().regex(sha256Pattern)
|
|
4314
4295
|
}).strict();
|
|
4315
|
-
|
|
4316
|
-
//#region src/review-recording.ts
|
|
4296
|
+
// src/review-recording.ts
|
|
4317
4297
|
/**
|
|
4318
4298
|
* The occurrences of the cycles already on the ladder, in recording order,
|
|
4319
4299
|
* with the write-time key each carries for grouping the next cycle. A cycle
|
|
@@ -4430,8 +4410,7 @@ const resolveDeclaredDispositions = ({ declarations, index, resolutions }) => {
|
|
|
4430
4410
|
}
|
|
4431
4411
|
return records;
|
|
4432
4412
|
};
|
|
4433
|
-
|
|
4434
|
-
//#region src/pr-proof-io.ts
|
|
4413
|
+
// src/pr-proof-io.ts
|
|
4435
4414
|
const proofPathFor = (descriptor, cwd, filePath = descriptor.defaultPath) => path.resolve(cwd, filePath);
|
|
4436
4415
|
const readProofFromPath = (parse, filePath) => parse(JSON.parse(readFileSync(filePath, "utf-8")));
|
|
4437
4416
|
const readProofFor = (descriptor, cwd, filePath) => readProofFromPath(descriptor.parse, proofPathFor(descriptor, cwd, filePath));
|
|
@@ -4706,8 +4685,7 @@ function assertCleanWorktreeForProof({ cwd, dirtyMessage, statusPorcelain }) {
|
|
|
4706
4685
|
const status = statusPorcelain(cwd);
|
|
4707
4686
|
if (status.trim().length > 0) throw new Error(`${dirtyMessage}\n${status}`);
|
|
4708
4687
|
}
|
|
4709
|
-
|
|
4710
|
-
//#region src/battery-shell-command.ts
|
|
4688
|
+
// src/battery-shell-command.ts
|
|
4711
4689
|
/** Quotes one argument for a POSIX shell, including embedded single quotes. */
|
|
4712
4690
|
function singleQuote(value) {
|
|
4713
4691
|
return `'${value.replaceAll("'", String.raw`'\''`)}'`;
|
|
@@ -4724,8 +4702,7 @@ function singleQuote(value) {
|
|
|
4724
4702
|
function withPinnedNodeOnPath(command, nodeBinDir) {
|
|
4725
4703
|
return `export PATH=${singleQuote(nodeBinDir)}:"$PATH"\n${command}`;
|
|
4726
4704
|
}
|
|
4727
|
-
|
|
4728
|
-
//#region src/github-issue-comments.ts
|
|
4705
|
+
// src/github-issue-comments.ts
|
|
4729
4706
|
const isCommentPage = (value) => Array.isArray(value[0]);
|
|
4730
4707
|
const normalizeIssueComments = (value) => {
|
|
4731
4708
|
return (isCommentPage(value) ? value.flat() : value).map((comment) => ({
|
|
@@ -4737,8 +4714,7 @@ const normalizeIssueComments = (value) => {
|
|
|
4737
4714
|
url: comment.html_url
|
|
4738
4715
|
}));
|
|
4739
4716
|
};
|
|
4740
|
-
|
|
4741
|
-
//#region src/github-client.ts
|
|
4717
|
+
// src/github-client.ts
|
|
4742
4718
|
/**
|
|
4743
4719
|
* Shared `gh` CLI client for the factory.
|
|
4744
4720
|
*
|
|
@@ -5044,8 +5020,7 @@ const describeCandidateBase = (binding) => {
|
|
|
5044
5020
|
const pullRequest = binding.source.pullRequest.status === "none" ? "no pull request is open for this branch" : `the pull request lookup was unavailable, so no live PR base could be read (${binding.source.pullRequest.reason})`;
|
|
5045
5021
|
return `base ${binding.ref} at ${binding.sha}, ${fetched}; ${pullRequest}`;
|
|
5046
5022
|
};
|
|
5047
|
-
|
|
5048
|
-
//#region src/candidate-identity.ts
|
|
5023
|
+
// src/candidate-identity.ts
|
|
5049
5024
|
/**
|
|
5050
5025
|
* The same fallback for a patch id taken at an explicit ref rather than at
|
|
5051
5026
|
* `HEAD`. It exists so the historical-cycle walk (#943) reads a past patch
|
|
@@ -5201,8 +5176,7 @@ function createCandidateIdentityResolver({ cwd, git }) {
|
|
|
5201
5176
|
return identity;
|
|
5202
5177
|
};
|
|
5203
5178
|
}
|
|
5204
|
-
|
|
5205
|
-
//#region src/catch-up-recognition.ts
|
|
5179
|
+
// src/catch-up-recognition.ts
|
|
5206
5180
|
const refused = (reason) => ({
|
|
5207
5181
|
reasons: [reason],
|
|
5208
5182
|
recognized: false
|
|
@@ -5241,8 +5215,7 @@ const recognizeCatchUpCandidate = ({ base, cwd }) => {
|
|
|
5241
5215
|
return refused(`catch-up recognition refused: ${error instanceof Error ? error.message : String(error)}`);
|
|
5242
5216
|
}
|
|
5243
5217
|
};
|
|
5244
|
-
|
|
5245
|
-
//#region src/demand-resolution.ts
|
|
5218
|
+
// src/demand-resolution.ts
|
|
5246
5219
|
/**
|
|
5247
5220
|
* Resolve the review modes demanded by a candidate's changed files.
|
|
5248
5221
|
*
|
|
@@ -5295,7 +5268,7 @@ const resolveAuthoritativeReviewDemand = ({ basePolicy, candidatePolicy, changed
|
|
|
5295
5268
|
const candidateCanonical = canonicalReviewPolicy(candidatePolicy);
|
|
5296
5269
|
const reviewPolicyChanged = baseCanonical !== candidateCanonical;
|
|
5297
5270
|
const candidatePaths = reviewPolicyPaths(candidatePolicy);
|
|
5298
|
-
const effectivePaths = [
|
|
5271
|
+
const effectivePaths = [.../* @__PURE__ */ new Set([...reviewPolicyPaths(basePolicy), ...candidatePaths])].toSorted(compareStrings);
|
|
5299
5272
|
const candidateOwned = new Set(candidatePaths);
|
|
5300
5273
|
const baseOnlyMatchedPaths = effectivePaths.filter((protectedPath) => !candidateOwned.has(protectedPath) && changedFiles.some((file) => matchesAnyGlob([protectedPath], file)));
|
|
5301
5274
|
const candidateAloneDemandsSecurity = changedFiles.some((file) => matchesAnyGlob(candidatePaths, file));
|
|
@@ -5756,8 +5729,9 @@ const gateTimingRecordSchema = z.object({
|
|
|
5756
5729
|
/** Wall-clock start of this gate invocation (ISO 8601). */
|
|
5757
5730
|
startedAt: z.iso.datetime()
|
|
5758
5731
|
}).strict();
|
|
5732
|
+
const CLAUDE_CODE_SESSION_ID_ENV$1 = "CLAUDE_CODE_SESSION_ID";
|
|
5759
5733
|
const GATE_TIMING_LEDGER_DIR = ".factory-memory/gate-timing";
|
|
5760
|
-
const resolveGateTimingAgentRunId = (env = process.env) => normalizeSessionId(env["FACTORY_AGENT_RUN_ID"]) ?? discoverFactorySessionId(env);
|
|
5734
|
+
const resolveGateTimingAgentRunId = (env = process.env) => normalizeSessionId(env["FACTORY_AGENT_RUN_ID"]) ?? discoverFactorySessionId(env) ?? normalizeSessionId(env[CLAUDE_CODE_SESSION_ID_ENV$1]);
|
|
5761
5735
|
const safeLedgerName = (agentRunId) => agentRunId.replaceAll(/[^\w.-]/gu, "-").slice(0, 120);
|
|
5762
5736
|
const gateTimingLedgerPath = (root, agentRunId) => path.join(root, GATE_TIMING_LEDGER_DIR, `${safeLedgerName(agentRunId)}.jsonl`);
|
|
5763
5737
|
/**
|
|
@@ -5780,8 +5754,7 @@ const parseGateTimingLedgerText = (text) => {
|
|
|
5780
5754
|
}
|
|
5781
5755
|
return records;
|
|
5782
5756
|
};
|
|
5783
|
-
|
|
5784
|
-
//#region src/hq-access.ts
|
|
5757
|
+
// src/hq-access.ts
|
|
5785
5758
|
/**
|
|
5786
5759
|
* The environment variables that carry the HQ Cloudflare Access service token.
|
|
5787
5760
|
* Both names are shell identifiers, so `/bin/sh` passes them through on every
|
|
@@ -5816,8 +5789,7 @@ const buildCloudflareAccessRequestInit = (token, init) => ({
|
|
|
5816
5789
|
},
|
|
5817
5790
|
redirect: "error"
|
|
5818
5791
|
});
|
|
5819
|
-
|
|
5820
|
-
//#region src/hq-credentials.ts
|
|
5792
|
+
// src/hq-credentials.ts
|
|
5821
5793
|
/**
|
|
5822
5794
|
* Resolving the HQ Access credentials, and saying *why* when that fails.
|
|
5823
5795
|
*
|
|
@@ -5995,8 +5967,7 @@ const FAILURE_SENTENCE = {
|
|
|
5995
5967
|
* read, so nothing here can quote a secret.
|
|
5996
5968
|
*/
|
|
5997
5969
|
const describeHqCredentialFailure = (resolution) => `HQ Access credentials are unavailable: ${FAILURE_SENTENCE[resolution.failure](resolution.reference ?? "the configured reference")}`;
|
|
5998
|
-
|
|
5999
|
-
//#region src/hq-origin-policy.ts
|
|
5970
|
+
// src/hq-origin-policy.ts
|
|
6000
5971
|
/**
|
|
6001
5972
|
* Where the HQ Access service token may be sent, decided once.
|
|
6002
5973
|
*
|
|
@@ -6017,7 +5988,7 @@ const describeHqCredentialFailure = (resolution) => `HQ Access credentials are u
|
|
|
6017
5988
|
* touch the filesystem, so it still applies when the file does not answer.
|
|
6018
5989
|
*/
|
|
6019
5990
|
/** Largest operator config or profile file the HQ readers will open. */
|
|
6020
|
-
const MAX_HQ_CONFIG_BYTES =
|
|
5991
|
+
const MAX_HQ_CONFIG_BYTES = 1048576;
|
|
6021
5992
|
const remainingMs = (deadline) => Math.max(0, deadline - performance.now());
|
|
6022
5993
|
const settleWithin = async (operation, budgetMs) => {
|
|
6023
5994
|
const settleOperation = async () => {
|
|
@@ -6133,7 +6104,8 @@ const resolveHqAllowedOrigins = (env, configOrigins) => {
|
|
|
6133
6104
|
const loadHqAllowedOrigins = async (env, deadline) => {
|
|
6134
6105
|
let configOrigins = [];
|
|
6135
6106
|
try {
|
|
6136
|
-
const
|
|
6107
|
+
const configPath = defaultUserConfigPath(env);
|
|
6108
|
+
const contents = await readBoundedTextFile(configPath, deadline);
|
|
6137
6109
|
if (contents !== void 0) configOrigins = hqAllowedOriginsFromConfigText(contents);
|
|
6138
6110
|
} catch {
|
|
6139
6111
|
configOrigins = [];
|
|
@@ -6145,8 +6117,7 @@ const loadHqAllowedOrigins = async (env, deadline) => {
|
|
|
6145
6117
|
* No prefix, wildcard, or host-only match.
|
|
6146
6118
|
*/
|
|
6147
6119
|
const isHqOriginAuthorized = (allowedOrigins, endpoint) => allowedOrigins.includes(endpoint.origin);
|
|
6148
|
-
|
|
6149
|
-
//#region src/hq-user-agent.ts
|
|
6120
|
+
// src/hq-user-agent.ts
|
|
6150
6121
|
/**
|
|
6151
6122
|
* The `User-Agent` every HQ ingest sink request carries (#1343). Without it
|
|
6152
6123
|
* the sink sends fetch's default, `node`. HQ stores the header in
|
|
@@ -6178,7 +6149,7 @@ const SPOOL_REPOSITORY_MARKER = ".repository-identity";
|
|
|
6178
6149
|
*/
|
|
6179
6150
|
const HQ_SPOOL_SWEEP_MAX_DEPTH = 4;
|
|
6180
6151
|
const HQ_SPOOL_STATE_SEGMENTS = ["patronage-factory", "hq-spool"];
|
|
6181
|
-
const MAX_HQ_INGEST_PAYLOAD_BYTES =
|
|
6152
|
+
const MAX_HQ_INGEST_PAYLOAD_BYTES = 262144;
|
|
6182
6153
|
const MAX_HQ_REPLAY_ENTRIES = 32;
|
|
6183
6154
|
const STALE_SPOOL_ARTIFACT_MS = 6e4;
|
|
6184
6155
|
const HQ_JOURNAL_FLUSH_BUDGET_MS = 250;
|
|
@@ -6472,7 +6443,7 @@ const persistRetrySpool = async (layout, entry, deadline) => {
|
|
|
6472
6443
|
status: "failed"
|
|
6473
6444
|
};
|
|
6474
6445
|
}
|
|
6475
|
-
if (Buffer.byteLength(body, "utf-8") >
|
|
6446
|
+
if (Buffer.byteLength(body, "utf-8") > 278528) return {
|
|
6476
6447
|
failure: "failed",
|
|
6477
6448
|
status: "failed"
|
|
6478
6449
|
};
|
|
@@ -6530,10 +6501,6 @@ const persistRetrySpool = async (layout, entry, deadline) => {
|
|
|
6530
6501
|
status: "failed"
|
|
6531
6502
|
};
|
|
6532
6503
|
};
|
|
6533
|
-
const appendCloseoutSpool = async (layout, entry, deadline) => {
|
|
6534
|
-
const result = await persistRetrySpool(layout, entry, deadline);
|
|
6535
|
-
return result.status === "failed" ? result.failure : void 0;
|
|
6536
|
-
};
|
|
6537
6504
|
const positiveBudget = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
6538
6505
|
const MAX_WIDENED_BUDGET_MS = 6e4;
|
|
6539
6506
|
const envBudget = (env, name) => {
|
|
@@ -6697,14 +6664,12 @@ const loadBoundedPayload = async (input, deadline) => {
|
|
|
6697
6664
|
* gate. Nothing else carries that record: re-emitting an earlier proof event
|
|
6698
6665
|
* to carry it would duplicate proof facts on the board.
|
|
6699
6666
|
*/
|
|
6700
|
-
const GATE_TIMED_PROOF_KINDS = new Set([
|
|
6667
|
+
const GATE_TIMED_PROOF_KINDS = /* @__PURE__ */ new Set([
|
|
6701
6668
|
"boundary-check-proof",
|
|
6702
6669
|
"pr-ready-proof",
|
|
6703
6670
|
"pr-review-proof",
|
|
6704
6671
|
"pr-verify-proof"
|
|
6705
6672
|
]);
|
|
6706
|
-
/** The newest ledger records one proof event carries. */
|
|
6707
|
-
const MAX_GATE_TIMINGS_PER_EVENT = 50;
|
|
6708
6673
|
/**
|
|
6709
6674
|
* The gate-timing records a proof event carries to HQ (#1316): the newest
|
|
6710
6675
|
* records in this lane's ledger in the emitting checkout, keyed the way
|
|
@@ -6726,7 +6691,7 @@ const emissionGateTimings = async (input, env, deadline, payloadBytes) => {
|
|
|
6726
6691
|
if (agentRunId === void 0) return [];
|
|
6727
6692
|
const ledger = await readBoundedTextFile(gateTimingLedgerPath(path.resolve(input.cwd), agentRunId), deadline, MAX_HQ_CONFIG_BYTES);
|
|
6728
6693
|
if (ledger === void 0) return [];
|
|
6729
|
-
const records = parseGateTimingLedgerText(ledger).slice(-
|
|
6694
|
+
const records = parseGateTimingLedgerText(ledger).slice(-50);
|
|
6730
6695
|
return payloadBytes + Buffer.byteLength(JSON.stringify({ gateTimings: records }), "utf-8") <= MAX_HQ_INGEST_PAYLOAD_BYTES ? records : [];
|
|
6731
6696
|
} catch {
|
|
6732
6697
|
return [];
|
|
@@ -6744,27 +6709,6 @@ const validatedIngestEndpoint = (value) => {
|
|
|
6744
6709
|
const origin = validatedHqOrigin(value);
|
|
6745
6710
|
return origin === void 0 ? void 0 : new URL(HQ_INGEST_PATH$1, origin.origin);
|
|
6746
6711
|
};
|
|
6747
|
-
const retainRetryEntry = async (layout, entry, dependencies, deadline) => {
|
|
6748
|
-
let customAppend;
|
|
6749
|
-
try {
|
|
6750
|
-
customAppend = dependencies.appendJournal;
|
|
6751
|
-
} catch {
|
|
6752
|
-
return "failed";
|
|
6753
|
-
}
|
|
6754
|
-
if (customAppend === void 0) return appendCloseoutSpool(layout, entry, deadline);
|
|
6755
|
-
let row;
|
|
6756
|
-
try {
|
|
6757
|
-
row = JSON.stringify(entry);
|
|
6758
|
-
} catch {
|
|
6759
|
-
return "failed";
|
|
6760
|
-
}
|
|
6761
|
-
const target = path.join(path.resolve(layout.root, ...layout.segments), `${randomUUID()}-${spoolFileName(entry)}`);
|
|
6762
|
-
setImmediate(async () => {
|
|
6763
|
-
try {
|
|
6764
|
-
await customAppend(target, row);
|
|
6765
|
-
} catch {}
|
|
6766
|
-
}).unref();
|
|
6767
|
-
};
|
|
6768
6712
|
/** The checkout's profile, read within `deadline`; unusable reads as absent. */
|
|
6769
6713
|
const readProjectHqProfile = async (cwd, profilePath, deadline) => {
|
|
6770
6714
|
let resolvedPath;
|
|
@@ -6942,7 +6886,7 @@ const isReplayableEntry = (value) => {
|
|
|
6942
6886
|
* automation stops retrying: 401/403 (Access refusing expired or wrong
|
|
6943
6887
|
* service-token credentials), 408 (request timeout), 429 (rate limit).
|
|
6944
6888
|
*/
|
|
6945
|
-
const NON_CONTENT_CLIENT_STATUSES = new Set([
|
|
6889
|
+
const NON_CONTENT_CLIENT_STATUSES = /* @__PURE__ */ new Set([
|
|
6946
6890
|
401,
|
|
6947
6891
|
403,
|
|
6948
6892
|
408,
|
|
@@ -6978,7 +6922,7 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
6978
6922
|
const metadata = await settleWithin(lstat(artifactPath), remainingMs(setupDeadline));
|
|
6979
6923
|
if (metadata.status !== "fulfilled" || !metadata.value.isFile() || metadata.value.isSymbolicLink() || !isTemporary && !isClaim || now - (isTemporary ? metadata.value.mtimeMs : Math.max(metadata.value.mtimeMs, metadata.value.ctimeMs)) < STALE_SPOOL_ARTIFACT_MS) continue;
|
|
6980
6924
|
if (isTemporary) {
|
|
6981
|
-
const file = await readBoundedTextFileNoFollow(artifactPath, setupDeadline,
|
|
6925
|
+
const file = await readBoundedTextFileNoFollow(artifactPath, setupDeadline, 278528);
|
|
6982
6926
|
let parsed;
|
|
6983
6927
|
try {
|
|
6984
6928
|
parsed = file === void 0 ? void 0 : JSON.parse(file.contents);
|
|
@@ -6990,7 +6934,8 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
6990
6934
|
if (!await mutateBoundDirectory(spool, spoolIdentity, setupDeadline, async () => unlink(artifactPath))) return;
|
|
6991
6935
|
continue;
|
|
6992
6936
|
}
|
|
6993
|
-
|
|
6937
|
+
const finalPath = path.join(spool, finalName);
|
|
6938
|
+
if (!await publishImmutableFile(spool, spoolIdentity, artifactPath, finalPath, setupDeadline)) return;
|
|
6994
6939
|
continue;
|
|
6995
6940
|
}
|
|
6996
6941
|
const markerIndex = name.indexOf(".json.draining-");
|
|
@@ -7007,10 +6952,10 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
7007
6952
|
if (!await directoryIdentityMatches(spool, spoolIdentity, setupDeadline)) return;
|
|
7008
6953
|
if (attempted >= maxEntries || remainingMs(replayDeadline) <= 0) break;
|
|
7009
6954
|
const metadata = await settleWithin(lstat(eventPath), remainingMs(setupDeadline));
|
|
7010
|
-
if (metadata.status !== "fulfilled" || !metadata.value.isFile() || metadata.value.isSymbolicLink() || metadata.value.size >
|
|
6955
|
+
if (metadata.status !== "fulfilled" || !metadata.value.isFile() || metadata.value.isSymbolicLink() || metadata.value.size > 278528) continue;
|
|
7011
6956
|
const claimPath = `${eventPath}.draining-${randomUUID()}`;
|
|
7012
6957
|
if (!await mutateBoundDirectory(spool, spoolIdentity, setupDeadline, async () => rename(eventPath, claimPath))) continue;
|
|
7013
|
-
const file = await readBoundedTextFileNoFollow(claimPath, setupDeadline,
|
|
6958
|
+
const file = await readBoundedTextFileNoFollow(claimPath, setupDeadline, 278528);
|
|
7014
6959
|
let entry;
|
|
7015
6960
|
try {
|
|
7016
6961
|
entry = file === void 0 ? void 0 : JSON.parse(file.contents);
|
|
@@ -7023,7 +6968,8 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
7023
6968
|
}
|
|
7024
6969
|
const entryEndpoint = validatedHqOrigin(entry.endpoint);
|
|
7025
6970
|
if (!entryEndpoint || entryEndpoint.origin !== endpoint.origin) {
|
|
7026
|
-
|
|
6971
|
+
const claimCompletionDeadline = performance.now() + flushBudgetMs;
|
|
6972
|
+
if (!await mutateBoundDirectory(spool, spoolIdentity, claimCompletionDeadline, async () => rename(claimPath, `${eventPath}${UNDELIVERABLE_SUFFIX}`))) return;
|
|
7027
6973
|
report?.({
|
|
7028
6974
|
detail: `recorded endpoint ${entryEndpoint?.origin ?? "(unusable)"} is not this repository's authorized HQ origin ${endpoint.origin}; dispositioned as ${path.basename(eventPath)}${UNDELIVERABLE_SUFFIX}`,
|
|
7029
6975
|
eventId: entry.event.eventId,
|
|
@@ -7044,7 +6990,8 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
7044
6990
|
const outcome = await attemptTransport(request, endpoint, clientId, clientSecret, body, Math.min(transportBudgetMs, remainingMs(replayDeadline)), report !== void 0);
|
|
7045
6991
|
const permanent = !outcome.ok && isPermanentRejection(outcome.reason);
|
|
7046
6992
|
if (permanent && options.evictPermanentRejections === true) {
|
|
7047
|
-
|
|
6993
|
+
const claimCompletionDeadline = performance.now() + flushBudgetMs;
|
|
6994
|
+
if (!await mutateBoundDirectory(spool, spoolIdentity, claimCompletionDeadline, async () => rename(claimPath, `${eventPath}${UNDELIVERABLE_SUFFIX}`))) return;
|
|
7048
6995
|
report?.({
|
|
7049
6996
|
detail: `${outcome.detail === void 0 ? outcome.reason : `${outcome.reason}: ${outcome.detail}`}; HQ refuses these bytes on every retry under its current ingest schema; dispositioned as ${path.basename(eventPath)}${UNDELIVERABLE_SUFFIX}`,
|
|
7050
6997
|
eventId: entry.event.eventId,
|
|
@@ -7070,10 +7017,13 @@ const replayCloseoutSpool = async (layout, endpoint, clientId, clientSecret, req
|
|
|
7070
7017
|
status: drainFailureStatus(outcome.reason)
|
|
7071
7018
|
});
|
|
7072
7019
|
}
|
|
7073
|
-
|
|
7020
|
+
const claimCompletionDeadline = performance.now() + flushBudgetMs;
|
|
7021
|
+
if (!await mutateBoundDirectory(spool, spoolIdentity, claimCompletionDeadline, () => outcome.ok ? unlink(claimPath) : rename(claimPath, eventPath))) return;
|
|
7074
7022
|
}
|
|
7075
7023
|
};
|
|
7076
|
-
async function deliverHqIngest(input, dependencies,
|
|
7024
|
+
async function deliverHqIngest(input, dependencies, anchoredSetupDeadline, timeoutMs, transportBudgetMs, lateStart) {
|
|
7025
|
+
let setupDeadline = anchoredSetupDeadline;
|
|
7026
|
+
let persistOnly = lateStart;
|
|
7077
7027
|
let config;
|
|
7078
7028
|
try {
|
|
7079
7029
|
if (!input.profile.hq?.enabled) return "skipped";
|
|
@@ -7093,7 +7043,8 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7093
7043
|
await reportDiagnostic(dependencies, setupDeadline, "operator configuration is unavailable", "HQ ingest skipped");
|
|
7094
7044
|
return "skipped";
|
|
7095
7045
|
}
|
|
7096
|
-
|
|
7046
|
+
const allowedOrigins = await loadHqAllowedOrigins(env, setupDeadline);
|
|
7047
|
+
if (!isHqOriginAuthorized(allowedOrigins, endpoint)) {
|
|
7097
7048
|
await reportDiagnostic(dependencies, setupDeadline, `endpoint origin ${endpoint.origin} is not authorized by hqAllowedOrigins in the operator user config`, "HQ ingest skipped");
|
|
7098
7049
|
return "skipped";
|
|
7099
7050
|
}
|
|
@@ -7126,7 +7077,10 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7126
7077
|
let unconfirmed = false;
|
|
7127
7078
|
try {
|
|
7128
7079
|
await setImmediate$1();
|
|
7129
|
-
if (remainingMs(setupDeadline) <= 0)
|
|
7080
|
+
if (remainingMs(setupDeadline) <= 0) {
|
|
7081
|
+
setupDeadline = performance.now() + timeoutMs;
|
|
7082
|
+
persistOnly = true;
|
|
7083
|
+
}
|
|
7130
7084
|
const projectedPayload = await loadBoundedPayload(input, setupDeadline);
|
|
7131
7085
|
const eventId = makeEventId();
|
|
7132
7086
|
const observedAt = now().toISOString();
|
|
@@ -7153,27 +7107,24 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7153
7107
|
schemaVersion: projectedPayload.value.schemaVersion,
|
|
7154
7108
|
...subject === void 0 ? {} : { subject }
|
|
7155
7109
|
};
|
|
7156
|
-
let
|
|
7110
|
+
let failedAt;
|
|
7157
7111
|
try {
|
|
7158
|
-
|
|
7112
|
+
failedAt = now().toISOString();
|
|
7159
7113
|
} catch {
|
|
7160
|
-
|
|
7114
|
+
failedAt = "unknown";
|
|
7161
7115
|
}
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
}, performance.now() + journalFlushBudgetFor(dependencies));
|
|
7175
|
-
if (persisted.status === "persisted") persistedEventPath = persisted.eventPath;
|
|
7176
|
-
else prePersistFailure = persisted.failure;
|
|
7116
|
+
const persisted = await persistRetrySpool(writeLayout, {
|
|
7117
|
+
endpoint: endpoint.href,
|
|
7118
|
+
event,
|
|
7119
|
+
failedAt,
|
|
7120
|
+
reason: persistOnly ? "setup-budget-elapsed" : "tracked-advisory-pending"
|
|
7121
|
+
}, performance.now() + journalFlushBudgetFor(dependencies));
|
|
7122
|
+
if (persisted.status === "persisted") persistedEventPath = persisted.eventPath;
|
|
7123
|
+
else prePersistFailure = persisted.failure;
|
|
7124
|
+
if (persistOnly) {
|
|
7125
|
+
if (persistedEventPath !== void 0) return "deferred";
|
|
7126
|
+
reason = "setup-budget-elapsed";
|
|
7127
|
+
throw new Error(reason);
|
|
7177
7128
|
}
|
|
7178
7129
|
if (!clientId || !clientSecret) {
|
|
7179
7130
|
if (persistedEventPath === void 0) {
|
|
@@ -7217,12 +7168,6 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7217
7168
|
} catch {
|
|
7218
7169
|
failedAt = "unknown";
|
|
7219
7170
|
}
|
|
7220
|
-
let customJournal = false;
|
|
7221
|
-
try {
|
|
7222
|
-
customJournal = dependencies.appendJournal !== void 0;
|
|
7223
|
-
} catch {
|
|
7224
|
-
customJournal = false;
|
|
7225
|
-
}
|
|
7226
7171
|
const retryEntry = {
|
|
7227
7172
|
endpoint: endpoint.href,
|
|
7228
7173
|
event,
|
|
@@ -7230,15 +7175,12 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7230
7175
|
reason,
|
|
7231
7176
|
...unconfirmed ? { unconfirmed: true } : {}
|
|
7232
7177
|
};
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
journalFailure = void 0;
|
|
7240
|
-
} else journalFailure = updated.failure;
|
|
7241
|
-
}
|
|
7178
|
+
const updated = await persistRetrySpool(writeLayout, retryEntry, flushDeadline);
|
|
7179
|
+
if (updated.status === "persisted") {
|
|
7180
|
+
if (persistedEventPath !== void 0) await removeRetrySpoolEvent(writeLayout, persistedEventPath, flushDeadline);
|
|
7181
|
+
persistedEventPath = updated.eventPath;
|
|
7182
|
+
journalFailure = void 0;
|
|
7183
|
+
} else journalFailure = updated.failure;
|
|
7242
7184
|
}
|
|
7243
7185
|
if (!unconfirmed && journalFailure === void 0 && persistedEventPath !== void 0) return "deferred";
|
|
7244
7186
|
const journalSuffix = journalFailure ? `; retry spool ${journalFailure}` : "";
|
|
@@ -7248,12 +7190,13 @@ async function deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, tr
|
|
|
7248
7190
|
async function dispatchBounded(dependencies, gateStartedAt, work) {
|
|
7249
7191
|
await setImmediate$1();
|
|
7250
7192
|
const timeoutMs = timeoutFor(dependencies);
|
|
7251
|
-
const
|
|
7252
|
-
|
|
7193
|
+
const lateStart = remainingMs(gateStartedAt + timeoutMs) <= 0;
|
|
7194
|
+
const anchoredAt = lateStart ? performance.now() : gateStartedAt;
|
|
7195
|
+
const setupDeadline = anchoredAt + timeoutMs;
|
|
7253
7196
|
const transportBudgetMs = transportTimeoutFor(dependencies);
|
|
7254
|
-
const outerDeadline =
|
|
7197
|
+
const outerDeadline = anchoredAt + timeoutMs + 2 * transportBudgetMs + HQ_JOURNAL_FLUSH_BUDGET_MS + 500;
|
|
7255
7198
|
try {
|
|
7256
|
-
const result = await settleWithin(work(setupDeadline, timeoutMs, transportBudgetMs), remainingMs(outerDeadline));
|
|
7199
|
+
const result = await settleWithin(work(setupDeadline, timeoutMs, transportBudgetMs, lateStart), remainingMs(outerDeadline));
|
|
7257
7200
|
return result.status === "fulfilled" ? result.value : "deferred";
|
|
7258
7201
|
} catch {
|
|
7259
7202
|
return "deferred";
|
|
@@ -7280,7 +7223,8 @@ async function drainRepositorySpool(input, dependencies, setupDeadline, timeoutM
|
|
|
7280
7223
|
const endpoint = validatedIngestEndpoint(profile.hq.endpoint);
|
|
7281
7224
|
if (!endpoint) return "skipped";
|
|
7282
7225
|
const env = dependencies.env ?? process.env;
|
|
7283
|
-
|
|
7226
|
+
const allowedOrigins = await loadHqAllowedOrigins(env, setupDeadline);
|
|
7227
|
+
if (!isHqOriginAuthorized(allowedOrigins, endpoint)) return "skipped";
|
|
7284
7228
|
const layout = repositorySpoolLayout({
|
|
7285
7229
|
owner: profile.repository.owner,
|
|
7286
7230
|
repo: profile.repository.name
|
|
@@ -7310,14 +7254,14 @@ async function drainHqSpoolOnExit(input, dependencies = {}) {
|
|
|
7310
7254
|
} catch {}
|
|
7311
7255
|
}
|
|
7312
7256
|
/** Wall-clock ceiling for one explicit drain. Flush is not a gate; it may wait. */
|
|
7313
|
-
const DEFAULT_HQ_FLUSH_BUDGET_MS =
|
|
7257
|
+
const DEFAULT_HQ_FLUSH_BUDGET_MS = 6e5;
|
|
7314
7258
|
/** ENOENT is the only filesystem answer that means "this location is absent". */
|
|
7315
7259
|
const isMissingEntryError = (error) => typeof error === "object" && error !== null && error.code === "ENOENT";
|
|
7316
7260
|
const countRemainingSpoolWork = async (spools, deadline, options = {}) => {
|
|
7317
7261
|
let remaining = 0;
|
|
7318
7262
|
const reasons = /* @__PURE__ */ new Map();
|
|
7319
7263
|
const noteReason = async (file, listed) => {
|
|
7320
|
-
const read = await readBoundedTextFileNoFollow(file, deadline,
|
|
7264
|
+
const read = await readBoundedTextFileNoFollow(file, deadline, 278528);
|
|
7321
7265
|
if (read !== void 0 && (read.identity.dev !== listed.dev || read.identity.ino !== listed.ino)) return;
|
|
7322
7266
|
let entry;
|
|
7323
7267
|
try {
|
|
@@ -7592,17 +7536,19 @@ async function flushHqSpool(input, dependencies = {}) {
|
|
|
7592
7536
|
*/
|
|
7593
7537
|
function enqueueHqIngest(input, dependencies = {}) {
|
|
7594
7538
|
try {
|
|
7595
|
-
|
|
7539
|
+
const gateStartedAt = performance.now();
|
|
7540
|
+
return trackPendingHqIngest(dispatchBounded(dependencies, gateStartedAt, (setupDeadline, timeoutMs, transportBudgetMs, lateStart) => deliverHqIngest(input, dependencies, setupDeadline, timeoutMs, transportBudgetMs, lateStart)));
|
|
7596
7541
|
} catch {
|
|
7597
7542
|
return Promise.resolve("skipped");
|
|
7598
7543
|
}
|
|
7599
7544
|
}
|
|
7600
7545
|
function enqueueProjectHqIngest(input, dependencies = {}) {
|
|
7601
7546
|
try {
|
|
7602
|
-
|
|
7547
|
+
const gateStartedAt = performance.now();
|
|
7548
|
+
return trackPendingHqIngest(dispatchBounded(dependencies, gateStartedAt, async (setupDeadline, timeoutMs, transportBudgetMs, lateStart) => {
|
|
7603
7549
|
const projectInput = await projectInputForHqIngest(input, setupDeadline);
|
|
7604
7550
|
if (projectInput === void 0) return "skipped";
|
|
7605
|
-
return deliverHqIngest(projectInput, dependencies, setupDeadline, timeoutMs, transportBudgetMs);
|
|
7551
|
+
return deliverHqIngest(projectInput, dependencies, setupDeadline, timeoutMs, transportBudgetMs, lateStart);
|
|
7606
7552
|
}));
|
|
7607
7553
|
} catch {
|
|
7608
7554
|
return Promise.resolve("skipped");
|
|
@@ -7925,7 +7871,8 @@ const deferProjectHqIngestIsolated = async (input, env) => {
|
|
|
7925
7871
|
if (!isIsolatedReadResult(sourcesRead)) return "held";
|
|
7926
7872
|
const configOrigins = isolatedConfigOrigins(sourcesRead.results.config);
|
|
7927
7873
|
if (configOrigins === void 0) return "skipped";
|
|
7928
|
-
|
|
7874
|
+
const allowedOrigins = resolveHqAllowedOrigins(env, configOrigins);
|
|
7875
|
+
if (!isHqOriginAuthorized(allowedOrigins, endpoint)) return "skipped";
|
|
7929
7876
|
const payloadSource = input.payloadJson ?? (sourcesRead.results.payload?.status === "ok" ? sourcesRead.results.payload.source : void 0);
|
|
7930
7877
|
if (payloadSource === void 0) return "held";
|
|
7931
7878
|
const projectedPayload = parseBoundedPayloadText(payloadSource);
|
|
@@ -7987,8 +7934,7 @@ async function deferProjectHqIngest(input, dependencies = {}) {
|
|
|
7987
7934
|
}
|
|
7988
7935
|
return deferProjectHqIngestIsolated(input, env);
|
|
7989
7936
|
}
|
|
7990
|
-
|
|
7991
|
-
//#region src/evidence-freshness.ts
|
|
7937
|
+
// src/evidence-freshness.ts
|
|
7992
7938
|
const patchIdMatches = (recorded, candidate) => Boolean(recorded.patchId) && recorded.patchId === candidate.patchId;
|
|
7993
7939
|
const headShaMatches = (recorded, candidate) => Boolean(recorded.headSha && candidate.headSha && sameHeadSha(candidate.headSha, recorded.headSha));
|
|
7994
7940
|
/**
|
|
@@ -8002,8 +7948,7 @@ function evidenceFresh({ candidate, recorded, rule }) {
|
|
|
8002
7948
|
if (patchIdMatches(recorded, candidate)) return true;
|
|
8003
7949
|
return rule === "patch-id-or-head-sha" && headShaMatches(recorded, candidate);
|
|
8004
7950
|
}
|
|
8005
|
-
|
|
8006
|
-
//#region src/pr-readiness/external-evidence.ts
|
|
7951
|
+
// src/pr-readiness/external-evidence.ts
|
|
8007
7952
|
var external_evidence_exports = /* @__PURE__ */ __exportAll({
|
|
8008
7953
|
EVIDENCE_CHECK_TYPES: () => EVIDENCE_CHECK_TYPES,
|
|
8009
7954
|
EVIDENCE_DIR: () => EVIDENCE_DIR,
|
|
@@ -8338,8 +8283,7 @@ function independenceRefusalReason(name, independence) {
|
|
|
8338
8283
|
default: return `Required review check "${name}" independence could not be confirmed; fail closed (ADR 0014).`;
|
|
8339
8284
|
}
|
|
8340
8285
|
}
|
|
8341
|
-
|
|
8342
|
-
//#region src/evidence-emit.ts
|
|
8286
|
+
// src/evidence-emit.ts
|
|
8343
8287
|
const defaultGit = () => ({
|
|
8344
8288
|
currentHeadSha,
|
|
8345
8289
|
mergeBaseSha,
|
|
@@ -8368,7 +8312,7 @@ function buildEvidenceEnvelope(args, dependencies = {}) {
|
|
|
8368
8312
|
git
|
|
8369
8313
|
});
|
|
8370
8314
|
const sessionId = resolveEmitSessionId(args.sessionId, env);
|
|
8371
|
-
const
|
|
8315
|
+
const candidate = {
|
|
8372
8316
|
check: args.check,
|
|
8373
8317
|
checkType: "verify",
|
|
8374
8318
|
headSha,
|
|
@@ -8382,7 +8326,8 @@ function buildEvidenceEnvelope(args, dependencies = {}) {
|
|
|
8382
8326
|
...args.policyVersion ? { policyVersion: args.policyVersion } : {},
|
|
8383
8327
|
...sessionId ? { sessionId } : {},
|
|
8384
8328
|
...args.requestId ? { requestId: args.requestId } : {}
|
|
8385
|
-
}
|
|
8329
|
+
};
|
|
8330
|
+
const parsed = parseEvidenceEnvelope(candidate);
|
|
8386
8331
|
if (!parsed.ok) throw new Error(`Refusing to emit an invalid evidence envelope: ${parsed.error}`);
|
|
8387
8332
|
return parsed.envelope;
|
|
8388
8333
|
}
|
|
@@ -8406,8 +8351,7 @@ function runEvidenceEmit(args, dependencies = {}) {
|
|
|
8406
8351
|
path: target
|
|
8407
8352
|
};
|
|
8408
8353
|
}
|
|
8409
|
-
|
|
8410
|
-
//#region src/gate-timing-finalize.ts
|
|
8354
|
+
// src/gate-timing-finalize.ts
|
|
8411
8355
|
/**
|
|
8412
8356
|
* A gate's hook to write its own timing record before its final proof event
|
|
8413
8357
|
* (#1316).
|
|
@@ -8446,8 +8390,7 @@ const finalizeGateTiming = (gate, { passed }) => {
|
|
|
8446
8390
|
if (scope?.gate === gate) scope.finalize(passed ? "pass" : "fail");
|
|
8447
8391
|
} catch {}
|
|
8448
8392
|
};
|
|
8449
|
-
|
|
8450
|
-
//#region src/advisory-line.ts
|
|
8393
|
+
// src/advisory-line.ts
|
|
8451
8394
|
const absorbStreamError = () => {};
|
|
8452
8395
|
/**
|
|
8453
8396
|
* One best-effort line, on stderr unless another stream is named. A closed
|
|
@@ -8468,8 +8411,7 @@ const writeAdvisoryLine = (line, stream = process.stderr) => {
|
|
|
8468
8411
|
if (error === null || error === void 0) stream.removeListener("error", absorbStreamError);
|
|
8469
8412
|
});
|
|
8470
8413
|
};
|
|
8471
|
-
|
|
8472
|
-
//#region src/check-run-generations.ts
|
|
8414
|
+
// src/check-run-generations.ts
|
|
8473
8415
|
/**
|
|
8474
8416
|
* Select the newest generation, or say why there is no single authority.
|
|
8475
8417
|
*
|
|
@@ -8501,8 +8443,7 @@ function generationOrderMs(value) {
|
|
|
8501
8443
|
const parsed = value ? Date.parse(value) : NaN;
|
|
8502
8444
|
return Number.isFinite(parsed) ? parsed : Number.NEGATIVE_INFINITY;
|
|
8503
8445
|
}
|
|
8504
|
-
|
|
8505
|
-
//#region src/check-run-relay.ts
|
|
8446
|
+
// src/check-run-relay.ts
|
|
8506
8447
|
/**
|
|
8507
8448
|
* The CLI side of HQ's Factory check-run relay (#1535, #1567).
|
|
8508
8449
|
*
|
|
@@ -8599,8 +8540,7 @@ async function postCheckRunThroughRelay(relay, body, request, timeoutMs) {
|
|
|
8599
8540
|
if (!response.ok) throw new GitHubApiError(response.status, response.statusText);
|
|
8600
8541
|
return await response.json();
|
|
8601
8542
|
}
|
|
8602
|
-
|
|
8603
|
-
//#region src/github-app-client.ts
|
|
8543
|
+
// src/github-app-client.ts
|
|
8604
8544
|
const readExchange = async (request, url, init, timeoutMs) => {
|
|
8605
8545
|
const response = await request(url, {
|
|
8606
8546
|
...init,
|
|
@@ -8667,16 +8607,14 @@ async function requestFactoryApp(input, dependencies = {}) {
|
|
|
8667
8607
|
const token = await resolveFactoryAppToken(input, dependencies, request, timeoutMs);
|
|
8668
8608
|
return readExchange(request, `https://api.github.com/repos/${input.owner}/${input.repo}/${input.path}`, factoryAppInit(input, token), timeoutMs);
|
|
8669
8609
|
}
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
const RESOLVED_PR_VERIFY_MODES = new Set([
|
|
8610
|
+
// src/pr-verify-mode.ts
|
|
8611
|
+
const RESOLVED_PR_VERIFY_MODES = /* @__PURE__ */ new Set([
|
|
8673
8612
|
"docs-only",
|
|
8674
8613
|
"trivial",
|
|
8675
8614
|
"full"
|
|
8676
8615
|
]);
|
|
8677
8616
|
const isResolvedPrVerifyMode = (value) => RESOLVED_PR_VERIFY_MODES.has(value);
|
|
8678
|
-
|
|
8679
|
-
//#region src/catch-up-recognition-record.ts
|
|
8617
|
+
// src/catch-up-recognition-record.ts
|
|
8680
8618
|
const objectShaSchema = z.string().regex(/^[0-9a-f]{40}$/u);
|
|
8681
8619
|
const catchUpRecognitionSchema = z.object({
|
|
8682
8620
|
baseRef: z.string().min(1),
|
|
@@ -8685,8 +8623,7 @@ const catchUpRecognitionSchema = z.object({
|
|
|
8685
8623
|
mergedTreeSha: objectShaSchema,
|
|
8686
8624
|
upstreamRef: z.string().min(1)
|
|
8687
8625
|
}).strict();
|
|
8688
|
-
|
|
8689
|
-
//#region src/policy-resolution.ts
|
|
8626
|
+
// src/policy-resolution.ts
|
|
8690
8627
|
const COMMIT_SHA_PATTERN$3 = /^[0-9a-f]{40}$/u;
|
|
8691
8628
|
const digestSchema = z.string().regex(/^[0-9a-f]{64}$/u);
|
|
8692
8629
|
/**
|
|
@@ -8744,8 +8681,7 @@ const unresolvedPolicyResolutionSchema = z.object({
|
|
|
8744
8681
|
const policyResolutionSchema = z.discriminatedUnion("status", [authoritativePolicyResolutionSchema, unresolvedPolicyResolutionSchema]);
|
|
8745
8682
|
/** Only the ordinary pre-PR unresolved policy permits proof reuse (#1459). */
|
|
8746
8683
|
const policyResolutionAllowsProofReuse = (resolution) => resolution?.status !== "unresolved" || resolution.cause === "no-pull-request";
|
|
8747
|
-
|
|
8748
|
-
//#region src/verification-battery.ts
|
|
8684
|
+
// src/verification-battery.ts
|
|
8749
8685
|
const UNCONDITIONAL_BASIS = "unconditional: the profile declares no impactTarget for this command";
|
|
8750
8686
|
/**
|
|
8751
8687
|
* The `vetoedTargets` contract, enforced at RUNTIME as well as at the type
|
|
@@ -8878,7 +8814,7 @@ const assertBatteryCompleteness = (proof, context) => {
|
|
|
8878
8814
|
seen.add(entry.name);
|
|
8879
8815
|
}
|
|
8880
8816
|
if (proof.outcome !== "passed") return;
|
|
8881
|
-
const disposed = new Set([...executed, ...seen]);
|
|
8817
|
+
const disposed = /* @__PURE__ */ new Set([...executed, ...seen]);
|
|
8882
8818
|
const undisposed = selected.filter((name) => !disposed.has(name));
|
|
8883
8819
|
if (undisposed.length > 0) context.addIssue({
|
|
8884
8820
|
code: "custom",
|
|
@@ -8976,8 +8912,7 @@ const batteryScopeSummaryLines = (plan) => {
|
|
|
8976
8912
|
if (plan.notRequired.length === 0) return [];
|
|
8977
8913
|
return ["Verification battery scoped by the impact stamp (not-required):", ...plan.notRequired.map((entry) => `- ${entry.name} (${entry.impactTarget}): ${entry.basis}`)];
|
|
8978
8914
|
};
|
|
8979
|
-
|
|
8980
|
-
//#region src/pr-verify-proof-rules.ts
|
|
8915
|
+
// src/pr-verify-proof-rules.ts
|
|
8981
8916
|
const assertPrVerifyProofRules = (proof, context) => {
|
|
8982
8917
|
if (proof.notDemandedRecords !== void 0 && proof.impactStamp === void 0) context.addIssue({
|
|
8983
8918
|
code: "custom",
|
|
@@ -8996,6 +8931,12 @@ const assertPrVerifyProofRules = (proof, context) => {
|
|
|
8996
8931
|
* factory must adopt this release before HQ ingests its pr:verify proofs.
|
|
8997
8932
|
*/
|
|
8998
8933
|
const SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS = [4];
|
|
8934
|
+
/** Where a verification battery ran (#1570). */
|
|
8935
|
+
const PR_VERIFY_RUNNER_KINDS = [
|
|
8936
|
+
"ci",
|
|
8937
|
+
"cloud",
|
|
8938
|
+
"local"
|
|
8939
|
+
];
|
|
8999
8940
|
const prVerifyTestFailureSchema = z.object({
|
|
9000
8941
|
file: z.string().min(1),
|
|
9001
8942
|
kind: z.enum([
|
|
@@ -9030,6 +8971,17 @@ const notDemandedRecordSchema = z.object({
|
|
|
9030
8971
|
basis: z.string().min(1),
|
|
9031
8972
|
name: z.string().min(1)
|
|
9032
8973
|
});
|
|
8974
|
+
const runnerSchema = z.object({
|
|
8975
|
+
arch: z.string().min(1).max(32),
|
|
8976
|
+
cpuCount: z.number().int().positive(),
|
|
8977
|
+
kind: z.enum(PR_VERIFY_RUNNER_KINDS),
|
|
8978
|
+
os: z.string().min(1).max(32),
|
|
8979
|
+
provider: z.enum([
|
|
8980
|
+
"claude-code",
|
|
8981
|
+
"cursor",
|
|
8982
|
+
"github-actions"
|
|
8983
|
+
]).optional()
|
|
8984
|
+
});
|
|
9033
8985
|
const prVerifySchemaVersionSchema = z.literal(4);
|
|
9034
8986
|
const prVerifyProofSchema = z.object({
|
|
9035
8987
|
authoringSession: z.string().trim().min(1),
|
|
@@ -9071,6 +9023,7 @@ const prVerifyProofSchema = z.object({
|
|
|
9071
9023
|
profilePath: z.string().min(1),
|
|
9072
9024
|
projectKey: z.string().min(1),
|
|
9073
9025
|
repository: z.string().min(1),
|
|
9026
|
+
runner: runnerSchema.optional(),
|
|
9074
9027
|
schemaVersion: prVerifySchemaVersionSchema,
|
|
9075
9028
|
startedAt: z.iso.datetime(),
|
|
9076
9029
|
verificationCommands: z.array(z.object({
|
|
@@ -9088,8 +9041,7 @@ const prVerifyProofSchema = z.object({
|
|
|
9088
9041
|
function validatePrVerifyProof(value) {
|
|
9089
9042
|
return prVerifyProofSchema.parse(value);
|
|
9090
9043
|
}
|
|
9091
|
-
|
|
9092
|
-
//#region src/pr-verify-check-payload.ts
|
|
9044
|
+
// src/pr-verify-check-payload.ts
|
|
9093
9045
|
/**
|
|
9094
9046
|
* Machine-readable binding carried on the `patronage-factory/pr-verify` check
|
|
9095
9047
|
* run (#247), alongside the human-readable prose summary.
|
|
@@ -9179,8 +9131,7 @@ const parsePrVerifyCheckPayload = (text) => {
|
|
|
9179
9131
|
} catch {}
|
|
9180
9132
|
};
|
|
9181
9133
|
const renderPrVerifyCheckPayloadText = (payload) => `\`\`\`json\n${JSON.stringify(payload, null, 2)}\n\`\`\``;
|
|
9182
|
-
|
|
9183
|
-
//#region src/github-check-runs.ts
|
|
9134
|
+
// src/github-check-runs.ts
|
|
9184
9135
|
const FACTORY_CHECK_NAMES = {
|
|
9185
9136
|
"pr-ready": "patronage-factory/pr-ready",
|
|
9186
9137
|
"pr-review": "patronage-factory/pr-review",
|
|
@@ -9785,25 +9736,13 @@ async function ensureFactoryCheckRunPublished(input, dependencies = {}) {
|
|
|
9785
9736
|
return false;
|
|
9786
9737
|
}
|
|
9787
9738
|
}
|
|
9788
|
-
/**
|
|
9789
|
-
* The detached publication's budget, stated once (#1322, #1394). Each stage
|
|
9790
|
-
* enforces its own share in per-call timeouts (`timeoutMs`, 5 s by default):
|
|
9791
|
-
* the Details lookup (`gh pr view`) one call; the App credential two (a PEM
|
|
9792
|
-
* mint's installation lookup and token POST, one attempt each, or a Cursor
|
|
9793
|
-
* VM's OIDC mint and broker exchange); the check-run POST one per attempt,
|
|
9794
|
-
* with its retry delays between. A publication that finishes inside its stage
|
|
9795
|
-
* budgets therefore finishes inside their sum, plus a margin for the work
|
|
9796
|
-
* between stages. By default that is 4 × 5 s + 1 s = 21 s.
|
|
9797
|
-
*/
|
|
9798
|
-
const DETAILS_URL_CALLS = 1;
|
|
9799
|
-
const CREDENTIAL_CALLS = 2;
|
|
9800
9739
|
const STAGE_HANDOFF_MARGIN_MS = 1e3;
|
|
9801
9740
|
const publicationBudgetMs = (dependencies) => {
|
|
9802
9741
|
const timeoutMs = dependencies.timeoutMs ?? 5e3;
|
|
9803
9742
|
const { attempts, delayMs } = dependencies.retry ?? DEFAULT_CHECK_RUN_RETRY;
|
|
9804
9743
|
const posts = Math.max(1, attempts);
|
|
9805
9744
|
const postTimeoutMs = checkRunRelayOptedIn(dependencies.env ?? process.env) ? Math.max(timeoutMs, CHECK_RUN_RELAY_TIMEOUT_MS) : timeoutMs;
|
|
9806
|
-
return
|
|
9745
|
+
return 3 * timeoutMs + posts * postTimeoutMs + (posts - 1) * delayMs + STAGE_HANDOFF_MARGIN_MS;
|
|
9807
9746
|
};
|
|
9808
9747
|
/** `request` with `signal` joined to each call's own signal, never in its place. */
|
|
9809
9748
|
const fetchCancelledBy = (request, signal) => async (resource, init) => request(resource, {
|
|
@@ -10307,8 +10246,7 @@ function readExactHeadFactoryRunFrom(source, input) {
|
|
|
10307
10246
|
}
|
|
10308
10247
|
/** One line naming a run: its id or link, its status and its conclusion. */
|
|
10309
10248
|
const describeExactHeadFactoryRun = (gate, run) => `${FACTORY_CHECK_NAMES[gate]} run ${run.url ?? (run.id === void 0 ? "with no id" : String(run.id))} (${run.status === "completed" ? `completed, ${run.conclusion || "no conclusion"}` : run.status || "no status"})`;
|
|
10310
|
-
|
|
10311
|
-
//#region src/repository-profile-path.ts
|
|
10249
|
+
// src/repository-profile-path.ts
|
|
10312
10250
|
/**
|
|
10313
10251
|
* `git rev-parse --show-toplevel` answers with a real path, while a caller's
|
|
10314
10252
|
* `cwd` may reach the same directory through a symlink (every macOS temporary
|
|
@@ -10378,8 +10316,7 @@ const repositoryContainedProfilePath = ({ cwd, profilePath, readRepositoryRoot =
|
|
|
10378
10316
|
if (escapesRoot(relativePath)) throw new Error("The readiness profile must be inside the trusted checkout.");
|
|
10379
10317
|
return relativePath;
|
|
10380
10318
|
};
|
|
10381
|
-
|
|
10382
|
-
//#region src/pr-classification.ts
|
|
10319
|
+
// src/pr-classification.ts
|
|
10383
10320
|
const MISSING_STAMP_REASON = "impact stamp is missing; fail closed to non-trivial";
|
|
10384
10321
|
function ownershipFromStamp(stamp, file) {
|
|
10385
10322
|
if (stamp.inertPaths.includes(file)) return { kind: "inert" };
|
|
@@ -10487,8 +10424,7 @@ function classifyDiffForRun(profile, files, options) {
|
|
|
10487
10424
|
});
|
|
10488
10425
|
return applyProfileEditGuard(files, relativeProfile, options.profilePath, classifyDiff(files, stamp));
|
|
10489
10426
|
}
|
|
10490
|
-
|
|
10491
|
-
//#region src/pr-readiness/verification-proof.ts
|
|
10427
|
+
// src/pr-readiness/verification-proof.ts
|
|
10492
10428
|
var verification_proof_exports = /* @__PURE__ */ __exportAll({
|
|
10493
10429
|
SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS: () => SUPPORTED_PR_VERIFY_SCHEMA_VERSIONS,
|
|
10494
10430
|
prVerifyFullHeadShasForDiff: () => prVerifyFullHeadShasForDiff,
|
|
@@ -10738,8 +10674,56 @@ const verificationProofBlockingReason = (state) => {
|
|
|
10738
10674
|
return "Typed pr:verify proof shows verification aborted; verification did not pass. Re-run patronage-factory pr:verify.";
|
|
10739
10675
|
}
|
|
10740
10676
|
};
|
|
10741
|
-
|
|
10742
|
-
|
|
10677
|
+
// src/verify-runner.ts
|
|
10678
|
+
const currentHost = () => ({
|
|
10679
|
+
arch: process.arch,
|
|
10680
|
+
cpuCount: availableParallelism(),
|
|
10681
|
+
os: process.platform
|
|
10682
|
+
});
|
|
10683
|
+
const present = (value) => value !== void 0 && value.length > 0;
|
|
10684
|
+
/**
|
|
10685
|
+
* Classifies the machine a pr:verify battery runs on (#1570). It reads only
|
|
10686
|
+
* documented environment markers, never a hostname or path:
|
|
10687
|
+
*
|
|
10688
|
+
* - `GITHUB_ACTIONS` or `CI` marks a hosted CI runner (the same test as
|
|
10689
|
+
* `isHostedRunner`).
|
|
10690
|
+
* - `CLAUDE_CODE_REMOTE=true` marks a Claude Code cloud session.
|
|
10691
|
+
* - `CURSOR_AGENT_SOCKET` marks a Cursor-managed VM (the same marker
|
|
10692
|
+
* `doctor` reads).
|
|
10693
|
+
*
|
|
10694
|
+
* Everything else is `local`. CI wins over a cloud marker, because an agent
|
|
10695
|
+
* that dispatches to CI runs the battery on the CI machine.
|
|
10696
|
+
*/
|
|
10697
|
+
const describeVerifyRunner = (env, host = currentHost()) => {
|
|
10698
|
+
const base = {
|
|
10699
|
+
arch: host.arch,
|
|
10700
|
+
cpuCount: Math.max(1, Math.trunc(host.cpuCount)),
|
|
10701
|
+
os: host.os
|
|
10702
|
+
};
|
|
10703
|
+
if (isHostedRunner(env)) return env.GITHUB_ACTIONS === "true" ? {
|
|
10704
|
+
...base,
|
|
10705
|
+
kind: "ci",
|
|
10706
|
+
provider: "github-actions"
|
|
10707
|
+
} : {
|
|
10708
|
+
...base,
|
|
10709
|
+
kind: "ci"
|
|
10710
|
+
};
|
|
10711
|
+
if (env.CLAUDE_CODE_REMOTE === "true") return {
|
|
10712
|
+
...base,
|
|
10713
|
+
kind: "cloud",
|
|
10714
|
+
provider: "claude-code"
|
|
10715
|
+
};
|
|
10716
|
+
if (present(env.CURSOR_AGENT_SOCKET)) return {
|
|
10717
|
+
...base,
|
|
10718
|
+
kind: "cloud",
|
|
10719
|
+
provider: "cursor"
|
|
10720
|
+
};
|
|
10721
|
+
return {
|
|
10722
|
+
...base,
|
|
10723
|
+
kind: "local"
|
|
10724
|
+
};
|
|
10725
|
+
};
|
|
10726
|
+
// src/workspace-install-resolution.ts
|
|
10743
10727
|
const readJson = (filePath, read) => {
|
|
10744
10728
|
if (!existsSync(filePath)) return null;
|
|
10745
10729
|
try {
|
|
@@ -10765,7 +10749,10 @@ const packageDirForName = (repoRoot, name, read) => {
|
|
|
10765
10749
|
"software-factory",
|
|
10766
10750
|
"software-factory-hq",
|
|
10767
10751
|
"software-factory-docs"
|
|
10768
|
-
])
|
|
10752
|
+
]) {
|
|
10753
|
+
const pkgPath = path.join(repoRoot, dir, "package.json");
|
|
10754
|
+
if (readJson(pkgPath, read)?.name === name) return path.join(repoRoot, dir);
|
|
10755
|
+
}
|
|
10769
10756
|
return null;
|
|
10770
10757
|
};
|
|
10771
10758
|
/** Workspace packages HQ depends on whose Node default export is under dist/. */
|
|
@@ -10860,8 +10847,7 @@ const assertCleanInstallResolution = (repoRoot, dependencies = {}) => {
|
|
|
10860
10847
|
skipped: false
|
|
10861
10848
|
};
|
|
10862
10849
|
};
|
|
10863
|
-
|
|
10864
|
-
//#region src/pr-verify.ts
|
|
10850
|
+
// src/pr-verify.ts
|
|
10865
10851
|
const DEFAULT_PR_VERIFY_PROOF_PATH = ".factory-memory/pr-verify.json";
|
|
10866
10852
|
const PR_VERIFY_PROOF_DESCRIPTOR$1 = {
|
|
10867
10853
|
defaultPath: DEFAULT_PR_VERIFY_PROOF_PATH,
|
|
@@ -10947,7 +10933,7 @@ const classifyVitestFailure = (errorLine) => {
|
|
|
10947
10933
|
* run that crashes while writing why it failed.
|
|
10948
10934
|
*/
|
|
10949
10935
|
function parseVitestFailures(stdout) {
|
|
10950
|
-
const lines = stdout.
|
|
10936
|
+
const lines = stdout.replaceAll(ANSI_ESCAPE_PATTERN, "").split(/\r?\n/u);
|
|
10951
10937
|
const failures = [];
|
|
10952
10938
|
const seen = /* @__PURE__ */ new Set();
|
|
10953
10939
|
for (const [index, line] of lines.entries()) {
|
|
@@ -11031,7 +11017,7 @@ function baselineFullProofsForDocsOnly({ previousProof, profilePath, projectKey,
|
|
|
11031
11017
|
seedFilter: matchesProfile
|
|
11032
11018
|
});
|
|
11033
11019
|
}
|
|
11034
|
-
function buildPrVerifyProof({ authoringSession, base, baseSha, baselineFullProofs, catchUpRecognition, classification, commands, endedAt, executedCommands, files, headSha, impactStamp, mode, mergeBaseSha: proofMergeBaseSha, notRequiredCommands, outcome, patchId, policyResolution, profilePath, projectKey, repository, startedAt }) {
|
|
11020
|
+
function buildPrVerifyProof({ authoringSession, base, baseSha, baselineFullProofs, catchUpRecognition, classification, commands, endedAt, executedCommands, files, headSha, impactStamp, mode, mergeBaseSha: proofMergeBaseSha, notRequiredCommands, outcome, patchId, policyResolution, profilePath, projectKey, repository, runner, startedAt }) {
|
|
11035
11021
|
return {
|
|
11036
11022
|
authoringSession,
|
|
11037
11023
|
base,
|
|
@@ -11056,6 +11042,7 @@ function buildPrVerifyProof({ authoringSession, base, baseSha, baselineFullProof
|
|
|
11056
11042
|
profilePath,
|
|
11057
11043
|
projectKey,
|
|
11058
11044
|
repository,
|
|
11045
|
+
...runner ? { runner } : {},
|
|
11059
11046
|
schemaVersion: 4,
|
|
11060
11047
|
startedAt: startedAt.toISOString(),
|
|
11061
11048
|
verificationCommands: commands
|
|
@@ -11292,6 +11279,7 @@ function runPrVerify(args, dependencies = {}) {
|
|
|
11292
11279
|
profilePath,
|
|
11293
11280
|
projectKey: profile.repository.name,
|
|
11294
11281
|
repository,
|
|
11282
|
+
runner: (dependencies.describeRunner ?? describeVerifyRunner)(dependencies.env ?? process.env),
|
|
11295
11283
|
startedAt
|
|
11296
11284
|
};
|
|
11297
11285
|
const writePartialProof = (outcome) => {
|
|
@@ -11451,8 +11439,7 @@ const runPrVerifyWithAdmission = async (args, dependencies = {}) => {
|
|
|
11451
11439
|
lookupPullRequestBase: () => lookup
|
|
11452
11440
|
});
|
|
11453
11441
|
};
|
|
11454
|
-
|
|
11455
|
-
//#region src/demand-waive.ts
|
|
11442
|
+
// src/demand-waive.ts
|
|
11456
11443
|
const DEMAND_WAIVER_SCHEMA_VERSION = 1;
|
|
11457
11444
|
const shaSchema$3 = z.string().regex(/^[0-9a-f]{40}$/u);
|
|
11458
11445
|
const demandWaiverStorePath = (cwd, filePath) => path.resolve(cwd, filePath ?? ".factory-memory/demand-waivers.json");
|
|
@@ -11574,11 +11561,13 @@ const runDemandWaive = (args, dependencies = {}) => {
|
|
|
11574
11561
|
...authorization.authorization.session ? { session: authorization.authorization.session } : {}
|
|
11575
11562
|
};
|
|
11576
11563
|
const storePath = demandWaiverStorePath(cwd, args.output);
|
|
11577
|
-
|
|
11564
|
+
const existing = readDemandWaivers(cwd, args.output).filter((candidate) => !(candidate.demand === waiver.demand && candidate.candidate.pr === waiver.candidate.pr && candidate.candidate.headSha === waiver.candidate.headSha));
|
|
11565
|
+
const store = {
|
|
11578
11566
|
command: "patronage-factory demand:waive",
|
|
11579
11567
|
schemaVersion: DEMAND_WAIVER_SCHEMA_VERSION,
|
|
11580
|
-
waivers: [...
|
|
11581
|
-
}
|
|
11568
|
+
waivers: [...existing, waiver]
|
|
11569
|
+
};
|
|
11570
|
+
writeProofJson(validateDemandWaiverStore(store), storePath);
|
|
11582
11571
|
console.log(`demand:waive recorded a waiver of "${waiver.demand}" for PR #${waiver.candidate.pr} at ${waiver.candidate.headSha} by ${waiver.operator}. The demand is waived, not met.`);
|
|
11583
11572
|
console.log(`demand:waive record written to ${storePath}`);
|
|
11584
11573
|
if (args.json) console.log(JSON.stringify(waiver, null, 2));
|
|
@@ -11622,8 +11611,7 @@ const blockedReasonIssues = (proof) => {
|
|
|
11622
11611
|
const drifted = named.findIndex((reason, index) => reason.detail !== blockedReasonDetail(reasons[index]));
|
|
11623
11612
|
return drifted === -1 ? [] : blockedReasonIssue(`blockedReasons[${drifted}] does not carry blocking reason ${drifted}; the two projections must tell one story`);
|
|
11624
11613
|
};
|
|
11625
|
-
|
|
11626
|
-
//#region src/packages/review-prompt-sections/schema.ts
|
|
11614
|
+
// src/packages/review-prompt-sections/schema.ts
|
|
11627
11615
|
const REVIEW_PROMPT_SECTION_PROVENANCES = [
|
|
11628
11616
|
"coding-standards",
|
|
11629
11617
|
"prior-review-ledger",
|
|
@@ -11805,8 +11793,7 @@ const renderReviewFindingsFileExample = (waveRung) => JSON.stringify(exampleForS
|
|
|
11805
11793
|
"resolutions",
|
|
11806
11794
|
"rung"
|
|
11807
11795
|
] : [])), null, 2);
|
|
11808
|
-
|
|
11809
|
-
//#region src/review-ladder.ts
|
|
11796
|
+
// src/review-ladder.ts
|
|
11810
11797
|
const LADDER_NEXT_ACTION_KINDS = [
|
|
11811
11798
|
"run-interior-cycle",
|
|
11812
11799
|
"advance-to-gate",
|
|
@@ -11935,8 +11922,7 @@ const evaluateReviewLadder = ({ cycles, policy }) => {
|
|
|
11935
11922
|
occurrences
|
|
11936
11923
|
};
|
|
11937
11924
|
};
|
|
11938
|
-
|
|
11939
|
-
//#region src/pr-readiness/ladder-proof-state.ts
|
|
11925
|
+
// src/pr-readiness/ladder-proof-state.ts
|
|
11940
11926
|
const persistedCycleSchema = z.custom((cycle) => typeof cycle === "object" && cycle !== null, "ladder cycle must be an object").superRefine((cycle, context) => {
|
|
11941
11927
|
const parsed = reviewCycleRecordingSchema.safeParse(cycle.recording);
|
|
11942
11928
|
if (!parsed.success) context.addIssue({
|
|
@@ -12002,8 +11988,7 @@ const reviewAcceptedThroughSnapshot = (snapshot) => {
|
|
|
12002
11988
|
if (snapshot.evaluation.nextAction.kind === "accept-nonblocking-findings") return snapshot.cycleState.autoBlockingFindings === 0;
|
|
12003
11989
|
return false;
|
|
12004
11990
|
};
|
|
12005
|
-
|
|
12006
|
-
//#region src/pr-readiness/review-epoch.ts
|
|
11991
|
+
// src/pr-readiness/review-epoch.ts
|
|
12007
11992
|
const openStateFromReviews = (reviews) => {
|
|
12008
11993
|
const openEntries = reviews.flatMap((review) => review.findings);
|
|
12009
11994
|
const blockingEntries = openEntries.filter((finding) => resolveFindingBlocking(finding, "open"));
|
|
@@ -12104,8 +12089,7 @@ const reviewProofForEpoch = (proof, kind, epoch, current) => {
|
|
|
12104
12089
|
return {};
|
|
12105
12090
|
};
|
|
12106
12091
|
const reviewProofFor = (proof, kind, policy, current) => reviewProofForEpoch(proof, kind, reviewEpochModeFor(proof ?? {}, policy), current);
|
|
12107
|
-
|
|
12108
|
-
//#region src/pr-readiness/review-proof.ts
|
|
12092
|
+
// src/pr-readiness/review-proof.ts
|
|
12109
12093
|
var review_proof_exports = /* @__PURE__ */ __exportAll({
|
|
12110
12094
|
DEFAULT_PR_REVIEW_MAX_CYCLES: () => 5,
|
|
12111
12095
|
DEFAULT_PR_REVIEW_PROOF_PATH: () => DEFAULT_PR_REVIEW_PROOF_PATH,
|
|
@@ -12269,8 +12253,7 @@ const PR_REVIEW_PROOF_DESCRIPTOR = {
|
|
|
12269
12253
|
parse: validatePrReviewProof,
|
|
12270
12254
|
schemaVersion: 3
|
|
12271
12255
|
};
|
|
12272
|
-
|
|
12273
|
-
//#region src/review-proof-applicability.ts
|
|
12256
|
+
// src/review-proof-applicability.ts
|
|
12274
12257
|
const REVIEW_STATUS_VALUES = [
|
|
12275
12258
|
"not-required",
|
|
12276
12259
|
"current",
|
|
@@ -12310,8 +12293,7 @@ const reviewStatus = ({ blocked, required, reviewedHeadSha, reviewedPatchId, hea
|
|
|
12310
12293
|
})) return "current";
|
|
12311
12294
|
return "stale";
|
|
12312
12295
|
};
|
|
12313
|
-
|
|
12314
|
-
//#region src/review-state.ts
|
|
12296
|
+
// src/review-state.ts
|
|
12315
12297
|
const reviewStateIssue = (message, field) => [{
|
|
12316
12298
|
code: "custom",
|
|
12317
12299
|
message,
|
|
@@ -12381,8 +12363,7 @@ const closeoutArtifactSchema = z.object({
|
|
|
12381
12363
|
repo: RepoSchema,
|
|
12382
12364
|
schemaVersion: z.literal(5)
|
|
12383
12365
|
}).strict();
|
|
12384
|
-
|
|
12385
|
-
//#region src/schemas.ts
|
|
12366
|
+
// src/schemas.ts
|
|
12386
12367
|
const evidenceCheckTypeSchema = z.enum(EVIDENCE_CHECK_TYPES);
|
|
12387
12368
|
const evidenceReviewRungSchema = z.enum(EVIDENCE_REVIEW_RUNGS);
|
|
12388
12369
|
const diffClassificationSchema = z.enum(DIFF_CLASSIFICATIONS);
|
|
@@ -12675,8 +12656,7 @@ z.object({
|
|
|
12675
12656
|
}).superRefine((proof, context) => {
|
|
12676
12657
|
for (const issue of blockedReasonIssues({ ...proof })) context.addIssue(issue);
|
|
12677
12658
|
});
|
|
12678
|
-
|
|
12679
|
-
//#region src/boundary-check.ts
|
|
12659
|
+
// src/boundary-check.ts
|
|
12680
12660
|
const DEFAULT_BOUNDARY_CHECK_PROOF_PATH = ".factory-memory/boundary-check.json";
|
|
12681
12661
|
const CLOSING_PRS_QUERY = `query($owner: String!, $repo: String!, $issue: Int!) {
|
|
12682
12662
|
repository(owner: $owner, name: $repo) {
|
|
@@ -12737,12 +12717,14 @@ const closingFetcherWithBodyKeywords = (manifest, repo, github) => {
|
|
|
12737
12717
|
const listInput = manifest.integrationBranch === void 0 ? {} : { integrationBranch: manifest.integrationBranch };
|
|
12738
12718
|
const candidates = github.listCandidatePullRequests(repo, listInput);
|
|
12739
12719
|
return (issue) => {
|
|
12740
|
-
|
|
12720
|
+
const graphql = github.fetchClosingPullRequests(repo, issue);
|
|
12721
|
+
const extra = candidates.flatMap((candidate) => {
|
|
12741
12722
|
return new Set(declaredChildrenNamedInBody(candidate.body, {
|
|
12742
12723
|
owner,
|
|
12743
12724
|
repo: name
|
|
12744
12725
|
}, declared)).has(issue) ? [withoutBody(candidate)] : [];
|
|
12745
|
-
})
|
|
12726
|
+
});
|
|
12727
|
+
return mergeClosingRefs(graphql, extra);
|
|
12746
12728
|
};
|
|
12747
12729
|
};
|
|
12748
12730
|
const closeGateForMemberships = ({ final, github, memberships, repo, waivers }) => {
|
|
@@ -12963,8 +12945,7 @@ async function runBoundaryCheckWithAdmission(args, dependencies = {}) {
|
|
|
12963
12945
|
function validateBoundaryCheckProof(value) {
|
|
12964
12946
|
return boundaryCheckProofSchema.parse(value);
|
|
12965
12947
|
}
|
|
12966
|
-
|
|
12967
|
-
//#region src/interior-telemetry/pricing-snapshot.ts
|
|
12948
|
+
// src/interior-telemetry/pricing-snapshot.ts
|
|
12968
12949
|
/** Human-readable provenance tag, embedded in data-gap messages so an unpriced
|
|
12969
12950
|
* block names the exact snapshot that lacked its model. */
|
|
12970
12951
|
const PRICING_SNAPSHOT_PROVENANCE = "litellm model_prices_and_context_window.json @ d966122 (fetched 2026-07-20)";
|
|
@@ -13044,8 +13025,7 @@ const LITELLM_PRICING_SNAPSHOT = {
|
|
|
13044
13025
|
* must degrade to a null cost plus a data gap, never approximate.
|
|
13045
13026
|
*/
|
|
13046
13027
|
const resolveModelPricing = (model) => LITELLM_PRICING_SNAPSHOT[model] ?? LITELLM_PRICING_SNAPSHOT[model.replace(/-20\d{6}$/u, "")];
|
|
13047
|
-
|
|
13048
|
-
//#region src/interior-telemetry/harvest-adapter.ts
|
|
13028
|
+
// src/interior-telemetry/harvest-adapter.ts
|
|
13049
13029
|
const nonNegInt = (value) => typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
13050
13030
|
const asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
13051
13031
|
/** First non-empty string among the candidates, or undefined. */
|
|
@@ -13161,7 +13141,8 @@ const addTotals = (target, delta) => {
|
|
|
13161
13141
|
};
|
|
13162
13142
|
/** The cumulative `total_token_usage` on an at-rest `token_count` event. */
|
|
13163
13143
|
const cumulativeFromTokenCount = (payload) => {
|
|
13164
|
-
const
|
|
13144
|
+
const info = asRecord(payload.info);
|
|
13145
|
+
const total = asRecord(info?.total_token_usage);
|
|
13165
13146
|
return total ? totalsFromUsage(total) : void 0;
|
|
13166
13147
|
};
|
|
13167
13148
|
/** Fold one rollout line into the accumulator (model + cumulative + per-turn). */
|
|
@@ -13481,8 +13462,7 @@ const harvestTokenFamilies = (input) => {
|
|
|
13481
13462
|
};
|
|
13482
13463
|
}
|
|
13483
13464
|
};
|
|
13484
|
-
|
|
13485
|
-
//#region src/interior-telemetry/gate-timing.ts
|
|
13465
|
+
// src/interior-telemetry/gate-timing.ts
|
|
13486
13466
|
const readGateTimingLedger = (ledgerPath) => {
|
|
13487
13467
|
let content;
|
|
13488
13468
|
try {
|
|
@@ -13562,8 +13542,7 @@ function withGateTiming(spec, action) {
|
|
|
13562
13542
|
}
|
|
13563
13543
|
};
|
|
13564
13544
|
}
|
|
13565
|
-
|
|
13566
|
-
//#region src/commands/boundary-check.ts
|
|
13545
|
+
// src/commands/boundary-check.ts
|
|
13567
13546
|
const renderReport = (record) => {
|
|
13568
13547
|
const lines = [`boundary:check ${record.status === "ready" ? "READY" : "BLOCKED"} — ${record.boundary ?? "(no manifest)"} (epic #${record.epicIssue}, ${record.repo})`];
|
|
13569
13548
|
if (record.manifestHash) lines.push(`manifest sha256 ${record.manifestHash.value}`);
|
|
@@ -13592,8 +13571,7 @@ function createBoundaryCheckCommand(output, action) {
|
|
|
13592
13571
|
if (record.status !== "ready") throw new Error(`boundary:check refused: ${record.blockingReasons.join("; ")}`);
|
|
13593
13572
|
})));
|
|
13594
13573
|
}
|
|
13595
|
-
|
|
13596
|
-
//#region src/candidate-impact.ts
|
|
13574
|
+
// src/candidate-impact.ts
|
|
13597
13575
|
const CANDIDATE_IMPACT_DECISION_SCHEMA_VERSION = 1;
|
|
13598
13576
|
const COMMIT_SHA_PATTERN$2 = /^[0-9a-f]{40}$/iu;
|
|
13599
13577
|
const ZERO_SHA_PATTERN$1 = /^0{40}$/u;
|
|
@@ -13821,8 +13799,7 @@ const candidateImpactSummaryLines = (decision) => decision.basis.classification
|
|
|
13821
13799
|
inertPathsLine(decision.inertPaths),
|
|
13822
13800
|
unsubscribedPathsLine(decision.unsubscribedPaths)
|
|
13823
13801
|
];
|
|
13824
|
-
|
|
13825
|
-
//#region src/commands/candidate-impact.ts
|
|
13802
|
+
// src/commands/candidate-impact.ts
|
|
13826
13803
|
function createCandidateImpactCommand(output) {
|
|
13827
13804
|
return markCwdOptionDefault(new Command("candidate:impact").description("Classify candidate targets from an exact pull-request base/head identity").option("--base <sha>", "candidate base commit SHA").option("--head <sha>", "candidate head commit SHA").option("--cwd <path>", "repository working directory", collectCwdOption).option("--profile <path>", "path to the project profile JSON file").option("--github-output <path>", "append stable decision outputs to a GitHub Actions output file").option("--github-summary <path>", "append a human-readable decision to a GitHub Actions summary file").option("--json", "print the complete decision as JSON").option("--emit-run-context", "emit the FACTORY_BASE_REF / FACTORY_CHANGED_FILES run-context contract").action((options) => {
|
|
13828
13805
|
const decision = runCandidateImpact({
|
|
@@ -13846,8 +13823,7 @@ function createCandidateImpactCommand(output) {
|
|
|
13846
13823
|
} else output.stdout.write(`${candidateImpactSummaryLines(decision).join("\n")}\n`);
|
|
13847
13824
|
}));
|
|
13848
13825
|
}
|
|
13849
|
-
|
|
13850
|
-
//#region src/ci-analyze.ts
|
|
13826
|
+
// src/ci-analyze.ts
|
|
13851
13827
|
/**
|
|
13852
13828
|
* `ci:analyze` — read-only GitHub Actions run lifecycle analysis (#647).
|
|
13853
13829
|
*
|
|
@@ -14320,8 +14296,7 @@ const renderCiAnalyzeReport = (report) => {
|
|
|
14320
14296
|
}
|
|
14321
14297
|
return `${lines.join("\n")}\n`;
|
|
14322
14298
|
};
|
|
14323
|
-
|
|
14324
|
-
//#region src/commands/ci-analyze.ts
|
|
14299
|
+
// src/commands/ci-analyze.ts
|
|
14325
14300
|
/**
|
|
14326
14301
|
* `ci:analyze` command wiring (#647).
|
|
14327
14302
|
*
|
|
@@ -14394,7 +14369,7 @@ const assembleRunRequests = (input) => {
|
|
|
14394
14369
|
}
|
|
14395
14370
|
return ordered;
|
|
14396
14371
|
};
|
|
14397
|
-
const GH_ARTIFACT_MAX_BYTES =
|
|
14372
|
+
const GH_ARTIFACT_MAX_BYTES = 268435456;
|
|
14398
14373
|
const PAGE_SIZE = 100;
|
|
14399
14374
|
const MAX_PAGES = 50;
|
|
14400
14375
|
/**
|
|
@@ -14484,7 +14459,7 @@ const parseZipInfoListing = (text) => {
|
|
|
14484
14459
|
}
|
|
14485
14460
|
return members;
|
|
14486
14461
|
};
|
|
14487
|
-
const MAX_ARTIFACT_DECOMPRESSED_BYTES =
|
|
14462
|
+
const MAX_ARTIFACT_DECOMPRESSED_BYTES = 268435456;
|
|
14488
14463
|
const UNSAFE_MEMBER_CHARACTERS = /[*?[\]]/u;
|
|
14489
14464
|
/**
|
|
14490
14465
|
* The member policy for artifact zips, as a pure function so the security
|
|
@@ -14527,10 +14502,11 @@ const createGhCiAnalyzeClient = (repository) => ({
|
|
|
14527
14502
|
const zip = execFileSync("gh", ["api", `/repos/${repository}/actions/artifacts/${artifactId}/zip`], { maxBuffer: GH_ARTIFACT_MAX_BYTES });
|
|
14528
14503
|
const zipPath = path.join(scratch, "artifact.zip");
|
|
14529
14504
|
writeFileSync(zipPath, zip);
|
|
14530
|
-
const
|
|
14505
|
+
const listing = execFileSync("unzip", ["-Z", zipPath], {
|
|
14531
14506
|
encoding: "utf-8",
|
|
14532
14507
|
maxBuffer: GH_ARTIFACT_MAX_BYTES
|
|
14533
|
-
})
|
|
14508
|
+
});
|
|
14509
|
+
const selected = selectProfileZipMembers(parseZipInfoListing(listing));
|
|
14534
14510
|
if (selected.length === 0) return Promise.resolve([]);
|
|
14535
14511
|
const extracted = path.join(scratch, "extracted");
|
|
14536
14512
|
execFileSync("unzip", [
|
|
@@ -14619,8 +14595,7 @@ const UnknownFactoryTraceEventSchema = FactoryTraceEventCoreSchema.extend({
|
|
|
14619
14595
|
payload: z.unknown(),
|
|
14620
14596
|
unknownTraceEvent: z.literal(true)
|
|
14621
14597
|
}).strict();
|
|
14622
|
-
|
|
14623
|
-
//#region src/packages/trace/implementation/review-gate.ts
|
|
14598
|
+
// src/packages/trace/implementation/review-gate.ts
|
|
14624
14599
|
const ReviewGateTracePayloadShape = z.object({
|
|
14625
14600
|
base: nonEmptyString$1,
|
|
14626
14601
|
changedFiles: z.array(nonEmptyString$1).min(1),
|
|
@@ -14639,8 +14614,7 @@ const ReviewGateTraceEventSchema = FactoryTraceEventCoreSchema.extend({
|
|
|
14639
14614
|
typeVersion: z.literal(1)
|
|
14640
14615
|
}).strict();
|
|
14641
14616
|
const reviewGatePayloadFor = (event) => ReviewGateTracePayloadSchema.parse(Object.fromEntries(Object.keys(ReviewGateTracePayloadShape.shape).map((key) => [key, event[key]]).filter(([, value]) => value !== void 0)));
|
|
14642
|
-
|
|
14643
|
-
//#region src/packages/trace/implementation/review-ladder-stage.ts
|
|
14617
|
+
// src/packages/trace/implementation/review-ladder-stage.ts
|
|
14644
14618
|
const LadderSessionAttributionSchema = z.object({
|
|
14645
14619
|
orchestrationMode: z.enum(["autonomous", "manual"]).optional(),
|
|
14646
14620
|
resumedSession: z.boolean().optional(),
|
|
@@ -14685,8 +14659,7 @@ const ReviewLadderStageTraceEventSchema = FactoryTraceEventCoreSchema.extend({
|
|
|
14685
14659
|
typeVersion: z.literal(1)
|
|
14686
14660
|
}).strict();
|
|
14687
14661
|
const reviewLadderStagePayloadFor = (event) => ReviewLadderStageTracePayloadSchema.parse(Object.fromEntries(Object.keys(ReviewLadderStageTracePayloadShape.shape).map((key) => [key, event[key]]).filter(([, value]) => value !== void 0)));
|
|
14688
|
-
|
|
14689
|
-
//#region src/packages/trace/implementation/definitions.ts
|
|
14662
|
+
// src/packages/trace/implementation/definitions.ts
|
|
14690
14663
|
const defineTraceEvent = (definition) => definition;
|
|
14691
14664
|
const FACTORY_TRACE_EVENT_DEFINITIONS = [defineTraceEvent({
|
|
14692
14665
|
appendEventSchema: ReviewGateTraceEventSchema,
|
|
@@ -14723,7 +14696,8 @@ const deriveTraceRegistry = (definitions) => {
|
|
|
14723
14696
|
const factoryTraceEventSchema = z.union(readUnionSchemas);
|
|
14724
14697
|
const appendFactoryTraceEventSchema = z.union(appendUnionSchemas);
|
|
14725
14698
|
const wirePayloadFor = (event) => {
|
|
14726
|
-
|
|
14699
|
+
const kind = event.eventType;
|
|
14700
|
+
return definitionByKind[kind].emit(event);
|
|
14727
14701
|
};
|
|
14728
14702
|
return {
|
|
14729
14703
|
appendFactoryTraceEventSchema,
|
|
@@ -14737,8 +14711,7 @@ const deriveTraceRegistry = (definitions) => {
|
|
|
14737
14711
|
};
|
|
14738
14712
|
};
|
|
14739
14713
|
const { appendFactoryTraceEventSchema: AppendFactoryTraceEventSchema, factoryTraceEventSchema: FactoryTraceEventSchema, payloadSchemaRegistry, payloadVersions: FACTORY_TRACE_PAYLOAD_VERSIONS, wirePayloadFor } = deriveTraceRegistry(FACTORY_TRACE_EVENT_DEFINITIONS);
|
|
14740
|
-
|
|
14741
|
-
//#region src/packages/trace/implementation/trace-shard.ts
|
|
14714
|
+
// src/packages/trace/implementation/trace-shard.ts
|
|
14742
14715
|
const FACTORY_TRACE_DIR = ".factory-memory/factory-trace";
|
|
14743
14716
|
const shardDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u, "must be YYYY-MM-DD");
|
|
14744
14717
|
const validateFactoryTraceShardDate = (date) => {
|
|
@@ -14748,8 +14721,7 @@ const validateFactoryTraceShardDate = (date) => {
|
|
|
14748
14721
|
};
|
|
14749
14722
|
const factoryTraceEventDate = (event) => new Date(event.createdAt).toISOString().slice(0, 10);
|
|
14750
14723
|
const factoryTraceShardPath = (repoRoot, date) => path.join(repoRoot, FACTORY_TRACE_DIR, `${validateFactoryTraceShardDate(date)}.jsonl`);
|
|
14751
|
-
|
|
14752
|
-
//#region src/packages/trace/implementation/trace-sinks.ts
|
|
14724
|
+
// src/packages/trace/implementation/trace-sinks.ts
|
|
14753
14725
|
const createLocalJsonlTraceSink = (repoRoot) => ({ append: (envelope) => {
|
|
14754
14726
|
const filePath = factoryTraceShardPath(repoRoot, factoryTraceEventDate({ createdAt: envelope.createdAt }));
|
|
14755
14727
|
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
@@ -14775,8 +14747,7 @@ const resolveTraceWriteSinks = (repoRoot, options = {}) => {
|
|
|
14775
14747
|
...options.mirror ? { mirror: options.mirror } : {}
|
|
14776
14748
|
};
|
|
14777
14749
|
};
|
|
14778
|
-
|
|
14779
|
-
//#region src/packages/trace/implementation/facade.ts
|
|
14750
|
+
// src/packages/trace/implementation/facade.ts
|
|
14780
14751
|
var FactoryTraceJsonlError = class extends Error {
|
|
14781
14752
|
diagnostic;
|
|
14782
14753
|
constructor(diagnostic) {
|
|
@@ -15017,8 +14988,7 @@ const scanFactoryTraceDiagnostics = ({ filters, from, repoRoot, to }) => scanFac
|
|
|
15017
14988
|
repoRoot,
|
|
15018
14989
|
to
|
|
15019
14990
|
}).diagnostics;
|
|
15020
|
-
|
|
15021
|
-
//#region src/epic-closeout/gather.ts
|
|
14991
|
+
// src/epic-closeout/gather.ts
|
|
15022
14992
|
const BUDGET_NOTE = "bounded closeout report: trace diagnostics scan plus the lane token harvest; no per-commit forensic dig";
|
|
15023
14993
|
function gatherCloseoutInputs(opts) {
|
|
15024
14994
|
const diagnostics = scanFactoryTraceDiagnostics({
|
|
@@ -15039,16 +15009,14 @@ function gatherCloseoutInputs(opts) {
|
|
|
15039
15009
|
diagnostics
|
|
15040
15010
|
};
|
|
15041
15011
|
}
|
|
15042
|
-
|
|
15043
|
-
//#region src/epic-closeout/types.ts
|
|
15012
|
+
// src/epic-closeout/types.ts
|
|
15044
15013
|
var CloseoutValidationError = class extends Error {
|
|
15045
15014
|
constructor(message) {
|
|
15046
15015
|
super(message);
|
|
15047
15016
|
this.name = "CloseoutValidationError";
|
|
15048
15017
|
}
|
|
15049
15018
|
};
|
|
15050
|
-
|
|
15051
|
-
//#region src/epic-closeout/report.ts
|
|
15019
|
+
// src/epic-closeout/report.ts
|
|
15052
15020
|
const ROW_LIMIT_BLINDSPOT_ID = "closeout-row-limit";
|
|
15053
15021
|
const BASELINE_BLINDSPOT = {
|
|
15054
15022
|
id: "bounded-standing-step",
|
|
@@ -15068,7 +15036,7 @@ const assertMetricSources = (metrics) => {
|
|
|
15068
15036
|
*/
|
|
15069
15037
|
const boundCloseoutRows = (input) => {
|
|
15070
15038
|
const sourceBlindspots = input.blindspots.filter((blindspot) => blindspot.id !== ROW_LIMIT_BLINDSPOT_ID);
|
|
15071
|
-
let remaining = Math.max(0,
|
|
15039
|
+
let remaining = Math.max(0, 999);
|
|
15072
15040
|
const blindspots = sourceBlindspots.slice(0, remaining);
|
|
15073
15041
|
remaining -= blindspots.length;
|
|
15074
15042
|
const metrics = input.metrics.slice(0, remaining);
|
|
@@ -15108,8 +15076,7 @@ function buildEpicCloseoutReport(input) {
|
|
|
15108
15076
|
schemaVersion: 5
|
|
15109
15077
|
});
|
|
15110
15078
|
}
|
|
15111
|
-
|
|
15112
|
-
//#region src/epic-closeout/token-harvest.ts
|
|
15079
|
+
// src/epic-closeout/token-harvest.ts
|
|
15113
15080
|
/**
|
|
15114
15081
|
* The closeout token harvest.
|
|
15115
15082
|
*
|
|
@@ -15251,7 +15218,7 @@ const gptMetrics = (gpt) => gpt.roles.flatMap((role) => {
|
|
|
15251
15218
|
const harvestCloseoutTokens = (input) => {
|
|
15252
15219
|
const env = input.env ?? process.env;
|
|
15253
15220
|
const dataGaps = [];
|
|
15254
|
-
const laneIdentity = resolveGateTimingAgentRunId(env)
|
|
15221
|
+
const laneIdentity = resolveGateTimingAgentRunId(env);
|
|
15255
15222
|
const agentRunId = laneIdentity ?? `closeout-${safeRunName(input.epic)}`;
|
|
15256
15223
|
if (laneIdentity === void 0) dataGaps.push("agentRunId is synthetic (no lane run identity exported): the closeout is keyed to the epic, not to a run.");
|
|
15257
15224
|
const claudeSessionId = discoverFactorySessionId(env) ?? resolveNativeSessionId(env);
|
|
@@ -15311,13 +15278,11 @@ const harvestCloseoutTokens = (input) => {
|
|
|
15311
15278
|
metrics
|
|
15312
15279
|
};
|
|
15313
15280
|
};
|
|
15314
|
-
|
|
15315
|
-
//#region src/epic-closeout/epic-filename.ts
|
|
15281
|
+
// src/epic-closeout/epic-filename.ts
|
|
15316
15282
|
function sanitizeEpicFilename(epic) {
|
|
15317
15283
|
return epic.replaceAll(/[^A-Za-z0-9._-]/gu, "-");
|
|
15318
15284
|
}
|
|
15319
|
-
|
|
15320
|
-
//#region src/epic-closeout/render.ts
|
|
15285
|
+
// src/epic-closeout/render.ts
|
|
15321
15286
|
const formatValue = (value) => {
|
|
15322
15287
|
if (value === null) return "_null_";
|
|
15323
15288
|
if (typeof value === "boolean") return value ? "true" : "false";
|
|
@@ -15356,8 +15321,7 @@ function renderCloseoutMarkdown(artifact) {
|
|
|
15356
15321
|
""
|
|
15357
15322
|
].join("\n");
|
|
15358
15323
|
}
|
|
15359
|
-
|
|
15360
|
-
//#region src/epic-closeout/write-artifact.ts
|
|
15324
|
+
// src/epic-closeout/write-artifact.ts
|
|
15361
15325
|
/** The closeout artifact directory, relative to repoRoot. */
|
|
15362
15326
|
const DEFAULT_OUT_DIR = ".factory-memory/closeouts";
|
|
15363
15327
|
function closeoutArtifactPaths(opts) {
|
|
@@ -15382,8 +15346,7 @@ function writeCloseoutArtifact(opts) {
|
|
|
15382
15346
|
writeFileSync(markdownPath, renderCloseoutMarkdown(artifact), "utf-8");
|
|
15383
15347
|
return { markdownPath };
|
|
15384
15348
|
}
|
|
15385
|
-
|
|
15386
|
-
//#region src/proof-archive.ts
|
|
15349
|
+
// src/proof-archive.ts
|
|
15387
15350
|
const FACTORY_MEMORY_DIR = ".factory-memory";
|
|
15388
15351
|
const PROOF_ARCHIVE_DIR_ENV = "FACTORY_PROOF_ARCHIVE_DIR";
|
|
15389
15352
|
const DEFAULT_PROOF_ARCHIVE_SUBPATH = path.join(".factory", "proof-archive");
|
|
@@ -15441,7 +15404,8 @@ function archiveProofResidue(input) {
|
|
|
15441
15404
|
entryCount: 0
|
|
15442
15405
|
};
|
|
15443
15406
|
}
|
|
15444
|
-
const
|
|
15407
|
+
const homeDir = input.homeDir ?? homedir();
|
|
15408
|
+
const archiveRoot = resolveProofArchiveRoot(env, homeDir);
|
|
15445
15409
|
const repoSlug = `${safeSegment(input.repo.owner)}-${safeSegment(input.repo.name)}`;
|
|
15446
15410
|
const archiveDir = path.join(archiveRoot, repoSlug, safeSegment(input.agentRunId), archiveTimestamp(now));
|
|
15447
15411
|
const residueDir = path.join(archiveDir, "factory-memory");
|
|
@@ -15481,8 +15445,7 @@ function archiveProofResidue(input) {
|
|
|
15481
15445
|
};
|
|
15482
15446
|
}
|
|
15483
15447
|
}
|
|
15484
|
-
|
|
15485
|
-
//#region src/commands/closeout.ts
|
|
15448
|
+
// src/commands/closeout.ts
|
|
15486
15449
|
const formatUtcDate = (date) => date.toISOString().slice(0, 10);
|
|
15487
15450
|
const nonEmptyRepoRoot = (value) => {
|
|
15488
15451
|
if (value.trim() === "") throw new InvalidArgumentError("--repo-root requires a non-empty path");
|
|
@@ -15637,8 +15600,7 @@ function createCloseoutCommand(output, dependencies = {}) {
|
|
|
15637
15600
|
output.stdout.write(`wrote ${written.markdownPath}\n`);
|
|
15638
15601
|
}));
|
|
15639
15602
|
}
|
|
15640
|
-
|
|
15641
|
-
//#region src/commands/config.ts
|
|
15603
|
+
// src/commands/config.ts
|
|
15642
15604
|
function resolveConfigPath(deps) {
|
|
15643
15605
|
return deps.configPath ?? defaultUserConfigPath(deps.env ?? process.env);
|
|
15644
15606
|
}
|
|
@@ -15699,8 +15661,7 @@ function createConfigCommand(output, deps = {}) {
|
|
|
15699
15661
|
});
|
|
15700
15662
|
return config;
|
|
15701
15663
|
}
|
|
15702
|
-
|
|
15703
|
-
//#region src/commands/demand-waive.ts
|
|
15664
|
+
// src/commands/demand-waive.ts
|
|
15704
15665
|
/**
|
|
15705
15666
|
* The one override verb (#354). It takes a resolved demand key, never a
|
|
15706
15667
|
* control name, so no control ever needs a skip flag of its own — and it
|
|
@@ -15718,8 +15679,7 @@ function createDemandWaiveCommand(_output, action = runDemandWaive) {
|
|
|
15718
15679
|
});
|
|
15719
15680
|
}));
|
|
15720
15681
|
}
|
|
15721
|
-
|
|
15722
|
-
//#region src/hq-ingest-preflight.ts
|
|
15682
|
+
// src/hq-ingest-preflight.ts
|
|
15723
15683
|
/**
|
|
15724
15684
|
* Whether the HQ ingest credentials resolve (#312).
|
|
15725
15685
|
*
|
|
@@ -15776,7 +15736,8 @@ function hqIngestCredentialCheck({ env, resolve = defaultSecretReferenceProbe, r
|
|
|
15776
15736
|
})).filter(({ resolution }) => resolution.status !== "resolved");
|
|
15777
15737
|
if (unresolved.length > 0) return {
|
|
15778
15738
|
message: `HQ ingest credentials are absent and did not resolve from the operator's secret store: ${unresolved.map(({ reference, resolution }) => {
|
|
15779
|
-
|
|
15739
|
+
const status = resolution.status;
|
|
15740
|
+
return `${reference} (${RESOLUTION_HINT[status]})`;
|
|
15780
15741
|
}).join("; ")}. Warm the reference (\`op-fast read '<ref>' >/dev/null\`) or correct it in the operator user config. ${REMEDY_SHAPE}`,
|
|
15781
15742
|
name: HQ_INGEST_PREFLIGHT_CHECK_NAME,
|
|
15782
15743
|
status: "warning"
|
|
@@ -15787,8 +15748,7 @@ function hqIngestCredentialCheck({ env, resolve = defaultSecretReferenceProbe, r
|
|
|
15787
15748
|
status: "ok"
|
|
15788
15749
|
};
|
|
15789
15750
|
}
|
|
15790
|
-
|
|
15791
|
-
//#region src/admission-preflight.ts
|
|
15751
|
+
// src/admission-preflight.ts
|
|
15792
15752
|
const errorMessage$1 = (error) => error instanceof Error ? error.message : String(error);
|
|
15793
15753
|
/**
|
|
15794
15754
|
* The base every row below measures against (#1131, #1121). Bound the same
|
|
@@ -16133,8 +16093,7 @@ const admissionPreflightChecks = ({ base, candidateBase, cwd, env = process.env,
|
|
|
16133
16093
|
})
|
|
16134
16094
|
];
|
|
16135
16095
|
};
|
|
16136
|
-
|
|
16137
|
-
//#region src/doctor-hq-checks.ts
|
|
16096
|
+
// src/doctor-hq-checks.ts
|
|
16138
16097
|
const HQ_SPOOL_CHECK_NAME = "hq-spool";
|
|
16139
16098
|
const FLUSH_REMEDY = "Run `psf hq:flush` to drain them.";
|
|
16140
16099
|
/** One sentence per orphaned location, with the `--dir` recovery it needs. */
|
|
@@ -16358,8 +16317,7 @@ async function hqReadinessDoctorChecks(input, dependencies = {}) {
|
|
|
16358
16317
|
reachable
|
|
16359
16318
|
];
|
|
16360
16319
|
}
|
|
16361
|
-
|
|
16362
|
-
//#region src/hq-last-stored.ts
|
|
16320
|
+
// src/hq-last-stored.ts
|
|
16363
16321
|
/**
|
|
16364
16322
|
* The HQ client for `GET /api/ingest/last-stored` (#1339): when HQ last stored
|
|
16365
16323
|
* an event for a repository. Doctor's `hq-webhook` row asks it when GitHub
|
|
@@ -16448,8 +16406,7 @@ async function fetchHqLastStored(input, dependencies = {}) {
|
|
|
16448
16406
|
return unknown("unexpected-response", `HQ at ${origin.origin} answered 200 with a reply that is not a last-stored answer.`);
|
|
16449
16407
|
}
|
|
16450
16408
|
}
|
|
16451
|
-
|
|
16452
|
-
//#region src/doctor-hq-last-stored.ts
|
|
16409
|
+
// src/doctor-hq-last-stored.ts
|
|
16453
16410
|
/**
|
|
16454
16411
|
* The `hq-last-stored` doctor row (#1342): the silent-spool alarm. A machine
|
|
16455
16412
|
* whose gates stop reaching HQ looks, from HQ, like a machine that stopped
|
|
@@ -16479,7 +16436,6 @@ const PR_VERIFY_PROOF_PATH = path.join(".factory-memory", "pr-verify.json");
|
|
|
16479
16436
|
* most, and how far a coarse filesystem clock may put the write before it.
|
|
16480
16437
|
*/
|
|
16481
16438
|
const PROOF_WRITE_WINDOW_MS = 6e4;
|
|
16482
|
-
const MTIME_GRANULARITY_MS = 2e3;
|
|
16483
16439
|
/**
|
|
16484
16440
|
* This checkout's pr:verify proof, and whether a pr:verify run here wrote it.
|
|
16485
16441
|
* Only such a run handed the proof to the HQ sink, at `endedAt`.
|
|
@@ -16505,7 +16461,7 @@ const readLocalProof = (input) => {
|
|
|
16505
16461
|
}
|
|
16506
16462
|
const { name, owner } = input.profile.repository;
|
|
16507
16463
|
const writeLag = writtenAtMs - Date.parse(proof.endedAt);
|
|
16508
|
-
return proof.profilePath === input.profilePath && proof.repository === `${owner}/${name}` && writeLag >= -
|
|
16464
|
+
return proof.profilePath === input.profilePath && proof.repository === `${owner}/${name}` && writeLag >= -2e3 && writeLag <= PROOF_WRITE_WINDOW_MS ? {
|
|
16509
16465
|
endedAt: proof.endedAt,
|
|
16510
16466
|
status: "local"
|
|
16511
16467
|
} : { status: "unattributed" };
|
|
@@ -16590,8 +16546,7 @@ async function hqLastStoredDoctorCheck(input, dependencies = {}) {
|
|
|
16590
16546
|
status: behind || spool.pending > 0 || spool.unlistable > 0 ? "warning" : "ok"
|
|
16591
16547
|
};
|
|
16592
16548
|
}
|
|
16593
|
-
|
|
16594
|
-
//#region src/doctor-hq-webhook.ts
|
|
16549
|
+
// src/doctor-hq-webhook.ts
|
|
16595
16550
|
/**
|
|
16596
16551
|
* The `hq-webhook` doctor row (#1341): whether GitHub's webhook deliveries
|
|
16597
16552
|
* from this repository reach HQ. paitronage and firedup answered 401 from
|
|
@@ -16735,8 +16690,7 @@ async function hqWebhookDoctorCheck(input, dependencies = {}) {
|
|
|
16735
16690
|
return unreadableCheck(input, hq, error, dependencies);
|
|
16736
16691
|
}
|
|
16737
16692
|
}
|
|
16738
|
-
|
|
16739
|
-
//#region src/doctor-machine-checks.ts
|
|
16693
|
+
// src/doctor-machine-checks.ts
|
|
16740
16694
|
/**
|
|
16741
16695
|
* Machine readiness rows for `doctor` (#1315): facts about this machine, not
|
|
16742
16696
|
* about the profile, that decide whether factory work can run here.
|
|
@@ -16910,8 +16864,7 @@ function machineDoctorChecks(input, dependencies = {}) {
|
|
|
16910
16864
|
previewProducerCheck(input, dependencies.isOnPath ?? isExecutableOnPath)
|
|
16911
16865
|
];
|
|
16912
16866
|
}
|
|
16913
|
-
|
|
16914
|
-
//#region src/doctor.ts
|
|
16867
|
+
// src/doctor.ts
|
|
16915
16868
|
async function doctorProjectProfile(input = {}) {
|
|
16916
16869
|
const { path, profile } = loadProjectProfile(input);
|
|
16917
16870
|
const env = input.env ?? process.env;
|
|
@@ -17145,8 +17098,7 @@ const ambientGhAuthCheck = async (cwd, env, check = (root, ghEnv) => {
|
|
|
17145
17098
|
};
|
|
17146
17099
|
}
|
|
17147
17100
|
};
|
|
17148
|
-
|
|
17149
|
-
//#region src/commands/doctor.ts
|
|
17101
|
+
// src/commands/doctor.ts
|
|
17150
17102
|
function createDoctorCommand(output) {
|
|
17151
17103
|
return markCwdOptionDefault(new Command("doctor").description("Validate a project profile without mutating GitHub or local files").option("--base <ref>", "base ref to assert for --preflight. With a pull request open for this branch its live base is the base and a disagreeing value is reported; without one, this ref (default origin/main) is fetched fresh").option("--cwd <path>", "working directory to validate", collectCwdOption).option("--json", "print the doctor report as JSON").option("--preflight", "also list the pre-checkable admission requirements for the current candidate (read-only; never blocks); each required check states whether this candidate is demanded to satisfy it, resolved by candidate:impact; findings-file shape and wave membership have no read-only pre-check").option("--profile <path>", "path to the project profile JSON file").action(async (options) => {
|
|
17152
17104
|
const report = await doctorProjectProfile({
|
|
@@ -17170,8 +17122,7 @@ function formatHumanReport(report) {
|
|
|
17170
17122
|
""
|
|
17171
17123
|
].join("\n");
|
|
17172
17124
|
}
|
|
17173
|
-
|
|
17174
|
-
//#region src/epic-structure.ts
|
|
17125
|
+
// src/epic-structure.ts
|
|
17175
17126
|
/**
|
|
17176
17127
|
* Producer-side `epic-structure` v1 emitter (epic #132, lane #135).
|
|
17177
17128
|
*
|
|
@@ -17352,7 +17303,8 @@ const validateDagDocument = (input) => {
|
|
|
17352
17303
|
const rawNodes = Array.isArray(doc.nodes) ? doc.nodes : void 0;
|
|
17353
17304
|
if (rawNodes === void 0 || rawNodes.length === 0) diagnostics.push("dag document requires a non-empty `nodes` array");
|
|
17354
17305
|
const { nodes, slugs } = validateNodes(rawNodes ?? [], diagnostics);
|
|
17355
|
-
const
|
|
17306
|
+
const rawEdges = Array.isArray(doc.edges) ? doc.edges : [];
|
|
17307
|
+
const edges = validateEdges(rawEdges, slugs, diagnostics);
|
|
17356
17308
|
const cycle = findCycle(slugs, edges);
|
|
17357
17309
|
if (cycle) diagnostics.push(`dependency cycle detected: ${cycle.join(" -> ")}`);
|
|
17358
17310
|
if (diagnostics.length > 0 || epicId === void 0 || repo === void 0) throw new EpicStructureValidationError(diagnostics);
|
|
@@ -17476,8 +17428,7 @@ const publishEpicStructure = async (args) => {
|
|
|
17476
17428
|
status: response.status
|
|
17477
17429
|
};
|
|
17478
17430
|
};
|
|
17479
|
-
|
|
17480
|
-
//#region src/commands/epic-publish-structure.ts
|
|
17431
|
+
// src/commands/epic-publish-structure.ts
|
|
17481
17432
|
const STDIN = "-";
|
|
17482
17433
|
/** Reads a dag.yml source path, or stdin when `source` is `-`. */
|
|
17483
17434
|
const readSource = (source) => {
|
|
@@ -17505,7 +17456,8 @@ const parseDocument = (raw, source) => {
|
|
|
17505
17456
|
* document; the command does not patch authored structure with override flags.
|
|
17506
17457
|
*/
|
|
17507
17458
|
const buildEvent = (source) => {
|
|
17508
|
-
|
|
17459
|
+
const document = parseDocument(readSource(source), source);
|
|
17460
|
+
return buildEpicStructureEvent({ document });
|
|
17509
17461
|
};
|
|
17510
17462
|
function createEpicPublishStructureCommand(output, deps = {}) {
|
|
17511
17463
|
const env = deps.env ?? process.env;
|
|
@@ -17531,8 +17483,7 @@ function createEpicPublishStructureCommand(output, deps = {}) {
|
|
|
17531
17483
|
output.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : `epic:publish-structure ${result.duplicate ? "no-op (duplicate)" : "accepted"} — eventId ${result.eventId} [HTTP ${result.status}]\n`);
|
|
17532
17484
|
});
|
|
17533
17485
|
}
|
|
17534
|
-
|
|
17535
|
-
//#region src/commands/evidence-emit.ts
|
|
17486
|
+
// src/commands/evidence-emit.ts
|
|
17536
17487
|
const readStdin = () => {
|
|
17537
17488
|
let raw = "";
|
|
17538
17489
|
try {
|
|
@@ -17601,8 +17552,7 @@ function createEvidenceEmitCommand(output, action = runEvidenceEmit, readInput =
|
|
|
17601
17552
|
if (options.json && "envelope" in result) output.stdout.write(`${JSON.stringify(result.envelope, null, 2)}\n`);
|
|
17602
17553
|
}));
|
|
17603
17554
|
}
|
|
17604
|
-
|
|
17605
|
-
//#region src/hq-flush.ts
|
|
17555
|
+
// src/hq-flush.ts
|
|
17606
17556
|
/**
|
|
17607
17557
|
* Spools holding this repository's evidence under an earlier key of its own
|
|
17608
17558
|
* (#420) — a question the drain itself cannot answer, because it resolves
|
|
@@ -17761,8 +17711,7 @@ const hqFlushExitCode = (result) => {
|
|
|
17761
17711
|
if (result.unreachableFiles > 0) return HQ_FLUSH_TRANSPORT_EXIT_CODE;
|
|
17762
17712
|
return result.incomplete ? HQ_FLUSH_INCOMPLETE_EXIT_CODE : 0;
|
|
17763
17713
|
};
|
|
17764
|
-
|
|
17765
|
-
//#region src/commands/hq-flush.ts
|
|
17714
|
+
// src/commands/hq-flush.ts
|
|
17766
17715
|
function createHqFlushCommand(output, action = runHqFlush) {
|
|
17767
17716
|
return markCwdOptionDefault(new Command("hq:flush").description("Drain this repository's spooled HQ evidence and report every event; exits 1 when transport failed and 2 when the drain did not finish").option("--cwd <path>", "working directory to evaluate", collectCwdOption).option("--dir <path>", "drain an explicit spool directory instead of the default locations; repeatable", (value, previous = []) => [...previous, value]).option("--evict-permanent", "disposition schema-permanent rejections (HTTP 422) in place with `.undeliverable` instead of retaining them").option("--json", "print the flush result as JSON").option("--profile <path>", "path to the project profile JSON file").action(async (options) => {
|
|
17768
17717
|
const result = await action({
|
|
@@ -17777,8 +17726,7 @@ function createHqFlushCommand(output, action = runHqFlush) {
|
|
|
17777
17726
|
if (exitCode !== 0) process.exitCode = exitCode;
|
|
17778
17727
|
}));
|
|
17779
17728
|
}
|
|
17780
|
-
|
|
17781
|
-
//#region src/follow-up.ts
|
|
17729
|
+
// src/follow-up.ts
|
|
17782
17730
|
const FACTORY_CLI_EXECUTABLE = "patronage-factory";
|
|
17783
17731
|
const FactoryCliInvocationSchema = z.object({
|
|
17784
17732
|
argvPrefix: z.array(z.string().min(1)).min(1),
|
|
@@ -17823,8 +17771,28 @@ const FollowUpActionSchema = z.object({
|
|
|
17823
17771
|
argv: z.array(z.string()),
|
|
17824
17772
|
command: z.string()
|
|
17825
17773
|
}).strict();
|
|
17826
|
-
|
|
17827
|
-
|
|
17774
|
+
// src/hold-label.ts
|
|
17775
|
+
/** The label that keeps an admitted pull request attended (#1299). */
|
|
17776
|
+
const FACTORY_HOLD_LABEL = "factory:hold";
|
|
17777
|
+
/**
|
|
17778
|
+
* `--hold` on pr:publish and pr:ready (#1513): put `factory:hold` on the pull
|
|
17779
|
+
* request before anything can arm it, so readiness admits it and leaves the
|
|
17780
|
+
* merge to a person. A REST call, so it works where GraphQL is refused, and
|
|
17781
|
+
* on the operator's own credential, like every other write that is not a
|
|
17782
|
+
* pull request create or body edit.
|
|
17783
|
+
*/
|
|
17784
|
+
const ghApiArgsForHoldLabel = ({ owner, pr, repo }) => [
|
|
17785
|
+
"api",
|
|
17786
|
+
"--method",
|
|
17787
|
+
"POST",
|
|
17788
|
+
`/repos/${owner}/${repo}/issues/${pr}/labels`,
|
|
17789
|
+
"-f",
|
|
17790
|
+
`labels[]=${FACTORY_HOLD_LABEL}`
|
|
17791
|
+
];
|
|
17792
|
+
const holdPullRequest = (input) => {
|
|
17793
|
+
runCapture("gh", ghApiArgsForHoldLabel(input), input.cwd);
|
|
17794
|
+
};
|
|
17795
|
+
// src/pr-publish-transaction-error.ts
|
|
17828
17796
|
/**
|
|
17829
17797
|
* Publish's admission read is a bounded transaction (#348): undraft, await the
|
|
17830
17798
|
* newest hosted run for this head, re-evaluate, and return the current
|
|
@@ -17837,8 +17805,7 @@ var PrPublishTransactionAbortedError = class extends Error {
|
|
|
17837
17805
|
this.name = "PrPublishTransactionAbortedError";
|
|
17838
17806
|
}
|
|
17839
17807
|
};
|
|
17840
|
-
|
|
17841
|
-
//#region src/pr-readiness/pr-body-sections.ts
|
|
17808
|
+
// src/pr-readiness/pr-body-sections.ts
|
|
17842
17809
|
const MANAGED_SECTION_NAMES = [
|
|
17843
17810
|
"Verification",
|
|
17844
17811
|
"Review proof",
|
|
@@ -17894,8 +17861,7 @@ const findSectionBounds = (body, heading) => {
|
|
|
17894
17861
|
headingStart
|
|
17895
17862
|
};
|
|
17896
17863
|
};
|
|
17897
|
-
|
|
17898
|
-
//#region src/pr-readiness/pr-body-patch.ts
|
|
17864
|
+
// src/pr-readiness/pr-body-patch.ts
|
|
17899
17865
|
const markerSlug = (heading) => heading.toLowerCase().replaceAll(/[^a-z0-9]+/gu, "-");
|
|
17900
17866
|
const markerFor = (heading, edge) => `<!-- patronage-factory:${markerSlug(heading)}:${edge} -->`;
|
|
17901
17867
|
const renderManagedPrBodyBlock = (heading, content) => `${markerFor(heading, "start")}\n${content.trim()}\n${markerFor(heading, "end")}`;
|
|
@@ -17940,8 +17906,7 @@ const patchPrBodySections = (body, parts) => {
|
|
|
17940
17906
|
}
|
|
17941
17907
|
return result;
|
|
17942
17908
|
};
|
|
17943
|
-
|
|
17944
|
-
//#region src/pr-readiness/pr-body-renderer.ts
|
|
17909
|
+
// src/pr-readiness/pr-body-renderer.ts
|
|
17945
17910
|
var pr_body_renderer_exports = /* @__PURE__ */ __exportAll({
|
|
17946
17911
|
PR_BODY_MANAGED_SECTIONS: () => MANAGED_SECTION_NAMES,
|
|
17947
17912
|
renderPrBodySectionParts: () => renderPrBodySectionParts,
|
|
@@ -17981,8 +17946,7 @@ const renderPrBodySections = ({ reviewProof, verifyProof }) => `${renderPrBodySe
|
|
|
17981
17946
|
reviewProof,
|
|
17982
17947
|
verifyProof
|
|
17983
17948
|
}).map((part) => `## ${part.heading}\n\n${renderManagedPrBodyBlock(part.heading, part.content)}`).join("\n\n")}\n`;
|
|
17984
|
-
|
|
17985
|
-
//#region src/pr-readiness/status-check-rollup.ts
|
|
17949
|
+
// src/pr-readiness/status-check-rollup.ts
|
|
17986
17950
|
var status_check_rollup_exports = /* @__PURE__ */ __exportAll({
|
|
17987
17951
|
HOSTED_VERIFY_CHECK_NAME: () => HOSTED_VERIFY_CHECK_NAME,
|
|
17988
17952
|
HOSTED_VERIFY_DRAFT_CHECK_NAME: () => HOSTED_VERIFY_DRAFT_CHECK_NAME,
|
|
@@ -18002,19 +17966,19 @@ var status_check_rollup_exports = /* @__PURE__ */ __exportAll({
|
|
|
18002
17966
|
statusCheckState: () => statusCheckState,
|
|
18003
17967
|
unsettledNonRequiredCheckNames: () => unsettledNonRequiredCheckNames
|
|
18004
17968
|
});
|
|
18005
|
-
const PASSED_STATES = new Set([
|
|
17969
|
+
const PASSED_STATES = /* @__PURE__ */ new Set([
|
|
18006
17970
|
"SUCCESS",
|
|
18007
17971
|
"SKIPPED",
|
|
18008
17972
|
"NEUTRAL"
|
|
18009
17973
|
]);
|
|
18010
|
-
const FAILED_STATES = new Set([
|
|
17974
|
+
const FAILED_STATES = /* @__PURE__ */ new Set([
|
|
18011
17975
|
"FAILURE",
|
|
18012
17976
|
"ERROR",
|
|
18013
17977
|
"CANCELLED",
|
|
18014
17978
|
"TIMED_OUT",
|
|
18015
17979
|
"ACTION_REQUIRED"
|
|
18016
17980
|
]);
|
|
18017
|
-
const PENDING_STATES = new Set([
|
|
17981
|
+
const PENDING_STATES = /* @__PURE__ */ new Set([
|
|
18018
17982
|
"PENDING",
|
|
18019
17983
|
"QUEUED",
|
|
18020
17984
|
"IN_PROGRESS",
|
|
@@ -18066,7 +18030,7 @@ const HOSTED_VERIFY_DRAFT_CHECK_NAME = `${HOSTED_VERIFY_CHECK_NAME} (draft)`;
|
|
|
18066
18030
|
* clear it. The draft run is a superseded generation of the summary job the
|
|
18067
18031
|
* `verify` row already answers for, so admission does not judge it.
|
|
18068
18032
|
*/
|
|
18069
|
-
const isDraftHostedVerifyCheck = (check) => check.name ===
|
|
18033
|
+
const isDraftHostedVerifyCheck = (check) => check.name === "verify (draft)" && Boolean(check.workflowName);
|
|
18070
18034
|
/**
|
|
18071
18035
|
* Is this a cancelled run of the PR status HUD job (#1056)?
|
|
18072
18036
|
*
|
|
@@ -18303,8 +18267,7 @@ const admissionCheckSetDescription = (requiredContexts) => {
|
|
|
18303
18267
|
if (requiredContexts === void 0) return "every hosted run (the base branch's required checks could not be read)";
|
|
18304
18268
|
return requiredContexts.length === 0 ? "every hosted run (the base branch requires no checks)" : `the base branch's required checks (${requiredContexts.join(", ")})`;
|
|
18305
18269
|
};
|
|
18306
|
-
|
|
18307
|
-
//#region src/arm-auto-merge.ts
|
|
18270
|
+
// src/arm-auto-merge.ts
|
|
18308
18271
|
/**
|
|
18309
18272
|
* The read-back, parsed rather than asserted. `state` is read loosely so a
|
|
18310
18273
|
* merged pull request is still recognised as merged even when the enablement
|
|
@@ -18388,8 +18351,7 @@ function armAutoMerge(input, dependencies = {}) {
|
|
|
18388
18351
|
outcome: "not-armed"
|
|
18389
18352
|
};
|
|
18390
18353
|
}
|
|
18391
|
-
|
|
18392
|
-
//#region src/merge-freeze.ts
|
|
18354
|
+
// src/merge-freeze.ts
|
|
18393
18355
|
const MERGE_FREEZE_CHECK_NAME = "patronage-factory/merge-freeze";
|
|
18394
18356
|
/**
|
|
18395
18357
|
* The Factory App's slug, as GitHub serves it on the runs the writer posts.
|
|
@@ -18867,8 +18829,7 @@ function armingMergeFreezeOutcome(input, authority) {
|
|
|
18867
18829
|
notices: []
|
|
18868
18830
|
};
|
|
18869
18831
|
}
|
|
18870
|
-
|
|
18871
|
-
//#region src/pr-readiness/proof-identity.ts
|
|
18832
|
+
// src/pr-readiness/proof-identity.ts
|
|
18872
18833
|
var proof_identity_exports = /* @__PURE__ */ __exportAll({
|
|
18873
18834
|
REVIEW_STATUS_VALUES: () => REVIEW_STATUS_VALUES,
|
|
18874
18835
|
explicitFailureIdentity: () => explicitFailureIdentity,
|
|
@@ -19046,8 +19007,7 @@ const managedReadinessLedgerSchema = z.object({
|
|
|
19046
19007
|
function validateManagedReadinessLedger(value) {
|
|
19047
19008
|
return managedReadinessLedgerSchema.parse(value);
|
|
19048
19009
|
}
|
|
19049
|
-
|
|
19050
|
-
//#region src/pr-readiness/review-requiredness.ts
|
|
19010
|
+
// src/pr-readiness/review-requiredness.ts
|
|
19051
19011
|
const proofInputs = (input, epoch) => {
|
|
19052
19012
|
const current = {
|
|
19053
19013
|
headSha: input.headSha,
|
|
@@ -19121,8 +19081,7 @@ const resolveReviewRequiredness = (input) => {
|
|
|
19121
19081
|
gateCapMismatchBlockers: gateCapMismatchBlockers(evaluation)
|
|
19122
19082
|
};
|
|
19123
19083
|
};
|
|
19124
|
-
|
|
19125
|
-
//#region src/pr-readiness/readiness-evaluation.ts
|
|
19084
|
+
// src/pr-readiness/readiness-evaluation.ts
|
|
19126
19085
|
var readiness_evaluation_exports = /* @__PURE__ */ __exportAll({
|
|
19127
19086
|
CORRECTNESS_UNTYPED_REVIEW_BLOCKER_REASON: () => CORRECTNESS_UNTYPED_REVIEW_BLOCKER_REASON,
|
|
19128
19087
|
DRAFT_BLOCKER_REASON: () => DRAFT_BLOCKER_REASON,
|
|
@@ -19465,12 +19424,13 @@ const waveRungBlockers = (input) => {
|
|
|
19465
19424
|
if (!demanded) return [];
|
|
19466
19425
|
return demandedRungSatisfactionReasons({
|
|
19467
19426
|
demandedRung: demanded.review,
|
|
19468
|
-
reviewRuns: input.reviewProof
|
|
19427
|
+
reviewRuns: currentRoundReviewRuns(input.reviewProof)
|
|
19469
19428
|
}).map((reason) => ({
|
|
19470
19429
|
demand: reviewRungDemand(demanded.review),
|
|
19471
19430
|
reason
|
|
19472
19431
|
}));
|
|
19473
19432
|
};
|
|
19433
|
+
const currentRoundReviewRuns = (proof) => proof && [...proof.reviews, ...(proof.ladder?.cycles ?? []).filter((cycle) => cycle.historical !== true && cycle.identity?.patchId === proof.patchId).flatMap((cycle) => cycle.verdicts ?? [])];
|
|
19474
19434
|
const mergeFreezeBlockers = (input) => (input.mergeFreeze?.blockingReasons ?? []).map((reason) => ({
|
|
19475
19435
|
demand: DEMAND_KEYS.mergeFreeze,
|
|
19476
19436
|
reason
|
|
@@ -19577,34 +19537,35 @@ const evaluateReadiness = (input) => {
|
|
|
19577
19537
|
});
|
|
19578
19538
|
const { ledgerVerification, prVerifyStatus } = verifyGate;
|
|
19579
19539
|
const requiredChecks = requiredChecksEvaluation(input);
|
|
19540
|
+
const resolvedBlockers = [
|
|
19541
|
+
...collectBlockers({
|
|
19542
|
+
correctnessRequired,
|
|
19543
|
+
correctnessStatus,
|
|
19544
|
+
correctnessUntyped,
|
|
19545
|
+
input,
|
|
19546
|
+
prVerifyStatus,
|
|
19547
|
+
securityRequired,
|
|
19548
|
+
securityStatus,
|
|
19549
|
+
securityUntyped,
|
|
19550
|
+
verificationProof: verifyGate.verification.verificationProof
|
|
19551
|
+
}),
|
|
19552
|
+
...requiredChecks.blockers,
|
|
19553
|
+
...(catchUpRecognition ? [] : input.policyIdentityRefusals ?? []).map((reason) => ({
|
|
19554
|
+
demand: DEMAND_KEYS.policyIdentity,
|
|
19555
|
+
reason
|
|
19556
|
+
})),
|
|
19557
|
+
...catchUpRecognition ? [] : reviewRoundLimitBlockers(input),
|
|
19558
|
+
...gateCapMismatchBlockers.map((blocker) => ({
|
|
19559
|
+
demand: DEMAND_KEYS.reviewLadder,
|
|
19560
|
+
reason: blocker.reason
|
|
19561
|
+
})),
|
|
19562
|
+
...waveRungBlockers(input),
|
|
19563
|
+
...armedWithoutBoundaryBlockers(input),
|
|
19564
|
+
...mergeFreezeBlockers(input),
|
|
19565
|
+
...exactHeadRunBlockers(input)
|
|
19566
|
+
];
|
|
19580
19567
|
const { blockers, waivedDemands } = foldWaivers({
|
|
19581
|
-
blockers:
|
|
19582
|
-
...collectBlockers({
|
|
19583
|
-
correctnessRequired,
|
|
19584
|
-
correctnessStatus,
|
|
19585
|
-
correctnessUntyped,
|
|
19586
|
-
input,
|
|
19587
|
-
prVerifyStatus,
|
|
19588
|
-
securityRequired,
|
|
19589
|
-
securityStatus,
|
|
19590
|
-
securityUntyped,
|
|
19591
|
-
verificationProof: verifyGate.verification.verificationProof
|
|
19592
|
-
}),
|
|
19593
|
-
...requiredChecks.blockers,
|
|
19594
|
-
...(catchUpRecognition ? [] : input.policyIdentityRefusals ?? []).map((reason) => ({
|
|
19595
|
-
demand: DEMAND_KEYS.policyIdentity,
|
|
19596
|
-
reason
|
|
19597
|
-
})),
|
|
19598
|
-
...catchUpRecognition ? [] : reviewRoundLimitBlockers(input),
|
|
19599
|
-
...gateCapMismatchBlockers.map((blocker) => ({
|
|
19600
|
-
demand: DEMAND_KEYS.reviewLadder,
|
|
19601
|
-
reason: blocker.reason
|
|
19602
|
-
})),
|
|
19603
|
-
...waveRungBlockers(input),
|
|
19604
|
-
...armedWithoutBoundaryBlockers(input),
|
|
19605
|
-
...mergeFreezeBlockers(input),
|
|
19606
|
-
...exactHeadRunBlockers(input)
|
|
19607
|
-
],
|
|
19568
|
+
blockers: resolvedBlockers,
|
|
19608
19569
|
waivers: input.waivers ?? []
|
|
19609
19570
|
});
|
|
19610
19571
|
const notices = [
|
|
@@ -19696,8 +19657,7 @@ const evaluateReadiness = (input) => {
|
|
|
19696
19657
|
waivedDemands
|
|
19697
19658
|
};
|
|
19698
19659
|
};
|
|
19699
|
-
|
|
19700
|
-
//#region src/github-pr-status-comment.ts
|
|
19660
|
+
// src/github-pr-status-comment.ts
|
|
19701
19661
|
const FACTORY_PR_STATUS_COMMENT_MARKER = "<!-- patronage-factory-pr-status-hud -->";
|
|
19702
19662
|
const OBSERVED_MARKER_PREFIX = "<!-- patronage-factory-pr-status-observed:";
|
|
19703
19663
|
const OBSERVED_MARKER_SUFFIX = " -->";
|
|
@@ -19827,12 +19787,16 @@ const reconcileManagedComments = async (exchange, input, comments, incomingBody)
|
|
|
19827
19787
|
const attemptUpsert = async (exchange, input, writtenBody, attempt) => {
|
|
19828
19788
|
if (attempt >= UPSERT_ATTEMPT_LIMIT) throw new Error("PR status HUD upsert exhausted attempts without a single current comment.");
|
|
19829
19789
|
const managed = await listManagedComments(exchange, input);
|
|
19830
|
-
if (managed.length > 1)
|
|
19790
|
+
if (managed.length > 1) {
|
|
19791
|
+
const keeper = await reconcileManagedComments(exchange, input, managed, writtenBody);
|
|
19792
|
+
return resultFrom("updated", keeper);
|
|
19793
|
+
}
|
|
19831
19794
|
const [existing] = managed;
|
|
19832
19795
|
if (existing) try {
|
|
19833
19796
|
const fresh = await readComment(exchange, input, existing.id);
|
|
19834
19797
|
if (existingIsCurrentOrNewer(fresh.body, input.observedAt)) return resultFrom("updated", fresh);
|
|
19835
|
-
|
|
19798
|
+
const updated = await patchManaged(exchange, input, existing.id, writtenBody);
|
|
19799
|
+
return resultFrom("updated", updated);
|
|
19836
19800
|
} catch (error) {
|
|
19837
19801
|
if (isRetryableMutation(error)) return attemptUpsert(exchange, input, writtenBody, attempt + 1);
|
|
19838
19802
|
throw error;
|
|
@@ -19858,10 +19822,11 @@ const attemptUpsert = async (exchange, input, writtenBody, attempt) => {
|
|
|
19858
19822
|
}
|
|
19859
19823
|
};
|
|
19860
19824
|
async function upsertFactoryPrStatusComment(input, dependencies = {}) {
|
|
19861
|
-
|
|
19825
|
+
const exchange = exchangeFor(dependencies);
|
|
19826
|
+
const writtenBody = managedBody(input.body, input.observedAt);
|
|
19827
|
+
return attemptUpsert(exchange, input, writtenBody, 0);
|
|
19862
19828
|
}
|
|
19863
|
-
|
|
19864
|
-
//#region src/preview-lifecycle.ts
|
|
19829
|
+
// src/preview-lifecycle.ts
|
|
19865
19830
|
const previewTargetPlanSchema = z.object({
|
|
19866
19831
|
basis: z.string(),
|
|
19867
19832
|
disposition: z.enum(["deploy", "not-required"]),
|
|
@@ -19940,8 +19905,7 @@ const planPreviewLifecycle = ({ candidate, profile, proof, vetoedTargets }) => {
|
|
|
19940
19905
|
targets
|
|
19941
19906
|
};
|
|
19942
19907
|
};
|
|
19943
|
-
|
|
19944
|
-
//#region src/pr-status-hud.ts
|
|
19908
|
+
// src/pr-status-hud.ts
|
|
19945
19909
|
const statusLabel = (status) => {
|
|
19946
19910
|
return `${{
|
|
19947
19911
|
Failed: "❌",
|
|
@@ -20206,6 +20170,19 @@ const newestSnapshot = (name, generations) => {
|
|
|
20206
20170
|
};
|
|
20207
20171
|
const completedSnapshot = (name, sha, runs) => newestSnapshot(name, factoryGenerations(name, sha, runs));
|
|
20208
20172
|
const MERGE_FREEZE_CHECK = "patronage-factory/merge-freeze";
|
|
20173
|
+
/** A red freeze row for a run readiness refuses to read. */
|
|
20174
|
+
const refusedFreezeSnapshot = (run, sha, refusal) => {
|
|
20175
|
+
const at = run.completed_at ?? run.started_at;
|
|
20176
|
+
if (!at) throw new Error(`${MERGE_FREEZE_CHECK} presentation snapshot has a refused run with no usable timestamp.`);
|
|
20177
|
+
return {
|
|
20178
|
+
completedAt: at,
|
|
20179
|
+
conclusion: run.conclusion ?? run.status,
|
|
20180
|
+
...run.details_url ? { detailsUrl: run.details_url } : {},
|
|
20181
|
+
headSha: sha,
|
|
20182
|
+
name: MERGE_FREEZE_CHECK,
|
|
20183
|
+
refusal
|
|
20184
|
+
};
|
|
20185
|
+
};
|
|
20209
20186
|
/**
|
|
20210
20187
|
* The merge-freeze row shows the generation readiness reads (#1501), chosen by
|
|
20211
20188
|
* the freeze's own selection rather than a second copy of it. That selection
|
|
@@ -20218,11 +20195,12 @@ const MERGE_FREEZE_CHECK = "patronage-factory/merge-freeze";
|
|
|
20218
20195
|
* pinned Factory App did not write refuses the whole read, as it does in the
|
|
20219
20196
|
* reader (#1393): filtering it out could let an older generation win. So does
|
|
20220
20197
|
* any listed run the reader cannot parse, such as an older one concluded
|
|
20221
|
-
* `cancelled` (#1550). A newest payload the selection cannot parse,
|
|
20222
|
-
* that contradicts its own check run,
|
|
20198
|
+
* `cancelled` (#1550). A newest payload the selection cannot parse, one
|
|
20199
|
+
* that contradicts its own check run, or two newest generations that share a
|
|
20200
|
+
* start (#1557) is unreadable.
|
|
20223
20201
|
*
|
|
20224
20202
|
* Otherwise the row is the newest completed snapshot, as for every other check:
|
|
20225
|
-
* running
|
|
20203
|
+
* running and missing generations present as before. Every case
|
|
20226
20204
|
* where the freeze stays fail-closed keeps the row red. The HUD is advisory and
|
|
20227
20205
|
* never gates.
|
|
20228
20206
|
*/
|
|
@@ -20230,19 +20208,12 @@ const mergeFreezeSnapshot = (sha, runs) => {
|
|
|
20230
20208
|
const foreign = runs.find((run) => !writtenByFactoryApp(run));
|
|
20231
20209
|
const unparseable = runs.find((run) => !isReadableMergeFreezeListedRun(run));
|
|
20232
20210
|
const refusing = foreign ?? unparseable;
|
|
20233
|
-
if (refusing) {
|
|
20234
|
-
const at = refusing.completed_at ?? refusing.started_at;
|
|
20235
|
-
if (!at) throw new Error(`${MERGE_FREEZE_CHECK} presentation snapshot has a refused run with no usable timestamp.`);
|
|
20236
|
-
return {
|
|
20237
|
-
completedAt: at,
|
|
20238
|
-
conclusion: refusing.conclusion ?? refusing.status,
|
|
20239
|
-
...refusing.details_url ? { detailsUrl: refusing.details_url } : {},
|
|
20240
|
-
headSha: sha,
|
|
20241
|
-
name: MERGE_FREEZE_CHECK,
|
|
20242
|
-
refusal: foreign ? `refused: run ${String(foreign.id)} was not written by the Factory App` : `refused: run ${String(refusing.id)} cannot be read`
|
|
20243
|
-
};
|
|
20244
|
-
}
|
|
20211
|
+
if (refusing) return refusedFreezeSnapshot(refusing, sha, foreign ? `refused: run ${String(foreign.id)} was not written by the Factory App` : `refused: run ${String(refusing.id)} cannot be read`);
|
|
20245
20212
|
const generations = factoryGenerations(MERGE_FREEZE_CHECK, sha, runs);
|
|
20213
|
+
const newestStart = Math.max(...generations.map((run) => generationOrderMs(run.started_at)));
|
|
20214
|
+
const tied = generations.filter((run) => generationOrderMs(run.started_at) === newestStart).toSorted((a, b) => b.id - a.id);
|
|
20215
|
+
const [highestTied] = tied;
|
|
20216
|
+
if (tied.length > 1 && highestTied) return refusedFreezeSnapshot(highestTied, sha, "unreadable newest payload");
|
|
20246
20217
|
const newest = newestSnapshot(MERGE_FREEZE_CHECK, generations);
|
|
20247
20218
|
if (!newest) return newest;
|
|
20248
20219
|
const unreadable = {
|
|
@@ -20261,7 +20232,7 @@ const mergeFreezeSnapshot = (sha, runs) => {
|
|
|
20261
20232
|
return unreadable;
|
|
20262
20233
|
}
|
|
20263
20234
|
};
|
|
20264
|
-
const FAILED_PREVIEW_CONCLUSIONS = new Set([
|
|
20235
|
+
const FAILED_PREVIEW_CONCLUSIONS = /* @__PURE__ */ new Set([
|
|
20265
20236
|
"action_required",
|
|
20266
20237
|
"cancelled",
|
|
20267
20238
|
"failure",
|
|
@@ -20439,8 +20410,7 @@ async function refreshFactoryPrStatusHudSafely(input, onNotice = (message) => {
|
|
|
20439
20410
|
onNotice(`PR status HUD refresh failed without affecting the gate: ${error instanceof Error ? error.message : String(error)}`);
|
|
20440
20411
|
}
|
|
20441
20412
|
}
|
|
20442
|
-
|
|
20443
|
-
//#region src/pr-ready.ts
|
|
20413
|
+
// src/pr-ready.ts
|
|
20444
20414
|
const CHECK_CONCLUSION_BY_READINESS_STATUS = {
|
|
20445
20415
|
blocked: "failure",
|
|
20446
20416
|
ready: "success"
|
|
@@ -20678,8 +20648,6 @@ function canResolveCommit(cwd, sha) {
|
|
|
20678
20648
|
return false;
|
|
20679
20649
|
}
|
|
20680
20650
|
}
|
|
20681
|
-
/** The label that keeps an admitted pull request attended (#1299). */
|
|
20682
|
-
const FACTORY_HOLD_LABEL = "factory:hold";
|
|
20683
20651
|
const EPIC_LABEL = "epic";
|
|
20684
20652
|
const labelNamesSchema = z.object({ nodes: z.array(z.object({ name: z.string() })) }).transform(({ nodes }) => nodes.map((node) => node.name));
|
|
20685
20653
|
const issueParentSchema = z.object({
|
|
@@ -20869,7 +20837,7 @@ const standaloneMembership = async ({ bodyIssues, readFacts, readParent }) => {
|
|
|
20869
20837
|
const armingWithheldNotice = ({ facts, liveEnablement, membership }) => {
|
|
20870
20838
|
if (!facts.ok) return `Native auto-merge was not armed: pr:ready could not read the repository's auto-merge setting or the labels and closing issues of this pull request. ${facts.detail} Re-run pr:ready when GitHub answers.`;
|
|
20871
20839
|
if (!facts.value.autoMergeAllowed) return "Native auto-merge was not armed: this repository does not allow auto-merge (GitHub's \"Allow auto-merge\" setting is off). The candidate is admitted and stays attended by repository policy. This is not a failure.";
|
|
20872
|
-
if (hasLabel(facts.value.labels,
|
|
20840
|
+
if (hasLabel(facts.value.labels, "factory:hold")) return liveEnablement ? `This pull request carries the ${FACTORY_HOLD_LABEL} label, so pr:ready did not arm it, but GitHub already has auto-merge on for it. The label does not turn auto-merge off: GitHub still merges it when its required checks are green. To hold it for a person, turn off auto-merge on the pull request.` : `Native auto-merge was not armed: this pull request carries the ${FACTORY_HOLD_LABEL} label, so it is admitted and held for a person. To arm it, remove the label and re-run pr:ready.`;
|
|
20873
20841
|
if (membership?.kind === "member") return `Native auto-merge was not armed: this pull request closes #${membership.issue}, a sub-issue of open epic #${membership.parent}, and the boundary manifest of that epic governs its members. Re-run pr:ready --epic ${membership.parent} so its wave decides.`;
|
|
20874
20842
|
if (membership?.kind === "unreadable") return `Native auto-merge was not armed: pr:ready could not read the sub-issue parent of ${membership.issue === void 0 ? "the issues this pull request closes" : `#${membership.issue}`}, so it cannot tell whether a boundary manifest governs this pull request. ${membership.detail} Re-run pr:ready when GitHub answers, or with --epic <issue> when an epic governs it.`;
|
|
20875
20843
|
};
|
|
@@ -21064,6 +21032,12 @@ async function runPrReady(args, dependencies = {}) {
|
|
|
21064
21032
|
});
|
|
21065
21033
|
};
|
|
21066
21034
|
try {
|
|
21035
|
+
if (args.hold) await (dependencies.holdPullRequest ?? holdPullRequest)({
|
|
21036
|
+
cwd,
|
|
21037
|
+
owner: repository.owner,
|
|
21038
|
+
pr: args.pr,
|
|
21039
|
+
repo: repository.name
|
|
21040
|
+
});
|
|
21067
21041
|
const pr = await withAdmissionReadRetry((extraEnv) => fetchPullRequestWithMergeablePoll({
|
|
21068
21042
|
fetch: () => github.fetchPullRequest({
|
|
21069
21043
|
owner: repository.owner,
|
|
@@ -21389,8 +21363,7 @@ async function runPrReady(args, dependencies = {}) {
|
|
|
21389
21363
|
throw error;
|
|
21390
21364
|
}
|
|
21391
21365
|
}
|
|
21392
|
-
|
|
21393
|
-
//#region src/pr-review-gate-trace.ts
|
|
21366
|
+
// src/pr-review-gate-trace.ts
|
|
21394
21367
|
const eventTime$1 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
21395
21368
|
const buildReviewGateNotRequiredTraceEvent = ({ createdAt = eventTime$1(), identity, proof }) => ReviewGateTraceEventSchema.parse({
|
|
21396
21369
|
base: proof.base,
|
|
@@ -21426,8 +21399,7 @@ const tryAppendReviewGateNotRequiredTraceEvent = ({ identity, proof, repoRoot })
|
|
|
21426
21399
|
};
|
|
21427
21400
|
}
|
|
21428
21401
|
};
|
|
21429
|
-
|
|
21430
|
-
//#region src/review-fault-injection.ts
|
|
21402
|
+
// src/review-fault-injection.ts
|
|
21431
21403
|
const REVIEW_FAULT_ENV = "FACTORY_REVIEW_FAULT";
|
|
21432
21404
|
const REVIEW_FAULT_POINTS = [
|
|
21433
21405
|
"after-retain",
|
|
@@ -21458,8 +21430,7 @@ const resolveReviewFault = ({ allowFaultInjection = false, env = process.env } =
|
|
|
21458
21430
|
const faultAt = (injected, point) => {
|
|
21459
21431
|
if (injected === point) throw new InjectedReviewFaultError(point);
|
|
21460
21432
|
};
|
|
21461
|
-
|
|
21462
|
-
//#region src/review-findings-retention.ts
|
|
21433
|
+
// src/review-findings-retention.ts
|
|
21463
21434
|
const REVIEW_FINDINGS_RETENTION_DIR = ".factory-memory/review-findings";
|
|
21464
21435
|
const retainReviewBytes = ({ bytes, cwd, directory: relativeDirectory = REVIEW_FINDINGS_RETENTION_DIR }) => {
|
|
21465
21436
|
const digest = sha256Hex(bytes);
|
|
@@ -21491,8 +21462,7 @@ const retainReviewBytes = ({ bytes, cwd, directory: relativeDirectory = REVIEW_F
|
|
|
21491
21462
|
path: target
|
|
21492
21463
|
};
|
|
21493
21464
|
};
|
|
21494
|
-
|
|
21495
|
-
//#region src/issue-body-sections.ts
|
|
21465
|
+
// src/issue-body-sections.ts
|
|
21496
21466
|
const HEADING_PATTERN = /^#{2,6}\s+(?<title>.+?)\s*$/u;
|
|
21497
21467
|
const FENCE_PATTERN = /^\s*(?<fence>`{3,}|~{3,})(?<rest>.*)$/u;
|
|
21498
21468
|
/**
|
|
@@ -21537,14 +21507,12 @@ const sectionBody = (body, heading) => {
|
|
|
21537
21507
|
if (startIndex === -1) return;
|
|
21538
21508
|
return lines.slice(startIndex + 1).join("\n").trim();
|
|
21539
21509
|
};
|
|
21540
|
-
|
|
21541
|
-
//#region src/review-focus.ts
|
|
21510
|
+
// src/review-focus.ts
|
|
21542
21511
|
const REVIEW_FOCUS_SECTION = "Review focus";
|
|
21543
21512
|
const reviewFocusFromIssueBody = (body) => {
|
|
21544
21513
|
return sectionBody(body, "Review focus") || void 0;
|
|
21545
21514
|
};
|
|
21546
|
-
|
|
21547
|
-
//#region src/review-ladder-trace.ts
|
|
21515
|
+
// src/review-ladder-trace.ts
|
|
21548
21516
|
const eventTime = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
21549
21517
|
const buildReviewLadderStageTraceEvent = ({ createdAt = eventTime(), event, headSha, identity, patchId }) => {
|
|
21550
21518
|
const trace = {
|
|
@@ -21596,14 +21564,13 @@ const tryAppendReviewLadderStageTraceEvent = (input) => {
|
|
|
21596
21564
|
};
|
|
21597
21565
|
}
|
|
21598
21566
|
};
|
|
21599
|
-
|
|
21600
|
-
//#region src/review-lineage.ts
|
|
21567
|
+
// src/review-lineage.ts
|
|
21601
21568
|
const isReviewLineageContinuous = (prior, current, isAncestor) => prior.base === current.base && (prior.headSha === current.headSha || isAncestor(prior.headSha, current.headSha));
|
|
21602
|
-
|
|
21603
|
-
//#region src/review-policy-declarations.ts
|
|
21569
|
+
// src/review-policy-declarations.ts
|
|
21604
21570
|
const identityRepeatDeclarations = (occurrences, cycleIndex) => occurrences.flatMap((occurrence) => {
|
|
21605
21571
|
if (cycleOfAddress(occurrence.address) !== cycleIndex || occurrence.root === occurrence.address) return [];
|
|
21606
|
-
const
|
|
21572
|
+
const earlier = occurrences.filter((member) => member.root === occurrence.root && cycleOfAddress(member.address) < cycleIndex);
|
|
21573
|
+
const disposition = IDENTITY_REPEAT_DISPOSITION[projectedGroupDisposition(earlier)];
|
|
21607
21574
|
return disposition === void 0 ? [] : [{
|
|
21608
21575
|
authority: "policy",
|
|
21609
21576
|
disposition,
|
|
@@ -21623,8 +21590,7 @@ const severityFloorDeclarations = (occurrences, liveCycleCount) => {
|
|
|
21623
21590
|
}] : [];
|
|
21624
21591
|
});
|
|
21625
21592
|
};
|
|
21626
|
-
|
|
21627
|
-
//#region src/review-ladder-proof.ts
|
|
21593
|
+
// src/review-ladder-proof.ts
|
|
21628
21594
|
const priorLadderStateFor = ({ base, headSha, isAncestor, prior }) => {
|
|
21629
21595
|
if (!prior?.ladder) return;
|
|
21630
21596
|
return isReviewLineageContinuous({
|
|
@@ -21688,7 +21654,11 @@ function ladderStateForRun({ historical, identity, model, policy, priorLadder, r
|
|
|
21688
21654
|
model,
|
|
21689
21655
|
recording: record,
|
|
21690
21656
|
stage: "gate",
|
|
21691
|
-
...Object.keys(session).length > 0 ? { session } : {}
|
|
21657
|
+
...Object.keys(session).length > 0 ? { session } : {},
|
|
21658
|
+
verdicts: runs.map(({ review }) => ({
|
|
21659
|
+
outcome: review.outcome,
|
|
21660
|
+
...review.rung === void 0 ? {} : { rung: review.rung }
|
|
21661
|
+
}))
|
|
21692
21662
|
};
|
|
21693
21663
|
};
|
|
21694
21664
|
const explicit = recording.declarations;
|
|
@@ -21723,8 +21693,7 @@ function emitLadderStageTrace({ cwd, evaluation, headSha, issue, patchId, profil
|
|
|
21723
21693
|
if (traceResult.ok) console.error(`review-ladder-stage trace event appended to ${traceResult.filePath}`);
|
|
21724
21694
|
else console.error(`review-ladder-stage trace event not written: ${traceResult.errorMessage}`);
|
|
21725
21695
|
}
|
|
21726
|
-
|
|
21727
|
-
//#region src/review-contract.ts
|
|
21696
|
+
// src/review-contract.ts
|
|
21728
21697
|
const SESSION_ID_RULE = `"sessionId" is this review session's own id. It must differ from the authoring session id the candidate was verified under (FACTORY_SESSION_ID): pr:review --findings refuses a findings file whose sessionId equals the authoring session.`;
|
|
21729
21698
|
const authorityRule = (waveRung) => waveRung === void 0 ? `Emit schemaVersion 1 and omit "producer" and "rung": this candidate resolves no boundary-wave review rung. If your dispatch instructions do name a rung, emit schemaVersion 3 with that rung and with "producer" instead. "resolutions" is accepted at every schemaVersion: when the prior-review ledger below shows an open occurrence you verified fixed, add "resolutions": [{"target": "<its address, for example c1f1>", "reference": "<the commit or the verified fix>"}]; silence is not resolution, and an occurrence you do not name stays open.` : `This candidate belongs to a boundary wave that demands the ${waveRung} review rung, so schemaVersion 3 is required. Record "rung": "${waveRung}" exactly as shown, and set "producer" to the engine and model that ran this review (for example "codex-cli/gpt-5.6-sol"). Findings without both fields are recorded without authority, and pr:publish then refuses with "no passing review at that authority". "resolutions" is optional: when the prior-review ledger below shows an open occurrence you verified fixed, name it by its address (for example "c1f1") with a reference; silence is not resolution, and an occurrence you do not name stays open.`;
|
|
21730
21699
|
/**
|
|
@@ -21741,8 +21710,7 @@ ${authorityRule(waveRung)}
|
|
|
21741
21710
|
${SESSION_ID_RULE}
|
|
21742
21711
|
Use category "correctness", "safety", "coordination", or "maintainability"; set blockingAfterCap true for correctness, safety, or coordination findings. citedSpan must be the exact code text the finding is about, quoted verbatim from the diff (identity is derived from this, not from the title, so quote precisely). prescribedAction must be a concise, standalone statement of the required fix (identity is derived from this text too).`;
|
|
21743
21712
|
};
|
|
21744
|
-
|
|
21745
|
-
//#region src/review-prompt.ts
|
|
21713
|
+
// src/review-prompt.ts
|
|
21746
21714
|
const reviewScope = ({ base, changedFiles: files, headSha, patchId, profile, waveRung }) => `Review scope:
|
|
21747
21715
|
- Repository: ${profile.repository.owner}/${profile.repository.name}
|
|
21748
21716
|
- Base ref: ${base}
|
|
@@ -21840,13 +21808,14 @@ Open occurrences above are unadjudicated: each still needs a disposition. If you
|
|
|
21840
21808
|
});
|
|
21841
21809
|
const assembleReviewPrompt = ({ base, changedFiles, cwd = process.cwd(), headSha, issueFocus, kind, patchId, priorLedgerEntries, profile, waveRung }, dependencies = {}) => {
|
|
21842
21810
|
const priorLedger = priorLedgerEntries ?? [];
|
|
21811
|
+
const codingStandards = kind === "correctness" ? readCodingStandardsAtHead({
|
|
21812
|
+
cwd,
|
|
21813
|
+
git: dependencies.git,
|
|
21814
|
+
headSha
|
|
21815
|
+
}) : void 0;
|
|
21843
21816
|
const optionalSegments = {
|
|
21844
21817
|
"coding-standards": codingStandardsSegment({
|
|
21845
|
-
contents:
|
|
21846
|
-
cwd,
|
|
21847
|
-
git: dependencies.git,
|
|
21848
|
-
headSha
|
|
21849
|
-
}) : void 0,
|
|
21818
|
+
contents: codingStandards,
|
|
21850
21819
|
headSha
|
|
21851
21820
|
}),
|
|
21852
21821
|
"issue-review-focus": issueFocus ? issueFocusSegment(issueFocus) : void 0,
|
|
@@ -21872,8 +21841,7 @@ const assembleReviewPrompt = ({ base, changedFiles, cwd = process.cwd(), headSha
|
|
|
21872
21841
|
sections: segments.flatMap((segment) => segment.section ? [segment.section] : [])
|
|
21873
21842
|
};
|
|
21874
21843
|
};
|
|
21875
|
-
|
|
21876
|
-
//#region src/review-recording-id.ts
|
|
21844
|
+
// src/review-recording-id.ts
|
|
21877
21845
|
const lengthPrefixed = (field) => `${Buffer.byteLength(field, "utf-8")}:${field}`;
|
|
21878
21846
|
const reviewRecordingId = ({ baseSha, dispositionsBytes, findingsBytes, historical, model, patchId, producer, rung, sessionId }) => sha256Hex([
|
|
21879
21847
|
patchId,
|
|
@@ -21886,8 +21854,7 @@ const reviewRecordingId = ({ baseSha, dispositionsBytes, findingsBytes, historic
|
|
|
21886
21854
|
sha256Hex(findingsBytes),
|
|
21887
21855
|
sha256Hex(dispositionsBytes ?? "")
|
|
21888
21856
|
].map((field) => lengthPrefixed(field)).join(""));
|
|
21889
|
-
|
|
21890
|
-
//#region src/pr-review.ts
|
|
21857
|
+
// src/pr-review.ts
|
|
21891
21858
|
const DEFAULT_ASSEMBLED_REVIEW_PROMPT_PATH = ".factory-memory/pr-review-prompt.json";
|
|
21892
21859
|
const MISSING_ASSEMBLED_PROMPT_NOTICE = "pr:review notice: assembled review prompt not found at .factory-memory/pr-review-prompt.json; accepting findings without promptSections.";
|
|
21893
21860
|
const STALE_ASSEMBLED_PROMPT_NOTICE = "pr:review notice: assembled review prompt patch-id does not match the candidate; accepting findings without promptSections.";
|
|
@@ -21926,7 +21893,8 @@ const defaultPrReviewGit = () => ({
|
|
|
21926
21893
|
* a real reader will run; off a Cursor VM `gh` is unchanged.
|
|
21927
21894
|
*/
|
|
21928
21895
|
const assembleIssueReads = async ({ args, dependencies, profile }) => {
|
|
21929
|
-
const
|
|
21896
|
+
const needsRealRead = (args.issue !== void 0 || args.epic !== void 0) && (dependencies.fetchIssueBody === void 0 || args.epic !== void 0 && dependencies.fetchClosingPullRequests === void 0);
|
|
21897
|
+
const real = githubWaveDemandReads(needsRealRead ? await (dependencies.admission ?? processAdmissionCredential).ghEnv("read-issue", {
|
|
21930
21898
|
owner: profile.repository.owner,
|
|
21931
21899
|
repo: profile.repository.name
|
|
21932
21900
|
}) : void 0);
|
|
@@ -22003,10 +21971,10 @@ const assertReviewCycleInWindow = (cycle, maxCycles) => {
|
|
|
22003
21971
|
*/
|
|
22004
21972
|
function enabledKinds(profile, mode, files = [], suppliedFindingsKinds = [], demandedKinds = []) {
|
|
22005
21973
|
const demanded = new Set(demandedKinds);
|
|
22006
|
-
const profileModes = new Set(["correctness", ...(profile.review?.conditional?.length ?? 0) > 0 || demanded.has("security") ? ["security"] : []]);
|
|
21974
|
+
const profileModes = /* @__PURE__ */ new Set(["correctness", ...(profile.review?.conditional?.length ?? 0) > 0 || demanded.has("security") ? ["security"] : []]);
|
|
22007
21975
|
const configuredKinds = (mode === "all" ? [...profileModes] : [mode]).filter((kind) => profileModes.has(kind));
|
|
22008
21976
|
if (configuredKinds.length === 0) throw new Error(`No configured review mode matches ${mode}.`);
|
|
22009
|
-
const applicableKinds = new Set([...resolveApplicableReviewModes(profile, files), ...demanded]);
|
|
21977
|
+
const applicableKinds = /* @__PURE__ */ new Set([...resolveApplicableReviewModes(profile, files), ...demanded]);
|
|
22010
21978
|
const suppliedKinds = new Set(suppliedFindingsKinds);
|
|
22011
21979
|
return configuredKinds.filter((kind) => applicableKinds.has(kind) || suppliedKinds.has(kind));
|
|
22012
21980
|
}
|
|
@@ -22273,7 +22241,8 @@ const assertAssembleMayPrepareReview = ({ args, base, cwd, git, headSha, output,
|
|
|
22273
22241
|
};
|
|
22274
22242
|
};
|
|
22275
22243
|
const promptSectionsFromAssembledArtifact = ({ cwd, patchId }) => {
|
|
22276
|
-
const
|
|
22244
|
+
const artifactPath = path.resolve(cwd, DEFAULT_ASSEMBLED_REVIEW_PROMPT_PATH);
|
|
22245
|
+
const read = readAssembledReviewPrompt(artifactPath);
|
|
22277
22246
|
if (read.status === "missing") {
|
|
22278
22247
|
console.error(MISSING_ASSEMBLED_PROMPT_NOTICE);
|
|
22279
22248
|
return;
|
|
@@ -22902,8 +22871,7 @@ async function runPrReview(args, dependencies = {}) {
|
|
|
22902
22871
|
assertReviewOutcomes(recorded.proof, ladderPolicy, args.cycle, maxCycles);
|
|
22903
22872
|
return recorded.proof;
|
|
22904
22873
|
}
|
|
22905
|
-
|
|
22906
|
-
//#region src/pull-request-fill.ts
|
|
22874
|
+
// src/pull-request-fill.ts
|
|
22907
22875
|
const FIELD_SEPARATOR = "";
|
|
22908
22876
|
const RECORD_SEPARATOR = "";
|
|
22909
22877
|
/**
|
|
@@ -22946,8 +22914,7 @@ const pullRequestFill = (commits) => {
|
|
|
22946
22914
|
title: oldest.subject
|
|
22947
22915
|
};
|
|
22948
22916
|
};
|
|
22949
|
-
|
|
22950
|
-
//#region src/pr-publish.ts
|
|
22917
|
+
// src/pr-publish.ts
|
|
22951
22918
|
const defaultNow = () => /* @__PURE__ */ new Date();
|
|
22952
22919
|
var PrPublishFollowUpError = class extends Error {
|
|
22953
22920
|
result;
|
|
@@ -23274,6 +23241,7 @@ const producerPostStatus = async (post) => {
|
|
|
23274
23241
|
async function ensureVerifyProof({ args, cwd, dependencies, headSha, pr, verifyProofPath }) {
|
|
23275
23242
|
let declineReason = "no pr:verify proof was available to reuse";
|
|
23276
23243
|
if (typeof headSha === "string") {
|
|
23244
|
+
const files = (dependencies.git?.changedFiles ?? changedFiles)(cwd, args.base);
|
|
23277
23245
|
const applicability = resolveVerifyProofApplicability({
|
|
23278
23246
|
currentVerifyIdentityForBase: () => {
|
|
23279
23247
|
const selectedStablePatchId = dependencies.git?.stablePatchId ?? runStablePatchId;
|
|
@@ -23284,7 +23252,7 @@ async function ensureVerifyProof({ args, cwd, dependencies, headSha, pr, verifyP
|
|
|
23284
23252
|
}) };
|
|
23285
23253
|
},
|
|
23286
23254
|
explicitProof: false,
|
|
23287
|
-
files
|
|
23255
|
+
files,
|
|
23288
23256
|
headSha,
|
|
23289
23257
|
proofPath: verifyProofPath
|
|
23290
23258
|
});
|
|
@@ -23869,6 +23837,7 @@ async function runPrPublish(args, dependencies = {}) {
|
|
|
23869
23837
|
const prNumber = discovered.number;
|
|
23870
23838
|
const readyArgs = {
|
|
23871
23839
|
...args,
|
|
23840
|
+
hold: false,
|
|
23872
23841
|
pr: prNumber
|
|
23873
23842
|
};
|
|
23874
23843
|
const fetchPr = () => withAdmissionReadRetry((extraEnv) => github.fetchPullRequest({
|
|
@@ -23959,6 +23928,12 @@ async function runPrPublish(args, dependencies = {}) {
|
|
|
23959
23928
|
json: false,
|
|
23960
23929
|
report: false
|
|
23961
23930
|
};
|
|
23931
|
+
if (args.hold) await (dependencies.holdPullRequest ?? holdPullRequest)({
|
|
23932
|
+
cwd,
|
|
23933
|
+
owner: profile.repository.owner,
|
|
23934
|
+
pr: prNumber,
|
|
23935
|
+
repo: profile.repository.name
|
|
23936
|
+
});
|
|
23962
23937
|
const promotionStartedAt = promotionInstant(dependencies);
|
|
23963
23938
|
const promotion = await promoteDraftBeforeDemandEvaluation({
|
|
23964
23939
|
cwd,
|
|
@@ -24060,16 +24035,16 @@ async function deliverSpooledEvidence({ awaitPending, cwd, flush, profilePath })
|
|
|
24060
24035
|
process.stderr.write(`hq:flush advisory drain failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
24061
24036
|
}
|
|
24062
24037
|
}
|
|
24063
|
-
|
|
24064
|
-
//#region src/commands/pr-publish.ts
|
|
24038
|
+
// src/commands/pr-publish.ts
|
|
24065
24039
|
function createPrPublishCommand(_output, action = runPrPublish) {
|
|
24066
|
-
return markCwdOptionDefault(new Command("pr:publish").description("Promote a proved draft, then evaluate Candidate demands; never launches review").option("--pr <number>", "pull request number", positiveInteger$1("--pr")).option("--base <ref>", "local base Git ref assertion; origin/<branch> creates against GitHub <branch>").option("--authoring-session <id>", "known authoring session identity for verification retries").option("--cwd <path>", "working directory to evaluate", collectCwdOption).option("--epic <number>", "issue carrying the factory-boundary manifest, which may be the work issue itself; the composed readiness evaluation then applies the wave-demanded review rung (#351, #789)", positiveInteger$1("--epic")).option("--findings <path>", "clean-session findings to validate when no current review proof is available").option("--json", "print the publish result as JSON").option("--output <path>", "write readiness proof JSON to a file").option("--profile <path>", "path to the project profile JSON file").option("--review-proof <path>", "pr:review proof JSON path").option("--verify-proof <path>", "pr:verify proof JSON path").action(async (options) => {
|
|
24040
|
+
return markCwdOptionDefault(new Command("pr:publish").description("Promote a proved draft, then evaluate Candidate demands; never launches review").option("--pr <number>", "pull request number", positiveInteger$1("--pr")).option("--base <ref>", "local base Git ref assertion; origin/<branch> creates against GitHub <branch>").option("--authoring-session <id>", "known authoring session identity for verification retries").option("--cwd <path>", "working directory to evaluate", collectCwdOption).option("--epic <number>", "issue carrying the factory-boundary manifest, which may be the work issue itself; the composed readiness evaluation then applies the wave-demanded review rung (#351, #789)", positiveInteger$1("--epic")).option("--findings <path>", "clean-session findings to validate when no current review proof is available").option("--hold", "label the pull request factory:hold before promotion, so it is admitted and held for a person instead of armed (#1513)").option("--json", "print the publish result as JSON").option("--output <path>", "write readiness proof JSON to a file").option("--profile <path>", "path to the project profile JSON file").option("--review-proof <path>", "pr:review proof JSON path").option("--verify-proof <path>", "pr:verify proof JSON path").action(async (options) => {
|
|
24067
24041
|
await runPrPublishAction({
|
|
24068
24042
|
authoringSessionIds: options.authoringSession ? [options.authoringSession] : void 0,
|
|
24069
24043
|
base: options.base ?? "",
|
|
24070
24044
|
cwd: resolveCwdOption(options.cwd),
|
|
24071
24045
|
epic: options.epic,
|
|
24072
24046
|
findings: options.findings,
|
|
24047
|
+
...options.hold ? { hold: true } : {},
|
|
24073
24048
|
json: Boolean(options.json),
|
|
24074
24049
|
output: options.output,
|
|
24075
24050
|
pr: options.pr,
|
|
@@ -24079,10 +24054,9 @@ function createPrPublishCommand(_output, action = runPrPublish) {
|
|
|
24079
24054
|
}, action);
|
|
24080
24055
|
}));
|
|
24081
24056
|
}
|
|
24082
|
-
|
|
24083
|
-
//#region src/commands/pr-ready.ts
|
|
24057
|
+
// src/commands/pr-ready.ts
|
|
24084
24058
|
function createPrReadyCommand(output, action) {
|
|
24085
|
-
return markCwdOptionDefault(new Command("pr:ready").description("Evaluate typed proof and GitHub state for final readiness").requiredOption("--pr <number>", "pull request number", positiveInteger$1("--pr")).option("--base <ref>", "explicit base branch or ref override").option("--authoring-session <id...>", "recorded authoring session id(s) for review-type requiredCheck independence (ADR 0014)").option("--cwd <path>", "working directory to evaluate", collectCwdOption).option("--epic <number>", "issue carrying the factory-boundary manifest, which may be the work issue itself; readiness then evaluates the wave-demanded review rung (#351, #789)", positiveInteger$1("--epic")).option("--json", "print the readiness proof as JSON").option("--output <path>", "write proof JSON to a file").option("--profile <path>", "path to the project profile JSON file").option("--review-proof <path>", "pr:review proof JSON path").option("--verify-proof <path>", "pr:verify proof JSON path").action(withGateTiming({
|
|
24059
|
+
return markCwdOptionDefault(new Command("pr:ready").description("Evaluate typed proof and GitHub state for final readiness").requiredOption("--pr <number>", "pull request number", positiveInteger$1("--pr")).option("--base <ref>", "explicit base branch or ref override").option("--authoring-session <id...>", "recorded authoring session id(s) for review-type requiredCheck independence (ADR 0014)").option("--cwd <path>", "working directory to evaluate", collectCwdOption).option("--epic <number>", "issue carrying the factory-boundary manifest, which may be the work issue itself; readiness then evaluates the wave-demanded review rung (#351, #789)", positiveInteger$1("--epic")).option("--hold", "label the pull request factory:hold first, so an admitted candidate is held for a person instead of armed (#1513)").option("--json", "print the readiness proof as JSON").option("--output <path>", "write proof JSON to a file").option("--profile <path>", "path to the project profile JSON file").option("--review-proof <path>", "pr:review proof JSON path").option("--verify-proof <path>", "pr:verify proof JSON path").action(withGateTiming({
|
|
24086
24060
|
gate: "pr:ready",
|
|
24087
24061
|
resolveLedgerRoot: (options) => resolveCwdOption(options.cwd),
|
|
24088
24062
|
stderr: output.stderr
|
|
@@ -24092,6 +24066,7 @@ function createPrReadyCommand(output, action) {
|
|
|
24092
24066
|
base: options.base ?? "",
|
|
24093
24067
|
cwd: resolveCwdOption(options.cwd),
|
|
24094
24068
|
...options.epic === void 0 ? {} : { epic: options.epic },
|
|
24069
|
+
...options.hold ? { hold: true } : {},
|
|
24095
24070
|
json: Boolean(options.json),
|
|
24096
24071
|
output: options.output,
|
|
24097
24072
|
pr: options.pr,
|
|
@@ -24107,8 +24082,7 @@ function createPrReadyCommand(output, action) {
|
|
|
24107
24082
|
}
|
|
24108
24083
|
})));
|
|
24109
24084
|
}
|
|
24110
|
-
|
|
24111
|
-
//#region src/gate-foreground-guard.ts
|
|
24085
|
+
// src/gate-foreground-guard.ts
|
|
24112
24086
|
const GATE_BACKGROUND_ENV_MARKERS = ["FACTORY_GATE_BACKGROUND", "FACTORY_GATE_DETACHED"];
|
|
24113
24087
|
function isTruthyEnvFlag(value) {
|
|
24114
24088
|
if (value === void 0) return false;
|
|
@@ -24131,8 +24105,7 @@ function gateForegroundGuardMessage(gate) {
|
|
|
24131
24105
|
function assertForegroundGate({ gate, env = process.env }) {
|
|
24132
24106
|
if (classifyGateInvocation(env) === "detached") throw new GateForegroundGuardError(gateForegroundGuardMessage(gate));
|
|
24133
24107
|
}
|
|
24134
|
-
|
|
24135
|
-
//#region src/commands/pr-review.ts
|
|
24108
|
+
// src/commands/pr-review.ts
|
|
24136
24109
|
function createPrReviewCommand(output, action) {
|
|
24137
24110
|
return markCwdOptionDefault(new Command("pr:review").description("Assemble a factory-owned review prompt, or validate clean-session findings and write typed review proof").option("--base <ref>", "base ref to assert. With a pull request open for this branch its live base is the base and a disagreeing value is refused; without one, this ref (default origin/main) is fetched fresh and its SHA recorded").option("--cwd <path>", "working directory to review", collectCwdOption).option("--cycle <number>", "review cycle number", positiveInteger$1("--cycle"), 1).option("--mode <mode>", "correctness, security, or all", "all").option("--assemble", "write the factory-owned review prompt for a clean session; do not validate findings").option("--epic <number>", "issue carrying the factory-boundary manifest, which may be the work issue itself; --assemble then asks the reviewer for the findings schema the wave-demanded review rung accepts (#1001), and refuses while no pull request is open for the branch (#1245)", positiveInteger$1("--epic")).option("--findings <path>", "typed clean-session findings JSON file").option("--historical", "record findings that read an earlier commit on this branch: the cycle joins the ladder as prior history and renders no verdict of its own, so it never admits. It leaves the candidate's recorded verdict untouched. This recording may carry --dispositions for the findings it flags; otherwise declare them on the next cycle once they are persisted ledger entries").option("--dispositions <path>", "JSON file of ladder disposition declarations (waived / follow-up-filed / fixed-in-thread) for previously flagged findings, or for the findings a --historical recording itself flags").option("--issue <number>", "issue number recorded on the review ladder trace; --assemble also loads Review focus from this issue", positiveInteger$1("--issue")).option("--output <path>", "write proof JSON to a file").option("--allow-fault-injection", "test-only: honour FACTORY_REVIEW_FAULT (after-retain | proof-rename | after-proof-write) to interrupt the recording at that point and demonstrate that a retry resolves to already-recorded or a clean re-record (#1131)").option("--profile <path>", "path to the project profile JSON file").option("--verify-proof <path>", "pr:verify proof JSON path").action(withGateTiming({
|
|
24138
24111
|
gate: "pr:review",
|
|
@@ -24165,8 +24138,7 @@ function createPrReviewCommand(output, action) {
|
|
|
24165
24138
|
await (action ? action(args) : runPrReview(args, { publishCheckRun: createFactoryCheckPublisher(output) }));
|
|
24166
24139
|
})));
|
|
24167
24140
|
}
|
|
24168
|
-
|
|
24169
|
-
//#region src/commands/pr-verify.ts
|
|
24141
|
+
// src/commands/pr-verify.ts
|
|
24170
24142
|
function createPrVerifyCommand(output, action = runPrVerifyWithAdmission) {
|
|
24171
24143
|
return markCwdOptionDefault(new Command("pr:verify").description("Run project-profile verification commands and write typed proof").option("--base <ref>", "base ref to assert. With a pull request open for this branch its live base is the base and a disagreeing value is refused; without one, this ref (default origin/main) is fetched fresh and its SHA recorded").option("--cwd <path>", "working directory to verify", collectCwdOption).option("--docs-only", "run the docs/process verification gate").option("--full", "run the full verification gate").option("--authoring-session <id>", "explicit authoring session identity (required for review evidence)").option("--reuse-accepted", "reuse an exact-candidate App proof with matching current verification coverage; otherwise verify normally").option("--json", "print the proof as JSON after verification").option("--output <path>", "write proof JSON to a file").option("--profile <path>", "path to the project profile JSON file").option("--no-status", "skip posting the patronage-factory/pr-verify commit status").action(withGateTiming({
|
|
24172
24144
|
gate: "pr:verify",
|
|
@@ -24199,6 +24171,15 @@ const DEPLOYMENT_RECEIPT_TASK = "patronage-factory/deployment";
|
|
|
24199
24171
|
const PREVIEW_DEPLOYMENT_RECEIPT_TASK = "patronage-factory/preview-deployment";
|
|
24200
24172
|
/** The `performed_via_github_app.id` of GitHub Actions itself. */
|
|
24201
24173
|
const GITHUB_ACTIONS_APP_ID = 15368;
|
|
24174
|
+
/**
|
|
24175
|
+
* The `github-actions[bot]` account. A deployment created with a workflow's
|
|
24176
|
+
* `GITHUB_TOKEN` names it as creator and leaves `performed_via_github_app`
|
|
24177
|
+
* null (#1505).
|
|
24178
|
+
*/
|
|
24179
|
+
const GITHUB_ACTIONS_BOT = {
|
|
24180
|
+
id: 41898282,
|
|
24181
|
+
login: "github-actions[bot]"
|
|
24182
|
+
};
|
|
24202
24183
|
const RECEIPT_PAGE_SIZE = 100;
|
|
24203
24184
|
var DeploymentReceiptTransportError = class extends Error {
|
|
24204
24185
|
code;
|
|
@@ -24268,6 +24249,11 @@ const receiptPayloadSchema = z.object({
|
|
|
24268
24249
|
});
|
|
24269
24250
|
const deploymentRecordSchema = z.object({
|
|
24270
24251
|
created_at: z.string(),
|
|
24252
|
+
creator: z.object({
|
|
24253
|
+
id: z.number().int(),
|
|
24254
|
+
login: z.string(),
|
|
24255
|
+
type: z.string()
|
|
24256
|
+
}).nullable().optional(),
|
|
24271
24257
|
environment: z.string(),
|
|
24272
24258
|
id: z.number().int(),
|
|
24273
24259
|
/** Fixed at creation. `environment` can be rewritten by a later status write. */
|
|
@@ -24278,6 +24264,16 @@ const deploymentRecordSchema = z.object({
|
|
|
24278
24264
|
sha: z.string(),
|
|
24279
24265
|
task: z.string()
|
|
24280
24266
|
});
|
|
24267
|
+
/**
|
|
24268
|
+
* GitHub Actions wrote this deployment: either GitHub names the Actions app,
|
|
24269
|
+
* or it names no app and the creator is the `github-actions[bot]` account a
|
|
24270
|
+
* workflow's `GITHUB_TOKEN` acts as. Any other app is refused.
|
|
24271
|
+
*/
|
|
24272
|
+
const performedByGitHubActions = (deployment) => {
|
|
24273
|
+
const app = deployment.performed_via_github_app;
|
|
24274
|
+
if (app) return app.id === GITHUB_ACTIONS_APP_ID;
|
|
24275
|
+
return deployment.creator?.id === GITHUB_ACTIONS_BOT.id && deployment.creator.login === GITHUB_ACTIONS_BOT.login && deployment.creator.type === "Bot";
|
|
24276
|
+
};
|
|
24281
24277
|
const workflowRunJobSchema = z.object({
|
|
24282
24278
|
conclusion: z.string().nullable(),
|
|
24283
24279
|
head_sha: z.string(),
|
|
@@ -24332,7 +24328,7 @@ const previewPayloadRefusal = (args, deployment, receipt) => {
|
|
|
24332
24328
|
};
|
|
24333
24329
|
const bindReceiptPayload = (args, deployment) => {
|
|
24334
24330
|
const label = `deployment ${deployment.id}`;
|
|
24335
|
-
if (deployment
|
|
24331
|
+
if (!performedByGitHubActions(deployment)) return { reason: `${label} was not performed by GitHub Actions` };
|
|
24336
24332
|
if (deployment.task !== (args.preview ? PREVIEW_DEPLOYMENT_RECEIPT_TASK : "patronage-factory/deployment")) return { reason: `${label} has a foreign task, not a factory receipt` };
|
|
24337
24333
|
const payload = receiptPayloadSchema.safeParse(deployment.payload);
|
|
24338
24334
|
if (!payload.success) return { reason: `${label} payload is not a schema-version-1 factory receipt` };
|
|
@@ -24489,7 +24485,7 @@ const assertPublicationScope = (args) => {
|
|
|
24489
24485
|
};
|
|
24490
24486
|
const assertOwnPreviewIntent = (args, payload, environment, deploymentId) => {
|
|
24491
24487
|
const own = z.array(deploymentRecordSchema).parse(args.transport.listDeployments()).find((record) => record.id === deploymentId);
|
|
24492
|
-
if (!own || own.original_environment !== environment || own.sha !== args.sourceSha || own.production_environment !== false || own.task !== PREVIEW_DEPLOYMENT_RECEIPT_TASK || own
|
|
24488
|
+
if (!own || own.original_environment !== environment || own.sha !== args.sourceSha || own.production_environment !== false || own.task !== PREVIEW_DEPLOYMENT_RECEIPT_TASK || !performedByGitHubActions(own) || JSON.stringify(receiptPayloadSchema.parse(own.payload)) !== JSON.stringify(receiptPayloadSchema.parse(payload))) throw new Error("Preview completion must name this run's own deployment intent.");
|
|
24493
24489
|
};
|
|
24494
24490
|
const publishDeploymentReceipt = (args) => {
|
|
24495
24491
|
const environment = deploymentReceiptEnvironment(args.target, args.preview);
|
|
@@ -24615,8 +24611,7 @@ const ghDeploymentReceiptTransport = (cwd, repository, run = defaultGhRunner) =>
|
|
|
24615
24611
|
listWorkflowRunJobs: (runId, attempt) => api(`${base}/actions/runs/${runId}/attempts/${attempt}/jobs?per_page=${RECEIPT_PAGE_SIZE}`)
|
|
24616
24612
|
};
|
|
24617
24613
|
};
|
|
24618
|
-
|
|
24619
|
-
//#region src/production-impact.ts
|
|
24614
|
+
// src/production-impact.ts
|
|
24620
24615
|
/**
|
|
24621
24616
|
* Production deployment demand (#1075, epic #1063).
|
|
24622
24617
|
*
|
|
@@ -24722,12 +24717,13 @@ const resolveReceiptSource = (cwd, receipts) => {
|
|
|
24722
24717
|
};
|
|
24723
24718
|
const outputState = (state) => state === "superseded" ? "withdrawn" : state;
|
|
24724
24719
|
const writeGithubOutputs = (outputPath, decision) => {
|
|
24725
|
-
|
|
24720
|
+
const lines = [
|
|
24726
24721
|
`decision=${decision.decision}`,
|
|
24727
24722
|
`basis=${JSON.stringify(decision.basis)}`,
|
|
24728
24723
|
`unsubscribed_paths=${JSON.stringify(decision.unsubscribedPaths)}`,
|
|
24729
24724
|
...decision.targets.map((target) => `${productionImpactTargetOutput(target.name)}=${outputState(target.state)}`)
|
|
24730
|
-
]
|
|
24725
|
+
];
|
|
24726
|
+
appendFileSync(outputPath, `${lines.join("\n")}\n`, "utf-8");
|
|
24731
24727
|
};
|
|
24732
24728
|
/** Classify the delta from one baseline to the candidate, once per distinct baseline. */
|
|
24733
24729
|
const classifyDelta = ({ baseline, candidate, cwd, profile, profilePath }) => {
|
|
@@ -24945,8 +24941,7 @@ const runProductionReceipt = (args) => {
|
|
|
24945
24941
|
};
|
|
24946
24942
|
};
|
|
24947
24943
|
const productionReceiptSummaryLines = (result) => [`Deployment receipt: ${result.receipt.state} for ${result.receipt.payload.target}${result.receipt.payload.stage ? ` stage ${result.receipt.payload.stage}` : ""} at ${result.receipt.payload.sourceSha} (deployment ${result.receipt.deploymentId}, run ${result.receipt.payload.workflow.runId}).`, ...result.staleCandidate ? [`Stale candidate: ${result.receipt.payload.sourceSha} is an ancestor of the previously trusted baseline ${result.staleCandidate.sha} (run ${result.staleCandidate.runId}); production now runs the older revision and needs reconciliation.`] : []];
|
|
24948
|
-
|
|
24949
|
-
//#region src/commands/production-impact.ts
|
|
24944
|
+
// src/commands/production-impact.ts
|
|
24950
24945
|
/**
|
|
24951
24946
|
* `production:impact` has two modes on one command. Without
|
|
24952
24947
|
* `--publish-receipt` it resolves deployment demand from receipts; with it,
|
|
@@ -24984,8 +24979,7 @@ function createProductionImpactCommand(output, receipts) {
|
|
|
24984
24979
|
output.stdout.write(options.json ? `${JSON.stringify(decision, null, 2)}\n` : `${productionImpactSummaryLines(decision).join("\n")}\n`);
|
|
24985
24980
|
}));
|
|
24986
24981
|
}
|
|
24987
|
-
|
|
24988
|
-
//#region src/hq-spool-exit-report.ts
|
|
24982
|
+
// src/hq-spool-exit-report.ts
|
|
24989
24983
|
/** A recorded reason is file content: keep the line one line, and short. */
|
|
24990
24984
|
const MAX_REASON_LENGTH = 120;
|
|
24991
24985
|
const printableReason = (reason) => {
|
|
@@ -25029,8 +25023,7 @@ async function reportSpooledHqEvents(input) {
|
|
|
25029
25023
|
writeAdvisoryLine(`${describeSpooledHqEvents(counted)}\n`);
|
|
25030
25024
|
} catch {}
|
|
25031
25025
|
}
|
|
25032
|
-
|
|
25033
|
-
//#region src/pr-status.ts
|
|
25026
|
+
// src/pr-status.ts
|
|
25034
25027
|
const oid = z.string().regex(/^[0-9a-f]{40}$/u);
|
|
25035
25028
|
const instant = z.iso.datetime({ offset: true });
|
|
25036
25029
|
const pullRequestSchema = z.object({
|
|
@@ -25154,8 +25147,7 @@ async function readPrStatus(pr, handoffSha, handoffAt) {
|
|
|
25154
25147
|
if (report.progressSignals.length > 0) report.verdict = "progressed";
|
|
25155
25148
|
return report;
|
|
25156
25149
|
}
|
|
25157
|
-
|
|
25158
|
-
//#region src/pr-status-command.ts
|
|
25150
|
+
// src/pr-status-command.ts
|
|
25159
25151
|
function createPrStatusCommand(output) {
|
|
25160
25152
|
return new Command("pr:status").description("Read lane progress since handoff once: merged/closed win; progressed means head moved or a Factory run, ready-for-review transition, or auto-merge enablement strictly newer than --handoff-at. No writes.").requiredOption("--pr <number>", "pull request number in the checkout's origin repository", positiveInteger$1("--pr")).requiredOption("--since <handoff-sha>", "handoff head SHA, full or unambiguous abbreviation (at least 7 hex characters)").requiredOption("--handoff-at <iso-8601>", "handoff instant with an explicit timezone/offset").option("--json", "print one JSON object").action(async (options) => {
|
|
25161
25153
|
try {
|
|
@@ -25173,8 +25165,7 @@ function createPrStatusCommand(output) {
|
|
|
25173
25165
|
}
|
|
25174
25166
|
});
|
|
25175
25167
|
}
|
|
25176
|
-
|
|
25177
|
-
//#region src/pr-status-hud-command.ts
|
|
25168
|
+
// src/pr-status-hud-command.ts
|
|
25178
25169
|
const shaSchema = z.string().regex(/^[0-9a-f]{40}$/u);
|
|
25179
25170
|
const boundPlanSchema = z.object({
|
|
25180
25171
|
headSha: shaSchema,
|
|
@@ -25238,9 +25229,8 @@ function createPrStatusHudCommand(output, action = runPrStatusHud, env = process
|
|
|
25238
25229
|
output.stdout.write(`PR status HUD ${result.action}: ${result.url} (comment ${result.commentId})\n`);
|
|
25239
25230
|
}));
|
|
25240
25231
|
}
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
const ACTIONS = new Set([
|
|
25232
|
+
// src/preview-cleanup-command.ts
|
|
25233
|
+
const ACTIONS = /* @__PURE__ */ new Set([
|
|
25244
25234
|
"audit",
|
|
25245
25235
|
"discover",
|
|
25246
25236
|
"record",
|
|
@@ -25387,8 +25377,7 @@ function createPreviewCleanupCommand(output, deps = {}) {
|
|
|
25387
25377
|
output.stdout.write(await runPreviewCleanup(options, deps));
|
|
25388
25378
|
});
|
|
25389
25379
|
}
|
|
25390
|
-
|
|
25391
|
-
//#region src/preview-reaper.ts
|
|
25380
|
+
// src/preview-reaper.ts
|
|
25392
25381
|
const previewBindingReferenceSchema = z.object({
|
|
25393
25382
|
binding: z.string().min(1),
|
|
25394
25383
|
consumer: z.string().min(1),
|
|
@@ -25613,7 +25602,8 @@ const listWorkerBindings = async (cfRoot, workers, headers, fetchImpl) => {
|
|
|
25613
25602
|
const values = [];
|
|
25614
25603
|
const batchSize = 20;
|
|
25615
25604
|
for (let offset = 0; offset < workers.length; offset += batchSize) values.push(...await Promise.all(workers.slice(offset, offset + batchSize).map(async (worker) => {
|
|
25616
|
-
const
|
|
25605
|
+
const response = await fetchImpl(`${cfRoot}/workers/scripts/${encodeURIComponent(worker.name)}/settings`, { headers });
|
|
25606
|
+
const body = await jsonResponse(response, `Read Worker settings for ${worker.name}`);
|
|
25617
25607
|
const settings = workerSettingsSchema.safeParse(body.result);
|
|
25618
25608
|
if (!settings.success) throw new Error(`Worker ${worker.name} settings inventory is incomplete; refusing to classify a partial binding graph.`);
|
|
25619
25609
|
return [worker.name, settings.data.bindings ?? []];
|
|
@@ -25802,7 +25792,8 @@ async function createPreviewReapPlan(args, dependencies = {}) {
|
|
|
25802
25792
|
].filter((value) => Boolean(value)).toSorted().at(-1) ?? null;
|
|
25803
25793
|
const pullRequest = stage.owner.kind === "pull-request" ? pullRequests.get(`${stage.owner.repository}#${stage.owner.pr}`) : void 0;
|
|
25804
25794
|
if (stage.owner.kind === "pull-request" && !pullRequest) throw new Error(`Missing pull request result for ${stage.id}`);
|
|
25805
|
-
const
|
|
25795
|
+
const runFreshnessComplete = stage.owner.kind === "pull-request" || stage.workers.length > 0 && stage.workers.every((resource) => Boolean(resource.modifiedAt)) && stage.d1.every((resource) => Boolean(resource.createdAt)) && stage.r2.every((resource) => Boolean(resource.createdAt));
|
|
25796
|
+
const classified = classifyStage(pullRequest, newestResourceAt, cutoff, runFreshnessComplete);
|
|
25806
25797
|
const disposition = classified === "reclaim" && [
|
|
25807
25798
|
...stage.workers,
|
|
25808
25799
|
...stage.d1,
|
|
@@ -25845,11 +25836,12 @@ const assertPreviewReapPlanIntegrity = (plan) => {
|
|
|
25845
25836
|
if (previewReapPlanId(payload) !== planId) throw new Error("Preview reaper plan integrity check failed; regenerate and review the dry-run plan.");
|
|
25846
25837
|
};
|
|
25847
25838
|
const githubPullRequest = async (claim, githubToken, fetchImpl) => {
|
|
25848
|
-
|
|
25839
|
+
const response = await fetchImpl(`https://api.github.com/repos/${claim.repository}/pulls/${claim.pr}`, { headers: {
|
|
25849
25840
|
Accept: "application/vnd.github+json",
|
|
25850
25841
|
Authorization: `Bearer ${githubToken}`,
|
|
25851
25842
|
"X-GitHub-Api-Version": "2022-11-28"
|
|
25852
|
-
} })
|
|
25843
|
+
} });
|
|
25844
|
+
return jsonResponse(response, `Re-check ${claim.repository}#${claim.pr}`);
|
|
25853
25845
|
};
|
|
25854
25846
|
const deleteCloudflareResource = async (url, headers, context, fetchImpl) => {
|
|
25855
25847
|
const response = await fetchImpl(url, {
|
|
@@ -25869,10 +25861,11 @@ const listR2Objects = async (root, bucket, headers, fetchImpl) => {
|
|
|
25869
25861
|
const url = new URL(`${root}/r2/buckets/${encodeURIComponent(bucket.name)}/objects`);
|
|
25870
25862
|
url.searchParams.set("per_page", "1000");
|
|
25871
25863
|
if (cursor) url.searchParams.set("cursor", cursor);
|
|
25872
|
-
const
|
|
25864
|
+
const response = await fetchImpl(url, { headers: {
|
|
25873
25865
|
...headers,
|
|
25874
25866
|
...bucket.jurisdiction ? { "cf-r2-jurisdiction": bucket.jurisdiction } : {}
|
|
25875
|
-
} })
|
|
25867
|
+
} });
|
|
25868
|
+
const page = await jsonResponse(response, `List objects in R2 bucket ${bucket.name}`);
|
|
25876
25869
|
for (const object of page.result) {
|
|
25877
25870
|
if (!object.key) throw new Error(`R2 bucket ${bucket.name} returned an object without a key; refusing to delete the bucket.`);
|
|
25878
25871
|
values.push(object.key);
|
|
@@ -25906,7 +25899,10 @@ async function applyPreviewReapPlan(plan, args, dependencies = {}) {
|
|
|
25906
25899
|
if (target.claim.kind === "pull-request") {
|
|
25907
25900
|
const pullRequest = await githubPullRequest(target.claim, args.githubToken, fetchImpl);
|
|
25908
25901
|
if (pullRequest.state !== "closed" || !pullRequest.closed_at || new Date(pullRequest.closed_at) > new Date(plan.cutoff)) throw new Error(`${stageClaimLabel(target)} (${target.id}) is no longer reclaimable immediately before apply; refusing deletion.`);
|
|
25909
|
-
} else
|
|
25902
|
+
} else {
|
|
25903
|
+
const liveWorkers = (await listWorkers(`${cfRoot}/workers/scripts?per_page=1000`, cfHeaders, fetchImpl)).filter((worker) => workerIdentity(worker.name)?.id === target.id);
|
|
25904
|
+
if (comparableWorkers(liveWorkers) !== comparableWorkers(target.resources.workers)) throw new Error(`${target.id} Worker freshness changed immediately before apply; refusing deletion.`);
|
|
25905
|
+
}
|
|
25910
25906
|
const doOwners = new Set(target.resources.durableObjects.map((namespace) => namespace.script));
|
|
25911
25907
|
for (const worker of target.resources.workers) {
|
|
25912
25908
|
const force = doOwners.has(worker.name) ? "?force=true" : "";
|
|
@@ -25931,8 +25927,7 @@ async function applyPreviewReapPlan(plan, args, dependencies = {}) {
|
|
|
25931
25927
|
if (residue) throw new Error(`${residue.id} still has preview resources after apply; post-apply verification failed.`);
|
|
25932
25928
|
return { appliedStages };
|
|
25933
25929
|
}
|
|
25934
|
-
|
|
25935
|
-
//#region src/preview-reap-command.ts
|
|
25930
|
+
// src/preview-reap-command.ts
|
|
25936
25931
|
const positiveNumber = (value) => {
|
|
25937
25932
|
const parsed = Number(value);
|
|
25938
25933
|
if (!Number.isFinite(parsed) || parsed <= 0) throw new InvalidArgumentError("must be a positive number");
|
|
@@ -25991,8 +25986,7 @@ function createPreviewReapCommand(output, deps = {}) {
|
|
|
25991
25986
|
if (options.githubSummary) appendFileSync(options.githubSummary, rendered);
|
|
25992
25987
|
});
|
|
25993
25988
|
}
|
|
25994
|
-
|
|
25995
|
-
//#region src/preview-receipt-command.ts
|
|
25989
|
+
// src/preview-receipt-command.ts
|
|
25996
25990
|
const policySchema = z.object({
|
|
25997
25991
|
cleanupWorkflowPaths: z.array(z.string().regex(/^\.github\/workflows\/[^/]+\.ya?ml$/u)),
|
|
25998
25992
|
publishers: z.array(z.object({
|
|
@@ -26123,8 +26117,7 @@ const createPreviewReceiptCommand = (output) => markCwdOptionDefault(new Command
|
|
|
26123
26117
|
]).parse(options.action);
|
|
26124
26118
|
output.stdout.write(`${JSON.stringify(runPreviewReceipt(options), null, 2)}\n`);
|
|
26125
26119
|
}));
|
|
26126
|
-
|
|
26127
|
-
//#region src/worktree-scratch-files.ts
|
|
26120
|
+
// src/worktree-scratch-files.ts
|
|
26128
26121
|
var worktree_scratch_files_exports = /* @__PURE__ */ __exportAll({
|
|
26129
26122
|
checkWorktreeScratchFiles: () => checkWorktreeScratchFiles,
|
|
26130
26123
|
formatScratchFileCheckSummary: () => formatScratchFileCheckSummary,
|
|
@@ -26174,8 +26167,7 @@ function formatScratchFileCheckSummary(check) {
|
|
|
26174
26167
|
if (check.status === "clean") return "Scratch files: none";
|
|
26175
26168
|
return "Scratch files: not checked (no readable worktree path)";
|
|
26176
26169
|
}
|
|
26177
|
-
|
|
26178
|
-
//#region src/index.ts
|
|
26170
|
+
// src/index.ts
|
|
26179
26171
|
function createProgram(options = {}) {
|
|
26180
26172
|
const factoryCliInvocation = options.factoryCliInvocation ? FactoryCliInvocationSchema.parse(options.factoryCliInvocation) : defaultFactoryCliInvocation(factoryCliEntry());
|
|
26181
26173
|
const output = options.output ?? {
|
|
@@ -26219,7 +26211,7 @@ function createProgram(options = {}) {
|
|
|
26219
26211
|
* it found it. `hq:flush` is the explicit drain and has just run.
|
|
26220
26212
|
* `app-token:exec` only runs another command and records no evidence.
|
|
26221
26213
|
*/
|
|
26222
|
-
const EXIT_DRAIN_EXEMPT_COMMANDS = new Set([
|
|
26214
|
+
const EXIT_DRAIN_EXEMPT_COMMANDS = /* @__PURE__ */ new Set([
|
|
26223
26215
|
"app-token:exec",
|
|
26224
26216
|
"config",
|
|
26225
26217
|
"doctor",
|
|
@@ -26231,7 +26223,7 @@ const EXIT_DRAIN_EXEMPT_COMMANDS = new Set([
|
|
|
26231
26223
|
* `pr:publish` is not one: it already runs its own `hq:flush` drain and
|
|
26232
26224
|
* prints what stays spooled.
|
|
26233
26225
|
*/
|
|
26234
|
-
const EXIT_SPOOL_REPORT_COMMANDS = new Set(["pr:ready"]);
|
|
26226
|
+
const EXIT_SPOOL_REPORT_COMMANDS = /* @__PURE__ */ new Set(["pr:ready"]);
|
|
26235
26227
|
/**
|
|
26236
26228
|
* Which checkout's spool the command drains on exit: its `--cwd` (closeout's
|
|
26237
26229
|
* `--repo-root`), else the process directory, with its `--profile` if given.
|
|
@@ -26284,5 +26276,4 @@ async function run(argv = process.argv, cliEntry = factoryCliEntry()) {
|
|
|
26284
26276
|
}
|
|
26285
26277
|
}
|
|
26286
26278
|
}
|
|
26287
|
-
//#endregion
|
|
26288
26279
|
export { DEFAULT_DEMAND_WAIVER_PATH, DEFAULT_FACTORY_REPOSITORY, DEFAULT_ROOT_SHARED_GLOBS, DemandWaiveRefusalError, EMPTY_TREE_OBJECT_HASH, EPIC_STRUCTURE_NODE_STATUSES, EPIC_STRUCTURE_SCHEMA_VERSION, EpicStructureValidationError, FACTORY_BASE_REF_ENV, FACTORY_CHANGED_FILES_ENV, FACTORY_CHANGED_FILES_FILE_ENV, FACTORY_LOCKFILE_BASE_REF_ENV, FACTORY_LOCKFILE_IMPORTERS_ENV, FactoryCliInvocationSchema, FollowUpActionSchema, MERGE_FREEZE_APP_SLUG, MERGE_FREEZE_CHECK_NAME, PrPublishFollowUpError, REVIEW_FOCUS_SECTION, WorkerCheckoutGuardError, appendWithTraceSinks, applyDemandWaiver, assembleReviewPrompt, assertFactoryPrStatusIdentity, assertWorkerCheckoutAllowed, authorizeDemandWaiver, batteryScopeSummaryLines, boundary_manifest_exports as boundaryManifest, boundary_review_proof_exports as boundaryReviewProof, buildEpicStructureEvent, buildEpicStructurePayload, buildEvidenceEnvelope, buildReviewGateNotRequiredTraceEvent, comment_provenance_exports as commentProvenance, createGitHubCheckRunMergeFreezeStore, createLocalJsonlTraceSink, createProgram, createVerificationRunContext, doctorProjectProfile, epicStructureEventId, evidenceEnvelopeFilename, followUpFromArgv, impactStampScopeDecision, isProductionHqUrl, loadProjectProfile, normalizeIssueComments, planFactoryPrStatusHud, planPreviewLifecycle, planPublishFollowUp, planVerificationBattery, readiness_evaluation_exports as prReadinessEvaluation, external_evidence_exports as prReadinessExternalEvidence, pr_body_renderer_exports as prReadinessPrBodyRenderer, proof_identity_exports as prReadinessProofIdentity, review_proof_exports as prReadinessReviewProof, status_check_rollup_exports as prReadinessStatusChecks, verification_proof_exports as prReadinessVerificationProof, presentFactoryPrStatusHud, previewLifecycleTargets, publishEpicStructure, readDemandWaivers, readFactoryPrStatusSources, readPrReadyProof, refreshFactoryPrStatusHud, refreshFactoryPrStatusHudSafely, renderFactoryPrStatusHud, resolveFactoryRepository, resolveTraceWriteSinks, reviewFocusFromIssueBody, reviewPromptSectionSchema, reviewPromptSectionsSchema, run, runBoundaryCheck, runDemandWaive, runEvidenceEmit, runPrPublish, runPrReady, runPrReview, runPrVerify, scanFactoryTraceDiagnostics, scanFactoryTraceEvents, selectWaiversForCandidate, toFactoryTraceEnvelope, tryAppendReviewGateNotRequiredTraceEvent, validateBoundaryCheckProof, validateDagDocument, validateDemandWaiverStore, validateFactoryTraceEvent, validateMergeFreezeState, validatePrReadyProof, validatePrVerifyProof, validatePreviewLifecyclePlan, waivedDemandNotice, waivedDemandSchema, worktree_scratch_files_exports as worktreeScratchFiles };
|