@attalabs/vinaya 0.9.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +7 -5
  2. package/aeg-root/enforcement.md +3 -3
  3. package/aeg-root/glossary.md +4 -0
  4. package/aeg-root/roles/archivist.md +2 -2
  5. package/aeg-root/roles/developer.md +29 -5
  6. package/aeg-root/roles/planner.md +1 -1
  7. package/aeg-root/roles/reviewer.md +1 -1
  8. package/aeg-root/roles/security.md +1 -1
  9. package/aeg-root/roles/tranche-archivist.md +1 -1
  10. package/aeg-root/state-machine.md +6 -6
  11. package/aeg-root/templates/pr-report-template.md +8 -4
  12. package/aeg-root/tranche-model.md +33 -11
  13. package/dist/checks/bin/check-branch-topology.js +204 -115
  14. package/dist/checks/bin/check-brief-shape.js +204 -115
  15. package/dist/checks/bin/check-closes-n.js +204 -115
  16. package/dist/checks/bin/check-coherence.js +204 -115
  17. package/dist/checks/bin/check-dead-branch-push.js +204 -115
  18. package/dist/checks/bin/check-dispatch-readiness.js +204 -115
  19. package/dist/checks/bin/check-doc-coverage-push.js +231 -124
  20. package/dist/checks/bin/check-doc-coverage.js +233 -126
  21. package/dist/checks/bin/check-evidence-fresh.js +3173 -0
  22. package/dist/checks/bin/check-first-push-dispatch.js +204 -115
  23. package/dist/checks/bin/check-issue-assignment.js +204 -115
  24. package/dist/checks/bin/check-no-disk-state.js +204 -115
  25. package/dist/checks/bin/check-reader-resolvable-prose.js +204 -115
  26. package/dist/checks/bin/check-registry-gates.js +204 -115
  27. package/dist/checks/bin/check-review-gate.js +204 -115
  28. package/dist/checks/bin/check-single-plan-pr.js +204 -115
  29. package/dist/checks/bin/check-test-plan.js +204 -115
  30. package/dist/index.js +487 -221
  31. package/package.json +1 -1
  32. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  33. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  34. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  35. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +3 -1
  36. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  37. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  38. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  39. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  40. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  41. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  42. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  43. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  44. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  45. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  46. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  47. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  48. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  49. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  50. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  51. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  52. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  53. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  54. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  55. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  56. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  57. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +2 -2
  58. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -3
  59. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  60. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  61. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  62. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  63. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  64. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  65. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  66. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  67. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  68. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  69. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  70. 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
  71. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__029-1ch._.js +1 -1
  72. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05t6482._.js +1 -1
  73. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0gw1_g2._.js +1 -1
  74. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0mdkphe._.js +3 -0
  75. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0plfbyn._.js +45 -0
  76. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0q56ohl._.js +1 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0rr_lq7._.js +51 -0
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1_ojzp1._.js +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1d_8nm4._.js +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1p19382._.js → [root-of-the-server]__1wsl6ro._.js} +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1zkwtx8._.js +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__210ehg9._.js +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_00yjcv1._.js +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rix02i._.js +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_18-d2be._.js +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1fqw88f._.js +5 -4
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1gw6vc9._.js +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_20yap_f._.js +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_1vo08dj._.js +2 -2
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +3 -3
  95. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3zyedaek9nvr_.js → 1eo32v1tbjy7c.js} +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1t7yy_s34022p.js +1 -0
  97. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3antrj5z0uf_c.js → 2ieu4oi-pp_bz.js} +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  100. package/templates/custom-check.template.ts +5 -0
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1s7kj3s._.js +0 -3
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1tswrm4._.js +0 -9
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_01jl99k._.js +0 -45
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_20c6-3m._.js +0 -45
  105. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2e68sbtdhi5dg.js +0 -1
  106. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{pY8RKWuVAUZOjj2-bAYCY → ZHVE9Y9G8XKR91g27SgVX}/_buildManifest.js +0 -0
  107. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{pY8RKWuVAUZOjj2-bAYCY → ZHVE9Y9G8XKR91g27SgVX}/_clientMiddlewareManifest.js +0 -0
  108. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{pY8RKWuVAUZOjj2-bAYCY → ZHVE9Y9G8XKR91g27SgVX}/_ssgManifest.js +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/checks/bin/check-closes-n.ts
