@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
package/dist/index.js CHANGED
@@ -6904,21 +6904,145 @@ var init_resolve_repo = __esm(() => {
6904
6904
  };
6905
6905
  });
6906
6906
 
6907
+ // ../../harness/kernel/log/roles.ts
6908
+ function registerRole(name, role) {
6909
+ roles.set(name, role);
6910
+ }
6911
+ function registerTitle(name, title) {
6912
+ titles.set(name, title);
6913
+ }
6914
+ function isRole(value) {
6915
+ return value !== undefined && roles.has(value);
6916
+ }
6917
+ function lookupRole(name) {
6918
+ return roles.get(name);
6919
+ }
6920
+ function lookupTitle(name) {
6921
+ return roles.get(name)?.title ?? titles.get(name);
6922
+ }
6923
+ var roles, titles;
6924
+ var init_roles = __esm(() => {
6925
+ roles = new Map;
6926
+ titles = new Map;
6927
+ });
6928
+
6929
+ // ../../harness/kernel/log/envelope.ts
6930
+ import { createHash as createHash5 } from "node:crypto";
6931
+ function actorIdFromEnv(role) {
6932
+ return role === undefined || role === "" ? null : role;
6933
+ }
6934
+ function lineageFieldFromEnv(value) {
6935
+ return value === undefined || value === "" ? null : value;
6936
+ }
6937
+ function attemptFromEnv(value) {
6938
+ if (value === undefined || value === "")
6939
+ return null;
6940
+ const n = Number(value);
6941
+ return Number.isInteger(n) ? n : null;
6942
+ }
6943
+ function provenanceFor(input) {
6944
+ if (input.provenance)
6945
+ return input.provenance;
6946
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6947
+ return "unavailable";
6948
+ if (input.env.role || input.env.task)
6949
+ return "env_correlated";
6950
+ return "unavailable";
6951
+ }
6952
+ function issueFromTask(task) {
6953
+ if (task === undefined || task === "")
6954
+ return null;
6955
+ const n = Number(task);
6956
+ return Number.isInteger(n) ? n : null;
6957
+ }
6958
+ function roundFromEnv(round) {
6959
+ if (round === undefined || round === "")
6960
+ return;
6961
+ const n = Number(round);
6962
+ return Number.isInteger(n) ? n : undefined;
6963
+ }
6964
+ function prFromEnv(pr) {
6965
+ if (pr === undefined || pr === "")
6966
+ return;
6967
+ const n = Number(pr);
6968
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6969
+ }
6970
+ function buildHeader(input) {
6971
+ const role = isRole(input.env.role) ? input.env.role : "unattributed";
6972
+ const round = roundFromEnv(input.env.round);
6973
+ const pr = prFromEnv(input.env.pr);
6974
+ const subject = {
6975
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6976
+ role,
6977
+ ...round !== undefined ? { round } : {},
6978
+ ...pr !== undefined ? { pr } : {},
6979
+ ...input.subject ?? {}
6980
+ };
6981
+ const issue = subject.issue;
6982
+ return {
6983
+ meta: {
6984
+ schema: 4,
6985
+ ts: input.now.toISOString(),
6986
+ run_id: input.runId,
6987
+ seq: input.seq,
6988
+ repo: input.repo,
6989
+ vinaya: input.vinaya,
6990
+ doctrine: input.doctrine,
6991
+ host: input.host,
6992
+ machine: createHash5("sha256").update(input.hostname).digest("hex"),
6993
+ event_id: input.eventId,
6994
+ process_id: input.processId,
6995
+ actor_id: actorIdFromEnv(input.env.role),
6996
+ lineage: {
6997
+ run: lineageFieldFromEnv(input.env.run),
6998
+ attempt: attemptFromEnv(input.env.attempt),
6999
+ parent: lineageFieldFromEnv(input.env.parent)
7000
+ },
7001
+ input_versions: {
7002
+ manifest_version: input.inputVersions?.manifestVersion ?? null,
7003
+ objectives_version: input.inputVersions?.objectivesVersion ?? null,
7004
+ brief_hash: input.inputVersions?.briefHash ?? null,
7005
+ ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
7006
+ pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
7007
+ policy_digest: input.inputVersions?.policyDigest ?? null
7008
+ },
7009
+ provenance: provenanceFor(input),
7010
+ work: {
7011
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
7012
+ repo: input.repo,
7013
+ change: pr === undefined ? null : String(pr),
7014
+ revision: input.revision ?? null
7015
+ },
7016
+ flow: {
7017
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
7018
+ version: lineageFieldFromEnv(input.env.flowVersion)
7019
+ },
7020
+ runtime: lineageFieldFromEnv(input.env.runtime),
7021
+ process: {
7022
+ id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
7023
+ version: lineageFieldFromEnv(input.env.processVersion),
7024
+ digest: lineageFieldFromEnv(input.env.processDigest)
7025
+ },
7026
+ runner: {
7027
+ id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
7028
+ version: lineageFieldFromEnv(input.env.runnerVersion)
7029
+ },
7030
+ source: lineageFieldFromEnv(input.env.source)
7031
+ },
7032
+ subject
7033
+ };
7034
+ }
7035
+ var init_envelope = __esm(() => {
7036
+ init_roles();
7037
+ });
7038
+
6907
7039
  // ../../harness/kernel/log/schema.ts
