@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.
Files changed (46) hide show
  1. package/README.md +1 -2
  2. package/aeg-root/roles/developer/reference.md +3 -3
  3. package/aeg-root/templates/pr-report-template.md +7 -2
  4. package/dist/checks/bin/check-body-bare-digits.js +229 -86
  5. package/dist/checks/bin/check-branch-topology.js +101 -89
  6. package/dist/checks/bin/check-brief-shape.js +222 -79
  7. package/dist/checks/bin/check-changeset-coverage.js +739 -232
  8. package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
  9. package/dist/checks/bin/check-closes-n.js +101 -89
  10. package/dist/checks/bin/check-coherence.js +233 -129
  11. package/dist/checks/bin/check-dead-branch-push.js +97 -44
  12. package/dist/checks/bin/check-dispatch-readiness.js +238 -134
  13. package/dist/checks/bin/check-doc-coverage-push.js +722 -215
  14. package/dist/checks/bin/check-doc-coverage.js +726 -219
  15. package/dist/checks/bin/check-doctrine-no-procedures.js +222 -79
  16. package/dist/checks/bin/check-doctrine-portability.js +724 -217
  17. package/dist/checks/bin/check-evidence-fresh.js +720 -206
  18. package/dist/checks/bin/check-exec-bits.js +720 -213
  19. package/dist/checks/bin/check-first-push-dispatch.js +231 -129
  20. package/dist/checks/bin/check-issue-assignment.js +103 -91
  21. package/dist/checks/bin/check-issue-milestone-attach.js +94 -41
  22. package/dist/checks/bin/check-issue-objectives-numbering.js +94 -41
  23. package/dist/checks/bin/check-issue-parts-coverage.js +94 -41
  24. package/dist/checks/bin/check-issue-surface-globs.js +251 -127
  25. package/dist/checks/bin/check-issue-title-grammar.js +94 -41
  26. package/dist/checks/bin/check-issue-tranche-label.js +94 -41
  27. package/dist/checks/bin/check-main-branch-refusal.js +94 -41
  28. package/dist/checks/bin/check-no-disk-state.js +94 -41
  29. package/dist/checks/bin/check-pr-premise-reassert.js +222 -77
  30. package/dist/checks/bin/check-pr-report-density.js +94 -41
  31. package/dist/checks/bin/check-principal-test-plan-wait.js +94 -39
  32. package/dist/checks/bin/check-quoted-command.js +710 -201
  33. package/dist/checks/bin/check-reader-resolvable-prose.js +722 -213
  34. package/dist/checks/bin/check-registry-gates.js +104 -41
  35. package/dist/checks/bin/check-retired-vocabulary.js +708 -199
  36. package/dist/checks/bin/check-review-gate.js +224 -79
  37. package/dist/checks/bin/check-single-plan-pr.js +94 -41
  38. package/dist/checks/bin/check-surface-scope.js +101 -89
  39. package/dist/checks/bin/check-test-plan.js +94 -39
  40. package/dist/checks/bin/check-token-collection-wired.js +100 -42
  41. package/dist/checks/bin/check-token-report.js +96 -43
  42. package/dist/checks/bin/check-workspace-escape.js +722 -213
  43. package/dist/index.js +3725 -3148
  44. package/dist/lib/pre-push-cache-test-run.js +4175 -0
  45. package/dist/lib/pre-push-select-tests.js +709 -101
  46. 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-brief-shape.ts
6
4
  import { execFileSync as execFileSync3 } from "node:child_process";
