@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-first-push-dispatch.ts
6
4
  import { execFileSync as execFileSync4 } from "node:child_process";
@@ -1037,7 +1035,7 @@ function withDefaults(oldDefaults, newDefaults) {
1037
1035
  var endpoint = withDefaults(null, DEFAULTS);
1038
1036
 
1039
1037
  // ../../node_modules/fast-content-type-parse/index.js
1040
- var NullObject = function NullObject2() {};
1038
+ var NullObject = function NullObject() {};
1041
1039
  NullObject.prototype = Object.create(null);
1042
1040
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1043
1041
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1781,27 +1779,27 @@ function splitTableRow(row) {
1781
1779
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1782
1780
  }
1783
1781
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1784
- function resolveWorkspaceEntry(entry2, listDirs) {
1785
- if (entry2.endsWith("/*")) {
1786
- const baseDir = entry2.slice(0, -2);
1782
+ function resolveWorkspaceEntry(entry, listDirs) {
1783
+ if (entry.endsWith("/*")) {
1784
+ const baseDir = entry.slice(0, -2);
1787
1785
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1788
1786
  }
1789
- if (entry2.includes("*"))
1787
+ if (entry.includes("*"))
1790
1788
  return [];
1791
- return [entry2];
1789
+ return [entry];
1792
1790
  }
1793
1791
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1794
1792
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1795
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1796
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1793
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1794
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1797
1795
  const excluded = new Set;
1798
- for (const entry2 of negative) {
1799
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1796
+ for (const entry of negative) {
1797
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1800
1798
  excluded.add(member);
1801
1799
  }
1802
1800
  const members = new Set;
1803
- for (const entry2 of positive) {
1804
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1801
+ for (const entry of positive) {
1802
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1805
1803
  if (!excluded.has(member))
1806
1804
  members.add(member);
1807
1805
  }
@@ -2125,15 +2123,15 @@ function summarizeTranscript(jsonl) {
2125
2123
  const line = rawLine.trim();
2126
2124
  if (!line)
2127
2125
  continue;
2128
- let entry2;
2126
+ let entry;
2129
2127
  try {
2130
- entry2 = JSON.parse(line);
2128
+ entry = JSON.parse(line);
2131
2129
  } catch {
2132
2130
  continue;
2133
2131
  }
2134
- if (!entry2 || typeof entry2 !== "object")
2132
+ if (!entry || typeof entry !== "object")
2135
2133
  continue;
2136
- const obj = entry2;
2134
+ const obj = entry;
2137
2135
  if (obj.type !== "assistant")
2138
2136
  continue;
2139
2137
  const message = obj.message;
@@ -2981,7 +2979,7 @@ function isStep0Block(content) {
2981
2979
  }
2982
2980
  function checkCommandsCarryOutput(prBody) {
2983
2981
  const errors = [];
2984
- for (const [label2, num] of [
2982
+ for (const [label, num] of [
2985
2983
  ["5", 5],
2986
2984
  ["6", 6]
2987
2985
  ]) {
@@ -2995,7 +2993,7 @@ function checkCommandsCarryOutput(prBody) {
2995
2993
  continue;
2996
2994
  const next = blocks[i + 1];
2997
2995
  if (!next || isCommandBlock(next.content)) {
2998
- errors.push(`brief-validation commands carry output: §${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.`);
2996
+ errors.push(`brief-validation commands carry output: §${label} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
2999
2997
  }
3000
2998
  }
3001
2999
  }
@@ -3432,8 +3430,8 @@ function stripPartBackticks(text) {
3432
3430
  function partWordCount(text) {
3433
3431
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3434
3432
  }
3435
- function looksLikeFilePath(entry2) {
3436
- const stripped = entry2.replace(/\/\*\*?$/, "");
3433
+ function looksLikeFilePath(entry) {
3434
+ const stripped = entry.replace(/\/\*\*?$/, "");
3437
3435
  const lastSegment = stripped.split("/").pop() ?? stripped;
3438
3436
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3439
3437
  return extMatch !== null && extMatch.index > 0;
@@ -3919,14 +3917,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3919
3917
  const referenced = extractClosesReferences(prBody);
3920
3918
  if (taskIssueRefs) {
3921
3919
  for (const n of referenced) {
3922
- const ref2 = taskIssueRefs.get(n);
3923
- if (!ref2)
3920
+ const ref = taskIssueRefs.get(n);
3921
+ if (!ref)
3924
3922
  continue;
3925
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3923
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3926
3924
  if (branch !== expectedBranch) {
3927
3925
  return {
3928
3926
  ok: false,
3929
- message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${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.`
3927
+ message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
3930
3928
  };
3931
3929
  }
3932
3930
  }
@@ -3935,15 +3933,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3935
3933
  if (!ref)
3936
3934
  return { ok: true };
3937
3935
  if (ref.kind === "issue") {
3938
- const expectedIssue2 = ref.issueNumber;
3939
- if (!referenced.has(expectedIssue2)) {
3936
+ const expectedIssue = ref.issueNumber;
3937
+ if (!referenced.has(expectedIssue)) {
3940
3938
  return {
3941
3939
  ok: false,
3942
- expectedIssue: expectedIssue2,
3943
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3940
+ expectedIssue,
3941
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3944
3942
  };
3945
3943
  }
3946
- return { ok: true, expectedIssue: expectedIssue2 };
3944
+ return { ok: true, expectedIssue };
3947
3945
  }
3948
3946
  const trancheSlug = ref.tranche;
3949
3947
  const taskId = ref.taskId;
@@ -3989,8 +3987,8 @@ function extractIssue(body) {
3989
3987
  const anchorNums = closesRefs(anchored);
3990
3988
  if (anchorNums.length === 0)
3991
3989
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3992
- const issue2 = anchorNums[0];
3993
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
3990
+ const issue = anchorNums[0];
3991
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
3994
3992
  }
3995
3993
  const headerNums = closesRefs(headerRegion(stripped));
3996
3994
  if (bodyNums.length === 0)
@@ -4059,15 +4057,15 @@ function compareManifest(echoed, current, patchIdOf) {
4059
4057
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4060
4058
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4061
4059
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4062
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4060
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4063
4061
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4064
4062
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4065
4063
  return {
4066
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4064
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4067
4065
  head,
4068
4066
  base,
4069
4067
  briefHash: briefHashBound,
4070
- objectivesVersion: objectivesVersion2,
4068
+ objectivesVersion,
4071
4069
  rulingOrdinal,
4072
4070
  policyDigest: policyDigestBound
4073
4071
  };
@@ -5499,6 +5497,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5499
5497
  }
5500
5498
  return findings;
5501
5499
  }
5500
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5501
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5502
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5503
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5502
5504
  // ../../packages/aeg-core/src/log/envelope.ts
5503
5505
  import { createHash as createHash5 } from "node:crypto";
5504
5506
 
@@ -6037,6 +6039,7 @@ function redact(value, home) {
6037
6039
  return value;
6038
6040
  }
6039
6041
  // ../../packages/aeg-core/src/log/store.ts
6042
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6040
6043
  function metaOf(obj) {
6041
6044
  if (obj === null || typeof obj !== "object")
6042
6045
  return null;
@@ -6059,11 +6062,61 @@ function recordIdentity(obj) {
6059
6062
  }
6060
6063
  return null;
6061
6064
  }
6062
-
6063
- // ../../packages/aeg-core/src/log/artifact.ts
6064
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6065
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6066
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6065
+ function schemaVersionOf(obj) {
6066
+ const meta = metaOf(obj);
6067
+ const schema = meta?.schema;
6068
+ return typeof schema === "number" ? schema : null;
6069
+ }
6070
+ function isKnownSchema(version) {
6071
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6072
+ }
6073
+ function classifyStoredLine(raw, home) {
6074
+ let obj;
6075
+ try {
6076
+ obj = JSON.parse(raw);
6077
+ } catch {
6078
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6079
+ }
6080
+ const version = schemaVersionOf(obj);
6081
+ if (version === null) {
6082
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6083
+ }
6084
+ if (!isKnownSchema(version)) {
6085
+ return {
6086
+ status: "unknown_version",
6087
+ identity: recordIdentity(obj),
6088
+ schema: version,
6089
+ raw,
6090
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6091
+ };
6092
+ }
6093
+ const result = LogEventSchema.safeParse(obj);
6094
+ if (!result.success) {
6095
+ return {
6096
+ status: "invalid",
6097
+ identity: recordIdentity(obj),
6098
+ raw,
6099
+ reason: result.error.issues[0]?.message ?? "schema violation"
6100
+ };
6101
+ }
6102
+ const event = result.data;
6103
+ const identity = recordIdentity(event);
6104
+ if (identity === null) {
6105
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6106
+ }
6107
+ const redacted = redact(event, home);
6108
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6109
+ return {
6110
+ status: "ok",
6111
+ identity,
6112
+ runId: event.meta.run_id,
6113
+ seq: event.meta.seq,
6114
+ schema: version,
6115
+ provenance,
6116
+ event,
6117
+ postLine: JSON.stringify(redacted)
6118
+ };
6119
+ }
6067
6120
  // ../../packages/aeg-core/src/control-store/records.ts
6068
6121
  import { z as z3 } from "zod";
6069
6122
  var isoTimestamp = z3.string().min(1);
@@ -6344,10 +6397,10 @@ var COMMANDS = [
6344
6397
  }
6345
6398
  ],
6346
6399
  details: [
6347
- "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.",
6400
+ "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.",
6348
6401
  "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.",
6349
- "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.",
6350
- "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."
6402
+ "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.",
6403
+ "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`)."
6351
6404
  ],
6352
6405
  status: "shipped"
6353
6406
  },
@@ -6516,48 +6569,6 @@ var COMMANDS = [
6516
6569
  ],
6517
6570
  status: "shipped"
6518
6571
  },
6519
- {
6520
- name: "log flush",
6521
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
6522
- flags: [
6523
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
6524
- {
6525
- flag: "--pr",
6526
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
6527
- },
6528
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
6529
- ],
6530
- details: [
6531
- "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.",
6532
- "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.",
6533
- "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."
6534
- ],
6535
- status: "shipped"
6536
- },
6537
- {
6538
- name: "log export-artifact",
6539
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
6540
- flags: [],
6541
- details: [
6542
- "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.",
6543
- "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."
6544
- ],
6545
- status: "shipped"
6546
- },
6547
- {
6548
- name: "log collect-artifact",
6549
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
6550
- flags: [
6551
- { flag: "--pr", description: "The pull request this artifact belongs to" },
6552
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
6553
- ],
6554
- details: [
6555
- "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.",
6556
- "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.",
6557
- "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."
6558
- ],
6559
- status: "shipped"
6560
- },
6561
6572
  {
6562
6573
  name: "milestone create",
6563
6574
  description: "Create a GitHub Milestone from a validated body",
@@ -6887,7 +6898,7 @@ var COMMANDS = [
6887
6898
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
6888
6899
  {
6889
6900
  flag: "--pr",
6890
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
6901
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
6891
6902
  },
6892
6903
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
6893
6904
  {
@@ -6899,7 +6910,7 @@ var COMMANDS = [
6899
6910
  details: [
6900
6911
  "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.",
6901
6912
  "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`.",
6902
- "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.",
6913
+ "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.",
6903
6914
  "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."
6904
6915
  ],
6905
6916
  status: "shipped"
@@ -6919,7 +6930,8 @@ var COMMANDS = [
6919
6930
  "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> -->`.",
6920
6931
  "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.",
6921
6932
  "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.",
6922
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
6933
+ "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.",
6934
+ "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)."
6923
6935
  ],
6924
6936
  status: "shipped"
6925
6937
  }
@@ -6946,7 +6958,8 @@ function emitCheckError(error) {
6946
6958
  }
6947
6959
 
6948
6960
  // src/lib/config.ts
6949
- import { execFileSync as execFileSync2 } from "node:child_process";
6961
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6962
+ import { promisify as promisify4 } from "node:util";
6950
6963
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6951
6964
  import { homedir } from "node:os";
6952
6965
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -6973,10 +6986,10 @@ var CheckEntrySchema = z5.object({
6973
6986
  ownWorkflow: z5.boolean().optional(),
6974
6987
  principalOwed: z5.literal(true).optional(),
6975
6988
  validates: z5.enum(["body", "issue"]).optional()
6976
- }).superRefine((entry2, ctx) => {
6977
- if (!entry2.env)
6989
+ }).superRefine((entry, ctx) => {
6990
+ if (!entry.env)
6978
6991
  return;
6979
- for (const [key, value] of Object.entries(entry2.env)) {
6992
+ for (const [key, value] of Object.entries(entry.env)) {
6980
6993
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6981
6994
  continue;
6982
6995
  const members = value.anyOf;
@@ -7133,18 +7146,19 @@ var VinayaConfigSchema = z5.object({
7133
7146
  });
7134
7147
  }
7135
7148
  }).optional(),
7136
- logPublish: z5.object({
7137
- issue: z5.number().int().positive().optional(),
7138
- pr: z5.number().int().positive().optional(),
7139
- webhookUrl: z5.string().url().optional(),
7140
- headers: z5.record(z5.string()).optional(),
7141
- maxChunksPerFlush: z5.number().int().positive().optional()
7142
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
7143
- message: "logPublish: set at most one of issue/pr/webhookUrl"
7144
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
7145
- message: "logPublish: headers requires webhookUrl"
7146
- }).optional(),
7147
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
7149
+ logPublish: z5.unknown().refine((v) => v === undefined, {
7150
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7151
+ }),
7152
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7153
+ logs: z5.object({
7154
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7155
+ url: z5.string().url().optional(),
7156
+ headers: z5.record(z5.string()).optional()
7157
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7158
+ message: "logs: set at most one of folder/url"
7159
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
7160
+ message: "logs: headers requires url"
7161
+ }).optional()
7148
7162
  });
7149
7163
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
7150
7164
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -7189,32 +7203,39 @@ function globalTokensCollectIgnoredWarning(path) {
7189
7203
  function globalRuntimeDirIgnoredWarning(path) {
7190
7204
  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.`;
7191
7205
  }
7206
+ var emittedGlobalKeyWarnings = new Set;
7207
+ function warnGlobalKeyIgnoredOnce(message) {
7208
+ if (emittedGlobalKeyWarnings.has(message))
7209
+ return;
7210
+ emittedGlobalKeyWarnings.add(message);
7211
+ console.error(`⚠ ${message}`);
7212
+ }
7192
7213
  function stripGlobalOnlyKeys(config, path) {
7193
7214
  if (path !== GLOBAL_CONFIG_PATH)
7194
7215
  return config;
7195
7216
  let result = config;
7196
7217
  if (result.checks && Object.keys(result.checks).length > 0) {
7197
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
7218
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
7198
7219
  result = { ...result, checks: undefined };
7199
7220
  }
7200
7221
  if (result.roles && Object.keys(result.roles).length > 0) {
7201
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
7222
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
7202
7223
  result = { ...result, roles: undefined };
7203
7224
  }
7204
7225
  if (result.principals && result.principals.length > 0) {
7205
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
7226
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
7206
7227
  result = { ...result, principals: undefined };
7207
7228
  }
7208
7229
  if (result.releaseActor) {
7209
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
7230
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
7210
7231
  result = { ...result, releaseActor: undefined };
7211
7232
  }
7212
7233
  if (result.tokens) {
7213
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
7234
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
7214
7235
  result = { ...result, tokens: undefined };
7215
7236
  }
7216
7237
  if (result.runtimeDir) {
7217
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
7238
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
7218
7239
  result = { ...result, runtimeDir: undefined };
7219
7240
  }
7220
7241
  return result;
@@ -7247,25 +7268,80 @@ function resolveReviewPolicy(config) {
7247
7268
  maxRounds
7248
7269
  };
7249
7270
  }
7250
- function trustAnchorRepo() {
7251
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7252
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7253
- if (fromRunner) {
7254
- const validated = wellFormed(fromRunner);
7255
- if (validated)
7256
- return validated;
7271
+ function resolveRuntimeDirSetting(config) {
7272
+ return config?.runtimeDir ?? null;
7273
+ }
7274
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
7275
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
7276
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
7277
+ }
7278
+ function resolveLogsSetting(config) {
7279
+ const raw = config?.logs;
7280
+ if (!raw)
7281
+ return null;
7282
+ if (raw.url !== undefined)
7283
+ return { url: raw.url, headers: raw.headers };
7284
+ if (raw.folder !== undefined)
7285
+ return { folder: raw.folder };
7286
+ return null;
7287
+ }
7288
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7289
+ const anchored = resolveLogsSetting(trustAnchorConfig);
7290
+ if (!anchored)
7291
+ return null;
7292
+ if ("url" in local)
7293
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
7294
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7295
+ }
7296
+ function resolveLogsHeaderValues(headers, env) {
7297
+ if (!headers)
7298
+ return;
7299
+ const resolved = {};
7300
+ for (const [key, value] of Object.entries(headers)) {
7301
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7257
7302
  }
7303
+ return resolved;
7304
+ }
7305
+ function trustAnchorRepo() {
7306
+ const fromRunner = trustAnchorRepoFromRunner();
7307
+ if (fromRunner)
7308
+ return fromRunner;
7258
7309
  try {
7259
7310
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
7260
7311
  encoding: "utf-8",
7261
7312
  stdio: ["ignore", "pipe", "pipe"]
7262
- }).trim();
7263
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7264
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
7313
+ });
7314
+ return trustAnchorRepoFromRemoteUrl(url);
7315
+ } catch {
7316
+ return null;
7317
+ }
7318
+ }
7319
+ async function trustAnchorRepoAsync() {
7320
+ const fromRunner = trustAnchorRepoFromRunner();
7321
+ if (fromRunner)
7322
+ return fromRunner;
7323
+ try {
7324
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7325
+ encoding: "utf-8",
7326
+ timeout: 1e4
7327
+ });
7328
+ return trustAnchorRepoFromRemoteUrl(stdout);
7265
7329
  } catch {
7266
7330
  return null;
7267
7331
  }
7268
7332
  }
7333
+ function wellFormedRepoSlug(slug) {
7334
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7335
+ }
7336
+ function trustAnchorRepoFromRunner() {
7337
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7338
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
7339
+ }
7340
+ function trustAnchorRepoFromRemoteUrl(url) {
7341
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7342
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7343
+ }
7344
+ var execFileAsync4 = promisify4(execFile4);
7269
7345
  function ghFetchTrustAnchorConfig() {
7270
7346
  const repo = trustAnchorRepo();
7271
7347
  if (!repo)
@@ -7275,6 +7351,13 @@ function ghFetchTrustAnchorConfig() {
7275
7351
  stdio: ["ignore", "pipe", "pipe"]
7276
7352
  });
7277
7353
  }
7354
+ async function ghFetchTrustAnchorConfigAsync() {
7355
+ const repo = await trustAnchorRepoAsync();
7356
+ if (!repo)
7357
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7358
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
7359
+ return stdout;
7360
+ }
7278
7361
  function firstLine(err) {
7279
7362
  return err?.message?.split(`
7280
7363
  `)[0] ?? "unknown error";
@@ -7289,16 +7372,35 @@ function isMissingFileError(err) {
7289
7372
  return /\b404\b|not found/i.test(haystack);
7290
7373
  }
7291
7374
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
7292
- 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.
7293
- `);
7294
7375
  let base64;
7295
7376
  try {
7296
- base64 = fetcher().trim();
7377
+ base64 = fetcher();
7297
7378
  } catch (err) {
7298
- if (!isMissingFileError(err))
7299
- warn(firstLine(err));
7300
- return null;
7379
+ return trustAnchorFetchFailed(err);
7380
+ }
7381
+ return parseTrustAnchorContent(base64);
7382
+ }
7383
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
7384
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7385
+ let base64;
7386
+ try {
7387
+ base64 = await fetcher();
7388
+ } catch (err) {
7389
+ return trustAnchorFetchFailed(err, warn);
7301
7390
  }
7391
+ return parseTrustAnchorContent(base64, warn);
7392
+ }
7393
+ function warnTrustAnchorFallback(why) {
7394
+ 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.
7395
+ `);
7396
+ }
7397
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7398
+ if (!isMissingFileError(err))
7399
+ warn(firstLine(err));
7400
+ return null;
7401
+ }
7402
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7403
+ const base64 = content.trim();
7302
7404
  if (!base64)
7303
7405
  return null;
7304
7406
  try {
@@ -7481,14 +7583,14 @@ function prExistsFor(branch) {
7481
7583
  return false;
7482
7584
  }
7483
7585
  }
7484
- async function classifyReadiness(trancheSlug, taskId2) {
7586
+ async function classifyReadiness(trancheSlug, taskId) {
7485
7587
  const repo = resolveRepo2();
7486
7588
  if (!repo)
7487
7589
  return "UNKNOWN";
7488
7590
  try {
7489
7591
  const source = createForgeSource({ owner: repo.owner, repo: repo.repo });
7490
7592
  const tranche = await source.getTranche(trancheSlug);
7491
- const task = tranche.tasks.find((t) => t.id === taskId2);
7593
+ const task = tranche.tasks.find((t) => t.id === taskId);
7492
7594
  if (!task)
7493
7595
  return "NOT_READY";
7494
7596
  const taskRefs = tranche.tasks.map((t) => ({ id: t.id, issue: t.issue }));