@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
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
2
|
|
|
5
3
|
// src/checks/bin/check-body-bare-digits.ts
|
|
6
4
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
@@ -1037,7 +1035,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
1037
1035
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
1038
1036
|
|
|
1039
1037
|
// ../../node_modules/fast-content-type-parse/index.js
|
|
1040
|
-
var NullObject = function
|
|
1038
|
+
var NullObject = function NullObject() {};
|
|
1041
1039
|
NullObject.prototype = Object.create(null);
|
|
1042
1040
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
1043
1041
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
@@ -1781,27 +1779,27 @@ function splitTableRow(row) {
|
|
|
1781
1779
|
return parts.map((p) => p.split(PLACEHOLDER).join("|"));
|
|
1782
1780
|
}
|
|
1783
1781
|
// ../../packages/aeg-core/src/blast-radius-domains.ts
|
|
1784
|
-
function resolveWorkspaceEntry(
|
|
1785
|
-
if (
|
|
1786
|
-
const baseDir =
|
|
1782
|
+
function resolveWorkspaceEntry(entry, listDirs) {
|
|
1783
|
+
if (entry.endsWith("/*")) {
|
|
1784
|
+
const baseDir = entry.slice(0, -2);
|
|
1787
1785
|
return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
|
|
1788
1786
|
}
|
|
1789
|
-
if (
|
|
1787
|
+
if (entry.includes("*"))
|
|
1790
1788
|
return [];
|
|
1791
|
-
return [
|
|
1789
|
+
return [entry];
|
|
1792
1790
|
}
|
|
1793
1791
|
// ../../packages/aeg-core/src/consumer-enumeration.ts
|
|
1794
1792
|
function deriveWorkspaceMemberDirs(workspaces, listDirs) {
|
|
1795
|
-
const positive = workspaces.filter((
|
|
1796
|
-
const negative = workspaces.filter((
|
|
1793
|
+
const positive = workspaces.filter((entry) => !entry.startsWith("!"));
|
|
1794
|
+
const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
|
|
1797
1795
|
const excluded = new Set;
|
|
1798
|
-
for (const
|
|
1799
|
-
for (const member of resolveWorkspaceEntry(
|
|
1796
|
+
for (const entry of negative) {
|
|
1797
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs))
|
|
1800
1798
|
excluded.add(member);
|
|
1801
1799
|
}
|
|
1802
1800
|
const members = new Set;
|
|
1803
|
-
for (const
|
|
1804
|
-
for (const member of resolveWorkspaceEntry(
|
|
1801
|
+
for (const entry of positive) {
|
|
1802
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs)) {
|
|
1805
1803
|
if (!excluded.has(member))
|
|
1806
1804
|
members.add(member);
|
|
1807
1805
|
}
|
|
@@ -2125,15 +2123,15 @@ function summarizeTranscript(jsonl) {
|
|
|
2125
2123
|
const line = rawLine.trim();
|
|
2126
2124
|
if (!line)
|
|
2127
2125
|
continue;
|
|
2128
|
-
let
|
|
2126
|
+
let entry;
|
|
2129
2127
|
try {
|
|
2130
|
-
|
|
2128
|
+
entry = JSON.parse(line);
|
|
2131
2129
|
} catch {
|
|
2132
2130
|
continue;
|
|
2133
2131
|
}
|
|
2134
|
-
if (!
|
|
2132
|
+
if (!entry || typeof entry !== "object")
|
|
2135
2133
|
continue;
|
|
2136
|
-
const obj =
|
|
2134
|
+
const obj = entry;
|
|
2137
2135
|
if (obj.type !== "assistant")
|
|
2138
2136
|
continue;
|
|
2139
2137
|
const message = obj.message;
|
|
@@ -2981,7 +2979,7 @@ function isStep0Block(content) {
|
|
|
2981
2979
|
}
|
|
2982
2980
|
function checkCommandsCarryOutput(prBody) {
|
|
2983
2981
|
const errors = [];
|
|
2984
|
-
for (const [
|
|
2982
|
+
for (const [label, num] of [
|
|
2985
2983
|
["5", 5],
|
|
2986
2984
|
["6", 6]
|
|
2987
2985
|
]) {
|
|
@@ -2995,7 +2993,7 @@ function checkCommandsCarryOutput(prBody) {
|
|
|
2995
2993
|
continue;
|
|
2996
2994
|
const next = blocks[i + 1];
|
|
2997
2995
|
if (!next || isCommandBlock(next.content)) {
|
|
2998
|
-
errors.push(`brief-validation commands carry output: §${
|
|
2996
|
+
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.`);
|
|
2999
2997
|
}
|
|
3000
2998
|
}
|
|
3001
2999
|
}
|
|
@@ -3432,8 +3430,8 @@ function stripPartBackticks(text) {
|
|
|
3432
3430
|
function partWordCount(text) {
|
|
3433
3431
|
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3434
3432
|
}
|
|
3435
|
-
function looksLikeFilePath(
|
|
3436
|
-
const stripped =
|
|
3433
|
+
function looksLikeFilePath(entry) {
|
|
3434
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3437
3435
|
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3438
3436
|
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3439
3437
|
return extMatch !== null && extMatch.index > 0;
|
|
@@ -3919,14 +3917,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3919
3917
|
const referenced = extractClosesReferences(prBody);
|
|
3920
3918
|
if (taskIssueRefs) {
|
|
3921
3919
|
for (const n of referenced) {
|
|
3922
|
-
const
|
|
3923
|
-
if (!
|
|
3920
|
+
const ref = taskIssueRefs.get(n);
|
|
3921
|
+
if (!ref)
|
|
3924
3922
|
continue;
|
|
3925
|
-
const expectedBranch = `task/${
|
|
3923
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
3926
3924
|
if (branch !== expectedBranch) {
|
|
3927
3925
|
return {
|
|
3928
3926
|
ok: false,
|
|
3929
|
-
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${
|
|
3927
|
+
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.`
|
|
3930
3928
|
};
|
|
3931
3929
|
}
|
|
3932
3930
|
}
|
|
@@ -3935,15 +3933,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3935
3933
|
if (!ref)
|
|
3936
3934
|
return { ok: true };
|
|
3937
3935
|
if (ref.kind === "issue") {
|
|
3938
|
-
const
|
|
3939
|
-
if (!referenced.has(
|
|
3936
|
+
const expectedIssue = ref.issueNumber;
|
|
3937
|
+
if (!referenced.has(expectedIssue)) {
|
|
3940
3938
|
return {
|
|
3941
3939
|
ok: false,
|
|
3942
|
-
expectedIssue
|
|
3943
|
-
message: `closes-n: PR body does not contain \`Closes #${
|
|
3940
|
+
expectedIssue,
|
|
3941
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3944
3942
|
};
|
|
3945
3943
|
}
|
|
3946
|
-
return { ok: true, expectedIssue
|
|
3944
|
+
return { ok: true, expectedIssue };
|
|
3947
3945
|
}
|
|
3948
3946
|
const trancheSlug = ref.tranche;
|
|
3949
3947
|
const taskId = ref.taskId;
|
|
@@ -3989,8 +3987,8 @@ function extractIssue(body) {
|
|
|
3989
3987
|
const anchorNums = closesRefs(anchored);
|
|
3990
3988
|
if (anchorNums.length === 0)
|
|
3991
3989
|
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
3992
|
-
const
|
|
3993
|
-
return { issue
|
|
3990
|
+
const issue = anchorNums[0];
|
|
3991
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
3994
3992
|
}
|
|
3995
3993
|
const headerNums = closesRefs(headerRegion(stripped));
|
|
3996
3994
|
if (bodyNums.length === 0)
|
|
@@ -4059,15 +4057,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4059
4057
|
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4060
4058
|
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4061
4059
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4062
|
-
const
|
|
4060
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4063
4061
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4064
4062
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4065
4063
|
return {
|
|
4066
|
-
bound: head && base && briefHashBound &&
|
|
4064
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4067
4065
|
head,
|
|
4068
4066
|
base,
|
|
4069
4067
|
briefHash: briefHashBound,
|
|
4070
|
-
objectivesVersion
|
|
4068
|
+
objectivesVersion,
|
|
4071
4069
|
rulingOrdinal,
|
|
4072
4070
|
policyDigest: policyDigestBound
|
|
4073
4071
|
};
|
|
@@ -5499,6 +5497,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5499
5497
|
}
|
|
5500
5498
|
return findings;
|
|
5501
5499
|
}
|
|
5500
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5501
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5502
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5503
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5502
5504
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5503
5505
|
import { createHash as createHash5 } from "node:crypto";
|
|
5504
5506
|
|
|
@@ -6037,6 +6039,7 @@ function redact(value, home) {
|
|
|
6037
6039
|
return value;
|
|
6038
6040
|
}
|
|
6039
6041
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6042
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6040
6043
|
function metaOf(obj) {
|
|
6041
6044
|
if (obj === null || typeof obj !== "object")
|
|
6042
6045
|
return null;
|
|
@@ -6059,11 +6062,61 @@ function recordIdentity(obj) {
|
|
|
6059
6062
|
}
|
|
6060
6063
|
return null;
|
|
6061
6064
|
}
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6065
|
+
function schemaVersionOf(obj) {
|
|
6066
|
+
const meta = metaOf(obj);
|
|
6067
|
+
const schema = meta?.schema;
|
|
6068
|
+
return typeof schema === "number" ? schema : null;
|
|
6069
|
+
}
|
|
6070
|
+
function isKnownSchema(version) {
|
|
6071
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
6072
|
+
}
|
|
6073
|
+
function classifyStoredLine(raw, home) {
|
|
6074
|
+
let obj;
|
|
6075
|
+
try {
|
|
6076
|
+
obj = JSON.parse(raw);
|
|
6077
|
+
} catch {
|
|
6078
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
6079
|
+
}
|
|
6080
|
+
const version = schemaVersionOf(obj);
|
|
6081
|
+
if (version === null) {
|
|
6082
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
6083
|
+
}
|
|
6084
|
+
if (!isKnownSchema(version)) {
|
|
6085
|
+
return {
|
|
6086
|
+
status: "unknown_version",
|
|
6087
|
+
identity: recordIdentity(obj),
|
|
6088
|
+
schema: version,
|
|
6089
|
+
raw,
|
|
6090
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
6091
|
+
};
|
|
6092
|
+
}
|
|
6093
|
+
const result = LogEventSchema.safeParse(obj);
|
|
6094
|
+
if (!result.success) {
|
|
6095
|
+
return {
|
|
6096
|
+
status: "invalid",
|
|
6097
|
+
identity: recordIdentity(obj),
|
|
6098
|
+
raw,
|
|
6099
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
6100
|
+
};
|
|
6101
|
+
}
|
|
6102
|
+
const event = result.data;
|
|
6103
|
+
const identity = recordIdentity(event);
|
|
6104
|
+
if (identity === null) {
|
|
6105
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6106
|
+
}
|
|
6107
|
+
const redacted = redact(event, home);
|
|
6108
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
6109
|
+
return {
|
|
6110
|
+
status: "ok",
|
|
6111
|
+
identity,
|
|
6112
|
+
runId: event.meta.run_id,
|
|
6113
|
+
seq: event.meta.seq,
|
|
6114
|
+
schema: version,
|
|
6115
|
+
provenance,
|
|
6116
|
+
event,
|
|
6117
|
+
postLine: JSON.stringify(redacted)
|
|
6118
|
+
};
|
|
6119
|
+
}
|
|
6067
6120
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6068
6121
|
import { z as z3 } from "zod";
|
|
6069
6122
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -6194,7 +6247,8 @@ var ResolutionRecordSchema = z3.object({
|
|
|
6194
6247
|
consumedAt: isoTimestamp
|
|
6195
6248
|
}).strict();
|
|
6196
6249
|
// src/lib/config.ts
|
|
6197
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6250
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
6251
|
+
import { promisify as promisify4 } from "node:util";
|
|
6198
6252
|
import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
|
|
6199
6253
|
import { homedir } from "node:os";
|
|
6200
6254
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -6221,10 +6275,10 @@ var CheckEntrySchema = z4.object({
|
|
|
6221
6275
|
ownWorkflow: z4.boolean().optional(),
|
|
6222
6276
|
principalOwed: z4.literal(true).optional(),
|
|
6223
6277
|
validates: z4.enum(["body", "issue"]).optional()
|
|
6224
|
-
}).superRefine((
|
|
6225
|
-
if (!
|
|
6278
|
+
}).superRefine((entry, ctx) => {
|
|
6279
|
+
if (!entry.env)
|
|
6226
6280
|
return;
|
|
6227
|
-
for (const [key, value] of Object.entries(
|
|
6281
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
6228
6282
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6229
6283
|
continue;
|
|
6230
6284
|
const members = value.anyOf;
|
|
@@ -6381,18 +6435,19 @@ var VinayaConfigSchema = z4.object({
|
|
|
6381
6435
|
});
|
|
6382
6436
|
}
|
|
6383
6437
|
}).optional(),
|
|
6384
|
-
logPublish: z4.
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
}).refine((v) => v.
|
|
6393
|
-
message: "
|
|
6394
|
-
}).
|
|
6395
|
-
|
|
6438
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6439
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6440
|
+
}),
|
|
6441
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6442
|
+
logs: z4.object({
|
|
6443
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6444
|
+
url: z4.string().url().optional(),
|
|
6445
|
+
headers: z4.record(z4.string()).optional()
|
|
6446
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6447
|
+
message: "logs: set at most one of folder/url"
|
|
6448
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6449
|
+
message: "logs: headers requires url"
|
|
6450
|
+
}).optional()
|
|
6396
6451
|
});
|
|
6397
6452
|
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
6398
6453
|
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
@@ -6437,32 +6492,39 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
6437
6492
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
6438
6493
|
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.`;
|
|
6439
6494
|
}
|
|
6495
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
6496
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
6497
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
6498
|
+
return;
|
|
6499
|
+
emittedGlobalKeyWarnings.add(message);
|
|
6500
|
+
console.error(`⚠ ${message}`);
|
|
6501
|
+
}
|
|
6440
6502
|
function stripGlobalOnlyKeys(config, path) {
|
|
6441
6503
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
6442
6504
|
return config;
|
|
6443
6505
|
let result = config;
|
|
6444
6506
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6445
|
-
|
|
6507
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6446
6508
|
result = { ...result, checks: undefined };
|
|
6447
6509
|
}
|
|
6448
6510
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6449
|
-
|
|
6511
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6450
6512
|
result = { ...result, roles: undefined };
|
|
6451
6513
|
}
|
|
6452
6514
|
if (result.principals && result.principals.length > 0) {
|
|
6453
|
-
|
|
6515
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6454
6516
|
result = { ...result, principals: undefined };
|
|
6455
6517
|
}
|
|
6456
6518
|
if (result.releaseActor) {
|
|
6457
|
-
|
|
6519
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6458
6520
|
result = { ...result, releaseActor: undefined };
|
|
6459
6521
|
}
|
|
6460
6522
|
if (result.tokens) {
|
|
6461
|
-
|
|
6523
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6462
6524
|
result = { ...result, tokens: undefined };
|
|
6463
6525
|
}
|
|
6464
6526
|
if (result.runtimeDir) {
|
|
6465
|
-
|
|
6527
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6466
6528
|
result = { ...result, runtimeDir: undefined };
|
|
6467
6529
|
}
|
|
6468
6530
|
return result;
|
|
@@ -6495,25 +6557,80 @@ function resolveReviewPolicy(config) {
|
|
|
6495
6557
|
maxRounds
|
|
6496
6558
|
};
|
|
6497
6559
|
}
|
|
6498
|
-
function
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6560
|
+
function resolveRuntimeDirSetting(config) {
|
|
6561
|
+
return config?.runtimeDir ?? null;
|
|
6562
|
+
}
|
|
6563
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6564
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6565
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6566
|
+
}
|
|
6567
|
+
function resolveLogsSetting(config) {
|
|
6568
|
+
const raw = config?.logs;
|
|
6569
|
+
if (!raw)
|
|
6570
|
+
return null;
|
|
6571
|
+
if (raw.url !== undefined)
|
|
6572
|
+
return { url: raw.url, headers: raw.headers };
|
|
6573
|
+
if (raw.folder !== undefined)
|
|
6574
|
+
return { folder: raw.folder };
|
|
6575
|
+
return null;
|
|
6576
|
+
}
|
|
6577
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6578
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6579
|
+
if (!anchored)
|
|
6580
|
+
return null;
|
|
6581
|
+
if ("url" in local)
|
|
6582
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6583
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6584
|
+
}
|
|
6585
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
6586
|
+
if (!headers)
|
|
6587
|
+
return;
|
|
6588
|
+
const resolved = {};
|
|
6589
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6590
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
6505
6591
|
}
|
|
6592
|
+
return resolved;
|
|
6593
|
+
}
|
|
6594
|
+
function trustAnchorRepo() {
|
|
6595
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6596
|
+
if (fromRunner)
|
|
6597
|
+
return fromRunner;
|
|
6506
6598
|
try {
|
|
6507
6599
|
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
6508
6600
|
encoding: "utf-8",
|
|
6509
6601
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6510
|
-
})
|
|
6511
|
-
|
|
6512
|
-
|
|
6602
|
+
});
|
|
6603
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
6604
|
+
} catch {
|
|
6605
|
+
return null;
|
|
6606
|
+
}
|
|
6607
|
+
}
|
|
6608
|
+
async function trustAnchorRepoAsync() {
|
|
6609
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6610
|
+
if (fromRunner)
|
|
6611
|
+
return fromRunner;
|
|
6612
|
+
try {
|
|
6613
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6614
|
+
encoding: "utf-8",
|
|
6615
|
+
timeout: 1e4
|
|
6616
|
+
});
|
|
6617
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6513
6618
|
} catch {
|
|
6514
6619
|
return null;
|
|
6515
6620
|
}
|
|
6516
6621
|
}
|
|
6622
|
+
function wellFormedRepoSlug(slug) {
|
|
6623
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6624
|
+
}
|
|
6625
|
+
function trustAnchorRepoFromRunner() {
|
|
6626
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6627
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6628
|
+
}
|
|
6629
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6630
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6631
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6632
|
+
}
|
|
6633
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
6517
6634
|
function ghFetchTrustAnchorConfig() {
|
|
6518
6635
|
const repo = trustAnchorRepo();
|
|
6519
6636
|
if (!repo)
|
|
@@ -6523,6 +6640,13 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6523
6640
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6524
6641
|
});
|
|
6525
6642
|
}
|
|
6643
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
6644
|
+
const repo = await trustAnchorRepoAsync();
|
|
6645
|
+
if (!repo)
|
|
6646
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6647
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6648
|
+
return stdout;
|
|
6649
|
+
}
|
|
6526
6650
|
function firstLine(err) {
|
|
6527
6651
|
return err?.message?.split(`
|
|
6528
6652
|
`)[0] ?? "unknown error";
|
|
@@ -6537,16 +6661,35 @@ function isMissingFileError(err) {
|
|
|
6537
6661
|
return /\b404\b|not found/i.test(haystack);
|
|
6538
6662
|
}
|
|
6539
6663
|
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6540
|
-
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.
|
|
6541
|
-
`);
|
|
6542
6664
|
let base64;
|
|
6543
6665
|
try {
|
|
6544
|
-
base64 = fetcher()
|
|
6666
|
+
base64 = fetcher();
|
|
6545
6667
|
} catch (err) {
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6668
|
+
return trustAnchorFetchFailed(err);
|
|
6669
|
+
}
|
|
6670
|
+
return parseTrustAnchorContent(base64);
|
|
6671
|
+
}
|
|
6672
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6673
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
6674
|
+
let base64;
|
|
6675
|
+
try {
|
|
6676
|
+
base64 = await fetcher();
|
|
6677
|
+
} catch (err) {
|
|
6678
|
+
return trustAnchorFetchFailed(err, warn);
|
|
6549
6679
|
}
|
|
6680
|
+
return parseTrustAnchorContent(base64, warn);
|
|
6681
|
+
}
|
|
6682
|
+
function warnTrustAnchorFallback(why) {
|
|
6683
|
+
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.
|
|
6684
|
+
`);
|
|
6685
|
+
}
|
|
6686
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
6687
|
+
if (!isMissingFileError(err))
|
|
6688
|
+
warn(firstLine(err));
|
|
6689
|
+
return null;
|
|
6690
|
+
}
|
|
6691
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
6692
|
+
const base64 = content.trim();
|
|
6550
6693
|
if (!base64)
|
|
6551
6694
|
return null;
|
|
6552
6695
|
try {
|
|
@@ -6767,14 +6910,14 @@ function blankAnchoredRegions(body) {
|
|
|
6767
6910
|
function blankTokenReportSection(body) {
|
|
6768
6911
|
const lines = body.split(`
|
|
6769
6912
|
`);
|
|
6770
|
-
const
|
|
6771
|
-
const
|
|
6772
|
-
const startIdx = lines.findIndex((l) =>
|
|
6913
|
+
const HEADING = /^#{1,6}\s/;
|
|
6914
|
+
const TOKEN_REPORT_HEADING = /^#{1,6}\s*token report\s*$/i;
|
|
6915
|
+
const startIdx = lines.findIndex((l) => TOKEN_REPORT_HEADING.test(l));
|
|
6773
6916
|
if (startIdx === -1)
|
|
6774
6917
|
return body;
|
|
6775
6918
|
let endIdx = lines.length;
|
|
6776
6919
|
for (let i = startIdx + 1;i < lines.length; i++) {
|
|
6777
|
-
if (
|
|
6920
|
+
if (HEADING.test(lines[i])) {
|
|
6778
6921
|
endIdx = i;
|
|
6779
6922
|
break;
|
|
6780
6923
|
}
|
|
@@ -6793,10 +6936,10 @@ function blankTierField(line) {
|
|
|
6793
6936
|
}
|
|
6794
6937
|
var SEGMENT_HAS_DIGIT = /\p{Nd}/u;
|
|
6795
6938
|
function blankProjectField(line) {
|
|
6796
|
-
const
|
|
6797
|
-
if (!
|
|
6939
|
+
const label = PROJECT_LABEL.exec(line);
|
|
6940
|
+
if (!label)
|
|
6798
6941
|
return line;
|
|
6799
|
-
const valueStart =
|
|
6942
|
+
const valueStart = label.index + label[0].length;
|
|
6800
6943
|
const segments = line.slice(valueStart).split(",");
|
|
6801
6944
|
const blanked = segments.map((seg) => {
|
|
6802
6945
|
const name = unwrapValue(seg);
|