6908
7040
  import { z as z6 } from "zod";
6909
- 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;
7041
+ 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;
6910
7042
  var init_schema = __esm(() => {
6911
7043
  init_custom();
6912
- ROLE_VALUES = [
6913
- "planner",
6914
- "developer",
6915
- "code-reviewer",
6916
- "security",
6917
- "principal",
6918
- "archivist",
6919
- "architect"
6920
- ];
6921
- RoleSchema = z6.enum(ROLE_VALUES);
7044
+ ROLE_NAME_PATTERN = /^[a-z0-9-]+$/;
7045
+ RoleSchema = z6.string().regex(ROLE_NAME_PATTERN);
6922
7046
  HOST_VALUES = ["hook", "ci", "cli", "loop"];
6923
7047
  HostSchema = z6.enum(HOST_VALUES);
6924
7048
  RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
@@ -7500,119 +7624,6 @@ var init_schema = __esm(() => {
7500
7624
  ]);
7501
7625
  });
7502
7626
 
7503
- // ../../harness/kernel/log/envelope.ts
7504
- import { createHash as createHash5 } from "node:crypto";
7505
- function isRole(value) {
7506
- return value !== undefined && ROLE_VALUES.includes(value);
7507
- }
7508
- function actorIdFromEnv(role) {
7509
- return role === undefined || role === "" ? null : role;
7510
- }
7511
- function lineageFieldFromEnv(value) {
7512
- return value === undefined || value === "" ? null : value;
7513
- }
7514
- function attemptFromEnv(value) {
7515
- if (value === undefined || value === "")
7516
- return null;
7517
- const n = Number(value);
7518
- return Number.isInteger(n) ? n : null;
7519
- }
7520
- function provenanceFor(input) {
7521
- if (input.provenance)
7522
- return input.provenance;
7523
- if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
7524
- return "unavailable";
7525
- if (input.env.role || input.env.task)
7526
- return "env_correlated";
7527
- return "unavailable";
7528
- }
7529
- function issueFromTask(task) {
7530
- if (task === undefined || task === "")
7531
- return null;
7532
- const n = Number(task);
7533
- return Number.isInteger(n) ? n : null;
7534
- }
7535
- function roundFromEnv(round) {
7536
- if (round === undefined || round === "")
7537
- return;
7538
- const n = Number(round);
7539
- return Number.isInteger(n) ? n : undefined;
7540
- }
7541
- function prFromEnv(pr) {
7542
- if (pr === undefined || pr === "")
7543
- return;
7544
- const n = Number(pr);
7545
- return Number.isInteger(n) && n > 0 ? n : undefined;
7546
- }
7547
- function buildHeader(input) {
7548
- const role = isRole(input.env.role) ? input.env.role : "unattributed";
7549
- const round = roundFromEnv(input.env.round);
7550
- const pr = prFromEnv(input.env.pr);
7551
- const subject = {
7552
- issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
7553
- role,
7554
- ...round !== undefined ? { round } : {},
7555
- ...pr !== undefined ? { pr } : {},
7556
- ...input.subject ?? {}
7557
- };
7558
- const issue = subject.issue;
7559
- return {
7560
- meta: {
7561
- schema: 4,
7562
- ts: input.now.toISOString(),
7563
- run_id: input.runId,
7564
- seq: input.seq,
7565
- repo: input.repo,
7566
- vinaya: input.vinaya,
7567
- doctrine: input.doctrine,
7568
- host: input.host,
7569
- machine: createHash5("sha256").update(input.hostname).digest("hex"),
7570
- event_id: input.eventId,
7571
- process_id: input.processId,
7572
- actor_id: actorIdFromEnv(input.env.role),
7573
- lineage: {
7574
- run: lineageFieldFromEnv(input.env.run),
7575
- attempt: attemptFromEnv(input.env.attempt),
7576
- parent: lineageFieldFromEnv(input.env.parent)
7577
- },
7578
- input_versions: {
7579
- manifest_version: input.inputVersions?.manifestVersion ?? null,
7580
- objectives_version: input.inputVersions?.objectivesVersion ?? null,
7581
- brief_hash: input.inputVersions?.briefHash ?? null,
7582
- ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
7583
- pause_bound_ruling: input.inputVersions?.pauseBoundRuling ?? null,
7584
- policy_digest: input.inputVersions?.policyDigest ?? null
7585
- },
7586
- provenance: provenanceFor(input),
7587
- work: {
7588
- ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
7589
- repo: input.repo,
7590
- change: pr === undefined ? null : String(pr),
7591
- revision: input.revision ?? null
7592
- },
7593
- flow: {
7594
- id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
7595
- version: lineageFieldFromEnv(input.env.flowVersion)
7596
- },
7597
- runtime: lineageFieldFromEnv(input.env.runtime),
7598
- process: {
7599
- id: lineageFieldFromEnv(input.env.processId) ?? "vinaya",
7600
- version: lineageFieldFromEnv(input.env.processVersion),
7601
- digest: lineageFieldFromEnv(input.env.processDigest)
7602
- },
7603
- runner: {
7604
- id: lineageFieldFromEnv(input.env.runnerId) ?? "standalone",
7605
- version: lineageFieldFromEnv(input.env.runnerVersion)
7606
- },
7607
- source: lineageFieldFromEnv(input.env.source)
7608
- },
7609
- subject
7610
- };
7611
- }
7612
- var init_envelope = __esm(() => {
7613
- init_schema();
7614
- });
7615
-
7616
7627
  // ../../harness/kernel/log/redact.ts
