@attalabs/vinaya 0.42.1 → 0.42.2

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 (41) hide show
  1. package/dist/checks/bin/check-evidence-fresh.js +169 -147
  2. package/dist/checks/bin/check-registry-gates.js +10 -3
  3. package/dist/index.js +292 -168
  4. package/dist/lib/pre-push-cache-test-run.js +142 -143
  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 +169 -147
  10. package/dist/programs/audit.js +169 -147
  11. package/dist/programs/check.js +169 -147
  12. package/dist/programs/commit-msg.js +169 -147
  13. package/dist/programs/dev-review-loop.js +291 -170
  14. package/dist/programs/dispatch.js +1902 -1876
  15. package/dist/programs/log-emit.js +169 -147
  16. package/dist/programs/log-selftest.js +169 -147
  17. package/dist/programs/log-send.js +169 -147
  18. package/dist/programs/pr-report.js +169 -147
  19. package/dist/programs/pr-snapshot.js +169 -147
  20. package/dist/programs/pr-verify-evidence.js +169 -147
  21. package/dist/programs/pr.js +169 -147
  22. package/dist/programs/review-post.js +169 -147
  23. package/dist/programs/review-status.js +177 -147
  24. package/dist/programs/sync.js +60 -38
  25. package/dist/programs/task-brief.js +169 -147
  26. package/dist/programs/task-sweep.js +241 -150
  27. package/dist/programs/task-tools-serve.js +249 -154
  28. package/dist/programs/tokens.js +169 -147
  29. package/dist/programs/waiver.js +169 -147
  30. package/package.json +1 -1
  31. package/studio-standalone/apps/vinaya-studio/.next/BUILD_ID +1 -1
  32. package/studio-standalone/apps/vinaya-studio/.next/build-manifest.json +2 -2
  33. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.html +1 -1
  34. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.rsc +1 -1
  35. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  36. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  37. package/studio-standalone/apps/vinaya-studio/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  38. package/studio-standalone/apps/vinaya-studio/.next/server/middleware-build-manifest.js +1 -1
  39. package/studio-standalone/apps/vinaya-studio/.next/server/pages/500.html +1 -1
  40. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → Q_xjhiWztjosXWbMSJ0Yp}/_buildManifest.js +0 -0
  41. /package/studio-standalone/apps/vinaya-studio/.next/static/{yFfoujElgbwPk-7KNS-kw → Q_xjhiWztjosXWbMSJ0Yp}/_ssgManifest.js +0 -0
@@ -2427,6 +2427,138 @@ var init_fetch_documentation = __esm(() => {
2427
2427
  };
2428
2428
  });
2429
2429
 
2430
+ // ../../harness/kernel/log/roles.ts
2431
+ function registerRole(name, role) {
2432
+ roles.set(name, role);
2433
+ }
2434
+ function registerTitle(name, title) {
2435
+ titles.set(name, title);
2436
+ }
2437
+ function isRole(value) {
2438
+ return value !== undefined && roles.has(value);
2439
+ }
2440
+ function lookupRole(name) {
2441
+ return roles.get(name);
2442
+ }
2443
+ function lookupTitle(name) {
2444
+ return roles.get(name)?.title ?? titles.get(name);
2445
+ }
2446
+ var roles, titles;
2447
+ var init_roles = __esm(() => {
2448
+ roles = new Map;
2449
+ titles = new Map;
2450
+ });
2451
+
2452
+ // ../../harness/kernel/log/envelope.ts
2453
+ import { createHash as createHash2 } from "node:crypto";
2454
+ function actorIdFromEnv(role) {
2455
+ return role === undefined || role === "" ? null : role;
2456
+ }
2457
+ function lineageFieldFromEnv(value) {
2458
+ return value === undefined || value === "" ? null : value;
2459
+ }
2460
+ function attemptFromEnv(value) {
2461
+ if (value === undefined || value === "")
2462
+ return null;
2463
+ const n = Number(value);
2464
+ return Number.isInteger(n) ? n : null;
2465
+ }
2466
+ function provenanceFor(input) {
2467
+ if (input.provenance)
2468
+ return input.provenance;
2469
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
2470
+ return "unavailable";
2471
+ if (input.env.role || input.env.task)
2472
+ return "env_correlated";
2473
+ return "unavailable";
2474
+ }
2475
+ function issueFromTask(task) {
2476
+ if (task === undefined || task === "")
2477
+ return null;
2478
+ const n = Number(task);
2479
+ return Number.isInteger(n) ? n : null;
2480
+ }
2481
+ function roundFromEnv(round) {
2482
+ if (round === undefined || round === "")
2483
+ return;
2484
+ const n = Number(round);
2485
+ return Number.isInteger(n) ? n : undefined;
2486
+ }
2487
+ function prFromEnv(pr) {
2488
+ if (pr === undefined || pr === "")
2489
+ return;
2490
+ const n = Number(pr);
2491
+ return Number.isInteger(n) && n > 0 ? n : undefined;
2492
+ }
2493
+ function buildHeader(input) {
2494
+ const role = isRole(input.env.role) ? input.env.role : "unattributed";
2495
+ const round = roundFromEnv(input.env.round);
2496
+ const pr = prFromEnv(input.env.pr);
2497
+ const subject = {
2498
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
2499
+ role,
2500
+ ...round !== undefined ? { round } : {},
2501
+ ...pr !== undefined ? { pr } : {},
2502
+ ...input.subject ?? {}
2503
+ };
2504
+ const issue = subject.issue;
2505
+ return {
2506
+ meta: {
2507
+ schema: 4,
2508
+ ts: input.now.toISOString(),
2509
+ run_id: input.runId,
2510
+ seq: input.seq,
2511
+ repo: input.repo,
2512
+ vinaya: input.vinaya,
2513
+ doctrine: input.doctrine,
2514
+ host: input.host,
2515
+ machine: createHash2("sha256").update(input.hostname).digest("hex"),
2516
+ event_id: input.eventId,
2517
+ process_id: input.processId,
2518
+ actor_id: actorIdFromEnv(input.env.role),
2519
+ lineage: {
2520
+ run: lineageFieldFromEnv(input.env.run),
2521
+ attempt: attemptFromEnv(input.env.attempt),
2522
+ parent: lineageFieldFromEnv(input.env.parent)
2523
+ },
2524
+ input_versions: {
2525
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
2526
+ objectives_version: input.inputVersions?.objectivesVersion ?? null,
2527
+ brief_hash: input.inputVersions?.briefHash ?? null,
2528
+ ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
2529
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
2530
+ policy_digest: input.inputVersions?.policyDigest ?? null
2531
+ },
2532
+ provenance: provenanceFor(input),
2533
+ work: {
2534
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
2535
+ repo: input.repo,
2536
+ change: pr === undefined ? null : String(pr),
2537
+ revision: input.revision ?? null
2538
+ },
2539
+ flow: {
2540
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
2541
+ version: lineageFieldFromEnv(input.env.flowVersion)
2542
+ },
2543
+ runtime: lineageFieldFromEnv(input.env.runtime),
2544
+ process: {
2545
+ id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
2546
+ version: lineageFieldFromEnv(input.env.processVersion),
2547
+ digest: lineageFieldFromEnv(input.env.processDigest)
2548
+ },
2549
+ runner: {
2550
+ id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
2551
+ version: lineageFieldFromEnv(input.env.runnerVersion)
2552
+ },
2553
+ source: lineageFieldFromEnv(input.env.source)
2554
+ },
2555
+ subject
2556
+ };
2557
+ }
2558
+ var init_envelope = __esm(() => {
2559
+ init_roles();
2560
+ });
2561
+
2430
2562
  // ../../harness/kernel/log/custom.ts
