@attalabs/vinaya 0.31.0 → 0.32.0
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 +1 -2
- package/aeg-root/roles/developer/reference.md +3 -3
- package/aeg-root/templates/pr-report-template.md +7 -2
- package/dist/checks/bin/check-body-bare-digits.js +229 -86
- package/dist/checks/bin/check-branch-topology.js +101 -89
- package/dist/checks/bin/check-brief-shape.js +222 -79
- package/dist/checks/bin/check-changeset-coverage.js +739 -232
- package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
- package/dist/checks/bin/check-closes-n.js +101 -89
- package/dist/checks/bin/check-coherence.js +233 -129
- package/dist/checks/bin/check-dead-branch-push.js +97 -44
- package/dist/checks/bin/check-dispatch-readiness.js +238 -134
- package/dist/checks/bin/check-doc-coverage-push.js +722 -215
- package/dist/checks/bin/check-doc-coverage.js +726 -219
- package/dist/checks/bin/check-doctrine-no-procedures.js +222 -79
- package/dist/checks/bin/check-doctrine-portability.js +724 -217
- package/dist/checks/bin/check-evidence-fresh.js +720 -206
- package/dist/checks/bin/check-exec-bits.js +720 -213
- package/dist/checks/bin/check-first-push-dispatch.js +231 -129
- package/dist/checks/bin/check-issue-assignment.js +103 -91
- package/dist/checks/bin/check-issue-milestone-attach.js +94 -41
- package/dist/checks/bin/check-issue-objectives-numbering.js +94 -41
- package/dist/checks/bin/check-issue-parts-coverage.js +94 -41
- package/dist/checks/bin/check-issue-surface-globs.js +251 -127
- package/dist/checks/bin/check-issue-title-grammar.js +94 -41
- package/dist/checks/bin/check-issue-tranche-label.js +94 -41
- package/dist/checks/bin/check-main-branch-refusal.js +94 -41
- package/dist/checks/bin/check-no-disk-state.js +94 -41
- package/dist/checks/bin/check-pr-premise-reassert.js +222 -77
- package/dist/checks/bin/check-pr-report-density.js +94 -41
- package/dist/checks/bin/check-principal-test-plan-wait.js +94 -39
- package/dist/checks/bin/check-quoted-command.js +710 -201
- package/dist/checks/bin/check-reader-resolvable-prose.js +722 -213
- package/dist/checks/bin/check-registry-gates.js +104 -41
- package/dist/checks/bin/check-retired-vocabulary.js +708 -199
- package/dist/checks/bin/check-review-gate.js +224 -79
- package/dist/checks/bin/check-single-plan-pr.js +94 -41
- package/dist/checks/bin/check-surface-scope.js +101 -89
- package/dist/checks/bin/check-test-plan.js +94 -39
- package/dist/checks/bin/check-token-collection-wired.js +100 -42
- package/dist/checks/bin/check-token-report.js +96 -43
- package/dist/checks/bin/check-workspace-escape.js +722 -213
- package/dist/index.js +3725 -3148
- package/dist/lib/pre-push-cache-test-run.js +4175 -0
- package/dist/lib/pre-push-select-tests.js +709 -101
- package/package.json +3 -2
|
@@ -1038,7 +1038,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
1038
1038
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
1039
1039
|
|
|
1040
1040
|
// ../../node_modules/fast-content-type-parse/index.js
|
|
1041
|
-
var NullObject = function
|
|
1041
|
+
var NullObject = function NullObject() {};
|
|
1042
1042
|
NullObject.prototype = Object.create(null);
|
|
1043
1043
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
1044
1044
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
@@ -1782,27 +1782,27 @@ function splitTableRow(row) {
|
|
|
1782
1782
|
return parts.map((p) => p.split(PLACEHOLDER).join("|"));
|
|
1783
1783
|
}
|
|
1784
1784
|
// ../../packages/aeg-core/src/blast-radius-domains.ts
|
|
1785
|
-
function resolveWorkspaceEntry(
|
|
1786
|
-
if (
|
|
1787
|
-
const baseDir =
|
|
1785
|
+
function resolveWorkspaceEntry(entry, listDirs) {
|
|
1786
|
+
if (entry.endsWith("/*")) {
|
|
1787
|
+
const baseDir = entry.slice(0, -2);
|
|
1788
1788
|
return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
|
|
1789
1789
|
}
|
|
1790
|
-
if (
|
|
1790
|
+
if (entry.includes("*"))
|
|
1791
1791
|
return [];
|
|
1792
|
-
return [
|
|
1792
|
+
return [entry];
|
|
1793
1793
|
}
|
|
1794
1794
|
// ../../packages/aeg-core/src/consumer-enumeration.ts
|
|
1795
1795
|
function deriveWorkspaceMemberDirs(workspaces, listDirs) {
|
|
1796
|
-
const positive = workspaces.filter((
|
|
1797
|
-
const negative = workspaces.filter((
|
|
1796
|
+
const positive = workspaces.filter((entry) => !entry.startsWith("!"));
|
|
1797
|
+
const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
|
|
1798
1798
|
const excluded = new Set;
|
|
1799
|
-
for (const
|
|
1800
|
-
for (const member of resolveWorkspaceEntry(
|
|
1799
|
+
for (const entry of negative) {
|
|
1800
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs))
|
|
1801
1801
|
excluded.add(member);
|
|
1802
1802
|
}
|
|
1803
1803
|
const members = new Set;
|
|
1804
|
-
for (const
|
|
1805
|
-
for (const member of resolveWorkspaceEntry(
|
|
1804
|
+
for (const entry of positive) {
|
|
1805
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs)) {
|
|
1806
1806
|
if (!excluded.has(member))
|
|
1807
1807
|
members.add(member);
|
|
1808
1808
|
}
|
|
@@ -2126,15 +2126,15 @@ function summarizeTranscript(jsonl) {
|
|
|
2126
2126
|
const line = rawLine.trim();
|
|
2127
2127
|
if (!line)
|
|
2128
2128
|
continue;
|
|
2129
|
-
let
|
|
2129
|
+
let entry;
|
|
2130
2130
|
try {
|
|
2131
|
-
|
|
2131
|
+
entry = JSON.parse(line);
|
|
2132
2132
|
} catch {
|
|
2133
2133
|
continue;
|
|
2134
2134
|
}
|
|
2135
|
-
if (!
|
|
2135
|
+
if (!entry || typeof entry !== "object")
|
|
2136
2136
|
continue;
|
|
2137
|
-
const obj =
|
|
2137
|
+
const obj = entry;
|
|
2138
2138
|
if (obj.type !== "assistant")
|
|
2139
2139
|
continue;
|
|
2140
2140
|
const message = obj.message;
|
|
@@ -2982,7 +2982,7 @@ function isStep0Block(content) {
|
|
|
2982
2982
|
}
|
|
2983
2983
|
function checkCommandsCarryOutput(prBody) {
|
|
2984
2984
|
const errors = [];
|
|
2985
|
-
for (const [
|
|
2985
|
+
for (const [label, num] of [
|
|
2986
2986
|
["5", 5],
|
|
2987
2987
|
["6", 6]
|
|
2988
2988
|
]) {
|
|
@@ -2996,7 +2996,7 @@ function checkCommandsCarryOutput(prBody) {
|
|
|
2996
2996
|
continue;
|
|
2997
2997
|
const next = blocks[i + 1];
|
|
2998
2998
|
if (!next || isCommandBlock(next.content)) {
|
|
2999
|
-
errors.push(`brief-validation commands carry output: §${
|
|
2999
|
+
errors.push(`brief-validation commands carry output: §${label} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
|
|
3000
3000
|
}
|
|
3001
3001
|
}
|
|
3002
3002
|
}
|
|
@@ -3433,8 +3433,8 @@ function stripPartBackticks(text) {
|
|
|
3433
3433
|
function partWordCount(text) {
|
|
3434
3434
|
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3435
3435
|
}
|
|
3436
|
-
function looksLikeFilePath(
|
|
3437
|
-
const stripped =
|
|
3436
|
+
function looksLikeFilePath(entry) {
|
|
3437
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3438
3438
|
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3439
3439
|
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3440
3440
|
return extMatch !== null && extMatch.index > 0;
|
|
@@ -3920,14 +3920,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3920
3920
|
const referenced = extractClosesReferences(prBody);
|
|
3921
3921
|
if (taskIssueRefs) {
|
|
3922
3922
|
for (const n of referenced) {
|
|
3923
|
-
const
|
|
3924
|
-
if (!
|
|
3923
|
+
const ref = taskIssueRefs.get(n);
|
|
3924
|
+
if (!ref)
|
|
3925
3925
|
continue;
|
|
3926
|
-
const expectedBranch = `task/${
|
|
3926
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
3927
3927
|
if (branch !== expectedBranch) {
|
|
3928
3928
|
return {
|
|
3929
3929
|
ok: false,
|
|
3930
|
-
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${
|
|
3930
|
+
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
|
|
3931
3931
|
};
|
|
3932
3932
|
}
|
|
3933
3933
|
}
|
|
@@ -3936,15 +3936,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3936
3936
|
if (!ref)
|
|
3937
3937
|
return { ok: true };
|
|
3938
3938
|
if (ref.kind === "issue") {
|
|
3939
|
-
const
|
|
3940
|
-
if (!referenced.has(
|
|
3939
|
+
const expectedIssue = ref.issueNumber;
|
|
3940
|
+
if (!referenced.has(expectedIssue)) {
|
|
3941
3941
|
return {
|
|
3942
3942
|
ok: false,
|
|
3943
|
-
expectedIssue
|
|
3944
|
-
message: `closes-n: PR body does not contain \`Closes #${
|
|
3943
|
+
expectedIssue,
|
|
3944
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3945
3945
|
};
|
|
3946
3946
|
}
|
|
3947
|
-
return { ok: true, expectedIssue
|
|
3947
|
+
return { ok: true, expectedIssue };
|
|
3948
3948
|
}
|
|
3949
3949
|
const trancheSlug = ref.tranche;
|
|
3950
3950
|
const taskId = ref.taskId;
|
|
@@ -3990,8 +3990,8 @@ function extractIssue(body) {
|
|
|
3990
3990
|
const anchorNums = closesRefs(anchored);
|
|
3991
3991
|
if (anchorNums.length === 0)
|
|
3992
3992
|
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
3993
|
-
const
|
|
3994
|
-
return { issue
|
|
3993
|
+
const issue = anchorNums[0];
|
|
3994
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
3995
3995
|
}
|
|
3996
3996
|
const headerNums = closesRefs(headerRegion(stripped));
|
|
3997
3997
|
if (bodyNums.length === 0)
|
|
@@ -4060,15 +4060,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4060
4060
|
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4061
4061
|
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4062
4062
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4063
|
-
const
|
|
4063
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4064
4064
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4065
4065
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4066
4066
|
return {
|
|
4067
|
-
bound: head && base && briefHashBound &&
|
|
4067
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4068
4068
|
head,
|
|
4069
4069
|
base,
|
|
4070
4070
|
briefHash: briefHashBound,
|
|
4071
|
-
objectivesVersion
|
|
4071
|
+
objectivesVersion,
|
|
4072
4072
|
rulingOrdinal,
|
|
4073
4073
|
policyDigest: policyDigestBound
|
|
4074
4074
|
};
|
|
@@ -5500,6 +5500,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5500
5500
|
}
|
|
5501
5501
|
return findings;
|
|
5502
5502
|
}
|
|
5503
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5504
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5505
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5506
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5503
5507
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5504
5508
|
import { createHash as createHash5 } from "node:crypto";
|
|
5505
5509
|
|
|
@@ -6038,6 +6042,7 @@ function redact(value, home) {
|
|
|
6038
6042
|
return value;
|
|
6039
6043
|
}
|
|
6040
6044
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6045
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6041
6046
|
function metaOf(obj) {
|
|
6042
6047
|
if (obj === null || typeof obj !== "object")
|
|
6043
6048
|
return null;
|
|
@@ -6060,11 +6065,61 @@ function recordIdentity(obj) {
|
|
|
6060
6065
|
}
|
|
6061
6066
|
return null;
|
|
6062
6067
|
}
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
+
function schemaVersionOf(obj) {
|
|
6069
|
+
const meta = metaOf(obj);
|
|
6070
|
+
const schema = meta?.schema;
|
|
6071
|
+
return typeof schema === "number" ? schema : null;
|
|
6072
|
+
}
|
|
6073
|
+
function isKnownSchema(version) {
|
|
6074
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
6075
|
+
}
|
|
6076
|
+
function classifyStoredLine(raw, home) {
|
|
6077
|
+
let obj;
|
|
6078
|
+
try {
|
|
6079
|
+
obj = JSON.parse(raw);
|
|
6080
|
+
} catch {
|
|
6081
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
6082
|
+
}
|
|
6083
|
+
const version = schemaVersionOf(obj);
|
|
6084
|
+
if (version === null) {
|
|
6085
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
6086
|
+
}
|
|
6087
|
+
if (!isKnownSchema(version)) {
|
|
6088
|
+
return {
|
|
6089
|
+
status: "unknown_version",
|
|
6090
|
+
identity: recordIdentity(obj),
|
|
6091
|
+
schema: version,
|
|
6092
|
+
raw,
|
|
6093
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
6094
|
+
};
|
|
6095
|
+
}
|
|
6096
|
+
const result = LogEventSchema.safeParse(obj);
|
|
6097
|
+
if (!result.success) {
|
|
6098
|
+
return {
|
|
6099
|
+
status: "invalid",
|
|
6100
|
+
identity: recordIdentity(obj),
|
|
6101
|
+
raw,
|
|
6102
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
6103
|
+
};
|
|
6104
|
+
}
|
|
6105
|
+
const event = result.data;
|
|
6106
|
+
const identity = recordIdentity(event);
|
|
6107
|
+
if (identity === null) {
|
|
6108
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6109
|
+
}
|
|
6110
|
+
const redacted = redact(event, home);
|
|
6111
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
6112
|
+
return {
|
|
6113
|
+
status: "ok",
|
|
6114
|
+
identity,
|
|
6115
|
+
runId: event.meta.run_id,
|
|
6116
|
+
seq: event.meta.seq,
|
|
6117
|
+
schema: version,
|
|
6118
|
+
provenance,
|
|
6119
|
+
event,
|
|
6120
|
+
postLine: JSON.stringify(redacted)
|
|
6121
|
+
};
|
|
6122
|
+
}
|
|
6068
6123
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6069
6124
|
import { z as z3 } from "zod";
|
|
6070
6125
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -6205,7 +6260,8 @@ function emitCheckError(error) {
|
|
|
6205
6260
|
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve2, sep } from "node:path";
|
|
6206
6261
|
|
|
6207
6262
|
// src/lib/config.ts
|
|
6208
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6263
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6264
|
+
import { promisify as promisify4 } from "node:util";
|
|
6209
6265
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6210
6266
|
import { homedir } from "node:os";
|
|
6211
6267
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -6232,10 +6288,10 @@ var CheckEntrySchema = z4.object({
|
|
|
6232
6288
|
ownWorkflow: z4.boolean().optional(),
|
|
6233
6289
|
principalOwed: z4.literal(true).optional(),
|
|
6234
6290
|
validates: z4.enum(["body", "issue"]).optional()
|
|
6235
|
-
}).superRefine((
|
|
6236
|
-
if (!
|
|
6291
|
+
}).superRefine((entry, ctx) => {
|
|
6292
|
+
if (!entry.env)
|
|
6237
6293
|
return;
|
|
6238
|
-
for (const [key, value] of Object.entries(
|
|
6294
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
6239
6295
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6240
6296
|
continue;
|
|
6241
6297
|
const members = value.anyOf;
|
|
@@ -6392,18 +6448,19 @@ var VinayaConfigSchema = z4.object({
|
|
|
6392
6448
|
});
|
|
6393
6449
|
}
|
|
6394
6450
|
}).optional(),
|
|
6395
|
-
logPublish: z4.
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
}).refine((v) => v.
|
|
6404
|
-
message: "
|
|
6405
|
-
}).
|
|
6406
|
-
|
|
6451
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6452
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6453
|
+
}),
|
|
6454
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6455
|
+
logs: z4.object({
|
|
6456
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6457
|
+
url: z4.string().url().optional(),
|
|
6458
|
+
headers: z4.record(z4.string()).optional()
|
|
6459
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6460
|
+
message: "logs: set at most one of folder/url"
|
|
6461
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6462
|
+
message: "logs: headers requires url"
|
|
6463
|
+
}).optional()
|
|
6407
6464
|
});
|
|
6408
6465
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
6409
6466
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
@@ -6448,32 +6505,39 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
6448
6505
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
6449
6506
|
return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
|
|
6450
6507
|
}
|
|
6508
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
6509
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
6510
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
6511
|
+
return;
|
|
6512
|
+
emittedGlobalKeyWarnings.add(message);
|
|
6513
|
+
console.error(`⚠ ${message}`);
|
|
6514
|
+
}
|
|
6451
6515
|
function stripGlobalOnlyKeys(config, path) {
|
|
6452
6516
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
6453
6517
|
return config;
|
|
6454
6518
|
let result = config;
|
|
6455
6519
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6456
|
-
|
|
6520
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6457
6521
|
result = { ...result, checks: undefined };
|
|
6458
6522
|
}
|
|
6459
6523
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6460
|
-
|
|
6524
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6461
6525
|
result = { ...result, roles: undefined };
|
|
6462
6526
|
}
|
|
6463
6527
|
if (result.principals && result.principals.length > 0) {
|
|
6464
|
-
|
|
6528
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6465
6529
|
result = { ...result, principals: undefined };
|
|
6466
6530
|
}
|
|
6467
6531
|
if (result.releaseActor) {
|
|
6468
|
-
|
|
6532
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6469
6533
|
result = { ...result, releaseActor: undefined };
|
|
6470
6534
|
}
|
|
6471
6535
|
if (result.tokens) {
|
|
6472
|
-
|
|
6536
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6473
6537
|
result = { ...result, tokens: undefined };
|
|
6474
6538
|
}
|
|
6475
6539
|
if (result.runtimeDir) {
|
|
6476
|
-
|
|
6540
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6477
6541
|
result = { ...result, runtimeDir: undefined };
|
|
6478
6542
|
}
|
|
6479
6543
|
return result;
|
|
@@ -6506,25 +6570,80 @@ function resolveReviewPolicy(config) {
|
|
|
6506
6570
|
maxRounds
|
|
6507
6571
|
};
|
|
6508
6572
|
}
|
|
6509
|
-
function
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6573
|
+
function resolveRuntimeDirSetting(config) {
|
|
6574
|
+
return config?.runtimeDir ?? null;
|
|
6575
|
+
}
|
|
6576
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6577
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6578
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6579
|
+
}
|
|
6580
|
+
function resolveLogsSetting(config) {
|
|
6581
|
+
const raw = config?.logs;
|
|
6582
|
+
if (!raw)
|
|
6583
|
+
return null;
|
|
6584
|
+
if (raw.url !== undefined)
|
|
6585
|
+
return { url: raw.url, headers: raw.headers };
|
|
6586
|
+
if (raw.folder !== undefined)
|
|
6587
|
+
return { folder: raw.folder };
|
|
6588
|
+
return null;
|
|
6589
|
+
}
|
|
6590
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6591
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6592
|
+
if (!anchored)
|
|
6593
|
+
return null;
|
|
6594
|
+
if ("url" in local)
|
|
6595
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6596
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6597
|
+
}
|
|
6598
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
6599
|
+
if (!headers)
|
|
6600
|
+
return;
|
|
6601
|
+
const resolved = {};
|
|
6602
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6603
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
6516
6604
|
}
|
|
6605
|
+
return resolved;
|
|
6606
|
+
}
|
|
6607
|
+
function trustAnchorRepo() {
|
|
6608
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6609
|
+
if (fromRunner)
|
|
6610
|
+
return fromRunner;
|
|
6517
6611
|
try {
|
|
6518
6612
|
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
6519
6613
|
encoding: "utf-8",
|
|
6520
6614
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6521
|
-
})
|
|
6522
|
-
|
|
6523
|
-
|
|
6615
|
+
});
|
|
6616
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
6617
|
+
} catch {
|
|
6618
|
+
return null;
|
|
6619
|
+
}
|
|
6620
|
+
}
|
|
6621
|
+
async function trustAnchorRepoAsync() {
|
|
6622
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6623
|
+
if (fromRunner)
|
|
6624
|
+
return fromRunner;
|
|
6625
|
+
try {
|
|
6626
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6627
|
+
encoding: "utf-8",
|
|
6628
|
+
timeout: 1e4
|
|
6629
|
+
});
|
|
6630
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6524
6631
|
} catch {
|
|
6525
6632
|
return null;
|
|
6526
6633
|
}
|
|
6527
6634
|
}
|
|
6635
|
+
function wellFormedRepoSlug(slug) {
|
|
6636
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6637
|
+
}
|
|
6638
|
+
function trustAnchorRepoFromRunner() {
|
|
6639
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6640
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6641
|
+
}
|
|
6642
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6643
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6644
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6645
|
+
}
|
|
6646
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
6528
6647
|
function ghFetchTrustAnchorConfig() {
|
|
6529
6648
|
const repo = trustAnchorRepo();
|
|
6530
6649
|
if (!repo)
|
|
@@ -6534,6 +6653,13 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6534
6653
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6535
6654
|
});
|
|
6536
6655
|
}
|
|
6656
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
6657
|
+
const repo = await trustAnchorRepoAsync();
|
|
6658
|
+
if (!repo)
|
|
6659
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6660
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6661
|
+
return stdout;
|
|
6662
|
+
}
|
|
6537
6663
|
function firstLine(err) {
|
|
6538
6664
|
return err?.message?.split(`
|
|
6539
6665
|
`)[0] ?? "unknown error";
|
|
@@ -6548,16 +6674,35 @@ function isMissingFileError(err) {
|
|
|
6548
6674
|
return /\b404\b|not found/i.test(haystack);
|
|
6549
6675
|
}
|
|
6550
6676
|
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6551
|
-
const warn = (why) => process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
6552
|
-
`);
|
|
6553
6677
|
let base64;
|
|
6554
6678
|
try {
|
|
6555
|
-
base64 = fetcher()
|
|
6679
|
+
base64 = fetcher();
|
|
6556
6680
|
} catch (err) {
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6681
|
+
return trustAnchorFetchFailed(err);
|
|
6682
|
+
}
|
|
6683
|
+
return parseTrustAnchorContent(base64);
|
|
6684
|
+
}
|
|
6685
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6686
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
6687
|
+
let base64;
|
|
6688
|
+
try {
|
|
6689
|
+
base64 = await fetcher();
|
|
6690
|
+
} catch (err) {
|
|
6691
|
+
return trustAnchorFetchFailed(err, warn);
|
|
6560
6692
|
}
|
|
6693
|
+
return parseTrustAnchorContent(base64, warn);
|
|
6694
|
+
}
|
|
6695
|
+
function warnTrustAnchorFallback(why) {
|
|
6696
|
+
process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
|
|
6697
|
+
`);
|
|
6698
|
+
}
|
|
6699
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
6700
|
+
if (!isMissingFileError(err))
|
|
6701
|
+
warn(firstLine(err));
|
|
6702
|
+
return null;
|
|
6703
|
+
}
|
|
6704
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
6705
|
+
const base64 = content.trim();
|
|
6561
6706
|
if (!base64)
|
|
6562
6707
|
return null;
|
|
6563
6708
|
try {
|