@attalabs/vinaya 0.42.1 → 0.43.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 (88) hide show
  1. package/dist/checks/bin/check-evidence-fresh.js +177 -152
  2. package/dist/checks/bin/check-registry-gates.js +10 -3
  3. package/dist/index.js +300 -173
  4. package/dist/lib/pre-push-cache-test-run.js +145 -144
  5. package/dist/lib/pre-push-changed-files.js +10 -3
  6. package/dist/lib/pre-push-progress-dir.js +169 -147
  7. package/dist/lib/pre-push-select-tests.js +16 -4
  8. package/dist/lib/push-progress-observer.js +169 -147
  9. package/dist/programs/archive.js +172 -148
  10. package/dist/programs/audit.js +169 -147
  11. package/dist/programs/check.js +172 -148
  12. package/dist/programs/commit-msg.js +172 -148
  13. package/dist/programs/dev-review-loop.js +300 -176
  14. package/dist/programs/dispatch.js +1905 -1877
  15. package/dist/programs/log-emit.js +172 -148
  16. package/dist/programs/log-selftest.js +172 -148
  17. package/dist/programs/log-send.js +172 -148
  18. package/dist/programs/pr-report.js +177 -152
  19. package/dist/programs/pr-snapshot.js +172 -148
  20. package/dist/programs/pr-verify-evidence.js +177 -152
  21. package/dist/programs/pr.js +172 -148
  22. package/dist/programs/review-post.js +172 -148
  23. package/dist/programs/review-status.js +180 -148
  24. package/dist/programs/run-engine.js +110594 -0
  25. package/dist/programs/supervised-command.js +67 -0
  26. package/dist/programs/sync.js +63 -39
  27. package/dist/programs/task-brief.js +174 -150
  28. package/dist/programs/task-sweep.js +244 -151
  29. package/dist/programs/task-tools-serve.js +260 -163
  30. package/dist/programs/tokens.js +172 -148
  31. package/dist/programs/waiver.js +172 -148
  32. package/dist/vinaya-strict/checks/registry.ts +1085 -0
  33. package/dist/vinaya-strict/executing/code-reviewer/README.md +3 -0
  34. package/dist/vinaya-strict/executing/code-reviewer/doctrine.md +185 -0
  35. package/dist/vinaya-strict/executing/code-reviewer/evals/README.md +1 -0
  36. package/dist/vinaya-strict/executing/code-reviewer/evals/code-reviewer-cases.json +280 -0
  37. package/dist/vinaya-strict/executing/code-reviewer/grants.yaml +22 -0
  38. package/dist/vinaya-strict/executing/code-reviewer/output.schema.json +93 -0
  39. package/dist/vinaya-strict/executing/code-reviewer/review-result.ts +347 -0
  40. package/dist/vinaya-strict/executing/dev-review.flow.yaml +103 -0
  41. package/dist/vinaya-strict/executing/developer/README.md +3 -0
  42. package/dist/vinaya-strict/executing/developer/developer-doctrine-shape.test.ts +69 -0
  43. package/dist/vinaya-strict/executing/developer/developer-turn-result.ts +286 -0
  44. package/dist/vinaya-strict/executing/developer/doctrine.md +111 -0
  45. package/dist/vinaya-strict/executing/developer/evals/README.md +1 -0
  46. package/dist/vinaya-strict/executing/developer/evals/developer-capability-cases.json +6275 -0
  47. package/dist/vinaya-strict/executing/developer/evals/developer-capability-held-out.json +11526 -0
  48. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.test.ts +498 -0
  49. package/dist/vinaya-strict/executing/developer/evals/developer-capability-suite.ts +1407 -0
  50. package/dist/vinaya-strict/executing/developer/grants.yaml +25 -0
  51. package/dist/vinaya-strict/executing/developer/output.schema.json +148 -0
  52. package/dist/vinaya-strict/executing/developer/reference.md +376 -0
  53. package/dist/vinaya-strict/executing/operator/doctrine.md +209 -0
  54. package/dist/vinaya-strict/executing/security-reviewer/README.md +3 -0
  55. package/dist/vinaya-strict/executing/security-reviewer/doctrine.md +171 -0
  56. package/dist/vinaya-strict/executing/security-reviewer/evals/README.md +1 -0
  57. package/dist/vinaya-strict/executing/security-reviewer/evals/security-reviewer-cases.json +141 -0
  58. package/dist/vinaya-strict/executing/security-reviewer/grants.yaml +22 -0
  59. package/dist/vinaya-strict/executing/security-reviewer/output.schema.json +93 -0
  60. package/dist/vinaya-strict/integration/config/vinaya-config-section.ts +1278 -0
  61. package/dist/vinaya-strict/integration/policies/vinaya-policies.ts +52 -0
  62. package/dist/vinaya-strict/integration/process/process-integration.ts +57 -0
  63. package/dist/vinaya-strict/loops/dev-review/v2/dev-review-v2.flow.yaml +136 -0
  64. package/dist/vinaya-strict/process.yaml +43 -0
  65. package/dist/vinaya-strict/retrospecting/archivist/doctrine.md +174 -0
  66. package/dist/vinaya-strict/retrospecting/tranche-archivist/doctrine.md +270 -0
  67. package/dist/vinaya-strict/thinking/architect/doctrine.md +110 -0
  68. package/dist/vinaya-strict/thinking/planner/doctrine.md +105 -0
  69. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.test.ts +128 -0
  70. package/dist/vinaya-strict/thinking/planner/tools/amend-rationale-deps.ts +169 -0
  71. package/dist/vinaya-strict/thinking/planner/tools/open-issue.test.ts +701 -0
  72. package/dist/vinaya-strict/thinking/planner/tools/open-issue.ts +1035 -0
  73. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.test.ts +359 -0
  74. package/dist/vinaya-strict/thinking/planner/tools/planner-operations.ts +815 -0
  75. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.test.ts +200 -0
  76. package/dist/vinaya-strict/thinking/planner/tools/planner-tools.ts +458 -0
  77. package/package.json +4 -2
  78. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  79. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  80. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  81. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  82. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  86. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  87. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_buildManifest.js +0 -0
  88. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → x2q88XfwsihlevulRhIvs}/_ssgManifest.js +0 -0
