@attalabs/vinaya 0.39.0 → 0.41.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 (186) hide show
  1. package/README.md +9 -9
  2. package/aeg-root/contracts/developer-reviewer.md +2 -2
  3. package/aeg-root/contracts/planner-developer.md +5 -5
  4. package/aeg-root/enforcement.md +22 -22
  5. package/aeg-root/process.md +4 -4
  6. package/aeg-root/roles/archivist.md +1 -1
  7. package/aeg-root/roles/developer/reference.md +7 -1
  8. package/aeg-root/roles/developer.md +1 -1
  9. package/aeg-root/roles/planner/reference.md +18 -5
  10. package/aeg-root/roles/principal.md +1 -1
  11. package/aeg-root/roles/reviewer.md +3 -3
  12. package/aeg-root/roles/security.md +4 -4
  13. package/aeg-root/roles/tranche-archivist.md +2 -2
  14. package/aeg-root/skills/aeg/SKILL.md +1 -1
  15. package/aeg-root/state-machine.md +10 -15
  16. package/aeg-root/templates/brief-template.md +5 -2
  17. package/aeg-root/templates/decision-record-template.md +38 -0
  18. package/aeg-root/templates/issue-rationale-template.md +1 -1
  19. package/aeg-root/tranche-model.md +1 -1
  20. package/dist/checks/bin/check-body-bare-digits.js +1974 -354
  21. package/dist/checks/bin/check-branch-topology.js +1296 -243
  22. package/dist/checks/bin/check-brief-shape.js +2038 -460
  23. package/dist/checks/bin/check-changeset-coverage.js +2411 -564
  24. package/dist/checks/bin/check-ci-shard-coverage.js +12391 -15
  25. package/dist/checks/bin/check-closes-n.js +1296 -243
  26. package/dist/checks/bin/check-coherence.js +1914 -1155
  27. package/dist/checks/bin/check-dead-branch-push.js +1242 -230
  28. package/dist/checks/bin/check-dispatch-readiness.js +2222 -460
  29. package/dist/checks/bin/check-doc-claims.js +2233 -260
  30. package/dist/checks/bin/check-doc-coverage-push.js +2436 -550
  31. package/dist/checks/bin/check-doc-coverage.js +2434 -552
  32. package/dist/checks/bin/check-doctrine-no-procedures.js +1776 -353
  33. package/dist/checks/bin/check-doctrine-portability.js +2408 -561
  34. package/dist/checks/bin/check-evidence-fresh.js +2370 -508
  35. package/dist/checks/bin/check-exec-bits.js +2407 -560
  36. package/dist/checks/bin/check-first-push-dispatch.js +1984 -380
  37. package/dist/checks/bin/check-issue-assignment.js +712 -170
  38. package/dist/checks/bin/check-issue-milestone-attach.js +1233 -230
  39. package/dist/checks/bin/check-issue-objectives-numbering.js +1769 -346
  40. package/dist/checks/bin/check-issue-parts-coverage.js +1233 -230
  41. package/dist/checks/bin/check-issue-surface-globs.js +1926 -378
  42. package/dist/checks/bin/check-issue-title-grammar.js +1233 -230
  43. package/dist/checks/bin/check-issue-tranche-label.js +702 -170
  44. package/dist/checks/bin/check-main-branch-refusal.js +1245 -232
  45. package/dist/checks/bin/check-no-disk-state.js +1233 -230
  46. package/dist/checks/bin/check-pr-premise-reassert.js +1769 -346
  47. package/dist/checks/bin/check-pr-report-density.js +1233 -230
  48. package/dist/checks/bin/check-principal-test-plan-wait.js +2489 -259
  49. package/dist/checks/bin/check-quoted-command.js +2391 -544
  50. package/dist/checks/bin/check-reader-resolvable-prose.js +2437 -564
  51. package/dist/checks/bin/check-registry-gates.js +1380 -296
  52. package/dist/checks/bin/check-retired-vocabulary.js +2416 -550
  53. package/dist/checks/bin/check-review-gate.js +2073 -371
  54. package/dist/checks/bin/check-single-plan-pr.js +1297 -235
  55. package/dist/checks/bin/check-surface-scope.js +1531 -252
  56. package/dist/checks/bin/check-test-plan.js +2487 -258
  57. package/dist/checks/bin/check-token-collection-wired.js +1233 -230
  58. package/dist/checks/bin/check-workspace-escape.js +2408 -561
  59. package/dist/checks/bin/verify-coherence.js +597 -97
  60. package/dist/checks/bin/verify-dispatch.js +632 -152
  61. package/dist/checks/bin/verify-docs.js +642 -132
  62. package/dist/index.js +25948 -16630
  63. package/dist/lib/pre-push-cache-test-run.js +1813 -297
  64. package/dist/lib/pre-push-changed-files.js +65 -19
  65. package/dist/lib/pre-push-mode.js +466 -0
  66. package/dist/lib/pre-push-progress-dir.js +4205 -0
  67. package/dist/lib/pre-push-record-tests.js +446 -0
  68. package/dist/lib/pre-push-select-tests.js +2353 -632
  69. package/dist/lib/push-progress-observer.js +4213 -0
  70. package/package.json +22 -5
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +17 -3
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +73 -30
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +29 -3
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +35 -18
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -1
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/entry-point.ts +27 -0
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +3 -5
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +96 -9
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +809 -106
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +2 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +6 -4
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +53 -93
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +32 -13
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  114. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +2 -2
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  156. 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
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0sxadt2._.js +13 -0
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +57 -0
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1ug9syi._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  178. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{33rszkngkuoko.js → 0x7u6si-ai179.js} +1 -1
  179. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{06_55xbp7rcbi.js → 2fu7mfsj4oima.js} +1 -1
  180. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2brkwv169ygep.js → 34b4ruddunn3q.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +0 -57
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__19jyp3m._.js +0 -13
  184. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
  185. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
  186. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{D3LiJNIq5FWZxen7CpOSJ → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@attalabs/vinaya",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Vinaya — Agentic Engineering Harness. Deterministic checks every AI coding agent must satisfy before merge.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-ALv2",
7
7
  "author": "Daniel Estevez",
8
8
  "bin": {
9
- "vinaya": "./dist/index.js",
10
- "vinaya-select-tests": "./dist/lib/pre-push-select-tests.js",
11
- "vinaya-changed-files": "./dist/lib/pre-push-changed-files.js",
12
- "vinaya-cache-test-run": "./dist/lib/pre-push-cache-test-run.js"
9
+ "vinaya": "dist/index.js",
10
+ "vinaya-select-tests": "dist/lib/pre-push-select-tests.js",
11
+ "vinaya-changed-files": "dist/lib/pre-push-changed-files.js",
12
+ "vinaya-cache-test-run": "dist/lib/pre-push-cache-test-run.js",
13
+ "vinaya-record-tests": "dist/lib/pre-push-record-tests.js",
14
+ "vinaya-push-mode": "dist/lib/pre-push-mode.js",
15
+ "vinaya-push-progress": "dist/lib/pre-push-progress-dir.js",
16
+ "vinaya-push-progress-observer": "dist/lib/push-progress-observer.js"
13
17
  },
14
18
  "files": [
15
19
  "dist",
@@ -51,14 +55,27 @@
51
55
  },
52
56
  "dependencies": {
53
57
  "gray-matter": "^4.0.3",
58
+ "safe-regex2": "5.1.1",
54
59
  "zod": "3.25.76"
55
60
  },
56
61
  "devDependencies": {
62
+ "@atta/adapter-langgraph": "file:tests/fixtures/atta-engine/atta-adapter-langgraph-0.0.1.tgz",
63
+ "@atta/agents": "file:tests/fixtures/atta-engine/atta-agents-0.1.0.tgz",
64
+ "@atta/engine": "file:tests/fixtures/atta-engine/atta-engine-0.0.1.tgz",
65
+ "@atta/executor-agent-spawn": "file:tests/fixtures/atta-engine/atta-executor-agent-spawn-0.1.1.tgz",
66
+ "@atta/models": "file:tests/fixtures/atta-engine/atta-models-0.1.0.tgz",
57
67
  "@attalabs/aeg-core": "workspace:*",
58
68
  "@attalabs/aeg-forge-state": "workspace:*",
69
+ "@attalabs/aeg-types": "workspace:*",
59
70
  "@atta/typescript-config": "workspace:*",
60
71
  "@attalabs/vinaya-sources": "workspace:*",
61
72
  "@types/bun": "latest",
73
+ "@types/react": "^19.0.0",
62
74
  "typescript": "^5.5.0"
75
+ },
76
+ "overrides": {
77
+ "@atta/agents": "file:tests/fixtures/atta-engine/atta-agents-0.1.0.tgz",
78
+ "@atta/engine": "file:tests/fixtures/atta-engine/atta-engine-0.0.1.tgz",
79
+ "@atta/models": "file:tests/fixtures/atta-engine/atta-models-0.1.0.tgz"
63
80
  }
64
81
  }