@@ -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 NullObject2() {};
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(entry2, listDirs) {
1786
- if (entry2.endsWith("/*")) {
1787
- const baseDir = entry2.slice(0, -2);
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 (entry2.includes("*"))
1788
+ if (entry.includes("*"))
1791
1789
  return [];
1792
- return [entry2];
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((entry2) => !entry2.startsWith("!"));
1797
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
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 entry2 of negative) {
1800
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
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 entry2 of positive) {
1805
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
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 entry2;
2127
+ let entry;
2130
2128
  try {
2131
- entry2 = JSON.parse(line);
2129
+ entry = JSON.parse(line);
2132
2130
  } catch {
2133
2131
  continue;
2134
2132
  }
2135
- if (!entry2 || typeof entry2 !== "object")
2133
+ if (!entry || typeof entry !== "object")
2136
2134
  continue;
2137
- const obj = entry2;
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 [label2, num] of [
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: §${label2} 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.`);
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(entry2) {
3437
- const stripped = entry2.replace(/\/\*\*?$/, "");
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 ref2 = taskIssueRefs.get(n);
3924
- if (!ref2)
3921
+ const ref = taskIssueRefs.get(n);
3922
+ if (!ref)
3925
3923
  continue;
3926
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
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 ${ref2.taskId} of tranche "${ref2.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.`
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 expectedIssue2 = ref.issueNumber;
3940
- if (!referenced.has(expectedIssue2)) {
3937
+ const expectedIssue = ref.issueNumber;
3938
+ if (!referenced.has(expectedIssue)) {
3941
3939
  return {
3942
3940
  ok: false,
3943
- expectedIssue: expectedIssue2,
3944
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
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: expectedIssue2 };
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 issue2 = anchorNums[0];
3994
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
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 objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
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 && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4065
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4068
4066
  head,
4069
4067
  base,
4070
4068
  briefHash: briefHashBound,
4071
- objectivesVersion: objectivesVersion2,
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
- // ../../packages/aeg-core/src/log/artifact.ts
6065
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6066
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6067
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
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);
@@ -6202,7 +6255,8 @@ function emitCheckError(error) {
6202
6255
  }
6203
6256
 
6204
6257
  // src/lib/config.ts
6205
- import { execFileSync as execFileSync2 } from "node:child_process";
6258
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6259
+ import { promisify as promisify4 } from "node:util";
6206
6260
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6207
6261
  import { homedir } from "node:os";
6208
6262
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -6229,10 +6283,10 @@ var CheckEntrySchema = z4.object({
6229
6283
  ownWorkflow: z4.boolean().optional(),
6230
6284
  principalOwed: z4.literal(true).optional(),
6231
6285
  validates: z4.enum(["body", "issue"]).optional()
6232
- }).superRefine((entry2, ctx) => {
6233
- if (!entry2.env)
6286
+ }).superRefine((entry, ctx) => {
6287
+ if (!entry.env)
6234
6288
  return;
6235
- for (const [key, value] of Object.entries(entry2.env)) {
6289
+ for (const [key, value] of Object.entries(entry.env)) {
6236
6290
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6237
6291
  continue;
6238
6292
  const members = value.anyOf;
@@ -6389,18 +6443,19 @@ var VinayaConfigSchema = z4.object({
6389
6443
  });
6390
6444
  }
6391
6445
  }).optional(),
6392
- logPublish: z4.object({
6393
- issue: z4.number().int().positive().optional(),
6394
- pr: z4.number().int().positive().optional(),
6395
- webhookUrl: z4.string().url().optional(),
6396
- headers: z4.record(z4.string()).optional(),
6397
- maxChunksPerFlush: z4.number().int().positive().optional()
6398
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
6399
- message: "logPublish: set at most one of issue/pr/webhookUrl"
6400
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
6401
- message: "logPublish: headers requires webhookUrl"
6402
- }).optional(),
6403
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
6446
+ logPublish: z4.unknown().refine((v) => v === undefined, {
6447
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6448
+ }),
6449
+ runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6450
+ logs: z4.object({
6451
+ folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6452
+ url: z4.string().url().optional(),
6453
+ headers: z4.record(z4.string()).optional()
6454
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6455
+ message: "logs: set at most one of folder/url"
6456
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
6457
+ message: "logs: headers requires url"
6458
+ }).optional()
6404
6459
  });
6405
6460
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
6406
6461
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -6445,32 +6500,39 @@ function globalTokensCollectIgnoredWarning(path) {
6445
6500
  function globalRuntimeDirIgnoredWarning(path) {
6446
6501
  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.`;
6447
6502
  }
6503
+ var emittedGlobalKeyWarnings = new Set;
6504
+ function warnGlobalKeyIgnoredOnce(message) {
6505
+ if (emittedGlobalKeyWarnings.has(message))
6506
+ return;
6507
+ emittedGlobalKeyWarnings.add(message);
6508
+ console.error(`⚠ ${message}`);
6509
+ }
6448
6510
  function stripGlobalOnlyKeys(config, path) {
6449
6511
  if (path !== GLOBAL_CONFIG_PATH)
6450
6512
  return config;
6451
6513
  let result = config;
6452
6514
  if (result.checks && Object.keys(result.checks).length > 0) {
6453
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
6515
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
6454
6516
  result = { ...result, checks: undefined };
6455
6517
  }
6456
6518
  if (result.roles && Object.keys(result.roles).length > 0) {
6457
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
6519
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
6458
6520
  result = { ...result, roles: undefined };
6459
6521
  }
6460
6522
  if (result.principals && result.principals.length > 0) {
6461
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
6523
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
6462
6524
  result = { ...result, principals: undefined };
6463
6525
  }
6464
6526
  if (result.releaseActor) {
6465
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
6527
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
6466
6528
  result = { ...result, releaseActor: undefined };
6467
6529
  }
6468
6530
  if (result.tokens) {
6469
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
6531
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
6470
6532
  result = { ...result, tokens: undefined };
6471
6533
  }
6472
6534
  if (result.runtimeDir) {
6473
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
6535
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
6474
6536
  result = { ...result, runtimeDir: undefined };
6475
6537
  }
6476
6538
  return result;
@@ -6503,25 +6565,80 @@ function resolveReviewPolicy(config) {
6503
6565
  maxRounds
6504
6566
  };
6505
6567
  }
6506
- function trustAnchorRepo() {
6507
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6508
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6509
- if (fromRunner) {
6510
- const validated = wellFormed(fromRunner);
6511
- if (validated)
6512
- return validated;
6568
+ function resolveRuntimeDirSetting(config) {
6569
+ return config?.runtimeDir ?? null;
6570
+ }
6571
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
6572
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
6573
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
6574
+ }
6575
+ function resolveLogsSetting(config) {
6576
+ const raw = config?.logs;
6577
+ if (!raw)
6578
+ return null;
6579
+ if (raw.url !== undefined)
6580
+ return { url: raw.url, headers: raw.headers };
6581
+ if (raw.folder !== undefined)
6582
+ return { folder: raw.folder };
6583
+ return null;
6584
+ }
6585
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6586
+ const anchored = resolveLogsSetting(trustAnchorConfig);
6587
+ if (!anchored)
6588
+ return null;
6589
+ if ("url" in local)
6590
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
6591
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6592
+ }
6593
+ function resolveLogsHeaderValues(headers, env) {
6594
+ if (!headers)
6595
+ return;
6596
+ const resolved = {};
6597
+ for (const [key, value] of Object.entries(headers)) {
6598
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6513
6599
  }
6600
+ return resolved;
6601
+ }
6602
+ function trustAnchorRepo() {
6603
+ const fromRunner = trustAnchorRepoFromRunner();
6604
+ if (fromRunner)
6605
+ return fromRunner;
6514
6606
  try {
6515
6607
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6516
6608
  encoding: "utf-8",
6517
6609
  stdio: ["ignore", "pipe", "pipe"]
6518
- }).trim();
6519
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6520
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
6610
+ });
6611
+ return trustAnchorRepoFromRemoteUrl(url);
6612
+ } catch {
6613
+ return null;
6614
+ }
6615
+ }
6616
+ async function trustAnchorRepoAsync() {
6617
+ const fromRunner = trustAnchorRepoFromRunner();
6618
+ if (fromRunner)
6619
+ return fromRunner;
6620
+ try {
6621
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6622
+ encoding: "utf-8",
6623
+ timeout: 1e4
6624
+ });
6625
+ return trustAnchorRepoFromRemoteUrl(stdout);
6521
6626
  } catch {
6522
6627
  return null;
6523
6628
  }
6524
6629
  }
6630
+ function wellFormedRepoSlug(slug) {
6631
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6632
+ }
6633
+ function trustAnchorRepoFromRunner() {
6634
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6635
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
6636
+ }
6637
+ function trustAnchorRepoFromRemoteUrl(url) {
6638
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6639
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
6640
+ }
6641
+ var execFileAsync4 = promisify4(execFile4);
6525
6642
  function ghFetchTrustAnchorConfig() {
6526
6643
  const repo = trustAnchorRepo();
6527
6644
  if (!repo)
@@ -6531,6 +6648,13 @@ function ghFetchTrustAnchorConfig() {
6531
6648
  stdio: ["ignore", "pipe", "pipe"]
6532
6649
  });
6533
6650
  }
6651
+ async function ghFetchTrustAnchorConfigAsync() {
6652
+ const repo = await trustAnchorRepoAsync();
6653
+ if (!repo)
6654
+ throw new Error("could not resolve repo identity for the trust-anchor read");
6655
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
6656
+ return stdout;
6657
+ }
6534
6658
  function firstLine(err) {
6535
6659
  return err?.message?.split(`
6536
6660
  `)[0] ?? "unknown error";
@@ -6545,16 +6669,35 @@ function isMissingFileError(err) {
6545
6669
  return /\b404\b|not found/i.test(haystack);
6546
6670
  }
6547
6671
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
6548
- 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.
6549
- `);
6550
6672
  let base64;
6551
6673
  try {
6552
- base64 = fetcher().trim();
6674
+ base64 = fetcher();
6553
6675
  } catch (err) {
6554
- if (!isMissingFileError(err))
6555
- warn(firstLine(err));
6556
- return null;
6676
+ return trustAnchorFetchFailed(err);
6677
+ }
6678
+ return parseTrustAnchorContent(base64);
6679
+ }
6680
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
6681
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
6682
+ let base64;
6683
+ try {
6684
+ base64 = await fetcher();
6685
+ } catch (err) {
6686
+ return trustAnchorFetchFailed(err, warn);
6557
6687
  }
6688
+ return parseTrustAnchorContent(base64, warn);
6689
+ }
6690
+ function warnTrustAnchorFallback(why) {
6691
+ 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.
6692
+ `);
6693
+ }
6694
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
6695
+ if (!isMissingFileError(err))
6696
+ warn(firstLine(err));
6697
+ return null;
6698
+ }
6699
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
6700
+ const base64 = content.trim();
6558
6701
  if (!base64)
6559
6702
  return null;
6560
6703
  try {