@@ -1324,11 +1324,12 @@ function lookup(name) {
1324
1324
  throw new Error(`no program named '${name}' — the program table names: ${[...PROGRAMS.keys()].join(", ")}`);
1325
1325
  return found;
1326
1326
  }
1327
- function programFile(name) {
1327
+ function programFile(name, packageRoot = cliPackageRoot(), fromSource = FROM_SOURCE) {
1328
1328
  const entry = lookup(name);
1329
- const built = join3(cliPackageRoot(), entry.built);
1330
- const source = join3(SOURCE_ROOT, entry.source);
1331
- if (FROM_SOURCE && existsSync3(source))
1329
+ return pickFile(join3(packageRoot, entry.built), join3(SOURCE_ROOT, entry.source), fromSource);
1330
+ }
1331
+ function pickFile(built, source, fromSource) {
1332
+ if (fromSource && existsSync3(source))
1332
1333
  return source;
1333
1334
  return existsSync3(built) ? built : source;
1334
1335
  }
@@ -1392,7 +1393,9 @@ var init_programs = __esm(() => {
1392
1393
  program("log-selftest", `${P}/integration/bin/log-selftest.ts`, "dist/programs/log-selftest.js", [
1393
1394
  words("log", "selftest")
1394
1395
  ]),
1395
- program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")])
1396
+ program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")]),
1397
+ program("run-engine", `${P}/bin/run-engine.ts`, "dist/programs/run-engine.js"),
1398
+ program("supervised-command", `${P}/loops/dev-review/v2/supervised-command.ts`, "dist/programs/supervised-command.js")
1396
1399
  ]);
1397
1400
  SOURCE_ROOT = join3(dirname3(fileURLToPath3(import.meta.url)), "..", "..", "..", "..");
1398
1401
  FROM_SOURCE = fileURLToPath3(import.meta.url).endsWith(".ts");
@@ -7555,21 +7558,145 @@ var init_fetch_documentation = __esm(() => {
7555
7558
  REQUEST_HEADER_ALLOWANCE = 64 * 1024;
7556
7559
  });
7557
7560
 
7561
+ // ../../harness/kernel/log/roles.ts
7562
+ function registerRole(name, role) {
7563
+ roles.set(name, role);
7564
+ }
7565
+ function registerTitle(name, title) {
7566
+ titles.set(name, title);
7567
+ }
7568
+ function isRole(value) {
7569
+ return value !== undefined && roles.has(value);
7570
+ }
7571
+ function lookupRole(name) {
7572
+ return roles.get(name);
7573
+ }
7574
+ function lookupTitle(name) {
7575
+ return roles.get(name)?.title ?? titles.get(name);
7576
+ }
7577
+ var roles, titles;
7578
+ var init_roles = __esm(() => {
7579
+ roles = new Map;
7580
+ titles = new Map;
7581
+ });
7582
+
7583
+ // ../../harness/kernel/log/envelope.ts
7584
+ import { createHash as createHash6 } from "node:crypto";
7585
+ function actorIdFromEnv(role) {
7586
+ return role === undefined || role === "" ? null : role;
7587
+ }
7588
+ function lineageFieldFromEnv(value) {
7589
+ return value === undefined || value === "" ? null : value;
7590
+ }
7591
+ function attemptFromEnv(value) {
7592
+ if (value === undefined || value === "")
7593
+ return null;
7594
+ const n = Number(value);
7595
+ return Number.isInteger(n) ? n : null;
7596
+ }
7597
+ function provenanceFor(input) {
7598
+ if (input.provenance)
7599
+ return input.provenance;
7600
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
7601
+ return "unavailable";
7602
+ if (input.env.role || input.env.task)
7603
+ return "env_correlated";
7604
+ return "unavailable";
7605
+ }
7606
+ function issueFromTask(task) {
7607
+ if (task === undefined || task === "")
7608
+ return null;
7609
+ const n = Number(task);
7610
+ return Number.isInteger(n) ? n : null;
7611
+ }
7612
+ function roundFromEnv(round) {
7613
+ if (round === undefined || round === "")
7614
+ return;
7615
+ const n = Number(round);
7616
+ return Number.isInteger(n) ? n : undefined;
7617
+ }
7618
+ function prFromEnv(pr) {
7619
+ if (pr === undefined || pr === "")
7620
+ return;
7621
+ const n = Number(pr);
7622
+ return Number.isInteger(n) && n > 0 ? n : undefined;
7623
+ }
7624
+ function buildHeader(input) {
7625
+ const role = isRole(input.env.role) ? input.env.role : "unattributed";
7626
+ const round = roundFromEnv(input.env.round);
7627
+ const pr = prFromEnv(input.env.pr);
7628
+ const subject = {
7629
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
7630
+ role,
7631
+ ...round !== undefined ? { round } : {},
7632
+ ...pr !== undefined ? { pr } : {},
7633
+ ...input.subject ?? {}
7634
+ };
7635
+ const issue = subject.issue;
7636
+ return {
7637
+ meta: {
7638
+ schema: 4,
7639
+ ts: input.now.toISOString(),
7640
+ run_id: input.runId,
7641
+ seq: input.seq,
7642
+ repo: input.repo,
7643
+ vinaya: input.vinaya,
7644
+ doctrine: input.doctrine,
7645
+ host: input.host,
7646
+ machine: createHash6("sha256").update(input.hostname).digest("hex"),
7647
+ event_id: input.eventId,
7648
+ process_id: input.processId,
7649
+ actor_id: actorIdFromEnv(input.env.role),
7650
+ lineage: {
7651
+ run: lineageFieldFromEnv(input.env.run),
7652
+ attempt: attemptFromEnv(input.env.attempt),
7653
+ parent: lineageFieldFromEnv(input.env.parent)
7654
+ },
7655
+ input_versions: {
7656
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
7657
+ objectives_version: input.inputVersions?.objectivesVersion ?? null,
7658
+ brief_hash: input.inputVersions?.briefHash ?? null,
7659
+ ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
7660
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
7661
+ policy_digest: input.inputVersions?.policyDigest ?? null
7662
+ },
7663
+ provenance: provenanceFor(input),
7664
+ work: {
7665
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
7666
+ repo: input.repo,
7667
+ change: pr === undefined ? null : String(pr),
7668
+ revision: input.revision ?? null
7669
+ },
7670
+ flow: {
7671
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
7672
+ version: lineageFieldFromEnv(input.env.flowVersion)
7673
+ },
7674
+ runtime: lineageFieldFromEnv(input.env.runtime),
7675
+ process: {
7676
+ id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
7677
+ version: lineageFieldFromEnv(input.env.processVersion),
7678
+ digest: lineageFieldFromEnv(input.env.processDigest)
7679
+ },
7680
+ runner: {
7681
+ id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
7682
+ version: lineageFieldFromEnv(input.env.runnerVersion)
7683
+ },
7684
+ source: lineageFieldFromEnv(input.env.source)
7685
+ },
7686
+ subject
7687
+ };
7688
+ }
7689
+ var init_envelope = __esm(() => {
7690
+ init_roles();
7691
+ });
7692
+
7558
7693
  // ../../harness/kernel/log/schema.ts
7559
7694
  import { z as z8 } from "zod";
7560
- var CONFIDENCE_REASON_MAX_LENGTH = 280, REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000, ROLE_VALUES, RoleSchema, HOST_VALUES, HostSchema, RUN_ID_PATTERN, headerMetaCore, HeaderMetaV1Schema, LineageSchema, InputVersionsSchema, ProvenanceSchema, HeaderMetaV2Schema, WorkSchema, FlowSchema, HeaderMetaV3Schema, HeaderMetaV4Schema, HeaderMetaSchema, SubjectSchema, HeaderSchema, envelopeTail, ReviewFindingSchema, DispatchOutcomeSchema, dispatchShared, dispatchUsageField, DispatchEventSchema, CODE_TOKEN_PATTERN, CodeTokenSchema, ReviewerVerdictSchema, loopShared, DevReviewLoopEventSchema, ForgeOpSchema, ForgeWriteTargetSchema, forgeWriteShared, ForgeWriteEventSchema, GateOutcomeSchema, gateShared, GateEventSchema, OperationResultSchema, operationShared, OperationEventSchema, UsageUnitsSchema, usageShared, UsageEventSchema, RoleAttemptOutcomeSchema, roleAttemptShared, RoleAttemptEventSchema, handoffShared, HandoffEventSchema, EffectTargetSchema, effectShared, EffectEventSchema, CustomFieldValueSchema, customShared, CustomEventSchema, LogEventSchema;
7695
+ var CONFIDENCE_REASON_MAX_LENGTH = 280, REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000, ROLE_NAME_PATTERN, RoleSchema, HOST_VALUES, HostSchema, RUN_ID_PATTERN, headerMetaCore, HeaderMetaV1Schema, LineageSchema, InputVersionsSchema, ProvenanceSchema, HeaderMetaV2Schema, WorkSchema, FlowSchema, HeaderMetaV3Schema, HeaderMetaV4Schema, HeaderMetaSchema, SubjectSchema, HeaderSchema, envelopeTail, ReviewFindingSchema, DispatchOutcomeSchema, dispatchShared, dispatchUsageField, DispatchEventSchema, CODE_TOKEN_PATTERN, CodeTokenSchema, ReviewerVerdictSchema, loopShared, DevReviewLoopEventSchema, ForgeOpSchema, ForgeWriteTargetSchema, forgeWriteShared, ForgeWriteEventSchema, GateOutcomeSchema, gateShared, GateEventSchema, OperationResultSchema, operationShared, OperationEventSchema, UsageUnitsSchema, usageShared, UsageEventSchema, RoleAttemptOutcomeSchema, roleAttemptShared, RoleAttemptEventSchema, handoffShared, HandoffEventSchema, EffectTargetSchema, effectShared, EffectEventSchema, CustomFieldValueSchema, customShared, CustomEventSchema, LogEventSchema;
7561
7696
  var init_schema = __esm(() => {
7562
7697
  init_custom();
7563
- ROLE_VALUES = [
7564
- "planner",
7565
- "developer",
7566
- "code-reviewer",
7567
- "security",
7568
- "principal",
7569
- "archivist",
7570
- "architect"
7571
- ];
7572
- RoleSchema = z8.enum(ROLE_VALUES);
7698
+ ROLE_NAME_PATTERN = /^[a-z0-9-]+$/;
7699
+ RoleSchema = z8.string().regex(ROLE_NAME_PATTERN);
7573
7700
  HOST_VALUES = ["hook", "ci", "cli", "loop"];
7574
7701
  HostSchema = z8.enum(HOST_VALUES);
7575
7702
  RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
@@ -8151,119 +8278,6 @@ var init_schema = __esm(() => {
8151
8278
  ]);
8152
8279
  });
8153
8280
 
8154
- // ../../harness/kernel/log/envelope.ts
8155
- import { createHash as createHash6 } from "node:crypto";
8156
- function isRole(value) {
8157
- return value !== undefined && ROLE_VALUES.includes(value);
8158
- }
8159
- function actorIdFromEnv(role) {
8160
- return role === undefined || role === "" ? null : role;
8161
- }
8162
- function lineageFieldFromEnv(value) {
8163
- return value === undefined || value === "" ? null : value;
8164
- }
8165
- function attemptFromEnv(value) {
8166
- if (value === undefined || value === "")
8167
- return null;
8168
- const n = Number(value);
8169
- return Number.isInteger(n) ? n : null;
8170
- }
8171
- function provenanceFor(input) {
8172
- if (input.provenance)
8173
- return input.provenance;
8174
- if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
8175
- return "unavailable";
8176
- if (input.env.role || input.env.task)
8177
- return "env_correlated";
8178
- return "unavailable";
8179
- }
8180
- function issueFromTask(task) {
8181
- if (task === undefined || task === "")
8182
- return null;
8183
- const n = Number(task);
8184
- return Number.isInteger(n) ? n : null;
8185
- }
8186
- function roundFromEnv(round) {
8187
- if (round === undefined || round === "")
8188
- return;
8189
- const n = Number(round);
8190
- return Number.isInteger(n) ? n : undefined;
8191
- }
8192
- function prFromEnv(pr) {
8193
- if (pr === undefined || pr === "")
8194
- return;
8195
- const n = Number(pr);
8196
- return Number.isInteger(n) && n > 0 ? n : undefined;
8197
- }
8198
- function buildHeader(input) {
8199
- const role = isRole(input.env.role) ? input.env.role : "unattributed";
8200
- const round = roundFromEnv(input.env.round);
8201
- const pr = prFromEnv(input.env.pr);
8202
- const subject = {
8203
- issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
8204
- role,
8205
- ...round !== undefined ? { round } : {},
8206
- ...pr !== undefined ? { pr } : {},
8207
- ...input.subject ?? {}
8208
- };
8209
- const issue = subject.issue;
8210
- return {
8211
- meta: {
8212
- schema: 4,
8213
- ts: input.now.toISOString(),
8214
- run_id: input.runId,
8215
- seq: input.seq,
8216
- repo: input.repo,
8217
- vinaya: input.vinaya,
8218
- doctrine: input.doctrine,
8219
- host: input.host,
8220
- machine: createHash6("sha256").update(input.hostname).digest("hex"),
8221
- event_id: input.eventId,
8222
- process_id: input.processId,
8223
- actor_id: actorIdFromEnv(input.env.role),
8224
- lineage: {
8225
- run: lineageFieldFromEnv(input.env.run),
8226
- attempt: attemptFromEnv(input.env.attempt),
8227
- parent: lineageFieldFromEnv(input.env.parent)
8228
- },
8229
- input_versions: {
8230
- manifest_version: input.inputVersions?.manifestVersion ?? null,
8231
- objectives_version: input.inputVersions?.objectivesVersion ?? null,
8232
- brief_hash: input.inputVersions?.briefHash ?? null,
8233
- ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
8234
- pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
8235
- policy_digest: input.inputVersions?.policyDigest ?? null
8236
- },
8237
- provenance: provenanceFor(input),
8238
- work: {
8239
- ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
8240
- repo: input.repo,
8241
- change: pr === undefined ? null : String(pr),
8242
- revision: input.revision ?? null
8243
- },
8244
- flow: {
8245
- id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
8246
- version: lineageFieldFromEnv(input.env.flowVersion)
8247
- },
8248
- runtime: lineageFieldFromEnv(input.env.runtime),
8249
- process: {
8250
- id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
8251
- version: lineageFieldFromEnv(input.env.processVersion),
8252
- digest: lineageFieldFromEnv(input.env.processDigest)
8253
- },
8254
- runner: {
8255
- id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
8256
- version: lineageFieldFromEnv(input.env.runnerVersion)
8257
- },
8258
- source: lineageFieldFromEnv(input.env.source)
8259
- },
8260
- subject
8261
- };
8262
- }
8263
- var init_envelope = __esm(() => {
8264
- init_schema();
8265
- });
8266
-
8267
8281
  // ../../harness/kernel/log/store.ts
8268
8282
  function metaOf(obj) {
8269
8283
  if (obj === null || typeof obj !== "object")
@@ -8369,7 +8383,8 @@ function code(value) {
8369
8383
  return typeof value === "string" && CODE_TOKEN_PATTERN.test(value) ? value : null;
8370
8384
  }
8371
8385
  function roleSubject(value, sentenceStart = true) {
8372
- const name = typeof value === "string" && ROLE_VALUES.includes(value) ? `the ${value === "security" ? "security reviewer" : value.replace(/-/g, " ")}` : "a role";
8386
+ const known = typeof value === "string" ? lookupRole(value) : undefined;
8387
+ const name = known ? `the ${known.reading}` : "a role";
8373
8388
  return sentenceStart ? `${name[0]?.toUpperCase()}${name.slice(1)}` : name;
8374
8389
  }
8375
8390
  function roundLabel(record) {
@@ -8488,7 +8503,7 @@ function conflictReentry(record) {
8488
8503
  function dispatched(record) {
8489
8504
  const role = text(record.target_role);
8490
8505
  const who = roleSubject(role);
8491
- const reviewing = role === "code-reviewer" || role === "security";
8506
+ const reviewing = role !== null && (lookupRole(role)?.reviews ?? false);
8492
8507
  const round = whole(record.round);
8493
8508
  return {
8494
8509
  kind: "working",
@@ -8547,6 +8562,7 @@ function narrate(record, earlier = []) {
8547
8562
  }
8548
8563
  var REASONS, PAUSE_WITHOUT_CODE;
8549
8564
  var init_narration = __esm(() => {
8565
+ init_roles();
8550
8566
  init_schema();
8551
8567
  REASONS = {
8552
8568
  escalation: { words: "a role escalated a question", person: true },
@@ -8579,13 +8595,7 @@ var init_narration = __esm(() => {
8579
8595
 
8580
8596
  // ../../harness/kernel/adapters/agents/agent-line.ts
8581
8597
  function roleLabel(role) {
8582
- if (role in roleLabels)
8583
- return roleLabels[role];
8584
- if (role === "dev-review-loop")
8585
- return "Loop";
8586
- if (role === "operator")
8587
- return "Operator";
8588
- return role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
8598
+ return lookupTitle(role) ?? role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
8589
8599
  }
8590
8600
  function formatLineMeta(meta) {
8591
8601
  if (meta === undefined)
@@ -8613,17 +8623,9 @@ function formatAgentLine(role, words, options = {}) {
8613
8623
  const mark = options.unicode ?? true ? unicodeMarks[options.mark ?? "working"] : asciiMarks[options.mark ?? "working"];
8614
8624
  return `${time} ${mark} ${roleLabel(role)} ${words}`;
8615
8625
  }
8616
- var roleLabels, unicodeMarks, asciiMarks, META_KEY, META_VALUE;
8626
+ var unicodeMarks, asciiMarks, META_KEY, META_VALUE;
8617
8627
  var init_agent_line = __esm(() => {
8618
- roleLabels = {
8619
- planner: "Planner",
8620
- developer: "Developer",
8621
- "code-reviewer": "Code review",
8622
- security: "Security",
8623
- principal: "Principal",
8624
- archivist: "Archivist",
8625
- architect: "Architect"
8626
- };
8628
+ init_roles();
8627
8629
  unicodeMarks = { working: "▸", done: "✓", failed: "✕", waiting: "◌", round: "◆" };
8628
8630
  asciiMarks = { working: ">", done: "+", failed: "x", waiting: "~", round: "#" };
8629
8631
  META_KEY = /^[a-z]+$/;
@@ -9854,6 +9856,28 @@ var init_log_sink = __esm(() => {
9854
9856
  defaultSinkSlot = createDefaultLogSinkSlot(process.env.VINAYA_RUN_ID || randomUUID3());
9855
9857
  });
9856
9858
 
9859
+ // ../../harness/processes/vinaya-strict/integration/log/log-roles.ts
9860
+ function registerVinayaLogRoles() {
9861
+ for (const { name, reading, title, reviews } of VINAYA_LOG_ROLES)
9862
+ registerRole(name, { reading, title, reviews });
9863
+ registerTitle("dev-review-loop", "Loop");
9864
+ }
9865
+ var VINAYA_LOG_ROLES, VINAYA_LOG_ROLE_NAMES;
9866
+ var init_log_roles = __esm(() => {
9867
+ init_roles();
9868
+ VINAYA_LOG_ROLES = [
9869
+ { name: "planner", reading: "planner", title: "Planner", reviews: false },
9870
+ { name: "developer", reading: "developer", title: "Developer", reviews: false },
9871
+ { name: "code-reviewer", reading: "code reviewer", title: "Code review", reviews: true },
9872
+ { name: "security", reading: "security reviewer", title: "Security", reviews: true },
9873
+ { name: "principal", reading: "principal", title: "Principal", reviews: false },
9874
+ { name: "archivist", reading: "archivist", title: "Archivist", reviews: false },
9875
+ { name: "architect", reading: "architect", title: "Architect", reviews: false }
9876
+ ];
9877
+ VINAYA_LOG_ROLE_NAMES = VINAYA_LOG_ROLES.map((role) => role.name);
9878
+ registerVinayaLogRoles();
9879
+ });
9880
+
9857
9881
  // ../../harness/processes/vinaya-strict/integration/log/branch-issue.ts
9858
9882
  import { execFile as execFile5 } from "node:child_process";
9859
9883
  import { promisify as promisify5 } from "node:util";
@@ -10056,6 +10080,7 @@ function installVinayaLogSinkFactory() {
10056
10080
  var init_log_sink_factory = __esm(() => {
10057
10081
  init_log_sink();
10058
10082
  init_package_root();
10083
+ init_log_roles();
10059
10084
  init_branch_issue();
10060
10085
  init_doctrine_version();
10061
10086
  });
@@ -11188,14 +11213,14 @@ function terminateChildWithGrace(pid, graceMs = TERMINATE_GRACE_MS) {
11188
11213
  } catch {}
11189
11214
  }
11190
11215
  }
11191
- function captureSettledChildSnapshot(pid) {
11192
- let snapshot = getProcessSnapshot(pid);
11216
+ function captureSettledChildSnapshot(pid, readSnapshot = getProcessSnapshot) {
11217
+ let snapshot = readSnapshot(pid);
11193
11218
  if (snapshot === null)
11194
11219
  return null;
11195
11220
  const deadline = Date.now() + IDENTITY_SETTLE_BUDGET_MS;
11196
11221
  while (Date.now() < deadline) {
11197
11222
  sleepSyncMs(IDENTITY_SETTLE_POLL_MS);
11198
- const next = getProcessSnapshot(pid);
11223
+ const next = readSnapshot(pid);
11199
11224
  if (next === null)
11200
11225
  return snapshot;
11201
11226
  if (next.command === snapshot.command)
@@ -14952,7 +14977,7 @@ var init_commands = __esm(() => {
14952
14977
  }
14953
14978
  ],
14954
14979
  details: [
14955
- "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.",
14980
+ "The atta-engine runner starts the Engine runner with Bun, so it needs Bun on the machine, streams its output and returns its exit code. The published package carries the Engine runner as a built program and a checkout starts its source file; a command line without the runner file 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.",
14956
14981
  "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.",
14957
14982
  "`--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.",
14958
14983
  "`--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.",
@@ -15986,7 +16011,7 @@ var init_config_reference = __esm(() => {
15986
16011
  type: '"standalone" | "atta-engine" (optional)',
15987
16012
  semantics: [
15988
16013
  "Selects the task runner. The default is `standalone`: an absent key runs the standalone loop, so a published install never changes runner on its own. Any value other than `standalone` or `atta-engine` is refused at config load. `task run --runner <name>` overrides this setting for one invocation, so `standalone` stays selectable by this key and by that flag.",
15989
- "atta-engine starts the workspace Engine script as a Bun subprocess with the resolved task, agent and model. When the Engine runner script is absent — a published install carries none — `task run` prints one fallback notice, `vinaya task run: Engine runner script is unavailable; falling back to standalone.`, and runs standalone. The Engine Log reaches the same configured destination the standalone loop uses, a server included.",
16014
+ "atta-engine starts the Engine runner as a Bun subprocess with the resolved task, agent and model, so it needs Bun on the machine. The published package carries the Engine runner as a built program, `dist/programs/run-engine.js`, beside a copy of the process files it loads under `dist/vinaya-strict`; a checkout of this repository starts the runner’s source file. When the Engine runner file is absent, `task run` prints one fallback notice, `vinaya task run: Engine runner script is unavailable; falling back to standalone.`, and runs standalone. The Engine Log reaches the same configured destination the standalone loop uses, a server included.",
15990
16015
  "Each run records the runner it actually used, and status, resume and cancel follow that record rather than this key. A run with no recorded runner, started before runs recorded one, is a standalone run, whatever this key now names."
15991
16016
  ],
15992
16017
  example: `{ "runner": "atta-engine" }`
@@ -17852,8 +17877,8 @@ var init_protected_paths2 = __esm(() => {
17852
17877
 
17853
17878
  // ../../harness/processes/vinaya-strict/integration/policies/roles.ts
17854
17879
  var GRANTED_ROLES, ROLE_TOOL_GRANTS, VINAYA_TOOL_GRANTS, VINAYA_BROKER_ROLES, VINAYA_BOUNDARY_ROLES, OPERATOR_TOOL_GRANT, PLANNER_TOOL_GRANT, VINAYA_PLANNER_ROUTER_ROLES, ARCHITECT_TOOL_GRANT, TRANCHE_ARCHIVIST_TOOL_GRANT, VINAYA_ARCHITECT_ROUTER_ROLES, VINAYA_TRANCHE_ARCHIVIST_ROUTER_ROLES, VINAYA_ROUTER_ROLES;
17855
- var init_roles = __esm(() => {
17856
- init_schema();
17880
+ var init_roles2 = __esm(() => {
17881
+ init_log_roles();
17857
17882
  GRANTED_ROLES = ["developer", "code-reviewer", "security", "controller"];
17858
17883
  ROLE_TOOL_GRANTS = {
17859
17884
  developer: [
@@ -17872,7 +17897,7 @@ var init_roles = __esm(() => {
17872
17897
  };
17873
17898
  VINAYA_TOOL_GRANTS = { roles: GRANTED_ROLES, grants: ROLE_TOOL_GRANTS };
17874
17899
  VINAYA_BROKER_ROLES = {
17875
- recognizedRoles: ROLE_VALUES,
17900
+ recognizedRoles: VINAYA_LOG_ROLE_NAMES,
17876
17901
  workerRoles: ["developer"],
17877
17902
  surfaceOwner: "the Planner"
17878
17903
  };
@@ -18034,7 +18059,7 @@ function vinayaRouterPolicies() {
18034
18059
  var init_vinaya_policies = __esm(() => {
18035
18060
  init_launch_records();
18036
18061
  init_protected_paths2();
18037
- init_roles();
18062
+ init_roles2();
18038
18063
  init_scratch_names();
18039
18064
  });
18040
18065
 
@@ -19787,6 +19812,73 @@ var init_premise_reassert_logic = __esm(() => {
19787
19812
  init_ops();
19788
19813
  });
19789
19814
 
19815
+ // ../../harness/processes/vinaya-strict/loops/dev-review/v2/git-read-memo.ts
19816
+ import { resolve as resolve6 } from "node:path";
19817
+ function gitSubcommand(args) {
19818
+ for (let i = 0;i < args.length; i++) {
19819
+ const arg = args[i];
19820
+ if (arg === "-C" || arg === "-c" || arg === "--git-dir" || arg === "--work-tree") {
19821
+ i++;
19822
+ continue;
19823
+ }
19824
+ if (arg.startsWith("-"))
19825
+ continue;
19826
+ return arg;
19827
+ }
19828
+ return;
19829
+ }
19830
+ function gitReadKey(cwd, args) {
19831
+ return [resolve6(cwd ?? process.cwd()), ...args].join("\x00");
19832
+ }
19833
+ function gitReadMemoServing() {
19834
+ return memoEnabled && state.scopes > 0 && state.turns === 0;
19835
+ }
19836
+ function clearGitReadMemo(reason = "cleared") {
19837
+ state.entries.clear();
19838
+ notify({ kind: "clear", reason });
19839
+ }
19840
+ function runGit(cwd, args, run) {
19841
+ const sub = gitSubcommand(args);
19842
+ const key = gitReadKey(cwd, args);
19843
+ const memoizable = sub !== undefined && MEMOIZED.has(sub);
19844
+ if (memoizable && gitReadMemoServing()) {
19845
+ const kept = state.entries.get(key);
19846
+ if (kept !== undefined) {
19847
+ notify({ kind: "hit", key });
19848
+ return kept;
19849
+ }
19850
+ let value;
19851
+ try {
19852
+ value = run();
19853
+ } catch (error) {
19854
+ notify({ kind: "spawn", key, memoizable: true, served: false });
19855
+ throw error;
19856
+ }
19857
+ notify({ kind: "spawn", key, memoizable: true, served: true });
19858
+ if (gitReadMemoServing())
19859
+ state.entries.set(key, value);
19860
+ return value;
19861
+ }
19862
+ notify({ kind: "spawn", key, memoizable, served: false });
19863
+ if (memoizable || sub !== undefined && READ_ONLY_UNKEPT.has(sub))
19864
+ return run();
19865
+ try {
19866
+ return run();
19867
+ } finally {
19868
+ clearGitReadMemo(`git ${sub ?? "(none)"}`);
19869
+ }
19870
+ }
19871
+ var MEMOIZED, READ_ONLY_UNKEPT, state, memoEnabled = true, notify = (event) => {
19872
+ for (const listener of state.listeners)
19873
+ listener(event);
19874
+ }, wrapped;
19875
+ var init_git_read_memo = __esm(() => {
19876
+ MEMOIZED = new Set(["rev-parse", "merge-base", "show-ref", "for-each-ref", "rev-list"]);
19877
+ READ_ONLY_UNKEPT = new Set(["ls-remote", "status", "diff", "ls-files", "log", "show", "cat-file", "merge-tree"]);
19878
+ state = { scopes: 0, turns: 0, entries: new Map, listeners: new Set };
19879
+ wrapped = new WeakMap;
19880
+ });
19881
+
19790
19882
  // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
19791
19883
  import { execFileSync as execFileSync14 } from "node:child_process";
19792
19884
  function shEnvOverride(name, fallback) {
@@ -19803,11 +19895,12 @@ function sleepSyncMs2(ms) {
19803
19895
  }
19804
19896
  function sh(cmd, args, options = {}) {
19805
19897
  if (cmd !== "gh") {
19806
- return execFileSync14(cmd, args, {
19898
+ const run = () => execFileSync14(cmd, args, {
19807
19899
  encoding: "utf8",
19808
19900
  stdio: ["ignore", "pipe", "pipe"],
19809
19901
  maxBuffer: MAX_GH_OUTPUT_BYTES
19810
19902
  }).trim();
19903
+ return cmd === "git" ? runGit(undefined, args, run) : run();
19811
19904
  }
19812
19905
  const attempts = options.attempts ?? shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_ATTEMPTS", 3);
19813
19906
  const backoffMs = shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_BACKOFF_MS", 500);
@@ -19858,6 +19951,7 @@ var MAX_GH_OUTPUT_BYTES, NON_CI_WORKFLOW_PATHS, NON_CI_WORKFLOW_NAMES, FAILED_WO
19858
19951
  var init_gate_reading = __esm(() => {
19859
19952
  init_premise_reassert_logic();
19860
19953
  init_round_assess();
19954
+ init_git_read_memo();
19861
19955
  MAX_GH_OUTPUT_BYTES = 64 * 1024 * 1024;
19862
19956
  NON_CI_WORKFLOW_PATHS = [
19863
19957
  REVIEW_WORKFLOW_PATH,
@@ -20897,6 +20991,7 @@ import { z as z11 } from "zod";
20897
20991
  var SECURITY_SCAN_MAX_BUFFER_BYTES, DevReviewLoopEventInputSchema;
20898
20992
  var init_git_defaults = __esm(() => {
20899
20993
  init_gate_reading();
20994
+ init_git_read_memo();
20900
20995
  init_pr_report_engine();
20901
20996
  init_worker_boundary();
20902
20997
  init_issue_validation();
@@ -20997,6 +21092,7 @@ var init_developer_defaults = __esm(async () => {
20997
21092
  init_live_developer_context();
20998
21093
  init_worker_boundary();
20999
21094
  init_gate_reading();
21095
+ init_git_read_memo();
21000
21096
  init_git_defaults();
21001
21097
  init_driver_tool_guard();
21002
21098
  init_live_developer_context();
@@ -21545,6 +21641,7 @@ var init_live_check = __esm(() => {
21545
21641
  init_runner();
21546
21642
  init_dispatch();
21547
21643
  init_pr_facts();
21644
+ init_git_read_memo();
21548
21645
  init_worker_boundary();
21549
21646
  LIVE_RUN_TIMEOUT_MS = 20 * 60000;
21550
21647
  MAX_KEPT_OUTPUT_CHARS = 256 * 1024;
@@ -21573,7 +21670,7 @@ var init_task_sweep = __esm(async () => {
21573
21670
 
21574
21671
  // ../../harness/processes/vinaya-strict/loops/dev-review/run-control/task-run-engine.ts
21575
21672
  import { existsSync as existsSync19, readFileSync as readFileSync19, renameSync as renameSync4, writeFileSync as writeFileSync13 } from "node:fs";
21576
- import { dirname as dirname14, join as join23, resolve as resolve6 } from "node:path";
21673
+ import { dirname as dirname14, join as join23 } from "node:path";
21577
21674
  function taskRunnerRecordPath(task, root = runtimeDirForThisRepo()) {
21578
21675
  return runPath2(root, task, { area: "task", file: "runner.json" });
21579
21676
  }
@@ -21610,11 +21707,10 @@ function engineContinuationCommand(target) {
21610
21707
  return ["bun", ...engineContinuationArgv(target)].join(" ");
21611
21708
  }
21612
21709
  function engineRunnerScriptPath() {
21613
- return resolve6(cliPackageRoot(), "../..", PROCESS_FOLDER_IN_CHECKOUT, "bin/run-engine.ts");
21710
+ return programFile("run-engine");
21614
21711
  }
21615
- var PROCESS_FOLDER_IN_CHECKOUT = "harness/processes/vinaya-strict";
21616
21712
  var init_task_run_engine = __esm(async () => {
21617
- init_package_root();
21713
+ init_programs();
21618
21714
  init_run_paths();
21619
21715
  await init_pause_resume();
21620
21716
  });
@@ -22086,6 +22182,7 @@ var init_turn_confinement = __esm(async () => {
22086
22182
  // ../../harness/processes/vinaya-strict/tools/dev-review-policy/assess-round.ts
22087
22183
  var init_assess_round = __esm(() => {
22088
22184
  init_schema();
22185
+ init_log_roles();
22089
22186
  init_review_status();
22090
22187
  init_task_phase_history();
22091
22188
  init_types();
@@ -25516,7 +25613,7 @@ function taskPrReadHandler(input, forge = defaultPrReadForge) {
25516
25613
  // ../../harness/processes/vinaya-strict/integration/server.ts
25517
25614
  init_router();
25518
25615
  init_vinaya_policies();
25519
- init_roles();
25616
+ init_roles2();
25520
25617
 
25521
25618
  // ../../harness/processes/vinaya-strict/thinking/architect/tools/architect-tools.ts
25522
25619
  import { z as z13 } from "zod";