@patronage/software-factory 1.0.0-alpha.46 → 1.0.0-alpha.47
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 +25 -0
- package/dist/cloud/credentials.d.mts +21 -0
- package/dist/cloud/credentials.mjs +136 -0
- package/dist/cloud/install-tools.sh +59 -0
- package/dist/index.d.ts +1827 -1816
- package/dist/index.js +30 -67
- package/dist/schemas.d.ts +488 -480
- package/dist/schemas.js +8 -8
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ 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.
|
|
25
|
+
var version = "1.0.0-alpha.47";
|
|
26
26
|
// src/git-globals-parse.ts
|
|
27
27
|
const VALUE_TAKING_GIT_OPTIONS = /* @__PURE__ */ new Set([
|
|
28
28
|
"-C",
|
|
@@ -1973,6 +1973,7 @@ const DIFF_CLASSIFICATIONS = [
|
|
|
1973
1973
|
];
|
|
1974
1974
|
// src/required-check-policy.ts
|
|
1975
1975
|
const EVIDENCE_CHECK_TYPES = ["review", "verify"];
|
|
1976
|
+
const evidenceCheckTypeSchema = z.enum(EVIDENCE_CHECK_TYPES);
|
|
1976
1977
|
const requiredCheckScopeSchema = z.object({ classifications: z.array(z.enum(DIFF_CLASSIFICATIONS)).min(1) }).strict();
|
|
1977
1978
|
const requiredCheckInScope = ({ context, scope }) => {
|
|
1978
1979
|
if (!scope) return {
|
|
@@ -11573,6 +11574,12 @@ const runDemandWaive = (args, dependencies = {}) => {
|
|
|
11573
11574
|
if (args.json) console.log(JSON.stringify(waiver, null, 2));
|
|
11574
11575
|
return waiver;
|
|
11575
11576
|
};
|
|
11577
|
+
// src/arming-outcome.ts
|
|
11578
|
+
const ARMING_OUTCOMES = [
|
|
11579
|
+
"armed",
|
|
11580
|
+
"merged",
|
|
11581
|
+
"not-armed"
|
|
11582
|
+
];
|
|
11576
11583
|
/** One refusal sentence: single line, trimmed, bounded. */
|
|
11577
11584
|
const blockedReasonDetailSchema = z.string().min(1).max(280).refine((value) => value.trim().length > 0, { message: "must not be blank" }).refine((value) => !/[\r\n]/u.test(value), { message: "must be one line, not a multi-line payload" });
|
|
11578
11585
|
const blockedReasonSchema = z.object({
|
|
@@ -12364,7 +12371,6 @@ const closeoutArtifactSchema = z.object({
|
|
|
12364
12371
|
schemaVersion: z.literal(5)
|
|
12365
12372
|
}).strict();
|
|
12366
12373
|
// src/schemas.ts
|
|
12367
|
-
const evidenceCheckTypeSchema = z.enum(EVIDENCE_CHECK_TYPES);
|
|
12368
12374
|
const evidenceReviewRungSchema = z.enum(EVIDENCE_REVIEW_RUNGS);
|
|
12369
12375
|
const diffClassificationSchema = z.enum(DIFF_CLASSIFICATIONS);
|
|
12370
12376
|
const ladderStageSchema = z.enum(LADDER_STAGES);
|
|
@@ -12627,15 +12633,11 @@ const managedReadinessLedgerSchema$1 = z.object({
|
|
|
12627
12633
|
])
|
|
12628
12634
|
});
|
|
12629
12635
|
const prReadySchemaVersionSchema = z.literal(3);
|
|
12630
|
-
z.object({
|
|
12636
|
+
const prReadyProofSchema = z.object({
|
|
12631
12637
|
arming: z.object({
|
|
12632
12638
|
detail: z.string().min(1).optional(),
|
|
12633
12639
|
headSha: z.string().regex(/^[0-9a-f]{40}$/u),
|
|
12634
|
-
outcome: z.enum(
|
|
12635
|
-
"armed",
|
|
12636
|
-
"merged",
|
|
12637
|
-
"not-armed"
|
|
12638
|
-
])
|
|
12640
|
+
outcome: z.enum(ARMING_OUTCOMES)
|
|
12639
12641
|
}).optional(),
|
|
12640
12642
|
authoringSession: z.string().min(1).optional(),
|
|
12641
12643
|
blockedReasons: blockedReasonsSchema.optional(),
|
|
@@ -18100,7 +18102,7 @@ const checkTimestampMs = (check) => {
|
|
|
18100
18102
|
const effectiveChecks = (rollup) => {
|
|
18101
18103
|
const checksByContext = /* @__PURE__ */ new Map();
|
|
18102
18104
|
const unkeyed = [];
|
|
18103
|
-
for (const
|
|
18105
|
+
for (const check of rollup) {
|
|
18104
18106
|
const context = checkContext(check);
|
|
18105
18107
|
if (!context) {
|
|
18106
18108
|
unkeyed.push(check);
|
|
@@ -18109,7 +18111,6 @@ const effectiveChecks = (rollup) => {
|
|
|
18109
18111
|
const checks = checksByContext.get(context) ?? [];
|
|
18110
18112
|
checks.push({
|
|
18111
18113
|
check,
|
|
18112
|
-
index,
|
|
18113
18114
|
timestampMs: checkTimestampMs(check)
|
|
18114
18115
|
});
|
|
18115
18116
|
checksByContext.set(context, checks);
|
|
@@ -18122,20 +18123,17 @@ const effectiveChecks = (rollup) => {
|
|
|
18122
18123
|
currentChecks.push(firstCheck.check);
|
|
18123
18124
|
continue;
|
|
18124
18125
|
}
|
|
18125
|
-
|
|
18126
|
+
const orderable = checks.flatMap((check) => check.timestampMs === void 0 ? [] : [{
|
|
18127
|
+
check: check.check,
|
|
18128
|
+
orderMs: check.timestampMs
|
|
18129
|
+
}]);
|
|
18130
|
+
if (orderable.length !== checks.length) {
|
|
18126
18131
|
currentChecks.push(...checks.map((check) => check.check));
|
|
18127
18132
|
continue;
|
|
18128
18133
|
}
|
|
18129
|
-
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
if (candidate.timestampMs > latest.timestampMs) {
|
|
18133
|
-
latest = candidate;
|
|
18134
|
-
continue;
|
|
18135
|
-
}
|
|
18136
|
-
if (candidate.timestampMs === latest.timestampMs && candidate.index > latest.index) latest = candidate;
|
|
18137
|
-
}
|
|
18138
|
-
currentChecks.push(latest.check);
|
|
18134
|
+
const newest = selectNewestGeneration(orderable);
|
|
18135
|
+
if (newest.kind === "newest") currentChecks.push(newest.generation.check);
|
|
18136
|
+
else if (newest.kind === "ambiguous") currentChecks.push(...newest.tied.map((generation) => generation.check));
|
|
18139
18137
|
}
|
|
18140
18138
|
return currentChecks;
|
|
18141
18139
|
};
|
|
@@ -18942,13 +18940,9 @@ const readinessRepairSchema = z.object({
|
|
|
18942
18940
|
const managedReadinessLedgerSchema = z.object({
|
|
18943
18941
|
baseSha: shaSchema$1,
|
|
18944
18942
|
blockingReasons: z.array(z.string()),
|
|
18945
|
-
classification: z.enum(
|
|
18946
|
-
"docs/process-only",
|
|
18947
|
-
"trivial",
|
|
18948
|
-
"non-trivial"
|
|
18949
|
-
]),
|
|
18943
|
+
classification: z.enum(DIFF_CLASSIFICATIONS),
|
|
18950
18944
|
externalChecks: z.array(z.object({
|
|
18951
|
-
checkType:
|
|
18945
|
+
checkType: evidenceCheckTypeSchema,
|
|
18952
18946
|
name: z.string().min(1),
|
|
18953
18947
|
reason: z.string().optional(),
|
|
18954
18948
|
scope: requiredCheckScopeSchema.optional(),
|
|
@@ -20415,6 +20409,13 @@ const CHECK_CONCLUSION_BY_READINESS_STATUS = {
|
|
|
20415
20409
|
blocked: "failure",
|
|
20416
20410
|
ready: "success"
|
|
20417
20411
|
};
|
|
20412
|
+
/**
|
|
20413
|
+
* Blocked on nothing but a required check that has not settled: the one
|
|
20414
|
+
* refusal time alone clears. `pr:ready` withholds a follow-up for exactly this
|
|
20415
|
+
* state, and `pr:publish` waits on exactly this state. Both read it from the
|
|
20416
|
+
* recorded verdict, so publish never infers it from a missing follow-up.
|
|
20417
|
+
*/
|
|
20418
|
+
const isAwaitingRequiredChecksOnly = (verdict) => verdict.status === "blocked" && verdict.ledger.github.requiredChecks === "pending" && verdict.blockingReasons.length === 1;
|
|
20418
20419
|
function defaultPrReadyGit() {
|
|
20419
20420
|
return {
|
|
20420
20421
|
canResolveCommit,
|
|
@@ -20488,35 +20489,6 @@ async function fetchPullRequestWithMergeablePoll({ fetch, sleep = setTimeout$1 }
|
|
|
20488
20489
|
function defaultPrReadyGithub() {
|
|
20489
20490
|
return { fetchPullRequest };
|
|
20490
20491
|
}
|
|
20491
|
-
const prReadyProofSchema = z.object({
|
|
20492
|
-
arming: z.object({
|
|
20493
|
-
detail: z.string().min(1).optional(),
|
|
20494
|
-
headSha: z.string().regex(/^[0-9a-f]{40}$/u),
|
|
20495
|
-
outcome: z.enum([
|
|
20496
|
-
"armed",
|
|
20497
|
-
"merged",
|
|
20498
|
-
"not-armed"
|
|
20499
|
-
])
|
|
20500
|
-
}).optional(),
|
|
20501
|
-
authoringSession: z.string().min(1).optional(),
|
|
20502
|
-
blockedReasons: blockedReasonsSchema.optional(),
|
|
20503
|
-
blockingReasons: z.array(z.string()),
|
|
20504
|
-
command: z.literal("patronage-factory pr:ready"),
|
|
20505
|
-
followUp: FollowUpActionSchema.optional(),
|
|
20506
|
-
humanBlockingReasons: z.array(z.string()).default([]),
|
|
20507
|
-
ledger: managedReadinessLedgerSchema,
|
|
20508
|
-
notices: z.array(z.string().min(1)).optional(),
|
|
20509
|
-
policyResolution: policyResolutionSchema.optional(),
|
|
20510
|
-
profileBlobSha: z.string().regex(/^[0-9a-f]{40}$/u).optional(),
|
|
20511
|
-
profilePath: z.string().min(1).optional(),
|
|
20512
|
-
repairs: z.array(readinessRepairSchema).default([]),
|
|
20513
|
-
repository: z.string().regex(/^[^/\s]+\/[^/\s]+$/u).optional(),
|
|
20514
|
-
schemaVersion: z.literal(3),
|
|
20515
|
-
status: z.enum(["ready", "blocked"]),
|
|
20516
|
-
waivedDemands: z.array(waivedDemandSchema).optional()
|
|
20517
|
-
}).superRefine((proof, context) => {
|
|
20518
|
-
for (const issue of blockedReasonIssues({ ...proof })) context.addIssue(issue);
|
|
20519
|
-
});
|
|
20520
20492
|
function validatePrReadyProof(value) {
|
|
20521
20493
|
return prReadyProofSchema.parse(value);
|
|
20522
20494
|
}
|
|
@@ -21246,7 +21218,7 @@ async function runPrReady(args, dependencies = {}) {
|
|
|
21246
21218
|
recorded: verifyProofRead.proof?.authoringSession
|
|
21247
21219
|
});
|
|
21248
21220
|
const undraftRepair = evaluation.repairs.find((repair) => repair.code === "undraft-pr");
|
|
21249
|
-
const pendingExternalChecksOnly =
|
|
21221
|
+
const pendingExternalChecksOnly = isAwaitingRequiredChecksOnly(evaluation);
|
|
21250
21222
|
const routeOwnedNotYetOnly = evaluation.status === "blocked" && evaluation.humanBlockingReasons.length === 0;
|
|
21251
21223
|
const boundary = waveDemand?.kind === "demanded" ? waveDemand.demand : void 0;
|
|
21252
21224
|
const armingConsidered = evaluation.status === "ready" && boundary?.autoMerge !== false;
|
|
@@ -23731,15 +23703,6 @@ const requirePromotedProofHead = ({ expectedHeadSha, promotion, proof }) => {
|
|
|
23731
23703
|
};
|
|
23732
23704
|
const candidateFollowUpAfterPromotion = (promotion, proof) => promotion.status === "not-requested" ? proof.followUp : void 0;
|
|
23733
23705
|
/**
|
|
23734
|
-
* A proof with no follow-up that is not `ready` means `pr:ready` found the
|
|
23735
|
-
* candidate blocked solely on a pending hosted check for the family excluded
|
|
23736
|
-
* from readiness's own evaluation (`isFactoryReadyCheck`) — the only
|
|
23737
|
-
* condition time alone can resolve. Everything else — a human action, a
|
|
23738
|
-
* route-owned repair, a verification rerun — carries a follow-up and is
|
|
23739
|
-
* publish's current, actionable answer; this function must not wait on it.
|
|
23740
|
-
*/
|
|
23741
|
-
const isAwaitingHostedRunOnly = (proof) => proof.followUp === void 0 && proof.status !== "ready";
|
|
23742
|
-
/**
|
|
23743
23706
|
* The bounded transaction's await-and-re-evaluate loop (#348). Starting from
|
|
23744
23707
|
* `proof`, while the candidate is blocked solely on a pending hosted check for
|
|
23745
23708
|
* its head: abort honestly if that head moves (the candidate this invocation
|
|
@@ -23752,7 +23715,7 @@ async function awaitCurrentReadyVerdict({ args, dependencies, proof }) {
|
|
|
23752
23715
|
const originalHeadSha = proof.ledger.headSha;
|
|
23753
23716
|
const sleep = dependencies.sleep ?? setTimeout$1;
|
|
23754
23717
|
let current = proof;
|
|
23755
|
-
for (let attempt = 0;
|
|
23718
|
+
for (let attempt = 0; isAwaitingRequiredChecksOnly(current); attempt += 1) {
|
|
23756
23719
|
if (current.ledger.headSha !== originalHeadSha) throw new PrPublishTransactionAbortedError(`awaited the newest hosted check run for ${originalHeadSha}, but the head moved to ${current.ledger.headSha} while waiting. Re-run pr:publish against the current head.`);
|
|
23757
23720
|
if (attempt >= 12) throw new PrPublishTransactionAbortedError(`timed out after ${12 * PUBLISH_HOSTED_RUN_POLL_MS}ms awaiting the newest hosted check run to leave pending for ${originalHeadSha}. Re-run pr:publish once hosted CI finishes.`);
|
|
23758
23721
|
await sleep(PUBLISH_HOSTED_RUN_POLL_MS);
|