@attalabs/vinaya 0.37.0 → 0.38.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 (174) hide show
  1. package/aeg-root/enforcement.md +5 -4
  2. package/aeg-root/roles/developer/reference.md +24 -22
  3. package/aeg-root/roles/developer.md +4 -4
  4. package/aeg-root/roles/planner/reference.md +11 -0
  5. package/aeg-root/roles/reviewer.md +5 -3
  6. package/aeg-root/roles/security.md +3 -2
  7. package/aeg-root/state-machine.md +1 -1
  8. package/aeg-root/templates/brief-template.md +4 -4
  9. package/aeg-root/tranche-model.md +6 -0
  10. package/dist/checks/bin/check-body-bare-digits.js +139 -12
  11. package/dist/checks/bin/check-branch-topology.js +171 -13
  12. package/dist/checks/bin/check-brief-shape.js +139 -12
  13. package/dist/checks/bin/check-changeset-coverage.js +177 -17
  14. package/dist/checks/bin/check-closes-n.js +171 -13
  15. package/dist/checks/bin/check-coherence.js +171 -13
  16. package/dist/checks/bin/check-dead-branch-push.js +139 -12
  17. package/dist/checks/bin/check-dispatch-readiness.js +195 -23
  18. package/dist/checks/bin/check-doc-coverage-push.js +173 -13
  19. package/dist/checks/bin/check-doc-coverage.js +180 -13
  20. package/dist/checks/bin/check-doctrine-no-procedures.js +139 -12
  21. package/dist/checks/bin/check-doctrine-portability.js +173 -13
  22. package/dist/checks/bin/check-evidence-fresh.js +173 -13
  23. package/dist/checks/bin/check-exec-bits.js +173 -13
  24. package/dist/checks/bin/check-first-push-dispatch.js +171 -13
  25. package/dist/checks/bin/check-issue-assignment.js +171 -13
  26. package/dist/checks/bin/check-issue-milestone-attach.js +139 -12
  27. package/dist/checks/bin/check-issue-objectives-numbering.js +139 -12
  28. package/dist/checks/bin/check-issue-parts-coverage.js +139 -12
  29. package/dist/checks/bin/check-issue-surface-globs.js +171 -13
  30. package/dist/checks/bin/check-issue-title-grammar.js +139 -12
  31. package/dist/checks/bin/check-issue-tranche-label.js +139 -12
  32. package/dist/checks/bin/check-main-branch-refusal.js +139 -12
  33. package/dist/checks/bin/check-no-disk-state.js +139 -12
  34. package/dist/checks/bin/check-pr-premise-reassert.js +139 -12
  35. package/dist/checks/bin/check-pr-report-density.js +139 -12
  36. package/dist/checks/bin/check-principal-test-plan-wait.js +139 -12
  37. package/dist/checks/bin/check-quoted-command.js +173 -13
  38. package/dist/checks/bin/check-reader-resolvable-prose.js +173 -13
  39. package/dist/checks/bin/check-registry-gates.js +406 -68
  40. package/dist/checks/bin/check-retired-vocabulary.js +173 -13
  41. package/dist/checks/bin/check-review-gate.js +139 -12
  42. package/dist/checks/bin/check-single-plan-pr.js +139 -12
  43. package/dist/checks/bin/check-surface-scope.js +171 -13
  44. package/dist/checks/bin/check-test-plan.js +139 -12
  45. package/dist/checks/bin/check-token-collection-wired.js +139 -12
  46. package/dist/checks/bin/check-workspace-escape.js +173 -13
  47. package/dist/checks/bin/verify-dispatch.js +3849 -0
  48. package/dist/index.js +7348 -2095
  49. package/dist/lib/pre-push-cache-test-run.js +42 -2
  50. package/dist/lib/pre-push-changed-files.js +16 -11
  51. package/dist/lib/pre-push-select-tests.js +177 -21
  52. package/package.json +1 -1
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +33 -15
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +31 -2
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +214 -24
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +11 -3
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -4
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -145
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +63 -14
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +56 -7
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +7 -7
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +219 -15
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +38 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
  107. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  109. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  145. 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
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0h9yhwx._.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__14ui9sz._.js → [root-of-the-server]__0jdjsxe._.js} +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  161. 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
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  166. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1-acpmtfmrc35.js +1 -0
  167. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3qtt1v3ya-ofe.js → 2f2y8xxok8zph.js} +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3l56x8wjdzvaw.js → 2xevgia1h8g0y.js} +4 -4
  169. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  170. package/dist/checks/bin/check-token-report.js +0 -6526
  171. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vtfb0g813gki.js +0 -1
  172. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
  173. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
  174. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