@@ -39,7 +39,7 @@
39
39
  * **Tier:** 1
40
40
  * <!-- AEG:TIER:END -->
41
41
  *
42
- * Deliberately minimal: seven field names, one shape. This is a delimiting
42
+ * Deliberately minimal: eight field names, one shape. This is a delimiting
43
43
  * convention, not a metadata DSL; resist adding structure to it.
44
44
  *
45
45
  * `EVIDENCE` (fix/pr-report-emitter) differs from the other five in one way:
@@ -52,13 +52,27 @@
52
52
  import { maskCode } from '@attalabs/aeg-forge-state/strip-code'
53
53
 
54
54
  /**
55
- * The six gate-read fields with an anchored home. A `TOKENS` entry belonged
55
+ * The gate-read fields with an anchored home. `BEYOND-SURFACE`, like
56
+ * `EVIDENCE`, is never hand-typed: the review-loop driver rewrites it on every
57
+ * pull-request body write with each changed path the task's Surface does not
58
+ * cover, and the `surface-scope` check reads it. A `TOKENS` entry belonged
56
59
  * here while a pull-request body carried a token table; that table is retired
57
60
  * — token use is recorded as the Vinaya log's own `usage` event — so nothing
58
61
  * writes or reads that anchor any more. An older body that still carries the
59
62
  * pair keeps it: no reader here resolves it, and no writer touches it.
63
+ * `LIVE` is the driver's own record of its `[live]` Test plan runs
64
+ * (`live-record.ts`), never hand-typed either; the Test Plan gate reads it.
60
65
  */
61
- export const ANCHOR_FIELDS = ['CLOSES', 'PROJECT', 'TIER', 'PREMISE', 'TEST-PLAN', 'EVIDENCE'] as const
66
+ export const ANCHOR_FIELDS = [
67
+ 'CLOSES',
68
+ 'PROJECT',
69
+ 'TIER',
70
+ 'PREMISE',
71
+ 'TEST-PLAN',
72
+ 'EVIDENCE',
73
+ 'BEYOND-SURFACE',
74
+ 'LIVE'
75
+ ] as const
62
76
 
63
77
  export type AnchorField = (typeof ANCHOR_FIELDS)[number]
