@attalabs/vinaya 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/aeg-root/roles/developer/reference.md +3 -3
- package/aeg-root/templates/pr-report-template.md +7 -2
- package/dist/checks/bin/check-body-bare-digits.js +229 -86
- package/dist/checks/bin/check-branch-topology.js +101 -89
- package/dist/checks/bin/check-brief-shape.js +222 -79
- package/dist/checks/bin/check-changeset-coverage.js +739 -232
- package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
- package/dist/checks/bin/check-closes-n.js +101 -89
- package/dist/checks/bin/check-coherence.js +233 -129
- package/dist/checks/bin/check-dead-branch-push.js +97 -44
- package/dist/checks/bin/check-dispatch-readiness.js +238 -134
- package/dist/checks/bin/check-doc-coverage-push.js +722 -215
- package/dist/checks/bin/check-doc-coverage.js +726 -219
- package/dist/checks/bin/check-doctrine-no-procedures.js +222 -79
- package/dist/checks/bin/check-doctrine-portability.js +724 -217
- package/dist/checks/bin/check-evidence-fresh.js +720 -206
- package/dist/checks/bin/check-exec-bits.js +720 -213
- package/dist/checks/bin/check-first-push-dispatch.js +231 -129
- package/dist/checks/bin/check-issue-assignment.js +103 -91
- package/dist/checks/bin/check-issue-milestone-attach.js +94 -41
- package/dist/checks/bin/check-issue-objectives-numbering.js +94 -41
- package/dist/checks/bin/check-issue-parts-coverage.js +94 -41
- package/dist/checks/bin/check-issue-surface-globs.js +251 -127
- package/dist/checks/bin/check-issue-title-grammar.js +94 -41
- package/dist/checks/bin/check-issue-tranche-label.js +94 -41
- package/dist/checks/bin/check-main-branch-refusal.js +94 -41
- package/dist/checks/bin/check-no-disk-state.js +94 -41
- package/dist/checks/bin/check-pr-premise-reassert.js +222 -77
- package/dist/checks/bin/check-pr-report-density.js +94 -41
- package/dist/checks/bin/check-principal-test-plan-wait.js +94 -39
- package/dist/checks/bin/check-quoted-command.js +710 -201
- package/dist/checks/bin/check-reader-resolvable-prose.js +722 -213
- package/dist/checks/bin/check-registry-gates.js +104 -41
- package/dist/checks/bin/check-retired-vocabulary.js +708 -199
- package/dist/checks/bin/check-review-gate.js +224 -79
- package/dist/checks/bin/check-single-plan-pr.js +94 -41
- package/dist/checks/bin/check-surface-scope.js +101 -89
- package/dist/checks/bin/check-test-plan.js +94 -39
- package/dist/checks/bin/check-token-collection-wired.js +100 -42
- package/dist/checks/bin/check-token-report.js +96 -43
- package/dist/checks/bin/check-workspace-escape.js +722 -213
- package/dist/index.js +3725 -3148
- package/dist/lib/pre-push-cache-test-run.js +4175 -0
- package/dist/lib/pre-push-select-tests.js +709 -101
- package/package.json +3 -2
|
@@ -1,10 +1,8 @@
|
|
|
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-quoted-command.ts
|
|
6
|
-
import { existsSync as
|
|
7
|
-
import { join as
|
|
4
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
|
|
5
|
+
import { join as join10, relative as relative2, resolve as resolve3 } from "node:path";
|
|
8
6
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
9
7
|
var GATE_AUDIENCE = {
|
|
10
8
|
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
@@ -1038,7 +1036,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
1038
1036
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
1039
1037
|
|
|
1040
1038
|
// ../../node_modules/fast-content-type-parse/index.js
|
|
1041
|
-
var NullObject = function
|
|
1039
|
+
var NullObject = function NullObject() {};
|
|
1042
1040
|
NullObject.prototype = Object.create(null);
|
|
1043
1041
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
1044
1042
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
@@ -1132,8 +1130,8 @@ function isPlainObject2(value) {
|
|
|
1132
1130
|
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
1133
1131
|
}
|
|
1134
1132
|
async function fetchWrapper(requestOptions) {
|
|
1135
|
-
const
|
|
1136
|
-
if (!
|
|
1133
|
+
const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
|
|
1134
|
+
if (!fetch2) {
|
|
1137
1135
|
throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");
|
|
1138
1136
|
}
|
|
1139
1137
|
const log = requestOptions.request?.log || console;
|
|
@@ -1145,7 +1143,7 @@ async function fetchWrapper(requestOptions) {
|
|
|
1145
1143
|
]));
|
|
1146
1144
|
let fetchResponse;
|
|
1147
1145
|
try {
|
|
1148
|
-
fetchResponse = await
|
|
1146
|
+
fetchResponse = await fetch2(requestOptions.url, {
|
|
1149
1147
|
method: requestOptions.method,
|
|
1150
1148
|
body,
|
|
1151
1149
|
redirect: requestOptions.request?.redirect,
|
|
@@ -1782,27 +1780,27 @@ function splitTableRow(row) {
|
|
|
1782
1780
|
return parts.map((p) => p.split(PLACEHOLDER).join("|"));
|
|
1783
1781
|
}
|
|
1784
1782
|
// ../../packages/aeg-core/src/blast-radius-domains.ts
|
|
1785
|
-
function resolveWorkspaceEntry(
|
|
1786
|
-
if (
|
|
1787
|
-
const baseDir =
|
|
1783
|
+
function resolveWorkspaceEntry(entry, listDirs) {
|
|
1784
|
+
if (entry.endsWith("/*")) {
|
|
1785
|
+
const baseDir = entry.slice(0, -2);
|
|
1788
1786
|
return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
|
|
1789
1787
|
}
|
|
1790
|
-
if (
|
|
1788
|
+
if (entry.includes("*"))
|
|
1791
1789
|
return [];
|
|
1792
|
-
return [
|
|
1790
|
+
return [entry];
|
|
1793
1791
|
}
|
|
1794
1792
|
// ../../packages/aeg-core/src/consumer-enumeration.ts
|
|
1795
1793
|
function deriveWorkspaceMemberDirs(workspaces, listDirs) {
|
|
1796
|
-
const positive = workspaces.filter((
|
|
1797
|
-
const negative = workspaces.filter((
|
|
1794
|
+
const positive = workspaces.filter((entry) => !entry.startsWith("!"));
|
|
1795
|
+
const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
|
|
1798
1796
|
const excluded = new Set;
|
|
1799
|
-
for (const
|
|
1800
|
-
for (const member of resolveWorkspaceEntry(
|
|
1797
|
+
for (const entry of negative) {
|
|
1798
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs))
|
|
1801
1799
|
excluded.add(member);
|
|
1802
1800
|
}
|
|
1803
1801
|
const members = new Set;
|
|
1804
|
-
for (const
|
|
1805
|
-
for (const member of resolveWorkspaceEntry(
|
|
1802
|
+
for (const entry of positive) {
|
|
1803
|
+
for (const member of resolveWorkspaceEntry(entry, listDirs)) {
|
|
1806
1804
|
if (!excluded.has(member))
|
|
1807
1805
|
members.add(member);
|
|
1808
1806
|
}
|
|
@@ -2126,15 +2124,15 @@ function summarizeTranscript(jsonl) {
|
|
|
2126
2124
|
const line = rawLine.trim();
|
|
2127
2125
|
if (!line)
|
|
2128
2126
|
continue;
|
|
2129
|
-
let
|
|
2127
|
+
let entry;
|
|
2130
2128
|
try {
|
|
2131
|
-
|
|
2129
|
+
entry = JSON.parse(line);
|
|
2132
2130
|
} catch {
|
|
2133
2131
|
continue;
|
|
2134
2132
|
}
|
|
2135
|
-
if (!
|
|
2133
|
+
if (!entry || typeof entry !== "object")
|
|
2136
2134
|
continue;
|
|
2137
|
-
const obj =
|
|
2135
|
+
const obj = entry;
|
|
2138
2136
|
if (obj.type !== "assistant")
|
|
2139
2137
|
continue;
|
|
2140
2138
|
const message = obj.message;
|
|
@@ -2982,7 +2980,7 @@ function isStep0Block(content) {
|
|
|
2982
2980
|
}
|
|
2983
2981
|
function checkCommandsCarryOutput(prBody) {
|
|
2984
2982
|
const errors = [];
|
|
2985
|
-
for (const [
|
|
2983
|
+
for (const [label, num] of [
|
|
2986
2984
|
["5", 5],
|
|
2987
2985
|
["6", 6]
|
|
2988
2986
|
]) {
|
|
@@ -2996,7 +2994,7 @@ function checkCommandsCarryOutput(prBody) {
|
|
|
2996
2994
|
continue;
|
|
2997
2995
|
const next = blocks[i + 1];
|
|
2998
2996
|
if (!next || isCommandBlock(next.content)) {
|
|
2999
|
-
errors.push(`brief-validation commands carry output: §${
|
|
2997
|
+
errors.push(`brief-validation commands carry output: §${label} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
|
|
3000
2998
|
}
|
|
3001
2999
|
}
|
|
3002
3000
|
}
|
|
@@ -3433,8 +3431,8 @@ function stripPartBackticks(text) {
|
|
|
3433
3431
|
function partWordCount(text) {
|
|
3434
3432
|
return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
|
|
3435
3433
|
}
|
|
3436
|
-
function looksLikeFilePath(
|
|
3437
|
-
const stripped =
|
|
3434
|
+
function looksLikeFilePath(entry) {
|
|
3435
|
+
const stripped = entry.replace(/\/\*\*?$/, "");
|
|
3438
3436
|
const lastSegment = stripped.split("/").pop() ?? stripped;
|
|
3439
3437
|
const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
|
|
3440
3438
|
return extMatch !== null && extMatch.index > 0;
|
|
@@ -3920,14 +3918,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3920
3918
|
const referenced = extractClosesReferences(prBody);
|
|
3921
3919
|
if (taskIssueRefs) {
|
|
3922
3920
|
for (const n of referenced) {
|
|
3923
|
-
const
|
|
3924
|
-
if (!
|
|
3921
|
+
const ref = taskIssueRefs.get(n);
|
|
3922
|
+
if (!ref)
|
|
3925
3923
|
continue;
|
|
3926
|
-
const expectedBranch = `task/${
|
|
3924
|
+
const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
|
|
3927
3925
|
if (branch !== expectedBranch) {
|
|
3928
3926
|
return {
|
|
3929
3927
|
ok: false,
|
|
3930
|
-
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${
|
|
3928
|
+
message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
|
|
3931
3929
|
};
|
|
3932
3930
|
}
|
|
3933
3931
|
}
|
|
@@ -3936,15 +3934,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
|
|
|
3936
3934
|
if (!ref)
|
|
3937
3935
|
return { ok: true };
|
|
3938
3936
|
if (ref.kind === "issue") {
|
|
3939
|
-
const
|
|
3940
|
-
if (!referenced.has(
|
|
3937
|
+
const expectedIssue = ref.issueNumber;
|
|
3938
|
+
if (!referenced.has(expectedIssue)) {
|
|
3941
3939
|
return {
|
|
3942
3940
|
ok: false,
|
|
3943
|
-
expectedIssue
|
|
3944
|
-
message: `closes-n: PR body does not contain \`Closes #${
|
|
3941
|
+
expectedIssue,
|
|
3942
|
+
message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
|
|
3945
3943
|
};
|
|
3946
3944
|
}
|
|
3947
|
-
return { ok: true, expectedIssue
|
|
3945
|
+
return { ok: true, expectedIssue };
|
|
3948
3946
|
}
|
|
3949
3947
|
const trancheSlug = ref.tranche;
|
|
3950
3948
|
const taskId = ref.taskId;
|
|
@@ -3990,8 +3988,8 @@ function extractIssue(body) {
|
|
|
3990
3988
|
const anchorNums = closesRefs(anchored);
|
|
3991
3989
|
if (anchorNums.length === 0)
|
|
3992
3990
|
return { issue: null, extraIssues: bodyNums, outsideHeader: false };
|
|
3993
|
-
const
|
|
3994
|
-
return { issue
|
|
3991
|
+
const issue = anchorNums[0];
|
|
3992
|
+
return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
|
|
3995
3993
|
}
|
|
3996
3994
|
const headerNums = closesRefs(headerRegion(stripped));
|
|
3997
3995
|
if (bodyNums.length === 0)
|
|
@@ -4060,15 +4058,15 @@ function compareManifest(echoed, current, patchIdOf) {
|
|
|
4060
4058
|
const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
|
|
4061
4059
|
const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
|
|
4062
4060
|
const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
|
|
4063
|
-
const
|
|
4061
|
+
const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
|
|
4064
4062
|
const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
|
|
4065
4063
|
const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
|
|
4066
4064
|
return {
|
|
4067
|
-
bound: head && base && briefHashBound &&
|
|
4065
|
+
bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
|
|
4068
4066
|
head,
|
|
4069
4067
|
base,
|
|
4070
4068
|
briefHash: briefHashBound,
|
|
4071
|
-
objectivesVersion
|
|
4069
|
+
objectivesVersion,
|
|
4072
4070
|
rulingOrdinal,
|
|
4073
4071
|
policyDigest: policyDigestBound
|
|
4074
4072
|
};
|
|
@@ -5500,6 +5498,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
5500
5498
|
}
|
|
5501
5499
|
return findings;
|
|
5502
5500
|
}
|
|
5501
|
+
// ../../packages/aeg-core/src/dev-review-loop/types.ts
|
|
5502
|
+
var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
|
|
5503
|
+
// ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
|
|
5504
|
+
var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
|
|
5503
5505
|
// ../../packages/aeg-core/src/log/envelope.ts
|
|
5504
5506
|
import { createHash as createHash5 } from "node:crypto";
|
|
5505
5507
|
|
|
@@ -6038,6 +6040,7 @@ function redact(value, home) {
|
|
|
6038
6040
|
return value;
|
|
6039
6041
|
}
|
|
6040
6042
|
// ../../packages/aeg-core/src/log/store.ts
|
|
6043
|
+
var KNOWN_SCHEMA_VERSIONS = [1, 2];
|
|
6041
6044
|
function metaOf(obj) {
|
|
6042
6045
|
if (obj === null || typeof obj !== "object")
|
|
6043
6046
|
return null;
|
|
@@ -6060,11 +6063,61 @@ function recordIdentity(obj) {
|
|
|
6060
6063
|
}
|
|
6061
6064
|
return null;
|
|
6062
6065
|
}
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6066
|
+
function schemaVersionOf(obj) {
|
|
6067
|
+
const meta = metaOf(obj);
|
|
6068
|
+
const schema = meta?.schema;
|
|
6069
|
+
return typeof schema === "number" ? schema : null;
|
|
6070
|
+
}
|
|
6071
|
+
function isKnownSchema(version) {
|
|
6072
|
+
return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
|
|
6073
|
+
}
|
|
6074
|
+
function classifyStoredLine(raw, home) {
|
|
6075
|
+
let obj;
|
|
6076
|
+
try {
|
|
6077
|
+
obj = JSON.parse(raw);
|
|
6078
|
+
} catch {
|
|
6079
|
+
return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
|
|
6080
|
+
}
|
|
6081
|
+
const version = schemaVersionOf(obj);
|
|
6082
|
+
if (version === null) {
|
|
6083
|
+
return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
|
|
6084
|
+
}
|
|
6085
|
+
if (!isKnownSchema(version)) {
|
|
6086
|
+
return {
|
|
6087
|
+
status: "unknown_version",
|
|
6088
|
+
identity: recordIdentity(obj),
|
|
6089
|
+
schema: version,
|
|
6090
|
+
raw,
|
|
6091
|
+
reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
|
|
6092
|
+
};
|
|
6093
|
+
}
|
|
6094
|
+
const result = LogEventSchema.safeParse(obj);
|
|
6095
|
+
if (!result.success) {
|
|
6096
|
+
return {
|
|
6097
|
+
status: "invalid",
|
|
6098
|
+
identity: recordIdentity(obj),
|
|
6099
|
+
raw,
|
|
6100
|
+
reason: result.error.issues[0]?.message ?? "schema violation"
|
|
6101
|
+
};
|
|
6102
|
+
}
|
|
6103
|
+
const event = result.data;
|
|
6104
|
+
const identity = recordIdentity(event);
|
|
6105
|
+
if (identity === null) {
|
|
6106
|
+
return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
|
|
6107
|
+
}
|
|
6108
|
+
const redacted = redact(event, home);
|
|
6109
|
+
const provenance = version === 2 ? event.meta.provenance ?? null : null;
|
|
6110
|
+
return {
|
|
6111
|
+
status: "ok",
|
|
6112
|
+
identity,
|
|
6113
|
+
runId: event.meta.run_id,
|
|
6114
|
+
seq: event.meta.seq,
|
|
6115
|
+
schema: version,
|
|
6116
|
+
provenance,
|
|
6117
|
+
event,
|
|
6118
|
+
postLine: JSON.stringify(redacted)
|
|
6119
|
+
};
|
|
6120
|
+
}
|
|
6068
6121
|
// ../../packages/aeg-core/src/control-store/records.ts
|
|
6069
6122
|
import { z as z3 } from "zod";
|
|
6070
6123
|
var isoTimestamp = z3.string().min(1);
|
|
@@ -6248,7 +6301,8 @@ function hasDoctrineEntry(root) {
|
|
|
6248
6301
|
}
|
|
6249
6302
|
|
|
6250
6303
|
// src/lib/config.ts
|
|
6251
|
-
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
6304
|
+
import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
|
|
6305
|
+
import { promisify as promisify4 } from "node:util";
|
|
6252
6306
|
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
|
|
6253
6307
|
import { homedir } from "node:os";
|
|
6254
6308
|
import { dirname as dirname3, isAbsolute, join as join3, resolve } from "node:path";
|
|
@@ -6275,10 +6329,10 @@ var CheckEntrySchema = z4.object({
|
|
|
6275
6329
|
ownWorkflow: z4.boolean().optional(),
|
|
6276
6330
|
principalOwed: z4.literal(true).optional(),
|
|
6277
6331
|
validates: z4.enum(["body", "issue"]).optional()
|
|
6278
|
-
}).superRefine((
|
|
6279
|
-
if (!
|
|
6332
|
+
}).superRefine((entry, ctx) => {
|
|
6333
|
+
if (!entry.env)
|
|
6280
6334
|
return;
|
|
6281
|
-
for (const [key, value] of Object.entries(
|
|
6335
|
+
for (const [key, value] of Object.entries(entry.env)) {
|
|
6282
6336
|
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
6283
6337
|
continue;
|
|
6284
6338
|
const members = value.anyOf;
|
|
@@ -6435,18 +6489,19 @@ var VinayaConfigSchema = z4.object({
|
|
|
6435
6489
|
});
|
|
6436
6490
|
}
|
|
6437
6491
|
}).optional(),
|
|
6438
|
-
logPublish: z4.
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
}).refine((v) => v.
|
|
6447
|
-
message: "
|
|
6448
|
-
}).
|
|
6449
|
-
|
|
6492
|
+
logPublish: z4.unknown().refine((v) => v === undefined, {
|
|
6493
|
+
message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
|
|
6494
|
+
}),
|
|
6495
|
+
runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
|
|
6496
|
+
logs: z4.object({
|
|
6497
|
+
folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
|
|
6498
|
+
url: z4.string().url().optional(),
|
|
6499
|
+
headers: z4.record(z4.string()).optional()
|
|
6500
|
+
}).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
|
|
6501
|
+
message: "logs: set at most one of folder/url"
|
|
6502
|
+
}).refine((v) => v.headers === undefined || v.url !== undefined, {
|
|
6503
|
+
message: "logs: headers requires url"
|
|
6504
|
+
}).optional()
|
|
6450
6505
|
});
|
|
6451
6506
|
var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
|
|
6452
6507
|
var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
|
|
@@ -6491,32 +6546,39 @@ function globalTokensCollectIgnoredWarning(path) {
|
|
|
6491
6546
|
function globalRuntimeDirIgnoredWarning(path) {
|
|
6492
6547
|
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.`;
|
|
6493
6548
|
}
|
|
6549
|
+
var emittedGlobalKeyWarnings = new Set;
|
|
6550
|
+
function warnGlobalKeyIgnoredOnce(message) {
|
|
6551
|
+
if (emittedGlobalKeyWarnings.has(message))
|
|
6552
|
+
return;
|
|
6553
|
+
emittedGlobalKeyWarnings.add(message);
|
|
6554
|
+
console.error(`⚠ ${message}`);
|
|
6555
|
+
}
|
|
6494
6556
|
function stripGlobalOnlyKeys(config, path) {
|
|
6495
6557
|
if (path !== GLOBAL_CONFIG_PATH)
|
|
6496
6558
|
return config;
|
|
6497
6559
|
let result = config;
|
|
6498
6560
|
if (result.checks && Object.keys(result.checks).length > 0) {
|
|
6499
|
-
|
|
6561
|
+
warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
|
|
6500
6562
|
result = { ...result, checks: undefined };
|
|
6501
6563
|
}
|
|
6502
6564
|
if (result.roles && Object.keys(result.roles).length > 0) {
|
|
6503
|
-
|
|
6565
|
+
warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
|
|
6504
6566
|
result = { ...result, roles: undefined };
|
|
6505
6567
|
}
|
|
6506
6568
|
if (result.principals && result.principals.length > 0) {
|
|
6507
|
-
|
|
6569
|
+
warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
|
|
6508
6570
|
result = { ...result, principals: undefined };
|
|
6509
6571
|
}
|
|
6510
6572
|
if (result.releaseActor) {
|
|
6511
|
-
|
|
6573
|
+
warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
|
|
6512
6574
|
result = { ...result, releaseActor: undefined };
|
|
6513
6575
|
}
|
|
6514
6576
|
if (result.tokens) {
|
|
6515
|
-
|
|
6577
|
+
warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
|
|
6516
6578
|
result = { ...result, tokens: undefined };
|
|
6517
6579
|
}
|
|
6518
6580
|
if (result.runtimeDir) {
|
|
6519
|
-
|
|
6581
|
+
warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
|
|
6520
6582
|
result = { ...result, runtimeDir: undefined };
|
|
6521
6583
|
}
|
|
6522
6584
|
return result;
|
|
@@ -6549,25 +6611,80 @@ function resolveReviewPolicy(config) {
|
|
|
6549
6611
|
maxRounds
|
|
6550
6612
|
};
|
|
6551
6613
|
}
|
|
6552
|
-
function
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6614
|
+
function resolveRuntimeDirSetting(config) {
|
|
6615
|
+
return config?.runtimeDir ?? null;
|
|
6616
|
+
}
|
|
6617
|
+
function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
|
|
6618
|
+
const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
|
|
6619
|
+
return anchored !== null && anchored === localRuntimeDir ? anchored : null;
|
|
6620
|
+
}
|
|
6621
|
+
function resolveLogsSetting(config) {
|
|
6622
|
+
const raw = config?.logs;
|
|
6623
|
+
if (!raw)
|
|
6624
|
+
return null;
|
|
6625
|
+
if (raw.url !== undefined)
|
|
6626
|
+
return { url: raw.url, headers: raw.headers };
|
|
6627
|
+
if (raw.folder !== undefined)
|
|
6628
|
+
return { folder: raw.folder };
|
|
6629
|
+
return null;
|
|
6630
|
+
}
|
|
6631
|
+
function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
|
|
6632
|
+
const anchored = resolveLogsSetting(trustAnchorConfig);
|
|
6633
|
+
if (!anchored)
|
|
6634
|
+
return null;
|
|
6635
|
+
if ("url" in local)
|
|
6636
|
+
return "url" in anchored && anchored.url === local.url ? anchored : null;
|
|
6637
|
+
return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
|
|
6638
|
+
}
|
|
6639
|
+
function resolveLogsHeaderValues(headers, env) {
|
|
6640
|
+
if (!headers)
|
|
6641
|
+
return;
|
|
6642
|
+
const resolved = {};
|
|
6643
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6644
|
+
resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
|
|
6559
6645
|
}
|
|
6646
|
+
return resolved;
|
|
6647
|
+
}
|
|
6648
|
+
function trustAnchorRepo() {
|
|
6649
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6650
|
+
if (fromRunner)
|
|
6651
|
+
return fromRunner;
|
|
6560
6652
|
try {
|
|
6561
6653
|
const url = execFileSync3("git", ["remote", "get-url", "origin"], {
|
|
6562
6654
|
encoding: "utf-8",
|
|
6563
6655
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6564
|
-
})
|
|
6565
|
-
|
|
6566
|
-
return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
|
|
6656
|
+
});
|
|
6657
|
+
return trustAnchorRepoFromRemoteUrl(url);
|
|
6567
6658
|
} catch {
|
|
6568
6659
|
return null;
|
|
6569
6660
|
}
|
|
6570
6661
|
}
|
|
6662
|
+
async function trustAnchorRepoAsync() {
|
|
6663
|
+
const fromRunner = trustAnchorRepoFromRunner();
|
|
6664
|
+
if (fromRunner)
|
|
6665
|
+
return fromRunner;
|
|
6666
|
+
try {
|
|
6667
|
+
const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
|
|
6668
|
+
encoding: "utf-8",
|
|
6669
|
+
timeout: 1e4
|
|
6670
|
+
});
|
|
6671
|
+
return trustAnchorRepoFromRemoteUrl(stdout);
|
|
6672
|
+
} catch {
|
|
6673
|
+
return null;
|
|
6674
|
+
}
|
|
6675
|
+
}
|
|
6676
|
+
function wellFormedRepoSlug(slug) {
|
|
6677
|
+
return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
6678
|
+
}
|
|
6679
|
+
function trustAnchorRepoFromRunner() {
|
|
6680
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
6681
|
+
return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
|
|
6682
|
+
}
|
|
6683
|
+
function trustAnchorRepoFromRemoteUrl(url) {
|
|
6684
|
+
const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
6685
|
+
return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
|
|
6686
|
+
}
|
|
6687
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
6571
6688
|
function ghFetchTrustAnchorConfig() {
|
|
6572
6689
|
const repo = trustAnchorRepo();
|
|
6573
6690
|
if (!repo)
|
|
@@ -6577,6 +6694,13 @@ function ghFetchTrustAnchorConfig() {
|
|
|
6577
6694
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6578
6695
|
});
|
|
6579
6696
|
}
|
|
6697
|
+
async function ghFetchTrustAnchorConfigAsync() {
|
|
6698
|
+
const repo = await trustAnchorRepoAsync();
|
|
6699
|
+
if (!repo)
|
|
6700
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
6701
|
+
const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
|
|
6702
|
+
return stdout;
|
|
6703
|
+
}
|
|
6580
6704
|
function firstLine(err) {
|
|
6581
6705
|
return err?.message?.split(`
|
|
6582
6706
|
`)[0] ?? "unknown error";
|
|
@@ -6591,16 +6715,35 @@ function isMissingFileError(err) {
|
|
|
6591
6715
|
return /\b404\b|not found/i.test(haystack);
|
|
6592
6716
|
}
|
|
6593
6717
|
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
6594
|
-
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.
|
|
6595
|
-
`);
|
|
6596
6718
|
let base64;
|
|
6597
6719
|
try {
|
|
6598
|
-
base64 = fetcher()
|
|
6720
|
+
base64 = fetcher();
|
|
6599
6721
|
} catch (err) {
|
|
6600
|
-
|
|
6601
|
-
warn(firstLine(err));
|
|
6602
|
-
return null;
|
|
6722
|
+
return trustAnchorFetchFailed(err);
|
|
6603
6723
|
}
|
|
6724
|
+
return parseTrustAnchorContent(base64);
|
|
6725
|
+
}
|
|
6726
|
+
async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
|
|
6727
|
+
const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
|
|
6728
|
+
let base64;
|
|
6729
|
+
try {
|
|
6730
|
+
base64 = await fetcher();
|
|
6731
|
+
} catch (err) {
|
|
6732
|
+
return trustAnchorFetchFailed(err, warn);
|
|
6733
|
+
}
|
|
6734
|
+
return parseTrustAnchorContent(base64, warn);
|
|
6735
|
+
}
|
|
6736
|
+
function warnTrustAnchorFallback(why) {
|
|
6737
|
+
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.
|
|
6738
|
+
`);
|
|
6739
|
+
}
|
|
6740
|
+
function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
|
|
6741
|
+
if (!isMissingFileError(err))
|
|
6742
|
+
warn(firstLine(err));
|
|
6743
|
+
return null;
|
|
6744
|
+
}
|
|
6745
|
+
function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
|
|
6746
|
+
const base64 = content.trim();
|
|
6604
6747
|
if (!base64)
|
|
6605
6748
|
return null;
|
|
6606
6749
|
try {
|
|
@@ -6636,11 +6779,13 @@ function emitCheckError(error) {
|
|
|
6636
6779
|
}
|
|
6637
6780
|
|
|
6638
6781
|
// src/lib/diff-evidence.ts
|
|
6639
|
-
import { execFileSync as
|
|
6640
|
-
import { join as
|
|
6782
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
6783
|
+
import { join as join9, relative, resolve as resolve2 } from "node:path";
|
|
6641
6784
|
|
|
6642
6785
|
// src/lib/brief-assembly.ts
|
|
6643
6786
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
6787
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
|
|
6788
|
+
import { join as join4 } from "node:path";
|
|
6644
6789
|
|
|
6645
6790
|
// ../../packages/sources/src/commands.ts
|
|
6646
6791
|
var COMMANDS = [
|
|
@@ -6793,10 +6938,10 @@ var COMMANDS = [
|
|
|
6793
6938
|
}
|
|
6794
6939
|
],
|
|
6795
6940
|
details: [
|
|
6796
|
-
"Composes `task brief`'s own preparation (`prepareTask`) with `dev-review-loop`
|
|
6941
|
+
"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.",
|
|
6797
6942
|
"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.",
|
|
6798
|
-
"Refuses when the frozen brief's developer branch already has an open pull request —
|
|
6799
|
-
"Exit and printed summary distinguish a published
|
|
6943
|
+
"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.",
|
|
6944
|
+
"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`)."
|
|
6800
6945
|
],
|
|
6801
6946
|
status: "shipped"
|
|
6802
6947
|
},
|
|
@@ -6965,48 +7110,6 @@ var COMMANDS = [
|
|
|
6965
7110
|
],
|
|
6966
7111
|
status: "shipped"
|
|
6967
7112
|
},
|
|
6968
|
-
{
|
|
6969
|
-
name: "log flush",
|
|
6970
|
-
description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
|
|
6971
|
-
flags: [
|
|
6972
|
-
{ flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
|
|
6973
|
-
{
|
|
6974
|
-
flag: "--pr",
|
|
6975
|
-
description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
|
|
6976
|
-
},
|
|
6977
|
-
{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }
|
|
6978
|
-
],
|
|
6979
|
-
details: [
|
|
6980
|
-
"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.",
|
|
6981
|
-
"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.",
|
|
6982
|
-
"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."
|
|
6983
|
-
],
|
|
6984
|
-
status: "shipped"
|
|
6985
|
-
},
|
|
6986
|
-
{
|
|
6987
|
-
name: "log export-artifact",
|
|
6988
|
-
description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
|
|
6989
|
-
flags: [],
|
|
6990
|
-
details: [
|
|
6991
|
-
"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.",
|
|
6992
|
-
"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."
|
|
6993
|
-
],
|
|
6994
|
-
status: "shipped"
|
|
6995
|
-
},
|
|
6996
|
-
{
|
|
6997
|
-
name: "log collect-artifact",
|
|
6998
|
-
description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
|
|
6999
|
-
flags: [
|
|
7000
|
-
{ flag: "--pr", description: "The pull request this artifact belongs to" },
|
|
7001
|
-
{ flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
|
|
7002
|
-
],
|
|
7003
|
-
details: [
|
|
7004
|
-
"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.",
|
|
7005
|
-
"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.",
|
|
7006
|
-
"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."
|
|
7007
|
-
],
|
|
7008
|
-
status: "shipped"
|
|
7009
|
-
},
|
|
7010
7113
|
{
|
|
7011
7114
|
name: "milestone create",
|
|
7012
7115
|
description: "Create a GitHub Milestone from a validated body",
|
|
@@ -7336,7 +7439,7 @@ var COMMANDS = [
|
|
|
7336
7439
|
{ flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
|
|
7337
7440
|
{
|
|
7338
7441
|
flag: "--pr",
|
|
7339
|
-
description: "
|
|
7442
|
+
description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
|
|
7340
7443
|
},
|
|
7341
7444
|
{ flag: "--round", description: "Round number, for a dispatch inside a review loop" },
|
|
7342
7445
|
{
|
|
@@ -7348,7 +7451,7 @@ var COMMANDS = [
|
|
|
7348
7451
|
details: [
|
|
7349
7452
|
"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.",
|
|
7350
7453
|
"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`.",
|
|
7351
|
-
"
|
|
7454
|
+
"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.",
|
|
7352
7455
|
"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."
|
|
7353
7456
|
],
|
|
7354
7457
|
status: "shipped"
|
|
@@ -7368,7 +7471,8 @@ var COMMANDS = [
|
|
|
7368
7471
|
"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> -->`.",
|
|
7369
7472
|
"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.",
|
|
7370
7473
|
"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.",
|
|
7371
|
-
"Every dispatch and round transition is a log line through the Vinaya Log,
|
|
7474
|
+
"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.",
|
|
7475
|
+
"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)."
|
|
7372
7476
|
],
|
|
7373
7477
|
status: "shipped"
|
|
7374
7478
|
}
|
|
@@ -7506,6 +7610,9 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
|
|
|
7506
7610
|
}
|
|
7507
7611
|
|
|
7508
7612
|
// src/lib/brief-assembly.ts
|
|
7613
|
+
var PACKAGE_ROOT = packageRoot(import.meta.url);
|
|
7614
|
+
var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
|
|
7615
|
+
var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
|
|
7509
7616
|
function git(args) {
|
|
7510
7617
|
try {
|
|
7511
7618
|
return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
@@ -7521,14 +7628,14 @@ function expandGlob(glob) {
|
|
|
7521
7628
|
var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
|
|
7522
7629
|
|
|
7523
7630
|
// src/checks/registry.ts
|
|
7524
|
-
import { existsSync as
|
|
7525
|
-
import { join as
|
|
7526
|
-
var DIST_BIN_DIR =
|
|
7527
|
-
var SRC_BIN_DIR =
|
|
7528
|
-
var BIN_DIR =
|
|
7631
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7632
|
+
import { join as join5 } from "node:path";
|
|
7633
|
+
var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
|
|
7634
|
+
var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
|
|
7635
|
+
var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
|
|
7529
7636
|
var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
|
|
7530
7637
|
function bin(name) {
|
|
7531
|
-
return
|
|
7638
|
+
return join5(BIN_DIR, `${name}${BIN_EXT}`);
|
|
7532
7639
|
}
|
|
7533
7640
|
var REGISTRY = [
|
|
7534
7641
|
[
|
|
@@ -7940,6 +8047,16 @@ var REGISTRY = [
|
|
|
7940
8047
|
},
|
|
7941
8048
|
0
|
|
7942
8049
|
],
|
|
8050
|
+
[
|
|
8051
|
+
{
|
|
8052
|
+
name: "ci-shard-coverage",
|
|
8053
|
+
run: bin("check-ci-shard-coverage"),
|
|
8054
|
+
scope: "diff",
|
|
8055
|
+
timeoutMs: 15000,
|
|
8056
|
+
env: {}
|
|
8057
|
+
},
|
|
8058
|
+
0
|
|
8059
|
+
],
|
|
7943
8060
|
[
|
|
7944
8061
|
{
|
|
7945
8062
|
name: "workspace-escape",
|
|
@@ -8077,42 +8194,382 @@ function coreCheckRegistry() {
|
|
|
8077
8194
|
var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
|
|
8078
8195
|
|
|
8079
8196
|
// src/lib/log-sink.ts
|
|
8080
|
-
import {
|
|
8081
|
-
import { randomUUID } from "node:crypto";
|
|
8197
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
8198
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8199
|
+
import {
|
|
8200
|
+
closeSync as closeSync3,
|
|
8201
|
+
constants as fsConstants3,
|
|
8202
|
+
existsSync as existsSync7,
|
|
8203
|
+
fstatSync as fstatSync2,
|
|
8204
|
+
mkdirSync as mkdirSync3,
|
|
8205
|
+
openSync as openSync3,
|
|
8206
|
+
readFileSync as readFileSync6,
|
|
8207
|
+
renameSync as renameSync2,
|
|
8208
|
+
writeSync as writeSync2
|
|
8209
|
+
} from "node:fs";
|
|
8210
|
+
import { hostname as osHostname, homedir as homedir3 } from "node:os";
|
|
8211
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
8212
|
+
import { promisify as promisify5 } from "node:util";
|
|
8213
|
+
|
|
8214
|
+
// src/lib/run-paths.ts
|
|
8215
|
+
import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
|
|
8216
|
+
import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
|
|
8217
|
+
var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8218
|
+
function isSafeRepoSegment(segment) {
|
|
8219
|
+
return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
|
|
8220
|
+
}
|
|
8221
|
+
function repoSegment(repo) {
|
|
8222
|
+
if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
|
|
8223
|
+
return "unresolved";
|
|
8224
|
+
return `${repo.owner}-${repo.repo}`;
|
|
8225
|
+
}
|
|
8226
|
+
function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
|
|
8227
|
+
return join6(home, "runtime", repoSegment(repo));
|
|
8228
|
+
}
|
|
8229
|
+
function resolveRuntimeDir(input) {
|
|
8230
|
+
const local = resolveRuntimeDirSetting(input.localConfig);
|
|
8231
|
+
if (local === null)
|
|
8232
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8233
|
+
if (isInsideRepo(local, input.repoRoot))
|
|
8234
|
+
return defaultRuntimeDir(input.repo, input.home);
|
|
8235
|
+
if (!input.unattended)
|
|
8236
|
+
return local;
|
|
8237
|
+
const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
|
|
8238
|
+
return anchored ?? defaultRuntimeDir(input.repo, input.home);
|
|
8239
|
+
}
|
|
8240
|
+
function isInsideRepo(candidate, repoRoot) {
|
|
8241
|
+
if (!repoRoot)
|
|
8242
|
+
return false;
|
|
8243
|
+
const root = resolvePath(repoRoot);
|
|
8244
|
+
const target = resolvePath(candidate);
|
|
8245
|
+
return target === root || target.startsWith(`${root}/`);
|
|
8246
|
+
}
|
|
8247
|
+
var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
|
|
8248
|
+
var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
|
|
8249
|
+
function isUnattendedProcess(env = process.env) {
|
|
8250
|
+
return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
|
|
8251
|
+
}
|
|
8252
|
+
var memoized = null;
|
|
8253
|
+
async function runtimeDirForRepoAsync(repo) {
|
|
8254
|
+
const key = repoSegment(repo);
|
|
8255
|
+
if (memoized?.key === key)
|
|
8256
|
+
return memoized.value;
|
|
8257
|
+
const inputs = runtimeDirInputs();
|
|
8258
|
+
if (typeof inputs === "string")
|
|
8259
|
+
return inputs;
|
|
8260
|
+
const value = resolveRuntimeDir({
|
|
8261
|
+
repo,
|
|
8262
|
+
...inputs.base,
|
|
8263
|
+
trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
|
|
8264
|
+
});
|
|
8265
|
+
memoized = { key, value };
|
|
8266
|
+
return value;
|
|
8267
|
+
}
|
|
8268
|
+
function runtimeDirInputs() {
|
|
8269
|
+
const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
|
|
8270
|
+
if (handedDown)
|
|
8271
|
+
return handedDown;
|
|
8272
|
+
const localConfig = loadConfig();
|
|
8273
|
+
const unattended = isUnattendedProcess();
|
|
8274
|
+
return {
|
|
8275
|
+
base: { localConfig, unattended, repoRoot: repoRootSync() },
|
|
8276
|
+
needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
|
|
8277
|
+
};
|
|
8278
|
+
}
|
|
8279
|
+
function repoRootSync(start = process.cwd()) {
|
|
8280
|
+
let dir;
|
|
8281
|
+
try {
|
|
8282
|
+
dir = realpathSync2(start);
|
|
8283
|
+
} catch {
|
|
8284
|
+
return null;
|
|
8285
|
+
}
|
|
8286
|
+
for (;; ) {
|
|
8287
|
+
if (existsSync6(join6(dir, ".git")))
|
|
8288
|
+
return dir;
|
|
8289
|
+
const parent = dirname4(dir);
|
|
8290
|
+
if (parent === dir)
|
|
8291
|
+
return null;
|
|
8292
|
+
dir = parent;
|
|
8293
|
+
}
|
|
8294
|
+
}
|
|
8295
|
+
|
|
8296
|
+
// src/lib/log-webhook-drain.ts
|
|
8082
8297
|
import {
|
|
8083
8298
|
closeSync as closeSync2,
|
|
8084
8299
|
constants as fsConstants2,
|
|
8085
|
-
|
|
8086
|
-
fstatSync as fstatSync2,
|
|
8300
|
+
lstatSync,
|
|
8087
8301
|
mkdirSync as mkdirSync2,
|
|
8088
8302
|
openSync as openSync2,
|
|
8089
|
-
|
|
8303
|
+
linkSync,
|
|
8304
|
+
readFileSync as readFileSync5,
|
|
8090
8305
|
renameSync,
|
|
8306
|
+
statSync,
|
|
8307
|
+
unlinkSync,
|
|
8308
|
+
writeFileSync as writeFileSync2,
|
|
8091
8309
|
writeSync
|
|
8092
8310
|
} from "node:fs";
|
|
8093
|
-
import {
|
|
8094
|
-
import {
|
|
8095
|
-
|
|
8311
|
+
import { randomUUID } from "node:crypto";
|
|
8312
|
+
import { homedir as homedir2 } from "node:os";
|
|
8313
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
8314
|
+
var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
|
|
8315
|
+
var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
|
|
8316
|
+
var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8317
|
+
function isSafeRepoSegment2(segment) {
|
|
8318
|
+
return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
|
|
8319
|
+
}
|
|
8320
|
+
function isErrnoCode(err, code) {
|
|
8321
|
+
return typeof err === "object" && err !== null && err.code === code;
|
|
8322
|
+
}
|
|
8096
8323
|
function isEnoent(err) {
|
|
8324
|
+
return isErrnoCode(err, "ENOENT");
|
|
8325
|
+
}
|
|
8326
|
+
var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
|
|
8327
|
+
function tryCreateLock(lockPath, token) {
|
|
8328
|
+
try {
|
|
8329
|
+
mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
|
|
8330
|
+
const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
|
|
8331
|
+
try {
|
|
8332
|
+
writeSync(fd, `${token}
|
|
8333
|
+
`);
|
|
8334
|
+
} finally {
|
|
8335
|
+
closeSync2(fd);
|
|
8336
|
+
}
|
|
8337
|
+
return true;
|
|
8338
|
+
} catch (err) {
|
|
8339
|
+
if (isErrnoCode(err, "EEXIST"))
|
|
8340
|
+
return false;
|
|
8341
|
+
throw err;
|
|
8342
|
+
}
|
|
8343
|
+
}
|
|
8344
|
+
function acquireDrainLock(lockPath) {
|
|
8345
|
+
const token = `${process.pid}:${randomUUID()}`;
|
|
8346
|
+
if (tryCreateLock(lockPath, token))
|
|
8347
|
+
return token;
|
|
8348
|
+
let observedMtimeMs;
|
|
8349
|
+
try {
|
|
8350
|
+
observedMtimeMs = statSync(lockPath).mtimeMs;
|
|
8351
|
+
} catch (err) {
|
|
8352
|
+
if (!isEnoent(err))
|
|
8353
|
+
throw err;
|
|
8354
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8355
|
+
}
|
|
8356
|
+
if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
|
|
8357
|
+
return null;
|
|
8358
|
+
const claimed = `${lockPath}.claimed-${randomUUID()}`;
|
|
8359
|
+
try {
|
|
8360
|
+
renameSync(lockPath, claimed);
|
|
8361
|
+
} catch (err) {
|
|
8362
|
+
if (isEnoent(err))
|
|
8363
|
+
return null;
|
|
8364
|
+
throw err;
|
|
8365
|
+
}
|
|
8366
|
+
let claimedMtimeMs = null;
|
|
8367
|
+
try {
|
|
8368
|
+
claimedMtimeMs = statSync(claimed).mtimeMs;
|
|
8369
|
+
} catch (err) {
|
|
8370
|
+
if (!isEnoent(err))
|
|
8371
|
+
throw err;
|
|
8372
|
+
}
|
|
8373
|
+
if (claimedMtimeMs !== observedMtimeMs) {
|
|
8374
|
+
try {
|
|
8375
|
+
linkSync(claimed, lockPath);
|
|
8376
|
+
} catch (err) {
|
|
8377
|
+
if (!isErrnoCode(err, "EEXIST"))
|
|
8378
|
+
throw err;
|
|
8379
|
+
}
|
|
8380
|
+
try {
|
|
8381
|
+
unlinkSync(claimed);
|
|
8382
|
+
} catch (err) {
|
|
8383
|
+
if (!isEnoent(err))
|
|
8384
|
+
throw err;
|
|
8385
|
+
}
|
|
8386
|
+
return null;
|
|
8387
|
+
}
|
|
8388
|
+
unlinkSync(claimed);
|
|
8389
|
+
return tryCreateLock(lockPath, token) ? token : null;
|
|
8390
|
+
}
|
|
8391
|
+
function releaseDrainLock(lockPath, token) {
|
|
8392
|
+
try {
|
|
8393
|
+
const holder = readFileSync5(lockPath, "utf8").trim();
|
|
8394
|
+
if (holder !== token)
|
|
8395
|
+
return;
|
|
8396
|
+
unlinkSync(lockPath);
|
|
8397
|
+
} catch (err) {
|
|
8398
|
+
if (!isEnoent(err))
|
|
8399
|
+
throw err;
|
|
8400
|
+
}
|
|
8401
|
+
}
|
|
8402
|
+
|
|
8403
|
+
class WebhookDrainError extends Error {
|
|
8404
|
+
code;
|
|
8405
|
+
constructor(code, message) {
|
|
8406
|
+
super(message);
|
|
8407
|
+
this.code = code;
|
|
8408
|
+
}
|
|
8409
|
+
}
|
|
8410
|
+
async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
|
|
8411
|
+
const resolved = await resolveRepo();
|
|
8412
|
+
const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
|
|
8413
|
+
const outboxRoot = () => join7(GLOBAL_VINAYA_HOME, "outbox");
|
|
8414
|
+
const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
|
|
8415
|
+
const lockPath = `${path}.flush-lock`;
|
|
8416
|
+
const lockToken = acquireDrainLock(lockPath);
|
|
8417
|
+
if (lockToken === null)
|
|
8418
|
+
return { flushed: false };
|
|
8419
|
+
try {
|
|
8420
|
+
let lstat;
|
|
8421
|
+
try {
|
|
8422
|
+
lstat = lstatSync(path);
|
|
8423
|
+
} catch (err) {
|
|
8424
|
+
if (!isEnoent(err))
|
|
8425
|
+
throw err;
|
|
8426
|
+
}
|
|
8427
|
+
if (lstat === undefined)
|
|
8428
|
+
return { flushed: false };
|
|
8429
|
+
if (!lstat.isFile()) {
|
|
8430
|
+
throw new WebhookDrainError("log-webhook-drain-symlink", `log webhook drain: outbox target is not a regular file (symlink, FIFO, or similar) — refusing to read: ${path}`);
|
|
8431
|
+
}
|
|
8432
|
+
const buf = readFileSync5(path);
|
|
8433
|
+
const startOffset = buf.byteLength;
|
|
8434
|
+
const rawLines = buf.toString("utf8").split(`
|
|
8435
|
+
`).filter((l) => l.length > 0);
|
|
8436
|
+
if (rawLines.length === 0)
|
|
8437
|
+
return { flushed: false };
|
|
8438
|
+
const postLines = [];
|
|
8439
|
+
for (let i = 0;i < rawLines.length; i++) {
|
|
8440
|
+
const record = classifyStoredLine(rawLines[i], homedir2());
|
|
8441
|
+
if (record.status !== "ok") {
|
|
8442
|
+
throw new WebhookDrainError("log-webhook-drain-corrupt-line", `log webhook drain: outbox line ${i} failed schema re-validation — ${record.reason}`);
|
|
8443
|
+
}
|
|
8444
|
+
postLines.push(record.postLine);
|
|
8445
|
+
}
|
|
8446
|
+
const body = `${postLines.join(`
|
|
8447
|
+
`)}
|
|
8448
|
+
`;
|
|
8449
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
8450
|
+
if (bytes > MAX_WEBHOOK_BODY_BYTES) {
|
|
8451
|
+
throw new WebhookDrainError("log-webhook-drain-too-large", `log webhook drain: outbox body is ${bytes} byte(s), over the ${MAX_WEBHOOK_BODY_BYTES}-byte per-call cap — flush more often to drain it.`);
|
|
8452
|
+
}
|
|
8453
|
+
let response;
|
|
8454
|
+
try {
|
|
8455
|
+
response = await fetch(webhookUrl, {
|
|
8456
|
+
method: "POST",
|
|
8457
|
+
headers: { "content-type": "application/x-ndjson", ...headers },
|
|
8458
|
+
body,
|
|
8459
|
+
signal: AbortSignal.timeout(fetchTimeoutMs)
|
|
8460
|
+
});
|
|
8461
|
+
} catch (err) {
|
|
8462
|
+
const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
|
|
8463
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed: ${reason}`);
|
|
8464
|
+
}
|
|
8465
|
+
if (!response.ok) {
|
|
8466
|
+
throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}`);
|
|
8467
|
+
}
|
|
8468
|
+
const liveNow = readFileSync5(path);
|
|
8469
|
+
const tail = liveNow.subarray(Math.min(startOffset, liveNow.byteLength));
|
|
8470
|
+
writeFileSync2(path, tail);
|
|
8471
|
+
return { flushed: true, lineCount: postLines.length, bytes };
|
|
8472
|
+
} finally {
|
|
8473
|
+
releaseDrainLock(lockPath, lockToken);
|
|
8474
|
+
}
|
|
8475
|
+
}
|
|
8476
|
+
|
|
8477
|
+
// src/lib/log-sink.ts
|
|
8478
|
+
var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
|
|
8479
|
+
var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
|
|
8480
|
+
function withDeadline(work, ms, fallback) {
|
|
8481
|
+
return new Promise((resolve) => {
|
|
8482
|
+
const timer = setTimeout(() => resolve(fallback), ms);
|
|
8483
|
+
timer.unref?.();
|
|
8484
|
+
work.then((value) => {
|
|
8485
|
+
clearTimeout(timer);
|
|
8486
|
+
resolve(value);
|
|
8487
|
+
}, () => {
|
|
8488
|
+
clearTimeout(timer);
|
|
8489
|
+
resolve(fallback);
|
|
8490
|
+
});
|
|
8491
|
+
});
|
|
8492
|
+
}
|
|
8493
|
+
async function safeLoadTrustAnchorConfig() {
|
|
8494
|
+
return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
|
|
8495
|
+
}
|
|
8496
|
+
function logsCredentialMissing(headers, env) {
|
|
8497
|
+
if (!headers)
|
|
8498
|
+
return false;
|
|
8499
|
+
const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
8500
|
+
for (const value of Object.values(headers)) {
|
|
8501
|
+
for (const match of value.matchAll(varPattern)) {
|
|
8502
|
+
if (!env[match[1]])
|
|
8503
|
+
return true;
|
|
8504
|
+
}
|
|
8505
|
+
}
|
|
8506
|
+
return false;
|
|
8507
|
+
}
|
|
8508
|
+
function resolveLogDestinationFrom(input) {
|
|
8509
|
+
const local = resolveLogsSetting(input.localConfig);
|
|
8510
|
+
let effective = null;
|
|
8511
|
+
if (input.unattended) {
|
|
8512
|
+
effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
|
|
8513
|
+
} else {
|
|
8514
|
+
effective = local;
|
|
8515
|
+
}
|
|
8516
|
+
if (hostFromEnv(input.env) === "ci") {
|
|
8517
|
+
if (effective && "url" in effective) {
|
|
8518
|
+
if (logsCredentialMissing(effective.headers, input.env)) {
|
|
8519
|
+
return {
|
|
8520
|
+
kind: "none",
|
|
8521
|
+
reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
|
|
8522
|
+
};
|
|
8523
|
+
}
|
|
8524
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8525
|
+
}
|
|
8526
|
+
return {
|
|
8527
|
+
kind: "none",
|
|
8528
|
+
reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
|
|
8529
|
+
};
|
|
8530
|
+
}
|
|
8531
|
+
if (effective && "url" in effective) {
|
|
8532
|
+
return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
|
|
8533
|
+
}
|
|
8534
|
+
if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
|
|
8535
|
+
effective = null;
|
|
8536
|
+
}
|
|
8537
|
+
const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
|
|
8538
|
+
return { kind: "folder", folder };
|
|
8539
|
+
}
|
|
8540
|
+
var processTrustAnchorOnce;
|
|
8541
|
+
function processTrustAnchor() {
|
|
8542
|
+
if (processTrustAnchorOnce === undefined)
|
|
8543
|
+
processTrustAnchorOnce = safeLoadTrustAnchorConfig();
|
|
8544
|
+
return processTrustAnchorOnce;
|
|
8545
|
+
}
|
|
8546
|
+
async function defaultResolveLogDestination(repo, env) {
|
|
8547
|
+
const localConfig = loadConfig();
|
|
8548
|
+
const unattended = isUnattendedProcess(process.env);
|
|
8549
|
+
return resolveLogDestinationFrom({
|
|
8550
|
+
localConfig,
|
|
8551
|
+
trustAnchorConfig: unattended ? await processTrustAnchor() : null,
|
|
8552
|
+
unattended,
|
|
8553
|
+
env,
|
|
8554
|
+
defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
|
|
8555
|
+
repoRoot: repoRootSync()
|
|
8556
|
+
});
|
|
8557
|
+
}
|
|
8558
|
+
function isEnoent2(err) {
|
|
8097
8559
|
return typeof err === "object" && err !== null && err.code === "ENOENT";
|
|
8098
8560
|
}
|
|
8099
|
-
|
|
8561
|
+
var execFileAsync5 = promisify5(execFile5);
|
|
8562
|
+
async function resolveDoctrine(cwd, vinayaVersion) {
|
|
8100
8563
|
let toplevel;
|
|
8101
8564
|
try {
|
|
8102
|
-
toplevel =
|
|
8103
|
-
encoding: "utf8",
|
|
8104
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8105
|
-
}).trim();
|
|
8565
|
+
toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
|
|
8106
8566
|
} catch (err) {
|
|
8107
|
-
return
|
|
8567
|
+
return isEnoent2(err) ? "unknown" : vinayaVersion;
|
|
8108
8568
|
}
|
|
8109
|
-
if (!
|
|
8569
|
+
if (!existsSync7(join8(toplevel, "aeg-root", "roles")))
|
|
8110
8570
|
return vinayaVersion;
|
|
8111
8571
|
try {
|
|
8112
|
-
const sha =
|
|
8113
|
-
encoding: "utf8",
|
|
8114
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
8115
|
-
}).trim();
|
|
8572
|
+
const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
|
|
8116
8573
|
return `aeg-root@${sha}`;
|
|
8117
8574
|
} catch {
|
|
8118
8575
|
return vinayaVersion;
|
|
@@ -8120,20 +8577,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
|
|
|
8120
8577
|
}
|
|
8121
8578
|
function readVinayaVersion() {
|
|
8122
8579
|
try {
|
|
8123
|
-
const pkg = JSON.parse(
|
|
8580
|
+
const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
|
|
8124
8581
|
return pkg.version ?? "unknown";
|
|
8125
8582
|
} catch {
|
|
8126
8583
|
return "unknown";
|
|
8127
8584
|
}
|
|
8128
8585
|
}
|
|
8129
|
-
var
|
|
8130
|
-
function
|
|
8131
|
-
return
|
|
8586
|
+
var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
8587
|
+
function isSafeRepoSegment3(segment) {
|
|
8588
|
+
return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
|
|
8132
8589
|
}
|
|
8133
8590
|
function outboxPathFor(deps, repo, issue) {
|
|
8134
8591
|
const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
|
|
8135
8592
|
const fileName = `${issue ?? "none"}.ndjson`;
|
|
8136
|
-
return
|
|
8593
|
+
return join8(deps.outboxRoot(), dirName, fileName);
|
|
8137
8594
|
}
|
|
8138
8595
|
function hostFromEnv(env) {
|
|
8139
8596
|
if (env.GITHUB_ACTIONS)
|
|
@@ -8144,28 +8601,34 @@ function hostFromEnv(env) {
|
|
|
8144
8601
|
return "loop";
|
|
8145
8602
|
return "cli";
|
|
8146
8603
|
}
|
|
8604
|
+
var warnedThisProcess = false;
|
|
8605
|
+
function defaultStderr(message) {
|
|
8606
|
+
if (warnedThisProcess)
|
|
8607
|
+
return;
|
|
8608
|
+
warnedThisProcess = true;
|
|
8609
|
+
process.stderr.write(message);
|
|
8610
|
+
}
|
|
8147
8611
|
function defaultDeps() {
|
|
8148
8612
|
return {
|
|
8149
|
-
outboxRoot: () =>
|
|
8150
|
-
home: () =>
|
|
8613
|
+
outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
|
|
8614
|
+
home: () => homedir3(),
|
|
8151
8615
|
hostname: () => osHostname(),
|
|
8152
8616
|
cwd: () => process.cwd(),
|
|
8153
8617
|
now: () => new Date,
|
|
8154
8618
|
env: () => process.env,
|
|
8155
8619
|
resolveRepo: () => resolveRepo(),
|
|
8156
8620
|
vinayaVersion: () => readVinayaVersion(),
|
|
8157
|
-
stderr:
|
|
8158
|
-
process.stderr.write(message);
|
|
8159
|
-
},
|
|
8621
|
+
stderr: defaultStderr,
|
|
8160
8622
|
inputVersions: () => {
|
|
8161
8623
|
return;
|
|
8162
|
-
}
|
|
8624
|
+
},
|
|
8625
|
+
resolveLogDestination: defaultResolveLogDestination
|
|
8163
8626
|
};
|
|
8164
8627
|
}
|
|
8165
|
-
var APPEND_OPEN_FLAGS =
|
|
8628
|
+
var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
|
|
8166
8629
|
function guardedAppendOpen(path) {
|
|
8167
8630
|
try {
|
|
8168
|
-
return
|
|
8631
|
+
return openSync3(path, APPEND_OPEN_FLAGS, 384);
|
|
8169
8632
|
} catch {
|
|
8170
8633
|
return;
|
|
8171
8634
|
}
|
|
@@ -8173,7 +8636,7 @@ function guardedAppendOpen(path) {
|
|
|
8173
8636
|
function reportRotationOverflow(backupPath, warn) {
|
|
8174
8637
|
let raw;
|
|
8175
8638
|
try {
|
|
8176
|
-
raw =
|
|
8639
|
+
raw = readFileSync6(backupPath, "utf8");
|
|
8177
8640
|
} catch {
|
|
8178
8641
|
return;
|
|
8179
8642
|
}
|
|
@@ -8196,7 +8659,7 @@ function reportRotationOverflow(backupPath, warn) {
|
|
|
8196
8659
|
}
|
|
8197
8660
|
function appendLine(path, line, warn) {
|
|
8198
8661
|
try {
|
|
8199
|
-
|
|
8662
|
+
mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
|
|
8200
8663
|
let fd = guardedAppendOpen(path);
|
|
8201
8664
|
if (fd === undefined) {
|
|
8202
8665
|
warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
|
|
@@ -8212,11 +8675,11 @@ function appendLine(path, line, warn) {
|
|
|
8212
8675
|
return;
|
|
8213
8676
|
}
|
|
8214
8677
|
if (stat.size > OUTBOX_MAX_BYTES) {
|
|
8215
|
-
|
|
8678
|
+
closeSync3(fd);
|
|
8216
8679
|
closed = true;
|
|
8217
8680
|
const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
|
|
8218
8681
|
reportRotationOverflow(backupPath, warn);
|
|
8219
|
-
|
|
8682
|
+
renameSync2(path, backupPath);
|
|
8220
8683
|
const rotated = guardedAppendOpen(path);
|
|
8221
8684
|
if (rotated === undefined) {
|
|
8222
8685
|
warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
|
|
@@ -8226,10 +8689,10 @@ function appendLine(path, line, warn) {
|
|
|
8226
8689
|
fd = rotated;
|
|
8227
8690
|
closed = false;
|
|
8228
8691
|
}
|
|
8229
|
-
|
|
8692
|
+
writeSync2(fd, line);
|
|
8230
8693
|
} finally {
|
|
8231
8694
|
if (!closed)
|
|
8232
|
-
|
|
8695
|
+
closeSync3(fd);
|
|
8233
8696
|
}
|
|
8234
8697
|
} catch (err) {
|
|
8235
8698
|
warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
|
|
@@ -8238,8 +8701,8 @@ function appendLine(path, line, warn) {
|
|
|
8238
8701
|
}
|
|
8239
8702
|
function createLogSink(overrides = {}) {
|
|
8240
8703
|
const deps = { ...defaultDeps(), ...overrides };
|
|
8241
|
-
const runId = deps.env().VINAYA_RUN_ID ||
|
|
8242
|
-
const processId =
|
|
8704
|
+
const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
|
|
8705
|
+
const processId = randomUUID2();
|
|
8243
8706
|
let seq = 0;
|
|
8244
8707
|
let warned = false;
|
|
8245
8708
|
const warnOnce = (message) => {
|
|
@@ -8252,8 +8715,9 @@ function createLogSink(overrides = {}) {
|
|
|
8252
8715
|
};
|
|
8253
8716
|
let doctrineCache;
|
|
8254
8717
|
const doctrine = () => {
|
|
8255
|
-
if (doctrineCache === undefined)
|
|
8256
|
-
doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
|
|
8718
|
+
if (doctrineCache === undefined) {
|
|
8719
|
+
doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
|
|
8720
|
+
}
|
|
8257
8721
|
return doctrineCache;
|
|
8258
8722
|
};
|
|
8259
8723
|
let resolveRepoCache;
|
|
@@ -8262,6 +8726,30 @@ function createLogSink(overrides = {}) {
|
|
|
8262
8726
|
resolveRepoCache = deps.resolveRepo();
|
|
8263
8727
|
return resolveRepoCache;
|
|
8264
8728
|
};
|
|
8729
|
+
let contextCache;
|
|
8730
|
+
const context = () => {
|
|
8731
|
+
if (contextCache === undefined) {
|
|
8732
|
+
const env = deps.env();
|
|
8733
|
+
contextCache = Promise.all([
|
|
8734
|
+
withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
|
|
8735
|
+
doctrine()
|
|
8736
|
+
]).then(async ([resolved, doctrineValue]) => {
|
|
8737
|
+
const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
|
|
8738
|
+
return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
|
|
8739
|
+
});
|
|
8740
|
+
}
|
|
8741
|
+
return contextCache;
|
|
8742
|
+
};
|
|
8743
|
+
let drainChain = Promise.resolve();
|
|
8744
|
+
const pendingWrites = new Set;
|
|
8745
|
+
const scheduleWebhookDrain = (issue, url, headers) => {
|
|
8746
|
+
drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
|
|
8747
|
+
return;
|
|
8748
|
+
}).catch((err) => {
|
|
8749
|
+
warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
|
|
8750
|
+
`);
|
|
8751
|
+
});
|
|
8752
|
+
};
|
|
8265
8753
|
function log(e) {
|
|
8266
8754
|
try {
|
|
8267
8755
|
const env = deps.env();
|
|
@@ -8276,22 +8764,26 @@ function createLogSink(overrides = {}) {
|
|
|
8276
8764
|
attempt: env.VINAYA_ATTEMPT,
|
|
8277
8765
|
parent: env.VINAYA_PARENT_EVENT
|
|
8278
8766
|
};
|
|
8279
|
-
|
|
8280
|
-
const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
|
|
8767
|
+
const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
|
|
8281
8768
|
const header = buildHeader({
|
|
8282
8769
|
now,
|
|
8283
8770
|
runId,
|
|
8284
8771
|
seq: mySeq,
|
|
8285
8772
|
repo: repo ? `${repo.owner}/${repo.repo}` : null,
|
|
8286
8773
|
vinaya: deps.vinayaVersion(),
|
|
8287
|
-
doctrine:
|
|
8774
|
+
doctrine: doctrineValue,
|
|
8288
8775
|
host,
|
|
8289
8776
|
hostname: deps.hostname(),
|
|
8290
8777
|
env: envFields,
|
|
8291
|
-
eventId:
|
|
8778
|
+
eventId: randomUUID2(),
|
|
8292
8779
|
processId,
|
|
8293
8780
|
inputVersions: deps.inputVersions()
|
|
8294
8781
|
});
|
|
8782
|
+
if (resolvedDestination.kind === "none") {
|
|
8783
|
+
warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
|
|
8784
|
+
`);
|
|
8785
|
+
return;
|
|
8786
|
+
}
|
|
8295
8787
|
const full = { ...e, ...header };
|
|
8296
8788
|
const parsed = LogEventSchema.safeParse(full);
|
|
8297
8789
|
if (!parsed.success) {
|
|
@@ -8301,25 +8793,42 @@ function createLogSink(overrides = {}) {
|
|
|
8301
8793
|
}
|
|
8302
8794
|
const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
|
|
8303
8795
|
`;
|
|
8304
|
-
|
|
8796
|
+
const destination = resolvedDestination;
|
|
8797
|
+
if (destination.kind === "server") {
|
|
8798
|
+
appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
|
|
8799
|
+
scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
|
|
8800
|
+
} else {
|
|
8801
|
+
appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
|
|
8802
|
+
}
|
|
8305
8803
|
}).catch((err) => {
|
|
8306
8804
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8307
8805
|
`);
|
|
8308
8806
|
});
|
|
8807
|
+
pendingWrites.add(written);
|
|
8808
|
+
written.finally(() => pendingWrites.delete(written));
|
|
8309
8809
|
} catch (err) {
|
|
8310
8810
|
warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
|
|
8311
8811
|
`);
|
|
8312
8812
|
}
|
|
8313
8813
|
}
|
|
8314
8814
|
const warmup = () => {
|
|
8315
|
-
doctrine();
|
|
8316
8815
|
const originalWarn = console.warn;
|
|
8317
8816
|
console.warn = () => {};
|
|
8318
8817
|
resolveRepoOnce().finally(() => {
|
|
8319
8818
|
console.warn = originalWarn;
|
|
8320
8819
|
});
|
|
8820
|
+
context().catch(() => {
|
|
8821
|
+
return;
|
|
8822
|
+
});
|
|
8823
|
+
};
|
|
8824
|
+
const drain = async () => {
|
|
8825
|
+
if (pendingWrites.size > 0)
|
|
8826
|
+
await Promise.allSettled(Array.from(pendingWrites));
|
|
8827
|
+
await drainChain.catch(() => {
|
|
8828
|
+
return;
|
|
8829
|
+
});
|
|
8321
8830
|
};
|
|
8322
|
-
return { log, runId, warmup };
|
|
8831
|
+
return { log, runId, warmup, drain };
|
|
8323
8832
|
}
|
|
8324
8833
|
var defaultSink = createLogSink();
|
|
8325
8834
|
|
|
@@ -8363,7 +8872,7 @@ function parseChangedLineRanges(diffOutput) {
|
|
|
8363
8872
|
function fileDiffAgainst(ref, path) {
|
|
8364
8873
|
let out;
|
|
8365
8874
|
try {
|
|
8366
|
-
out =
|
|
8875
|
+
out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
|
|
8367
8876
|
encoding: "utf8",
|
|
8368
8877
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8369
8878
|
}).trim();
|
|
@@ -8374,7 +8883,7 @@ function fileDiffAgainst(ref, path) {
|
|
|
8374
8883
|
}
|
|
8375
8884
|
function revParse(ref) {
|
|
8376
8885
|
try {
|
|
8377
|
-
return
|
|
8886
|
+
return execFileSync6("git", ["rev-parse", "--verify", ref], {
|
|
8378
8887
|
encoding: "utf8",
|
|
8379
8888
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8380
8889
|
}).trim();
|
|
@@ -8384,7 +8893,7 @@ function revParse(ref) {
|
|
|
8384
8893
|
}
|
|
8385
8894
|
function repoRoot() {
|
|
8386
8895
|
try {
|
|
8387
|
-
return
|
|
8896
|
+
return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
|
|
8388
8897
|
encoding: "utf8",
|
|
8389
8898
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8390
8899
|
}).trim();
|
|
@@ -8395,7 +8904,7 @@ function repoRoot() {
|
|
|
8395
8904
|
function changedFiles(base) {
|
|
8396
8905
|
let out;
|
|
8397
8906
|
try {
|
|
8398
|
-
out =
|
|
8907
|
+
out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
|
|
8399
8908
|
encoding: "utf8",
|
|
8400
8909
|
stdio: ["ignore", "pipe", "pipe"]
|
|
8401
8910
|
}).trim();
|
|
@@ -8420,7 +8929,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
|
|
|
8420
8929
|
const relPaths = changedFiles(ref);
|
|
8421
8930
|
if (relPaths === null)
|
|
8422
8931
|
continue;
|
|
8423
|
-
return { base: ref, root, files: relPaths.map((p) =>
|
|
8932
|
+
return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
|
|
8424
8933
|
}
|
|
8425
8934
|
return null;
|
|
8426
8935
|
}
|
|
@@ -8461,15 +8970,15 @@ var READER_FACING_ACTIVE = READER_FACING_PREFIX !== null && READER_FACING_SUFFIX
|
|
|
8461
8970
|
function collect(dir, out = []) {
|
|
8462
8971
|
let entries;
|
|
8463
8972
|
try {
|
|
8464
|
-
entries =
|
|
8973
|
+
entries = readdirSync3(dir);
|
|
8465
8974
|
} catch {
|
|
8466
8975
|
return out;
|
|
8467
8976
|
}
|
|
8468
8977
|
for (const name of entries) {
|
|
8469
|
-
const full =
|
|
8978
|
+
const full = join10(dir, name);
|
|
8470
8979
|
let isDir;
|
|
8471
8980
|
try {
|
|
8472
|
-
isDir =
|
|
8981
|
+
isDir = statSync2(full).isDirectory();
|
|
8473
8982
|
} catch {
|
|
8474
8983
|
continue;
|
|
8475
8984
|
}
|
|
@@ -8484,7 +8993,7 @@ function collect(dir, out = []) {
|
|
|
8484
8993
|
return out;
|
|
8485
8994
|
}
|
|
8486
8995
|
function readAll(paths) {
|
|
8487
|
-
return paths.map((p) => ({ path: p, content:
|
|
8996
|
+
return paths.map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
|
|
8488
8997
|
}
|
|
8489
8998
|
function toPosix(p) {
|
|
8490
8999
|
return p.split("\\").join("/");
|
|
@@ -8509,9 +9018,9 @@ function main() {
|
|
|
8509
9018
|
continue;
|
|
8510
9019
|
if (!isValidCitedFilePath(quote.citedFile))
|
|
8511
9020
|
continue;
|
|
8512
|
-
const abs =
|
|
8513
|
-
if (
|
|
8514
|
-
citedFileContents.set(quote.citedFile,
|
|
9021
|
+
const abs = join10(root, quote.citedFile);
|
|
9022
|
+
if (existsSync8(abs) && statSync2(abs).isFile()) {
|
|
9023
|
+
citedFileContents.set(quote.citedFile, readFileSync7(abs, "utf8"));
|
|
8515
9024
|
}
|
|
8516
9025
|
}
|
|
8517
9026
|
const findings = evaluateCitedQuotes(citedQuotes, citedFileContents);
|