2431
2563
  import { z as z3 } from "zod";
2432
2564
  var CUSTOM_EVENT_NAME_PATTERN, CUSTOM_EVENT_NAME_MAX_LENGTH = 64, CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya", CUSTOM_EVENT_MAX_FIELDS = 20, CUSTOM_FIELD_NAME_PATTERN, CUSTOM_FIELD_NAME_MAX_LENGTH = 64, CUSTOM_TEXT_MAX_LENGTH = 500, CUSTOM_WORD_PATTERN, CUSTOM_WORD_MAX_LENGTH = 64, CUSTOM_FIELD_MAX_WORDS = 50, CustomFieldTypeSchema, CustomEventDeclarationsSchema;
@@ -2484,19 +2616,11 @@ var init_custom = __esm(() => {
2484
2616
 
2485
2617
  // ../../harness/kernel/log/schema.ts
2486
2618
  import { z as z4 } from "zod";
2487
- 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;
2619
+ 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;
2488
2620
  var init_schema = __esm(() => {
2489
2621
  init_custom();
2490
- ROLE_VALUES = [
2491
- "planner",
2492
- "developer",
2493
- "code-reviewer",
2494
- "security",
2495
- "principal",
2496
- "archivist",
2497
- "architect"
2498
- ];
2499
- RoleSchema = z4.enum(ROLE_VALUES);
2622
+ ROLE_NAME_PATTERN = /^[a-z0-9-]+$/;
2623
+ RoleSchema = z4.string().regex(ROLE_NAME_PATTERN);
2500
2624
  HOST_VALUES = ["hook", "ci", "cli", "loop"];
2501
2625
  HostSchema = z4.enum(HOST_VALUES);
2502
2626
  RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
@@ -3078,119 +3202,6 @@ var init_schema = __esm(() => {
3078
3202
  ]);
3079
3203
  });
3080
3204
 
3081
- // ../../harness/kernel/log/envelope.ts
3082
- import { createHash as createHash2 } from "node:crypto";
3083
- function isRole(value) {
3084
- return value !== undefined && ROLE_VALUES.includes(value);
3085
- }
3086
- function actorIdFromEnv(role) {
3087
- return role === undefined || role === "" ? null : role;
3088
- }
3089
- function lineageFieldFromEnv(value) {
3090
- return value === undefined || value === "" ? null : value;
3091
- }
3092
- function attemptFromEnv(value) {
3093
- if (value === undefined || value === "")
3094
- return null;
3095
- const n = Number(value);
3096
- return Number.isInteger(n) ? n : null;
3097
- }
3098
- function provenanceFor(input) {
3099
- if (input.provenance)
3100
- return input.provenance;
3101
- if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
3102
- return "unavailable";
3103
- if (input.env.role || input.env.task)
3104
- return "env_correlated";
3105
- return "unavailable";
3106
- }
3107
- function issueFromTask(task) {
3108
- if (task === undefined || task === "")
3109
- return null;
3110
- const n = Number(task);
3111
- return Number.isInteger(n) ? n : null;
3112
- }
3113
- function roundFromEnv(round) {
3114
- if (round === undefined || round === "")
3115
- return;
3116
- const n = Number(round);
3117
- return Number.isInteger(n) ? n : undefined;
3118
- }
3119
- function prFromEnv(pr) {
3120
- if (pr === undefined || pr === "")
3121
- return;
3122
- const n = Number(pr);
3123
- return Number.isInteger(n) && n > 0 ? n : undefined;
3124
- }
3125
- function buildHeader(input) {
3126
- const role = isRole(input.env.role) ? input.env.role : "unattributed";
3127
- const round = roundFromEnv(input.env.round);
3128
- const pr = prFromEnv(input.env.pr);
3129
- const subject = {
3130
- issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
3131
- role,
3132
- ...round !== undefined ? { round } : {},
3133
- ...pr !== undefined ? { pr } : {},
3134
- ...input.subject ?? {}
3135
- };
3136
- const issue = subject.issue;
3137
- return {
3138
- meta: {
3139
- schema: 4,
3140
- ts: input.now.toISOString(),
3141
- run_id: input.runId,
3142
- seq: input.seq,
3143
- repo: input.repo,
3144
- vinaya: input.vinaya,
3145
- doctrine: input.doctrine,
3146
- host: input.host,
3147
- machine: createHash2("sha256").update(input.hostname).digest("hex"),
3148
- event_id: input.eventId,
3149
- process_id: input.processId,
3150
- actor_id: actorIdFromEnv(input.env.role),
3151
- lineage: {
3152
- run: lineageFieldFromEnv(input.env.run),
3153
- attempt: attemptFromEnv(input.env.attempt),
3154
- parent: lineageFieldFromEnv(input.env.parent)
3155
- },
3156
- input_versions: {
3157
- manifest_version: input.inputVersions?.manifestVersion ?? null,
3158
- objectives_version: input.inputVersions?.objectivesVersion ?? null,
3159
- brief_hash: input.inputVersions?.briefHash ?? null,
3160
- ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
3161
- pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
3162
- policy_digest: input.inputVersions?.policyDigest ?? null
3163
- },
3164
- provenance: provenanceFor(input),
3165
- work: {
3166
- ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
3167
- repo: input.repo,
3168
- change: pr === undefined ? null : String(pr),
3169
- revision: input.revision ?? null
3170
- },
3171
- flow: {
3172
- id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
3173
- version: lineageFieldFromEnv(input.env.flowVersion)
3174
- },
3175
- runtime: lineageFieldFromEnv(input.env.runtime),
3176
- process: {
3177
- id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
3178
- version: lineageFieldFromEnv(input.env.processVersion),
3179
- digest: lineageFieldFromEnv(input.env.processDigest)
3180
- },
3181
- runner: {
3182
- id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
3183
- version: lineageFieldFromEnv(input.env.runnerVersion)
3184
- },
3185
- source: lineageFieldFromEnv(input.env.source)
3186
- },
3187
- subject
3188
- };
3189
- }
3190
- var init_envelope = __esm(() => {
3191
- init_schema();
3192
- });
3193
-
3194
3205
  // ../../harness/kernel/log/store.ts
3195
3206
  function metaOf(obj) {
3196
3207
  if (obj === null || typeof obj !== "object")
@@ -3296,7 +3307,8 @@ function code(value) {
3296
3307
  return typeof value === "string" && CODE_TOKEN_PATTERN.test(value) ? value : null;
3297
3308
  }
3298
3309
  function roleSubject(value, sentenceStart = true) {
3299
- const name = typeof value === "string" && ROLE_VALUES.includes(value) ? `the ${value === "security" ? "security reviewer" : value.replace(/-/g, " ")}` : "a role";
3310
+ const known = typeof value === "string" ? lookupRole(value) : undefined;
3311
+ const name = known ? `the ${known.reading}` : "a role";
3300
3312
  return sentenceStart ? `${name[0]?.toUpperCase()}${name.slice(1)}` : name;
3301
3313
  }
3302
3314
  function roundLabel(record) {
@@ -3415,7 +3427,7 @@ function conflictReentry(record) {
3415
3427
  function dispatched(record) {
3416
3428
  const role = text(record.target_role);
3417
3429
  const who = roleSubject(role);
3418
- const reviewing = role === "code-reviewer" || role === "security";
3430
+ const reviewing = role !== null && (lookupRole(role)?.reviews ?? false);
3419
3431
  const round = whole(record.round);
3420
3432
  return {
3421
3433
  kind: "working",
@@ -3474,6 +3486,7 @@ function narrate(record, earlier = []) {
3474
3486
  }
3475
3487
  var REASONS, PAUSE_WITHOUT_CODE;
3476
3488
  var init_narration = __esm(() => {
3489
+ init_roles();
3477
3490
  init_schema();
3478
3491
  REASONS = {
3479
3492
  escalation: { words: "a role escalated a question", person: true },
@@ -3506,13 +3519,7 @@ var init_narration = __esm(() => {
3506
3519
 
3507
3520
  // ../../harness/kernel/adapters/agents/agent-line.ts
3508
3521
  function roleLabel(role) {
3509
- if (role in roleLabels)
3510
- return roleLabels[role];
3511
- if (role === "dev-review-loop")
3512
- return "Loop";
3513
- if (role === "operator")
3514
- return "Operator";
3515
- return role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
3522
+ return lookupTitle(role) ?? role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
3516
3523
  }
3517
3524
  function logQuiet(env = process.env) {
3518
3525
  return env.VINAYA_LOG_QUIET === "1" || env.VINAYA_LOG_QUIET === "true";
@@ -3580,17 +3587,9 @@ function renderNarratedUpdate(update) {
3580
3587
  ...call
3581
3588
  };
3582
3589
  }
3583
- var roleLabels, unicodeMarks, asciiMarks, META_KEY, META_VALUE, actionVerbs, resultVerbs;
3590
+ var unicodeMarks, asciiMarks, META_KEY, META_VALUE, actionVerbs, resultVerbs;
3584
3591
  var init_agent_line = __esm(() => {
3585
- roleLabels = {
3586
- planner: "Planner",
3587
- developer: "Developer",
3588
- "code-reviewer": "Code review",
3589
- security: "Security",
3590
- principal: "Principal",
3591
- archivist: "Archivist",
3592
- architect: "Architect"
3593
- };
3592
+ init_roles();
3594
3593
  unicodeMarks = { working: "▸", done: "✓", failed: "✕", waiting: "◌", round: "◆" };
3595
3594
  asciiMarks = { working: ">", done: "+", failed: "x", waiting: "~", round: "#" };
3596
3595
  META_KEY = /^[a-z]+$/;
@@ -4922,6 +4921,28 @@ function cliPackageRoot() {
4922
4921
  }
4923
4922
  var init_package_root = () => {};
4924
4923
 
4924
+ // ../../harness/processes/vinaya-strict/integration/log/log-roles.ts
4925
+ function registerVinayaLogRoles() {
4926
+ for (const { name, reading, title, reviews } of VINAYA_LOG_ROLES)
4927
+ registerRole(name, { reading, title, reviews });
4928
+ registerTitle("dev-review-loop", "Loop");
4929
+ }
4930
+ var VINAYA_LOG_ROLES, VINAYA_LOG_ROLE_NAMES;
4931
+ var init_log_roles = __esm(() => {
4932
+ init_roles();
4933
+ VINAYA_LOG_ROLES = [
4934
+ { name: "planner", reading: "planner", title: "Planner", reviews: false },
4935
+ { name: "developer", reading: "developer", title: "Developer", reviews: false },
4936
+ { name: "code-reviewer", reading: "code reviewer", title: "Code review", reviews: true },
4937
+ { name: "security", reading: "security reviewer", title: "Security", reviews: true },
4938
+ { name: "principal", reading: "principal", title: "Principal", reviews: false },
4939
+ { name: "archivist", reading: "archivist", title: "Archivist", reviews: false },
4940
+ { name: "architect", reading: "architect", title: "Architect", reviews: false }
4941
+ ];
4942
+ VINAYA_LOG_ROLE_NAMES = VINAYA_LOG_ROLES.map((role) => role.name);
4943
+ registerVinayaLogRoles();
4944
+ });
4945
+
4925
4946
  // ../../harness/kernel/adapters/code-host/github/gh.ts
4926
4947
  import { execFile as execFile3, execFileSync as execFileSync3 } from "node:child_process";
4927
4948
  import { promisify as promisify3 } from "node:util";
@@ -5656,6 +5677,7 @@ function installVinayaLogSinkFactory() {
5656
5677
  var init_log_sink_factory = __esm(() => {
5657
5678
  init_log_sink();
5658
5679
  init_package_root();
5680
+ init_log_roles();
5659
5681
  init_branch_issue();
5660
5682
  init_doctrine_version();
5661
5683
  });
@@ -12705,6 +12727,10 @@ function colourLoopLine(line, stream) {
12705
12727
  function isAgentVendor(value) {
12706
12728
  return AGENT_VENDOR_NAMES.includes(value);
12707
12729
  }
12730
+ function realCeilingTimer(fire, timeoutMs) {
12731
+ const timer = setTimeout(fire, timeoutMs);
12732
+ return () => clearTimeout(timer);
12733
+ }
12708
12734
  function addCodexWritableDirs(args, extraWritableDirs, resumed, developerFiles = []) {
12709
12735
  const requestedDirs = [...extraWritableDirs, ...developerFiles.map((file) => dirname13(file))];
12710
12736
  if (requestedDirs.length === 0)
@@ -13916,14 +13942,14 @@ function terminateChildWithGrace(pid, graceMs = TERMINATE_GRACE_MS) {
13916
13942
  } catch {}
13917
13943
  }
13918
13944
  }
13919
- function captureSettledChildSnapshot(pid) {
13920
- let snapshot = getProcessSnapshot(pid);
13945
+ function captureSettledChildSnapshot(pid, readSnapshot = getProcessSnapshot) {
13946
+ let snapshot = readSnapshot(pid);
13921
13947
  if (snapshot === null)
13922
13948
  return null;
13923
13949
  const deadline = Date.now() + IDENTITY_SETTLE_BUDGET_MS;
13924
13950
  while (Date.now() < deadline) {
13925
13951
  sleepSyncMs2(IDENTITY_SETTLE_POLL_MS);
13926
- const next = getProcessSnapshot(pid);
13952
+ const next = readSnapshot(pid);
13927
13953
  if (next === null)
13928
13954
  return snapshot;
13929
13955
  if (next.command === snapshot.command)
@@ -14892,7 +14918,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
14892
14918
  const warnTimer = setTimeout(() => {
14893
14919
  writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: approaching timeout — SIGTERM in ~${Math.round(warnLeadMs / 1000)}s unless it finishes first`);
14894
14920
  }, Math.max(timeoutMs - warnLeadMs, 0));
14895
- const timeoutTimer = setTimeout(() => {
14921
+ const disarmCeiling = (opts.armCeiling ?? realCeilingTimer)(() => {
14896
14922
  timedOut = true;
14897
14923
  writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: ceiling reached — sending SIGTERM`);
14898
14924
  child.kill("SIGTERM");
@@ -14928,7 +14954,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
14928
14954
  if (settled)
14929
14955
  return;
14930
14956
  settled = true;
14931
- clearTimeout(timeoutTimer);
14957
+ disarmCeiling();
14932
14958
  if (killTimer)
14933
14959
  clearTimeout(killTimer);
14934
14960
  clearTimeout(firstWaitTimer);
@@ -15698,8 +15724,8 @@ var init_protected_paths2 = __esm(() => {
15698
15724
 
15699
15725
  // ../../harness/processes/vinaya-strict/integration/policies/roles.ts
15700
15726
  var GRANTED_ROLES, ROLE_TOOL_GRANTS, VINAYA_TOOL_GRANTS, VINAYA_BROKER_ROLES, VINAYA_BOUNDARY_ROLES, OPERATOR_TOOL_GRANT, VINAYA_ROUTER_ROLES;
15701
- var init_roles = __esm(() => {
15702
- init_schema();
15727
+ var init_roles2 = __esm(() => {
15728
+ init_log_roles();
15703
15729
  GRANTED_ROLES = ["developer", "code-reviewer", "security", "controller"];
15704
15730
  ROLE_TOOL_GRANTS = {
15705
15731
  developer: [
@@ -15718,7 +15744,7 @@ var init_roles = __esm(() => {
15718
15744
  };
15719
15745
  VINAYA_TOOL_GRANTS = { roles: GRANTED_ROLES, grants: ROLE_TOOL_GRANTS };
15720
15746
  VINAYA_BROKER_ROLES = {
15721
- recognizedRoles: ROLE_VALUES,
15747
+ recognizedRoles: VINAYA_LOG_ROLE_NAMES,
15722
15748
  workerRoles: ["developer"],
15723
15749
  surfaceOwner: "the Planner"
15724
15750
  };
@@ -15997,7 +16023,7 @@ function vinayaRouterPolicies() {
15997
16023
  var init_vinaya_policies = __esm(() => {
15998
16024
  init_launch_records();
15999
16025
  init_protected_paths2();
16000
- init_roles();
16026
+ init_roles2();
16001
16027
  init_scratch_names();
16002
16028
  });
16003
16029
 
@@ -21563,6 +21589,74 @@ function reassertPrBodyPremise(prBody, fileReader = defaultFileReader) {
21563
21589
 
21564
21590
  // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
21565
21591
  init_round_assess();
21592
+
21593
+ // ../../harness/processes/vinaya-strict/loops/dev-review/v2/git-read-memo.ts
21594
+ import { resolve as resolve6 } from "node:path";
21595
+ var MEMOIZED = new Set(["rev-parse", "merge-base", "show-ref", "for-each-ref", "rev-list"]);
21596
+ var READ_ONLY_UNKEPT = new Set(["ls-remote", "status", "diff", "ls-files", "log", "show", "cat-file", "merge-tree"]);
21597
+ var state = { scopes: 0, turns: 0, entries: new Map, listeners: new Set };
21598
+ var memoEnabled = true;
21599
+ var notify = (event) => {
21600
+ for (const listener of state.listeners)
21601
+ listener(event);
21602
+ };
21603
+ function gitSubcommand(args) {
21604
+ for (let i = 0;i < args.length; i++) {
21605
+ const arg = args[i];
21606
+ if (arg === "-C" || arg === "-c" || arg === "--git-dir" || arg === "--work-tree") {
21607
+ i++;
21608
+ continue;
21609
+ }
21610
+ if (arg.startsWith("-"))
21611
+ continue;
21612
+ return arg;
21613
+ }
21614
+ return;
21615
+ }
21616
+ function gitReadKey(cwd, args) {
21617
+ return [resolve6(cwd ?? process.cwd()), ...args].join("\x00");
21618
+ }
21619
+ function gitReadMemoServing() {
21620
+ return memoEnabled && state.scopes > 0 && state.turns === 0;
21621
+ }
21622
+ function clearGitReadMemo(reason = "cleared") {
21623
+ state.entries.clear();
21624
+ notify({ kind: "clear", reason });
21625
+ }
21626
+ function runGit(cwd, args, run) {
21627
+ const sub = gitSubcommand(args);
21628
+ const key = gitReadKey(cwd, args);
21629
+ const memoizable = sub !== undefined && MEMOIZED.has(sub);
21630
+ if (memoizable && gitReadMemoServing()) {
21631
+ const kept = state.entries.get(key);
21632
+ if (kept !== undefined) {
21633
+ notify({ kind: "hit", key });
21634
+ return kept;
21635
+ }
21636
+ let value;
21637
+ try {
21638
+ value = run();
21639
+ } catch (error) {
21640
+ notify({ kind: "spawn", key, memoizable: true, served: false });
21641
+ throw error;
21642
+ }
21643
+ notify({ kind: "spawn", key, memoizable: true, served: true });
21644
+ if (gitReadMemoServing())
21645
+ state.entries.set(key, value);
21646
+ return value;
21647
+ }
21648
+ notify({ kind: "spawn", key, memoizable, served: false });
21649
+ if (memoizable || sub !== undefined && READ_ONLY_UNKEPT.has(sub))
21650
+ return run();
21651
+ try {
21652
+ return run();
21653
+ } finally {
21654
+ clearGitReadMemo(`git ${sub ?? "(none)"}`);
21655
+ }
21656
+ }
21657
+ var wrapped = new WeakMap;
21658
+
21659
+ // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
21566
21660
  function shEnvOverride(name, fallback) {
21567
21661
  const raw = process.env[name];
21568
21662
  if (!raw)
@@ -21578,11 +21672,12 @@ function sleepSyncMs4(ms) {
21578
21672
  }
21579
21673
  function sh(cmd, args, options = {}) {
21580
21674
  if (cmd !== "gh") {
21581
- return execFileSync18(cmd, args, {
21675
+ const run = () => execFileSync18(cmd, args, {
21582
21676
  encoding: "utf8",
21583
21677
  stdio: ["ignore", "pipe", "pipe"],
21584
21678
  maxBuffer: MAX_GH_OUTPUT_BYTES
21585
21679
  }).trim();
21680
+ return cmd === "git" ? runGit(undefined, args, run) : run();
21586
21681
  }
21587
21682
  const attempts = options.attempts ?? shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_ATTEMPTS", 3);
21588
21683
  const backoffMs = shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_BACKOFF_MS", 500);
@@ -21870,7 +21965,9 @@ function fetchConflictingFiles(baseBranch, headBranch) {
21870
21965
  execFileSync18("git", ["fetch", "--quiet", "origin", baseBranch, headBranch], {
21871
21966
  stdio: ["ignore", "ignore", "ignore"]
21872
21967
  });
21873
- } catch {}
21968
+ } catch {} finally {
21969
+ clearGitReadMemo("git fetch");
21970
+ }
21874
21971
  try {
21875
21972
  execFileSync18("git", ["merge-tree", "--write-tree", `origin/${baseBranch}`, `origin/${headBranch}`], {
21876
21973
  encoding: "utf8",
@@ -22474,7 +22571,7 @@ init_enforcement_controls();
22474
22571
  // ../../harness/kernel/gates/local-gate-control.ts
22475
22572
  import { execFileSync as execFileSync20 } from "node:child_process";
22476
22573
  import { existsSync as existsSync28, readFileSync as readFileSync29, realpathSync as realpathSync8, statSync as statSync9 } from "node:fs";
22477
- import { dirname as dirname21, isAbsolute as isAbsolute4, join as join34, resolve as resolve6 } from "node:path";
22574
+ import { dirname as dirname21, isAbsolute as isAbsolute4, join as join34, resolve as resolve7 } from "node:path";
22478
22575
 
22479
22576
  // ../../harness/kernel/connectors/git/detect.ts
22480
22577
  import { execFile as execFile10, execFileSync as execFileSync19 } from "node:child_process";
@@ -22678,7 +22775,7 @@ function repairLocalGateControl(directory, onRepair = () => {}) {
22678
22775
  let ownFolder = value === null;
22679
22776
  if (value !== null) {
22680
22777
  try {
22681
- ownFolder = realpathSync8(resolve6(root, value)) === realpathSync8(join34(root, TRACKED_HOOK_DIR));
22778
+ ownFolder = realpathSync8(resolve7(root, value)) === realpathSync8(join34(root, TRACKED_HOOK_DIR));
22682
22779
  } catch {
22683
22780
  ownFolder = false;
22684
22781
  }
@@ -23641,7 +23738,7 @@ import { rmSync as rmSync11 } from "node:fs";
23641
23738
  init_schema();
23642
23739
  import { z as z11 } from "zod";
23643
23740
  import { existsSync as existsSync31 } from "node:fs";
23644
- import { resolve as resolve7 } from "node:path";
23741
+ import { resolve as resolve8 } from "node:path";
23645
23742
  import { spawnSync as spawnSync3 } from "node:child_process";
23646
23743
 
23647
23744
  // ../../harness/processes/vinaya-strict/loops/dev-review/actions/live-developer-context.ts
@@ -25761,8 +25858,10 @@ function defaultGitRevParseOriginMain() {
25761
25858
  }
25762
25859
  function defaultGitIsAncestor(ancestor, descendant) {
25763
25860
  try {
25764
- execFileSync22("git", ["merge-base", "--is-ancestor", ancestor, descendant], {
25765
- stdio: ["ignore", "ignore", "ignore"]
25861
+ const args = ["merge-base", "--is-ancestor", ancestor, descendant];
25862
+ runGit(undefined, args, () => {
25863
+ execFileSync22("git", args, { stdio: ["ignore", "ignore", "ignore"] });
25864
+ return "";
25766
25865
  });
25767
25866
  return true;
25768
25867
  } catch (err) {
@@ -25772,12 +25871,14 @@ function defaultGitIsAncestor(ancestor, descendant) {
25772
25871
  }
25773
25872
  }
25774
25873
  function defaultGitMergeBase(head) {
25775
- return resolveMergeBase(head);
25874
+ return resolveMergeBase(head).finally(() => clearGitReadMemo("merge-base resolution"));
25776
25875
  }
25777
25876
  function defaultGitFetch(sha) {
25778
25877
  try {
25779
25878
  execFileSync22("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
25780
- } catch {}
25879
+ } catch {} finally {
25880
+ clearGitReadMemo("git fetch");
25881
+ }
25781
25882
  }
25782
25883
  function defaultGitDiffShortstat(base, head) {
25783
25884
  try {
@@ -25855,6 +25956,7 @@ function defaultRunSecurityScanSubprocess(command, scanTargetDir) {
25855
25956
  return { ok: true, output: combined };
25856
25957
  return { ok: false, reason: e.message };
25857
25958
  } finally {
25959
+ clearGitReadMemo("security scan");
25858
25960
  try {
25859
25961
  rmSync11(sandbox, { recursive: true, force: true });
25860
25962
  } catch {}
@@ -25871,7 +25973,11 @@ function defaultResolveTaskSurface(task) {
25871
25973
  }
25872
25974
  }
25873
25975
  function defaultPatchIdOf(sha) {
25874
- return patchIdAt("main", sha);
25976
+ try {
25977
+ return patchIdAt("main", sha);
25978
+ } finally {
25979
+ clearGitReadMemo("patch-id fetch");
25980
+ }
25875
25981
  }
25876
25982
  var DevReviewLoopEventInputSchema = z11.discriminatedUnion("event", DevReviewLoopEventSchema.options.map((option) => option.omit({ meta: true, subject: true })));
25877
25983
  function assertValidLoopEvent(e) {
@@ -25915,11 +26021,12 @@ function defaultGitWorktreeUntrackedPaths(worktreePath) {
25915
26021
  }
25916
26022
  }
25917
26023
  function gitOk(worktreePath, args) {
26024
+ const full = ["-C", worktreePath, ...args];
25918
26025
  try {
25919
- return execFileSync22("git", ["-C", worktreePath, ...args], {
26026
+ return runGit(undefined, full, () => execFileSync22("git", full, {
25920
26027
  encoding: "utf8",
25921
26028
  stdio: ["ignore", "pipe", "pipe"]
25922
- }).trim();
26029
+ }).trim());
25923
26030
  } catch {
25924
26031
  return null;
25925
26032
  }
@@ -26024,12 +26131,12 @@ function defaultClassifyAgainstDefaultTip(worktreePath, head, tip, paths, remote
26024
26131
  function rebaseInProgress(worktreePath) {
26025
26132
  return ["rebase-merge", "rebase-apply"].some((name) => {
26026
26133
  const path = gitOk(worktreePath, ["rev-parse", "--git-path", name]);
26027
- return path !== null && existsSync31(resolve7(worktreePath, path));
26134
+ return path !== null && existsSync31(resolve8(worktreePath, path));
26028
26135
  });
26029
26136
  }
26030
26137
  function mergeInProgress2(worktreePath) {
26031
26138
  const path = gitOk(worktreePath, ["rev-parse", "--git-path", "MERGE_HEAD"]);
26032
- return path !== null && existsSync31(resolve7(worktreePath, path));
26139
+ return path !== null && existsSync31(resolve8(worktreePath, path));
26033
26140
  }
26034
26141
  function defaultMergeDefaultTip(worktreePath, tip, remoteUrl) {
26035
26142
  const refuse = (reason, conflictFiles = []) => ({
@@ -26054,6 +26161,7 @@ function defaultMergeDefaultTip(worktreePath, tip, remoteUrl) {
26054
26161
  env: { ...process.env, GIT_EDITOR: "true" },
26055
26162
  stdio: ["ignore", "pipe", "pipe"]
26056
26163
  });
26164
+ clearGitReadMemo("git merge");
26057
26165
  if (!merged.error && merged.status === 0 && !mergeInProgress2(worktreePath)) {
26058
26166
  const head = gitOk(worktreePath, ["rev-parse", "HEAD"]);
26059
26167
  if (head)
@@ -26101,6 +26209,7 @@ function defaultRebaseOntoDefaultTip(worktreePath, tip, remoteUrl) {
26101
26209
  env: { ...process.env, GIT_EDITOR: "true" },
26102
26210
  stdio: ["ignore", "pipe", "pipe"]
26103
26211
  });
26212
+ clearGitReadMemo("git rebase");
26104
26213
  if (!rebased.error && rebased.status === 0 && !rebaseInProgress(worktreePath)) {
26105
26214
  const head = gitOk(worktreePath, ["rev-parse", "HEAD"]);
26106
26215
  if (head)
@@ -26126,7 +26235,11 @@ function ownChangesRangeBase(worktreePath, pushedBase) {
26126
26235
  if (pushedBase === null)
26127
26236
  return null;
26128
26237
  try {
26129
- execFileSync22("git", ["-C", worktreePath, "merge-base", "--is-ancestor", pushedBase, "HEAD"], { stdio: "ignore" });
26238
+ const args = ["-C", worktreePath, "merge-base", "--is-ancestor", pushedBase, "HEAD"];
26239
+ runGit(undefined, args, () => {
26240
+ execFileSync22("git", args, { stdio: "ignore" });
26241
+ return "";
26242
+ });
26130
26243
  return pushedBase;
26131
26244
  } catch (err) {
26132
26245
  if (err.status !== 1)
@@ -26665,6 +26778,7 @@ function defaultBuildVendoredCliIfMissing(worktreePath) {
26665
26778
  encoding: "utf8",
26666
26779
  stdio: ["ignore", "pipe", "pipe"]
26667
26780
  });
26781
+ clearGitReadMemo("vendored CLI build");
26668
26782
  if (result.error || result.status !== 0) {
26669
26783
  const output = `${result.stdout ?? ""}
26670
26784
  ${result.stderr ?? ""}`.trim();
@@ -26690,6 +26804,7 @@ function defaultInstallWorktreeDependencies(worktreePath) {
26690
26804
  stdio: ["ignore", "pipe", "pipe"],
26691
26805
  timeout: 10 * 60 * 1000
26692
26806
  });
26807
+ clearGitReadMemo("dependency install");
26693
26808
  if (result.error || result.status !== 0) {
26694
26809
  const output = `${result.stdout ?? ""}
26695
26810
  ${result.stderr ?? ""}`.trim().split(`
@@ -26724,6 +26839,7 @@ ${"stderr" in err ? String(err.stderr ?? "") : ""}`.trim() : String(err);
26724
26839
  }
26725
26840
  throw err;
26726
26841
  } finally {
26842
+ clearGitReadMemo("git commit");
26727
26843
  rmSync13(traceDir, { recursive: true, force: true });
26728
26844
  }
26729
26845
  return { ok: true, sha: sh("git", ["-C", worktreePath, "rev-parse", "HEAD"]).trim() };
@@ -26774,6 +26890,7 @@ ${String(raw.stderr ?? "")}`.trim();
26774
26890
  const detail = boundedPushOutput(output || (err instanceof Error ? err.message : String(err)), "tail");
26775
26891
  throw new Error(`${exit}: ${detail || "no captured output"}`);
26776
26892
  } finally {
26893
+ clearGitReadMemo("git push");
26777
26894
  rmSync13(traceDir, { recursive: true, force: true });
26778
26895
  }
26779
26896
  }
@@ -27608,6 +27725,7 @@ var runRealLiveCommand = (command, cwd, timeoutMs) => new Promise((resolve) => {
27608
27725
  if (settled)
27609
27726
  return;
27610
27727
  settled = true;
27728
+ clearGitReadMemo("live command");
27611
27729
  clearTimeout(timer);
27612
27730
  if (grace !== undefined)
27613
27731
  clearTimeout(grace);
@@ -27649,6 +27767,7 @@ var LIVE_CHECKOUT_TIMEOUT_MS = 15 * 60000;
27649
27767
  function runFile(file, args, opts) {
27650
27768
  return new Promise((resolve, reject) => {
27651
27769
  execFile11(file, [...args], { cwd: opts.cwd, env: opts.env, timeout: opts.timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (err, _stdout, stderr) => {
27770
+ clearGitReadMemo(`${file} ${args[0] ?? ""}`);
27652
27771
  if (err === null)
27653
27772
  resolve();
27654
27773
  else
@@ -27669,6 +27788,7 @@ async function prepareRealLiveCheckout(repoRoot, head, opts = {}) {
27669
27788
  try {
27670
27789
  execFileSync26("git", ["-C", repoRoot, "worktree", "prune"], { stdio: "ignore" });
27671
27790
  } catch {}
27791
+ clearGitReadMemo("live checkout removed");
27672
27792
  };
27673
27793
  try {
27674
27794
  await runFile("git", ["-C", repoRoot, "-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", tree, head], {
@@ -28343,7 +28463,7 @@ init_loop_log();
28343
28463
  init_worker_boundary();
28344
28464
  init_issue_validation();
28345
28465
  init_package_root();
28346
- import { resolve as resolve8 } from "node:path";
28466
+ import { resolve as resolve9 } from "node:path";
28347
28467
  import { join as join40 } from "node:path";
28348
28468
  import { readFileSync as readFileSync37 } from "node:fs";
28349
28469
 
@@ -28459,7 +28579,7 @@ async function setStandaloneLogIdentity(env = process.env, cliRoot = packageRoot
28459
28579
  }
28460
28580
  env.VINAYA_RUNNER_ID = "standalone";
28461
28581
  env.VINAYA_RUNNER_VERSION = pkg.version;
28462
- const checkout = resolve8(cliRoot, "../..");
28582
+ const checkout = resolve9(cliRoot, "../..");
28463
28583
  const loaderPath = join40(checkout, "harness", "kernel", "dev-process-socket", "loader", "load-process.ts");
28464
28584
  const processFolder = join40(checkout, PROCESS_FOLDER_IN_CHECKOUT);
28465
28585
  if (!existsSync35(join40(checkout, ".git")) || !existsSync35(loaderPath) || !existsSync35(processFolder))
@@ -30182,6 +30302,7 @@ init_round_assess();
30182
30302
 
30183
30303
  // ../../harness/processes/vinaya-strict/tools/dev-review-policy/assess-round.ts
30184
30304
  init_schema();
30305
+ init_log_roles();
30185
30306
  function loopEventEnvelope(state) {
30186
30307
  return { kind: "dev_review_loop", payload: {}, loop_id: state.config.loopId };
30187
30308
  }
@@ -30229,7 +30350,7 @@ function verdictLogRole(role) {
30229
30350
  }
30230
30351
  function reviewerEntries(state, verdicts) {
30231
30352
  const held = new Map(verdicts.map((v) => [verdictLogRole(v.role), v]));
30232
- const isRole = (value) => ROLE_VALUES.includes(value);
30353
+ const isRole = (value) => VINAYA_LOG_ROLE_NAMES.includes(value);
30233
30354
  const roles = [...new Set([...state.config.reviewers.filter(isRole), ...held.keys()])];
30234
30355
  return roles.map((role) => {
30235
30356
  const v = held.get(role);