64
78
 
@@ -255,8 +255,9 @@ export type BriefFacts = {
255
255
  /**
256
256
  * The Issue's `## Test plan` section (`issue-validation.ts`'s
257
257
  * `parseIssueTestPlan`), copied into §9 verbatim. `{ kind: 'commands',
258
- * lines: [], principal: [] }` is the absent-section sentinel — a real
259
- * `commands` plan always carries at least one line or one principal item.
258
+ * lines: [], principal: [], live: [] }` is the absent-section sentinel — a
259
+ * real `commands` plan always carries at least one line, one principal item
260
+ * or one live item.
260
261
  */
261
262
  testPlan: IssueTestPlan
262
263
  /**
@@ -351,7 +352,12 @@ export type BriefFacts = {
351
352
  export type LocalGateCommands = {
352
353
  /** e.g. `bun packages/aeg-core/bin/verify-dispatch.ts`, or `null`. */
353
354
  dispatchReadiness: string | null
354
- /** e.g. `bun packages/aeg-core/bin/verify-docs.ts`, or `null`. */
355
+ /**
356
+ * e.g. `bun packages/aeg-core/bin/verify-docs.ts`, or `null`. No longer
357
+ * rendered: the documentation gate is the controller's (`run_checks`, CI),
358
+ * so §12 names no hand-run pre-open command. Still a fact the caller
359
+ * states, so the caller's own shape is unchanged.
360
+ */
355
361
  docCoverage: string | null
356
362
  }
357
363
 