4
4
  import { execFileSync as execFileSync2 } from "node:child_process";
5
- // ../../packages/aeg-core/src/anchored-region.ts
5
+ // ../../packages/aeg-forge-state/src/strip-code.ts
6
6
  function maskCode(body) {
7
7
  const fill = (line) => " ".repeat(line.length);
8
8
  return maskIndentedCode(maskFencedCode(body, fill), fill).replace(/(`+)[^\n]*?\1/g, (m) => " ".repeat(m.length));
@@ -19,29 +19,38 @@ function stripCode(body, options = {}) {
19
19
  var FENCE_OPEN = /^ {0,3}(`{3,}|~{3,})([^\r\n]*)\r?$/;
20
20
  var FENCE_CLOSE = /^ {0,3}(`+|~+)[ \t]*\r?$/;
21
21
  function maskFencedCode(body, fill) {
22
+ const { lines } = scanFencedCode(body);
23
+ return lines.map(({ line, inCode }) => inCode ? fill(line) : line).join(`
24
+ `);
25
+ }
26
+ function scanFencedCode(body) {
22
27
  let fenceChar = null;
23
28
  let fenceLen = 0;
24
- return body.split(`
29
+ const lines = body.split(`
25
30
  `).map((line) => {
26
31
  if (fenceChar === null) {
27
32
  const open = line.match(FENCE_OPEN);
28
33
  if (!open)
29
- return line;
34
+ return { line, inCode: false };
30
35
  const marker = open[1];
31
36
  if (marker[0] === "`" && open[2].includes("`"))
32
- return line;
37
+ return { line, inCode: false };
33
38
  fenceChar = marker[0];
34
39
  fenceLen = marker.length;
35
- return fill(line);
40
+ return { line, inCode: true };
36
41
  }
37
42
  const close = line.match(FENCE_CLOSE);
38
43
  if (close && close[1][0] === fenceChar && close[1].length >= fenceLen) {
39
44
  fenceChar = null;
40
45
  fenceLen = 0;
41
46
  }
42
- return fill(line);
43
- }).join(`
44
- `);
47
+ return { line, inCode: true };
48
+ });
49
+ return { lines, unterminated: fenceChar !== null };
50
+ }
51
+ function hasUnterminatedFence(body) {
52
+ return scanFencedCode(body.replace(/\r\n?/g, `
53
+ `)).unterminated;
45
54
  }
46
55
  var LIST_MARKER = /^ {0,3}(?:[-*+]|\d{1,9}[.)])(?:\s|$)/;
