@attalabs/vinaya 0.40.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 (157) hide show
  1. package/aeg-root/contracts/developer-reviewer.md +2 -2
  2. package/aeg-root/contracts/planner-developer.md +4 -4
  3. package/aeg-root/process.md +3 -3
  4. package/aeg-root/roles/developer/reference.md +3 -0
  5. package/aeg-root/state-machine.md +2 -2
  6. package/aeg-root/templates/brief-template.md +1 -1
  7. package/dist/checks/bin/check-body-bare-digits.js +165 -65
  8. package/dist/checks/bin/check-branch-topology.js +169 -60
  9. package/dist/checks/bin/check-brief-shape.js +165 -65
  10. package/dist/checks/bin/check-changeset-coverage.js +342 -122
  11. package/dist/checks/bin/check-ci-shard-coverage.js +384 -130
  12. package/dist/checks/bin/check-closes-n.js +169 -60
  13. package/dist/checks/bin/check-coherence.js +165 -65
  14. package/dist/checks/bin/check-dead-branch-push.js +142 -59
  15. package/dist/checks/bin/check-dispatch-readiness.js +211 -81
  16. package/dist/checks/bin/check-doc-claims.js +165 -65
  17. package/dist/checks/bin/check-doc-coverage-push.js +342 -122
  18. package/dist/checks/bin/check-doc-coverage.js +344 -124
  19. package/dist/checks/bin/check-doctrine-no-procedures.js +165 -65
  20. package/dist/checks/bin/check-doctrine-portability.js +342 -122
  21. package/dist/checks/bin/check-evidence-fresh.js +376 -129
  22. package/dist/checks/bin/check-exec-bits.js +342 -122
  23. package/dist/checks/bin/check-first-push-dispatch.js +208 -78
  24. package/dist/checks/bin/check-issue-milestone-attach.js +142 -59
  25. package/dist/checks/bin/check-issue-objectives-numbering.js +165 -65
  26. package/dist/checks/bin/check-issue-parts-coverage.js +142 -59
  27. package/dist/checks/bin/check-issue-surface-globs.js +218 -88
  28. package/dist/checks/bin/check-issue-title-grammar.js +142 -59
  29. package/dist/checks/bin/check-main-branch-refusal.js +142 -59
  30. package/dist/checks/bin/check-no-disk-state.js +142 -59
  31. package/dist/checks/bin/check-pr-premise-reassert.js +165 -65
  32. package/dist/checks/bin/check-pr-report-density.js +142 -59
  33. package/dist/checks/bin/check-principal-test-plan-wait.js +165 -65
  34. package/dist/checks/bin/check-quoted-command.js +338 -118
  35. package/dist/checks/bin/check-reader-resolvable-prose.js +338 -118
  36. package/dist/checks/bin/check-registry-gates.js +206 -78
  37. package/dist/checks/bin/check-retired-vocabulary.js +338 -118
  38. package/dist/checks/bin/check-review-gate.js +203 -83
  39. package/dist/checks/bin/check-single-plan-pr.js +142 -59
  40. package/dist/checks/bin/check-surface-scope.js +169 -60
  41. package/dist/checks/bin/check-test-plan.js +165 -65
  42. package/dist/checks/bin/check-token-collection-wired.js +142 -59
  43. package/dist/checks/bin/check-workspace-escape.js +340 -120
  44. package/dist/checks/bin/verify-coherence.js +153 -60
  45. package/dist/checks/bin/verify-dispatch.js +169 -69
  46. package/dist/checks/bin/verify-docs.js +142 -57
  47. package/dist/index.js +16280 -11764
  48. package/dist/lib/pre-push-cache-test-run.js +791 -68
  49. package/dist/lib/pre-push-changed-files.js +65 -19
  50. package/dist/lib/pre-push-mode.js +466 -0
  51. package/dist/lib/pre-push-progress-dir.js +4205 -0
  52. package/dist/lib/pre-push-record-tests.js +446 -0
  53. package/dist/lib/pre-push-select-tests.js +1426 -454
  54. package/dist/lib/push-progress-observer.js +4213 -0
  55. package/package.json +11 -5
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -2
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +18 -4
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +3 -3
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +2 -2
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +88 -5
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +34 -2
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +26 -4
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +7 -1
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +17 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +13 -17
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +1 -1
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +70 -45
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +1 -4
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +77 -7
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +24 -54
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +221 -56
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/live-record.ts +179 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +8 -2
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +1 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/narration.ts +1 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema-digest.ts +225 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +7 -1
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +23 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/principals-config.ts +44 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/prose-rules.ts +532 -0
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/protected-paths.ts +31 -0
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +157 -80
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +8 -12
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/retired-vocabulary.ts +52 -109
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +46 -17
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +85 -1
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +46 -0
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +2 -4
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +63 -8
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +24 -0
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +0 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  95. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  130. 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
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1a3j3n1._.js +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wzfiav._.js → [root-of-the-server]__1d4eth3._.js} +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +3 -3
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +3 -3
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  146. 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
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  151. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{38kom-9c-oi65.js → 0x7u6si-ai179.js} +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1p3vr9qts86_b.js → 2fu7mfsj4oima.js} +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{21tunzmxjvm2a.js → 34b4ruddunn3q.js} +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  155. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_buildManifest.js +0 -0
  156. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_clientMiddlewareManifest.js +0 -0
  157. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{Y3oaZSTSP9PivUuJvxK1W → 2ZARxTwpuRew8-SvYsRdU}/_ssgManifest.js +0 -0
@@ -1,28 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/lib/pre-push-cache-test-run.ts
4
- import { readFileSync as readFileSync9 } from "node:fs";
4
+ import { readFileSync as readFileSync11 } from "node:fs";
5
5
 
6
6
  // src/lib/pr-report-engine.ts
7
- import { execFile as execFile6 } from "node:child_process";
8
- import { createHash as createHash2, randomUUID as randomUUID3 } from "node:crypto";
7
+ import { execFile as execFile7 } from "node:child_process";
8
+ import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
9
9
  import {
10
- closeSync as closeSync6,
10
+ closeSync as closeSync7,
11
11
  constants as fsConstants6,
12
- existsSync as existsSync8,
13
- fsyncSync as fsyncSync2,
14
- lstatSync as lstatSync4,
12
+ existsSync as existsSync9,
13
+ fsyncSync as fsyncSync3,
14
+ lstatSync as lstatSync5,
15
15
  mkdtempSync,
16
- openSync as openSync6,
17
- readFileSync as readFileSync8,
18
- renameSync as renameSync4,
19
- rmSync,
20
- writeFileSync as writeFileSync4,
21
- writeSync as writeSync5
16
+ openSync as openSync7,
17
+ readFileSync as readFileSync10,
18
+ renameSync as renameSync5,
19
+ rmSync as rmSync3,
20
+ writeFileSync as writeFileSync5,
21
+ writeSync as writeSync6
22
22
  } from "node:fs";
23
23
  import { hostname, tmpdir } from "node:os";
24
- import { dirname as dirname8, join as join9, resolve as resolvePath2 } from "node:path";
25
- import { promisify as promisify6 } from "node:util";
24
+ import { dirname as dirname9, join as join10, resolve as resolvePath2 } from "node:path";
25
+ import { promisify as promisify7 } from "node:util";
26
26
  // ../../packages/aeg-forge-state/src/gh.ts
27
27
  import { execFile, execFileSync } from "node:child_process";
28
28
  import { promisify } from "node:util";
@@ -1189,7 +1189,17 @@ var HeaderMetaV3Schema = z3.object({
1189
1189
  runtime: z3.string().nullable(),
1190
1190
  source: z3.string().nullable()
1191
1191
  }).strict();
1192
- var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
1192
+ var HeaderMetaV4Schema = HeaderMetaV3Schema.extend({
1193
+ schema: z3.literal(4),
1194
+ process: z3.object({ id: z3.string(), version: z3.string().nullable(), digest: z3.string().nullable() }).strict(),
1195
+ runner: z3.object({ id: z3.string(), version: z3.string().nullable() }).strict()
1196
+ }).strict();
1197
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [
1198
+ HeaderMetaV1Schema,
1199
+ HeaderMetaV2Schema,
1200
+ HeaderMetaV3Schema,
1201
+ HeaderMetaV4Schema
1202
+ ]);
1193
1203
  var SubjectSchema = z3.object({
1194
1204
  issue: z3.number().int().nullable(),
1195
1205
  pr: z3.number().int().optional(),
@@ -1409,6 +1419,75 @@ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
1409
1419
  round: z3.number().int(),
1410
1420
  phase: z3.string()
1411
1421
  }).strict(),