@@ -459,8 +465,8 @@ function renderSection2(facts: BriefFacts): string {
459
465
  const branch = developerBranchForFacts(facts)
460
466
  const identityLine =
461
467
  facts.trancheSlug !== null
462
- ? `- **Tranche:** \`${facts.trancheSlug}\`, task ${facts.taskId}, Issue #${facts.issue}. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm dispatch readiness at your own Step 0, with the command §5 names.`
463
- : `- **Backlog Issue:** #${facts.issue}, no tranche. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`. Confirm dispatch readiness at your own Step 0, with the command §5 names.`
468
+ ? `- **Tranche:** \`${facts.trancheSlug}\`, task ${facts.taskId}, Issue #${facts.issue}. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`.`
469
+ : `- **Backlog Issue:** #${facts.issue}, no tranche. Branch \`${branch}\`. \`Depends-on: ${depends}\`, \`Conflicts-with: ${conflicts}\`.`
464
470
  const lines = [
465
471
  '## 2. Context — read before doing anything',
466
472
  '',
@@ -508,8 +514,18 @@ export function extractSourceRevision(briefText: string): string | null {
508
514
  return m ? (m[1] as string) : null
509
515
  }
510
516
 
517
+ /**
518
+ * The line §3 carries for a single-fix Issue — one with no tranche — that
519
+ * declares no Dependency rationale: a single fix has no siblings to relate to,
520
+ * so the render states the absence of edges rather than refusing for prose the
521
+ * Issue gate no longer asks of it.
522
+ */
523
+ export const SINGLE_FIX_NO_EDGES_LINE =
524
+ '**Dependency rationale** — none: this single-fix Issue declares no `Depends-on` or `Conflicts-with` edge.'
525
+
511
526
  function renderSection3(facts: BriefFacts): string {
512
- return ['## 3. Technical dependencies', '', `${facts.rationale.dependencyRationale}`].join('\n')
527
+ const dependencies = facts.rationale.dependencyRationale ?? SINGLE_FIX_NO_EDGES_LINE
528
+ return ['## 3. Technical dependencies', '', dependencies].join('\n')
513
529
  }
514
530
 
515
531
  // O6: the nearest ancestor directory of `path` that is itself
@@ -543,6 +559,14 @@ function nearestTestDir(path: string): string {
543
559
  return path
544
560
  }
545
561
 
562
+ /**
563
+ * Appended to §4's out-of-surface line: what happens to a change the Surface
564
+ * does not cover. Names no path, so the consumer-tests scan of §4 never reads
565
+ * a package in it.
566
+ */
567
+ export const BEYOND_SURFACE_RECORDING_RULE =
568
+ " — a change there, or to any path no Surface `in:` glob covers, is still published: the review-loop driver records each such path in the pull request body's beyond-Surface block, and the reviewers judge it like any change."
569
+
546
570
  function renderSection4(facts: BriefFacts): string {
547
571
  const created = facts.surfaceFiles.filter((f) => f.sha256 === null).map((f) => f.path)
548
572
  const modified = facts.surfaceFiles.filter((f) => f.sha256 !== null).map((f) => f.path)
@@ -578,11 +602,15 @@ function renderSection4(facts: BriefFacts): string {
578
602
  : '- (none named)'
579
603
 
580
604
  const createdBlock = created.length > 0 ? bulletList(created) : '- (none — every surface file already exists)'
605
+ // The recording rule rides on the same line: a change beyond the Surface is
606
+ // published, never refused — the driver records it in the pull request
607
+ // body and the reviewers judge it like any change.
581
608
  const outOfSurfaceLine =
582
609
  '**Out of surface:** ' +
583
610
  (facts.surface.out.length > 0
584
611
  ? facts.surface.out.join(', ')
585
- : "(none named — the Issue's `## Surface` `out:` line is empty)")
612
+ : "(none named — the Issue's `## Surface` `out:` line is empty)") +
613
+ BEYOND_SURFACE_RECORDING_RULE
586
614
  const premisePinsBlock = bulletList(
587
615
  facts.surfaceFiles
588
616
  .filter((f): f is SurfaceFileFact & { sha256: string } => f.sha256 !== null)
@@ -716,6 +744,20 @@ const RENDER_CHECK_NAME_RE = /\bcheck-[a-z0-9-]+(?:\.ts)?\b/
716
744
  const RENDER_FORGE_WRITE_COMMAND_RE =
717
745
  /\bgh\s+(?:pr|issue)\s+(?:create|merge|close|comment|edit|review)\b|\bgit\s+push\b|\bvinaya\s+pr\s+(?:create|report\s+--write)\b/i
718
746
 
747
+ /**
748
+ * The one publication rule the brief states, in §6's heading and in full in
749
+ * §12. A publication is one `publish_changes` call: a single commit of the
750
+ * whole worktree plus the push that runs the affected suite
751
+ * (`developer-publication.ts`, `apps/cli`) — so publishing per Part would run
752
+ * that suite once per Part, where §6's own Part lines already speak of one push.
753
+ * The driver's own re-ask prompts (no commit yet, pushed with no pull request,
754
+ * a refused push, a merge conflict) each ask for exactly the publication this
755
+ * rule already allows.
756
+ */
757
+ const PUBLICATION_RULE_HEADING = 'publish once with `publish_changes` when every Part is done, then `open_pull_request`'
758
+ const PUBLICATION_RULE =
759
+ '- Publish once, with `publish_changes`, when every Part is done; then open the pull request with `open_pull_request`. Publish again only to answer review findings or a red gate — a refused hook, a failing check, a merge conflict.'
760
+
719
761
  /**
720
762
  * §6 — one numbered Part per `IssuePart` (facts.parts), citation
721
763
  * reconstructed verbatim per `renderPartCitation`. Files stay grouped by
@@ -778,11 +820,7 @@ function renderSection6(facts: BriefFacts): string {
778
820
  return lines.join('\n')
779
821
  })
780
822
 
781
- return [
782
- '## 6. Numbered parts — call `publish_changes` after EACH part; `open_pull_request` once the first part is published',
783
- '',
784
- ...rendered
785
- ].join('\n')
823
+ return [`## 6. Numbered parts — ${PUBLICATION_RULE_HEADING}`, '', ...rendered].join('\n')
786
824
  }
787
825
 
788
826
  function renderSection7(section7Pointers: string[]): string {
@@ -797,19 +835,6 @@ function renderSection7(section7Pointers: string[]): string {
797
835
  return lines.join('\n')
798
836
  }
799
837
 
800
- /**
801
- * The pre-open documentation gate, as one command the reader can run — cited
802
- * by both §8 and §12, so it is written once. `check doc-coverage` is the
803
- * portable form; the authoring repository's fuller `--pr` derivation is
804
- * appended only when `facts` says that repository ships one.
805
- */
806
- function docGateCommand(facts: BriefFacts): string {
807
- const portable = `\`PR_BODY="$(cat <body-file>)" ${facts.cliInvocation} check doc-coverage\` green`
808
- return facts.localGateCommands.docCoverage !== null
809
- ? `${portable} (this repository also ships \`PR_BODY="$(cat <body-file>)" ${facts.localGateCommands.docCoverage} --pr\`, which additionally evaluates the spec-status and code-requires-docs contracts)`
810
- : portable
811
- }
812
-
813
838
  function renderSection8(facts: BriefFacts): string {
814
839
  return [
815
840
  '## 8. Verification before claiming done',
@@ -850,6 +875,14 @@ function safeFence(lines: string[]): string {
850
875
  return '`'.repeat(Math.max(3, longest + 1))
851
876
  }
852
877
 
878
+ /** A `[live]` command as a code span one backtick longer than any run inside it, padded when it starts or ends with a backtick — `parseIssueTestPlan` strips exactly this span back off. */
879
+ function liveCodeSpan(cmd: string): string {
880
+ const longest = Math.max(0, ...(cmd.match(/`+/g) ?? []).map((run) => run.length))
881
+ const ticks = '`'.repeat(longest + 1)
882
+ const pad = cmd.startsWith('`') || cmd.endsWith('`') ? ' ' : ''
883
+ return `${ticks}${pad}${cmd}${pad}${ticks}`
884
+ }
885
+
853
886
  /**
854
887
  * §9 — copied from the Issue's own `## Test plan` section (`facts.testPlan`),
855
888
  * never re-derived from the surface file list. `renderBrief`'s missing-fact
@@ -869,14 +902,18 @@ function renderSection9(facts: BriefFacts): string {
869
902
  }
870
903
 
871
904
  const principalLines = facts.testPlan.principal.map((p) => `- [ ] **[principal]** ${p}`)
905
+ // A `[live]` item is never a checkbox: the review loop runs it and records
906
+ // the outcome on the pull request, so there is no box for anyone to tick.
907
+ const liveLines = facts.testPlan.live.map((cmd) => `- **[live]** ${liveCodeSpan(cmd)}`)
872
908
  const fence = safeFence(facts.testPlan.lines)
909
+ const items = [...principalLines, ...liveLines]
873
910
  return [
874
911
  '## 9. Test Plan',
875
912
  '',
876
913
  fence,
877
914
  ...facts.testPlan.lines,
878
915
  fence,
879
- ...(principalLines.length > 0 ? ['', ...principalLines] : [])
916
+ ...(items.length > 0 ? ['', ...items] : [])
880
917
  ].join('\n')
881
918
  }
882
919
 
@@ -914,9 +951,10 @@ function renderSection12(facts: BriefFacts): string {
914
951
  '',
915
952
  `- PR title (exact): \`${prTitle}\``,
916
953
  '- Open the PR only via the `open_pull_request` tool (title and body); publish your commits with `publish_changes` and update the body with `update_pull_request_body`/`refresh_evidence` — you hold no `gh`/`git push` credential.',
917
- `- PR body = the Developer's PR report (print it with \`${facts.cliInvocation} doctrine --template pr-report --print\`), with this entire brief pasted as the reference copy inside a collapsed \`<details>\` block, and \`Closes #${facts.issue}\` at the top of the header block.`,
918
- `- Pre-open gate: tier checklist satisfied, and ${docGateCommand(facts)}.`,
919
- "- Include `git diff origin/main...HEAD --stat` as context only; Surface is judged by the driver's `surface-scope` check, never by this hand-run diff. Include a token report (if unavailable, state so).",
954
+ PUBLICATION_RULE,
955
+ `- PR body = the Developer's PR report (print it with \`${facts.cliInvocation} doctrine --template pr-report --print\`), with \`Closes #${facts.issue}\` at the top of the header block. This brief stays frozen on the task Issue and never rides in the body.`,
956
+ "- Pre-open: tier checklist satisfied. The documentation gate is the controller's — `run_checks` and CI run it.",
957
+ "- Include `git diff origin/main...HEAD --stat` as context only; Surface is judged by the driver's `surface-scope` check, never by this hand-run diff. Token use needs no report — the Vinaya log records it.",
920
958
  '- Then STOP. Review and Verification are separate invocations.'
921
959
  ].join('\n')
922
960
  }
@@ -992,7 +1030,8 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
992
1030
  if (
993
1031
  facts.testPlan.kind === 'commands' &&
994
1032
  facts.testPlan.lines.length === 0 &&
995
- facts.testPlan.principal.length === 0
1033
+ facts.testPlan.principal.length === 0 &&
1034
+ facts.testPlan.live.length === 0
996
1035
  ) {
997
1036
  missing.push(`Test plan (Issue has no \`## Test plan\` section — ${cutoverNote})`)
998
1037
  }
@@ -1002,6 +1041,10 @@ export function renderBrief(facts: BriefFacts, template: string): RenderResult {
1002
1041
  if (!facts.dispatchReady) missing.push(...facts.dispatchBlockers)
1003
1042
 
1004
1043
  for (const key of Object.keys(RATIONALE_FIELD_PATTERNS) as RationaleFieldKey[]) {
1044
+ // A single-fix Issue (no tranche) may omit its Dependency rationale;
1045
+ // `renderSection3` then writes `SINGLE_FIX_NO_EDGES_LINE`. A tranche task
1046
+ // still needs the field to render.
1047
+ if (key === 'dependencyRationale' && facts.trancheSlug === null) continue
1005
1048
  if (!facts.rationale[key]) missing.push(RATIONALE_FIELD_NAMES[key])
1006
1049
  }
1007
1050
 
@@ -124,7 +124,7 @@ function testPlanRegion(prBody: string): string {
124
124
  /**
125
125
  * Test Plan — pass iff the body contains the `Test Plan: unit-tests-only`
126
126
  * sentinel (bolded or not — see `TEST_PLAN_UNIT_TESTS_ONLY_RE`), OR at least one
127
- * `**[agent]**`/`**[principal]**`-tagged checklist line. Presence-only: does not
127
+ * `**[agent]**`/`**[principal]**`-tagged checklist line, OR a `**[live]**` item. Presence-only: does not
128
128
  * judge whether tags are correctly assigned or whether `unit-tests-only` is
129
129
  * justified by the surface map.
130
130
  */
@@ -144,7 +144,7 @@ export function checkTestPlan(prBody: string): BriefSectionResult {
144
144
  const located = locateTestPlanSection(prBody)
145
145
  const region = located.found ? located.section : prBody
146
146
  if (TEST_PLAN_UNIT_TESTS_ONLY_RE.test(region)) return { status: 'pass', errors: [] }
147
- if (/\*\*\[(?:agent|principal)\]\*\*/.test(region)) return { status: 'pass', errors: [] }
147
+ if (/\*\*\[(?:agent|principal|live)\]\*\*/.test(region)) return { status: 'pass', errors: [] }
148
148
  // Fenced-block detection only counts when the section was genuinely
149
149
  // LOCATED, never on the whole-body fallback: `testPlanRegion`'s fallback
150
150
  // exists so the sentinel/tag checks above still work on a body with no
@@ -158,7 +158,7 @@ export function checkTestPlan(prBody: string): BriefSectionResult {
158
158
  return {
159
159
  status: 'fail',
160
160
  errors: [
161
- 'brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`-tagged checklist item.'
161
+ 'brief-validation Test Plan: no Test Plan section found — expected `Test Plan: unit-tests-only`, a fenced `[agent]` command list, or at least one `**[agent]**`/`**[principal]**`/`**[live]**`-tagged item.'
162
162
  ]
163
163
  }
164
164
  }
@@ -20,7 +20,7 @@ import {
20
20
  type TaskSurfaceFacts
21
21
  } from './issue-validation'
22
22
  import { parseTaskBranchIdentity } from './task-branch-identity'
23
- import { isPrincipal, PRINCIPAL_ALLOWLIST } from './waiver-label'
23
+ import { isPrincipal } from './waiver-label'
24
24
  import type { ForgeIssue, TaskIssueRef } from '@attalabs/aeg-types'
25
25
  import type { GhIssue } from '@attalabs/aeg-forge-state'
26
26
  import type { ForgeFacts, Tranche, Task } from './types'
@@ -150,7 +150,7 @@ export type TrancheFile = {
150
150
  * is done-but-unprovable, or a broken close, exactly the class this check
151
151
  * exists to catch.
152
152
  */
153
- export function checkA1(entries: TaskEntry[], principalAllowlist: string[] = PRINCIPAL_ALLOWLIST): CheckResult {
153
+ export function checkA1(entries: TaskEntry[], principalAllowlist: string[]): CheckResult {
154
154
  const failures: CheckFailure[] = []
155
155
  for (const e of entries) {
156
156
  if (!e.facts) continue
@@ -188,15 +188,28 @@ function readRecord<T>(path: string, parse: (raw: string | undefined) => ParsedR
188
188
  * the co-tenant threat (a genuinely different account) this function exists
189
189
  * to catch, and group is not the bit `/tmp`'s own convention polices either.
190
190
  *
191
+ * **Overflow owner.** `trustedOverflowUid`, when given, is one more trusted
192
+ * owner — the kernel overflow uid, which every host uid a Linux user
193
+ * namespace leaves unmapped reads as from inside it (root's `/`, `/tmp`
194
+ * included). `mkdirNoSymlinks` passes it only for segments strictly above
195
+ * its `trustedRoot`, and only when `processTrustedOverflowUid` found root
196
+ * unmapped: at or below `trustedRoot` a co-tenant's directory reads as the
197
+ * same overflow uid, so trusting it there would accept exactly the plant this
198
+ * check exists to catch. The mode rule applies to it unchanged.
199
+ *
191
200
  * Split out from `mkdirNoSymlinks` so the foreign-owner branch — not
192
201
  * constructible as a real fixture in CI without a second local user — stays
193
202
  * unit-testable against a faked stat, the same convention
194
203
  * `metering-io-guard.test.ts`'s `isTrustedMeteringStat` suite already uses;
195
204
  * the mode branch is a real, constructible fixture (`local.test.ts`).
196
205
  */
197
- export function isTrustedDirStat(stat: { uid: number; mode: number }, ownUid: number | undefined): boolean {
206
+ export function isTrustedDirStat(
207
+ stat: { uid: number; mode: number },
208
+ ownUid: number | undefined,
209
+ trustedOverflowUid?: number
210
+ ): boolean {
198
211
  if (typeof ownUid !== 'number') return true
199
- if (stat.uid !== ownUid && stat.uid !== 0) return false
212
+ if (stat.uid !== ownUid && stat.uid !== 0 && stat.uid !== trustedOverflowUid) return false
200
213
  const worldWritable = (stat.mode & 0o002) !== 0
201
214
  const sticky = (stat.mode & 0o1000) !== 0
202
215
  return !worldWritable || sticky
@@ -206,6 +219,74 @@ function currentUid(): number | undefined {
206
219
  return typeof process.getuid === 'function' ? process.getuid() : undefined
207
220
  }
208
221
 
222
+ /**
223
+ * Whether a `/proc/self/uid_map` body leaves root unmapped: every line
224
+ * (`inside outside count`) parses, at least one does, and no inside range
225
+ * `[inside, inside + count)` contains `0`. The host's identity map
226
+ * (`0 0 4294967295`) maps root, so it answers `false`; an empty or malformed
227
+ * map answers `false` too — trusting the overflow uid needs a map that
228
+ * positively shows root unmapped, never the absence of one.
229
+ */
230
+ export function uidMapLeavesRootUnmapped(uidMap: string): boolean {
231
+ const lines = uidMap
232
+ .split('\n')
233
+ .map((line) => line.trim())
234
+ .filter((line) => line.length > 0)
235
+ if (lines.length === 0) return false
236
+ for (const line of lines) {
237
+ const fields = line.split(/\s+/)
238
+ if (fields.length !== 3 || !fields.every((field) => /^\d+$/.test(field))) return false
239
+ const inside = Number(fields[0])
240
+ const count = Number(fields[2])
241
+ if (inside === 0 && count > 0) return false
242
+ }
243
+ return true
244
+ }
245
+
246
+ /**
247
+ * The overflow uid `isTrustedDirStat` may trust above `trustedRoot`, read
248
+ * through `readFile` from `/proc/self/uid_map` and
249
+ * `/proc/sys/kernel/overflowuid` — or `undefined`, today's rule, whenever
250
+ * root is mapped, either file cannot be read (no `/proc` at all on macOS),
251
+ * or the overflow uid does not parse.
252
+ */
253
+ export function readTrustedOverflowUid(readFile: (path: string) => string): number | undefined {
254
+ try {
255
+ if (!uidMapLeavesRootUnmapped(readFile('/proc/self/uid_map'))) return undefined
256
+ const overflow = readFile('/proc/sys/kernel/overflowuid').trim()
257
+ return /^\d+$/.test(overflow) ? Number(overflow) : undefined
258
+ } catch {
259
+ return undefined
260
+ }
261
+ }
262
+
263
+ let cachedTrustedOverflowUid: { value: number | undefined } | undefined
264
+
265
+ /** `readTrustedOverflowUid` against the real `/proc`, read once per process — a process never changes user namespace mid-run. */
266
+ function processTrustedOverflowUid(): number | undefined {
267
+ cachedTrustedOverflowUid ??= { value: readTrustedOverflowUid((path) => readFileSync(path, 'utf8')) }
268
+ return cachedTrustedOverflowUid.value
269
+ }
270
+
271
+ /**
272
+ * The walk's one zone split: segment `index` of the walked path sits at or
273
+ * below `trustedRoot` (whose own index is `rootSegmentCount - 1`), or
274
+ * strictly above it. Both the symlink rule and the overflow-owner rule in
275
+ * `mkdirNoSymlinks` read it.
276
+ */
277
+ export function isAtOrBelowTrustedRoot(index: number, rootSegmentCount: number): boolean {
278
+ return index >= rootSegmentCount - 1
279
+ }
280
+
281
+ /** The overflow uid `mkdirNoSymlinks` hands `isTrustedDirStat` for one segment: never at or below `trustedRoot`. */
282
+ export function segmentTrustedOverflowUid(
283
+ index: number,
284
+ rootSegmentCount: number,
285
+ trustedOverflowUid: number | undefined
286
+ ): number | undefined {
287
+ return isAtOrBelowTrustedRoot(index, rootSegmentCount) ? undefined : trustedOverflowUid
288
+ }
289
+
209
290
  /**
210
291
  * Creates `dir` and every missing ancestor, refusing to traverse through a
211
292
  * pre-existing symlink — or a pre-existing real directory with an untrusted
@@ -260,13 +341,15 @@ export function mkdirNoSymlinks(dir: string, mode: number, trustedRoot: string):
260
341
  .filter((s) => s.length > 0)
261
342
  const segments = absolute.split(sep).filter((s) => s.length > 0)
262
343
  const ownUid = currentUid()
344
+ const trustedOverflowUid = typeof ownUid === 'number' ? processTrustedOverflowUid() : undefined
263
345
  let current = absolute.startsWith(sep) ? sep : ''
264
346
  segments.forEach((segment, index) => {
265
347
  current = current === '' || current === sep ? `${current}${segment}` : `${current}${sep}${segment}`
266
348
  // `trustedRoot` itself sits at index `rootSegments.length - 1` — at or
267
349
  // below it, refusal is unconditional; strictly above it, a symlink is
268
350
  // resolved and its real target trust-checked instead of refused outright.
269
- const atOrBelowTrustedRoot = index >= rootSegments.length - 1
351
+ const atOrBelowTrustedRoot = isAtOrBelowTrustedRoot(index, rootSegments.length)
352
+ const overflowUid = segmentTrustedOverflowUid(index, rootSegments.length, trustedOverflowUid)
270
353
  try {
271
354
  mkdirSync(current, { mode })
272
355
  } catch (err) {
@@ -292,7 +375,7 @@ export function mkdirNoSymlinks(dir: string, mode: number, trustedRoot: string):
292
375
  `control-store: refusing to create a run directory through ${current} — it is a symlink that does not resolve to a real directory`
293
376
  )
294
377
  }
295
- if (!isTrustedDirStat(real, ownUid)) {
378
+ if (!isTrustedDirStat(real, ownUid, overflowUid)) {
296
379
  throw new Error(
297
380
  `control-store: refusing to create a run directory through ${current} — its symlink target is owned by uid ${real.uid} with mode ${(real.mode & 0o7777).toString(8)}, neither this process's own user nor a safe shared mode`
298
381
  )
@@ -304,7 +387,7 @@ export function mkdirNoSymlinks(dir: string, mode: number, trustedRoot: string):
304
387
  `control-store: refusing to create a run directory through ${current} — it already exists and is not a real directory (a symlink or a file)`
305
388
  )
306
389
  }
307
- if (!isTrustedDirStat(stat, ownUid)) {
390
+ if (!isTrustedDirStat(stat, ownUid, overflowUid)) {
308
391
  throw new Error(
309
392
  `control-store: refusing to create a run directory through ${current} — it already exists, owned by uid ${stat.uid} with mode ${(stat.mode & 0o7777).toString(8)}, neither this process's own user nor a safe shared mode`
310
393
  )
@@ -149,6 +149,18 @@ export const ManifestRecordSchema = z
149
149
  objectivesVersion: z.string().min(1).nullable(),
150
150
  /** Rulings — the newest principal ruling ordinal at dispatch (`0` when none). */
151
151
  rulingOrdinal: epochNumber,
152
+ /** Review-manifest protocol version; unknown values are corrupt. */
153
+ manifestVersion: z.literal(2).optional(),
154
+ /** Principal ruling bound to the resumed pause, or explicit null. */
155
+ pauseBoundRuling: z
156
+ .object({
157
+ rulingId: z.string().min(1),
158
+ pauseId: z.string().min(1),
159
+ contentDigest: z.string().min(1)
160
+ })
161
+ .strict()
162
+ .nullable()
163
+ .optional(),
152
164
  /** Policy identity — the complete effective review policy's digest. */
153
165
  policyDigest: z.string().min(1),
154
166
  recordedAt: isoTimestamp
@@ -216,12 +228,32 @@ export const LoopStateRecordSchema = z
216
228
  * the developer at a finding or a failure that had in fact already
217
229
  * repeated, the exact outcome the two repeat stops exist to prevent.
218
230
  * Optional: a record written before this field existed still parses, and
219
- * reads back as no memory rather than as a corrupt record.
231
+ * reads back as no memory rather than as a corrupt record. The same holds
232
+ * for `lastFailure.developerAttemptedSince`: absent reads as no Developer
233
+ * attempt recorded since that failure.
220
234
  */
221
235
  repeatMemory: z
222
236
  .object({
223
237
  blockingFindings: z.array(z.string()),
224
- lastFailure: z.object({ signature: z.string(), message: z.string() }).nullable()
238
+ lastFailure: z
239
+ .object({ signature: z.string(), message: z.string(), developerAttemptedSince: z.boolean().optional() })
240
+ .nullable()
241
+ })
242
+ .strict()
243
+ .optional(),
244
+ /**
245
+ * What the next Developer packet is built from, so a restarted or
246
+ * re-exec'd driver builds the same packet the one before it would have:
247
+ * the newest review's unresolved findings, each with the controller-
248
+ * computed id the Developer cites and the finding line it was handed, and
249
+ * the checks that failed on the newest gate read. Overwritten as each
250
+ * changes. Optional: a record written before this field existed reads
251
+ * back as nothing handed over.
252
+ */
253
+ developerHandoff: z
254
+ .object({
255
+ findings: z.array(z.object({ id: z.string().min(1), description: z.string().min(1) }).strict()),
256
+ failingChecks: z.array(z.string().min(1))
225
257
  })
226
258
  .strict()
227
259
  .optional(),
@@ -37,8 +37,9 @@
37
37
  * stop a loop that is repeating itself rather than converging: the same
38
38
  * BLOCKING finding — same reviewer role, same file, same description — still open in
39
39
  * two consecutive reviewed rounds (`condition: 'repeat_finding'`), and two
40
- * consecutive attempts ending on the same mechanical failure
41
- * (`condition: 'repeat_failure'`). Neither revives `no_progress`: a round
40
+ * consecutive attempts ending on the same mechanical failure, with a
41
+ * finished Developer attempt between them (`condition: 'repeat_failure'`).
42
+ * Neither revives `no_progress`: a round
42
43
  * that resolves nothing but raises only new findings still continues, and
43
44
  * a round whose repeated finding is non-blocking continues too. Both name
44
45
  * what repeated in the pause's own `detail`.
@@ -468,15 +469,36 @@ const VOLATILE_TOKENS: readonly { pattern: RegExp; replacement: string }[] = [
468
469
  * the previous attempt's. Shared by both observation kinds that can carry a
469
470
  * mechanical failure, so a repeat means the same thing whether or not the
470
471
  * attempt produced a head.
472
+ *
473
+ * A matching signature is a repeat only when a Developer attempt finished
474
+ * since the previous failure was recorded (`recordDeveloperAttempt`). The
475
+ * same red gate read again after a retry that never reached the Developer —
476
+ * a dispatch that failed on infrastructure, then resumed — is the same
477
+ * attempt's failure read twice, and sends the Developer instead of pausing.
471
478
  */
472
479
  function matchFailure(
473
480
  state: LoopState,
474
481
  reported: string | undefined
475
- ): { failure: { signature: string; message: string } | null; repeat: boolean } {
482
+ ): { failure: NonNullable<LoopState['lastFailure']> | null; repeat: boolean } {
476
483
  const message = reported?.trim() ?? ''
477
484
  const signature = message === '' ? '' : normalizeFailureSignature(message)
478
485
  if (signature === '') return { failure: null, repeat: false }
479
- return { failure: { signature, message }, repeat: state.lastFailure?.signature === signature }
486
+ return {
487
+ failure: { signature, message, developerAttemptedSince: false },
488
+ repeat: state.lastFailure?.signature === signature && state.lastFailure.developerAttemptedSince === true
489
+ }
490
+ }
491
+
492
+ /**
493
+ * Records that a Developer attempt finished: the failure the loop last
494
+ * recorded now has an attempt after it, so the same failure read again is a
495
+ * second attempt's. The driver calls this when a Developer turn returns; a
496
+ * dispatch that failed before reaching the Developer never calls it. A state
497
+ * with no recorded failure is returned unchanged.
498
+ */
499
+ export function recordDeveloperAttempt(state: LoopState): LoopState {
500
+ if (state.lastFailure === null || state.lastFailure.developerAttemptedSince === true) return state
501
+ return { ...state, lastFailure: { ...state.lastFailure, developerAttemptedSince: true } }
480
502
  }
481
503
 
482
504
  /**
@@ -6,7 +6,7 @@
6
6
  * process, a file, or the forge.
7
7
  */
8
8
 
9
- import { assessRound } from './assess-round'
9
+ import { assessRound, recordDeveloperAttempt } from './assess-round'
10
10
  import type {
11
11
  Confidence,
12
12
  Decision,
@@ -104,6 +104,11 @@ export function notMetVerdict(role: 'reviewer' | 'security', objectiveIds: strin
104
104
  * time grows between observations. Omitted, no clock is passed at all, which
105
105
  * is exactly a caller that cannot measure the task's first start: the time
106
106
  * budget is then never armed and every existing scenario behaves as before.
107
+ *
108
+ * A `dispatch_developer` decision is followed by a finished Developer attempt
109
+ * before the next step, recorded with `recordDeveloperAttempt` exactly as the
110
+ * driver records one. A scenario whose dispatch never reaches the Developer
111
+ * calls `assessRound` directly instead.
107
112
  */
108
113
  export function runScenario(
109
114
  initial: LoopState,
@@ -115,7 +120,7 @@ export function runScenario(
115
120
  const decisions: Decision[] = []
116
121
  for (const [index, step] of steps.entries()) {
117
122
  const result = assessRound(state, step, clockAt?.(index))
118
- state = result.state
123
+ state = result.decision.type === 'dispatch_developer' ? recordDeveloperAttempt(result.state) : result.state
119
124
  events.push(...result.events)
120
125
  decisions.push(result.decision)
121
126
  }
@@ -1,4 +1,10 @@
1
- export { assessRound, renderPhaseBreakdown, renderTaskBudgetDetail, taskBudgetExceeded } from './assess-round'
1
+ export {
2
+ assessRound,
3
+ recordDeveloperAttempt,
4
+ renderPhaseBreakdown,
5
+ renderTaskBudgetDetail,
6
+ taskBudgetExceeded
7
+ } from './assess-round'
2
8
  export { parseSummaryConfidenceRows, renderPublishedMarker } from './render-summary'
3
9
  export type { SummaryConfidenceRow } from './render-summary'
4
10
  export { initialLoopState } from './types'