47
56
  function indentWidth(line) {
@@ -84,88 +93,7 @@ function maskIndentedCode(body, fill) {
84
93
  return out.join(`
85
94
  `);
86
95
  }
87
- function anchoredRegion(body, field) {
88
- const masked = maskCode(body);
89
- const start = new RegExp(`<!--\\s*AEG:${field}:START\\s*-->`).exec(masked);
90
- if (!start)
91
- return null;
92
- const afterStart = start.index + start[0].length;
93
- const end = new RegExp(`<!--\\s*AEG:${field}:END\\s*-->`).exec(masked.slice(afterStart));
94
- if (!end)
95
- return null;
96
- return body.slice(afterStart, afterStart + end.index);
97
- }
98
- // ../../packages/aeg-core/src/parse-registry.ts
99
- function parseRegistry(md) {
100
- const rows = readMarkdownTable(md, /^##\s+Registry\b/i);
101
- const projects = [];
102
- for (const row of rows) {
103
- if (row.length < 4)
104
- continue;
105
- const name = stripBackticks(row[0] ?? "").trim();
106
- const path = stripBackticks(row[1] ?? "").trim();
107
- const specsPath = stripBackticks(row[2] ?? "").trim();
108
- const stateCell = (row[3] ?? "").trim();
109
- if (!name || !path || !specsPath)
110
- continue;
111
- projects.push({
112
- name,
113
- path,
114
- specsPath,
115
- statePath: parseStateCell(stateCell)
116
- });
117
- }
118
- return projects;
119
- }
120
- function parseStateCell(cell) {
121
- if (!cell)
122
- return null;
123
- const stripped = stripBackticks(cell).trim();
124
- if (/^[\w./@-]+\/?$/.test(stripped) && cell.includes("`")) {
125
- return stripped;
126
- }
127
- return null;
128
- }
129
- function stripBackticks(s) {
130
- return s.replace(/`/g, "");
131
- }
132
- function readMarkdownTable(md, headingMatcher) {
133
- const lines = md.split(/\r?\n/);
134
- let i = 0;
135
- for (;i < lines.length; i++) {
136
- if (headingMatcher.test(lines[i] ?? "")) {
137
- i++;
138
- break;
139
- }
140
- }
141
- if (i >= lines.length)
142
- return [];
143
- for (;i < lines.length; i++) {
144
- if ((lines[i] ?? "").trim().startsWith("|"))
145
- break;
146
- }
147
- if (i + 1 >= lines.length)
148
- return [];
149
- i += 2;
150
- const out = [];
151
- for (;i < lines.length; i++) {
152
- const trimmed = (lines[i] ?? "").trim();
153
- if (!trimmed.startsWith("|"))
154
- break;
155
- out.push(splitTableRow(trimmed));
156
- }
157
- return out;
158
- }
159
- function splitTableRow(row) {
160
- const PLACEHOLDER = "\x00PIPE\x00";
161
- const escaped = row.replace(/\\\|/g, PLACEHOLDER);
162
- const parts = escaped.split("|").map((s) => s.trim());
163
- if (parts.length && parts[0] === "")
164
- parts.shift();
165
- if (parts.length && parts[parts.length - 1] === "")
166
- parts.pop();
167
- return parts.map((p) => p.split(PLACEHOLDER).join("|"));
168
- }
96
+
169
97
  // ../../packages/aeg-forge-state/src/parse-rationale-deps.ts
170
98
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
171
99
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
@@ -463,11 +391,37 @@ function findTrancheSlug(names) {
463
391
  var TITLE_PATTERN = /^\[([^\]]+)]\s*(\S+)\s*—\s*(.+)$/;
464
392
  var PROJECT_SLUG = /^[a-z0-9][a-z0-9-]*$/i;
465
393
  var PROJECT_FIELD = /^\s*(?:\*\*)?Project(?:\(s\))?(?:\*\*)?\s*:\s*(?:\*\*)?\s*(.+)$/im;
394
+ var VALUE_EDGE_MARKUP = /^[`.;\s]+|[`.;\s]+$/g;
395
+ function unwrapValue(raw) {
396
+ return raw.replace(/\*\*/g, "").replace(VALUE_EDGE_MARKUP, "");
397
+ }
398
+ function projectFieldFromBody(body) {
399
+ const m = stripCode(body, { inlineSpans: "keep" }).match(PROJECT_FIELD);
400
+ if (m)
401
+ return parseFieldValue(m[1] ?? "");
402
+ if (hasUnterminatedFence(body)) {
403
+ const raw = body.match(PROJECT_FIELD);
404
+ if (raw)
405
+ return { declared: true, names: [], unparsed: [(raw[1] ?? "").trim()], unreadable: true };
406
+ }
407
+ return { declared: false, names: [], unparsed: [], unreadable: false };
408
+ }
409
+ function parseFieldValue(value) {
410
+ const names = [];
411
+ const unparsed = [];
412
+ for (const raw of value.split(",")) {
413
+ const name = unwrapValue(raw);
414
+ if (name.length === 0)
415
+ continue;
416
+ if (PROJECT_SLUG.test(name))
417
+ names.push(name);
418
+ else
419
+ unparsed.push(raw.trim());
420
+ }
421
+ return { declared: true, names: [...new Set(names)], unparsed, unreadable: false };
422
+ }
466
423
  function projectsFromBody(body) {
467
- const m = body.match(PROJECT_FIELD);
468
- if (!m)
469
- return [];
470
- return (m[1] ?? "").split(",").map((s) => s.trim()).filter((s) => PROJECT_SLUG.test(s));
424
+ return projectFieldFromBody(body).names;
471
425
  }
472
426
  function taskFromIssue(issue) {
473
427
  const m = issue.title.match(TITLE_PATTERN);
@@ -509,8 +463,8 @@ function tasksFromIssues(issues) {
509
463
  }
510
464
  return tasks.sort((a, b) => compareTaskIds(a.id, b.id));
511
465
  }
512
- async function listTasksForSlugAsync(owner, repo, slug) {
513
- return tasksFromIssues(await ghIssueListByAnyLabelAsync(owner, repo, [trancheLabel(slug)]));
466
+ async function fetchTrancheIssuesAsync(owner, repo, slug) {
467
+ return ghIssueListByAnyLabelAsync(owner, repo, [trancheLabel(slug)]);
514
468
  }
515
469
  function resolveTaskIssueRef(title, labels) {
516
470
  const m = title.match(TITLE_PATTERN);
@@ -526,17 +480,20 @@ function resolveTaskIssueRef(title, labels) {
526
480
  }
527
481
 
528
482
  // ../../packages/aeg-forge-state/src/derive-from-forge.ts
529
- async function deriveTrancheFromForge(owner, repo, slug, known) {
530
- const milestone = known ?? findMilestoneForSlug(owner, repo, slug);
531
- const tasks = await listTasksForSlugAsync(owner, repo, slug);
483
+ function trancheFromIssues(slug, issues, known) {
532
484
  return {
533
485
  name: slug,
534
- lifecycle: milestone?.lifecycle ?? "active",
535
- goal: milestone?.goal ?? "",
536
- tasks,
486
+ lifecycle: known?.lifecycle ?? "active",
487
+ goal: known?.goal ?? "",
488
+ tasks: tasksFromIssues(issues),
537
489
  backlog: []
538
490
  };
539
491
  }
492
+ async function deriveTrancheFromForge(owner, repo, slug, known) {
493
+ const milestone = known ?? findMilestoneForSlug(owner, repo, slug);
494
+ const issues = await fetchTrancheIssuesAsync(owner, repo, slug);
495
+ return trancheFromIssues(slug, issues, milestone);
496
+ }
540
497
  // ../../node_modules/universal-user-agent/index.js
541
498
  function getUserAgent() {
542
499
  if (typeof navigator === "object" && "userAgent" in navigator) {
@@ -1456,6 +1413,96 @@ var systemEnv3 = {
1456
1413
  ...process.env,
1457
1414
  PATH: [process.env.PATH, "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"].filter(Boolean).join(":")
1458
1415
  };
1416
+ // ../../packages/aeg-core/src/anchored-region.ts
1417
+ function anchoredRegionBounds(body, field) {
1418
+ const masked = maskCode(body);
1419
+ const start = new RegExp(`<!--\\s*AEG:${field}:START\\s*-->`).exec(masked);
1420
+ if (!start)
1421
+ return null;
1422
+ const innerStart = start.index + start[0].length;
1423
+ const end = new RegExp(`<!--\\s*AEG:${field}:END\\s*-->`).exec(masked.slice(innerStart));
1424
+ if (!end)
1425
+ return null;
1426
+ const innerEnd = innerStart + end.index;
1427
+ return { outerStart: start.index, outerEnd: innerEnd + end[0].length, innerStart, innerEnd };
1428
+ }
1429
+ function anchoredRegion(body, field) {
1430
+ const bounds = anchoredRegionBounds(body, field);
1431
+ if (!bounds)
1432
+ return null;
1433
+ return body.slice(bounds.innerStart, bounds.innerEnd);
1434
+ }
1435
+ // ../../packages/aeg-core/src/parse-registry.ts
1436
+ function parseRegistry(md) {
1437
+ const rows = readMarkdownTable(md, /^##\s+Registry\b/i);
1438
+ const projects = [];
1439
+ for (const row of rows) {
1440
+ if (row.length < 4)
1441
+ continue;
1442
+ const name = stripBackticks(row[0] ?? "").trim();
1443
+ const path = stripBackticks(row[1] ?? "").trim();
1444
+ const specsPath = stripBackticks(row[2] ?? "").trim();
1445
+ const stateCell = (row[3] ?? "").trim();
1446
+ if (!name || !path || !specsPath)
1447
+ continue;
1448
+ projects.push({
1449
+ name,
1450
+ path,
1451
+ specsPath,
1452
+ statePath: parseStateCell(stateCell)
1453
+ });
1454
+ }
1455
+ return projects;
1456
+ }
1457
+ function parseStateCell(cell) {
1458
+ if (!cell)
1459
+ return null;
1460
+ const stripped = stripBackticks(cell).trim();
1461
+ if (/^[\w./@-]+\/?$/.test(stripped) && cell.includes("`")) {
1462
+ return stripped;
1463
+ }
1464
+ return null;
1465
+ }
1466
+ function stripBackticks(s) {
1467
+ return s.replace(/`/g, "");
1468
+ }
1469
+ function readMarkdownTable(md, headingMatcher) {
1470
+ const lines = md.split(/\r?\n/);
1471
+ let i = 0;
1472
+ for (;i < lines.length; i++) {
1473
+ if (headingMatcher.test(lines[i] ?? "")) {
1474
+ i++;
1475
+ break;
1476
+ }
1477
+ }
1478
+ if (i >= lines.length)
1479
+ return [];
1480
+ for (;i < lines.length; i++) {
1481
+ if ((lines[i] ?? "").trim().startsWith("|"))
1482
+ break;
1483
+ }
1484
+ if (i + 1 >= lines.length)
1485
+ return [];
1486
+ i += 2;
1487
+ const out = [];
1488
+ for (;i < lines.length; i++) {
1489
+ const trimmed = (lines[i] ?? "").trim();
1490
+ if (!trimmed.startsWith("|"))
1491
+ break;
1492
+ out.push(splitTableRow(trimmed));
1493
+ }
1494
+ return out;
1495
+ }
1496
+ function splitTableRow(row) {
1497
+ const PLACEHOLDER = "\x00PIPE\x00";
1498
+ const escaped = row.replace(/\\\|/g, PLACEHOLDER);
1499
+ const parts = escaped.split("|").map((s) => s.trim());
1500
+ if (parts.length && parts[0] === "")
1501
+ parts.shift();
1502
+ if (parts.length && parts[parts.length - 1] === "")
1503
+ parts.pop();
1504
+ return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1505
+ }
1459
1506
  // ../../packages/aeg-core/src/state-machine-model.ts
1460
1507
  var FORGE_FACT_INPUTS = [
1461
1508
  {
@@ -1959,23 +2006,65 @@ function checkIssueRationale(body) {
1959
2006
  function isTaskIssueLabelSet(labels) {
1960
2007
  return hasLabel("tranche", labels);
1961
2008
  }
2009
+ function isControlCodePoint(codePoint) {
2010
+ return codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
2011
+ }
2012
+ function isDisplayControlCodePoint(codePoint) {
2013
+ return codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
2014
+ }
2015
+ var MESSAGE_VALUE_COUNT_MAX = 5;
2016
+ function residueForMessage(values) {
2017
+ const shown = values.slice(0, MESSAGE_VALUE_COUNT_MAX).map((v) => `\`${forMessage(v)}\``);
2018
+ const rest = values.length - shown.length;
2019
+ return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
2020
+ }
2021
+ var MESSAGE_VALUE_MAX = 64;
2022
+ function forMessage(value) {
2023
+ const kept = [];
2024
+ for (const ch of value.replace(/\s+/g, " ")) {
2025
+ const codePoint = ch.codePointAt(0) ?? 0;
2026
+ if (isControlCodePoint(codePoint) || isDisplayControlCodePoint(codePoint))
2027
+ continue;
2028
+ kept.push(ch);
2029
+ }
2030
+ const cleaned = kept.join("").trim();
2031
+ if (cleaned.length === 0)
2032
+ return "(unprintable)";
2033
+ const points = Array.from(cleaned);
2034
+ return points.length > MESSAGE_VALUE_MAX ? `${points.slice(0, MESSAGE_VALUE_MAX).join("")}…` : cleaned;
2035
+ }
1962
2036
  function checkProjectsRegistered(body, _labels, registeredNames) {
1963
2037
  if (registeredNames.length === 0)
1964
2038
  return { status: "pass", errors: [] };
1965
- const known = new Set(registeredNames.map((n) => n.trim()));
1966
- const unregistered = projectsFromBody(body).filter((p) => !known.has(p));
1967
- if (unregistered.length === 0)
2039
+ const field = projectFieldFromBody(body);
2040
+ if (!field.declared)
1968
2041
  return { status: "pass", errors: [] };
1969
- const caseHints = unregistered.map((p) => {
1970
- const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
1971
- return row ? `\`${p}\` differs from the registered \`${row}\` only in case` : null;
1972
- }).filter((h) => h !== null);
1973
- return {
1974
- status: "fail",
1975
- errors: [
1976
- `issue-validation project registry: the \`**Project:**\` field declares ${unregistered.join(", ")} no such row in \`.vinaya/projects.md\`, which is the authority for valid project names (registered: ${[...registeredNames].join(", ")}). Fix the name, or register the project with \`vinaya init product <name> --path <folder>\` first; an unregistered project has no specs to read and no per-project state to update.${caseHints.length > 0 ? ` Note: ${caseHints.join("; ")} project names are matched exactly, because every downstream consumer compares them literally.` : ""} This reads the same field \`projectsFromBody\` derives the task's project from, so a name here that is not a row is a task that resolves to a project that does not exist.`
1977
- ]
1978
- };
2042
+ const known = new Set(registeredNames.map((n) => n.trim()));
2043
+ const registeredList = [...registeredNames].map(forMessage).join(", ");
2044
+ const errors = [];
2045
+ if (field.unreadable) {
2046
+ return {
2047
+ status: "fail",
2048
+ errors: [
2049
+ `issue-validation project registry: the body has an unterminated code fence, so its \`**Project:**\` field could not be read reliably the fence runs to end of body (CommonMark, and how the forge renders it), swallowing everything after it including the foot field where the declaration lives by convention. Read from the raw body the field says ${residueForMessage(field.unparsed) || "(nothing)"}, but a line inside a swallowed region may be a quoted example rather than a real declaration, so this gate refuses rather than guessing which. Balance the fences every opening run of backticks or tildes needs a closing run at least as long and the field reads normally.`
2050
+ ]
2051
+ };
2052
+ }
2053
+ const unregistered = field.names.filter((p) => !known.has(p));
2054
+ if (unregistered.length > 0) {
2055
+ const caseHints = unregistered.map((p) => {
2056
+ const row = [...known].find((k) => k.toLowerCase() === p.toLowerCase());
2057
+ return row ? `\`${forMessage(p)}\` differs from the registered \`${forMessage(row)}\` only in case` : null;
2058
+ }).filter((h) => h !== null);
2059
+ errors.push(`issue-validation project registry: the \`**Project:**\` field declares ${unregistered.map(forMessage).join(", ")} — no such row in \`.vinaya/projects.md\`, which is the authority for valid project names (registered: ${registeredList}). Fix the name, or register the project with \`vinaya init product <name> --path <folder>\` first; an unregistered project has no specs to read and no per-project state to update.${caseHints.length > 0 ? ` Note: ${caseHints.join("; ")} — project names are matched exactly, because every downstream consumer compares them literally.` : ""} This reads the same field \`projectsFromBody\` derives the task's project from, so a name here that is not a row is a task that resolves to a project that does not exist.`);
2060
+ }
2061
+ if (field.names.length === 0) {
2062
+ const residue = field.unparsed.length > 0 ? ` — ${residueForMessage(field.unparsed)}` : " — the field is empty";
2063
+ errors.push(`issue-validation project registry: the \`**Project:**\` field is present but resolves to no project name${residue} (registered: ${registeredList}). A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); prose, a parenthetical, or a sentence in this field resolves to no project at all, and this gate cannot check a name it never receives — which is how a declaration like this used to pass. Write the registered name on its own, or register the project with \`vinaya init product <name> --path <folder>\` first. If the task genuinely touches no registered project, omit the field rather than explaining its absence inside it — \`checkIssueRationale\` already requires the \`Project(s) + blast radius\` narrative field for that.`);
2064
+ } else if (field.unparsed.length > 0) {
2065
+ errors.push(`issue-validation project registry: the \`**Project:**\` field declares a value that is not a project name — ${residueForMessage(field.unparsed)} (registered: ${registeredList}). The rest of the field parsed, so this is a name the gate silently could not check rather than a field it could not read at all. A project name is a slug (\`[a-z0-9][a-z0-9-]*\`, matched exactly); write it on its own, or drop it if it names no project.`);
2066
+ }
2067
+ return errors.length > 0 ? { status: "fail", errors } : { status: "pass", errors: [] };
1979
2068
  }
1980
2069
 
1981
2070
  // ../../packages/aeg-core/src/coherence-checks.ts