@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
  // ../../packages/aeg-core/src/gate-audience.ts
5
3
  var GATE_AUDIENCE = {
6
4
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1034,7 +1032,7 @@ function withDefaults(oldDefaults, newDefaults) {
1034
1032
  var endpoint = withDefaults(null, DEFAULTS);
1035
1033
 
1036
1034
  // ../../node_modules/fast-content-type-parse/index.js
1037
- var NullObject = function NullObject2() {};
1035
+ var NullObject = function NullObject() {};
1038
1036
  NullObject.prototype = Object.create(null);
1039
1037
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1040
1038
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1778,27 +1776,27 @@ function splitTableRow(row) {
1778
1776
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1779
1777
  }
1780
1778
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1781
- function resolveWorkspaceEntry(entry2, listDirs) {
1782
- if (entry2.endsWith("/*")) {
1783
- const baseDir = entry2.slice(0, -2);
1779
+ function resolveWorkspaceEntry(entry, listDirs) {
1780
+ if (entry.endsWith("/*")) {
1781
+ const baseDir = entry.slice(0, -2);
1784
1782
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1785
1783
  }
1786
- if (entry2.includes("*"))
1784
+ if (entry.includes("*"))
1787
1785
  return [];
1788
- return [entry2];
1786
+ return [entry];
1789
1787
  }
1790
1788
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1791
1789
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1792
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1793
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1790
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1791
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1794
1792
  const excluded = new Set;
1795
- for (const entry2 of negative) {
1796
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1793
+ for (const entry of negative) {
1794
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1797
1795
  excluded.add(member);
1798
1796
  }
1799
1797
  const members = new Set;
1800
- for (const entry2 of positive) {
1801
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1798
+ for (const entry of positive) {
1799
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1802
1800
  if (!excluded.has(member))
1803
1801
  members.add(member);
1804
1802
  }
@@ -2122,15 +2120,15 @@ function summarizeTranscript(jsonl) {
2122
2120
  const line = rawLine.trim();
2123
2121
  if (!line)
2124
2122
  continue;
2125
- let entry2;
2123
+ let entry;
2126
2124
  try {
2127
- entry2 = JSON.parse(line);
2125
+ entry = JSON.parse(line);
2128
2126
  } catch {
2129
2127
  continue;
2130
2128
  }
2131
- if (!entry2 || typeof entry2 !== "object")
2129
+ if (!entry || typeof entry !== "object")
2132
2130
  continue;
2133
- const obj = entry2;
2131
+ const obj = entry;
2134
2132
  if (obj.type !== "assistant")
2135
2133
  continue;
2136
2134
  const message = obj.message;
@@ -2978,7 +2976,7 @@ function isStep0Block(content) {
2978
2976
  }
2979
2977
  function checkCommandsCarryOutput(prBody) {
2980
2978
  const errors = [];
2981
- for (const [label2, num] of [
2979
+ for (const [label, num] of [
2982
2980
  ["5", 5],
2983
2981
  ["6", 6]
2984
2982
  ]) {
@@ -2992,7 +2990,7 @@ function checkCommandsCarryOutput(prBody) {
2992
2990
  continue;
2993
2991
  const next = blocks[i + 1];
2994
2992
  if (!next || isCommandBlock(next.content)) {
2995
- 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.`);
2993
+ 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.`);
2996
2994
  }
2997
2995
  }
2998
2996
  }
@@ -3429,8 +3427,8 @@ function stripPartBackticks(text) {
3429
3427
  function partWordCount(text) {
3430
3428
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3431
3429
  }
3432
- function looksLikeFilePath(entry2) {
3433
- const stripped = entry2.replace(/\/\*\*?$/, "");
3430
+ function looksLikeFilePath(entry) {
3431
+ const stripped = entry.replace(/\/\*\*?$/, "");
3434
3432
  const lastSegment = stripped.split("/").pop() ?? stripped;
3435
3433
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3436
3434
  return extMatch !== null && extMatch.index > 0;
@@ -3916,14 +3914,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3916
3914
  const referenced = extractClosesReferences(prBody);
3917
3915
  if (taskIssueRefs) {
3918
3916
  for (const n of referenced) {
3919
- const ref2 = taskIssueRefs.get(n);
3920
- if (!ref2)
3917
+ const ref = taskIssueRefs.get(n);
3918
+ if (!ref)
3921
3919
  continue;
3922
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3920
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3923
3921
  if (branch !== expectedBranch) {
3924
3922
  return {
3925
3923
  ok: false,
3926
- 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.`
3924
+ 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.`
3927
3925
  };
3928
3926
  }
3929
3927
  }
@@ -3932,15 +3930,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3932
3930
  if (!ref)
3933
3931
  return { ok: true };
3934
3932
  if (ref.kind === "issue") {
3935
- const expectedIssue2 = ref.issueNumber;
3936
- if (!referenced.has(expectedIssue2)) {
3933
+ const expectedIssue = ref.issueNumber;
3934
+ if (!referenced.has(expectedIssue)) {
3937
3935
  return {
3938
3936
  ok: false,
3939
- expectedIssue: expectedIssue2,
3940
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3937
+ expectedIssue,
3938
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3941
3939
  };
3942
3940
  }
3943
- return { ok: true, expectedIssue: expectedIssue2 };
3941
+ return { ok: true, expectedIssue };
3944
3942
  }
3945
3943
  const trancheSlug = ref.tranche;
3946
3944
  const taskId = ref.taskId;
@@ -3986,8 +3984,8 @@ function extractIssue(body) {
3986
3984
  const anchorNums = closesRefs(anchored);
3987
3985
  if (anchorNums.length === 0)
3988
3986
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3989
- const issue2 = anchorNums[0];
3990
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
3987
+ const issue = anchorNums[0];
3988
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
3991
3989
  }
3992
3990
  const headerNums = closesRefs(headerRegion(stripped));
3993
3991
  if (bodyNums.length === 0)
@@ -4056,15 +4054,15 @@ function compareManifest(echoed, current, patchIdOf) {
4056
4054
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4057
4055
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4058
4056
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4059
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4057
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4060
4058
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4061
4059
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4062
4060
  return {
4063
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4061
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4064
4062
  head,
4065
4063
  base,
4066
4064
  briefHash: briefHashBound,
4067
- objectivesVersion: objectivesVersion2,
4065
+ objectivesVersion,
4068
4066
  rulingOrdinal,
4069
4067
  policyDigest: policyDigestBound
4070
4068
  };
@@ -5496,6 +5494,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5496
5494
  }
5497
5495
  return findings;
5498
5496
  }
5497
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5498
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5499
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5500
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5499
5501
  // ../../packages/aeg-core/src/log/envelope.ts
5500
5502
  import { createHash as createHash5 } from "node:crypto";
5501
5503
 
@@ -6034,6 +6036,7 @@ function redact(value, home) {
6034
6036
  return value;
6035
6037
  }
6036
6038
  // ../../packages/aeg-core/src/log/store.ts
6039
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6037
6040
  function metaOf(obj) {
6038
6041
  if (obj === null || typeof obj !== "object")
6039
6042
  return null;
@@ -6056,11 +6059,61 @@ function recordIdentity(obj) {
6056
6059
  }
6057
6060
  return null;
6058
6061
  }
6059
-
6060
- // ../../packages/aeg-core/src/log/artifact.ts
6061
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6062
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6063
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6062
+ function schemaVersionOf(obj) {
6063
+ const meta = metaOf(obj);
6064
+ const schema = meta?.schema;
6065
+ return typeof schema === "number" ? schema : null;
6066
+ }
6067
+ function isKnownSchema(version) {
6068
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6069
+ }
6070
+ function classifyStoredLine(raw, home) {
6071
+ let obj;
6072
+ try {
6073
+ obj = JSON.parse(raw);
6074
+ } catch {
6075
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6076
+ }
6077
+ const version = schemaVersionOf(obj);
6078
+ if (version === null) {
6079
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6080
+ }
6081
+ if (!isKnownSchema(version)) {
6082
+ return {
6083
+ status: "unknown_version",
6084
+ identity: recordIdentity(obj),
6085
+ schema: version,
6086
+ raw,
6087
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6088
+ };
6089
+ }
6090
+ const result = LogEventSchema.safeParse(obj);
6091
+ if (!result.success) {
6092
+ return {
6093
+ status: "invalid",
6094
+ identity: recordIdentity(obj),
6095
+ raw,
6096
+ reason: result.error.issues[0]?.message ?? "schema violation"
6097
+ };
6098
+ }
6099
+ const event = result.data;
6100
+ const identity = recordIdentity(event);
6101
+ if (identity === null) {
6102
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6103
+ }
6104
+ const redacted = redact(event, home);
6105
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6106
+ return {
6107
+ status: "ok",
6108
+ identity,
6109
+ runId: event.meta.run_id,
6110
+ seq: event.meta.seq,
6111
+ schema: version,
6112
+ provenance,
6113
+ event,
6114
+ postLine: JSON.stringify(redacted)
6115
+ };
6116
+ }
6064
6117
  // ../../packages/aeg-core/src/control-store/records.ts
6065
6118
  import { z as z3 } from "zod";
6066
6119
  var isoTimestamp = z3.string().min(1);
@@ -6217,6 +6270,8 @@ function readIssueCheckEnv(env = process.env) {
6217
6270
 
6218
6271
  // src/lib/brief-assembly.ts
6219
6272
  import { execFileSync as execFileSync4 } from "node:child_process";
6273
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6274
+ import { join as join3 } from "node:path";
6220
6275
 
6221
6276
  // ../../packages/sources/src/commands.ts
6222
6277
  var COMMANDS = [
@@ -6369,10 +6424,10 @@ var COMMANDS = [
6369
6424
  }
6370
6425
  ],
6371
6426
  details: [
6372
- "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.",
6427
+ "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.",
6373
6428
  "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.",
6374
- "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.",
6375
- "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."
6429
+ "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.",
6430
+ "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`)."
6376
6431
  ],
6377
6432
  status: "shipped"
6378
6433
  },
@@ -6541,48 +6596,6 @@ var COMMANDS = [
6541
6596
  ],
6542
6597
  status: "shipped"
6543
6598
  },
6544
- {
6545
- name: "log flush",
6546
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
6547
- flags: [
6548
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
6549
- {
6550
- flag: "--pr",
6551
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
6552
- },
6553
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
6554
- ],
6555
- details: [
6556
- "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.",
6557
- "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.",
6558
- "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."
6559
- ],
6560
- status: "shipped"
6561
- },
6562
- {
6563
- name: "log export-artifact",
6564
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
6565
- flags: [],
6566
- details: [
6567
- "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.",
6568
- "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."
6569
- ],
6570
- status: "shipped"
6571
- },
6572
- {
6573
- name: "log collect-artifact",
6574
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
6575
- flags: [
6576
- { flag: "--pr", description: "The pull request this artifact belongs to" },
6577
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
6578
- ],
6579
- details: [
6580
- "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.",
6581
- "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.",
6582
- "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."
6583
- ],
6584
- status: "shipped"
6585
- },
6586
6599
  {
6587
6600
  name: "milestone create",
6588
6601
  description: "Create a GitHub Milestone from a validated body",
@@ -6912,7 +6925,7 @@ var COMMANDS = [
6912
6925
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
6913
6926
  {
6914
6927
  flag: "--pr",
6915
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
6928
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
6916
6929
  },
6917
6930
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
6918
6931
  {
@@ -6924,7 +6937,7 @@ var COMMANDS = [
6924
6937
  details: [
6925
6938
  "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.",
6926
6939
  "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`.",
6927
- "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.",
6940
+ "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.",
6928
6941
  "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."
6929
6942
  ],
6930
6943
  status: "shipped"
@@ -6944,7 +6957,8 @@ var COMMANDS = [
6944
6957
  "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> -->`.",
6945
6958
  "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.",
6946
6959
  "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.",
6947
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
6960
+ "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.",
6961
+ "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)."
6948
6962
  ],
6949
6963
  status: "shipped"
6950
6964
  }
@@ -7082,7 +7096,8 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
7082
7096
  }
7083
7097
 
7084
7098
  // src/lib/config.ts
7085
- import { execFileSync as execFileSync3 } from "node:child_process";
7099
+ import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
7100
+ import { promisify as promisify4 } from "node:util";
7086
7101
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
7087
7102
  import { homedir } from "node:os";
7088
7103
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -7109,10 +7124,10 @@ var CheckEntrySchema = z5.object({
7109
7124
  ownWorkflow: z5.boolean().optional(),
7110
7125
  principalOwed: z5.literal(true).optional(),
7111
7126
  validates: z5.enum(["body", "issue"]).optional()
7112
- }).superRefine((entry2, ctx) => {
7113
- if (!entry2.env)
7127
+ }).superRefine((entry, ctx) => {
7128
+ if (!entry.env)
7114
7129
  return;
7115
- for (const [key, value] of Object.entries(entry2.env)) {
7130
+ for (const [key, value] of Object.entries(entry.env)) {
7116
7131
  if (typeof value !== "object" || value === null || !("anyOf" in value))
7117
7132
  continue;
7118
7133
  const members = value.anyOf;
@@ -7269,18 +7284,19 @@ var VinayaConfigSchema = z5.object({
7269
7284
  });
7270
7285
  }
7271
7286
  }).optional(),
7272
- logPublish: z5.object({
7273
- issue: z5.number().int().positive().optional(),
7274
- pr: z5.number().int().positive().optional(),
7275
- webhookUrl: z5.string().url().optional(),
7276
- headers: z5.record(z5.string()).optional(),
7277
- maxChunksPerFlush: z5.number().int().positive().optional()
7278
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
7279
- message: "logPublish: set at most one of issue/pr/webhookUrl"
7280
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
7281
- message: "logPublish: headers requires webhookUrl"
7282
- }).optional(),
7283
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
7287
+ logPublish: z5.unknown().refine((v) => v === undefined, {
7288
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7289
+ }),
7290
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7291
+ logs: z5.object({
7292
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7293
+ url: z5.string().url().optional(),
7294
+ headers: z5.record(z5.string()).optional()
7295
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7296
+ message: "logs: set at most one of folder/url"
7297
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
7298
+ message: "logs: headers requires url"
7299
+ }).optional()
7284
7300
  });
7285
7301
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
7286
7302
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -7325,32 +7341,39 @@ function globalTokensCollectIgnoredWarning(path) {
7325
7341
  function globalRuntimeDirIgnoredWarning(path) {
7326
7342
  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.`;
7327
7343
  }
7344
+ var emittedGlobalKeyWarnings = new Set;
7345
+ function warnGlobalKeyIgnoredOnce(message) {
7346
+ if (emittedGlobalKeyWarnings.has(message))
7347
+ return;
7348
+ emittedGlobalKeyWarnings.add(message);
7349
+ console.error(`⚠ ${message}`);
7350
+ }
7328
7351
  function stripGlobalOnlyKeys(config, path) {
7329
7352
  if (path !== GLOBAL_CONFIG_PATH)
7330
7353
  return config;
7331
7354
  let result = config;
7332
7355
  if (result.checks && Object.keys(result.checks).length > 0) {
7333
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
7356
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
7334
7357
  result = { ...result, checks: undefined };
7335
7358
  }
7336
7359
  if (result.roles && Object.keys(result.roles).length > 0) {
7337
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
7360
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
7338
7361
  result = { ...result, roles: undefined };
7339
7362
  }
7340
7363
  if (result.principals && result.principals.length > 0) {
7341
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
7364
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
7342
7365
  result = { ...result, principals: undefined };
7343
7366
  }
7344
7367
  if (result.releaseActor) {
7345
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
7368
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
7346
7369
  result = { ...result, releaseActor: undefined };
7347
7370
  }
7348
7371
  if (result.tokens) {
7349
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
7372
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
7350
7373
  result = { ...result, tokens: undefined };
7351
7374
  }
7352
7375
  if (result.runtimeDir) {
7353
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
7376
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
7354
7377
  result = { ...result, runtimeDir: undefined };
7355
7378
  }
7356
7379
  return result;
@@ -7383,25 +7406,80 @@ function resolveReviewPolicy(config) {
7383
7406
  maxRounds
7384
7407
  };
7385
7408
  }
7386
- function trustAnchorRepo() {
7387
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7388
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7389
- if (fromRunner) {
7390
- const validated = wellFormed(fromRunner);
7391
- if (validated)
7392
- return validated;
7409
+ function resolveRuntimeDirSetting(config) {
7410
+ return config?.runtimeDir ?? null;
7411
+ }
7412
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
7413
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
7414
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
7415
+ }
7416
+ function resolveLogsSetting(config) {
7417
+ const raw = config?.logs;
7418
+ if (!raw)
7419
+ return null;
7420
+ if (raw.url !== undefined)
7421
+ return { url: raw.url, headers: raw.headers };
7422
+ if (raw.folder !== undefined)
7423
+ return { folder: raw.folder };
7424
+ return null;
7425
+ }
7426
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7427
+ const anchored = resolveLogsSetting(trustAnchorConfig);
7428
+ if (!anchored)
7429
+ return null;
7430
+ if ("url" in local)
7431
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
7432
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7433
+ }
7434
+ function resolveLogsHeaderValues(headers, env) {
7435
+ if (!headers)
7436
+ return;
7437
+ const resolved = {};
7438
+ for (const [key, value] of Object.entries(headers)) {
7439
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7393
7440
  }
7441
+ return resolved;
7442
+ }
7443
+ function trustAnchorRepo() {
7444
+ const fromRunner = trustAnchorRepoFromRunner();
7445
+ if (fromRunner)
7446
+ return fromRunner;
7394
7447
  try {
7395
7448
  const url = execFileSync3("git", ["remote", "get-url", "origin"], {
7396
7449
  encoding: "utf-8",
7397
7450
  stdio: ["ignore", "pipe", "pipe"]
7398
- }).trim();
7399
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7400
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
7451
+ });
7452
+ return trustAnchorRepoFromRemoteUrl(url);
7453
+ } catch {
7454
+ return null;
7455
+ }
7456
+ }
7457
+ async function trustAnchorRepoAsync() {
7458
+ const fromRunner = trustAnchorRepoFromRunner();
7459
+ if (fromRunner)
7460
+ return fromRunner;
7461
+ try {
7462
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7463
+ encoding: "utf-8",
7464
+ timeout: 1e4
7465
+ });
7466
+ return trustAnchorRepoFromRemoteUrl(stdout);
7401
7467
  } catch {
7402
7468
  return null;
7403
7469
  }
7404
7470
  }
7471
+ function wellFormedRepoSlug(slug) {
7472
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7473
+ }
7474
+ function trustAnchorRepoFromRunner() {
7475
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7476
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
7477
+ }
7478
+ function trustAnchorRepoFromRemoteUrl(url) {
7479
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7480
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7481
+ }
7482
+ var execFileAsync4 = promisify4(execFile4);
7405
7483
  function ghFetchTrustAnchorConfig() {
7406
7484
  const repo = trustAnchorRepo();
7407
7485
  if (!repo)
@@ -7411,6 +7489,13 @@ function ghFetchTrustAnchorConfig() {
7411
7489
  stdio: ["ignore", "pipe", "pipe"]
7412
7490
  });
7413
7491
  }
7492
+ async function ghFetchTrustAnchorConfigAsync() {
7493
+ const repo = await trustAnchorRepoAsync();
7494
+ if (!repo)
7495
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7496
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
7497
+ return stdout;
7498
+ }
7414
7499
  function firstLine(err) {
7415
7500
  return err?.message?.split(`
7416
7501
  `)[0] ?? "unknown error";
@@ -7425,16 +7510,35 @@ function isMissingFileError(err) {
7425
7510
  return /\b404\b|not found/i.test(haystack);
7426
7511
  }
7427
7512
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
7428
- 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.
7429
- `);
7430
7513
  let base64;
7431
7514
  try {
7432
- base64 = fetcher().trim();
7515
+ base64 = fetcher();
7433
7516
  } catch (err) {
7434
- if (!isMissingFileError(err))
7435
- warn(firstLine(err));
7436
- return null;
7517
+ return trustAnchorFetchFailed(err);
7518
+ }
7519
+ return parseTrustAnchorContent(base64);
7520
+ }
7521
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
7522
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7523
+ let base64;
7524
+ try {
7525
+ base64 = await fetcher();
7526
+ } catch (err) {
7527
+ return trustAnchorFetchFailed(err, warn);
7437
7528
  }
7529
+ return parseTrustAnchorContent(base64, warn);
7530
+ }
7531
+ function warnTrustAnchorFallback(why) {
7532
+ 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.
7533
+ `);
7534
+ }
7535
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7536
+ if (!isMissingFileError(err))
7537
+ warn(firstLine(err));
7538
+ return null;
7539
+ }
7540
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7541
+ const base64 = content.trim();
7438
7542
  if (!base64)
7439
7543
  return null;
7440
7544
  try {
@@ -7462,7 +7566,27 @@ function loadConfig() {
7462
7566
  }
7463
7567
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7464
7568
 
7569
+ // src/lib/package-root.ts
7570
+ import { existsSync as existsSync2 } from "node:fs";
7571
+ import { dirname as dirname2, join as join2 } from "node:path";
7572
+ import { fileURLToPath } from "node:url";
7573
+ function packageRoot(moduleUrl) {
7574
+ let dir = dirname2(fileURLToPath(moduleUrl));
7575
+ while (!existsSync2(join2(dir, "package.json"))) {
7576
+ if (existsSync2(join2(dir, ".git")))
7577
+ break;
7578
+ const parent = dirname2(dir);
7579
+ if (parent === dir)
7580
+ break;
7581
+ dir = parent;
7582
+ }
7583
+ return dir;
7584
+ }
7585
+
7465
7586
  // src/lib/brief-assembly.ts
7587
+ var PACKAGE_ROOT = packageRoot(import.meta.url);
7588
+ var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7589
+ var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7466
7590
  function git(args) {
7467
7591
  try {
7468
7592
  return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();