@@ -24,7 +24,10 @@ export type { TokenSourcePr } from './parse-token-report'
24
24
  export { deriveReviewStatus, parseDeveloperRoundMarker, renderReviewStatus } from './review-status'
25
25
  export type { ReviewStatus, ReviewStatusInput } from './review-status'
26
26
  export {
27
+ activeBudgetMs,
27
28
  emptyPhaseSamples,
29
+ INACTIVE_BUDGET_PHASES,
30
+ isActiveBudgetPhase,
28
31
  isRecordedLoopPhase,
29
32
  medianOf,
30
33
  MIN_PHASE_HISTORY_SAMPLES,
@@ -340,8 +343,14 @@ export type {
340
343
  } from './diagram-model'
341
344
  export { parseEnforcementRegistry } from './registry-parse'
342
345
  export type { GateRing, GateRow } from './registry-parse'
343
- export { checkG1, checkG2, checkG3, checkG4, checkG5, checkG6 } from './registry-checks'
344
- export type { RegistryCheckResult, RegistryCheckStatus, RegistryFinding } from './registry-checks'
346
+ export { checkG1, checkG2, checkG3, checkG4, checkG5, checkG6, findUnshippedHookRefs } from './registry-checks'
347
+ export type {
348
+ HookReferenceInput,
349
+ HookScanFile,
350
+ RegistryCheckResult,
351
+ RegistryCheckStatus,
352
+ RegistryFinding
353
+ } from './registry-checks'
345
354
  export { applyScaffoldPlan, computeScaffoldPlan, PLACEHOLDER } from './registry-scaffold'
346
355
  export type { ScaffoldPlan, ScaffoldSkip, ScaffoldStub } from './registry-scaffold'
347
356
  export { ACTIONS, CROSSING_KEYWORDS } from './actions'
@@ -358,7 +367,7 @@ export { checkPremises, parsePremiseBlock } from './premise-check'
358
367
  export type { PremiseAssertion, PremiseCheckResult } from './premise-check'
359
368
  export { checkDocClaims } from './doc-claim'
360
369
  export type { ClaimBinding, ClaimFinding, ClaimVoice, DocClaimSourceFile } from './doc-claim'
361
- export { classifyLeftover } from './leftover-detection'
370
+ export { classifyLeftover, leftoverBlocksDispatch } from './leftover-detection'
362
371
  export type { LeftoverInput, LeftoverResult, LeftoverVerdict } from './leftover-detection'
363
372
  export { checkDeadBranchPush } from './dead-branch-push-guard'
364
373
  export type {
@@ -383,10 +392,11 @@ export {
383
392
  normalizeSpecPath,
384
393
  parseGlossaryTerms,
385
394
  PRODUCT_SLUG_SCOPE,
395
+ specGrandfatherPaths,
386
396
  stripNonProse,
387
397
  TASK_NUMBER_PATTERN
388
398
  } from './reader-resolvable-prose'
389
- export type { ProseFileClass, ProseFinding, ProseSourceFile } from './reader-resolvable-prose'
399
+ export type { ProseFileClass, ProseFinding, ProseSourceFile, SpecGrandfather } from './reader-resolvable-prose'
390
400
  export {
391
401
  checkQuotedCommandStaleness,
392
402
  evaluateCitedQuotes,
@@ -444,7 +454,6 @@ export {
444
454
  isOperatorGranted,
445
455
  isTaskToolName,
446
456
  MAX_PAGE_LIMIT,
447
- OPERATOR_STATUS_FOLLOW,
448
457
  OPERATOR_TOOL_GRANT,
449
458
  TASK_CANCEL_TOOL,
450
459
  TASK_ESCALATION_READ_TOOL,
@@ -602,9 +611,12 @@ export {
602
611
  isPublishedSummaryComment,
603
612
  nextRoundNumber,
604
613
  parseSummaryConfidenceRows,
614
+ PUBLISHED_MARKER_LINE,
605
615
  reconstructRounds,
606
- renderSummary,
607
- SUMMARY_TABLE_HEADER
616
+ renderPhaseBreakdown,
617
+ renderPublishedMarker,
618
+ renderTaskBudgetDetail,
619
+ taskBudgetExceeded
608
620
  } from './dev-review-loop'
609
621
  export type {
610
622
  Confidence,
@@ -625,6 +637,7 @@ export type {
625
637
  RoundOutcome,
626
638
  RoundRecord,
627
639
  RoundStats,
640
+ TaskClock,
628
641
  VerdictObservation
629
642
  } from './dev-review-loop'
630
643
  export {
@@ -642,6 +655,9 @@ export {
642
655
  HandoffEventSchema,
643
656
  HeaderMetaV1Schema,
644
657
  HeaderMetaV2Schema,
658
+ HeaderMetaV3Schema,
659
+ WorkSchema,
660
+ FlowSchema,
645
661
  HeaderSchema,
646
662
  HostSchema,
647
663
  HOST_VALUES,
@@ -677,6 +693,9 @@ export type {
677
693
  HeaderInput,
678
694
  HeaderMetaV1,
679
695
  HeaderMetaV2,
696
+ HeaderMetaV3,
697
+ Work,
698
+ Flow,
680
699
  Host,
681
700
  InputVersions,
682
701
  Lineage,
@@ -698,6 +717,35 @@ export type {
698
717
  UsageEvent,
699
718
  UsageUnits
700
719
  } from './log'
720
+ export {
721
+ cacheContractCases,
722
+ createMemoryCache,
723
+ isLowTrustVersion,
724
+ known,
725
+ LOW_TRUST_BELOW_VERSION,
726
+ normalizeStoredLine,
727
+ unknownBecause
728
+ } from './log'
729
+ export type {
730
+ CacheContractCase,
731
+ Dataset,
732
+ DatasetRow,
733
+ JsonObject,
734
+ LogCache,
735
+ LogSource,
736
+ Measured,
737
+ NormalizedLine,
738
+ PutOutcome,
739
+ QuarantineRecord,
740
+ RowEdit,
741
+ RowOrigin,
742
+ RowTrust,
743
+ SourceCursor,
744
+ SourceGap,
745
+ SourceLine,
746
+ SourcePage,
747
+ UnknownableField
748
+ } from './log'
701
749
  export {
702
750
  acquireOwnership,
703
751
  appendTransition,
@@ -723,6 +771,7 @@ export {
723
771
  parseRunRecord,
724
772
  parseTransitionRecord,
725
773
  readCurrentOwnership,
774
+ readEarliestOwnership,
726
775
  readEffect,
727
776
  readEscalation,
728
777
  readInput,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Planner→Brief Issue-rationale grammar. Pure — no `fs`, no `fetch`,
3
- * no `process.env`. The tool-layer gate (`bin/open-issue.ts`, invoked because
4
- * the `check-forge-gates.sh` hook denies raw `gh issue create`) calls
3
+ * no `process.env`. The local gate (`bin/open-issue.ts`, the sanctioned way to
4
+ * create an Issue; no hook refuses a raw `gh issue create`) calls
5
5
  * `checkIssueRationale` before any task Issue can reach the forge.
6
6
  *
7
7
  * A task Issue's body must carry every producer field of the
@@ -1158,8 +1158,8 @@ export function checkIssueType(_body: string, labels: string[]): IssueSectionRes
1158
1158
  // through one product's lens instead of every consumer's); a `## References`
1159
1159
  // block copied brief-time content into the Issue, where it goes stale before
1160
1160
  // work starts; and nothing forced the rationale to name the docs/skills it
1161
- // touches, because the skill-check hook fires on file edits and a forge write
1162
- // edits no file. The checks below are those three failures turned into
1161
+ // touches, because no other check observes what the Planner read before a forge
1162
+ // write. The checks below are those three failures turned into
1163
1163
  // deterministic functions on the surface they happened on.
1164
1164
  //
1165
1165
  // EVERY ONE OF THEM READS BLOCK-STRIPPED TEXT, via the single exported
@@ -1728,8 +1728,8 @@ const NO_DOC_SURFACE_RE = /(?:\*\*)?\s*no-doc-surface/i
1728
1728
  /**
1729
1729
  * **D — no read-obligation signal.** The root cause of A and B both: nothing
1730
1730
  * forced the Planner to read the docs and skills governing the surface it was
1731
- * planning, because the skill-check hook fires on file edits and cutting an
1732
- * Issue edits no file. Requiring a concrete doc path in `Docs to keep coherent`
1731
+ * planning, because no other check observes what the Planner read before cutting
1732
+ * an Issue. Requiring a concrete doc path in `Docs to keep coherent`
1733
1733
  * / `Traps to avoid` makes the read leave an artifact — you cannot name
1734
1734
  * `.claude/skills/ui-library-system/SKILL.md` as the design anchor without
1735
1735
  * having gone looking for it.
@@ -1745,7 +1745,7 @@ export function checkRationaleNamesDocs(body: string): IssueSectionResult {
1745
1745
  return {
1746
1746
  status: 'fail',
1747
1747
  errors: [
1748
- 'issue-validation docs read: neither "Docs to keep coherent" nor "Traps to avoid" names a concrete doc path (aeg-root/…, .claude/skills/…, apps/*/CLAUDE.md, apps/*/specs/…). Naming one is the artifact of having read the surface being planned — the forge write triggers no skill-check hook, so this field is the only read-obligation signal. For a genuinely doc-less surface, write the explicit `no-doc-surface` sentinel.'
1748
+ 'issue-validation docs read: neither "Docs to keep coherent" nor "Traps to avoid" names a concrete doc path (aeg-root/…, .claude/skills/…, apps/*/CLAUDE.md, apps/*/specs/…). Naming one is the artifact of having read the surface being planned — no other check observes what you read before the forge write, so this field is the only read-obligation signal. For a genuinely doc-less surface, write the explicit `no-doc-surface` sentinel.'
1749
1749
  ]
1750
1750
  }
1751
1751
  }
@@ -4,12 +4,18 @@
4
4
  * exist, does a local worktree exist, how many commits is the branch ahead
5
5
  * of main) and passes them in.
6
6
  *
7
- * Exists to answer, deterministically, "is it safe to run Step 0's
8
- * `git worktree add -b <branch> origin/main` for this task?" — Step 0 itself
9
- * never creates a commit, so ANY commit already ahead of main on this branch
10
- * is real prior work, never an artifact of re-running Step 0. Silently
11
- * recreating a branch that already has commits ahead of main would discard
12
- * that work — the failure this module exists to prevent.
7
+ * Exists to answer, deterministically, "is it safe to (re)run
8
+ * `git worktree add -b <branch> origin/main` for this task?" — asked by the
9
+ * driver before every Developer turn, with `--existing-work` so its own
10
+ * commits never refuse (`leftoverBlocksDispatch`) (O1: the driver creates the
11
+ * task's worktree now, not Step 0 — see
12
+ * `apps/cli/src/lib/dev-review-loop/developer-dispatch.ts`'s
13
+ * `createTaskWorktree`) and, for a brief rendered before that changed, still
14
+ * named by Step 0 itself. Neither ever creates a commit, so ANY commit
15
+ * already ahead of main on this branch is real prior work, never an
16
+ * artifact of re-running it. Silently recreating a branch that already has
17
+ * commits ahead of main would discard that work — the failure this module
18
+ * exists to prevent.
13
19
  */
14
20
 
15
21
  export type LeftoverInput = {
@@ -65,3 +71,15 @@ export function classifyLeftover(input: LeftoverInput): LeftoverResult {
65
71
  reason: 'No branch, no worktree, no commits ahead of main — safe to run Step 0 fresh.'
66
72
  }
67
73
  }
74
+
75
+ /**
76
+ * Whether a leftover verdict refuses dispatch. `stop` protects real work from
77
+ * a fresh Step 0 — but a caller that resumes the task's existing worktree
78
+ * (`existingWork`: the review-loop driver, before every Developer turn after
79
+ * it created the worktree itself) expects commits ahead of main from the
80
+ * second turn on, and nothing it does can orphan them, so for it no verdict
81
+ * blocks.
82
+ */
83
+ export function leftoverBlocksDispatch(verdict: LeftoverVerdict, opts: { existingWork: boolean }): boolean {
84
+ return verdict === 'stop' && !opts.existingWork
85
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Consumer-declared log events — the pure half. A repository declares its
3
+ * own events under `vinaya.config.json`'s `logs.events` (`apps/cli/specs/log.md`
4
+ * § Custom events); this module holds the declaration rules the config
5
+ * loader applies and the value check the writer applies before one
6
+ * `custom` line is written. No filesystem, network or process access here —
7
+ * the writer (`apps/cli/src/lib/log-custom.ts`) reads the declarations and
8
+ * calls `log()`.
9
+ *
10
+ * A declaration names each field's type: `"text"`, `"number"`, `"boolean"`
11
+ * (yes/no), or a list of words the value must be one of. Every declared
12
+ * field is required; nested values and lists are never a field value.
13
+ */
14
+
15
+ import { z } from 'zod'
16
+
17
+ /** `<namespace>.<event>` — lowercase, a namespace, a dot, then the event (which may itself carry dots). */
18
+ export const CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/
19
+ export const CUSTOM_EVENT_NAME_MAX_LENGTH = 64
20
+ /** The namespace Vinaya's own events live in; a consumer can never declare a name in it. */
21
+ export const CUSTOM_EVENT_RESERVED_NAMESPACE = 'vinaya'
22
+ export const CUSTOM_EVENT_MAX_FIELDS = 20
23
+ export const CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/
24
+ export const CUSTOM_FIELD_NAME_MAX_LENGTH = 64
25
+ export const CUSTOM_TEXT_MAX_LENGTH = 500
26
+ /** A listed word: lowercase letters, digits, `_` and `-`, starting with a letter or digit. */
27
+ export const CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/
28
+ export const CUSTOM_WORD_MAX_LENGTH = 64
29
+ export const CUSTOM_FIELD_MAX_WORDS = 50
30
+ /** Stands in, in a refusal, for a given field name not shaped like one. */
31
+ export const UNRECORDABLE_FIELD_NAME = '<unrecordable>'
32
+
33
+ export type CustomFieldType = 'text' | 'number' | 'boolean' | string[]
34
+ export type CustomEventDeclaration = { fields: Record<string, CustomFieldType> }
35
+ export type CustomEventDeclarations = Record<string, CustomEventDeclaration>
36
+ /** One field's value as a `custom` line carries it — flat, never nested. */
37
+ export type CustomFieldValue = string | number | boolean
38
+
39
+ const CustomFieldTypeSchema = z.union([z.enum(['text', 'number', 'boolean']), z.array(z.string())])
40
+
41
+ /**
42
+ * `logs.events` — every rule a declaration must satisfy, checked at config
43
+ * load. Each refusal message names the event (and the field, when one is at
44
+ * fault), so a broken entry is found without reading the schema.
45
+ */
46
+ export const CustomEventDeclarationsSchema = z
47
+ .record(
48
+ z.string(),
49
+ z
50
+ .object({
51
+ fields: z.record(z.string(), CustomFieldTypeSchema)
52
+ })
53
+ .strict()
54
+ )
55
+ .superRefine((events, ctx) => {
56
+ for (const [name, declaration] of Object.entries(events)) {
57
+ const refuse = (message: string, path: (string | number)[] = []): void => {
58
+ ctx.addIssue({
59
+ code: z.ZodIssueCode.custom,
60
+ path: [name, ...path],
61
+ message: `logs.events "${name}": ${message}`
62
+ })
63
+ }
64
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
65
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`)
66
+ }
67
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
68
+ refuse('the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them')
69
+ } else if (name.split('.')[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
70
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`)
71
+ }
72
+ const fieldEntries = Object.entries(declaration.fields)
73
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
74
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ['fields'])
75
+ }
76
+ for (const [field, type] of fieldEntries) {
77
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
78
+ refuse(
79
+ `field "${field}": a field name is lowercase letters, digits and \`_\`, starting with a letter, at most ${CUSTOM_FIELD_NAME_MAX_LENGTH} characters`,
80
+ ['fields', field]
81
+ )
82
+ }
83
+ if (typeof type === 'string') continue
84
+ if (type.length === 0) {
85
+ refuse(`field "${field}": a list of words must name at least one word`, ['fields', field])
86
+ }
87
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
88
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ['fields', field])
89
+ }
90
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w))
91
+ if (bad.length > 0) {
92
+ refuse(
93
+ `field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`,
94
+ ['fields', field]
95
+ )
96
+ }
97
+ if (new Set(type).size !== type.length) {
98
+ refuse(`field "${field}": a list of words names a word twice`, ['fields', field])
99
+ }
100
+ }
101
+ }
102
+ })
103
+
104
+ /**
105
+ * Why a `custom` event was refused. `undeclared` — the name is not in
106
+ * `logs.events`; `missing_field` — a declared field was not given;
107
+ * `extra_field` — a field was given that the declaration does not name;
108
+ * `wrong_type` — a value is not of its declared type (a nested value or a
109
+ * list included); `too_long` — a text value is longer than the limit.
110
+ */
111
+ export type CustomEventRefusalReason = 'undeclared' | 'missing_field' | 'extra_field' | 'wrong_type' | 'too_long'
112
+
113
+ export type CustomEventCheck =
114
+ | { ok: true; name: string; fields: Record<string, CustomFieldValue> }
115
+ | { ok: false; reason: CustomEventRefusalReason; fieldNames: string[] }
116
+
117
+ function valueMatches(type: CustomFieldType, value: unknown): boolean {
118
+ if (type === 'text') return typeof value === 'string'
119
+ if (type === 'number') return typeof value === 'number' && Number.isFinite(value)
120
+ if (type === 'boolean') return typeof value === 'boolean'
121
+ return typeof value === 'string' && type.includes(value)
122
+ }
123
+
124
+ /**
125
+ * Checks one event against the declarations. The first failing class wins,
126
+ * in this order: undeclared, missing, extra, wrong type, too long — and the
127
+ * refusal names every field in that class, sorted, never a value.
128
+ */
129
+ export function checkCustomEvent(
130
+ declarations: CustomEventDeclarations,
131
+ name: string,
132
+ fields: Readonly<Record<string, unknown>>
133
+ ): CustomEventCheck {
134
+ const declaration = Object.hasOwn(declarations, name) ? declarations[name] : undefined
135
+ if (declaration === undefined) return { ok: false, reason: 'undeclared', fieldNames: [] }
136
+ const declared = declaration.fields
137
+ const given = Object.keys(fields)
138
+ const missing = Object.keys(declared).filter((f) => !Object.hasOwn(fields, f))
139
+ if (missing.length > 0) return { ok: false, reason: 'missing_field', fieldNames: missing.sort() }
140
+ const extra = given.filter((f) => !Object.hasOwn(declared, f))
141
+ if (extra.length > 0) {
142
+ // An undeclared name comes from the caller, not the declaration, and could
143
+ // itself be a value pasted in the wrong place — only a name shaped like a
144
+ // field name is recorded as given.
145
+ const named = extra.map((f) =>
146
+ f.length <= CUSTOM_FIELD_NAME_MAX_LENGTH && CUSTOM_FIELD_NAME_PATTERN.test(f) ? f : UNRECORDABLE_FIELD_NAME
147
+ )
148
+ return { ok: false, reason: 'extra_field', fieldNames: named.sort().slice(0, CUSTOM_EVENT_MAX_FIELDS) }
149
+ }
150
+ const wrong = given.filter((f) => !valueMatches(declared[f] as CustomFieldType, fields[f]))
151
+ if (wrong.length > 0) return { ok: false, reason: 'wrong_type', fieldNames: wrong.sort() }
152
+ const long = given.filter(
153
+ (f) => typeof fields[f] === 'string' && (fields[f] as string).length > CUSTOM_TEXT_MAX_LENGTH
154
+ )
155
+ if (long.length > 0) return { ok: false, reason: 'too_long', fieldNames: long.sort() }
156
+ return { ok: true, name, fields: { ...fields } as Record<string, CustomFieldValue> }
157
+ }
@@ -54,6 +54,13 @@ function roundFromEnv(round: string | undefined): number | undefined {
54
54
  return Number.isInteger(n) ? n : undefined
55
55
  }
56
56
 
57
+ /** `VINAYA_PR` parses to `subject.pr`; anything not a positive integer is absent — never invented. */
58
+ function prFromEnv(pr: string | undefined): number | undefined {
59
+ if (pr === undefined || pr === '') return undefined
60
+ const n = Number(pr)
61
+ return Number.isInteger(n) && n > 0 ? n : undefined
62
+ }
63
+
57
64
  /** Every value `buildHeader` needs, already read by the caller (the sink). Pure — no I/O here. */
58
65
  export type HeaderInput = {
59
66
  now: Date
@@ -64,7 +71,22 @@ export type HeaderInput = {
64
71
  doctrine: string
65
72
  host: Host
66
73
  hostname: string
67
- env: { role?: string; task?: string; round?: string; run?: string; attempt?: string; parent?: string }
74
+ env: {
75
+ role?: string
76
+ task?: string
77
+ round?: string
78
+ /** `VINAYA_PR` — the pull request number once the loop has one; absent or not a positive integer reads as no number. */
79
+ pr?: string
80
+ run?: string
81
+ attempt?: string
82
+ parent?: string
83
+ /** `VINAYA_WORK_REF`, `VINAYA_FLOW`, `VINAYA_FLOW_VERSION`, `VINAYA_RUNTIME`, `VINAYA_SOURCE` — the schema 3 identities a caller states; absent or empty reads `null` (`flow.id` reads `vinaya`). */
84
+ workRef?: string
85
+ flow?: string
86
+ flowVersion?: string
87
+ runtime?: string
88
+ source?: string
89
+ }
68
90
  /**
69
91
  * The Issue the caller's own checked-out branch names, for a process that
70
92
  * carries no `VINAYA_TASK` — `subject.issue`'s fallback, never its
@@ -97,22 +119,25 @@ export type HeaderInput = {
97
119
  * `subject.issue` come only from `input.env`/`input.subject`, never
98
120
  * self-declared by whatever's building the rest of the event.
99
121
  *
100
- * Always builds `schema: 2` (this task forward) — `schema: 1` remains a
101
- * read-side compatibility shape only, for a line already on disk before
102
- * this task; `buildHeader` never writes it.
122
+ * Always builds `schema: 3` — `schema: 1` and `2` remain read-side
123
+ * compatibility shapes only, for a line already on disk; `buildHeader` never
124
+ * writes them.
103
125
  */
104
126
  export function buildHeader(input: HeaderInput): Header {
105
127
  const role: Subject['role'] = isRole(input.env.role) ? input.env.role : 'unattributed'
106
128
  const round = roundFromEnv(input.env.round)
129
+ const pr = prFromEnv(input.env.pr)
107
130
  const subject: Subject = {
108
131
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
109
132
  role,
110
133
  ...(round !== undefined ? { round } : {}),
134
+ ...(pr !== undefined ? { pr } : {}),
111
135
  ...(input.subject ?? {})
112
136
  }
137
+ const issue = subject.issue
113
138
  return {
114
139
  meta: {
115
- schema: 2,
140
+ schema: 3,
116
141
  ts: input.now.toISOString(),
117
142
  run_id: input.runId,
118
143
  seq: input.seq,
@@ -135,7 +160,20 @@ export function buildHeader(input: HeaderInput): Header {
135
160
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
136
161
  policy_digest: input.inputVersions?.policyDigest ?? null
137
162
  },
138
- provenance: provenanceFor(input)
163
+ provenance: provenanceFor(input),
164
+ work: {
165
+ // A stated reference wins; failing that the Issue number `subject.issue` already carries; never anything guessed.
166
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
167
+ repo: input.repo,
168
+ change: null,
169
+ revision: null
170
+ },
171
+ flow: {
172
+ id: lineageFieldFromEnv(input.env.flow) ?? 'vinaya',
173
+ version: lineageFieldFromEnv(input.env.flowVersion)
174
+ },
175
+ runtime: lineageFieldFromEnv(input.env.runtime),
176
+ source: lineageFieldFromEnv(input.env.source)
139
177
  },
140
178
  subject
141
179
  }