@patronage/software-factory 1.0.0-alpha.2 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -17
- package/dist/index.js +25 -46
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -753,8 +753,8 @@ declare const mergeFreezeStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
753
753
|
generationId: z.ZodNumber;
|
|
754
754
|
headSha: z.ZodString;
|
|
755
755
|
outcome: z.ZodEnum<{
|
|
756
|
-
stale: "stale";
|
|
757
756
|
active: "active";
|
|
757
|
+
stale: "stale";
|
|
758
758
|
}>;
|
|
759
759
|
reason: z.ZodString;
|
|
760
760
|
recordedAt: z.ZodISODateTime;
|
|
@@ -1234,8 +1234,8 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
|
|
|
1234
1234
|
"run-interior-cycle": "run-interior-cycle";
|
|
1235
1235
|
}>;
|
|
1236
1236
|
stage: z.ZodEnum<{
|
|
1237
|
-
interior: "interior";
|
|
1238
1237
|
gate: "gate";
|
|
1238
|
+
interior: "interior";
|
|
1239
1239
|
"interior-complete": "interior-complete";
|
|
1240
1240
|
}>;
|
|
1241
1241
|
}, z.core.$strip>>;
|
|
@@ -1251,10 +1251,10 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
|
|
|
1251
1251
|
reviewedHeadSha: z.ZodOptional<z.ZodString>;
|
|
1252
1252
|
reviewedPatchId: z.ZodOptional<z.ZodString>;
|
|
1253
1253
|
status: z.ZodEnum<{
|
|
1254
|
-
"not-required": "not-required";
|
|
1255
1254
|
blocked: "blocked";
|
|
1256
|
-
|
|
1255
|
+
"not-required": "not-required";
|
|
1257
1256
|
stale: "stale";
|
|
1257
|
+
current: "current";
|
|
1258
1258
|
missing: "missing";
|
|
1259
1259
|
}>;
|
|
1260
1260
|
}, z.core.$strip>;
|
|
@@ -1263,10 +1263,10 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
|
|
|
1263
1263
|
reviewedHeadSha: z.ZodOptional<z.ZodString>;
|
|
1264
1264
|
reviewedPatchId: z.ZodOptional<z.ZodString>;
|
|
1265
1265
|
status: z.ZodEnum<{
|
|
1266
|
-
"not-required": "not-required";
|
|
1267
1266
|
blocked: "blocked";
|
|
1268
|
-
|
|
1267
|
+
"not-required": "not-required";
|
|
1269
1268
|
stale: "stale";
|
|
1269
|
+
current: "current";
|
|
1270
1270
|
missing: "missing";
|
|
1271
1271
|
}>;
|
|
1272
1272
|
}, z.core.$strip>>;
|
|
@@ -1277,8 +1277,8 @@ declare const managedReadinessLedgerSchema: z.ZodObject<{
|
|
|
1277
1277
|
docsOnlyDeltaAccepted: z.ZodOptional<z.ZodBoolean>;
|
|
1278
1278
|
docsOnlyVerifiedHeadSha: z.ZodOptional<z.ZodString>;
|
|
1279
1279
|
prVerify: z.ZodEnum<{
|
|
1280
|
-
passed: "passed";
|
|
1281
1280
|
stale: "stale";
|
|
1281
|
+
passed: "passed";
|
|
1282
1282
|
missing: "missing";
|
|
1283
1283
|
}>;
|
|
1284
1284
|
trivialDeltaAccepted: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1778,10 +1778,10 @@ declare const loadEvidenceEnvelopes: (cwd: string) => LoadedEvidenceEnvelope[];
|
|
|
1778
1778
|
//#region src/review-proof-applicability.d.ts
|
|
1779
1779
|
declare const REVIEW_STATUS_VALUES: readonly ["not-required", "current", "stale", "missing", "blocked"];
|
|
1780
1780
|
declare const reviewStatusSchema: z.ZodEnum<{
|
|
1781
|
-
"not-required": "not-required";
|
|
1782
1781
|
blocked: "blocked";
|
|
1783
|
-
|
|
1782
|
+
"not-required": "not-required";
|
|
1784
1783
|
stale: "stale";
|
|
1784
|
+
current: "current";
|
|
1785
1785
|
missing: "missing";
|
|
1786
1786
|
}>;
|
|
1787
1787
|
type ReviewStatus = z.infer<typeof reviewStatusSchema>;
|
|
@@ -2949,8 +2949,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
|
|
|
2949
2949
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
2950
2950
|
}, z.core.$strict>>;
|
|
2951
2951
|
stage: z.ZodEnum<{
|
|
2952
|
-
interior: "interior";
|
|
2953
2952
|
gate: "gate";
|
|
2953
|
+
interior: "interior";
|
|
2954
2954
|
}>;
|
|
2955
2955
|
usage: z.ZodOptional<z.ZodObject<{
|
|
2956
2956
|
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3002,8 +3002,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
|
|
|
3002
3002
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
3003
3003
|
}, z.core.$strict>>;
|
|
3004
3004
|
stage: z.ZodEnum<{
|
|
3005
|
-
interior: "interior";
|
|
3006
3005
|
gate: "gate";
|
|
3006
|
+
interior: "interior";
|
|
3007
3007
|
}>;
|
|
3008
3008
|
usage: z.ZodOptional<z.ZodObject<{
|
|
3009
3009
|
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3046,8 +3046,8 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
|
|
|
3046
3046
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
3047
3047
|
}, z.core.$strict>>;
|
|
3048
3048
|
stage: z.ZodEnum<{
|
|
3049
|
-
interior: "interior";
|
|
3050
3049
|
gate: "gate";
|
|
3050
|
+
interior: "interior";
|
|
3051
3051
|
}>;
|
|
3052
3052
|
usage: z.ZodOptional<z.ZodObject<{
|
|
3053
3053
|
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3077,7 +3077,7 @@ declare const FACTORY_TRACE_EVENT_DEFINITIONS: readonly [DefinedTraceEvent<"revi
|
|
|
3077
3077
|
staleRepeats: number;
|
|
3078
3078
|
};
|
|
3079
3079
|
observedAt: string;
|
|
3080
|
-
stage: "
|
|
3080
|
+
stage: "gate" | "interior";
|
|
3081
3081
|
issue?: number | undefined;
|
|
3082
3082
|
pr?: number | undefined;
|
|
3083
3083
|
threadId?: string | undefined;
|
|
@@ -4076,13 +4076,13 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
|
|
|
4076
4076
|
reviews: {
|
|
4077
4077
|
correctness: {
|
|
4078
4078
|
required: boolean;
|
|
4079
|
-
status: "
|
|
4079
|
+
status: "blocked" | "not-required" | "stale" | "current" | "missing";
|
|
4080
4080
|
reviewedHeadSha?: string | undefined;
|
|
4081
4081
|
reviewedPatchId?: string | undefined;
|
|
4082
4082
|
};
|
|
4083
4083
|
security?: {
|
|
4084
4084
|
required: boolean;
|
|
4085
|
-
status: "
|
|
4085
|
+
status: "blocked" | "not-required" | "stale" | "current" | "missing";
|
|
4086
4086
|
reviewedHeadSha?: string | undefined;
|
|
4087
4087
|
reviewedPatchId?: string | undefined;
|
|
4088
4088
|
} | undefined;
|
|
@@ -4090,7 +4090,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
|
|
|
4090
4090
|
schemaVersion: 1;
|
|
4091
4091
|
verification: {
|
|
4092
4092
|
command: "patronage-factory pr:verify";
|
|
4093
|
-
prVerify: "
|
|
4093
|
+
prVerify: "stale" | "passed" | "missing";
|
|
4094
4094
|
docsOnlyDeltaAccepted?: boolean | undefined;
|
|
4095
4095
|
docsOnlyVerifiedHeadSha?: string | undefined;
|
|
4096
4096
|
trivialDeltaAccepted?: boolean | undefined;
|
|
@@ -4133,7 +4133,7 @@ declare const evaluateReadiness: (input: EvaluationInput) => {
|
|
|
4133
4133
|
interior: number;
|
|
4134
4134
|
};
|
|
4135
4135
|
nextAction: "run-gate-cycle" | "accept-nonblocking-findings" | "escalate-to-triage" | "ready-for-human" | "advance-to-gate" | "run-interior-cycle";
|
|
4136
|
-
stage: "
|
|
4136
|
+
stage: "gate" | "interior" | "interior-complete";
|
|
4137
4137
|
forcedTransition?: "gate-cap-exhausted" | "interior-cap-reached" | undefined;
|
|
4138
4138
|
} | undefined;
|
|
4139
4139
|
reviewRuns?: PrReviewResult[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { appendFileSync, constants, cpSync, createReadStream, existsSync, mkdirS
|
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { Command, InvalidArgumentError } from "commander";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import crypto, { createHash,
|
|
7
|
+
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
10
10
|
import { link, lstat, mkdir, open, readFile, readdir, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
@@ -16,8 +16,9 @@ import { Worker } from "node:worker_threads";
|
|
|
16
16
|
import picomatch from "picomatch";
|
|
17
17
|
import { parse } from "yaml";
|
|
18
18
|
import { promisify } from "node:util";
|
|
19
|
+
import { GitHubApiError, mintInstallationToken } from "@patronage/factory-ci";
|
|
19
20
|
//#region package.json
|
|
20
|
-
var version = "1.0.0-alpha.
|
|
21
|
+
var version = "1.0.0-alpha.4";
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region src/review-rungs.ts
|
|
23
24
|
const EVIDENCE_REVIEW_RUNGS$1 = [
|
|
@@ -3050,7 +3051,10 @@ async function flushHqSpool(input, dependencies = {}) {
|
|
|
3050
3051
|
const env = dependencies.env ?? process.env;
|
|
3051
3052
|
const request = dependencies.fetch ?? fetch;
|
|
3052
3053
|
const transportBudgetMs = dependencies.transportTimeoutMs ?? DEFAULT_HQ_TRANSPORT_TIMEOUT_MS;
|
|
3053
|
-
const flushBudgetMs =
|
|
3054
|
+
const flushBudgetMs = journalFlushBudgetFor({
|
|
3055
|
+
env,
|
|
3056
|
+
journalFlushBudgetMs: dependencies.journalFlushBudgetMs
|
|
3057
|
+
});
|
|
3054
3058
|
const deadline = performance.now() + (dependencies.budgetMs ?? DEFAULT_HQ_FLUSH_BUDGET_MS);
|
|
3055
3059
|
const writeLayout = repositorySpoolLayout(input.repository, env);
|
|
3056
3060
|
const layouts = input.explicitDirectories && input.explicitDirectories.length > 0 ? input.explicitDirectories.map(explicitSpoolLayout) : [writeLayout, legacySpoolLayout(input.cwd)];
|
|
@@ -7670,31 +7674,6 @@ const defaultSleep = async (ms) => {
|
|
|
7670
7674
|
const { setTimeout: delay } = await import("node:timers/promises");
|
|
7671
7675
|
await delay(ms);
|
|
7672
7676
|
};
|
|
7673
|
-
const base64url = (value) => Buffer.from(value).toString("base64url");
|
|
7674
|
-
function appJwt(config, now) {
|
|
7675
|
-
const issuedAt = Math.floor(now / 1e3) - 60;
|
|
7676
|
-
const unsigned = `${base64url(JSON.stringify({
|
|
7677
|
-
alg: "RS256",
|
|
7678
|
-
typ: "JWT"
|
|
7679
|
-
}))}.${base64url(JSON.stringify({
|
|
7680
|
-
exp: issuedAt + 600,
|
|
7681
|
-
iat: issuedAt,
|
|
7682
|
-
iss: config.appId
|
|
7683
|
-
}))}`;
|
|
7684
|
-
const signer = createSign("RSA-SHA256");
|
|
7685
|
-
signer.update(unsigned);
|
|
7686
|
-
signer.end();
|
|
7687
|
-
return `${unsigned}.${signer.sign(readFileSync(config.privateKeyPath), "base64url")}`;
|
|
7688
|
-
}
|
|
7689
|
-
/** Carries the HTTP status so a caller can tell a retryable failure apart. */
|
|
7690
|
-
var GitHubApiError = class extends Error {
|
|
7691
|
-
status;
|
|
7692
|
-
constructor(status, statusText) {
|
|
7693
|
-
super(`GitHub API ${status} ${statusText}`);
|
|
7694
|
-
this.name = "GitHubApiError";
|
|
7695
|
-
this.status = status;
|
|
7696
|
-
}
|
|
7697
|
-
};
|
|
7698
7677
|
/**
|
|
7699
7678
|
* Worth another attempt: 422 is what GitHub answers for a head SHA it has not
|
|
7700
7679
|
* seen yet (the whole reason the retry exists), 5xx and rate limiting are
|
|
@@ -7749,24 +7728,24 @@ async function githubJson(request, url, init, timeoutMs = GITHUB_PUBLISH_TIMEOUT
|
|
|
7749
7728
|
if (!response.ok) throw new GitHubApiError(response.status, response.statusText);
|
|
7750
7729
|
return await response.json();
|
|
7751
7730
|
}
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
}
|
|
7731
|
+
/**
|
|
7732
|
+
* Mint an installation token for the Patronage Factory App.
|
|
7733
|
+
*
|
|
7734
|
+
* The mechanism — app JWT, installation lookup, token exchange — lives in
|
|
7735
|
+
* `@patronage/factory-ci` (#617), because paitronage's proof-comment publisher
|
|
7736
|
+
* had grown a second copy of it. What stays here is what is this repository's:
|
|
7737
|
+
* where the credentials come from (`user-config`), and the publish timeout the
|
|
7738
|
+
* rest of these calls are bound by. Nothing is cached, as before.
|
|
7739
|
+
*/
|
|
7740
|
+
const installationToken = (repository, config, request, now, timeoutMs = GITHUB_PUBLISH_TIMEOUT_MS) => mintInstallationToken({
|
|
7741
|
+
credentials: config,
|
|
7742
|
+
owner: repository.owner,
|
|
7743
|
+
repo: repository.repo
|
|
7744
|
+
}, {
|
|
7745
|
+
fetch: request,
|
|
7746
|
+
now: () => now,
|
|
7747
|
+
timeoutMs
|
|
7748
|
+
});
|
|
7770
7749
|
function verifyOutput(proof) {
|
|
7771
7750
|
const value = proof;
|
|
7772
7751
|
const commands = value.executedCommands?.length ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patronage/software-factory",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "Shared Patronage software factory CLI and project-profile validation tools",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"commander": "14.0.3",
|
|
36
36
|
"picomatch": "^4.0.5",
|
|
37
37
|
"yaml": "^2.9.0",
|
|
38
|
-
"zod": "4.4.3"
|
|
38
|
+
"zod": "4.4.3",
|
|
39
|
+
"@patronage/factory-ci": "1.0.0-alpha.4"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/node": "24.13.3",
|