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