@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
@@ -4433,21 +4433,145 @@ var init_fetch_documentation = __esm(() => {
4433
4433
  REQUEST_HEADER_ALLOWANCE = 64 * 1024;
4434
4434
  });
4435
4435
 
4436
+ // ../../harness/kernel/log/roles.ts
4437
+ function registerRole(name, role) {
4438
+ roles.set(name, role);
4439
+ }
4440
+ function registerTitle(name, title) {
4441
+ titles.set(name, title);
4442
+ }
4443
+ function isRole(value) {
4444
+ return value !== undefined && roles.has(value);
4445
+ }
4446
+ function lookupRole(name) {
4447
+ return roles.get(name);
4448
+ }
4449
+ function lookupTitle(name) {
4450
+ return roles.get(name)?.title ?? titles.get(name);
4451
+ }
4452
+ var roles, titles;
4453
+ var init_roles = __esm(() => {
4454
+ roles = new Map;
4455
+ titles = new Map;
4456
+ });
4457
+
4458
+ // ../../harness/kernel/log/envelope.ts
4459
+ import { createHash as createHash4 } from "node:crypto";
4460
+ function actorIdFromEnv(role) {
4461
+ return role === undefined || role === "" ? null : role;
4462
+ }
4463
+ function lineageFieldFromEnv(value) {
4464
+ return value === undefined || value === "" ? null : value;
4465
+ }
4466
+ function attemptFromEnv(value) {
4467
+ if (value === undefined || value === "")
4468
+ return null;
4469
+ const n = Number(value);
4470
+ return Number.isInteger(n) ? n : null;
4471
+ }
4472
+ function provenanceFor(input) {
4473
+ if (input.provenance)
4474
+ return input.provenance;
4475
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
4476
+ return "unavailable";
4477
+ if (input.env.role || input.env.task)
4478
+ return "env_correlated";
4479
+ return "unavailable";
4480
+ }
4481
+ function issueFromTask(task) {
4482
+ if (task === undefined || task === "")
4483
+ return null;
4484
+ const n = Number(task);
4485
+ return Number.isInteger(n) ? n : null;
4486
+ }
4487
+ function roundFromEnv(round) {
4488
+ if (round === undefined || round === "")
4489
+ return;
4490
+ const n = Number(round);
4491
+ return Number.isInteger(n) ? n : undefined;
4492
+ }
4493
+ function prFromEnv(pr) {
4494
+ if (pr === undefined || pr === "")
4495
+ return;
4496
+ const n = Number(pr);
4497
+ return Number.isInteger(n) && n > 0 ? n : undefined;
4498
+ }
4499
+ function buildHeader(input) {
4500
+ const role = isRole(input.env.role) ? input.env.role : "unattributed";
4501
+ const round = roundFromEnv(input.env.round);
4502
+ const pr = prFromEnv(input.env.pr);
4503
+ const subject = {
4504
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
4505
+ role,
4506
+ ...round !== undefined ? { round } : {},
4507
+ ...pr !== undefined ? { pr } : {},
4508
+ ...input.subject ?? {}
4509
+ };
4510
+ const issue = subject.issue;
4511
+ return {
4512
+ meta: {
4513
+ schema: 4,
4514
+ ts: input.now.toISOString(),
4515
+ run_id: input.runId,
4516
+ seq: input.seq,
4517
+ repo: input.repo,
4518
+ vinaya: input.vinaya,
4519
+ doctrine: input.doctrine,
4520
+ host: input.host,
4521
+ machine: createHash4("sha256").update(input.hostname).digest("hex"),
4522
+ event_id: input.eventId,
4523
+ process_id: input.processId,
4524
+ actor_id: actorIdFromEnv(input.env.role),
4525
+ lineage: {
4526
+ run: lineageFieldFromEnv(input.env.run),
4527
+ attempt: attemptFromEnv(input.env.attempt),
4528
+ parent: lineageFieldFromEnv(input.env.parent)
4529
+ },
4530
+ input_versions: {
4531
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
4532
+ objectives_version: input.inputVersions?.objectivesVersion ?? null,
4533
+ brief_hash: input.inputVersions?.briefHash ?? null,
4534
+ ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
4535
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
4536
+ policy_digest: input.inputVersions?.policyDigest ?? null
4537
+ },
4538
+ provenance: provenanceFor(input),
4539
+ work: {
4540
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
4541
+ repo: input.repo,
4542
+ change: pr === undefined ? null : String(pr),
4543
+ revision: input.revision ?? null
4544
+ },
4545
+ flow: {
4546
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
4547
+ version: lineageFieldFromEnv(input.env.flowVersion)
4548
+ },
4549
+ runtime: lineageFieldFromEnv(input.env.runtime),
4550
+ process: {
4551
+ id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
4552
+ version: lineageFieldFromEnv(input.env.processVersion),
4553
+ digest: lineageFieldFromEnv(input.env.processDigest)
4554
+ },
4555
+ runner: {
4556
+ id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
4557
+ version: lineageFieldFromEnv(input.env.runnerVersion)
4558
+ },
4559
+ source: lineageFieldFromEnv(input.env.source)
4560
+ },
4561
+ subject
4562
+ };
4563
+ }
4564
+ var init_envelope = __esm(() => {
4565
+ init_roles();
4566
+ });
4567
+
4436
4568
  // ../../harness/kernel/log/schema.ts