1422
+ z3.object({
1423
+ ...loopShared,
1424
+ event: z3.literal("conflict_reentry"),
1425
+ task: z3.number().int(),
1426
+ pr: z3.number().int().positive(),
1427
+ attempt: z3.number().int().positive(),
1428
+ bound: z3.number().int().positive()
1429
+ }).strict(),
1430
+ z3.object({
1431
+ ...loopShared,
1432
+ event: z3.literal("storage_push"),
1433
+ round: z3.number().int(),
1434
+ branch: z3.string(),
1435
+ head: z3.string()
1436
+ }).strict(),
1437
+ z3.object({
1438
+ ...loopShared,
1439
+ event: z3.literal("local_checks_run"),
1440
+ round: z3.number().int(),
1441
+ head: z3.string().nullable(),
1442
+ passed: z3.boolean(),
1443
+ wall_ms: z3.number().nonnegative()
1444
+ }).strict(),
1445
+ z3.object({
1446
+ ...loopShared,
1447
+ event: z3.literal("ready_push"),
1448
+ round: z3.number().int(),
1449
+ head: z3.string(),
1450
+ outcome: z3.enum(["passed", "refused"]),
1451
+ selected: z3.number().int().nonnegative(),
1452
+ failed: z3.number().int().nonnegative(),
1453
+ rerun: z3.boolean(),
1454
+ wall_ms: z3.number().nonnegative()
1455
+ }).strict(),
1456
+ z3.object({
1457
+ ...loopShared,
1458
+ event: z3.literal("failed_tests_rerun"),
1459
+ round: z3.number().int(),
1460
+ head: z3.string(),
1461
+ rerun_of: z3.string(),
1462
+ failed_files: z3.number().int().nonnegative(),
1463
+ affected_files: z3.number().int().nonnegative(),
1464
+ full_count: z3.number().int().nonnegative()
1465
+ }).strict(),
1466
+ z3.object({
1467
+ ...loopShared,
1468
+ event: z3.literal("pr_opened"),
1469
+ round: z3.number().int(),
1470
+ pr: z3.number().int().positive(),
1471
+ head: z3.string()
1472
+ }).strict(),
1473
+ z3.object({
1474
+ ...loopShared,
1475
+ event: z3.literal("ci_result_read"),
1476
+ round: z3.number().int(),
1477
+ pr: z3.number().int().positive(),
1478
+ head: z3.string(),
1479
+ conclusion: z3.enum(["green", "red", "pending", "skipped"]),
1480
+ failing_checks: z3.array(z3.string()),
1481
+ wait_ms: z3.number().nonnegative()
1482
+ }).strict(),
1483
+ z3.object({
1484
+ ...loopShared,
1485
+ event: z3.literal("phase_time"),
1486
+ round: z3.number().int(),
1487
+ phase: z3.enum(["developer", "local_checks", "review", "push", "ci", "other"]),
1488
+ step: z3.string(),
1489
+ wall_ms: z3.number().nonnegative()
1490
+ }).strict(),
1412
1491
  z3.object({
1413
1492
  ...loopShared,
1414
1493
  event: z3.literal("driver_exited"),
@@ -1596,7 +1675,7 @@ var EffectEventSchema = z3.discriminatedUnion("event", [
1596
1675
  ]);
1597
1676
  var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
1598
1677
  var customShared = {
1599
- meta: HeaderMetaV3Schema,
1678
+ meta: HeaderMetaSchema,
1600
1679
  subject: SubjectSchema,
1601
1680
  kind: z3.literal("custom"),
1602
1681
  ...envelopeTail
@@ -1681,7 +1760,7 @@ function buildHeader(input) {
1681
1760
  const issue = subject.issue;
1682
1761
  return {
1683
1762
  meta: {
1684
- schema: 3,
1763
+ schema: 4,
1685
1764
  ts: input.now.toISOString(),
1686
1765
  run_id: input.runId,
1687
1766
  seq: input.seq,
@@ -1718,6 +1797,15 @@ function buildHeader(input) {
1718
1797
  version: lineageFieldFromEnv(input.env.flowVersion)
1719
1798
  },
1720
1799
  runtime: lineageFieldFromEnv(input.env.runtime),
1800
+ process: {
1801
+ id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
1802
+ version: lineageFieldFromEnv(input.env.processVersion),
1803
+ digest: lineageFieldFromEnv(input.env.processDigest)
1804
+ },
1805
+ runner: {
1806
+ id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
1807
+ version: lineageFieldFromEnv(input.env.runnerVersion)
1808
+ },
1721
1809
  source: lineageFieldFromEnv(input.env.source)
1722
1810
  },
1723
1811
  subject
@@ -1761,7 +1849,7 @@ function redact(value, home) {
1761
1849
  return value;
1762
1850
  }
1763
1851
  // ../../packages/aeg-core/src/log/store.ts
1764
- var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
1852
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3, 4];
1765
1853
  function metaOf(obj) {
1766
1854
  if (obj === null || typeof obj !== "object")
1767
1855
  return null;
@@ -1985,6 +2073,16 @@ var ResolutionRecordSchema = z4.object({
1985
2073
  authenticatedFrom: z4.string().min(1),
1986
2074
  consumedAt: isoTimestamp
1987
2075
  }).strict();
2076
+ var ExecutionRoundMirrorRecordSchema = z4.object({
2077
+ version: z4.literal(1),
2078
+ kind: z4.literal("execution_round"),
2079
+ task: taskId,
2080
+ repository: z4.string().min(1),
2081
+ threadId: z4.string().min(1),
2082
+ checkpointId: z4.string().min(1),
2083
+ round: z4.number().int().positive(),
2084
+ recordedAt: isoTimestamp
2085
+ }).strict();
1988
2086
  // ../../packages/aeg-core/src/control-store/local.ts
1989
2087
  import {
1990
2088
  closeSync as closeSync2,
@@ -2735,7 +2833,7 @@ import {
2735
2833
  existsSync as existsSync6,
2736
2834
  fstatSync as fstatSync3,
2737
2835
  mkdirSync as mkdirSync5,
2738
- lstatSync as lstatSync3,
2836
+ lstatSync as lstatSync4,
2739
2837
  openSync as openSync5,
2740
2838
  readFileSync as readFileSync6,
2741
2839
  renameSync as renameSync3,
@@ -2749,9 +2847,9 @@ import { promisify as promisify5 } from "node:util";
2749
2847
  // src/lib/config.ts
2750
2848
  import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
2751
2849
  import { promisify as promisify4 } from "node:util";
2752
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
2850
+ import { existsSync as existsSync3, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
2753
2851
  import { homedir } from "node:os";
2754
- import { dirname as dirname3, isAbsolute, join as join4, resolve as resolve2 } from "node:path";
2852
+ import { basename, dirname as dirname3, isAbsolute, join as join4, resolve as resolve2 } from "node:path";
2755
2853
  import { z as z6 } from "zod";
2756
2854
 
2757
2855
  // src/checks/contract.ts
@@ -3214,7 +3312,8 @@ var VinayaConfigObjectSchema = z6.object({
3214
3312
  codeReviewThreshold: z6.string().min(1).optional(),
3215
3313
  securityThreshold: z6.string().min(1).optional(),
3216
3314
  maxRounds: z6.number().optional(),
3217
- maxTaskMinutes: z6.number().optional()
3315
+ maxTaskMinutes: z6.number().optional(),
3316
+ readyPushTimeoutMinutes: z6.number().optional()
3218
3317
  }).optional(),
3219
3318
  securityScan: z6.object({
3220
3319
  command: z6.array(z6.string().min(1)).min(1)
@@ -3230,7 +3329,16 @@ var VinayaConfigObjectSchema = z6.object({
3230
3329
  collisionThreshold: z6.number().int().nonnegative().optional()
3231
3330
  }).optional(),
3232
3331
  prePush: z6.object({
3233
- alwaysRun: z6.array(z6.string()).optional()
3332
+ alwaysRun: z6.array(z6.string()).optional(),
3333
+ readyTests: z6.object({
3334
+ mode: z6.literal("ci"),
3335
+ workflow: z6.literal(".github/workflows/ci.yml"),
3336
+ check: z6.literal("Vinaya CI")
3337
+ }).strict().optional(),
3338
+ requiredCi: z6.object({
3339
+ workflow: z6.literal(".github/workflows/ci.yml"),
3340
+ check: z6.literal("Vinaya CI")
3341
+ }).strict().optional()
3234
3342
  }).optional(),
3235
3343
  report: z6.object({
3236
3344
  commandTimeoutMs: z6.number().int().positive().optional()
@@ -3248,6 +3356,7 @@ var VinayaConfigObjectSchema = z6.object({
3248
3356
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
3249
3357
  }),
3250
3358
  runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
3359
+ runner: z6.enum(["standalone", "atta-engine"]).optional(),
3251
3360
  logs: z6.object({
3252
3361
  folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
3253
3362
  url: z6.string().url().optional(),
@@ -3260,7 +3369,7 @@ var VinayaConfigObjectSchema = z6.object({
3260
3369
  message: "logs: headers requires url"
3261
3370
  }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
3262
3371
  message: "logs: readHeaders requires url"
3263
- }).optional(),
3372
+ }).or(z6.literal(false)).optional(),
3264
3373
  decisionRecords: z6.object({
3265
3374
  path: RepoRelativePathSchema
3266
3375
  }).strict().optional()
@@ -3367,6 +3476,7 @@ function stripGlobalOnlyKeys(config, path) {
3367
3476
  }
3368
3477
  return result;
3369
3478
  }
3479
+ var emittedLocalOverrideWarnings = new Set;
3370
3480
  function resolveRuntimeDirSetting(config) {
3371
3481
  return config?.runtimeDir ?? null;
3372
3482
  }
@@ -3814,7 +3924,7 @@ function appendLoopLogLine(path, line) {
3814
3924
  import {
3815
3925
  closeSync as closeSync4,
3816
3926
  constants as fsConstants4,
3817
- lstatSync as lstatSync2,
3927
+ lstatSync as lstatSync3,
3818
3928
  mkdirSync as mkdirSync4,
3819
3929
  openSync as openSync4,
3820
3930
  linkSync as linkSync2,
@@ -3985,7 +4095,7 @@ function removeQueueHead(path, cut) {
3985
4095
  function queueBucketSize(path) {
3986
4096
  let lstat;
3987
4097
  try {
3988
- lstat = lstatSync2(path);
4098
+ lstat = lstatSync3(path);
3989
4099
  } catch (err) {
3990
4100
  if (!isEnoent(err))
3991
4101
  throw err;
@@ -4152,6 +4262,7 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
4152
4262
 
4153
4263
  // src/lib/log-sink.ts
4154
4264
  var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
4265
+ var LOG_FOLDER_ONLY_ENV = "VINAYA_LOG_FOLDER_ONLY";
4155
4266
  function describeFolderFallback(reason) {
4156
4267
  if (reason.kind === "anchor-unreadable") {
4157
4268
  return `not delivering to the configured log server ${reason.intendedUrl} — the default branch's ` + "vinaya.config.json could not be read to confirm it (the trust-anchor read via `gh` was offline, " + "unauthenticated, or slower than its deadline); events are written to the local folder and can be " + "delivered later with `vinaya log send`";
@@ -4191,6 +4302,9 @@ function logsCredentialMissing(headers, env) {
4191
4302
  return false;
4192
4303
  }
4193
4304
  function resolveLogDestinationFrom(input) {
4305
+ if (input.localConfig?.logs === false || input.unattended && input.trustAnchorConfig?.logs === false) {
4306
+ return { kind: "none", reason: "logs: false disables Log recording" };
4307
+ }
4194
4308
  const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
4195
4309
  if (spoolDir !== undefined && spoolDir.trim() !== "") {
4196
4310
  return { kind: "folder", folder: spoolDir };
@@ -4210,6 +4324,10 @@ function resolveLogDestinationFrom(input) {
4210
4324
  } else {
4211
4325
  effective = local;
4212
4326
  }
4327
+ if (input.folderOnly || input.env[LOG_FOLDER_ONLY_ENV] === "1") {
4328
+ const folder = effective && "folder" in effective && !isInsideRepo(effective.folder, input.repoRoot) ? effective.folder : input.defaultFolder;
4329
+ return { kind: "folder", folder };
4330
+ }
4213
4331
  if (hostFromEnv(input.env) === "ci") {
4214
4332
  if (effective && "url" in effective) {
4215
4333
  if (logsCredentialMissing(effective.headers, input.env)) {
@@ -4234,21 +4352,51 @@ function resolveLogDestinationFrom(input) {
4234
4352
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
4235
4353
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
4236
4354
  }
4237
- var processTrustAnchorByRepo = new Map;
4355
+ var LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS = 30000;
4356
+ var LOG_DESTINATION_ANCHOR_MAX_RETRIES = 5;
4357
+ function createTrustAnchorCache(read, now = Date.now, bounds = {
4358
+ retryIntervalMs: LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS,
4359
+ maxRetries: LOG_DESTINATION_ANCHOR_MAX_RETRIES
4360
+ }) {
4361
+ const slots = new Map;
4362
+ const start = (repoRoot, retries) => {
4363
+ const slot = {
4364
+ reading: Promise.resolve().then(read).catch(() => null),
4365
+ retries,
4366
+ missedAt: null
4367
+ };
4368
+ slots.set(repoRoot, slot);
4369
+ slot.reading.then((config) => {
4370
+ if (config === null)
4371
+ slot.missedAt = now();
4372
+ });
4373
+ return slot.reading;
4374
+ };
4375
+ return {
4376
+ get: (repoRoot) => {
4377
+ const slot = slots.get(repoRoot);
4378
+ if (slot === undefined)
4379
+ return start(repoRoot, 0);
4380
+ if (slot.missedAt === null)
4381
+ return slot.reading;
4382
+ if (slot.retries >= bounds.maxRetries || now() - slot.missedAt < bounds.retryIntervalMs)
4383
+ return slot.reading;
4384
+ return start(repoRoot, slot.retries + 1);
4385
+ },
4386
+ clear: () => slots.clear()
4387
+ };
4388
+ }
4389
+ var processTrustAnchorByRepo = createTrustAnchorCache(safeLoadTrustAnchorConfig);
4238
4390
  function processTrustAnchor(repoRoot) {
4239
- const cached = processTrustAnchorByRepo.get(repoRoot);
4240
- if (cached !== undefined)
4241
- return cached;
4242
- const reading = safeLoadTrustAnchorConfig();
4243
- processTrustAnchorByRepo.set(repoRoot, reading);
4244
- return reading;
4391
+ return processTrustAnchorByRepo.get(repoRoot);
4245
4392
  }
4246
- async function defaultResolveLogDestination(repo, env) {
4393
+ async function defaultResolveLogDestination(repo, env, folderOnly = false) {
4247
4394
  const localConfig = loadConfig();
4248
4395
  const unattended = isUnattendedProcess(process.env);
4249
4396
  const repoRoot = repoRootSync();
4250
4397
  return resolveLogDestinationFrom({
4251
4398
  localConfig,
4399
+ folderOnly,
4252
4400
  trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
4253
4401
  unattended,
4254
4402
  env,
@@ -4257,14 +4405,16 @@ async function defaultResolveLogDestination(repo, env) {
4257
4405
  });
4258
4406
  }
4259
4407
  function unresolvedLogDestination(env) {
4408
+ const loaded = loadConfig();
4409
+ if (loaded?.logs === false)
4410
+ return { kind: "none", reason: "logs: false disables Log recording" };
4260
4411
  if (hostFromEnv(env) === "ci") {
4261
4412
  return {
4262
4413
  kind: "none",
4263
4414
  reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
4264
4415
  };
4265
4416
  }
4266
- const loaded = loadConfig();
4267
- const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
4417
+ const localConfig = loaded?.logs && loaded.logs.url !== undefined ? { ...loaded, logs: undefined } : loaded;
4268
4418
  const unattended = isUnattendedProcess(process.env);
4269
4419
  const repoRoot = repoRootSync();
4270
4420
  const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
@@ -4486,6 +4636,7 @@ async function resolveHeadSha(cwd) {
4486
4636
  }
4487
4637
  function defaultDeps() {
4488
4638
  return {
4639
+ readConfig: loadConfig,
4489
4640
  outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
4490
4641
  home: () => homedir3(),
4491
4642
  hostname: () => osHostname(),
@@ -4669,23 +4820,59 @@ function createLogSink(overrides = {}) {
4669
4820
  };
4670
4821
  let contextCache;
4671
4822
  let settledContext;
4823
+ let contextEnv = {};
4824
+ const resolveDestination = async (repo, env) => deps.readConfig()?.logs === false ? { kind: "none", reason: "logs: false disables Log recording" } : await deps.resolveLogDestination(repo, env, deps.folderOnly);
4672
4825
  const context = () => {
4673
4826
  if (contextCache === undefined) {
4674
4827
  const env = deps.env();
4828
+ contextEnv = env;
4675
4829
  contextCache = Promise.all([
4676
4830
  withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
4677
4831
  doctrine()
4678
4832
  ]).then(async ([resolved, doctrineValue]) => {
4679
4833
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
4680
- settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
4834
+ settledContext = { repo, doctrine: doctrineValue, destination: await resolveDestination(repo, env) };
4835
+ destinationRetryDueAt = deps.now().getTime() + LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS;
4681
4836
  return settledContext;
4682
4837
  });
4683
4838
  }
4684
4839
  return contextCache;
4685
4840
  };
4841
+ let destinationRetries = 0;
4842
+ let destinationRetryDueAt = 0;
4843
+ let destinationRetryInFlight = false;
4844
+ const retryDestinationIfDue = (ctx) => {
4845
+ if (ctx.destination.kind !== "folder" || ctx.destination.fallbackReason?.kind !== "anchor-unreadable")
4846
+ return;
4847
+ if (destinationRetryInFlight || destinationRetries >= LOG_DESTINATION_ANCHOR_MAX_RETRIES)
4848
+ return;
4849
+ if (deps.now().getTime() < destinationRetryDueAt)
4850
+ return;
4851
+ destinationRetryInFlight = true;
4852
+ destinationRetries++;
4853
+ const generation = contextCache;
4854
+ Promise.resolve().then(() => resolveDestination(ctx.repo, contextEnv)).then((destination) => {
4855
+ if (contextCache !== generation)
4856
+ return;
4857
+ if (destination.kind === "server") {
4858
+ settledContext = { ...ctx, destination };
4859
+ contextCache = Promise.resolve(settledContext);
4860
+ return;
4861
+ }
4862
+ if (destination.kind !== "folder" || destination.fallbackReason?.kind !== "anchor-unreadable") {
4863
+ destinationRetries = LOG_DESTINATION_ANCHOR_MAX_RETRIES;
4864
+ }
4865
+ }, () => {
4866
+ return;
4867
+ }).finally(() => {
4868
+ destinationRetryInFlight = false;
4869
+ destinationRetryDueAt = deps.now().getTime() + LOG_DESTINATION_ANCHOR_RETRY_INTERVAL_MS;
4870
+ });
4871
+ };
4686
4872
  const resetContext = () => {
4687
4873
  contextCache = undefined;
4688
4874
  settledContext = undefined;
4875
+ destinationRetries = 0;
4689
4876
  };
4690
4877
  let drainChain = Promise.resolve();
4691
4878
  const pendingWrites = new Set;
@@ -4698,24 +4885,30 @@ function createLogSink(overrides = {}) {
4698
4885
  `);
4699
4886
  });
4700
4887
  };
4701
- const snapshot = () => {
4888
+ const snapshot = (attribution) => {
4702
4889
  const env = deps.env();
4703
4890
  return {
4891
+ attributed: attribution !== undefined,
4704
4892
  host: hostFromEnv(env),
4705
4893
  now: deps.now(),
4706
4894
  seq: seq++,
4707
4895
  envFields: {
4708
- role: env.VINAYA_ROLE,
4896
+ role: attribution?.role ?? env.VINAYA_ROLE,
4709
4897
  task: env.VINAYA_TASK,
4710
- round: env.VINAYA_ROUND,
4898
+ round: attribution ? String(attribution.round) : env.VINAYA_ROUND,
4711
4899
  pr: env.VINAYA_PR,
4712
4900
  run: env.VINAYA_RUN || runId,
4713
- attempt: env.VINAYA_ATTEMPT,
4901
+ attempt: attribution ? String(attribution.attempt) : env.VINAYA_ATTEMPT,
4714
4902
  parent: env.VINAYA_PARENT_EVENT,
4715
4903
  workRef: env.VINAYA_WORK_REF,
4716
4904
  flow: env.VINAYA_FLOW,
4717
4905
  flowVersion: env.VINAYA_FLOW_VERSION,
4718
4906
  runtime: env.VINAYA_RUNTIME,
4907
+ processId: env.VINAYA_PROCESS_ID,
4908
+ processVersion: env.VINAYA_PROCESS_VERSION,
4909
+ processDigest: env.VINAYA_PROCESS_DIGEST,
4910
+ runnerId: env.VINAYA_RUNNER_ID,
4911
+ runnerVersion: env.VINAYA_RUNNER_VERSION,
4719
4912
  source: env.VINAYA_SOURCE
4720
4913
  }
4721
4914
  };
@@ -4745,7 +4938,7 @@ function createLogSink(overrides = {}) {
4745
4938
  eventId: randomUUID2(),
4746
4939
  processId,
4747
4940
  revision: headSha,
4748
- provenance: deps.provenance,
4941
+ provenance: call.attributed ? "parent_attributed" : deps.provenance,
4749
4942
  inputVersions: deps.inputVersions()
4750
4943
  });
4751
4944
  const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
@@ -4770,11 +4963,14 @@ function createLogSink(overrides = {}) {
4770
4963
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
4771
4964
  }
4772
4965
  };
4773
- function log(e) {
4966
+ function log(e, attribution) {
4774
4967
  try {
4775
- const call = snapshot();
4968
+ const call = snapshot(attribution);
4776
4969
  const write = async () => {
4777
4970
  const ctx = await context();
4971
+ try {
4972
+ retryDestinationIfDue(ctx);
4973
+ } catch {}
4778
4974
  if (ctx.destination.kind === "none") {
4779
4975
  writeEvent(e, call, ctx, null, null, true);
4780
4976
  return;
@@ -4798,9 +4994,13 @@ function createLogSink(overrides = {}) {
4798
4994
  function logSync(e, opts = {}) {
4799
4995
  try {
4800
4996
  const call = snapshot();
4801
- let ctx = settledContext;
4997
+ let ctx = deps.readConfig()?.logs === false ? {
4998
+ repo: null,
4999
+ doctrine: "unknown",
5000
+ destination: { kind: "none", reason: "logs: false disables Log recording" }
5001
+ } : settledContext;
4802
5002
  if (ctx === undefined) {
4803
- const destination = deps.unresolvedLogDestination(deps.env());
5003
+ const destination = deps.readConfig()?.logs === false ? { kind: "none", reason: "logs: false disables Log recording" } : deps.unresolvedLogDestination(deps.env());
4804
5004
  if (destination.kind === "folder" && !opts.quiet) {
4805
5005
  warnOnce(`vinaya: the process ended before its log destination was resolved — the event is written to ${destination.folder}; \`vinaya log send\` delivers it to a configured server later
4806
5006
  `);
@@ -5012,6 +5212,10 @@ var COMMANDS = [
5012
5212
  needs: ["forge", "operator-seat"],
5013
5213
  description: "One command from a planned Issue to a reviewed pull request — exactly one developer started",
5014
5214
  flags: [
5215
+ {
5216
+ flag: "--runner <standalone|atta-engine>",
5217
+ description: "Override runner config for this invocation; absent uses config, whose default is standalone"
5218
+ },
5015
5219
  {
5016
5220
  flag: "--agent <claude|codex>",
5017
5221
  description: "Vendor for the developer and both reviewers this run dispatches"
@@ -5023,17 +5227,39 @@ var COMMANDS = [
5023
5227
  {
5024
5228
  flag: "--widen-surface <glob,...> --reason <text>",
5025
5229
  description: "Continue a pre-pull-request escalation whose Developer asked for `widen_surface`: supersede the frozen brief with the globs added to `## Surface`, record that as the escalation's resolution, grade the widened Issue through the write gate, then start the run"
5230
+ },
5231
+ {
5232
+ flag: "--rollback",
5233
+ description: "Run the terminate-and-restart procedure for this task: cancel its in-flight Engine run, reconcile every prepared and uncertain effect by its identity, then start a fresh standalone run from the same frozen brief. Refuses a task whose recorded runner is not `atta-engine`"
5026
5234
  }
5027
5235
  ],
5028
5236
  details: [
5237
+ "The atta-engine runner starts the workspace Engine script with Bun, streams its output and returns its exit code. A published install without the script prints one notice and falls back to standalone. Engine Log events use the local folder only; logs: false disables all Log destinations for both runners.",
5238
+ "A run's runner is recorded when it starts and never changes: switching `runner` in config changes only the runner of new runs, and a run recorded on `atta-engine` keeps routing to the Engine for `task status`, `task_resume` and `task_cancel`. A start on a pause another runner holds is refused with a typed reason naming the recorded runner and the requested one, and so is a start on another runner's Engine run that is still in flight with no pause held — halted or stopped short of completed or cancelled.",
5239
+ "`--rollback` ends the Engine run first: a held pause through the shared cancel `task_cancel` uses, which needs a Principal ruling newer than the pause as any cancel does; a run halted with no pause held has its started effects fenced; a run that already completed or was cancelled is refused, as is a driver still running with no pause held, which is never signalled; and the standalone run never starts while the Engine driver lives, a cancelled run's driver given a bounded wait to release its lock. Every started and uncertain effect is then reconciled by its identity: one the forge carries is recorded verified, one it does not carry is left for the restarted run to complete, and one the forge read cannot settle refuses the restart. Each rehearsal appends a record — task, recorded runner, action, reconciled effect identities, the restarted run's runner and terminal state — to `backend-rollback-rehearsals.jsonl` in the task's runtime directory, whether it completed, was refused or failed at a later step, and nothing removes it.",
5029
5240
  "`--widen-surface` is the Planner's one command for a widen-surface escalation, and refuses before any write when the held pause is not one (no pause, a pause with a pull request — whose continuation is the ruling on that pull request — or a round whose Developer asked for no `widen_surface`), when a driver is still alive for the task, when the escalation's resolution is already consumed (a replay — the Surface is never widened twice), or when the widened body fails the write gate, whose findings name the field to edit first. The escalation packet's permitted next actions name this command with the globs the Developer asked for, and `task_resume` refuses such an escalation naming it.",
5030
- "Composes `task brief`'s own preparation (`prepareTask`) with the watching driver (`runDriverLoop`, `dev-review-loop.ts`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
5241
+ "Prepares the frozen brief and resolves the task, branch and model once. The standalone runner then starts the watching driver (`runDriverLoop`, `dev-review-loop.ts`). Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
5031
5242
  "A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
5032
5243
  "Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
5033
5244
  "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the working `vinaya task run` command for this task's own branch to continue by hand — `<tranche> <n>` for a tranche task, `--issue <n>` for a backlog one — never a `dev-review-loop --resume` line naming a pull-request number this pause does not have), a usage/argv error (exit `2`), and any other failure (exit `3`)."
5034
5245
  ],
5035
5246
  status: "shipped"
5036
5247
  },
5248
+ {
5249
+ name: "task switch",
5250
+ needs: ["forge"],
5251
+ description: "Change a task's agent or model by setting its Engine checkpoint aside, so the next `task run` is accepted",
5252
+ flags: [
5253
+ { flag: "--issue <n>", description: "Address the task by its Issue number instead of `<tranche> <n>`" },
5254
+ { flag: "--agent <claude|codex>", description: "Vendor the next `task run` of the task continues on" },
5255
+ { flag: "--model <model>", description: "Model the next `task run` is meant to use; absent, the vendor default" }
5256
+ ],
5257
+ details: [
5258
+ "Refuses, changing nothing, while a driver for the task is alive, naming its pid. Otherwise moves the task's Engine checkpoint (`checkpoints.sqlite` with its `-wal` and `-shm` files) into a timestamped `switched-*` folder of the task's run directory and never deletes it; the branch, its commits and its pull request are untouched, so the next `task run` with the new agent continues the same branch on a fresh checkpoint.",
5259
+ "Writes one driver-log line naming the from and to agent, the from and to model and the folder the checkpoint went to. On the standalone runner it changes nothing on disk and says that runner already continues a task on a new `--agent` by itself. `task run` and `run-engine --resume` still refuse an agent other than the checkpoint's, and their refusal names this command."
5260
+ ],
5261
+ status: "shipped"
5262
+ },
5037
5263
  {
5038
5264
  name: "task status",
5039
5265
  needs: ["forge"],
@@ -5740,7 +5966,10 @@ var StateSourceConfigSchema = z7.discriminatedUnion("kind", [
5740
5966
  z7.object({ kind: z7.literal("file"), root: z7.string().optional() })
5741
5967
  ]);
5742
5968
  // src/checks/edge-resolve.ts
5969
+ import { execFile as execFile6 } from "node:child_process";
5970
+ import { promisify as promisify6 } from "node:util";
5743
5971
  var issueCache = new Map;
5972
+ var execFileAsync6 = promisify6(execFile6);
5744
5973
  var siblingTrancheCache = new Map;
5745
5974
 
5746
5975
  // src/commands/doctrine.ts
@@ -5774,8 +6003,480 @@ var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
5774
6003
  "conflicts-with"
5775
6004
  ]);
5776
6005
 
6006
+ // src/lib/pre-push-failed-tests.ts
6007
+ import { execFileSync as execFileSync4 } from "node:child_process";
6008
+ import { createHash as createHash2 } from "node:crypto";
6009
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync8, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
6010
+ import { dirname as dirname8, isAbsolute as isAbsolute2, join as join9 } from "node:path";
6011
+ var FAILED_TESTS_RECORD = "vinaya/pre-push-failed-tests.json";
6012
+ var LAST_PUSH_RESULT = "vinaya/pre-push-last-result.json";
6013
+ var SELECTION_NOTE = "vinaya/pre-push-selection.json";
6014
+ var TEST_SELECTION_COMPLETE = "vinaya-test-selection-complete ";
6015
+ function completedTestSelection(log, cwd, expected) {
6016
+ const completed = new Set;
6017
+ let batch = [];
6018
+ let markers = 0;
6019
+ const absolute = (path) => isAbsolute2(path) ? path : join9(cwd, path);
6020
+ for (const line of log.split(`
6021
+ `)) {
6022
+ if (!line.startsWith(TEST_SELECTION_COMPLETE)) {
6023
+ batch.push(line);
6024
+ continue;
6025
+ }
6026
+ try {
6027
+ const result = JSON.parse(line.slice(TEST_SELECTION_COMPLETE.length));
6028
+ if (![0, 1].includes(result.exitCode) || !Array.isArray(result.files) || !result.files.every((file) => typeof file === "string"))
6029
+ return false;
6030
+ const text = batch.join(`
6031
+ `);
6032
+ const summary = [...text.matchAll(/^Ran \d+ tests? across (\d+) files?\.(?:.*)$/gm)].at(-1);
6033
+ const headers = new Set([...text.matchAll(/^(\S.*\.test\.[a-zA-Z]+):$/gm)].map((match) => absolute(match[1])));
6034
+ const files = new Set(result.files.map(absolute));
6035
+ if (!summary || Number(summary[1]) !== files.size || headers.size !== files.size || [...files].some((file) => !headers.has(file)))
6036
+ return false;
6037
+ for (const file of files)
6038
+ completed.add(file);
6039
+ markers++;
6040
+ batch = [];
6041
+ } catch {
6042
+ return false;
6043
+ }
6044
+ }
6045
+ if (markers === 0 || batch.join(`
6046
+ `).trim() !== "")
6047
+ return false;
6048
+ return expected === undefined || new Set(expected.map(absolute)).size === completed.size && expected.every((file) => completed.has(absolute(file)));
6049
+ }
6050
+ function parseFailedTestFiles(log, cwd, exitedNonZero, selected) {
6051
+ if (exitedNonZero && !completedTestSelection(log, cwd, selected))
6052
+ return "all";
6053
+ const failed = new Set;
6054
+ let current = null;
6055
+ for (const raw of log.split(`
6056
+ `)) {
6057
+ const line = raw.trimEnd();
6058
+ if (/^\d+ tests? failed:/.test(line)) {
6059
+ current = null;
6060
+ continue;
6061
+ }
6062
+ const header = /^(\S.*\.test\.[a-zA-Z]+):$/.exec(line);
6063
+ if (header?.[1]) {
6064
+ current = isAbsolute2(header[1]) ? header[1] : join9(cwd, header[1]);
6065
+ continue;
6066
+ }
6067
+ if (current && (/^\(fail\) /.test(line) || line.startsWith("# Unhandled error")))
6068
+ failed.add(current);
6069
+ }
6070
+ if (failed.size === 0)
6071
+ return exitedNonZero ? "all" : [];
6072
+ return [...failed].sort();
6073
+ }
6074
+ function chooseTests(inputs) {
6075
+ const { record, head, branch, fullSelection } = inputs;
6076
+ const full = {
6077
+ version: 1,
6078
+ mode: "full",
6079
+ head,
6080
+ fullCount: fullSelection.length,
6081
+ selected: fullSelection
6082
+ };
6083
+ if (!record || record.failed === "all" || record.selectionCompleted !== true)
6084
+ return full;
6085
+ if (record.branch !== branch || !inputs.recordIsAncestor)
6086
+ return full;
6087
+ if (!record.failed.every(inputs.exists))
6088
+ return full;
6089
+ const rerunFailed = [...record.failed];
6090
+ const affectedSince = inputs.affectedSince.filter(inputs.exists).sort();
6091
+ const selected = [...new Set([...rerunFailed, ...affectedSince])].sort();
6092
+ if (selected.length === 0)
6093
+ return full;
6094
+ return {
6095
+ version: 1,
6096
+ mode: "rerun",
6097
+ head,
6098
+ rerunOf: record.head,
6099
+ recordedHead: record.head,
6100
+ rerunFailed,
6101
+ affectedSince,
6102
+ fullCount: fullSelection.length,
6103
+ selected
6104
+ };
6105
+ }
6106
+ function recordFromRun(outcome, failed, head, branch, now) {
6107
+ if (outcome === "passed")
6108
+ return null;
6109
+ return { version: 1, head, branch, failed, recordedAt: now.toISOString(), selectionCompleted: failed !== "all" };
6110
+ }
6111
+ function parseRecord(text) {
6112
+ if (!text)
6113
+ return null;
6114
+ try {
6115
+ const value = JSON.parse(text);
6116
+ if (value.version !== 1 || typeof value.head !== "string" || typeof value.branch !== "string")
6117
+ return null;
6118
+ if (value.failed !== "all" && !Array.isArray(value.failed))
6119
+ return null;
6120
+ return value;
6121
+ } catch {
6122
+ return null;
6123
+ }
6124
+ }
6125
+ var PASSING_RECORD_VERSION = 2;
6126
+ var SELECTION_POLICY = {
6127
+ name: "pre-push-since-green",
6128
+ version: 1,
6129
+ depth: "one",
6130
+ testTimeoutMs: 30000,
6131
+ rootConfigFile: "vinaya.config.json"
6132
+ };
6133
+ var VERIFICATION_LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "yarn.lock", "pnpm-lock.yaml"];
6134
+ var VERIFICATION_INPUT_FILES = ["vinaya.config.json", "package.json", "bunfig.toml", ...VERIFICATION_LOCKFILES];
6135
+ var VERIFICATION_ENV_KEYS = ["BUN_ENV", "CI", "NODE_ENV", "NODE_OPTIONS", "TZ"];
6136
+ function parsePassingRecord(text) {
6137
+ if (!text)
6138
+ return null;
6139
+ try {
6140
+ const value = JSON.parse(text);
6141
+ if (value.version !== PASSING_RECORD_VERSION || value.kind !== "passed")
6142
+ return null;
6143
+ if (typeof value.head !== "string" || typeof value.branch !== "string" || typeof value.context !== "string")
6144
+ return null;
6145
+ if (!Array.isArray(value.selection) || !value.selection.every((file) => typeof file === "string"))
6146
+ return null;
6147
+ return value;
6148
+ } catch {
6149
+ return null;
6150
+ }
6151
+ }
6152
+ function parseSelectionNote(text, head) {
6153
+ if (!text)
6154
+ return null;
6155
+ try {
6156
+ const value = JSON.parse(text);
6157
+ if (value.head !== head || !Array.isArray(value.selected))
6158
+ return null;
6159
+ if (!value.selected.every((file) => typeof file === "string"))
6160
+ return null;
6161
+ return { mode: "full", ...value };
6162
+ } catch {
6163
+ return null;
6164
+ }
6165
+ }
6166
+ function passingRecordFromRun(inputs) {
6167
+ const { selection, head, branch } = inputs;
6168
+ if (inputs.outcome !== "passed" || !selection || selection.head !== head)
6169
+ return null;
6170
+ if (selection.selected.length === 0 || !head || !branch || branch === "HEAD")
6171
+ return null;
6172
+ if (!selection.context || inputs.context !== selection.context || inputs.inputsClean !== true)
6173
+ return null;
6174
+ if (!completedTestSelection(inputs.log, inputs.repoRoot, selection.selected))
6175
+ return null;
6176
+ return {
6177
+ version: PASSING_RECORD_VERSION,
6178
+ kind: "passed",
6179
+ head,
6180
+ branch,
6181
+ selection: [...selection.selected],
6182
+ selectionCompleted: true,
6183
+ context: selection.context,
6184
+ recordedAt: inputs.now.toISOString()
6185
+ };
6186
+ }
6187
+ function decideSelection(deps) {
6188
+ const context = deps.context !== null && deps.inputsClean === true ? deps.context : null;
6189
+ const withContext = (note) => context === null ? note : { ...note, context };
6190
+ const sinceGreen = deps.failed === null ? sinceGreenNote(deps, context) : null;
6191
+ if (sinceGreen)
6192
+ return { note: withContext(sinceGreen), full: null };
6193
+ const full = deps.full();
6194
+ const record = deps.failed;
6195
+ const recordIsAncestor = record ? deps.isAncestor(record.head) : false;
6196
+ let usable = record;
6197
+ let affectedSince = [];
6198
+ if (record && record.failed !== "all" && recordIsAncestor && record.branch === deps.branch) {
6199
+ const changed = deps.changedBetween(record.head);
6200
+ if (changed === null)
6201
+ usable = null;
6202
+ else
6203
+ affectedSince = deps.affectedSince(changed);
6204
+ }
6205
+ const note = chooseTests({
6206
+ record: usable,
6207
+ head: deps.head,
6208
+ branch: deps.branch,
6209
+ recordIsAncestor,
6210
+ fullSelection: full.selected,
6211
+ affectedSince,
6212
+ exists: deps.exists
6213
+ });
6214
+ return { note: withContext(note), full };
6215
+ }
6216
+ function sinceGreenNote(deps, context) {
6217
+ const passing = deps.passing;
6218
+ if (!passing || passing.selectionCompleted !== true || passing.selection.length === 0)
6219
+ return null;
6220
+ if (passing.branch !== deps.branch || context === null || passing.context !== context)
6221
+ return null;
6222
+ if (!deps.isAncestor(passing.head))
6223
+ return null;
6224
+ const changed = deps.changedBetween(passing.head);
6225
+ if (changed === null || changed.includes(join9(deps.repoRoot, SELECTION_POLICY.rootConfigFile)))
6226
+ return null;
6227
+ const read = deps.sinceGreen(passing.head);
6228
+ if (read.readFailed)
6229
+ return null;
6230
+ const selected = [...new Set(read.selected)].filter(deps.exists).sort();
6231
+ const affectedSince = selected.filter((file) => !deps.isAlwaysRun(file) || changed.includes(file));
6232
+ if (changed.length > 0 && affectedSince.length === 0)
6233
+ return null;
6234
+ return {
6235
+ version: 1,
6236
+ mode: "since-green",
6237
+ head: deps.head,
6238
+ recordedHead: passing.head,
6239
+ affectedSince,
6240
+ fullCount: null,
6241
+ selected
6242
+ };
6243
+ }
6244
+ function cleanGitEnv() {
6245
+ const env = { ...process.env };
6246
+ for (const key of Object.keys(env))
6247
+ if (key.startsWith("GIT_"))
6248
+ delete env[key];
6249
+ return env;
6250
+ }
6251
+ function git(repoRoot, args) {
6252
+ try {
6253
+ return execFileSync4("git", args, {
6254
+ cwd: repoRoot,
6255
+ encoding: "utf8",
6256
+ stdio: ["ignore", "pipe", "ignore"],
6257
+ env: cleanGitEnv()
6258
+ }).trim();
6259
+ } catch {
6260
+ return null;
6261
+ }
6262
+ }
6263
+ function gitPath(repoRoot, name) {
6264
+ const out = git(repoRoot, ["rev-parse", "--git-path", name]);
6265
+ if (!out)
6266
+ return null;
6267
+ return isAbsolute2(out) ? out : join9(repoRoot, out);
6268
+ }
6269
+ function currentHead(repoRoot) {
6270
+ return git(repoRoot, ["rev-parse", "HEAD"]) ?? "";
6271
+ }
6272
+ function currentBranch(repoRoot) {
6273
+ return git(repoRoot, ["rev-parse", "--abbrev-ref", "HEAD"]) ?? "";
6274
+ }
6275
+ function isAncestor(repoRoot, ancestor, head) {
6276
+ try {
6277
+ execFileSync4("git", ["merge-base", "--is-ancestor", ancestor, head], {
6278
+ cwd: repoRoot,
6279
+ stdio: "ignore",
6280
+ env: cleanGitEnv()
6281
+ });
6282
+ return true;
6283
+ } catch {
6284
+ return false;
6285
+ }
6286
+ }
6287
+ function changedBetween(repoRoot, from, to) {
6288
+ const read = git(repoRoot, ["diff", "--name-only", "--diff-filter=ACMRD", from, to]);
6289
+ if (read === null)
6290
+ return null;
6291
+ return read.split(`
6292
+ `).map((s) => s.trim()).filter(Boolean).map((f) => join9(repoRoot, f));
6293
+ }
6294
+ function readJsonUnderGit(repoRoot, name) {
6295
+ const path = gitPath(repoRoot, name);
6296
+ if (!path || !existsSync8(path))
6297
+ return null;
6298
+ try {
6299
+ return readFileSync8(path, "utf8");
6300
+ } catch {
6301
+ return null;
6302
+ }
6303
+ }
6304
+ function writeJsonUnderGit(repoRoot, name, value) {
6305
+ const path = gitPath(repoRoot, name);
6306
+ if (!path)
6307
+ return;
6308
+ mkdirSync6(dirname8(path), { recursive: true });
6309
+ writeFileSync4(path, `${JSON.stringify(value, null, 2)}
6310
+ `);
6311
+ }
6312
+ function removeUnderGit(repoRoot, name) {
6313
+ const path = gitPath(repoRoot, name);
6314
+ if (path)
6315
+ rmSync(path, { force: true });
6316
+ }
6317
+ function readFailedTestsRecord(repoRoot) {
6318
+ return parseRecord(readJsonUnderGit(repoRoot, FAILED_TESTS_RECORD));
6319
+ }
6320
+ function readPassingRecord(repoRoot) {
6321
+ return parsePassingRecord(readJsonUnderGit(repoRoot, FAILED_TESTS_RECORD));
6322
+ }
6323
+ function clearRecordOfKind(repoRoot, kind) {
6324
+ const text = readJsonUnderGit(repoRoot, FAILED_TESTS_RECORD);
6325
+ const other = kind === "failed" ? parsePassingRecord(text) : parseRecord(text);
6326
+ if (text !== null && other !== null)
6327
+ return;
6328
+ removeUnderGit(repoRoot, FAILED_TESTS_RECORD);
6329
+ }
6330
+ function computeVerificationContext(repoRoot, env = process.env) {
6331
+ try {
6332
+ const sha = (data) => createHash2("sha256").update(data).digest("hex");
6333
+ const read = (name) => {
6334
+ const path = join9(repoRoot, name);
6335
+ return existsSync8(path) ? readFileSync8(path) : null;
6336
+ };
6337
+ const json = (name) => {
6338
+ const bytes = read(name);
6339
+ return bytes === null ? null : JSON.parse(bytes.toString("utf8"));
6340
+ };
6341
+ const config = json("vinaya.config.json");
6342
+ const pkg = json("package.json");
6343
+ const scripts = pkg?.scripts;
6344
+ const bunfig = read("bunfig.toml");
6345
+ const parts = {
6346
+ policy: sha(JSON.stringify(SELECTION_POLICY)),
6347
+ inputs: sha(JSON.stringify({ prePush: config?.prePush ?? null, workspaces: pkg?.workspaces ?? null })),
6348
+ lockfile: sha(VERIFICATION_LOCKFILES.map((name) => {
6349
+ const bytes = read(name);
6350
+ return `${name}:${bytes === null ? "absent" : sha(bytes)}`;
6351
+ }).join(`
6352
+ `)),
6353
+ runner: sha(JSON.stringify({
6354
+ bunfig: bunfig === null ? null : sha(bunfig),
6355
+ testScript: scripts?.test ?? null,
6356
+ bun: process.versions.bun ?? null
6357
+ })),
6358
+ environment: sha(VERIFICATION_ENV_KEYS.map((key) => `${key}=${env[key] ?? "\x00unset"}`).join(`
6359
+ `))
6360
+ };
6361
+ return { digest: sha(JSON.stringify(parts)), parts };
6362
+ } catch {
6363
+ return null;
6364
+ }
6365
+ }
6366
+ function verificationInputsDirty(repoRoot) {
6367
+ const out = git(repoRoot, ["status", "--porcelain", "--", ...VERIFICATION_INPUT_FILES]);
6368
+ return out === null ? null : out !== "";
6369
+ }
6370
+
6371
+ // src/lib/pre-push-mode-logic.ts
6372
+ var PUSH_MODE_MARKER = "vinaya/push-mode";
6373
+ function parseStorageMarker(text) {
6374
+ if (!text)
6375
+ return null;
6376
+ try {
6377
+ const value = JSON.parse(text);
6378
+ if (value.version !== 1 || value.mode !== "storage")
6379
+ return null;
6380
+ if (typeof value.runId !== "string" || value.runId === "")
6381
+ return null;
6382
+ if (typeof value.branch !== "string" || value.branch === "")
6383
+ return null;
6384
+ if (typeof value.pid !== "number" || !Number.isInteger(value.pid) || value.pid <= 0)
6385
+ return null;
6386
+ return value;
6387
+ } catch {
6388
+ return null;
6389
+ }
6390
+ }
6391
+ var isTaskBranch2 = (branch) => branch.startsWith("task/");
6392
+ function resolvePushMode(input) {
6393
+ const env = input.envMode?.trim();
6394
+ if (env === "ready" || env === "default")
6395
+ return { ok: true, mode: env };
6396
+ const marker = parseStorageMarker(input.marker);
6397
+ const live = marker !== null && isTaskBranch2(input.branch) && marker.branch === input.branch && input.isPidAlive(marker.pid);
6398
+ if (!live)
6399
+ return { ok: true, mode: "default" };
6400
+ let open;
6401
+ try {
6402
+ open = input.openPullRequests();
6403
+ } catch (error) {
6404
+ return {
6405
+ ok: false,
6406
+ reason: `a storage push runs no tests, so it must first confirm that no pull request is open for ${input.branch}, and that read failed: ${error instanceof Error ? error.message : String(error)}`
6407
+ };
6408
+ }
6409
+ if (open > 0) {
6410
+ return {
6411
+ ok: false,
6412
+ reason: `a pull request is open for ${input.branch}: storage pushes (no tests) are allowed only while none is open — push without the storage mode so the selected tests run`
6413
+ };
6414
+ }
6415
+ return { ok: true, mode: "storage" };
6416
+ }
6417
+
6418
+ // src/lib/process-registry.ts
6419
+ import { execFileSync as execFileSync5 } from "node:child_process";
6420
+ import {
6421
+ closeSync as closeSync6,
6422
+ fsyncSync as fsyncSync2,
6423
+ mkdirSync as mkdirSync7,
6424
+ openSync as openSync6,
6425
+ readdirSync as readdirSync3,
6426
+ readFileSync as readFileSync9,
6427
+ renameSync as renameSync4,
6428
+ rmSync as rmSync2,
6429
+ writeSync as writeSync5
6430
+ } from "node:fs";
6431
+ function linuxStartTime(pid) {
6432
+ try {
6433
+ const stat = readFileSync9(`/proc/${pid}/stat`, "utf8");
6434
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
6435
+ return fields[19] ?? null;
6436
+ } catch {
6437
+ return null;
6438
+ }
6439
+ }
6440
+ function psStartTime(pid) {
6441
+ try {
6442
+ const out = execFileSync5("ps", ["-o", "lstart=", "-p", String(pid)], {
6443
+ encoding: "utf8",
6444
+ stdio: ["ignore", "pipe", "ignore"]
6445
+ }).trim();
6446
+ return out === "" ? null : out;
6447
+ } catch {
6448
+ return null;
6449
+ }
6450
+ }
6451
+ function identityOf(pid) {
6452
+ if (!Number.isInteger(pid) || pid <= 0)
6453
+ return null;
6454
+ const startTime = process.platform === "linux" ? linuxStartTime(pid) : psStartTime(pid);
6455
+ return startTime === null ? null : { pid, startTime };
6456
+ }
6457
+
6458
+ // src/lib/pre-push-ready-policy.ts
6459
+ var DEFERRAL_MARKER_TTL_MS = 30 * 60 * 1000;
6460
+ if (false)
6461
+ ;
6462
+
6463
+ // src/lib/pre-push-test-runner.ts
6464
+ var REPOSITORY_LOCAL_RUN = "scripts/test-suites/local-run.ts";
6465
+ var NATIVE_EXACT = "exact";
6466
+ function parseNativeRunCommand(command) {
6467
+ const tokens = command.trim().split(/\s+/);
6468
+ if (tokens[0] !== "bun" || tokens[1] !== REPOSITORY_LOCAL_RUN || tokens[2] !== NATIVE_EXACT)
6469
+ return null;
6470
+ if (tokens[3] !== "--context" || !/^[0-9a-f]{64}$/.test(tokens[4] ?? "") || tokens[5] !== "--")
6471
+ return null;
6472
+ const identities = tokens.slice(6);
6473
+ if (identities.length === 0 || identities.some((identity) => identity.lastIndexOf("@") <= 0))
6474
+ return null;
6475
+ return { context: tokens[4], identities };
6476
+ }
6477
+
5777
6478
  // src/lib/pr-report-engine.ts
5778
- var execFileAsync6 = promisify6(execFile6);
6479
+ var execFileAsync7 = promisify7(execFile7);
5779
6480
  var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
5780
6481
  const decl = spec.env?.PR_BODY;
5781
6482
  return decl === true || typeof decl === "object" && decl !== null && "optional" in decl;
@@ -5783,23 +6484,23 @@ var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
5783
6484
  var FAILING_STATUSES = new Set(["fail", "error", "timeout"]);
5784
6485
  function readTestRunCacheFile(path) {
5785
6486
  try {
5786
- if (!lstatSync4(path).isFile())
6487
+ if (!lstatSync5(path).isFile())
5787
6488
  return {};
5788
- return JSON.parse(readFileSync8(path, "utf8"));
6489
+ return JSON.parse(readFileSync10(path, "utf8"));
5789
6490
  } catch {
5790
6491
  return {};
5791
6492
  }
5792
6493
  }
5793
6494
  function writeTestRunCacheFile(path, all) {
5794
6495
  const tmp = `${path}.tmp-${process.pid}-${randomUUID3()}`;
5795
- const fd = openSync6(tmp, fsConstants6.O_WRONLY | fsConstants6.O_CREAT | fsConstants6.O_EXCL, 384);
6496
+ const fd = openSync7(tmp, fsConstants6.O_WRONLY | fsConstants6.O_CREAT | fsConstants6.O_EXCL, 384);
5796
6497
  try {
5797
- writeSync5(fd, JSON.stringify(all, null, 2), null, "utf8");
5798
- fsyncSync2(fd);
6498
+ writeSync6(fd, JSON.stringify(all, null, 2), null, "utf8");
6499
+ fsyncSync3(fd);
5799
6500
  } finally {
5800
- closeSync6(fd);
6501
+ closeSync7(fd);
5801
6502
  }
5802
- renameSync4(tmp, path);
6503
+ renameSync5(tmp, path);
5803
6504
  }
5804
6505
  function fileBackedTestRunCache(path, runtimeDir) {
5805
6506
  return {
@@ -5807,7 +6508,7 @@ function fileBackedTestRunCache(path, runtimeDir) {
5807
6508
  set: (key, record) => {
5808
6509
  const all = readTestRunCacheFile(path);
5809
6510
  all[key] = record;
5810
- ensureRunDir(dirname8(path), runtimeDir);
6511
+ ensureRunDir(dirname9(path), runtimeDir);
5811
6512
  writeTestRunCacheFile(path, all);
5812
6513
  }
5813
6514
  };
@@ -5817,10 +6518,16 @@ function defaultTestRunCache() {
5817
6518
  const path = runPath(runtimeDir, "unscoped", { area: "output", file: "test-run-cache.json" });
5818
6519
  return fileBackedTestRunCache(path, runtimeDir);
5819
6520
  }
5820
- async function gitOrNull(args, cwd) {
6521
+ var GIT_MAX_BUFFER = 16 * 1024 * 1024;
6522
+ async function gitOrNull(args, cwd, trim = true) {
5821
6523
  try {
5822
- const { stdout } = await execFileAsync6("git", args, { encoding: "utf8", env: process.env, cwd });
5823
- return stdout.trim();
6524
+ const { stdout } = await execFileAsync7("git", args, {
6525
+ encoding: "utf8",
6526
+ env: process.env,
6527
+ cwd,
6528
+ maxBuffer: GIT_MAX_BUFFER
6529
+ });
6530
+ return trim ? stdout.trim() : stdout;
5824
6531
  } catch {
5825
6532
  return null;
5826
6533
  }
@@ -5837,19 +6544,24 @@ async function collectStateFields(cwd) {
5837
6544
  const head = await gitOrNull(["rev-parse", "HEAD"], cwd);
5838
6545
  if (!head)
5839
6546
  return null;
5840
- const status = await gitOrNull(["status", "--porcelain=v1", "-uall", "--ignored", "-z"], cwd);
6547
+ const status = await gitOrNull(["status", "--porcelain=v1", "-uall", "-z"], cwd);
5841
6548
  if (status === null)
5842
6549
  return null;
6550
+ const ignored = await gitOrNull(["ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"], cwd, false);
6551
+ if (ignored === null)
6552
+ return null;
5843
6553
  const diff = await gitOrNull(["diff", "HEAD"], cwd);
5844
6554
  if (diff === null)
5845
6555
  return null;
5846
- const fields = [hostname(), head, status, diff];
5847
- const uncommitted = status.split(NUL).filter((entry) => entry.startsWith("?? ") || entry.startsWith("!! ")).map((entry) => entry.slice(3)).sort();
6556
+ const fields = [hostname(), head, status, ignored, diff];
6557
+ const untracked = status.split(NUL).filter((entry) => entry.startsWith("?? ")).map((entry) => entry.slice(3));
6558
+ const ignoredPaths = ignored.split(NUL).filter(Boolean);
6559
+ const uncommitted = [...untracked, ...ignoredPaths].sort();
5848
6560
  const base = cwd ?? process.cwd();
5849
6561
  for (const f of uncommitted) {
5850
6562
  fields.push(f);
5851
6563
  try {
5852
- fields.push(readFileSync8(join9(base, f)));
6564
+ fields.push(readFileSync10(join10(base, f)));
5853
6565
  } catch {
5854
6566
  fields.push("MISSING");
5855
6567
  }
@@ -5857,7 +6569,7 @@ async function collectStateFields(cwd) {
5857
6569
  return fields;
5858
6570
  }
5859
6571
  function digestFields(fields) {
5860
- const hash = createHash2("sha256");
6572
+ const hash = createHash3("sha256");
5861
6573
  for (const f of fields)
5862
6574
  hashField(hash, f);
5863
6575
  return hash.digest("hex");
@@ -5924,13 +6636,24 @@ function truncateAgentOutput(output) {
5924
6636
  ${output.slice(-AGENT_COMMAND_OUTPUT_MAX_CHARS)}`;
5925
6637
  }
5926
6638
  var AGENT_COMMAND_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
5927
- async function recordGreenTestRun(command, output, cwd, source, cache = defaultTestRunCache()) {
6639
+ async function recordGreenTestRun(command, output, cwd, source, cache = defaultTestRunCache(), options = {}) {
6640
+ const native = parseNativeRunCommand(command);
6641
+ if (native && options.context !== native.context)
6642
+ return false;
5928
6643
  const key = await testRunCacheKey(command, cwd);
5929
6644
  if (!key)
5930
6645
  return false;
5931
6646
  const truncated = truncateAgentOutput(output);
5932
6647
  const recordedAt = new Date().toISOString();
5933
- cache.set(key, { output: truncated, exitCode: 0, timedOut: false, overflowed: false, recordedAt, source });
6648
+ cache.set(key, {
6649
+ output: truncated,
6650
+ exitCode: 0,
6651
+ timedOut: false,
6652
+ overflowed: false,
6653
+ recordedAt,
6654
+ source,
6655
+ ...options.context ? { context: options.context } : {}
6656
+ });
5934
6657
  const files = bunTestFileArgs(command);
5935
6658
  if (files) {
5936
6659
  const stateKey = await testRunStateKey(cwd);
@@ -5959,7 +6682,7 @@ async function main() {
5959
6682
  }
5960
6683
  let output;
5961
6684
  try {
5962
- output = readFileSync9(logPath, "utf8");
6685
+ output = readFileSync11(logPath, "utf8");
5963
6686
  } catch (err) {
5964
6687
  process.stderr.write(`vinaya pre-push: could not read ${logPath} to cache this run — nothing recorded (${err instanceof Error ? err.message : String(err)}).
5965
6688
  `);