7617
7628
  function redactString(value, home) {
7618
7629
  let out = value.replace(GITHUB_TOKEN_PATTERN, "<redacted>").replace(CLASSIC_GITHUB_PAT_PATTERN, "$1<redacted>").replace(BEARER_TOKEN_PATTERN, "<redacted>").replace(AWS_ACCESS_KEY_PATTERN, "<redacted>").replace(SLACK_TOKEN_PATTERN, "<redacted>").replace(STRIPE_KEY_PATTERN, "<redacted>").replace(ANTHROPIC_KEY_PATTERN, "<redacted>").replace(OPENAI_KEY_PATTERN, "<redacted>").replace(NPM_TOKEN_PATTERN, "<redacted>").replace(JWT_PATTERN, "<redacted>").replace(PEM_BLOCK_PATTERN, "<redacted>").replace(BASIC_AUTH_URL_PATTERN, "$1<redacted>@").replace(GENERIC_SECRET_ASSIGNMENT_PATTERN, "$1<redacted>");
@@ -8679,7 +8690,8 @@ function code(value) {
8679
8690
  return typeof value === "string" && CODE_TOKEN_PATTERN.test(value) ? value : null;
8680
8691
  }
8681
8692
  function roleSubject(value, sentenceStart = true) {
8682
- const name = typeof value === "string" && ROLE_VALUES.includes(value) ? `the ${value === "security" ? "security reviewer" : value.replace(/-/g, " ")}` : "a role";
8693
+ const known = typeof value === "string" ? lookupRole(value) : undefined;
8694
+ const name = known ? `the ${known.reading}` : "a role";
8683
8695
  return sentenceStart ? `${name[0]?.toUpperCase()}${name.slice(1)}` : name;
8684
8696
  }
8685
8697
  function roundLabel(record) {
@@ -8798,7 +8810,7 @@ function conflictReentry(record) {
8798
8810
  function dispatched(record) {
8799
8811
  const role = text(record.target_role);
8800
8812
  const who = roleSubject(role);
8801
- const reviewing = role === "code-reviewer" || role === "security";
8813
+ const reviewing = role !== null && (lookupRole(role)?.reviews ?? false);
8802
8814
  const round = whole(record.round);
8803
8815
  return {
8804
8816
  kind: "working",
@@ -8857,6 +8869,7 @@ function narrate(record, earlier = []) {
8857
8869
  }
8858
8870
  var REASONS, PAUSE_WITHOUT_CODE;
8859
8871
  var init_narration = __esm(() => {
8872
+ init_roles();
8860
8873
  init_schema();
8861
8874
  REASONS = {
8862
8875
  escalation: { words: "a role escalated a question", person: true },
@@ -8889,13 +8902,7 @@ var init_narration = __esm(() => {
8889
8902
 
8890
8903
  // ../../harness/kernel/adapters/agents/agent-line.ts
8891
8904
  function roleLabel(role) {
8892
- if (role in roleLabels)
8893
- return roleLabels[role];
8894
- if (role === "dev-review-loop")
8895
- return "Loop";
8896
- if (role === "operator")
8897
- return "Operator";
8898
- return role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
8905
+ return lookupTitle(role) ?? role.replace(/-/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
8899
8906
  }
8900
8907
  function logQuiet(env = process.env) {
8901
8908
  return env.VINAYA_LOG_QUIET === "1" || env.VINAYA_LOG_QUIET === "true";
@@ -8977,17 +8984,9 @@ function renderNarratedUpdate(update) {
8977
8984
  ...call
8978
8985
  };
8979
8986
  }
8980
- var roleLabels, unicodeMarks, asciiMarks, META_KEY, META_VALUE, actionVerbs, resultVerbs;
8987
+ var unicodeMarks, asciiMarks, META_KEY, META_VALUE, actionVerbs, resultVerbs;
8981
8988
  var init_agent_line = __esm(() => {
8982
- roleLabels = {
8983
- planner: "Planner",
8984
- developer: "Developer",
8985
- "code-reviewer": "Code review",
8986
- security: "Security",
8987
- principal: "Principal",
8988
- archivist: "Archivist",
8989
- architect: "Architect"
8990
- };
8989
+ init_roles();
8991
8990
  unicodeMarks = { working: "▸", done: "✓", failed: "✕", waiting: "◌", round: "◆" };
8992
8991
  asciiMarks = { working: ">", done: "+", failed: "x", waiting: "~", round: "#" };
8993
8992
  META_KEY = /^[a-z]+$/;
@@ -10334,6 +10333,28 @@ var init_log_sink = __esm(() => {
10334
10333
  defaultSinkSlot = createDefaultLogSinkSlot(process.env.VINAYA_RUN_ID || randomUUID3());
10335
10334
  });
10336
10335
 
10336
+ // ../../harness/processes/vinaya-strict/integration/log/log-roles.ts
10337
+ function registerVinayaLogRoles() {
10338
+ for (const { name, reading, title, reviews } of VINAYA_LOG_ROLES)
10339
+ registerRole(name, { reading, title, reviews });
10340
+ registerTitle("dev-review-loop", "Loop");
10341
+ }
10342
+ var VINAYA_LOG_ROLES, VINAYA_LOG_ROLE_NAMES;
10343
+ var init_log_roles = __esm(() => {
10344
+ init_roles();
10345
+ VINAYA_LOG_ROLES = [
10346
+ { name: "planner", reading: "planner", title: "Planner", reviews: false },
10347
+ { name: "developer", reading: "developer", title: "Developer", reviews: false },
10348
+ { name: "code-reviewer", reading: "code reviewer", title: "Code review", reviews: true },
10349
+ { name: "security", reading: "security reviewer", title: "Security", reviews: true },
10350
+ { name: "principal", reading: "principal", title: "Principal", reviews: false },
10351
+ { name: "archivist", reading: "archivist", title: "Archivist", reviews: false },
10352
+ { name: "architect", reading: "architect", title: "Architect", reviews: false }
10353
+ ];
10354
+ VINAYA_LOG_ROLE_NAMES = VINAYA_LOG_ROLES.map((role) => role.name);
10355
+ registerVinayaLogRoles();
10356
+ });
10357
+
10337
10358
  // ../../harness/processes/vinaya-strict/integration/log/branch-issue.ts
10338
10359
  import { execFile as execFile5 } from "node:child_process";
10339
10360
  import { promisify as promisify5 } from "node:util";
@@ -10536,6 +10557,7 @@ function installVinayaLogSinkFactory() {
10536
10557
  var init_log_sink_factory = __esm(() => {
10537
10558
  init_log_sink();
10538
10559
  init_package_root();
10560
+ init_log_roles();
10539
10561
  init_branch_issue();
10540
10562
  init_doctrine_version();
10541
10563
  });
@@ -14925,6 +14947,10 @@ function isAgentVendor2(value) {
14925
14947
  function isAgentClass(value) {
14926
14948
  return AGENT_CLASS_VALUES.includes(value);
14927
14949
  }
14950
+ function realCeilingTimer(fire, timeoutMs) {
14951
+ const timer = setTimeout(fire, timeoutMs);
14952
+ return () => clearTimeout(timer);
14953
+ }
14928
14954
  function addCodexWritableDirs(args, extraWritableDirs, resumed, developerFiles = []) {
14929
14955
  const requestedDirs = [...extraWritableDirs, ...developerFiles.map((file) => dirname13(file))];
14930
14956
  if (requestedDirs.length === 0)
@@ -16136,14 +16162,14 @@ function terminateChildWithGrace(pid, graceMs = TERMINATE_GRACE_MS) {
16136
16162
  } catch {}
16137
16163
  }
16138
16164
  }
16139
- function captureSettledChildSnapshot(pid) {
16140
- let snapshot = getProcessSnapshot(pid);
16165
+ function captureSettledChildSnapshot(pid, readSnapshot = getProcessSnapshot) {
16166
+ let snapshot = readSnapshot(pid);
16141
16167
  if (snapshot === null)
16142
16168
  return null;
16143
16169
  const deadline = Date.now() + IDENTITY_SETTLE_BUDGET_MS;
16144
16170
  while (Date.now() < deadline) {
16145
16171
  sleepSyncMs2(IDENTITY_SETTLE_POLL_MS);
16146
- const next = getProcessSnapshot(pid);
16172
+ const next = readSnapshot(pid);
16147
16173
  if (next === null)
16148
16174
  return snapshot;
16149
16175
  if (next.command === snapshot.command)
@@ -17145,7 +17171,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
17145
17171
  const warnTimer = setTimeout(() => {
17146
17172
  writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: approaching timeout — SIGTERM in ~${Math.round(warnLeadMs / 1000)}s unless it finishes first`);
17147
17173
  }, Math.max(timeoutMs - warnLeadMs, 0));
17148
- const timeoutTimer = setTimeout(() => {
17174
+ const disarmCeiling = (opts.armCeiling ?? realCeilingTimer)(() => {
17149
17175
  timedOut = true;
17150
17176
  writeLifecycle(`[vinaya dispatch ${effectId}] ${role} via ${agent}: ceiling reached — sending SIGTERM`);
17151
17177
  child.kill("SIGTERM");
@@ -17181,7 +17207,7 @@ ${agentControlsError}` : sandboxProbeError !== null ? `[vinaya dispatch ${effect
17181
17207
  if (settled)
17182
17208
  return;
17183
17209
  settled = true;
17184
- clearTimeout(timeoutTimer);
17210
+ disarmCeiling();
17185
17211
  if (killTimer)
17186
17212
  clearTimeout(killTimer);
17187
17213
  clearTimeout(firstWaitTimer);
@@ -17608,8 +17634,8 @@ var init_protected_paths2 = __esm(() => {
17608
17634
 
17609
17635
  // ../../harness/processes/vinaya-strict/integration/policies/roles.ts
17610
17636
  var GRANTED_ROLES, ROLE_TOOL_GRANTS, VINAYA_TOOL_GRANTS, VINAYA_BROKER_ROLES, VINAYA_BOUNDARY_ROLES, OPERATOR_TOOL_GRANT, VINAYA_ROUTER_ROLES;
17611
- var init_roles = __esm(() => {
17612
- init_schema();
17637
+ var init_roles2 = __esm(() => {
17638
+ init_log_roles();
17613
17639
  GRANTED_ROLES = ["developer", "code-reviewer", "security", "controller"];
17614
17640
  ROLE_TOOL_GRANTS = {
17615
17641
  developer: [
@@ -17628,7 +17654,7 @@ var init_roles = __esm(() => {
17628
17654
  };
17629
17655
  VINAYA_TOOL_GRANTS = { roles: GRANTED_ROLES, grants: ROLE_TOOL_GRANTS };
17630
17656
  VINAYA_BROKER_ROLES = {
17631
- recognizedRoles: ROLE_VALUES,
17657
+ recognizedRoles: VINAYA_LOG_ROLE_NAMES,
17632
17658
  workerRoles: ["developer"],
17633
17659
  surfaceOwner: "the Planner"
17634
17660
  };
@@ -17907,7 +17933,7 @@ function vinayaRouterPolicies() {
17907
17933
  var init_vinaya_policies = __esm(() => {
17908
17934
  init_launch_records();
17909
17935
  init_protected_paths2();
17910
- init_roles();
17936
+ init_roles2();
17911
17937
  init_scratch_names();
17912
17938
  });
17913
17939
 
@@ -35172,6 +35198,73 @@ var init_premise_reassert_logic = __esm(() => {
35172
35198
  init_ops();
35173
35199
  });
35174
35200
 
35201
+ // ../../harness/processes/vinaya-strict/loops/dev-review/v2/git-read-memo.ts
35202
+ import { resolve as resolve9 } from "node:path";
35203
+ function gitSubcommand(args) {
35204
+ for (let i = 0;i < args.length; i++) {
35205
+ const arg = args[i];
35206
+ if (arg === "-C" || arg === "-c" || arg === "--git-dir" || arg === "--work-tree") {
35207
+ i++;
35208
+ continue;
35209
+ }
35210
+ if (arg.startsWith("-"))
35211
+ continue;
35212
+ return arg;
35213
+ }
35214
+ return;
35215
+ }
35216
+ function gitReadKey(cwd, args) {
35217
+ return [resolve9(cwd ?? process.cwd()), ...args].join("\x00");
35218
+ }
35219
+ function gitReadMemoServing() {
35220
+ return memoEnabled && state.scopes > 0 && state.turns === 0;
35221
+ }
35222
+ function clearGitReadMemo(reason = "cleared") {
35223
+ state.entries.clear();
35224
+ notify({ kind: "clear", reason });
35225
+ }
35226
+ function runGit(cwd, args, run) {
35227
+ const sub = gitSubcommand(args);
35228
+ const key = gitReadKey(cwd, args);
35229
+ const memoizable = sub !== undefined && MEMOIZED.has(sub);
35230
+ if (memoizable && gitReadMemoServing()) {
35231
+ const kept = state.entries.get(key);
35232
+ if (kept !== undefined) {
35233
+ notify({ kind: "hit", key });
35234
+ return kept;
35235
+ }
35236
+ let value;
35237
+ try {
35238
+ value = run();
35239
+ } catch (error) {
35240
+ notify({ kind: "spawn", key, memoizable: true, served: false });
35241
+ throw error;
35242
+ }
35243
+ notify({ kind: "spawn", key, memoizable: true, served: true });
35244
+ if (gitReadMemoServing())
35245
+ state.entries.set(key, value);
35246
+ return value;
35247
+ }
35248
+ notify({ kind: "spawn", key, memoizable, served: false });
35249
+ if (memoizable || sub !== undefined && READ_ONLY_UNKEPT.has(sub))
35250
+ return run();
35251
+ try {
35252
+ return run();
35253
+ } finally {
35254
+ clearGitReadMemo(`git ${sub ?? "(none)"}`);
35255
+ }
35256
+ }
35257
+ var MEMOIZED, READ_ONLY_UNKEPT, state, memoEnabled = true, notify = (event) => {
35258
+ for (const listener of state.listeners)
35259
+ listener(event);
35260
+ }, wrapped;
35261
+ var init_git_read_memo = __esm(() => {
35262
+ MEMOIZED = new Set(["rev-parse", "merge-base", "show-ref", "for-each-ref", "rev-list"]);
35263
+ READ_ONLY_UNKEPT = new Set(["ls-remote", "status", "diff", "ls-files", "log", "show", "cat-file", "merge-tree"]);
35264
+ state = { scopes: 0, turns: 0, entries: new Map, listeners: new Set };
35265
+ wrapped = new WeakMap;
35266
+ });
35267
+
35175
35268
  // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/gate-reading.ts
35176
35269
  import { execFileSync as execFileSync26 } from "node:child_process";
35177
35270
  import { existsSync as existsSync42 } from "node:fs";
@@ -35189,11 +35282,12 @@ function sleepSyncMs4(ms) {
35189
35282
  }
35190
35283
  function sh2(cmd, args, options = {}) {
35191
35284
  if (cmd !== "gh") {
35192
- return execFileSync26(cmd, args, {
35285
+ const run = () => execFileSync26(cmd, args, {
35193
35286
  encoding: "utf8",
35194
35287
  stdio: ["ignore", "pipe", "pipe"],
35195
35288
  maxBuffer: MAX_GH_OUTPUT_BYTES2
35196
35289
  }).trim();
35290
+ return cmd === "git" ? runGit(undefined, args, run) : run();
35197
35291
  }
35198
35292
  const attempts = options.attempts ?? shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_ATTEMPTS", 3);
35199
35293
  const backoffMs = shEnvOverride("VINAYA_DEV_REVIEW_LOOP_GH_RETRY_BACKOFF_MS", 500);
@@ -35464,7 +35558,9 @@ function fetchConflictingFiles(baseBranch, headBranch) {
35464
35558
  execFileSync26("git", ["fetch", "--quiet", "origin", baseBranch, headBranch], {
35465
35559
  stdio: ["ignore", "ignore", "ignore"]
35466
35560
  });
35467
- } catch {}
35561
+ } catch {} finally {
35562
+ clearGitReadMemo("git fetch");
35563
+ }
35468
35564
  try {
35469
35565
  execFileSync26("git", ["merge-tree", "--write-tree", `origin/${baseBranch}`, `origin/${headBranch}`], {
35470
35566
  encoding: "utf8",
@@ -35518,6 +35614,7 @@ var MAX_GH_OUTPUT_BYTES2, NON_CI_WORKFLOW_PATHS, NON_CI_WORKFLOW_NAMES, FAILED_W
35518
35614
  var init_gate_reading = __esm(() => {
35519
35615
  init_premise_reassert_logic();
35520
35616
  init_round_assess();
35617
+ init_git_read_memo();
35521
35618
  MAX_GH_OUTPUT_BYTES2 = 64 * 1024 * 1024;
35522
35619
  NON_CI_WORKFLOW_PATHS = [
35523
35620
  REVIEW_WORKFLOW_PATH,
@@ -38723,7 +38820,7 @@ import { tmpdir as tmpdir9 } from "node:os";
38723
38820
  import { rmSync as rmSync14 } from "node:fs";
38724
38821
  import { z as z11 } from "zod";
38725
38822
  import { existsSync as existsSync45 } from "node:fs";
38726
- import { resolve as resolve9 } from "node:path";
38823
+ import { resolve as resolve10 } from "node:path";
38727
38824
  import { spawnSync as spawnSync3 } from "node:child_process";
38728
38825
  import { readFileSync as readFileSync50 } from "node:fs";
38729
38826
  function defaultRepoRoot() {
@@ -38734,8 +38831,10 @@ function defaultGitRevParseOriginMain() {
38734
38831
  }
38735
38832
  function defaultGitIsAncestor(ancestor, descendant) {
38736
38833
  try {
38737
- execFileSync29("git", ["merge-base", "--is-ancestor", ancestor, descendant], {
38738
- stdio: ["ignore", "ignore", "ignore"]
38834
+ const args = ["merge-base", "--is-ancestor", ancestor, descendant];
38835
+ runGit(undefined, args, () => {
38836
+ execFileSync29("git", args, { stdio: ["ignore", "ignore", "ignore"] });
38837
+ return "";
38739
38838
  });
38740
38839
  return true;
38741
38840
  } catch (err) {
@@ -38745,12 +38844,14 @@ function defaultGitIsAncestor(ancestor, descendant) {
38745
38844
  }
38746
38845
  }
38747
38846
  function defaultGitMergeBase(head) {
38748
- return resolveMergeBase(head);
38847
+ return resolveMergeBase(head).finally(() => clearGitReadMemo("merge-base resolution"));
38749
38848
  }
38750
38849
  function defaultGitFetch(sha) {
38751
38850
  try {
38752
38851
  execFileSync29("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
38753
- } catch {}
38852
+ } catch {} finally {
38853
+ clearGitReadMemo("git fetch");
38854
+ }
38754
38855
  }
38755
38856
  function defaultGitDiffShortstat(base, head) {
38756
38857
  try {
@@ -38826,6 +38927,7 @@ function defaultRunSecurityScanSubprocess(command, scanTargetDir) {
38826
38927
  return { ok: true, output: combined };
38827
38928
  return { ok: false, reason: e.message };
38828
38929
  } finally {
38930
+ clearGitReadMemo("security scan");
38829
38931
  try {
38830
38932
  rmSync14(sandbox, { recursive: true, force: true });
38831
38933
  } catch {}
@@ -38842,7 +38944,11 @@ function defaultResolveTaskSurface(task) {
38842
38944
  }
38843
38945
  }
38844
38946
  function defaultPatchIdOf(sha) {
38845
- return patchIdAt("main", sha);
38947
+ try {
38948
+ return patchIdAt("main", sha);
38949
+ } finally {
38950
+ clearGitReadMemo("patch-id fetch");
38951
+ }
38846
38952
  }
38847
38953
  function assertValidLoopEvent(e) {
38848
38954
  const parsed = DevReviewLoopEventInputSchema.safeParse(e);
@@ -38885,11 +38991,12 @@ function defaultGitWorktreeUntrackedPaths(worktreePath) {
38885
38991
  }
38886
38992
  }
38887
38993
  function gitOk(worktreePath, args) {
38994
+ const full = ["-C", worktreePath, ...args];
38888
38995
  try {
38889
- return execFileSync29("git", ["-C", worktreePath, ...args], {
38996
+ return runGit(undefined, full, () => execFileSync29("git", full, {
38890
38997
  encoding: "utf8",
38891
38998
  stdio: ["ignore", "pipe", "pipe"]
38892
- }).trim();
38999
+ }).trim());
38893
39000
  } catch {
38894
39001
  return null;
38895
39002
  }
@@ -38994,12 +39101,12 @@ function defaultClassifyAgainstDefaultTip(worktreePath, head, tip, paths, remote
38994
39101
  function rebaseInProgress(worktreePath) {
38995
39102
  return ["rebase-merge", "rebase-apply"].some((name) => {
38996
39103
  const path = gitOk(worktreePath, ["rev-parse", "--git-path", name]);
38997
- return path !== null && existsSync45(resolve9(worktreePath, path));
39104
+ return path !== null && existsSync45(resolve10(worktreePath, path));
38998
39105
  });
38999
39106
  }
39000
39107
  function mergeInProgress2(worktreePath) {
39001
39108
  const path = gitOk(worktreePath, ["rev-parse", "--git-path", "MERGE_HEAD"]);
39002
- return path !== null && existsSync45(resolve9(worktreePath, path));
39109
+ return path !== null && existsSync45(resolve10(worktreePath, path));
39003
39110
  }
39004
39111
  function defaultMergeDefaultTip(worktreePath, tip, remoteUrl) {
39005
39112
  const refuse = (reason, conflictFiles = []) => ({
@@ -39024,6 +39131,7 @@ function defaultMergeDefaultTip(worktreePath, tip, remoteUrl) {
39024
39131
  env: { ...process.env, GIT_EDITOR: "true" },
39025
39132
  stdio: ["ignore", "pipe", "pipe"]
39026
39133
  });
39134
+ clearGitReadMemo("git merge");
39027
39135
  if (!merged.error && merged.status === 0 && !mergeInProgress2(worktreePath)) {
39028
39136
  const head = gitOk(worktreePath, ["rev-parse", "HEAD"]);
39029
39137
  if (head)
@@ -39071,6 +39179,7 @@ function defaultRebaseOntoDefaultTip(worktreePath, tip, remoteUrl) {
39071
39179
  env: { ...process.env, GIT_EDITOR: "true" },
39072
39180
  stdio: ["ignore", "pipe", "pipe"]
39073
39181
  });
39182
+ clearGitReadMemo("git rebase");
39074
39183
  if (!rebased.error && rebased.status === 0 && !rebaseInProgress(worktreePath)) {
39075
39184
  const head = gitOk(worktreePath, ["rev-parse", "HEAD"]);
39076
39185
  if (head)
@@ -39096,7 +39205,11 @@ function ownChangesRangeBase(worktreePath, pushedBase) {
39096
39205
  if (pushedBase === null)
39097
39206
  return null;
39098
39207
  try {
39099
- execFileSync29("git", ["-C", worktreePath, "merge-base", "--is-ancestor", pushedBase, "HEAD"], { stdio: "ignore" });
39208
+ const args = ["-C", worktreePath, "merge-base", "--is-ancestor", pushedBase, "HEAD"];
39209
+ runGit(undefined, args, () => {
39210
+ execFileSync29("git", args, { stdio: "ignore" });
39211
+ return "";
39212
+ });
39100
39213
  return pushedBase;
39101
39214
  } catch (err) {
39102
39215
  if (err.status !== 1)
@@ -39158,6 +39271,7 @@ function traceHasRefusingHook(trace, names) {
39158
39271
  var SECURITY_SCAN_TIMEOUT_MS = 120000, SECURITY_SCAN_MAX_BUFFER_BYTES, DevReviewLoopEventInputSchema;
39159
39272
  var init_git_defaults = __esm(() => {
39160
39273
  init_gate_reading();
39274
+ init_git_read_memo();
39161
39275
  init_pr_report_engine();
39162
39276
  init_worker_boundary();
39163
39277
  init_issue_validation();
@@ -39618,6 +39732,7 @@ function defaultBuildVendoredCliIfMissing(worktreePath) {
39618
39732
  encoding: "utf8",
39619
39733
  stdio: ["ignore", "pipe", "pipe"]
39620
39734
  });
39735
+ clearGitReadMemo("vendored CLI build");
39621
39736
  if (result.error || result.status !== 0) {
39622
39737
  const output = `${result.stdout ?? ""}
39623
39738
  ${result.stderr ?? ""}`.trim();
@@ -39643,6 +39758,7 @@ function defaultInstallWorktreeDependencies(worktreePath) {
39643
39758
  stdio: ["ignore", "pipe", "pipe"],
39644
39759
  timeout: 10 * 60 * 1000
39645
39760
  });
39761
+ clearGitReadMemo("dependency install");
39646
39762
  if (result.error || result.status !== 0) {
39647
39763
  const output = `${result.stdout ?? ""}
39648
39764
  ${result.stderr ?? ""}`.trim().split(`
@@ -39677,6 +39793,7 @@ ${"stderr" in err ? String(err.stderr ?? "") : ""}`.trim() : String(err);
39677
39793
  }
39678
39794
  throw err;
39679
39795
  } finally {
39796
+ clearGitReadMemo("git commit");
39680
39797
  rmSync16(traceDir, { recursive: true, force: true });
39681
39798
  }
39682
39799
  return { ok: true, sha: sh2("git", ["-C", worktreePath, "rev-parse", "HEAD"]).trim() };
@@ -39722,6 +39839,7 @@ ${String(raw.stderr ?? "")}`.trim();
39722
39839
  const detail = boundedPushOutput(output || (err instanceof Error ? err.message : String(err)), "tail");
39723
39840
  throw new Error(`${exit}: ${detail || "no captured output"}`);
39724
39841
  } finally {
39842
+ clearGitReadMemo("git push");
39725
39843
  rmSync16(traceDir, { recursive: true, force: true });
39726
39844
  }
39727
39845
  }
@@ -39973,6 +40091,7 @@ var init_developer_defaults = __esm(async () => {
39973
40091
  init_live_developer_context();
39974
40092
  init_worker_boundary();
39975
40093
  init_gate_reading();
40094
+ init_git_read_memo();
39976
40095
  init_git_defaults();
39977
40096
  init_driver_tool_guard();
39978
40097
  init_live_developer_context();
@@ -40587,6 +40706,7 @@ function liveRunEnv(callerEnv = process.env) {
40587
40706
  function runFile(file, args, opts) {
40588
40707
  return new Promise((resolve, reject) => {
40589
40708
  execFile11(file, [...args], { cwd: opts.cwd, env: opts.env, timeout: opts.timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (err, _stdout, stderr) => {
40709
+ clearGitReadMemo(`${file} ${args[0] ?? ""}`);
40590
40710
  if (err === null)
40591
40711
  resolve();
40592
40712
  else
@@ -40607,6 +40727,7 @@ async function prepareRealLiveCheckout(repoRoot, head, opts = {}) {
40607
40727
  try {
40608
40728
  execFileSync33("git", ["-C", repoRoot, "worktree", "prune"], { stdio: "ignore" });
40609
40729
  } catch {}
40730
+ clearGitReadMemo("live checkout removed");
40610
40731
  };
40611
40732
  try {
40612
40733
  await runFile("git", ["-C", repoRoot, "-c", "core.hooksPath=/dev/null", "worktree", "add", "--detach", tree, head], {
@@ -40724,6 +40845,7 @@ var LIVE_RUN_TIMEOUT_MS, MAX_KEPT_OUTPUT_CHARS, REAL_SIGN_IN_SOURCES, LIVE_SIGN_
40724
40845
  if (settled)
40725
40846
  return;
40726
40847
  settled = true;
40848
+ clearGitReadMemo("live command");
40727
40849
  clearTimeout(timer);
40728
40850
  if (grace !== undefined)
40729
40851
  clearTimeout(grace);
@@ -40765,6 +40887,7 @@ var init_live_check = __esm(() => {
40765
40887
  init_runner();
40766
40888
  init_dispatch();
40767
40889
  init_pr_facts();
40890
+ init_git_read_memo();
40768
40891
  init_worker_boundary();
40769
40892
  LIVE_RUN_TIMEOUT_MS = 20 * 60000;
40770
40893
  MAX_KEPT_OUTPUT_CHARS = 256 * 1024;
@@ -41338,7 +41461,7 @@ var init_task_sweep = __esm(async () => {
41338
41461
  });
41339
41462
 
41340
41463
  // ../../harness/processes/vinaya-strict/loops/dev-review/standalone/dev-review-loop/driver-helpers.ts
41341
- import { resolve as resolve10 } from "node:path";
41464
+ import { resolve as resolve11 } from "node:path";
41342
41465
  import { join as join54 } from "node:path";
41343
41466
  import { readFileSync as readFileSync54 } from "node:fs";
41344
41467
  import { existsSync as existsSync48 } from "node:fs";
@@ -41424,7 +41547,7 @@ async function setStandaloneLogIdentity(env = process.env, cliRoot = packageRoot
41424
41547
  }
41425
41548
  env.VINAYA_RUNNER_ID = "standalone";
41426
41549
  env.VINAYA_RUNNER_VERSION = pkg.version;
41427
- const checkout = resolve10(cliRoot, "../..");
41550
+ const checkout = resolve11(cliRoot, "../..");
41428
41551
  const loaderPath = join54(checkout, "harness", "kernel", "dev-process-socket", "loader", "load-process.ts");
41429
41552
  const processFolder = join54(checkout, PROCESS_FOLDER_IN_CHECKOUT);
41430
41553
  if (!existsSync48(join54(checkout, ".git")) || !existsSync48(loaderPath) || !existsSync48(processFolder))
@@ -43506,7 +43629,7 @@ function verdictLogRole(role) {
43506
43629
  }
43507
43630
  function reviewerEntries(state, verdicts) {
43508
43631
  const held = new Map(verdicts.map((v) => [verdictLogRole(v.role), v]));
43509
- const isRole = (value) => ROLE_VALUES.includes(value);
43632
+ const isRole = (value) => VINAYA_LOG_ROLE_NAMES.includes(value);
43510
43633
  const roles = [...new Set([...state.config.reviewers.filter(isRole), ...held.keys()])];
43511
43634
  return roles.map((role) => {
43512
43635
  const v = held.get(role);
@@ -43997,6 +44120,7 @@ function assessRound(state, observations, clock) {
43997
44120
  var VOLATILE_TOKENS;
43998
44121
  var init_assess_round = __esm(() => {
43999
44122
  init_schema();
44123
+ init_log_roles();
44000
44124
  init_review_status();
44001
44125
  init_task_phase_history();
44002
44126
  init_types();