4437
4569
  import { z as z7 } from "zod";
4438
- 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;
4570
+ 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;
4439
4571
  var init_schema = __esm(() => {
4440
4572
  init_custom();
4441
- ROLE_VALUES = [
4442
- "planner",
4443
- "developer",
4444
- "code-reviewer",
4445
- "security",
4446
- "principal",
4447
- "archivist",
4448
- "architect"
4449
- ];
4450
- RoleSchema = z7.enum(ROLE_VALUES);
4573
+ ROLE_NAME_PATTERN = /^[a-z0-9-]+$/;
4574
+ RoleSchema = z7.string().regex(ROLE_NAME_PATTERN);
4451
4575
  HOST_VALUES = ["hook", "ci", "cli", "loop"];
4452
4576
  HostSchema = z7.enum(HOST_VALUES);
4453
4577
  RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
@@ -5029,119 +5153,6 @@ var init_schema = __esm(() => {
5029
5153
  ]);
5030
5154
  });
5031
5155
 
5032
- // ../../harness/kernel/log/envelope.ts
5033
- import { createHash as createHash4 } from "node:crypto";
5034
- function isRole(value) {
5035
- return value !== undefined && ROLE_VALUES.includes(value);
5036
- }
5037
- function actorIdFromEnv(role) {
5038
- return role === undefined || role === "" ? null : role;
5039
- }
5040
- function lineageFieldFromEnv(value) {
5041
- return value === undefined || value === "" ? null : value;
5042
- }
5043
- function attemptFromEnv(value) {
5044
- if (value === undefined || value === "")
5045
- return null;
5046
- const n = Number(value);
5047
- return Number.isInteger(n) ? n : null;
5048
- }
5049
- function provenanceFor(input) {
5050
- if (input.provenance)
5051
- return input.provenance;
5052
- if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
5053
- return "unavailable";
5054
- if (input.env.role || input.env.task)
5055
- return "env_correlated";
5056
- return "unavailable";
5057
- }
5058
- function issueFromTask(task) {
5059
- if (task === undefined || task === "")
5060
- return null;
5061
- const n = Number(task);
5062
- return Number.isInteger(n) ? n : null;
5063
- }
5064
- function roundFromEnv(round) {
5065
- if (round === undefined || round === "")
5066
- return;
5067
- const n = Number(round);
5068
- return Number.isInteger(n) ? n : undefined;
5069
- }
5070
- function prFromEnv(pr) {
5071
- if (pr === undefined || pr === "")
5072
- return;
5073
- const n = Number(pr);
5074
- return Number.isInteger(n) && n > 0 ? n : undefined;
5075
- }
5076
- function buildHeader(input) {
5077
- const role = isRole(input.env.role) ? input.env.role : "unattributed";
5078
- const round = roundFromEnv(input.env.round);
5079
- const pr = prFromEnv(input.env.pr);
5080
- const subject = {
5081
- issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
5082
- role,
5083
- ...round !== undefined ? { round } : {},
5084
- ...pr !== undefined ? { pr } : {},
5085
- ...input.subject ?? {}
5086
- };
5087
- const issue = subject.issue;
5088
- return {
5089
- meta: {
5090
- schema: 4,
5091
- ts: input.now.toISOString(),
5092
- run_id: input.runId,
5093
- seq: input.seq,
5094
- repo: input.repo,
5095
- vinaya: input.vinaya,
5096
- doctrine: input.doctrine,
5097
- host: input.host,
5098
- machine: createHash4("sha256").update(input.hostname).digest("hex"),
5099
- event_id: input.eventId,
5100
- process_id: input.processId,
5101
- actor_id: actorIdFromEnv(input.env.role),
5102
- lineage: {
5103
- run: lineageFieldFromEnv(input.env.run),
5104
- attempt: attemptFromEnv(input.env.attempt),
5105
- parent: lineageFieldFromEnv(input.env.parent)
5106
- },
5107
- input_versions: {
5108
- manifest_version: input.inputVersions?.manifestVersion ?? null,
5109
- objectives_version: input.inputVersions?.objectivesVersion ?? null,
5110
- brief_hash: input.inputVersions?.briefHash ?? null,
5111
- ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
5112
- pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
5113
- policy_digest: input.inputVersions?.policyDigest ?? null
5114
- },
5115
- provenance: provenanceFor(input),
5116
- work: {
5117
- ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
5118
- repo: input.repo,
5119
- change: pr === undefined ? null : String(pr),
5120
- revision: input.revision ?? null
5121
- },
5122
- flow: {
5123
- id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
5124
- version: lineageFieldFromEnv(input.env.flowVersion)
5125
- },
5126
- runtime: lineageFieldFromEnv(input.env.runtime),
5127
- process: {
5128
- id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
5129
- version: lineageFieldFromEnv(input.env.processVersion),
5130
- digest: lineageFieldFromEnv(input.env.processDigest)
5131
- },
5132
- runner: {
5133
- id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
5134
- version: lineageFieldFromEnv(input.env.runnerVersion)
5135
- },
5136
- source: lineageFieldFromEnv(input.env.source)
5137
- },
5138
- subject
5139
- };
5140
- }
5141
- var init_envelope = __esm(() => {
5142
- init_schema();
5143
- });
5144
-
5145
5156
  // ../../harness/kernel/log/store.ts
