@attalabs/vinaya 0.8.0 → 0.8.2
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/aeg-root/enforcement.md +2 -2
- package/aeg-root/roles/planner.md +2 -2
- package/aeg-root/roles/reviewer.md +1 -1
- package/aeg-root/skills/brief-authoring/SKILL.md +1 -1
- package/aeg-root/state-machine.md +6 -6
- package/aeg-root/tranche-model.md +1 -1
- package/dist/checks/bin/check-branch-topology.js +21 -5
- package/dist/checks/bin/check-brief-shape.js +21 -5
- package/dist/checks/bin/check-closes-n.js +21 -5
- package/dist/checks/bin/check-coherence.js +200 -10
- package/dist/checks/bin/check-dead-branch-push.js +21 -5
- package/dist/checks/bin/check-dispatch-readiness.js +223 -11
- package/dist/checks/bin/check-doc-coverage-push.js +21 -5
- package/dist/checks/bin/check-doc-coverage.js +55 -10
- package/dist/checks/bin/check-first-push-dispatch.js +224 -12
- package/dist/checks/bin/check-issue-assignment.js +21 -5
- package/dist/checks/bin/check-no-disk-state.js +21 -5
- package/dist/checks/bin/check-reader-resolvable-prose.js +21 -5
- package/dist/checks/bin/check-registry-gates.js +21 -5
- package/dist/checks/bin/check-review-gate.js +21 -5
- package/dist/checks/bin/check-single-plan-pr.js +21 -5
- package/dist/checks/bin/check-test-plan.js +21 -5
- package/dist/index.js +6 -2
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-first-push-dispatch.ts
|
|
4
|
-
import { execFileSync as
|
|
4
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
5
5
|
// ../../packages/aeg-core/src/anchored-region.ts
|
|
6
6
|
function maskCode(body) {
|
|
7
7
|
const fill = (line) => " ".repeat(line.length);
|
|
@@ -1218,7 +1218,8 @@ function mapForgeFacts(raw) {
|
|
|
1218
1218
|
reviewDecision: mapReviewDecision(raw.pullRequest?.reviewDecision),
|
|
1219
1219
|
stateReason: mapStateReason(raw.issue.stateReason),
|
|
1220
1220
|
closedAt: raw.issue.closedAt ?? null,
|
|
1221
|
-
mergedAt: raw.pullRequest?.mergedAt ?? null
|
|
1221
|
+
mergedAt: raw.pullRequest?.mergedAt ?? null,
|
|
1222
|
+
closedByActor: raw.closedByActor ?? null
|
|
1222
1223
|
};
|
|
1223
1224
|
}
|
|
1224
1225
|
function mapStateReason(reason) {
|
|
@@ -1311,6 +1312,7 @@ function buildBatchQuery(tranche, tasks) {
|
|
|
1311
1312
|
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1312
1313
|
nodes {
|
|
1313
1314
|
... on ClosedEvent {
|
|
1315
|
+
actor { login }
|
|
1314
1316
|
closer {
|
|
1315
1317
|
... on PullRequest {
|
|
1316
1318
|
number
|
|
@@ -1348,7 +1350,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1348
1350
|
const issue = repository[`${alias}_issue`];
|
|
1349
1351
|
const ref = repository[`${alias}_ref`];
|
|
1350
1352
|
const prs = repository[`${alias}_prs`];
|
|
1351
|
-
const
|
|
1353
|
+
const timelineNode = issue?.timelineItems?.nodes?.[0];
|
|
1354
|
+
const rawCloser = timelineNode?.closer ?? null;
|
|
1352
1355
|
const closingPr = rawCloser && typeof rawCloser.number === "number" && typeof rawCloser.url === "string" ? rawCloser : null;
|
|
1353
1356
|
const branchPr = prs && prs.nodes.length > 0 && prs.nodes[0] ? prs.nodes[0] : null;
|
|
1354
1357
|
return {
|
|
@@ -1360,7 +1363,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1360
1363
|
labels: issue.labels.nodes.map((n) => n.name)
|
|
1361
1364
|
} : null,
|
|
1362
1365
|
refExists: Boolean(ref && ref.name.length > 0),
|
|
1363
|
-
pullRequest: closingPr ?? branchPr
|
|
1366
|
+
pullRequest: closingPr ?? branchPr,
|
|
1367
|
+
closedByActor: timelineNode?.actor?.login ?? null
|
|
1364
1368
|
};
|
|
1365
1369
|
}
|
|
1366
1370
|
function describeError(err) {
|
|
@@ -1498,6 +1502,11 @@ var FORGE_FACT_INPUTS = [
|
|
|
1498
1502
|
fact: "mergedAt",
|
|
1499
1503
|
readsFrom: "PullRequest.mergedAt",
|
|
1500
1504
|
meaning: "Timestamp for the coherence oracle grandfather cutoff. No derivation rule reads it."
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
fact: "closedByActor",
|
|
1508
|
+
readsFrom: "ClosedEvent.actor.login (most recent timeline CLOSED_EVENT)",
|
|
1509
|
+
meaning: "GitHub login that hand-closed the Issue. No task-status derivation rule reads it — it is consumed by dispatch-gate.ts/coherence-checks.ts A1 to recognize a hand-closed dependency as resolved (task vinaya-engine-v1 21, #99), not by this status model."
|
|
1501
1510
|
}
|
|
1502
1511
|
];
|
|
1503
1512
|
var DERIVED_STATUSES = [
|
|
@@ -1977,7 +1986,7 @@ function isGrandfathered(isoDate) {
|
|
|
1977
1986
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
1978
1987
|
}
|
|
1979
1988
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
1980
|
-
function checkA1(entries) {
|
|
1989
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
1981
1990
|
const failures = [];
|
|
1982
1991
|
for (const e of entries) {
|
|
1983
1992
|
if (!e.facts)
|
|
@@ -1985,6 +1994,9 @@ function checkA1(entries) {
|
|
|
1985
1994
|
if (e.facts.stateReason === "not_planned")
|
|
1986
1995
|
continue;
|
|
1987
1996
|
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
1997
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
1998
|
+
if (handClosed)
|
|
1999
|
+
continue;
|
|
1988
2000
|
failures.push({
|
|
1989
2001
|
issue: e.task.issue,
|
|
1990
2002
|
tranche: e.trancheSlug,
|
|
@@ -2674,9 +2686,13 @@ function parseGlossaryTerms(glossaryContent) {
|
|
|
2674
2686
|
return terms;
|
|
2675
2687
|
}
|
|
2676
2688
|
// ../../packages/aeg-core/src/dispatch-gate.ts
|
|
2689
|
+
function isHandClosedByRecognizedPrincipal(dep, principalAllowlist) {
|
|
2690
|
+
return dep.issueState === "closed" && dep.stateReason === "completed" && isPrincipal(dep.closedByActor ?? null, principalAllowlist);
|
|
2691
|
+
}
|
|
2677
2692
|
function checkDispatchReadiness(input) {
|
|
2678
2693
|
const { trancheSlug, task } = input;
|
|
2679
2694
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
2695
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
2680
2696
|
const blockers = [];
|
|
2681
2697
|
if (task.issue === null) {
|
|
2682
2698
|
blockers.push(`dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`);
|
|
@@ -2687,7 +2703,7 @@ function checkDispatchReadiness(input) {
|
|
|
2687
2703
|
blockers.push(`dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`);
|
|
2688
2704
|
}
|
|
2689
2705
|
for (const dep of input.dependsOn) {
|
|
2690
|
-
if (!dep.merged) {
|
|
2706
|
+
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
2691
2707
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
2692
2708
|
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
2693
2709
|
}
|
|
@@ -2943,11 +2959,185 @@ function emitCheckError(error) {
|
|
|
2943
2959
|
`);
|
|
2944
2960
|
}
|
|
2945
2961
|
|
|
2962
|
+
// src/lib/config.ts
|
|
2963
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
2964
|
+
import { homedir } from "node:os";
|
|
2965
|
+
import { dirname, join } from "node:path";
|
|
2966
|
+
import { z as z2 } from "zod";
|
|
2967
|
+
var EnvEntrySchema = z2.union([
|
|
2968
|
+
z2.literal(true),
|
|
2969
|
+
z2.object({ optional: z2.literal(true) }),
|
|
2970
|
+
z2.object({ anyOf: z2.array(z2.string()).min(2) }),
|
|
2971
|
+
z2.string()
|
|
2972
|
+
]);
|
|
2973
|
+
var CheckEntrySchema = z2.object({
|
|
2974
|
+
run: z2.string(),
|
|
2975
|
+
scope: z2.enum(["diff", "full"]),
|
|
2976
|
+
include: z2.array(z2.string()).optional(),
|
|
2977
|
+
args: z2.array(z2.string()).optional(),
|
|
2978
|
+
timeoutMs: z2.number().optional(),
|
|
2979
|
+
env: z2.record(z2.string(), EnvEntrySchema).optional(),
|
|
2980
|
+
requiresOpenPr: z2.boolean().optional(),
|
|
2981
|
+
ownWorkflow: z2.boolean().optional()
|
|
2982
|
+
}).superRefine((entry2, ctx) => {
|
|
2983
|
+
if (!entry2.env)
|
|
2984
|
+
return;
|
|
2985
|
+
for (const [key, value] of Object.entries(entry2.env)) {
|
|
2986
|
+
if (typeof value !== "object" || value === null || !("anyOf" in value))
|
|
2987
|
+
continue;
|
|
2988
|
+
const members = value.anyOf;
|
|
2989
|
+
if (new Set(members).size !== members.length) {
|
|
2990
|
+
ctx.addIssue({
|
|
2991
|
+
code: z2.ZodIssueCode.custom,
|
|
2992
|
+
message: `env.${key}.anyOf has duplicate members`,
|
|
2993
|
+
path: ["env", key, "anyOf"]
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2996
|
+
if (!members.includes(key)) {
|
|
2997
|
+
ctx.addIssue({
|
|
2998
|
+
code: z2.ZodIssueCode.custom,
|
|
2999
|
+
message: `env.${key}.anyOf must include "${key}" itself as a member`,
|
|
3000
|
+
path: ["env", key, "anyOf"]
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
3005
|
+
var BRIEF_BUILTINS = [
|
|
3006
|
+
"tier",
|
|
3007
|
+
"testPlan",
|
|
3008
|
+
"testPlanExclusivity",
|
|
3009
|
+
"principalPlaceholder",
|
|
3010
|
+
"surfaceMap",
|
|
3011
|
+
"docUpdateList",
|
|
3012
|
+
"worktreeStep0",
|
|
3013
|
+
"stopConditions",
|
|
3014
|
+
"autonomyClause",
|
|
3015
|
+
"project",
|
|
3016
|
+
"for",
|
|
3017
|
+
"closesN",
|
|
3018
|
+
"premiseCoverage",
|
|
3019
|
+
"issueRationale"
|
|
3020
|
+
];
|
|
3021
|
+
var BriefSectionSchema = z2.union([
|
|
3022
|
+
z2.object({ builtin: z2.enum(BRIEF_BUILTINS) }),
|
|
3023
|
+
z2.object({ heading: z2.string().min(1), name: z2.string().optional() }),
|
|
3024
|
+
z2.object({ field: z2.string().min(1), name: z2.string().optional() }),
|
|
3025
|
+
z2.object({ phrase: z2.string().min(1), name: z2.string().optional() })
|
|
3026
|
+
]);
|
|
3027
|
+
var BriefSchemaSchema = z2.object({
|
|
3028
|
+
pr: z2.object({ sections: z2.array(BriefSectionSchema) }).optional(),
|
|
3029
|
+
issue: z2.object({ sections: z2.array(BriefSectionSchema) }).optional()
|
|
3030
|
+
});
|
|
3031
|
+
function isSafeRepoRelPath(p) {
|
|
3032
|
+
if (p.length === 0)
|
|
3033
|
+
return false;
|
|
3034
|
+
if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
|
|
3035
|
+
return false;
|
|
3036
|
+
return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
|
|
3037
|
+
}
|
|
3038
|
+
var SafeRepoRelPath = z2.string().refine(isSafeRepoRelPath, {
|
|
3039
|
+
message: "must be a repo-root-relative path with no `..` segment or absolute root"
|
|
3040
|
+
});
|
|
3041
|
+
var ManagedBlockRecordSchema = z2.object({
|
|
3042
|
+
path: SafeRepoRelPath,
|
|
3043
|
+
marker: z2.string(),
|
|
3044
|
+
comment: z2.enum(["hash", "html"])
|
|
3045
|
+
});
|
|
3046
|
+
var ManagedManifestSchema = z2.object({
|
|
3047
|
+
version: z2.number().int().positive(),
|
|
3048
|
+
files: z2.array(SafeRepoRelPath),
|
|
3049
|
+
blocks: z2.array(ManagedBlockRecordSchema),
|
|
3050
|
+
labels: z2.array(z2.string())
|
|
3051
|
+
});
|
|
3052
|
+
var VinayaConfigSchema = z2.object({
|
|
3053
|
+
rings: z2.object({
|
|
3054
|
+
ring1_forgeWriteInterception: z2.boolean(),
|
|
3055
|
+
ring2_asyncAudits: z2.boolean()
|
|
3056
|
+
}).optional(),
|
|
3057
|
+
checks: z2.record(z2.string(), CheckEntrySchema).optional(),
|
|
3058
|
+
briefSchema: BriefSchemaSchema.optional(),
|
|
3059
|
+
managed: ManagedManifestSchema.optional(),
|
|
3060
|
+
principals: z2.array(z2.string()).min(1).optional(),
|
|
3061
|
+
ci: z2.object({ setup: z2.string().min(1) }).optional()
|
|
3062
|
+
});
|
|
3063
|
+
var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
|
|
3064
|
+
var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
|
|
3065
|
+
var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
|
|
3066
|
+
function resolvePrincipalAllowlist(config) {
|
|
3067
|
+
return config?.principals ?? PRINCIPAL_ALLOWLIST;
|
|
3068
|
+
}
|
|
3069
|
+
function trustAnchorRepo() {
|
|
3070
|
+
const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
|
|
3071
|
+
const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
|
|
3072
|
+
if (fromRunner) {
|
|
3073
|
+
const validated = wellFormed(fromRunner);
|
|
3074
|
+
if (validated)
|
|
3075
|
+
return validated;
|
|
3076
|
+
}
|
|
3077
|
+
try {
|
|
3078
|
+
const url = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
3079
|
+
encoding: "utf-8",
|
|
3080
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
3081
|
+
}).trim();
|
|
3082
|
+
const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
|
|
3083
|
+
return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
|
|
3084
|
+
} catch {
|
|
3085
|
+
return null;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
function ghFetchTrustAnchorConfig() {
|
|
3089
|
+
const repo = trustAnchorRepo();
|
|
3090
|
+
if (!repo)
|
|
3091
|
+
throw new Error("could not resolve repo identity for the trust-anchor read");
|
|
3092
|
+
return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
|
|
3093
|
+
encoding: "utf-8",
|
|
3094
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
function firstLine(err) {
|
|
3098
|
+
return err?.message?.split(`
|
|
3099
|
+
`)[0] ?? "unknown error";
|
|
3100
|
+
}
|
|
3101
|
+
function isMissingFileError(err) {
|
|
3102
|
+
const stderr = err?.stderr;
|
|
3103
|
+
const haystack = [
|
|
3104
|
+
err?.message ?? "",
|
|
3105
|
+
typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
|
|
3106
|
+
].join(`
|
|
3107
|
+
`);
|
|
3108
|
+
return /\b404\b|not found/i.test(haystack);
|
|
3109
|
+
}
|
|
3110
|
+
function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
|
|
3111
|
+
const warn = (why) => process.stdout.write(`⚠ could not read \`principals\` from the default branch (${why}) — falling back to vinaya's built-in principal allowlist.
|
|
3112
|
+
`);
|
|
3113
|
+
let base64;
|
|
3114
|
+
try {
|
|
3115
|
+
base64 = fetcher().trim();
|
|
3116
|
+
} catch (err) {
|
|
3117
|
+
if (!isMissingFileError(err))
|
|
3118
|
+
warn(firstLine(err));
|
|
3119
|
+
return null;
|
|
3120
|
+
}
|
|
3121
|
+
if (!base64)
|
|
3122
|
+
return null;
|
|
3123
|
+
try {
|
|
3124
|
+
const raw = Buffer.from(base64, "base64").toString("utf-8");
|
|
3125
|
+
const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
|
|
3126
|
+
if (parsed.success)
|
|
3127
|
+
return parsed.data;
|
|
3128
|
+
warn("it did not satisfy the config schema");
|
|
3129
|
+
return null;
|
|
3130
|
+
} catch {
|
|
3131
|
+
warn("it was not readable as JSON");
|
|
3132
|
+
return null;
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
|
|
2946
3136
|
// src/checks/bin/check-first-push-dispatch.ts
|
|
2947
3137
|
var CHECK_NAME = "first-push-dispatch";
|
|
2948
3138
|
function git(args) {
|
|
2949
3139
|
try {
|
|
2950
|
-
return
|
|
3140
|
+
return execFileSync3("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
2951
3141
|
} catch {
|
|
2952
3142
|
return "";
|
|
2953
3143
|
}
|
|
@@ -2970,7 +3160,7 @@ function resolveRepo2() {
|
|
|
2970
3160
|
}
|
|
2971
3161
|
function prExistsFor(branch) {
|
|
2972
3162
|
try {
|
|
2973
|
-
const out =
|
|
3163
|
+
const out = execFileSync3("gh", ["pr", "list", "--head", branch, "--state", "all", "--json", "number", "--limit", "1"], {
|
|
2974
3164
|
encoding: "utf8",
|
|
2975
3165
|
stdio: ["ignore", "pipe", "ignore"]
|
|
2976
3166
|
});
|
|
@@ -2984,10 +3174,24 @@ function resolveEdge(id, taskById, factsByTaskId) {
|
|
|
2984
3174
|
const target = taskById.get(id);
|
|
2985
3175
|
if (target) {
|
|
2986
3176
|
const facts = target.issue !== null ? factsByTaskId.get(target.id) : undefined;
|
|
2987
|
-
return {
|
|
3177
|
+
return {
|
|
3178
|
+
issue: target.issue,
|
|
3179
|
+
merged: facts?.prState === "merged",
|
|
3180
|
+
open: facts?.prState === "open",
|
|
3181
|
+
issueState: facts?.issueState ?? null,
|
|
3182
|
+
stateReason: facts?.stateReason ?? null,
|
|
3183
|
+
closedByActor: facts?.closedByActor ?? null
|
|
3184
|
+
};
|
|
2988
3185
|
}
|
|
2989
3186
|
const direct = id.match(/^#(\d+)$/);
|
|
2990
|
-
return {
|
|
3187
|
+
return {
|
|
3188
|
+
issue: direct ? Number(direct[1]) : null,
|
|
3189
|
+
merged: false,
|
|
3190
|
+
open: false,
|
|
3191
|
+
issueState: null,
|
|
3192
|
+
stateReason: null,
|
|
3193
|
+
closedByActor: null
|
|
3194
|
+
};
|
|
2991
3195
|
}
|
|
2992
3196
|
async function classifyReadiness(trancheSlug, taskId) {
|
|
2993
3197
|
const repo = resolveRepo2();
|
|
@@ -3017,7 +3221,14 @@ async function classifyReadiness(trancheSlug, taskId) {
|
|
|
3017
3221
|
const factsByTaskId = snapshot.facts;
|
|
3018
3222
|
const dependsOn = task.dependsOn.map((dep) => {
|
|
3019
3223
|
const r = resolveEdge(dep, taskById, factsByTaskId);
|
|
3020
|
-
return {
|
|
3224
|
+
return {
|
|
3225
|
+
id: dep,
|
|
3226
|
+
issue: r.issue,
|
|
3227
|
+
merged: r.merged,
|
|
3228
|
+
issueState: r.issueState,
|
|
3229
|
+
stateReason: r.stateReason,
|
|
3230
|
+
closedByActor: r.closedByActor
|
|
3231
|
+
};
|
|
3021
3232
|
});
|
|
3022
3233
|
const conflictsWith = task.conflictsWith.map((c) => {
|
|
3023
3234
|
const r = resolveEdge(c, taskById, factsByTaskId);
|
|
@@ -3031,7 +3242,8 @@ async function classifyReadiness(trancheSlug, taskId) {
|
|
|
3031
3242
|
dependsOn,
|
|
3032
3243
|
conflictsWith,
|
|
3033
3244
|
priorTask: null,
|
|
3034
|
-
priorTrancheArchival: []
|
|
3245
|
+
priorTrancheArchival: [],
|
|
3246
|
+
principalAllowlist: resolvePrincipalAllowlist(loadTrustAnchorConfig())
|
|
3035
3247
|
};
|
|
3036
3248
|
return checkDispatchReadiness(input).ready ? "READY" : "NOT_READY";
|
|
3037
3249
|
} catch {
|
|
@@ -1218,7 +1218,8 @@ function mapForgeFacts(raw) {
|
|
|
1218
1218
|
reviewDecision: mapReviewDecision(raw.pullRequest?.reviewDecision),
|
|
1219
1219
|
stateReason: mapStateReason(raw.issue.stateReason),
|
|
1220
1220
|
closedAt: raw.issue.closedAt ?? null,
|
|
1221
|
-
mergedAt: raw.pullRequest?.mergedAt ?? null
|
|
1221
|
+
mergedAt: raw.pullRequest?.mergedAt ?? null,
|
|
1222
|
+
closedByActor: raw.closedByActor ?? null
|
|
1222
1223
|
};
|
|
1223
1224
|
}
|
|
1224
1225
|
function mapStateReason(reason) {
|
|
@@ -1311,6 +1312,7 @@ function buildBatchQuery(tranche, tasks) {
|
|
|
1311
1312
|
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1312
1313
|
nodes {
|
|
1313
1314
|
... on ClosedEvent {
|
|
1315
|
+
actor { login }
|
|
1314
1316
|
closer {
|
|
1315
1317
|
... on PullRequest {
|
|
1316
1318
|
number
|
|
@@ -1348,7 +1350,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1348
1350
|
const issue = repository[`${alias}_issue`];
|
|
1349
1351
|
const ref = repository[`${alias}_ref`];
|
|
1350
1352
|
const prs = repository[`${alias}_prs`];
|
|
1351
|
-
const
|
|
1353
|
+
const timelineNode = issue?.timelineItems?.nodes?.[0];
|
|
1354
|
+
const rawCloser = timelineNode?.closer ?? null;
|
|
1352
1355
|
const closingPr = rawCloser && typeof rawCloser.number === "number" && typeof rawCloser.url === "string" ? rawCloser : null;
|
|
1353
1356
|
const branchPr = prs && prs.nodes.length > 0 && prs.nodes[0] ? prs.nodes[0] : null;
|
|
1354
1357
|
return {
|
|
@@ -1360,7 +1363,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1360
1363
|
labels: issue.labels.nodes.map((n) => n.name)
|
|
1361
1364
|
} : null,
|
|
1362
1365
|
refExists: Boolean(ref && ref.name.length > 0),
|
|
1363
|
-
pullRequest: closingPr ?? branchPr
|
|
1366
|
+
pullRequest: closingPr ?? branchPr,
|
|
1367
|
+
closedByActor: timelineNode?.actor?.login ?? null
|
|
1364
1368
|
};
|
|
1365
1369
|
}
|
|
1366
1370
|
function describeError(err) {
|
|
@@ -1498,6 +1502,11 @@ var FORGE_FACT_INPUTS = [
|
|
|
1498
1502
|
fact: "mergedAt",
|
|
1499
1503
|
readsFrom: "PullRequest.mergedAt",
|
|
1500
1504
|
meaning: "Timestamp for the coherence oracle grandfather cutoff. No derivation rule reads it."
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
fact: "closedByActor",
|
|
1508
|
+
readsFrom: "ClosedEvent.actor.login (most recent timeline CLOSED_EVENT)",
|
|
1509
|
+
meaning: "GitHub login that hand-closed the Issue. No task-status derivation rule reads it — it is consumed by dispatch-gate.ts/coherence-checks.ts A1 to recognize a hand-closed dependency as resolved (task vinaya-engine-v1 21, #99), not by this status model."
|
|
1501
1510
|
}
|
|
1502
1511
|
];
|
|
1503
1512
|
var DERIVED_STATUSES = [
|
|
@@ -1977,7 +1986,7 @@ function isGrandfathered(isoDate) {
|
|
|
1977
1986
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
1978
1987
|
}
|
|
1979
1988
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
1980
|
-
function checkA1(entries) {
|
|
1989
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
1981
1990
|
const failures = [];
|
|
1982
1991
|
for (const e of entries) {
|
|
1983
1992
|
if (!e.facts)
|
|
@@ -1985,6 +1994,9 @@ function checkA1(entries) {
|
|
|
1985
1994
|
if (e.facts.stateReason === "not_planned")
|
|
1986
1995
|
continue;
|
|
1987
1996
|
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
1997
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
1998
|
+
if (handClosed)
|
|
1999
|
+
continue;
|
|
1988
2000
|
failures.push({
|
|
1989
2001
|
issue: e.task.issue,
|
|
1990
2002
|
tranche: e.trancheSlug,
|
|
@@ -2674,9 +2686,13 @@ function parseGlossaryTerms(glossaryContent) {
|
|
|
2674
2686
|
return terms;
|
|
2675
2687
|
}
|
|
2676
2688
|
// ../../packages/aeg-core/src/dispatch-gate.ts
|
|
2689
|
+
function isHandClosedByRecognizedPrincipal(dep, principalAllowlist) {
|
|
2690
|
+
return dep.issueState === "closed" && dep.stateReason === "completed" && isPrincipal(dep.closedByActor ?? null, principalAllowlist);
|
|
2691
|
+
}
|
|
2677
2692
|
function checkDispatchReadiness(input) {
|
|
2678
2693
|
const { trancheSlug, task } = input;
|
|
2679
2694
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
2695
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
2680
2696
|
const blockers = [];
|
|
2681
2697
|
if (task.issue === null) {
|
|
2682
2698
|
blockers.push(`dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`);
|
|
@@ -2687,7 +2703,7 @@ function checkDispatchReadiness(input) {
|
|
|
2687
2703
|
blockers.push(`dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`);
|
|
2688
2704
|
}
|
|
2689
2705
|
for (const dep of input.dependsOn) {
|
|
2690
|
-
if (!dep.merged) {
|
|
2706
|
+
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
2691
2707
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
2692
2708
|
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
2693
2709
|
}
|
|
@@ -1218,7 +1218,8 @@ function mapForgeFacts(raw) {
|
|
|
1218
1218
|
reviewDecision: mapReviewDecision(raw.pullRequest?.reviewDecision),
|
|
1219
1219
|
stateReason: mapStateReason(raw.issue.stateReason),
|
|
1220
1220
|
closedAt: raw.issue.closedAt ?? null,
|
|
1221
|
-
mergedAt: raw.pullRequest?.mergedAt ?? null
|
|
1221
|
+
mergedAt: raw.pullRequest?.mergedAt ?? null,
|
|
1222
|
+
closedByActor: raw.closedByActor ?? null
|
|
1222
1223
|
};
|
|
1223
1224
|
}
|
|
1224
1225
|
function mapStateReason(reason) {
|
|
@@ -1311,6 +1312,7 @@ function buildBatchQuery(tranche, tasks) {
|
|
|
1311
1312
|
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1312
1313
|
nodes {
|
|
1313
1314
|
... on ClosedEvent {
|
|
1315
|
+
actor { login }
|
|
1314
1316
|
closer {
|
|
1315
1317
|
... on PullRequest {
|
|
1316
1318
|
number
|
|
@@ -1348,7 +1350,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1348
1350
|
const issue = repository[`${alias}_issue`];
|
|
1349
1351
|
const ref = repository[`${alias}_ref`];
|
|
1350
1352
|
const prs = repository[`${alias}_prs`];
|
|
1351
|
-
const
|
|
1353
|
+
const timelineNode = issue?.timelineItems?.nodes?.[0];
|
|
1354
|
+
const rawCloser = timelineNode?.closer ?? null;
|
|
1352
1355
|
const closingPr = rawCloser && typeof rawCloser.number === "number" && typeof rawCloser.url === "string" ? rawCloser : null;
|
|
1353
1356
|
const branchPr = prs && prs.nodes.length > 0 && prs.nodes[0] ? prs.nodes[0] : null;
|
|
1354
1357
|
return {
|
|
@@ -1360,7 +1363,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1360
1363
|
labels: issue.labels.nodes.map((n) => n.name)
|
|
1361
1364
|
} : null,
|
|
1362
1365
|
refExists: Boolean(ref && ref.name.length > 0),
|
|
1363
|
-
pullRequest: closingPr ?? branchPr
|
|
1366
|
+
pullRequest: closingPr ?? branchPr,
|
|
1367
|
+
closedByActor: timelineNode?.actor?.login ?? null
|
|
1364
1368
|
};
|
|
1365
1369
|
}
|
|
1366
1370
|
function describeError(err) {
|
|
@@ -1498,6 +1502,11 @@ var FORGE_FACT_INPUTS = [
|
|
|
1498
1502
|
fact: "mergedAt",
|
|
1499
1503
|
readsFrom: "PullRequest.mergedAt",
|
|
1500
1504
|
meaning: "Timestamp for the coherence oracle grandfather cutoff. No derivation rule reads it."
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
fact: "closedByActor",
|
|
1508
|
+
readsFrom: "ClosedEvent.actor.login (most recent timeline CLOSED_EVENT)",
|
|
1509
|
+
meaning: "GitHub login that hand-closed the Issue. No task-status derivation rule reads it — it is consumed by dispatch-gate.ts/coherence-checks.ts A1 to recognize a hand-closed dependency as resolved (task vinaya-engine-v1 21, #99), not by this status model."
|
|
1501
1510
|
}
|
|
1502
1511
|
];
|
|
1503
1512
|
var DERIVED_STATUSES = [
|
|
@@ -1977,7 +1986,7 @@ function isGrandfathered(isoDate) {
|
|
|
1977
1986
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
1978
1987
|
}
|
|
1979
1988
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
1980
|
-
function checkA1(entries) {
|
|
1989
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
1981
1990
|
const failures = [];
|
|
1982
1991
|
for (const e of entries) {
|
|
1983
1992
|
if (!e.facts)
|
|
@@ -1985,6 +1994,9 @@ function checkA1(entries) {
|
|
|
1985
1994
|
if (e.facts.stateReason === "not_planned")
|
|
1986
1995
|
continue;
|
|
1987
1996
|
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
1997
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
1998
|
+
if (handClosed)
|
|
1999
|
+
continue;
|
|
1988
2000
|
failures.push({
|
|
1989
2001
|
issue: e.task.issue,
|
|
1990
2002
|
tranche: e.trancheSlug,
|
|
@@ -2674,9 +2686,13 @@ function parseGlossaryTerms(glossaryContent) {
|
|
|
2674
2686
|
return terms;
|
|
2675
2687
|
}
|
|
2676
2688
|
// ../../packages/aeg-core/src/dispatch-gate.ts
|
|
2689
|
+
function isHandClosedByRecognizedPrincipal(dep, principalAllowlist) {
|
|
2690
|
+
return dep.issueState === "closed" && dep.stateReason === "completed" && isPrincipal(dep.closedByActor ?? null, principalAllowlist);
|
|
2691
|
+
}
|
|
2677
2692
|
function checkDispatchReadiness(input) {
|
|
2678
2693
|
const { trancheSlug, task } = input;
|
|
2679
2694
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
2695
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
2680
2696
|
const blockers = [];
|
|
2681
2697
|
if (task.issue === null) {
|
|
2682
2698
|
blockers.push(`dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`);
|
|
@@ -2687,7 +2703,7 @@ function checkDispatchReadiness(input) {
|
|
|
2687
2703
|
blockers.push(`dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`);
|
|
2688
2704
|
}
|
|
2689
2705
|
for (const dep of input.dependsOn) {
|
|
2690
|
-
if (!dep.merged) {
|
|
2706
|
+
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
2691
2707
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
2692
2708
|
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
2693
2709
|
}
|
|
@@ -1220,7 +1220,8 @@ function mapForgeFacts(raw) {
|
|
|
1220
1220
|
reviewDecision: mapReviewDecision(raw.pullRequest?.reviewDecision),
|
|
1221
1221
|
stateReason: mapStateReason(raw.issue.stateReason),
|
|
1222
1222
|
closedAt: raw.issue.closedAt ?? null,
|
|
1223
|
-
mergedAt: raw.pullRequest?.mergedAt ?? null
|
|
1223
|
+
mergedAt: raw.pullRequest?.mergedAt ?? null,
|
|
1224
|
+
closedByActor: raw.closedByActor ?? null
|
|
1224
1225
|
};
|
|
1225
1226
|
}
|
|
1226
1227
|
function mapStateReason(reason) {
|
|
@@ -1313,6 +1314,7 @@ function buildBatchQuery(tranche, tasks) {
|
|
|
1313
1314
|
timelineItems(last: 1, itemTypes: [CLOSED_EVENT]) {
|
|
1314
1315
|
nodes {
|
|
1315
1316
|
... on ClosedEvent {
|
|
1317
|
+
actor { login }
|
|
1316
1318
|
closer {
|
|
1317
1319
|
... on PullRequest {
|
|
1318
1320
|
number
|
|
@@ -1350,7 +1352,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1350
1352
|
const issue = repository[`${alias}_issue`];
|
|
1351
1353
|
const ref = repository[`${alias}_ref`];
|
|
1352
1354
|
const prs = repository[`${alias}_prs`];
|
|
1353
|
-
const
|
|
1355
|
+
const timelineNode = issue?.timelineItems?.nodes?.[0];
|
|
1356
|
+
const rawCloser = timelineNode?.closer ?? null;
|
|
1354
1357
|
const closingPr = rawCloser && typeof rawCloser.number === "number" && typeof rawCloser.url === "string" ? rawCloser : null;
|
|
1355
1358
|
const branchPr = prs && prs.nodes.length > 0 && prs.nodes[0] ? prs.nodes[0] : null;
|
|
1356
1359
|
return {
|
|
@@ -1362,7 +1365,8 @@ function extractRawFromResponse(repository, alias) {
|
|
|
1362
1365
|
labels: issue.labels.nodes.map((n) => n.name)
|
|
1363
1366
|
} : null,
|
|
1364
1367
|
refExists: Boolean(ref && ref.name.length > 0),
|
|
1365
|
-
pullRequest: closingPr ?? branchPr
|
|
1368
|
+
pullRequest: closingPr ?? branchPr,
|
|
1369
|
+
closedByActor: timelineNode?.actor?.login ?? null
|
|
1366
1370
|
};
|
|
1367
1371
|
}
|
|
1368
1372
|
function describeError(err) {
|
|
@@ -1500,6 +1504,11 @@ var FORGE_FACT_INPUTS = [
|
|
|
1500
1504
|
fact: "mergedAt",
|
|
1501
1505
|
readsFrom: "PullRequest.mergedAt",
|
|
1502
1506
|
meaning: "Timestamp for the coherence oracle grandfather cutoff. No derivation rule reads it."
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
fact: "closedByActor",
|
|
1510
|
+
readsFrom: "ClosedEvent.actor.login (most recent timeline CLOSED_EVENT)",
|
|
1511
|
+
meaning: "GitHub login that hand-closed the Issue. No task-status derivation rule reads it — it is consumed by dispatch-gate.ts/coherence-checks.ts A1 to recognize a hand-closed dependency as resolved (task vinaya-engine-v1 21, #99), not by this status model."
|
|
1503
1512
|
}
|
|
1504
1513
|
];
|
|
1505
1514
|
var DERIVED_STATUSES = [
|
|
@@ -1979,7 +1988,7 @@ function isGrandfathered(isoDate) {
|
|
|
1979
1988
|
return isoDate.slice(0, 10) < COHERENCE_ENFORCED_FROM;
|
|
1980
1989
|
}
|
|
1981
1990
|
var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
|
|
1982
|
-
function checkA1(entries) {
|
|
1991
|
+
function checkA1(entries, principalAllowlist = PRINCIPAL_ALLOWLIST) {
|
|
1983
1992
|
const failures = [];
|
|
1984
1993
|
for (const e of entries) {
|
|
1985
1994
|
if (!e.facts)
|
|
@@ -1987,6 +1996,9 @@ function checkA1(entries) {
|
|
|
1987
1996
|
if (e.facts.stateReason === "not_planned")
|
|
1988
1997
|
continue;
|
|
1989
1998
|
if (e.facts.issueState === "closed" && e.facts.prState !== "merged") {
|
|
1999
|
+
const handClosed = e.facts.stateReason === "completed" && isPrincipal(e.facts.closedByActor, principalAllowlist);
|
|
2000
|
+
if (handClosed)
|
|
2001
|
+
continue;
|
|
1990
2002
|
failures.push({
|
|
1991
2003
|
issue: e.task.issue,
|
|
1992
2004
|
tranche: e.trancheSlug,
|
|
@@ -2676,9 +2688,13 @@ function parseGlossaryTerms(glossaryContent) {
|
|
|
2676
2688
|
return terms;
|
|
2677
2689
|
}
|
|
2678
2690
|
// ../../packages/aeg-core/src/dispatch-gate.ts
|
|
2691
|
+
function isHandClosedByRecognizedPrincipal(dep, principalAllowlist) {
|
|
2692
|
+
return dep.issueState === "closed" && dep.stateReason === "completed" && isPrincipal(dep.closedByActor ?? null, principalAllowlist);
|
|
2693
|
+
}
|
|
2679
2694
|
function checkDispatchReadiness(input) {
|
|
2680
2695
|
const { trancheSlug, task } = input;
|
|
2681
2696
|
const taskLabel = `task ${task.id} (tranche ${trancheSlug})`;
|
|
2697
|
+
const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
|
|
2682
2698
|
const blockers = [];
|
|
2683
2699
|
if (task.issue === null) {
|
|
2684
2700
|
blockers.push(`dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`);
|
|
@@ -2689,7 +2705,7 @@ function checkDispatchReadiness(input) {
|
|
|
2689
2705
|
blockers.push(`dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`);
|
|
2690
2706
|
}
|
|
2691
2707
|
for (const dep of input.dependsOn) {
|
|
2692
|
-
if (!dep.merged) {
|
|
2708
|
+
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
2693
2709
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
2694
2710
|
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
2695
2711
|
}
|