@attalabs/vinaya 0.19.3 → 0.21.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 +81 -0
- package/aeg-root/contracts/archivist-tranche-archivist.md +2 -2
- package/aeg-root/contracts/tranche-archivist-planner.md +8 -8
- package/aeg-root/enforcement.md +18 -9
- package/aeg-root/milestone-model.md +3 -1
- package/aeg-root/process.md +5 -5
- package/aeg-root/roles/architect.md +2 -2
- package/aeg-root/roles/archivist.md +10 -11
- package/aeg-root/roles/brief-author.md +1 -1
- package/aeg-root/roles/developer.md +4 -3
- package/aeg-root/roles/planner.md +2 -2
- package/aeg-root/roles/principal.md +2 -1
- package/aeg-root/roles/tranche-archivist.md +5 -18
- package/aeg-root/skills/aeg/SKILL.md +30 -1
- package/aeg-root/skills/aeg-roles/SKILL.md +1 -1
- package/aeg-root/skills/brief-authoring/SKILL.md +2 -2
- package/aeg-root/state-machine.md +8 -6
- package/aeg-root/task-model.md +1 -1
- package/aeg-root/templates/issue-rationale-template.md +4 -4
- package/aeg-root/templates/pr-report-template.md +4 -0
- package/aeg-root/tranche-model.md +1 -1
- package/dist/checks/bin/check-body-bare-digits.js +473 -32
- package/dist/checks/bin/check-branch-topology.js +792 -11
- package/dist/checks/bin/check-brief-shape.js +353 -11
- package/dist/checks/bin/check-changeset-coverage.js +4156 -0
- package/dist/checks/bin/check-closes-n.js +792 -11
- package/dist/checks/bin/check-coherence.js +831 -15
- package/dist/checks/bin/check-dead-branch-push.js +353 -11
- package/dist/checks/bin/check-dispatch-readiness.js +996 -28
- package/dist/checks/bin/check-doc-coverage-push.js +449 -22
- package/dist/checks/bin/check-doc-coverage.js +449 -22
- package/dist/checks/bin/check-doctrine-portability.js +392 -15
- package/dist/checks/bin/check-evidence-fresh.js +462 -20
- package/dist/checks/bin/check-first-push-dispatch.js +898 -26
- package/dist/checks/bin/check-issue-assignment.js +792 -11
- package/dist/checks/bin/check-main-branch-refusal.js +3973 -0
- package/dist/checks/bin/check-no-disk-state.js +353 -11
- package/dist/checks/bin/check-quoted-command.js +4405 -0
- package/dist/checks/bin/check-reader-resolvable-prose.js +466 -20
- package/dist/checks/bin/check-registry-gates.js +467 -16
- package/dist/checks/bin/check-retired-vocabulary.js +465 -19
- package/dist/checks/bin/check-review-gate.js +392 -15
- package/dist/checks/bin/check-single-plan-pr.js +353 -11
- package/dist/checks/bin/check-test-plan.js +353 -11
- package/dist/checks/bin/check-token-collection-wired.js +3975 -0
- package/dist/checks/bin/check-workspace-escape.js +353 -11
- package/dist/index.js +1921 -420
- package/package.json +1 -1
- package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +1089 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +5 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__0pvgf28._.js → [externals]__1agj1ww._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0053k9k._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0112h-k._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__040smoa._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0cxtq46._.js +25 -18
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0o771t1._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__03jepya._.js → [root-of-the-server]__0ozbaq0._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0puovz5._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0ykun-j._.js → [root-of-the-server]__0z6dav-._.js} +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__18kqy4q._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1hs0dcu._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1widio3._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1yoa8tx._.js +3 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_03x_w6q._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gvm3og._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0lwxg63._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0wxycau._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0x999pb._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-6rzip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1fqw88f._.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_0zys35s._.js → _1mqrlbl._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_1c9b9j-._.js → _1mrtj0f._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1n0cnq-._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{apps_vinaya-studio_web_src_app_studio_18kqbvs._.js → apps_vinaya-studio_web_src_app_studio_06it6s-._.js} +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_05ufo8i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0r4i_ks9z02bw.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3noqvds-2bvrd.js → 1hfhxjy577l5d.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1k916ih3p4nsg.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{29-foak16tjfu.js → 1t2kft7bxzuxn.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2iysedx-n06xc.js → 1ybrihl5_aocy.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{30ojnsx3p4lp4.js → 1yqs2zgvwa4p1.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{0msr2a1i-x-br.js → 25kbt5k-xb2a5.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3gehliafvmjo9.js → 2_k6j1o9q5nn4.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2hmannd4bjhzy.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3mqu_uhluy19i.css +1 -0
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
- package/aeg-root/coordination.md +0 -292
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1rku4gz._.js +0 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/25j-y57ng11hl.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/30lyvn0yzwdiz.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/35u8inxa732is.js +0 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/42wxpzjhw7oy4.css +0 -1
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{5Lv83SnT--7YJDjSbxona → crNCHQ9uAgKOYC6DKkZma}/_ssgManifest.js +0 -0
|
@@ -2,19 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
// src/checks/bin/check-evidence-fresh.ts
|
|
4
4
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
// src/checks/contract.ts
|
|
7
|
+
var CHECK_SCHEMA_VERSION = 1;
|
|
8
|
+
function emitCheckError(error) {
|
|
9
|
+
process.stderr.write(`${JSON.stringify(error)}
|
|
10
|
+
`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/lib/numstat.ts
|
|
14
|
+
function summariseNumstat(numstat) {
|
|
15
|
+
const rows = numstat.split(`
|
|
16
|
+
`).filter((l) => l.trim() !== "");
|
|
17
|
+
let added = 0;
|
|
18
|
+
let deleted = 0;
|
|
19
|
+
let binary = 0;
|
|
20
|
+
for (const row of rows) {
|
|
21
|
+
const [a, d] = row.split("\t");
|
|
22
|
+
if (a === "-" || d === "-") {
|
|
23
|
+
binary++;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
added += Number(a) || 0;
|
|
27
|
+
deleted += Number(d) || 0;
|
|
28
|
+
}
|
|
29
|
+
const files = `${rows.length} file${rows.length === 1 ? "" : "s"} changed`;
|
|
30
|
+
const bin = binary > 0 ? `, ${binary} binary` : "";
|
|
31
|
+
return `${files}, ${added} insertion${added === 1 ? "" : "s"}(+), ${deleted} deletion${deleted === 1 ? "" : "s"}(-)${bin}`;
|
|
32
|
+
}
|
|
33
|
+
var EVIDENCE_SUMMARY_PREFIX = "Summary: ";
|
|
5
34
|
// ../../packages/aeg-core/src/gate-audience.ts
|
|
6
35
|
var GATE_AUDIENCE = {
|
|
7
|
-
"check-branch-topology": { shippedAs: "branch-topology" },
|
|
8
|
-
"check-first-push-dispatch": { shippedAs: "first-push-dispatch" },
|
|
9
|
-
"check-no-disk-state": { shippedAs: "no-disk-state" },
|
|
10
|
-
"verify-brief": { shippedAs: "brief-shape" },
|
|
11
|
-
"verify-coherence": { shippedAs: "coherence" },
|
|
12
|
-
"verify-dispatch": { shippedAs: "dispatch-readiness" },
|
|
13
|
-
"verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"] },
|
|
14
|
-
"verify-registry": { shippedAs: "registry-gates" },
|
|
15
|
-
"verify-review-gate": { shippedAs: "review-gate" },
|
|
16
|
-
"verify-single-plan-pr": { shippedAs: "single-plan-pr" },
|
|
17
|
-
"verify-test-plan": { shippedAs: "test-plan" },
|
|
36
|
+
"check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
|
|
37
|
+
"check-first-push-dispatch": { shippedAs: "first-push-dispatch", ring: 0 },
|
|
38
|
+
"check-no-disk-state": { shippedAs: "no-disk-state", ring: 0 },
|
|
39
|
+
"verify-brief": { shippedAs: "brief-shape", ring: 0 },
|
|
40
|
+
"verify-coherence": { shippedAs: "coherence", ring: 0 },
|
|
41
|
+
"verify-dispatch": { shippedAs: "dispatch-readiness", ring: 0 },
|
|
42
|
+
"verify-docs": { shippedAs: ["doc-coverage", "doc-coverage-push"], ring: 0 },
|
|
43
|
+
"verify-registry": { shippedAs: "registry-gates", ring: 0 },
|
|
44
|
+
"verify-review-gate": { shippedAs: "review-gate", ring: 1 },
|
|
45
|
+
"verify-single-plan-pr": { shippedAs: "single-plan-pr", ring: 0 },
|
|
46
|
+
"verify-test-plan": { shippedAs: "test-plan", ring: 1 },
|
|
18
47
|
"check-direct-main-push": {
|
|
19
48
|
internal: "Reaches adopters through `vinaya audit --only=direct-push`, not the check registry: it is a ring-2 sweep over merge history keyed on `GITHUB_SHA`, run by the generated archivist job on push to the default branch. It has no diff to key on, so there is nothing for `vinaya check` to run it against."
|
|
20
49
|
},
|
|
@@ -189,6 +218,12 @@ var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
|
|
|
189
218
|
var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
|
|
190
219
|
var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
|
|
191
220
|
var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
|
|
221
|
+
function splitSlugQualifiedEdge(edge) {
|
|
222
|
+
const m = edge.trim().match(SLUG_QUALIFIED_ID);
|
|
223
|
+
if (!m)
|
|
224
|
+
return null;
|
|
225
|
+
return { slug: m[1], bareId: m[2] };
|
|
226
|
+
}
|
|
192
227
|
function isEmptyMarker(s) {
|
|
193
228
|
const t = s.trim();
|
|
194
229
|
return t === "" || t === "—" || t === "-" || t === "–";
|
|
@@ -326,6 +361,13 @@ var LABELS = [
|
|
|
326
361
|
form: "literal",
|
|
327
362
|
carries: "Execution is halted pending an external unblock; wins over every other derived status."
|
|
328
363
|
},
|
|
364
|
+
{
|
|
365
|
+
key: "backlog",
|
|
366
|
+
id: "vinaya/backlog",
|
|
367
|
+
category: "state",
|
|
368
|
+
form: "literal",
|
|
369
|
+
carries: "The Issue is deliberately unplanned — belongs to no tranche and is excluded from dispatch, until a Planner promotes it."
|
|
370
|
+
},
|
|
329
371
|
{
|
|
330
372
|
key: "tier-0",
|
|
331
373
|
id: "vinaya/tier:0",
|
|
@@ -1778,6 +1820,151 @@ var DERIVED_STATUSES = [
|
|
|
1778
1820
|
"incoherent"
|
|
1779
1821
|
];
|
|
1780
1822
|
var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
|
|
1823
|
+
// ../../packages/aeg-core/src/report-tokens.ts
|
|
1824
|
+
var DASH_LOOKALIKES = {
|
|
1825
|
+
"-": "‑",
|
|
1826
|
+
"–": "‒",
|
|
1827
|
+
"—": "―"
|
|
1828
|
+
};
|
|
1829
|
+
var DASH_CHARS = new Set(Object.keys(DASH_LOOKALIKES));
|
|
1830
|
+
// ../../packages/aeg-core/src/claude-code-transcript.ts
|
|
1831
|
+
function summarizeTranscript(jsonl) {
|
|
1832
|
+
const seen = new Set;
|
|
1833
|
+
const components = {
|
|
1834
|
+
inputTokens: 0,
|
|
1835
|
+
outputTokens: 0,
|
|
1836
|
+
cacheCreationInputTokens: 0,
|
|
1837
|
+
cacheReadInputTokens: 0
|
|
1838
|
+
};
|
|
1839
|
+
let model = null;
|
|
1840
|
+
let messageCount = 0;
|
|
1841
|
+
for (const rawLine of jsonl.split(/\r?\n/)) {
|
|
1842
|
+
const line = rawLine.trim();
|
|
1843
|
+
if (!line)
|
|
1844
|
+
continue;
|
|
1845
|
+
let entry2;
|
|
1846
|
+
try {
|
|
1847
|
+
entry2 = JSON.parse(line);
|
|
1848
|
+
} catch {
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
if (!entry2 || typeof entry2 !== "object")
|
|
1852
|
+
continue;
|
|
1853
|
+
const obj = entry2;
|
|
1854
|
+
if (obj.type !== "assistant")
|
|
1855
|
+
continue;
|
|
1856
|
+
const message = obj.message;
|
|
1857
|
+
const id = message?.id;
|
|
1858
|
+
const usage = message?.usage;
|
|
1859
|
+
if (typeof id !== "string" || !id || !usage || seen.has(id))
|
|
1860
|
+
continue;
|
|
1861
|
+
seen.add(id);
|
|
1862
|
+
messageCount++;
|
|
1863
|
+
components.inputTokens += numberOr(usage.input_tokens, 0);
|
|
1864
|
+
components.outputTokens += numberOr(usage.output_tokens, 0);
|
|
1865
|
+
components.cacheCreationInputTokens += numberOr(usage.cache_creation_input_tokens, 0);
|
|
1866
|
+
components.cacheReadInputTokens += numberOr(usage.cache_read_input_tokens, 0);
|
|
1867
|
+
const messageModel = message?.model;
|
|
1868
|
+
if (typeof messageModel === "string" && messageModel)
|
|
1869
|
+
model = messageModel;
|
|
1870
|
+
}
|
|
1871
|
+
return { components, model, messageCount };
|
|
1872
|
+
}
|
|
1873
|
+
function numberOr(value, fallback) {
|
|
1874
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1875
|
+
}
|
|
1876
|
+
function sanitizeKey(value) {
|
|
1877
|
+
return value.replace(/[^A-Za-z0-9]+/g, "-");
|
|
1878
|
+
}
|
|
1879
|
+
function transcriptPointerPath(projectDir, tmpDir) {
|
|
1880
|
+
return `${tmpDir}/claude-transcript-${sanitizeKey(projectDir)}.txt`;
|
|
1881
|
+
}
|
|
1882
|
+
function resolvePointer(explicitTranscriptPath, deps) {
|
|
1883
|
+
if (explicitTranscriptPath)
|
|
1884
|
+
return { path: explicitTranscriptPath, corroborated: true };
|
|
1885
|
+
const projectDir = deps.env.CLAUDE_PROJECT_DIR ?? deps.cwd;
|
|
1886
|
+
const tmpDir = deps.env.TMPDIR ?? "/tmp";
|
|
1887
|
+
const pointerPath = transcriptPointerPath(projectDir, tmpDir);
|
|
1888
|
+
const currentSessionId = deps.env.CLAUDE_CODE_SESSION_ID;
|
|
1889
|
+
if (!deps.exists(pointerPath)) {
|
|
1890
|
+
return {
|
|
1891
|
+
pointerExisted: false,
|
|
1892
|
+
corroborated: false,
|
|
1893
|
+
error: `No transcript pointer at ${pointerPath} and no --transcript given. ` + "Either this repo installs no track-transcript.sh Stop hook (lacking one is not a defect — " + "name the transcript directly instead), or no session has completed a turn yet."
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
let contents;
|
|
1897
|
+
try {
|
|
1898
|
+
contents = deps.readFile(pointerPath).replace(/\r?\n+$/, "");
|
|
1899
|
+
} catch (err) {
|
|
1900
|
+
return {
|
|
1901
|
+
pointerExisted: true,
|
|
1902
|
+
oursByLocation: true,
|
|
1903
|
+
error: `Transcript pointer at ${pointerPath} could not be read: ${err.message}. ` + "Remove that file to clear this — the Stop hook rewrites it on the next turn."
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
const [pointerSessionId, transcriptPath] = contents.split("\t");
|
|
1907
|
+
if (!transcriptPath) {
|
|
1908
|
+
return {
|
|
1909
|
+
pointerExisted: true,
|
|
1910
|
+
oursByLocation: true,
|
|
1911
|
+
error: `Transcript pointer file ${pointerPath} is malformed: "${contents.slice(0, 120)}${contents.length > 120 ? "…" : ""}". ` + "Remove that file to clear this — the Stop hook rewrites it on the next turn."
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
if (currentSessionId && pointerSessionId && currentSessionId !== pointerSessionId) {
|
|
1915
|
+
return {
|
|
1916
|
+
pointerExisted: true,
|
|
1917
|
+
corroborated: false,
|
|
1918
|
+
error: `Transcript pointer at ${pointerPath} is stale: written for session ${pointerSessionId}, ` + `but this session is ${currentSessionId}. Name your own transcript with --transcript instead of ` + "reporting another session's figures as yours."
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
return { path: transcriptPath, corroborated: Boolean(currentSessionId && pointerSessionId) };
|
|
1922
|
+
}
|
|
1923
|
+
function resolveMeteringCapability(deps, explicitTranscriptPath) {
|
|
1924
|
+
const resolved = resolvePointer(explicitTranscriptPath, deps);
|
|
1925
|
+
if ("error" in resolved) {
|
|
1926
|
+
const ours = resolved.pointerExisted && (resolved.corroborated || resolved.oursByLocation);
|
|
1927
|
+
if (ours)
|
|
1928
|
+
return { capable: false, reason: "pointer-unusable", detail: resolved.error };
|
|
1929
|
+
return {
|
|
1930
|
+
capable: false,
|
|
1931
|
+
reason: "no-transcript-resolved",
|
|
1932
|
+
detail: resolved.pointerExisted ? `A transcript pointer exists but belongs to another session, so this session has no wiring of its own to use. (Underlying condition, for diagnosis only: ${resolved.error})` : resolved.error
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
const downstream = (r, detail) => resolved.corroborated ? { reason: r, detail } : {
|
|
1936
|
+
reason: "no-transcript-resolved",
|
|
1937
|
+
detail: `A transcript pointer was found but could not be shown to belong to this session, so it is not treated as this session's wiring. (Underlying condition, for diagnosis only: ${detail})`
|
|
1938
|
+
};
|
|
1939
|
+
if (!deps.exists(resolved.path)) {
|
|
1940
|
+
return {
|
|
1941
|
+
capable: false,
|
|
1942
|
+
...downstream("transcript-unreadable", `Resolved transcript path ${resolved.path} is not readable as a regular file owned by this user.`)
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
let jsonl;
|
|
1946
|
+
try {
|
|
1947
|
+
jsonl = deps.readFile(resolved.path);
|
|
1948
|
+
} catch (err) {
|
|
1949
|
+
return {
|
|
1950
|
+
capable: false,
|
|
1951
|
+
...downstream("transcript-unreadable", `Transcript at ${resolved.path} could not be read: ${err.message}`)
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
const summary = summarizeTranscript(jsonl);
|
|
1955
|
+
if (summary.messageCount === 0) {
|
|
1956
|
+
return {
|
|
1957
|
+
capable: false,
|
|
1958
|
+
...downstream("transcript-empty", `Transcript at ${resolved.path} yielded zero assistant messages with usage data — ` + "it's empty, unparseable, or not yet flushed to disk.")
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
return { capable: true, transcriptPath: resolved.path, summary };
|
|
1962
|
+
}
|
|
1963
|
+
function isTokenCollectionWiringBroken(capability) {
|
|
1964
|
+
if (capability.capable)
|
|
1965
|
+
return false;
|
|
1966
|
+
return capability.reason !== "no-transcript-resolved";
|
|
1967
|
+
}
|
|
1781
1968
|
// ../../packages/aeg-core/src/file-classify.ts
|
|
1782
1969
|
function isCodeFile(p) {
|
|
1783
1970
|
if (p.endsWith(".md"))
|
|
@@ -1984,7 +2171,59 @@ function overrideActive(opts) {
|
|
|
1984
2171
|
return false;
|
|
1985
2172
|
}
|
|
1986
2173
|
// ../../packages/aeg-core/src/premise-check.ts
|
|
2174
|
+
import { createHash } from "node:crypto";
|
|
1987
2175
|
var ASSERTION_KINDS = new Set(["contains", "absent", "sha256"]);
|
|
2176
|
+
function isPremiseHeader(line) {
|
|
2177
|
+
const stripped = line.replace(/[*#]/g, "").trim();
|
|
2178
|
+
return /^premise\s*:?$/i.test(stripped);
|
|
2179
|
+
}
|
|
2180
|
+
var PREMISE_LINE = /^[-*]\s*(\S+)\s+(contains|absent|sha256)\s*:\s*(.+)$/i;
|
|
2181
|
+
function parsePremiseBlock(prBody) {
|
|
2182
|
+
const searchIn = anchoredRegion(prBody, "PREMISE") ?? prBody;
|
|
2183
|
+
const lines = searchIn.split(/\r?\n/);
|
|
2184
|
+
const assertions = [];
|
|
2185
|
+
let inBlock = false;
|
|
2186
|
+
for (const raw of lines) {
|
|
2187
|
+
const line = raw.trim();
|
|
2188
|
+
if (!inBlock) {
|
|
2189
|
+
if (isPremiseHeader(line))
|
|
2190
|
+
inBlock = true;
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
if (line === "")
|
|
2194
|
+
break;
|
|
2195
|
+
const m = line.match(PREMISE_LINE);
|
|
2196
|
+
if (!m)
|
|
2197
|
+
break;
|
|
2198
|
+
const [, path, kindRaw, value] = m;
|
|
2199
|
+
const kind = kindRaw.toLowerCase();
|
|
2200
|
+
if (!ASSERTION_KINDS.has(kind))
|
|
2201
|
+
continue;
|
|
2202
|
+
assertions.push({ kind, path, value: value.trim() });
|
|
2203
|
+
}
|
|
2204
|
+
return assertions;
|
|
2205
|
+
}
|
|
2206
|
+
function checkPremises(assertions, fileReader) {
|
|
2207
|
+
const failures = [];
|
|
2208
|
+
for (const a of assertions) {
|
|
2209
|
+
const content = fileReader(a.path);
|
|
2210
|
+
if (content === null) {
|
|
2211
|
+
failures.push(`premise-check: ${a.path} does not exist on disk (premise asserted \`${a.kind}: ${a.value}\`) — the surface moved since this brief was authored; re-dig before proceeding.`);
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
if (a.kind === "contains" && !content.includes(a.value)) {
|
|
2215
|
+
failures.push(`premise-check: ${a.path} no longer contains "${a.value}" — the premise this brief pinned has moved; re-dig before proceeding.`);
|
|
2216
|
+
} else if (a.kind === "absent" && content.includes(a.value)) {
|
|
2217
|
+
failures.push(`premise-check: ${a.path} now contains "${a.value}", but the brief pinned it absent — the premise has moved; re-dig before proceeding.`);
|
|
2218
|
+
} else if (a.kind === "sha256") {
|
|
2219
|
+
const actual = createHash("sha256").update(content).digest("hex");
|
|
2220
|
+
if (actual !== a.value.toLowerCase()) {
|
|
2221
|
+
failures.push(`premise-check: ${a.path} sha256 mismatch (brief pinned ${a.value}, file is now ${actual}) — the file changed since this brief was authored; re-dig before proceeding.`);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return { pass: failures.length === 0, failures };
|
|
2226
|
+
}
|
|
1988
2227
|
|
|
1989
2228
|
// ../../packages/aeg-core/src/test-plan-section.ts
|
|
1990
2229
|
var HEADING_FORM_RE = /^#{1,4}[ \t]*(?:\d+[a-z]?\.[ \t]*)?\*{0,2}Test Plan\*{0,2}[ \t]*$/im;
|
|
@@ -2788,6 +3027,7 @@ function checkG1(rows, existsFn) {
|
|
|
2788
3027
|
}
|
|
2789
3028
|
return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
|
|
2790
3029
|
}
|
|
3030
|
+
var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
|
|
2791
3031
|
function checkG2(rows, candidateFiles) {
|
|
2792
3032
|
const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
|
|
2793
3033
|
const findings = [];
|
|
@@ -2799,6 +3039,16 @@ function checkG2(rows, candidateFiles) {
|
|
|
2799
3039
|
});
|
|
2800
3040
|
}
|
|
2801
3041
|
}
|
|
3042
|
+
for (const row of rows) {
|
|
3043
|
+
const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
|
|
3044
|
+
if (carriesPlaceholder) {
|
|
3045
|
+
findings.push({
|
|
3046
|
+
row: row.action,
|
|
3047
|
+
path: row.implementation,
|
|
3048
|
+
reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
2802
3052
|
return { check: "G2", status: findings.length > 0 ? "info" : "pass", findings };
|
|
2803
3053
|
}
|
|
2804
3054
|
function checkG3(ring0Rows, crossingFiles) {
|
|
@@ -3146,6 +3396,100 @@ function parseGlossaryTerms(glossaryContent) {
|
|
|
3146
3396
|
}
|
|
3147
3397
|
return terms;
|
|
3148
3398
|
}
|
|
3399
|
+
// ../../packages/aeg-core/src/quoted-command.ts
|
|
3400
|
+
var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
|
|
3401
|
+
var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
|
|
3402
|
+
var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
|
|
3403
|
+
var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
|
|
3404
|
+
function isValidCitedFilePath(path) {
|
|
3405
|
+
if (path.length === 0)
|
|
3406
|
+
return false;
|
|
3407
|
+
if (path.startsWith("/") || path.startsWith("\\"))
|
|
3408
|
+
return false;
|
|
3409
|
+
if (/^[A-Za-z]:[\\/]/.test(path))
|
|
3410
|
+
return false;
|
|
3411
|
+
return !path.split(/[\\/]+/).includes("..");
|
|
3412
|
+
}
|
|
3413
|
+
function quotedCommandLineAt(content, index) {
|
|
3414
|
+
let line = 1;
|
|
3415
|
+
for (let i = 0;i < index; i++) {
|
|
3416
|
+
if (content.charCodeAt(i) === 10)
|
|
3417
|
+
line++;
|
|
3418
|
+
}
|
|
3419
|
+
return line;
|
|
3420
|
+
}
|
|
3421
|
+
function extractQuotedText(raw) {
|
|
3422
|
+
const trimmed = raw.trim();
|
|
3423
|
+
const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
|
|
3424
|
+
if (fenced)
|
|
3425
|
+
return (fenced[1] ?? "").trim();
|
|
3426
|
+
const inline = /^`([^`]+)`$/.exec(trimmed);
|
|
3427
|
+
if (inline)
|
|
3428
|
+
return (inline[1] ?? "").trim();
|
|
3429
|
+
return trimmed;
|
|
3430
|
+
}
|
|
3431
|
+
function findQuotesInFile(path, content) {
|
|
3432
|
+
const masked = maskCode(content);
|
|
3433
|
+
const quotes = [];
|
|
3434
|
+
START_PATTERN.lastIndex = 0;
|
|
3435
|
+
let start = START_PATTERN.exec(masked);
|
|
3436
|
+
while (start !== null) {
|
|
3437
|
+
const citedFile = start[1];
|
|
3438
|
+
const innerStart = start.index + start[0].length;
|
|
3439
|
+
const end = END_PATTERN.exec(masked.slice(innerStart));
|
|
3440
|
+
if (end === null) {
|
|
3441
|
+
START_PATTERN.lastIndex = innerStart;
|
|
3442
|
+
start = START_PATTERN.exec(masked);
|
|
3443
|
+
continue;
|
|
3444
|
+
}
|
|
3445
|
+
const innerEnd = innerStart + end.index;
|
|
3446
|
+
if (isValidCitedFilePath(citedFile)) {
|
|
3447
|
+
const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
|
|
3448
|
+
if (quotedText.length > 0) {
|
|
3449
|
+
quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
START_PATTERN.lastIndex = innerEnd + end[0].length;
|
|
3453
|
+
start = START_PATTERN.exec(masked);
|
|
3454
|
+
}
|
|
3455
|
+
return quotes;
|
|
3456
|
+
}
|
|
3457
|
+
function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
|
|
3458
|
+
const quotes = [];
|
|
3459
|
+
for (const file of files) {
|
|
3460
|
+
const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
|
|
3461
|
+
if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
|
|
3462
|
+
continue;
|
|
3463
|
+
quotes.push(...findQuotesInFile(file.path, file.content));
|
|
3464
|
+
}
|
|
3465
|
+
return quotes;
|
|
3466
|
+
}
|
|
3467
|
+
function evaluateCitedQuotes(citedQuotes, citedFileContents) {
|
|
3468
|
+
const findings = [];
|
|
3469
|
+
for (const quote of citedQuotes) {
|
|
3470
|
+
const content = citedFileContents.get(quote.citedFile);
|
|
3471
|
+
if (content === undefined) {
|
|
3472
|
+
findings.push({
|
|
3473
|
+
file: quote.file,
|
|
3474
|
+
line: quote.line,
|
|
3475
|
+
citedFile: quote.citedFile,
|
|
3476
|
+
quotedText: quote.quotedText,
|
|
3477
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
|
|
3478
|
+
});
|
|
3479
|
+
continue;
|
|
3480
|
+
}
|
|
3481
|
+
if (!content.includes(quote.quotedText)) {
|
|
3482
|
+
findings.push({
|
|
3483
|
+
file: quote.file,
|
|
3484
|
+
line: quote.line,
|
|
3485
|
+
citedFile: quote.citedFile,
|
|
3486
|
+
quotedText: quote.quotedText,
|
|
3487
|
+
message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
return findings;
|
|
3492
|
+
}
|
|
3149
3493
|
// ../../packages/aeg-core/src/retired-vocabulary.ts
|
|
3150
3494
|
var RETIRED_PATTERNS = [
|
|
3151
3495
|
String.raw`\bD-[0-9]{3}\b`,
|
|
@@ -3259,6 +3603,10 @@ function checkDispatchReadiness(input) {
|
|
|
3259
3603
|
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.`);
|
|
3260
3604
|
}
|
|
3261
3605
|
for (const dep of input.dependsOn) {
|
|
3606
|
+
if (dep.resolved === false) {
|
|
3607
|
+
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on "${dep.id}", which is UNRESOLVABLE — the resolver could not find a matching tranche/task/Issue for this edge (not a claim about merge status). Not dispatchable until the edge is corrected.`);
|
|
3608
|
+
continue;
|
|
3609
|
+
}
|
|
3262
3610
|
if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
|
|
3263
3611
|
const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
|
|
3264
3612
|
blockers.push(`dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
|
|
@@ -3318,6 +3666,29 @@ function isNewDiskStateFile(path, status) {
|
|
|
3318
3666
|
return false;
|
|
3319
3667
|
return ANY_DEPTH_TRANCHES_MD.test(path) || TOKENS_FILE.test(path);
|
|
3320
3668
|
}
|
|
3669
|
+
// ../../packages/aeg-core/src/main-branch-refusal.ts
|
|
3670
|
+
function checkMainBranchRefusal(facts) {
|
|
3671
|
+
const { currentSymbolicBranch, defaultBranch } = facts;
|
|
3672
|
+
if (currentSymbolicBranch === null)
|
|
3673
|
+
return null;
|
|
3674
|
+
if (defaultBranch === null) {
|
|
3675
|
+
return {
|
|
3676
|
+
reason: "default-branch-undetermined",
|
|
3677
|
+
severity: "warning",
|
|
3678
|
+
currentBranch: currentSymbolicBranch,
|
|
3679
|
+
defaultBranch: null
|
|
3680
|
+
};
|
|
3681
|
+
}
|
|
3682
|
+
if (currentSymbolicBranch === defaultBranch) {
|
|
3683
|
+
return {
|
|
3684
|
+
reason: "on-default-branch",
|
|
3685
|
+
severity: "error",
|
|
3686
|
+
currentBranch: currentSymbolicBranch,
|
|
3687
|
+
defaultBranch
|
|
3688
|
+
};
|
|
3689
|
+
}
|
|
3690
|
+
return null;
|
|
3691
|
+
}
|
|
3321
3692
|
// ../../packages/aeg-core/src/branch-topology-gate.ts
|
|
3322
3693
|
function taskBranchTopologyFields(branch) {
|
|
3323
3694
|
if (!/^task\/.*\/.*$/.test(branch))
|
|
@@ -3571,17 +3942,64 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
|
|
|
3571
3942
|
}
|
|
3572
3943
|
return findings;
|
|
3573
3944
|
}
|
|
3574
|
-
// src/checks/
|
|
3575
|
-
var
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3945
|
+
// src/checks/scan-context.ts
|
|
3946
|
+
var ZERO_WIDTH = /[\u200B-\u200D\u2060\uFEFF]/g;
|
|
3947
|
+
var HTML_ENTITIES = {
|
|
3948
|
+
""": '"',
|
|
3949
|
+
"'": "'",
|
|
3950
|
+
"<": "<",
|
|
3951
|
+
">": ">",
|
|
3952
|
+
"&": "&"
|
|
3953
|
+
};
|
|
3954
|
+
function decodeNamedEntities(body) {
|
|
3955
|
+
return body.replace(/&(?:quot|apos|lt|gt|amp);/g, (m) => HTML_ENTITIES[m] ?? m);
|
|
3956
|
+
}
|
|
3957
|
+
function normalizeBody(rawBody) {
|
|
3958
|
+
return decodeNamedEntities(rawBody.replace(ZERO_WIDTH, ""));
|
|
3959
|
+
}
|
|
3960
|
+
function buildAnchorLookupMask(body) {
|
|
3961
|
+
return maskDetailsBlocks(maskCode(body));
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
class ScanContext {
|
|
3965
|
+
raw;
|
|
3966
|
+
normalised;
|
|
3967
|
+
masked;
|
|
3968
|
+
constructor(raw, normalised, masked) {
|
|
3969
|
+
this.raw = raw;
|
|
3970
|
+
this.normalised = normalised;
|
|
3971
|
+
this.masked = masked;
|
|
3972
|
+
}
|
|
3973
|
+
static from(rawBody) {
|
|
3974
|
+
const normalised = normalizeBody(rawBody);
|
|
3975
|
+
return new ScanContext(rawBody, normalised, buildAnchorLookupMask(normalised));
|
|
3976
|
+
}
|
|
3977
|
+
rawResolutionAgrees(field) {
|
|
3978
|
+
const rawHasPair = anchoredRegionBounds(this.raw, field) !== null;
|
|
3979
|
+
return rawHasPair === (anchoredRegionBounds(this.masked, field) !== null);
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
function resolveAnchoredRegion(ctx, field) {
|
|
3983
|
+
const bounds = anchoredRegionBounds(ctx.masked, field);
|
|
3984
|
+
if (bounds === null) {
|
|
3985
|
+
return anchoredRegionBounds(ctx.normalised, field) !== null ? "hidden" : null;
|
|
3986
|
+
}
|
|
3987
|
+
return {
|
|
3988
|
+
region: ctx.normalised.slice(bounds.innerStart, bounds.innerEnd),
|
|
3989
|
+
maskedRegion: ctx.masked.slice(bounds.innerStart, bounds.innerEnd)
|
|
3990
|
+
};
|
|
3991
|
+
}
|
|
3992
|
+
function summaryLineIndex(maskedRegion) {
|
|
3993
|
+
const index = maskedRegion.split(`
|
|
3994
|
+
`).findIndex((line) => line.startsWith(EVIDENCE_SUMMARY_PREFIX));
|
|
3995
|
+
return index === -1 ? null : index;
|
|
3579
3996
|
}
|
|
3580
3997
|
|
|
3581
3998
|
// src/checks/evidence-fresh-logic.ts
|
|
3582
3999
|
var HEAD_LINE = /^Head:\s*([0-9a-f]{7,40})\s*$/m;
|
|
3583
4000
|
var FENCE = /```[^\n]*\n?([\s\S]*?)```/g;
|
|
3584
|
-
function compareEvidenceBlock(
|
|
4001
|
+
function compareEvidenceBlock(resolved, resolvedHead, actualNumstat) {
|
|
4002
|
+
const region = resolved.region;
|
|
3585
4003
|
const headMatch = region.match(HEAD_LINE);
|
|
3586
4004
|
const fences = [...region.matchAll(FENCE)].map((m) => (m[1] ?? "").trim());
|
|
3587
4005
|
if (!headMatch || fences.length < 1) {
|
|
@@ -3607,6 +4025,20 @@ function compareEvidenceBlock(region, resolvedHead, actualNumstat) {
|
|
|
3607
4025
|
].join(`
|
|
3608
4026
|
`));
|
|
3609
4027
|
}
|
|
4028
|
+
const summaryIndex = summaryLineIndex(resolved.maskedRegion);
|
|
4029
|
+
if (summaryIndex !== null) {
|
|
4030
|
+
const storedSummary = resolved.region.split(`
|
|
4031
|
+
`)[summaryIndex];
|
|
4032
|
+
const expectedSummary = `${EVIDENCE_SUMMARY_PREFIX}\`${summariseNumstat(actual)}\``;
|
|
4033
|
+
if (storedSummary !== expectedSummary) {
|
|
4034
|
+
errors.push([
|
|
4035
|
+
"evidence-fresh: the Summary line does not match a fresh recompute of the diff it summarises.",
|
|
4036
|
+
` block: ${JSON.stringify(storedSummary)}`,
|
|
4037
|
+
` actual: ${JSON.stringify(expectedSummary)}`
|
|
4038
|
+
].join(`
|
|
4039
|
+
`));
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
3610
4042
|
return errors.length > 0 ? { status: "fail", errors } : { status: "pass" };
|
|
3611
4043
|
}
|
|
3612
4044
|
|
|
@@ -3665,10 +4097,20 @@ function main() {
|
|
|
3665
4097
|
if (!body) {
|
|
3666
4098
|
process.exit(0);
|
|
3667
4099
|
}
|
|
3668
|
-
const
|
|
3669
|
-
if (
|
|
4100
|
+
const resolved = resolveAnchoredRegion(ScanContext.from(body), "EVIDENCE");
|
|
4101
|
+
if (resolved === null) {
|
|
3670
4102
|
process.exit(0);
|
|
3671
4103
|
}
|
|
4104
|
+
if (resolved === "hidden") {
|
|
4105
|
+
emitCheckError({
|
|
4106
|
+
schema: CHECK_SCHEMA_VERSION,
|
|
4107
|
+
check: CHECK_NAME,
|
|
4108
|
+
severity: "error",
|
|
4109
|
+
message: "evidence-fresh: the AEG:EVIDENCE block sits inside a `<details>` block, where its digits are exempt from `body-bare-digits` and nothing can verify what it claims. Move the block out of the collapsed section.",
|
|
4110
|
+
agent_recovery_prompt: "Move the AEG:EVIDENCE anchor pair out of the `<details>` block (the canonical home is its own `## Evidence` section), then re-run `vinaya pr report --write <body-file>`."
|
|
4111
|
+
});
|
|
4112
|
+
process.exit(1);
|
|
4113
|
+
}
|
|
3672
4114
|
const prNumberStr = process.env.PR_NUMBER;
|
|
3673
4115
|
if (!prNumberStr) {
|
|
3674
4116
|
process.exit(0);
|
|
@@ -3699,7 +4141,7 @@ function main() {
|
|
|
3699
4141
|
});
|
|
3700
4142
|
process.exit(1);
|
|
3701
4143
|
}
|
|
3702
|
-
const result = compareEvidenceBlock(
|
|
4144
|
+
const result = compareEvidenceBlock(resolved, resolvedHead, actualNumstat);
|
|
3703
4145
|
if (result.status === "fail") {
|
|
3704
4146
|
for (const message of result.errors) {
|
|
3705
4147
|
emitCheckError({
|