@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
@@ -3,10 +3,10 @@ import { createRequire } from "node:module";
3
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
 
5
5
  // src/checks/bin/check-coherence.ts
6
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
6
+ import { execFile as execFile5, execFileSync as execFileSync3 } from "node:child_process";
7
7
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
8
8
  import { join as join2 } from "node:path";
9
- import { promisify as promisify4 } from "node:util";
9
+ import { promisify as promisify5 } from "node:util";
10
10
  // ../../packages/aeg-core/src/gate-audience.ts
11
11
  var GATE_AUDIENCE = {
12
12
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1040,7 +1040,7 @@ function withDefaults(oldDefaults, newDefaults) {
1040
1040
  var endpoint = withDefaults(null, DEFAULTS);
1041
1041
 
1042
1042
  // ../../node_modules/fast-content-type-parse/index.js
1043
- var NullObject = function NullObject2() {};
1043
+ var NullObject = function NullObject() {};
1044
1044
  NullObject.prototype = Object.create(null);
1045
1045
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1046
1046
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1784,27 +1784,27 @@ function splitTableRow(row) {
1784
1784
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1785
1785
  }
1786
1786
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1787
- function resolveWorkspaceEntry(entry2, listDirs) {
1788
- if (entry2.endsWith("/*")) {
1789
- const baseDir = entry2.slice(0, -2);
1787
+ function resolveWorkspaceEntry(entry, listDirs) {
1788
+ if (entry.endsWith("/*")) {
1789
+ const baseDir = entry.slice(0, -2);
1790
1790
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1791
1791
  }
1792
- if (entry2.includes("*"))
1792
+ if (entry.includes("*"))
1793
1793
  return [];
1794
- return [entry2];
1794
+ return [entry];
1795
1795
  }
1796
1796
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1797
1797
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1798
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1799
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1798
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1799
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1800
1800
  const excluded = new Set;
1801
- for (const entry2 of negative) {
1802
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1801
+ for (const entry of negative) {
1802
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1803
1803
  excluded.add(member);
1804
1804
  }
1805
1805
  const members = new Set;
1806
- for (const entry2 of positive) {
1807
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1806
+ for (const entry of positive) {
1807
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1808
1808
  if (!excluded.has(member))
1809
1809
  members.add(member);
1810
1810
  }
@@ -2128,15 +2128,15 @@ function summarizeTranscript(jsonl) {
2128
2128
  const line = rawLine.trim();
2129
2129
  if (!line)
2130
2130
  continue;
2131
- let entry2;
2131
+ let entry;
2132
2132
  try {
2133
- entry2 = JSON.parse(line);
2133
+ entry = JSON.parse(line);
2134
2134
  } catch {
2135
2135
  continue;
2136
2136
  }
2137
- if (!entry2 || typeof entry2 !== "object")
2137
+ if (!entry || typeof entry !== "object")
2138
2138
  continue;
2139
- const obj = entry2;
2139
+ const obj = entry;
2140
2140
  if (obj.type !== "assistant")
2141
2141
  continue;
2142
2142
  const message = obj.message;
@@ -2984,7 +2984,7 @@ function isStep0Block(content) {
2984
2984
  }
2985
2985
  function checkCommandsCarryOutput(prBody) {
2986
2986
  const errors = [];
2987
- for (const [label2, num] of [
2987
+ for (const [label, num] of [
2988
2988
  ["5", 5],
2989
2989
  ["6", 6]
2990
2990
  ]) {
@@ -2998,7 +2998,7 @@ function checkCommandsCarryOutput(prBody) {
2998
2998
  continue;
2999
2999
  const next = blocks[i + 1];
3000
3000
  if (!next || isCommandBlock(next.content)) {
3001
- 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.`);
3001
+ 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.`);
3002
3002
  }
3003
3003
  }
3004
3004
  }
@@ -3435,8 +3435,8 @@ function stripPartBackticks(text) {
3435
3435
  function partWordCount(text) {
3436
3436
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3437
3437
  }
3438
- function looksLikeFilePath(entry2) {
3439
- const stripped = entry2.replace(/\/\*\*?$/, "");
3438
+ function looksLikeFilePath(entry) {
3439
+ const stripped = entry.replace(/\/\*\*?$/, "");
3440
3440
  const lastSegment = stripped.split("/").pop() ?? stripped;
3441
3441
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3442
3442
  return extMatch !== null && extMatch.index > 0;
@@ -3922,14 +3922,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3922
3922
  const referenced = extractClosesReferences(prBody);
3923
3923
  if (taskIssueRefs) {
3924
3924
  for (const n of referenced) {
3925
- const ref2 = taskIssueRefs.get(n);
3926
- if (!ref2)
3925
+ const ref = taskIssueRefs.get(n);
3926
+ if (!ref)
3927
3927
  continue;
3928
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3928
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3929
3929
  if (branch !== expectedBranch) {
3930
3930
  return {
3931
3931
  ok: false,
3932
- 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.`
3932
+ 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.`
3933
3933
  };
3934
3934
  }
3935
3935
  }
@@ -3938,15 +3938,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3938
3938
  if (!ref)
3939
3939
  return { ok: true };
3940
3940
  if (ref.kind === "issue") {
3941
- const expectedIssue2 = ref.issueNumber;
3942
- if (!referenced.has(expectedIssue2)) {
3941
+ const expectedIssue = ref.issueNumber;
3942
+ if (!referenced.has(expectedIssue)) {
3943
3943
  return {
3944
3944
  ok: false,
3945
- expectedIssue: expectedIssue2,
3946
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3945
+ expectedIssue,
3946
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3947
3947
  };
3948
3948
  }
3949
- return { ok: true, expectedIssue: expectedIssue2 };
3949
+ return { ok: true, expectedIssue };
3950
3950
  }
3951
3951
  const trancheSlug = ref.tranche;
3952
3952
  const taskId = ref.taskId;
@@ -3992,8 +3992,8 @@ function extractIssue(body) {
3992
3992
  const anchorNums = closesRefs(anchored);
3993
3993
  if (anchorNums.length === 0)
3994
3994
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3995
- const issue2 = anchorNums[0];
3996
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
3995
+ const issue = anchorNums[0];
3996
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
3997
3997
  }
3998
3998
  const headerNums = closesRefs(headerRegion(stripped));
3999
3999
  if (bodyNums.length === 0)
@@ -4062,15 +4062,15 @@ function compareManifest(echoed, current, patchIdOf) {
4062
4062
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4063
4063
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4064
4064
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4065
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4065
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4066
4066
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4067
4067
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4068
4068
  return {
4069
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4069
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4070
4070
  head,
4071
4071
  base,
4072
4072
  briefHash: briefHashBound,
4073
- objectivesVersion: objectivesVersion2,
4073
+ objectivesVersion,
4074
4074
  rulingOrdinal,
4075
4075
  policyDigest: policyDigestBound
4076
4076
  };
@@ -5502,6 +5502,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5502
5502
  }
5503
5503
  return findings;
5504
5504
  }
5505
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5506
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5507
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5508
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5505
5509
  // ../../packages/aeg-core/src/log/envelope.ts
5506
5510
  import { createHash as createHash5 } from "node:crypto";
5507
5511
 
@@ -6040,6 +6044,7 @@ function redact(value, home) {
6040
6044
  return value;
6041
6045
  }
6042
6046
  // ../../packages/aeg-core/src/log/store.ts
6047
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6043
6048
  function metaOf(obj) {
6044
6049
  if (obj === null || typeof obj !== "object")
6045
6050
  return null;
@@ -6062,11 +6067,61 @@ function recordIdentity(obj) {
6062
6067
  }
6063
6068
  return null;
6064
6069
  }
6065
-
6066
- // ../../packages/aeg-core/src/log/artifact.ts
6067
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6068
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6069
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6070
+ function schemaVersionOf(obj) {
6071
+ const meta = metaOf(obj);
6072
+ const schema = meta?.schema;
6073
+ return typeof schema === "number" ? schema : null;
6074
+ }
6075
+ function isKnownSchema(version) {
6076
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6077
+ }
6078
+ function classifyStoredLine(raw, home) {
6079
+ let obj;
6080
+ try {
6081
+ obj = JSON.parse(raw);
6082
+ } catch {
6083
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6084
+ }
6085
+ const version = schemaVersionOf(obj);
6086
+ if (version === null) {
6087
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6088
+ }
6089
+ if (!isKnownSchema(version)) {
6090
+ return {
6091
+ status: "unknown_version",
6092
+ identity: recordIdentity(obj),
6093
+ schema: version,
6094
+ raw,
6095
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6096
+ };
6097
+ }
6098
+ const result = LogEventSchema.safeParse(obj);
6099
+ if (!result.success) {
6100
+ return {
6101
+ status: "invalid",
6102
+ identity: recordIdentity(obj),
6103
+ raw,
6104
+ reason: result.error.issues[0]?.message ?? "schema violation"
6105
+ };
6106
+ }
6107
+ const event = result.data;
6108
+ const identity = recordIdentity(event);
6109
+ if (identity === null) {
6110
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6111
+ }
6112
+ const redacted = redact(event, home);
6113
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6114
+ return {
6115
+ status: "ok",
6116
+ identity,
6117
+ runId: event.meta.run_id,
6118
+ seq: event.meta.seq,
6119
+ schema: version,
6120
+ provenance,
6121
+ event,
6122
+ postLine: JSON.stringify(redacted)
6123
+ };
6124
+ }
6070
6125
  // ../../packages/aeg-core/src/control-store/records.ts
6071
6126
  import { z as z3 } from "zod";
6072
6127
  var isoTimestamp = z3.string().min(1);
@@ -6347,10 +6402,10 @@ var COMMANDS = [
6347
6402
  }
6348
6403
  ],
6349
6404
  details: [
6350
- "Composes `task brief`'s own preparation (`prepareTask`) with `dev-review-loop` (`devReviewLoop`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
6405
+ "Composes `task brief`'s own preparation (`prepareTask`) with the watching driver (`runDriverLoop`, `dev-review-loop.ts`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
6351
6406
  "A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
6352
- "Refuses when the frozen brief's developer branch already has an open pull request — the old `task dispatch` followed by `task run` cannot start two developers this way.",
6353
- "Exit and printed summary distinguish a published, reviewed pull request (exit `0`, the PR URL) from a pause (exit `1`, with the exact `vinaya dev-review-loop --resume <pr>` command to continue), a usage/argv error (exit `2`), and any other failure (exit `3`) — never sharing `1` with a pause, so an unattended host tells them apart from the exit code alone. A run that pauses is resumed with the loop's own existing `--resume <pr>` flag, never a flag on this command."
6407
+ "Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
6408
+ "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the exact `vinaya task run <tranche> <n>` command to continue by hand), a usage/argv error (exit `2`), and any other failure (exit `3`)."
6354
6409
  ],
6355
6410
  status: "shipped"
6356
6411
  },
@@ -6519,48 +6574,6 @@ var COMMANDS = [
6519
6574
  ],
6520
6575
  status: "shipped"
6521
6576
  },
6522
- {
6523
- name: "log flush",
6524
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
6525
- flags: [
6526
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
6527
- {
6528
- flag: "--pr",
6529
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
6530
- },
6531
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
6532
- ],
6533
- details: [
6534
- "Exactly one of `--issue`/`--pr` is required. `--pr` resolves the Issue from the PR body's `Closes #N` line — the same anchor every gate reads — and refuses with a check error naming the missing line when the body carries none.",
6535
- "Splits the outbox first at `run_id` boundaries (a maximal run of consecutive lines sharing one `run_id`, never a global group-by, so an interleaved outbox never produces a range spanning a gap), then at `FORGE_COMMENT_MAX_CHARS` (65536) within each run. Each comment opens with `<!-- aeg:log:<run_id>:<seq_from>-<seq_to> -->` on its own line, then one fenced `ndjson` block, one outbox line per line, verbatim. A single line too large to fit alone is refused by name, never split across two comments.",
6536
- "Logs its own `forge_write` line — `validated` before posting, `written` (with every returned comment id) after the last post succeeds, or `refused` (with gh's error) on any failure — through the same `log()` every other family uses, into the same outbox, before truncating. The outbox is truncated only to the lines confirmed posted; a failed chunk's lines, and anything appended to the outbox during the flush (including the flush's own `validated`/`written`/`refused` line), always survive to ride the next flush."
6537
- ],
6538
- status: "shipped"
6539
- },
6540
- {
6541
- name: "log export-artifact",
6542
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
6543
- flags: [],
6544
- details: [
6545
- "Concatenates every `*.ndjson` file under `~/.vinaya/outbox/` into `<dest>`, verbatim — no filtering, no second redaction pass (lines are already redacted at `log()`'s own write boundary). Writes nothing when the outbox is empty, and exits 0 either way: no gate events this run is a legitimate outcome, never a failure.",
6546
- "Runs inside the generated `vinaya-checks.yml` job, which holds no forge-write credential — this command never calls the forge. Both this step and the `actions/upload-artifact` step after it run `if: always()`, so a cancelled or failed job still exports whatever partial outbox it has."
6547
- ],
6548
- status: "shipped"
6549
- },
6550
- {
6551
- name: "log collect-artifact",
6552
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
6553
- flags: [
6554
- { flag: "--pr", description: "The pull request this artifact belongs to" },
6555
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
6556
- ],
6557
- details: [
6558
- "Runs inside the generated `vinaya-task-log-collector.yml` workflow — a `workflow_run`-triggered job on the default branch, holding the write credential the task-path job that produced the artifact never gets. `<path>` is already downloaded by that workflow, scoped to a specific, API-verified run id — a provenance guarantee this command never re-derives from the artifact bytes.",
6559
- "Never executes, imports, or evaluates the artifact's content: every line is read as text and validated (schema, an 8 MiB whole-artifact size cap, redaction, and a repo cross-check) before anything is trusted. A rejected line becomes a named gap — printed, never a silent drop — and the artifact is never partially trusted past that check into executing anything.",
6560
- "The valid, re-redacted survivors are appended into the same local outbox `vinaya log flush` would read for that PR's Issue, then published through the existing `flushOutbox` unmodified — reusing its chunking, its `<!-- aeg:log:… -->` marker, and its idempotent-retry read, rather than a second publisher. A retried collector run (a fresh runner, the same forge state) therefore dedupes for free: the marker already on the forge is acknowledged, never re-posted."
6561
- ],
6562
- status: "shipped"
6563
- },
6564
6577
  {
6565
6578
  name: "milestone create",
6566
6579
  description: "Create a GitHub Milestone from a validated body",
@@ -6890,7 +6903,7 @@ var COMMANDS = [
6890
6903
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
6891
6904
  {
6892
6905
  flag: "--pr",
6893
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
6906
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
6894
6907
  },
6895
6908
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
6896
6909
  {
@@ -6902,7 +6915,7 @@ var COMMANDS = [
6902
6915
  details: [
6903
6916
  "Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
6904
6917
  "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
6905
- "When `--task` or `--pr` is given, flushes that outbox via `vinaya log flush` immediately after the child settles — `--task` and `--pr` are mutually exclusive here, matching `log flush`'s own single-target rule. Without either, the dispatch still runs and logs; nothing is flushed, and the lines ride to the next flush.",
6918
+ "Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
6906
6919
  "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
6907
6920
  ],
6908
6921
  status: "shipped"
@@ -6922,7 +6935,8 @@ var COMMANDS = [
6922
6935
  "Dispatches the developer through `dispatchRole` with the brief read from the Issue, waits for the PR it opens, then runs `assessRound` (`@attalabs/aeg-core`) — the entire policy — against observations this command reads from the forge: the head via `git ls-remote` only (never `gh pr view headRefOid`, which can lag a push), CI conclusion via the check-runs API (never run locally), and ruling comments matching `<!-- aeg:principal:ruling:<pr>-<k> -->`.",
6923
6936
  "Nothing is posted to the PR before the policy decides `publish`: each round's reviewer and security verdicts are dispatched fresh (never a resumed session) through `dispatchRole`, rendered through `review post`'s own render functions, and written to a local file under the outbox — never `gh pr comment`/`gh pr review`. Posting the held verdicts is a separate, later task.",
6924
6937
  "The developer's session is resumed every round via `dispatchRole`'s `resumeId` — never a fresh session — for every vendor; a round whose resume fails for a vendor that resumed successfully the round before stops the loop rather than silently falling back to a fresh developer session.",
6925
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
6938
+ "Every dispatch and round transition is a log line through the Vinaya Log, delivered live to its configured `logs` destination as it is emitted — never a tracker comment.",
6939
+ "issue-711 O4: this command — `--task <n>`, `--resume <pr>`, `--cancel <pr>` alike — stays `task run`'s own one-shot debug/direct entry; the watching driver that survives a pause and continues on its own is `task run`'s (see that command's own entry)."
6926
6940
  ],
6927
6941
  status: "shipped"
6928
6942
  }
@@ -6949,7 +6963,8 @@ function emitCheckError(error) {
6949
6963
  }
6950
6964
 
6951
6965
  // src/lib/config.ts
6952
- import { execFileSync as execFileSync2 } from "node:child_process";
6966
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6967
+ import { promisify as promisify4 } from "node:util";
6953
6968
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6954
6969
  import { homedir } from "node:os";
6955
6970
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -6976,10 +6991,10 @@ var CheckEntrySchema = z5.object({
6976
6991
  ownWorkflow: z5.boolean().optional(),
6977
6992
  principalOwed: z5.literal(true).optional(),
6978
6993
  validates: z5.enum(["body", "issue"]).optional()
6979
- }).superRefine((entry2, ctx) => {
6980
- if (!entry2.env)
6994
+ }).superRefine((entry, ctx) => {
6995
+ if (!entry.env)
6981
6996
  return;
6982
- for (const [key, value] of Object.entries(entry2.env)) {
6997
+ for (const [key, value] of Object.entries(entry.env)) {
6983
6998
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6984
6999
  continue;
6985
7000
  const members = value.anyOf;
@@ -7136,18 +7151,19 @@ var VinayaConfigSchema = z5.object({
7136
7151
  });
7137
7152
  }
7138
7153
  }).optional(),
7139
- logPublish: z5.object({
7140
- issue: z5.number().int().positive().optional(),
7141
- pr: z5.number().int().positive().optional(),
7142
- webhookUrl: z5.string().url().optional(),
7143
- headers: z5.record(z5.string()).optional(),
7144
- maxChunksPerFlush: z5.number().int().positive().optional()
7145
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
7146
- message: "logPublish: set at most one of issue/pr/webhookUrl"
7147
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
7148
- message: "logPublish: headers requires webhookUrl"
7149
- }).optional(),
7150
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
7154
+ logPublish: z5.unknown().refine((v) => v === undefined, {
7155
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7156
+ }),
7157
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7158
+ logs: z5.object({
7159
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7160
+ url: z5.string().url().optional(),
7161
+ headers: z5.record(z5.string()).optional()
7162
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7163
+ message: "logs: set at most one of folder/url"
7164
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
7165
+ message: "logs: headers requires url"
7166
+ }).optional()
7151
7167
  });
7152
7168
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
7153
7169
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -7192,32 +7208,39 @@ function globalTokensCollectIgnoredWarning(path) {
7192
7208
  function globalRuntimeDirIgnoredWarning(path) {
7193
7209
  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.`;
7194
7210
  }
7211
+ var emittedGlobalKeyWarnings = new Set;
7212
+ function warnGlobalKeyIgnoredOnce(message) {
7213
+ if (emittedGlobalKeyWarnings.has(message))
7214
+ return;
7215
+ emittedGlobalKeyWarnings.add(message);
7216
+ console.error(`⚠ ${message}`);
7217
+ }
7195
7218
  function stripGlobalOnlyKeys(config, path) {
7196
7219
  if (path !== GLOBAL_CONFIG_PATH)
7197
7220
  return config;
7198
7221
  let result = config;
7199
7222
  if (result.checks && Object.keys(result.checks).length > 0) {
7200
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
7223
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
7201
7224
  result = { ...result, checks: undefined };
7202
7225
  }
7203
7226
  if (result.roles && Object.keys(result.roles).length > 0) {
7204
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
7227
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
7205
7228
  result = { ...result, roles: undefined };
7206
7229
  }
7207
7230
  if (result.principals && result.principals.length > 0) {
7208
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
7231
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
7209
7232
  result = { ...result, principals: undefined };
7210
7233
  }
7211
7234
  if (result.releaseActor) {
7212
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
7235
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
7213
7236
  result = { ...result, releaseActor: undefined };
7214
7237
  }
7215
7238
  if (result.tokens) {
7216
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
7239
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
7217
7240
  result = { ...result, tokens: undefined };
7218
7241
  }
7219
7242
  if (result.runtimeDir) {
7220
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
7243
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
7221
7244
  result = { ...result, runtimeDir: undefined };
7222
7245
  }
7223
7246
  return result;
@@ -7250,25 +7273,80 @@ function resolveReviewPolicy(config) {
7250
7273
  maxRounds
7251
7274
  };
7252
7275
  }
7253
- function trustAnchorRepo() {
7254
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7255
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7256
- if (fromRunner) {
7257
- const validated = wellFormed(fromRunner);
7258
- if (validated)
7259
- return validated;
7276
+ function resolveRuntimeDirSetting(config) {
7277
+ return config?.runtimeDir ?? null;
7278
+ }
7279
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
7280
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
7281
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
7282
+ }
7283
+ function resolveLogsSetting(config) {
7284
+ const raw = config?.logs;
7285
+ if (!raw)
7286
+ return null;
7287
+ if (raw.url !== undefined)
7288
+ return { url: raw.url, headers: raw.headers };
7289
+ if (raw.folder !== undefined)
7290
+ return { folder: raw.folder };
7291
+ return null;
7292
+ }
7293
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7294
+ const anchored = resolveLogsSetting(trustAnchorConfig);
7295
+ if (!anchored)
7296
+ return null;
7297
+ if ("url" in local)
7298
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
7299
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7300
+ }
7301
+ function resolveLogsHeaderValues(headers, env) {
7302
+ if (!headers)
7303
+ return;
7304
+ const resolved = {};
7305
+ for (const [key, value] of Object.entries(headers)) {
7306
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7260
7307
  }
7308
+ return resolved;
7309
+ }
7310
+ function trustAnchorRepo() {
7311
+ const fromRunner = trustAnchorRepoFromRunner();
7312
+ if (fromRunner)
7313
+ return fromRunner;
7261
7314
  try {
7262
7315
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
7263
7316
  encoding: "utf-8",
7264
7317
  stdio: ["ignore", "pipe", "pipe"]
7265
- }).trim();
7266
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7267
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
7318
+ });
7319
+ return trustAnchorRepoFromRemoteUrl(url);
7320
+ } catch {
7321
+ return null;
7322
+ }
7323
+ }
7324
+ async function trustAnchorRepoAsync() {
7325
+ const fromRunner = trustAnchorRepoFromRunner();
7326
+ if (fromRunner)
7327
+ return fromRunner;
7328
+ try {
7329
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7330
+ encoding: "utf-8",
7331
+ timeout: 1e4
7332
+ });
7333
+ return trustAnchorRepoFromRemoteUrl(stdout);
7268
7334
  } catch {
7269
7335
  return null;
7270
7336
  }
7271
7337
  }
7338
+ function wellFormedRepoSlug(slug) {
7339
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7340
+ }
7341
+ function trustAnchorRepoFromRunner() {
7342
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7343
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
7344
+ }
7345
+ function trustAnchorRepoFromRemoteUrl(url) {
7346
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7347
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7348
+ }
7349
+ var execFileAsync4 = promisify4(execFile4);
7272
7350
  function ghFetchTrustAnchorConfig() {
7273
7351
  const repo = trustAnchorRepo();
7274
7352
  if (!repo)
@@ -7278,6 +7356,13 @@ function ghFetchTrustAnchorConfig() {
7278
7356
  stdio: ["ignore", "pipe", "pipe"]
7279
7357
  });
7280
7358
  }
7359
+ async function ghFetchTrustAnchorConfigAsync() {
7360
+ const repo = await trustAnchorRepoAsync();
7361
+ if (!repo)
7362
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7363
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
7364
+ return stdout;
7365
+ }
7281
7366
  function firstLine(err) {
7282
7367
  return err?.message?.split(`
7283
7368
  `)[0] ?? "unknown error";
@@ -7292,16 +7377,35 @@ function isMissingFileError(err) {
7292
7377
  return /\b404\b|not found/i.test(haystack);
7293
7378
  }
7294
7379
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
7295
- 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.
7296
- `);
7297
7380
  let base64;
7298
7381
  try {
7299
- base64 = fetcher().trim();
7382
+ base64 = fetcher();
7300
7383
  } catch (err) {
7301
- if (!isMissingFileError(err))
7302
- warn(firstLine(err));
7303
- return null;
7384
+ return trustAnchorFetchFailed(err);
7304
7385
  }
7386
+ return parseTrustAnchorContent(base64);
7387
+ }
7388
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
7389
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7390
+ let base64;
7391
+ try {
7392
+ base64 = await fetcher();
7393
+ } catch (err) {
7394
+ return trustAnchorFetchFailed(err, warn);
7395
+ }
7396
+ return parseTrustAnchorContent(base64, warn);
7397
+ }
7398
+ function warnTrustAnchorFallback(why) {
7399
+ 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.
7400
+ `);
7401
+ }
7402
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7403
+ if (!isMissingFileError(err))
7404
+ warn(firstLine(err));
7405
+ return null;
7406
+ }
7407
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7408
+ const base64 = content.trim();
7305
7409
  if (!base64)
7306
7410
  return null;
7307
7411
  try {
@@ -7331,7 +7435,7 @@ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.j
7331
7435
 
7332
7436
  // src/checks/bin/check-coherence.ts
7333
7437
  var CHECK_NAME = "coherence";
7334
- var execFileAsync4 = promisify4(execFile4);
7438
+ var execFileAsync5 = promisify5(execFile5);
7335
7439
  function git(args) {
7336
7440
  try {
7337
7441
  return execFileSync3("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
@@ -7370,7 +7474,7 @@ async function resolveToken() {
7370
7474
  if (process.env.GH_TOKEN)
7371
7475
  return process.env.GH_TOKEN;
7372
7476
  try {
7373
- const { stdout } = await execFileAsync4("gh", ["auth", "token"]);
7477
+ const { stdout } = await execFileAsync5("gh", ["auth", "token"]);
7374
7478
  const token = stdout.trim();
7375
7479
  return token.length > 0 ? token : null;
7376
7480
  } catch {