5146
5157
  function metaOf(obj) {
5147
5158
  if (obj === null || typeof obj !== "object")
@@ -5247,7 +5258,8 @@ function code(value) {
5247
5258
  return typeof value === "string" && CODE_TOKEN_PATTERN.test(value) ? value : null;
5248
5259
  }
5249
5260
  function roleSubject(value, sentenceStart = true) {
5250
- const name = typeof value === "string" && ROLE_VALUES.includes(value) ? `the ${value === "security" ? "security reviewer" : value.replace(/-/g, " ")}` : "a role";
5261
+ const known = typeof value === "string" ? lookupRole(value) : undefined;
5262
+ const name = known ? `the ${known.reading}` : "a role";
5251
5263
  return sentenceStart ? `${name[0]?.toUpperCase()}${name.slice(1)}` : name;
5252
5264
  }
5253
5265
  function roundLabel(record) {
@@ -5366,7 +5378,7 @@ function conflictReentry(record) {
5366
5378
  function dispatched(record) {
5367
5379
  const role = text(record.target_role);
5368
5380
  const who = roleSubject(role);
5369
- const reviewing = role === "code-reviewer" || role === "security";
5381
+ const reviewing = role !== null && (lookupRole(role)?.reviews ?? false);
5370
5382
  const round = whole(record.round);
5371
5383
  return {
5372
5384
  kind: "working",
@@ -5425,6 +5437,7 @@ function narrate(record, earlier = []) {
5425
5437
  }
5426
5438
  var REASONS, PAUSE_WITHOUT_CODE;
5427
5439
  var init_narration = __esm(() => {
5440
+ init_roles();
5428
5441
  init_schema();
5429
5442
  REASONS = {
5430
5443
  escalation: { words: "a role escalated a question", person: true },
@@ -5457,13 +5470,7 @@ var init_narration = __esm(() => {
5457
5470
 
5458
5471
  // ../../harness/kernel/adapters/agents/agent-line.ts
5459
5472
  function roleLabel(role) {
5460
- if (role in roleLabels)
5461
- return roleLabels[role];
5462
- if (role === "dev-review-loop")
5463
- return "Loop";
5464
- if (role === "operator")
5465
- return "Operator";
5466
- return role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
5473
+ return lookupTitle(role) ?? role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
5467
5474
  }
5468
5475
  function formatLineMeta(meta) {
5469
5476
  if (meta === undefined)
@@ -5477,17 +5484,9 @@ function formatAgentLine(role, words, options = {}) {
5477
5484
  const mark = options.unicode ?? true ? unicodeMarks[options.mark ?? "working"] : asciiMarks[options.mark ?? "working"];
5478
5485
  return `${time} ${mark} ${roleLabel(role)} ${words}`;
5479
5486
  }
5480
- var roleLabels, unicodeMarks, asciiMarks, META_KEY, META_VALUE;
5487
+ var unicodeMarks, asciiMarks, META_KEY, META_VALUE;
5481
5488
  var init_agent_line = __esm(() => {
5482
- roleLabels = {
5483
- planner: "Planner",
5484
- developer: "Developer",
5485
- "code-reviewer": "Code review",
5486
- security: "Security",
5487
- principal: "Principal",
5488
- archivist: "Archivist",
5489
- architect: "Architect"
5490
- };
5489
+ init_roles();
5491
5490
  unicodeMarks = { working: "▸", done: "✓", failed: "✕", waiting: "◌", round: "◆" };
5492
5491
  asciiMarks = { working: ">", done: "+", failed: "x", waiting: "~", round: "#" };
5493
5492
  META_KEY = /^[a-z]+$/;
@@ -6709,6 +6708,28 @@ var init_log_sink = __esm(() => {
6709
6708
  defaultSinkSlot = createDefaultLogSinkSlot(process.env.VINAYA_RUN_ID || randomUUID2());
6710
6709
  });
6711
6710
 
6711
+ // ../../harness/processes/vinaya-strict/integration/log/log-roles.ts
6712
+ function registerVinayaLogRoles() {
6713
+ for (const { name, reading, title, reviews } of VINAYA_LOG_ROLES)
6714
+ registerRole(name, { reading, title, reviews });
6715
+ registerTitle("dev-review-loop", "Loop");
6716
+ }
6717
+ var VINAYA_LOG_ROLES, VINAYA_LOG_ROLE_NAMES;
6718
+ var init_log_roles = __esm(() => {
6719
+ init_roles();
6720
+ VINAYA_LOG_ROLES = [
6721
+ { name: "planner", reading: "planner", title: "Planner", reviews: false },
6722
+ { name: "developer", reading: "developer", title: "Developer", reviews: false },
6723
+ { name: "code-reviewer", reading: "code reviewer", title: "Code review", reviews: true },
6724
+ { name: "security", reading: "security reviewer", title: "Security", reviews: true },
6725
+ { name: "principal", reading: "principal", title: "Principal", reviews: false },
6726
+ { name: "archivist", reading: "archivist", title: "Archivist", reviews: false },
6727
+ { name: "architect", reading: "architect", title: "Architect", reviews: false }
6728
+ ];
6729
+ VINAYA_LOG_ROLE_NAMES = VINAYA_LOG_ROLES.map((role) => role.name);
6730
+ registerVinayaLogRoles();
6731
+ });
6732
+
6712
6733
  // ../../harness/processes/vinaya-strict/integration/log/branch-issue.ts
6713
6734
  import { execFile as execFile5 } from "node:child_process";
6714
6735
  import { promisify as promisify5 } from "node:util";
@@ -6911,6 +6932,7 @@ function installVinayaLogSinkFactory() {
6911
6932
  var init_log_sink_factory = __esm(() => {
6912
6933
  init_log_sink();
6913
6934
  init_package_root();
6935
+ init_log_roles();
6914
6936
  init_branch_issue();
6915
6937
  init_doctrine_version();
6916
6938
  });
@@ -7434,8 +7456,8 @@ var init_protected_paths2 = __esm(() => {
7434
7456
 
7435
7457
  // ../../harness/processes/vinaya-strict/integration/policies/roles.ts
7436
7458
  var GRANTED_ROLES, ROLE_TOOL_GRANTS, VINAYA_TOOL_GRANTS, VINAYA_BROKER_ROLES, VINAYA_BOUNDARY_ROLES, OPERATOR_TOOL_GRANT, VINAYA_ROUTER_ROLES;
7437
- var init_roles = __esm(() => {
7438
- init_schema();
7459
+ var init_roles2 = __esm(() => {
7460
+ init_log_roles();
7439
7461
  GRANTED_ROLES = ["developer", "code-reviewer", "security", "controller"];
7440
7462
  ROLE_TOOL_GRANTS = {
7441
7463
  developer: [
@@ -7454,7 +7476,7 @@ var init_roles = __esm(() => {
7454
7476
  };
7455
7477
  VINAYA_TOOL_GRANTS = { roles: GRANTED_ROLES, grants: ROLE_TOOL_GRANTS };
7456
7478
  VINAYA_BROKER_ROLES = {
7457
- recognizedRoles: ROLE_VALUES,
7479
+ recognizedRoles: VINAYA_LOG_ROLE_NAMES,
7458
7480
  workerRoles: ["developer"],
7459
7481
  surfaceOwner: "the Planner"
7460
7482
  };
@@ -7538,7 +7560,7 @@ function vinayaRouterPolicies() {
7538
7560
  var init_vinaya_policies = __esm(() => {
7539
7561
  init_launch_records();
7540
7562
  init_protected_paths2();
7541
- init_roles();
7563
+ init_roles2();
7542
7564
  init_scratch_names();
7543
7565
  });
7544
7566
 
@@ -7625,7 +7647,9 @@ var init_programs = __esm(() => {
7625
7647
  program("log-selftest", `${P}/integration/bin/log-selftest.ts`, "dist/programs/log-selftest.js", [
7626
7648
  words("log", "selftest")
7627
7649
  ]),
7628
- program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")])
7650
+ program("sync", `${P}/integration/bin/sync.ts`, "dist/programs/sync.js", [words("sync")]),
7651
+ program("run-engine", `${P}/bin/run-engine.ts`, "dist/programs/run-engine.js"),
7652
+ program("supervised-command", `${P}/loops/dev-review/v2/supervised-command.ts`, "dist/programs/supervised-command.js")
7629
7653
  ]);
7630
7654
  SOURCE_ROOT = join16(dirname10(fileURLToPath4(import.meta.url)), "..", "..", "..", "..");
7631
7655
  FROM_SOURCE = fileURLToPath4(import.meta.url).endsWith(".ts");
@@ -7633,7 +7657,7 @@ var init_programs = __esm(() => {
7633
7657
 
7634
7658
  // ../../harness/processes/vinaya-strict/tools/program-entry.ts
7635
7659
  import { spawnSync } from "node:child_process";
7636
- import { join as join17, resolve as resolve2 } from "node:path";
7660
+ import { join as join17, resolve as resolve3 } from "node:path";
7637
7661
  function maybeDeferToAuthorRepoSource(source) {
7638
7662
  if (process.env.VINAYA_NO_DEFER === "1")
7639
7663
  return;
@@ -7642,7 +7666,7 @@ function maybeDeferToAuthorRepoSource(source) {
7642
7666
  const cliSourceEntry = resolveAuthorRepoSourceEntry(cliPackageRoot());
7643
7667
  if (!cliSourceEntry)
7644
7668
  return;
7645
- const sourceEntry = join17(resolve2(cliSourceEntry, "..", "..", "..", ".."), source);
7669
+ const sourceEntry = join17(resolve3(cliSourceEntry, "..", "..", "..", ".."), source);
7646
7670
  const bunCheck = spawnSync("bun", ["--version"], { stdio: "ignore" });
7647
7671
  if (bunCheck.error || bunCheck.status !== 0) {
7648
7672
  process.stderr.write(`vinaya: author repo detected, but 'bun' is not on PATH — running the installed build instead of ${sourceEntry}
@@ -7845,6 +7869,74 @@ init_premise_check();
7845
7869
 
7846
7870
  // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
7847
7871
  init_round_assess();
7872
+
7873
+ // ../../harness/processes/vinaya-strict/loops/dev-review/v2/git-read-memo.ts
7874
+ import { resolve as resolve2 } from "node:path";
7875
+ var MEMOIZED = new Set(["rev-parse", "merge-base", "show-ref", "for-each-ref", "rev-list"]);
7876
+ var READ_ONLY_UNKEPT = new Set(["ls-remote", "status", "diff", "ls-files", "log", "show", "cat-file", "merge-tree"]);
7877
+ var state = { scopes: 0, turns: 0, entries: new Map, listeners: new Set };
7878
+ var memoEnabled = true;
7879
+ var notify = (event) => {
7880
+ for (const listener of state.listeners)
7881
+ listener(event);
7882
+ };
7883
+ function gitSubcommand(args) {
7884
+ for (let i = 0;i < args.length; i++) {
7885
+ const arg = args[i];
7886
+ if (arg === "-C" || arg === "-c" || arg === "--git-dir" || arg === "--work-tree") {
7887
+ i++;
7888
+ continue;
7889
+ }
7890
+ if (arg.startsWith("-"))
7891
+ continue;
7892
+ return arg;
7893
+ }
7894
+ return;
7895
+ }
7896
+ function gitReadKey(cwd, args) {
7897
+ return [resolve2(cwd ?? process.cwd()), ...args].join("\x00");
7898
+ }
7899
+ function gitReadMemoServing() {
7900
+ return memoEnabled && state.scopes > 0 && state.turns === 0;
7901
+ }
7902
+ function clearGitReadMemo(reason = "cleared") {
7903
+ state.entries.clear();
7904
+ notify({ kind: "clear", reason });
7905
+ }
7906
+ function runGit(cwd, args, run) {
7907
+ const sub = gitSubcommand(args);
7908
+ const key = gitReadKey(cwd, args);
7909
+ const memoizable = sub !== undefined && MEMOIZED.has(sub);
7910
+ if (memoizable && gitReadMemoServing()) {
7911
+ const kept = state.entries.get(key);
7912
+ if (kept !== undefined) {
7913
+ notify({ kind: "hit", key });
7914
+ return kept;
7915
+ }
7916
+ let value;
7917
+ try {
7918
+ value = run();
7919
+ } catch (error) {
7920
+ notify({ kind: "spawn", key, memoizable: true, served: false });
7921
+ throw error;
7922
+ }
7923
+ notify({ kind: "spawn", key, memoizable: true, served: true });
7924
+ if (gitReadMemoServing())
7925
+ state.entries.set(key, value);
7926
+ return value;
7927
+ }
7928
+ notify({ kind: "spawn", key, memoizable, served: false });
7929
+ if (memoizable || sub !== undefined && READ_ONLY_UNKEPT.has(sub))
7930
+ return run();
7931
+ try {
7932
+ return run();
7933
+ } finally {
7934
+ clearGitReadMemo(`git ${sub ?? "(none)"}`);
7935
+ }
7936
+ }
7937
+ var wrapped = new WeakMap;
7938
+
7939
+ // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
7848
7940
  function shEnvOverride(name, fallback) {
7849
7941
  const raw = process.env[name];
7850
7942
  if (!raw)
@@ -7860,11 +7952,12 @@ function sleepSyncMs(ms) {
7860
7952
  }
7861
7953
  function sh(cmd, args, options = {}) {
7862
7954
  if (cmd !== "gh") {
7863
- return execFileSync8(cmd, args, {
7955
+ const run = () => execFileSync8(cmd, args, {
7864
7956
  encoding: "utf8",
7865
7957
  stdio: ["ignore", "pipe", "pipe"],
7866
7958
  maxBuffer: MAX_GH_OUTPUT_BYTES
7867
7959
  }).trim();
7960
+ return cmd === "git" ? runGit(undefined, args, run) : run();
7868
7961
  }
7869
7962
  const attempts = options.attempts ?? shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_ATTEMPTS", 3);
7870
7963
  const backoffMs = shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_BACKOFF_MS", 500);