@akagilnc/pi-workflow-roles 0.1.1893 → 0.1.1941

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.
@@ -147,6 +147,18 @@ function validateRuntimeReviewerReceipt(output) {
147
147
  throw new Error("Successful Reviewer outcome lacks report");
148
148
  if (status === "failed" && report !== void 0) throw new Error("Failed Reviewer outcome cannot bind a report");
149
149
  }
150
+ const specDisposition = read(output, "specDisposition");
151
+ if (specDisposition === "launched") {
152
+ if (expectedAxes.length !== 2 || expectedAxes[0] !== "standards" || expectedAxes[1] !== "spec") {
153
+ throw new Error("Reviewer specDisposition launched requires Standards+Spec accepted legs");
154
+ }
155
+ } else if (specDisposition === "skipped-missing") {
156
+ if (expectedAxes.length !== 1 || expectedAxes[0] !== "standards") {
157
+ throw new Error("Reviewer specDisposition skipped-missing requires Standards-only accepted legs");
158
+ }
159
+ } else if (specDisposition !== void 0) {
160
+ throw new Error("Invalid Reviewer specDisposition");
161
+ }
150
162
  }
151
163
  return output;
152
164
  }
@@ -14873,6 +14885,69 @@ var init_sitian_role_run_coordinates = __esm({
14873
14885
  }
14874
14886
  });
14875
14887
 
14888
+ // src/ticket-frontmatter.ts
14889
+ function parseTicketNumberFrontmatter(bytes) {
14890
+ let text;
14891
+ if (typeof bytes === "string") {
14892
+ text = bytes;
14893
+ } else {
14894
+ try {
14895
+ text = exactUtf8(bytes, "ticket face");
14896
+ } catch {
14897
+ return void 0;
14898
+ }
14899
+ }
14900
+ let cursor;
14901
+ if (text.startsWith("---\n")) {
14902
+ cursor = 4;
14903
+ } else if (text.startsWith("---\r\n")) {
14904
+ cursor = 5;
14905
+ } else {
14906
+ return void 0;
14907
+ }
14908
+ const fmLines = [];
14909
+ let closed = false;
14910
+ while (cursor < text.length) {
14911
+ const nl = text.indexOf("\n", cursor);
14912
+ const lineEnd = nl === -1 ? text.length : nl;
14913
+ let line2 = text.slice(cursor, lineEnd);
14914
+ if (line2.endsWith("\r")) line2 = line2.slice(0, -1);
14915
+ if (line2 === "---") {
14916
+ closed = true;
14917
+ break;
14918
+ }
14919
+ fmLines.push(line2);
14920
+ if (nl === -1) break;
14921
+ cursor = nl + 1;
14922
+ }
14923
+ if (!closed) return void 0;
14924
+ let found;
14925
+ for (const line2 of fmLines) {
14926
+ const match = /^[ \t]*ticketNumber[ \t]*:[ \t]*(\d+)[ \t]*$/.exec(line2);
14927
+ if (match === null) continue;
14928
+ const value = Number(match[1]);
14929
+ if (!Number.isInteger(value) || value < 1) return void 0;
14930
+ if (found !== void 0 && found !== value) return void 0;
14931
+ found = value;
14932
+ }
14933
+ return found;
14934
+ }
14935
+ function resolveTicketNumberFromAttachmentBodies(bodies) {
14936
+ const found = /* @__PURE__ */ new Set();
14937
+ for (const body of bodies) {
14938
+ const value = parseTicketNumberFrontmatter(body);
14939
+ if (value !== void 0) found.add(value);
14940
+ }
14941
+ if (found.size !== 1) return void 0;
14942
+ return found.values().next().value;
14943
+ }
14944
+ var init_ticket_frontmatter = __esm({
14945
+ "src/ticket-frontmatter.ts"() {
14946
+ "use strict";
14947
+ init_exact_utf8();
14948
+ }
14949
+ });
14950
+
14876
14951
  // src/audit-escalation.ts
14877
14952
  function isAuditEscalationResult(value) {
14878
14953
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -15338,7 +15413,9 @@ async function writeRoleInvocationLedger(source, role) {
15338
15413
  projectRoot: source.projectRoot,
15339
15414
  runDirectory: source.runDirectory,
15340
15415
  sessionDirectory: source.sessionDirectory,
15341
- sessionFile: source.sessionFile
15416
+ sessionFile: source.sessionFile,
15417
+ ...source.correlationId === void 0 ? {} : { correlationId: source.correlationId },
15418
+ ...source.ticketNumber === void 0 ? {} : { ticketNumber: source.ticketNumber }
15342
15419
  };
15343
15420
  await writeFile2(
15344
15421
  join5(source.runDirectory, "invocation.json"),
@@ -15399,6 +15476,17 @@ function requireOptionPath(flag, value) {
15399
15476
  }
15400
15477
  return value;
15401
15478
  }
15479
+ function requireAuthorityRef(value) {
15480
+ if (value === void 0 || value.trim() === "") {
15481
+ throw new CliUsageError("--authority-ref requires a nonempty durable reference");
15482
+ }
15483
+ if (/\s/.test(value)) {
15484
+ throw new CliUsageError(
15485
+ "--authority-ref requires a durable reference, not inline Spec prose"
15486
+ );
15487
+ }
15488
+ return value;
15489
+ }
15402
15490
  function parseJudgeArgv(args) {
15403
15491
  const attachmentPaths = [];
15404
15492
  let project;
@@ -15568,13 +15656,37 @@ async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
15568
15656
  const frozenPath = join5(destinationDir, name);
15569
15657
  await writeFile2(frozenPath, bytes);
15570
15658
  return {
15571
- provenancePath: absolute,
15572
- frozenPath,
15573
- byteLength: bytes.byteLength,
15574
- sha256: sha256Hex(bytes),
15575
- mediaKind: "regular-file"
15659
+ attachment: {
15660
+ provenancePath: absolute,
15661
+ frozenPath,
15662
+ byteLength: bytes.byteLength,
15663
+ sha256: sha256Hex(bytes),
15664
+ mediaKind: "regular-file"
15665
+ },
15666
+ body: bytes
15576
15667
  };
15577
15668
  }
15669
+ async function freezeAttachmentsWithTicketNumber(attachmentPaths, attachmentsDirectory) {
15670
+ const attachments = [];
15671
+ const bodies = [];
15672
+ for (let i = 0; i < attachmentPaths.length; i += 1) {
15673
+ const frozen = await freezeRegularFileAttachment(
15674
+ attachmentPaths[i],
15675
+ attachmentsDirectory,
15676
+ i
15677
+ );
15678
+ attachments.push(frozen.attachment);
15679
+ bodies.push(frozen.body);
15680
+ }
15681
+ const ticketNumber = resolveTicketNumberFromAttachmentBodies(bodies);
15682
+ return {
15683
+ attachments,
15684
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
15685
+ };
15686
+ }
15687
+ function ticketAdmissionFields(ticketNumber) {
15688
+ return ticketNumber === void 0 ? {} : { ticketNumber };
15689
+ }
15578
15690
  async function admitJudgeInvocation(options) {
15579
15691
  if (options.project !== void 0) {
15580
15692
  requireOptionPath("--project", options.project);
@@ -15585,16 +15697,11 @@ async function admitJudgeInvocation(options) {
15585
15697
  const attachmentsDirectory = join5(runDirectory, "attachments");
15586
15698
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15587
15699
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15588
- const attachments = [];
15589
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15590
- attachments.push(
15591
- await freezeRegularFileAttachment(
15592
- options.attachmentPaths[i],
15593
- attachmentsDirectory,
15594
- i
15595
- )
15596
- );
15597
- }
15700
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15701
+ options.attachmentPaths,
15702
+ attachmentsDirectory
15703
+ );
15704
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15598
15705
  const instruction = options.instruction;
15599
15706
  const instructionEmpty = instruction.trim() === "";
15600
15707
  const admitted = {
@@ -15605,6 +15712,7 @@ async function admitJudgeInvocation(options) {
15605
15712
  runDirectory,
15606
15713
  sessionDirectory,
15607
15714
  sessionFile,
15715
+ ...ticketFields,
15608
15716
  instruction,
15609
15717
  instructionEmpty,
15610
15718
  attachments: attachments.map((a) => ({
@@ -15630,7 +15738,8 @@ async function admitJudgeInvocation(options) {
15630
15738
  runDirectory,
15631
15739
  sessionDirectory,
15632
15740
  sessionFile,
15633
- admittedRequestPath
15741
+ admittedRequestPath,
15742
+ ...ticketFields
15634
15743
  };
15635
15744
  }
15636
15745
  function buildJudgeTransportPrompt(admitted) {
@@ -15668,16 +15777,11 @@ async function admitCoderInvocation(options) {
15668
15777
  const attachmentsDirectory = join5(runDirectory, "attachments");
15669
15778
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15670
15779
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15671
- const attachments = [];
15672
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15673
- attachments.push(
15674
- await freezeRegularFileAttachment(
15675
- options.attachmentPaths[i],
15676
- attachmentsDirectory,
15677
- i
15678
- )
15679
- );
15680
- }
15780
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15781
+ options.attachmentPaths,
15782
+ attachmentsDirectory
15783
+ );
15784
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15681
15785
  const taskPath = join5(runDirectory, "task.md");
15682
15786
  await writeFile2(taskPath, instruction, "utf8");
15683
15787
  const admitted = {
@@ -15689,6 +15793,7 @@ async function admitCoderInvocation(options) {
15689
15793
  runDirectory,
15690
15794
  sessionDirectory,
15691
15795
  sessionFile,
15796
+ ...ticketFields,
15692
15797
  instruction,
15693
15798
  instructionEmpty: false,
15694
15799
  taskPath,
@@ -15717,7 +15822,8 @@ async function admitCoderInvocation(options) {
15717
15822
  sessionDirectory,
15718
15823
  sessionFile,
15719
15824
  admittedRequestPath,
15720
- taskPath
15825
+ taskPath,
15826
+ ...ticketFields
15721
15827
  };
15722
15828
  }
15723
15829
  function buildCoderTransportPrompt(admitted) {
@@ -15744,29 +15850,12 @@ async function admitFixerInvocation(options) {
15744
15850
  if (options.phase !== "plan" && options.phase !== "apply") {
15745
15851
  throw new CliUsageError("fixer phase must be plan or apply");
15746
15852
  }
15747
- const projectRoot = resolve4(options.project ?? options.cwd);
15748
- const runId = (options.createRunId ?? uuidv7)();
15749
- const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
15750
- const attachmentsDirectory = join5(runDirectory, "attachments");
15751
- ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15752
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15753
- const attachments = [];
15754
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
15755
- attachments.push(
15756
- await freezeRegularFileAttachment(
15757
- options.attachmentPaths[i],
15758
- attachmentsDirectory,
15759
- i
15760
- )
15761
- );
15762
- }
15763
15853
  let prerequisites = Object.freeze([]);
15764
- let prerequisitesPath;
15854
+ let prerequisitesSource;
15765
15855
  if (options.prerequisitesPath !== void 0) {
15766
15856
  const absolutePrereq = isAbsolute3(options.prerequisitesPath) ? options.prerequisitesPath : resolve4(options.prerequisitesPath);
15767
- let source;
15768
15857
  try {
15769
- source = await readFile4(absolutePrereq, "utf8");
15858
+ prerequisitesSource = await readFile4(absolutePrereq, "utf8");
15770
15859
  } catch (error) {
15771
15860
  throw new CliUsageError(
15772
15861
  `fixer prerequisites path is unreadable: ${options.prerequisitesPath}`,
@@ -15774,13 +15863,27 @@ async function admitFixerInvocation(options) {
15774
15863
  );
15775
15864
  }
15776
15865
  try {
15777
- prerequisites = parseFixerPrerequisites(source);
15866
+ prerequisites = parseFixerPrerequisites(prerequisitesSource);
15778
15867
  } catch (error) {
15779
15868
  if (error instanceof FixerPacketValidationError) {
15780
15869
  throw new CliUsageError(error.message, { cause: error });
15781
15870
  }
15782
15871
  throw error;
15783
15872
  }
15873
+ }
15874
+ const projectRoot = resolve4(options.project ?? options.cwd);
15875
+ const runId = (options.createRunId ?? uuidv7)();
15876
+ const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "fixer", home: options.home });
15877
+ const attachmentsDirectory = join5(runDirectory, "attachments");
15878
+ ensureRealDirectoryTree(ledgerHome, sessionDirectory);
15879
+ ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
15880
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
15881
+ options.attachmentPaths,
15882
+ attachmentsDirectory
15883
+ );
15884
+ const ticketFields = ticketAdmissionFields(ticketNumber);
15885
+ let prerequisitesPath;
15886
+ if (prerequisitesSource !== void 0) {
15784
15887
  prerequisitesPath = join5(runDirectory, "prerequisites.json");
15785
15888
  await writeFile2(
15786
15889
  prerequisitesPath,
@@ -15800,6 +15903,7 @@ async function admitFixerInvocation(options) {
15800
15903
  runDirectory,
15801
15904
  sessionDirectory,
15802
15905
  sessionFile,
15906
+ ...ticketFields,
15803
15907
  instruction,
15804
15908
  instructionEmpty: false,
15805
15909
  packetPath,
@@ -15835,7 +15939,8 @@ async function admitFixerInvocation(options) {
15835
15939
  admittedRequestPath,
15836
15940
  packetPath,
15837
15941
  ...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
15838
- prerequisites
15942
+ prerequisites,
15943
+ ...ticketFields
15839
15944
  };
15840
15945
  }
15841
15946
  function buildFixerTransportPrompt(admitted) {
@@ -16003,34 +16108,32 @@ async function admitCollectorInvocation(options) {
16003
16108
  } else {
16004
16109
  repository = resolveGitHubRemoteRepository(projectRoot);
16005
16110
  }
16006
- const runId = (options.createRunId ?? uuidv7)();
16007
- const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
16008
- const attachmentsDirectory = join5(runDirectory, "attachments");
16009
- ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16010
- ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16011
- const attachments = [];
16012
- const attachmentPaths = options.attachmentPaths ?? [];
16013
- for (let i = 0; i < attachmentPaths.length; i += 1) {
16014
- attachments.push(
16015
- await freezeRegularFileAttachment(
16016
- attachmentPaths[i],
16017
- attachmentsDirectory,
16018
- i
16019
- )
16020
- );
16021
- }
16022
16111
  let manifest = emptyCollectorManifest();
16023
- let requestManifestPath;
16112
+ let manifestCanonicalJson;
16024
16113
  if (options.requestManifestPath !== void 0) {
16025
16114
  try {
16026
16115
  manifest = await loadCollectorManifest(options.requestManifestPath);
16116
+ manifestCanonicalJson = manifest.canonicalJson;
16027
16117
  } catch (error) {
16028
16118
  throw new CliUsageError(error instanceof Error ? error.message : String(error), { cause: error });
16029
16119
  }
16030
- requestManifestPath = join5(runDirectory, "request-manifest.json");
16031
- await writeFile2(requestManifestPath, manifest.canonicalJson, "utf8");
16032
16120
  }
16033
16121
  const manifestDigest = manifest.digest;
16122
+ const runId = (options.createRunId ?? uuidv7)();
16123
+ const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "collector", home: options.home });
16124
+ const attachmentsDirectory = join5(runDirectory, "attachments");
16125
+ ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16126
+ ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16127
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16128
+ options.attachmentPaths ?? [],
16129
+ attachmentsDirectory
16130
+ );
16131
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16132
+ let requestManifestPath;
16133
+ if (manifestCanonicalJson !== void 0) {
16134
+ requestManifestPath = join5(runDirectory, "request-manifest.json");
16135
+ await writeFile2(requestManifestPath, manifestCanonicalJson, "utf8");
16136
+ }
16034
16137
  const instruction = options.instruction ?? "";
16035
16138
  const instructionEmpty = instruction.trim() === "";
16036
16139
  const admitted = {
@@ -16041,6 +16144,7 @@ async function admitCollectorInvocation(options) {
16041
16144
  runDirectory,
16042
16145
  sessionDirectory,
16043
16146
  sessionFile,
16147
+ ...ticketFields,
16044
16148
  instruction,
16045
16149
  instructionEmpty,
16046
16150
  prNumber,
@@ -16079,7 +16183,8 @@ async function admitCollectorInvocation(options) {
16079
16183
  prNumber,
16080
16184
  repository,
16081
16185
  ...requestManifestPath === void 0 ? {} : { requestManifestPath },
16082
- manifestDigest
16186
+ manifestDigest,
16187
+ ...ticketFields
16083
16188
  };
16084
16189
  }
16085
16190
  function buildCollectorTransportPrompt(_admitted) {
@@ -16276,17 +16381,11 @@ async function admitDoctorInvocation(options) {
16276
16381
  const attachmentsDirectory = join5(runDirectory, "attachments");
16277
16382
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16278
16383
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16279
- const attachments = [];
16280
- const attachmentPaths = options.attachmentPaths ?? [];
16281
- for (let i = 0; i < attachmentPaths.length; i += 1) {
16282
- attachments.push(
16283
- await freezeRegularFileAttachment(
16284
- attachmentPaths[i],
16285
- attachmentsDirectory,
16286
- i
16287
- )
16288
- );
16289
- }
16384
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16385
+ options.attachmentPaths ?? [],
16386
+ attachmentsDirectory
16387
+ );
16388
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16290
16389
  const instruction = options.instruction ?? "";
16291
16390
  const instructionEmpty = instruction.trim() === "";
16292
16391
  const admitted = {
@@ -16297,6 +16396,7 @@ async function admitDoctorInvocation(options) {
16297
16396
  runDirectory,
16298
16397
  sessionDirectory,
16299
16398
  sessionFile,
16399
+ ...ticketFields,
16300
16400
  instruction,
16301
16401
  instructionEmpty,
16302
16402
  issueNumber: options.issueNumber,
@@ -16332,7 +16432,8 @@ async function admitDoctorInvocation(options) {
16332
16432
  admittedRequestPath,
16333
16433
  issueNumber: options.issueNumber,
16334
16434
  caseRunsPath,
16335
- caseIdentity: caseIdentity2
16435
+ caseIdentity: caseIdentity2,
16436
+ ...ticketFields
16336
16437
  };
16337
16438
  }
16338
16439
  function buildDoctorTransportPrompt(admitted) {
@@ -16348,6 +16449,7 @@ function buildDoctorTransportPrompt(admitted) {
16348
16449
  }
16349
16450
  function parseReviewerArgv(args) {
16350
16451
  const attachmentPaths = [];
16452
+ const authorityRefs = [];
16351
16453
  let project;
16352
16454
  let baseRevision;
16353
16455
  const positional = [];
@@ -16374,6 +16476,14 @@ function parseReviewerArgv(args) {
16374
16476
  baseRevision = requireOptionPath("--base", token.slice("--base=".length));
16375
16477
  continue;
16376
16478
  }
16479
+ if (token === "--authority-ref") {
16480
+ authorityRefs.push(requireAuthorityRef(tokens.shift()));
16481
+ continue;
16482
+ }
16483
+ if (token.startsWith("--authority-ref=")) {
16484
+ authorityRefs.push(requireAuthorityRef(token.slice("--authority-ref=".length)));
16485
+ continue;
16486
+ }
16377
16487
  if (token.startsWith("-") && token !== "-") {
16378
16488
  throw new CliUsageError(`unknown reviewer option: ${token}`);
16379
16489
  }
@@ -16386,6 +16496,7 @@ function parseReviewerArgv(args) {
16386
16496
  instruction: positional.join(" "),
16387
16497
  attachmentPaths,
16388
16498
  baseRevision,
16499
+ authorityRefs,
16389
16500
  ...project === void 0 ? {} : { project }
16390
16501
  };
16391
16502
  }
@@ -16396,22 +16507,20 @@ async function admitReviewerInvocation(options) {
16396
16507
  if (options.baseRevision.trim() === "") {
16397
16508
  throw new CliUsageError("--base requires a nonempty revision");
16398
16509
  }
16510
+ const authorityRefs = Object.freeze(
16511
+ (options.authorityRefs ?? []).map((ref) => requireAuthorityRef(ref))
16512
+ );
16399
16513
  const projectRoot = resolve4(options.project ?? options.cwd);
16400
16514
  const runId = (options.createRunId ?? uuidv7)();
16401
16515
  const { ledgerHome, bookKey, runDirectory, sessionDirectory, sessionFile } = roleRunSessionCoordinates({ cwd: projectRoot, runId, role: "reviewer", home: options.home });
16402
16516
  const attachmentsDirectory = join5(runDirectory, "attachments");
16403
16517
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16404
16518
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16405
- const attachments = [];
16406
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
16407
- attachments.push(
16408
- await freezeRegularFileAttachment(
16409
- options.attachmentPaths[i],
16410
- attachmentsDirectory,
16411
- i
16412
- )
16413
- );
16414
- }
16519
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16520
+ options.attachmentPaths,
16521
+ attachmentsDirectory
16522
+ );
16523
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16415
16524
  const instruction = options.instruction;
16416
16525
  const instructionEmpty = instruction.trim() === "";
16417
16526
  const admitted = {
@@ -16422,9 +16531,11 @@ async function admitReviewerInvocation(options) {
16422
16531
  runDirectory,
16423
16532
  sessionDirectory,
16424
16533
  sessionFile,
16534
+ ...ticketFields,
16425
16535
  instruction,
16426
16536
  instructionEmpty,
16427
16537
  baseRevision: options.baseRevision,
16538
+ authorityRefs: [...authorityRefs],
16428
16539
  attachments: attachments.map((a) => ({
16429
16540
  provenancePath: a.provenancePath,
16430
16541
  frozenPath: a.frozenPath,
@@ -16453,7 +16564,9 @@ async function admitReviewerInvocation(options) {
16453
16564
  sessionDirectory,
16454
16565
  sessionFile,
16455
16566
  admittedRequestPath,
16456
- baseRevision: options.baseRevision
16567
+ baseRevision: options.baseRevision,
16568
+ authorityRefs,
16569
+ ...ticketFields
16457
16570
  };
16458
16571
  }
16459
16572
  function buildReviewerTransportPrompt(admitted) {
@@ -16555,16 +16668,11 @@ async function admitMergerInvocation(options) {
16555
16668
  const attachmentsDirectory = join5(runDirectory, "attachments");
16556
16669
  ensureRealDirectoryTree(ledgerHome, sessionDirectory);
16557
16670
  ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
16558
- const attachments = [];
16559
- for (let i = 0; i < options.attachmentPaths.length; i += 1) {
16560
- attachments.push(
16561
- await freezeRegularFileAttachment(
16562
- options.attachmentPaths[i],
16563
- attachmentsDirectory,
16564
- i
16565
- )
16566
- );
16567
- }
16671
+ const { attachments, ticketNumber } = await freezeAttachmentsWithTicketNumber(
16672
+ options.attachmentPaths,
16673
+ attachmentsDirectory
16674
+ );
16675
+ const ticketFields = ticketAdmissionFields(ticketNumber);
16568
16676
  const targetIntent = mergerMaterialFromUtf8(
16569
16677
  `Investigate primary sources for target parent ${derived.targetObjectId}. Do not invent intent.`
16570
16678
  );
@@ -16604,6 +16712,7 @@ async function admitMergerInvocation(options) {
16604
16712
  runDirectory,
16605
16713
  sessionDirectory,
16606
16714
  sessionFile,
16715
+ ...ticketFields,
16607
16716
  instruction,
16608
16717
  instructionEmpty: false,
16609
16718
  mergerInputPath,
@@ -16643,7 +16752,8 @@ async function admitMergerInvocation(options) {
16643
16752
  sessionFile,
16644
16753
  admittedRequestPath,
16645
16754
  mergerInputPath,
16646
- derived: admitted.derived
16755
+ derived: admitted.derived,
16756
+ ...ticketFields
16647
16757
  };
16648
16758
  }
16649
16759
  function buildMergerTransportPrompt(admitted) {
@@ -16666,6 +16776,7 @@ var init_invocation = __esm({
16666
16776
  init_activation_ledger_topology();
16667
16777
  init_activation_ledger_git();
16668
16778
  init_sitian_role_run_coordinates();
16779
+ init_ticket_frontmatter();
16669
16780
  init_doctor_evidence();
16670
16781
  init_collector_config();
16671
16782
  init_fixer_packet();
@@ -16731,7 +16842,7 @@ var init_reviewer_scope_prompt = __esm({
16731
16842
  });
16732
16843
 
16733
16844
  // src/reviewer-construction.ts
16734
- var REVIEWER_CONSTRUCTION_RECIPE, REVIEWER_AXIS_OUTPUT_ADAPTER, REVIEWER_STANDARDS_CONCLUSION_KEYS, REVIEWER_STANDARDS_CONCLUSION_LABELS;
16845
+ var REVIEWER_CONSTRUCTION_RECIPE, REVIEWER_AXIS_OUTPUT_ADAPTER, REVIEWER_VERIFICATION_BOUNDARY, REVIEWER_STANDARDS_CONCLUSION_KEYS, REVIEWER_STANDARDS_CONCLUSION_LABELS;
16735
16846
  var init_reviewer_construction = __esm({
16736
16847
  "src/reviewer-construction.ts"() {
16737
16848
  "use strict";
@@ -16748,6 +16859,14 @@ var init_reviewer_construction = __esm({
16748
16859
  version: 1,
16749
16860
  implementationSha256: sha256Hex("reviewer-axis-output:v1:single-axis-verbatim-report+standards-three-priorities")
16750
16861
  });
16862
+ REVIEWER_VERIFICATION_BOUNDARY = [
16863
+ "Verification-Boundary: you may run focused product tests during this review turn when independent verification needs them.",
16864
+ "A full repository test suite is not forbidden, but do not re-run it every review round;",
16865
+ "prefer once at family wrap-up unless this review specifically requires a broader run.",
16866
+ "Slice and review work should not trigger frequent full-suite reruns.",
16867
+ "Independently discover test facts (including existing coder/fixer receipts and any tests you run);",
16868
+ "do not treat caller prose as the source of those facts."
16869
+ ].join(" ");
16751
16870
  REVIEWER_STANDARDS_CONCLUSION_KEYS = Object.freeze([
16752
16871
  "constitutionality",
16753
16872
  "minimum-necessary-test-cost",
@@ -16772,6 +16891,7 @@ var init_reviewer_dispatch = __esm({
16772
16891
  init_reviewer_prompt_identity();
16773
16892
  init_sha256();
16774
16893
  init_reviewer_construction();
16894
+ init_reviewer_construction();
16775
16895
  init_reviewer_preflight_error();
16776
16896
  init_sha256();
16777
16897
  init_reviewer_prompt_identity();
@@ -17524,6 +17644,20 @@ async function findRunDirectoryById(home, runId) {
17524
17644
  }
17525
17645
  return void 0;
17526
17646
  }
17647
+ function parsePersistedTicketIdentity(record4) {
17648
+ const correlationId = typeof record4.correlationId === "string" && record4.correlationId.trim() !== "" ? record4.correlationId : void 0;
17649
+ const ticketNumber = typeof record4.ticketNumber === "number" && Number.isInteger(record4.ticketNumber) && record4.ticketNumber >= 1 ? record4.ticketNumber : void 0;
17650
+ return {
17651
+ ...correlationId === void 0 ? {} : { correlationId },
17652
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
17653
+ };
17654
+ }
17655
+ function restoredTicketFields(fields) {
17656
+ return {
17657
+ ...fields.correlationId === void 0 ? {} : { correlationId: fields.correlationId },
17658
+ ...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
17659
+ };
17660
+ }
17527
17661
  async function loadResumableRunRecord(home, runId) {
17528
17662
  const runDirectory = await findRunDirectoryById(home, runId);
17529
17663
  if (runDirectory === void 0) {
@@ -17553,8 +17687,11 @@ async function loadResumableRunRecord(home, runId) {
17553
17687
  let prerequisitesPath;
17554
17688
  let prerequisites;
17555
17689
  let baseRevision;
17690
+ let authorityRefs;
17556
17691
  let mergerInputPath;
17557
17692
  let derived;
17693
+ let correlationId;
17694
+ let ticketNumber;
17558
17695
  try {
17559
17696
  const raw = JSON.parse(
17560
17697
  await readFile8(run.admittedRequestPath, "utf8")
@@ -17588,6 +17725,18 @@ async function loadResumableRunRecord(home, runId) {
17588
17725
  if (typeof record4.baseRevision === "string" && record4.baseRevision.trim() !== "") {
17589
17726
  baseRevision = record4.baseRevision;
17590
17727
  }
17728
+ if (Array.isArray(record4.authorityRefs)) {
17729
+ authorityRefs = Object.freeze(
17730
+ record4.authorityRefs.map((ref) => {
17731
+ if (typeof ref !== "string") {
17732
+ throw new CliUsageError(
17733
+ "role run admitted authority refs must be durable reference strings"
17734
+ );
17735
+ }
17736
+ return requireAuthorityRef(ref);
17737
+ })
17738
+ );
17739
+ }
17591
17740
  if (typeof record4.mergerInputPath === "string" && record4.mergerInputPath.trim() !== "") {
17592
17741
  mergerInputPath = record4.mergerInputPath;
17593
17742
  }
@@ -17603,12 +17752,38 @@ async function loadResumableRunRecord(home, runId) {
17603
17752
  };
17604
17753
  }
17605
17754
  }
17755
+ const fromAdmitted = parsePersistedTicketIdentity(record4);
17756
+ correlationId = fromAdmitted.correlationId;
17757
+ ticketNumber = fromAdmitted.ticketNumber;
17606
17758
  }
17607
- } catch {
17759
+ } catch (error) {
17760
+ if (error instanceof CliUsageError) throw error;
17608
17761
  throw new CliUsageError(
17609
- `role run admitted request is unreadable: ${runId}`
17762
+ `role run admitted request is unreadable: ${runId}`,
17763
+ { cause: error }
17610
17764
  );
17611
17765
  }
17766
+ if (correlationId === void 0 || ticketNumber === void 0) {
17767
+ try {
17768
+ const invocationRaw = JSON.parse(
17769
+ await readFile8(join9(run.runDirectory, "invocation.json"), "utf8")
17770
+ );
17771
+ if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
17772
+ const fromInvocation = parsePersistedTicketIdentity(
17773
+ invocationRaw
17774
+ );
17775
+ if (correlationId === void 0) correlationId = fromInvocation.correlationId;
17776
+ if (ticketNumber === void 0) ticketNumber = fromInvocation.ticketNumber;
17777
+ }
17778
+ } catch (error) {
17779
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
17780
+ throw new CliUsageError(
17781
+ `role run invocation identity is unreadable: ${runId}`,
17782
+ { cause: error }
17783
+ );
17784
+ }
17785
+ }
17786
+ }
17612
17787
  return {
17613
17788
  run,
17614
17789
  observation: run.resumable,
@@ -17622,8 +17797,11 @@ async function loadResumableRunRecord(home, runId) {
17622
17797
  ...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
17623
17798
  ...prerequisites === void 0 ? {} : { prerequisites },
17624
17799
  ...baseRevision === void 0 ? {} : { baseRevision },
17800
+ ...authorityRefs === void 0 ? {} : { authorityRefs },
17625
17801
  ...mergerInputPath === void 0 ? {} : { mergerInputPath },
17626
- ...derived === void 0 ? {} : { derived }
17802
+ ...derived === void 0 ? {} : { derived },
17803
+ ...correlationId === void 0 ? {} : { correlationId },
17804
+ ...ticketNumber === void 0 ? {} : { ticketNumber }
17627
17805
  }
17628
17806
  };
17629
17807
  }
@@ -17645,7 +17823,8 @@ async function loadResumableJudgeRun(home, runId) {
17645
17823
  runDirectory: loaded.run.runDirectory,
17646
17824
  sessionDirectory: loaded.run.sessionDirectory,
17647
17825
  sessionFile: loaded.run.sessionFile,
17648
- admittedRequestPath: loaded.run.admittedRequestPath
17826
+ admittedRequestPath: loaded.run.admittedRequestPath,
17827
+ ...restoredTicketFields(loaded.admittedFields)
17649
17828
  };
17650
17829
  return {
17651
17830
  admitted,
@@ -17690,7 +17869,8 @@ async function loadResumableCoderRun(home, runId) {
17690
17869
  sessionDirectory: loaded.run.sessionDirectory,
17691
17870
  sessionFile: loaded.run.sessionFile,
17692
17871
  admittedRequestPath: loaded.run.admittedRequestPath,
17693
- taskPath
17872
+ taskPath,
17873
+ ...restoredTicketFields(loaded.admittedFields)
17694
17874
  };
17695
17875
  return {
17696
17876
  admitted,
@@ -17738,7 +17918,8 @@ async function loadResumableFixerRun(home, runId) {
17738
17918
  admittedRequestPath: loaded.run.admittedRequestPath,
17739
17919
  packetPath,
17740
17920
  ...loaded.admittedFields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: loaded.admittedFields.prerequisitesPath },
17741
- prerequisites
17921
+ prerequisites,
17922
+ ...restoredTicketFields(loaded.admittedFields)
17742
17923
  };
17743
17924
  return {
17744
17925
  admitted,
@@ -17771,7 +17952,9 @@ async function loadResumableReviewerRun(home, runId) {
17771
17952
  sessionDirectory: loaded.run.sessionDirectory,
17772
17953
  sessionFile: loaded.run.sessionFile,
17773
17954
  admittedRequestPath: loaded.run.admittedRequestPath,
17774
- baseRevision
17955
+ baseRevision,
17956
+ authorityRefs: Object.freeze([...loaded.admittedFields.authorityRefs ?? []]),
17957
+ ...restoredTicketFields(loaded.admittedFields)
17775
17958
  };
17776
17959
  return {
17777
17960
  admitted,
@@ -17816,7 +17999,8 @@ async function loadResumableMergerRun(home, runId) {
17816
17999
  sessionFile: loaded.run.sessionFile,
17817
18000
  admittedRequestPath: loaded.run.admittedRequestPath,
17818
18001
  mergerInputPath,
17819
- derived
18002
+ derived,
18003
+ ...restoredTicketFields(loaded.admittedFields)
17820
18004
  };
17821
18005
  return {
17822
18006
  admitted,
@@ -17973,8 +18157,9 @@ var init_evidence_child_executor = __esm({
17973
18157
  "use strict";
17974
18158
  init_compliance_transport();
17975
18159
  init_package_owned_tool_idle();
17976
- init_stream_idle_guard();
17977
18160
  init_receipt_delivery_policy();
18161
+ init_reviewer_construction();
18162
+ init_stream_idle_guard();
17978
18163
  init_upstream_error_testimony();
17979
18164
  }
17980
18165
  });
@@ -19232,6 +19417,7 @@ function reviewerDecisiveFacts(output) {
19232
19417
  const axes = reviewerAxes(outcomes.readable ? outcomes.value : void 0);
19233
19418
  const reportAxes = reviewerAxes(reports.readable ? reports.value : void 0);
19234
19419
  const acceptedBatch = safelyRead(candidate, "acceptedBatch");
19420
+ const specDisposition = safelyRead(candidate, "specDisposition");
19235
19421
  const facts = {
19236
19422
  axes,
19237
19423
  reportAxes,
@@ -19239,6 +19425,9 @@ function reviewerDecisiveFacts(output) {
19239
19425
  ...auditNoReceiptDecisiveFact(candidate)
19240
19426
  };
19241
19427
  if (status.readable && typeof status.value === "string") facts.reviewerStatus = status.value;
19428
+ if (specDisposition.readable && (specDisposition.value === "launched" || specDisposition.value === "skipped-missing")) {
19429
+ facts.specDisposition = specDisposition.value;
19430
+ }
19242
19431
  const diagnostic = safelyRead(candidate, "diagnostic");
19243
19432
  if (status.readable && status.value === "refused" && diagnostic.readable) {
19244
19433
  facts.diagnosticPresent = typeof diagnostic.value === "string" && diagnostic.value.trim().length > 0;
@@ -20529,6 +20718,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, sessionDirectory,
20529
20718
  sessionFile: admitted.sessionFile,
20530
20719
  admittedRequestPath: admitted.admittedRequestPath,
20531
20720
  baseRevision: admitted.baseRevision,
20721
+ authorityRefs: [...admitted.authorityRefs],
20532
20722
  ...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
20533
20723
  attachments: admitted.attachments.map((a) => ({
20534
20724
  provenancePath: a.provenancePath,
@@ -21265,8 +21455,9 @@ async function dispatchAdmittedCoder(input) {
21265
21455
  PI_CODING_AGENT_DIR: env.agentDir,
21266
21456
  AK_ROLE_RUN_DIR: admitted.runDirectory
21267
21457
  };
21268
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
21269
- childEnv.AK_CORRELATION_ID = env.correlationId;
21458
+ const correlationId = admitted.correlationId ?? env.correlationId;
21459
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
21460
+ childEnv.AK_CORRELATION_ID = correlationId;
21270
21461
  }
21271
21462
  let result2;
21272
21463
  try {
@@ -21412,7 +21603,10 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
21412
21603
  });
21413
21604
  return await dispatchAdmittedCoder({
21414
21605
  admitted,
21415
- env,
21606
+ env: {
21607
+ ...env,
21608
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21609
+ },
21416
21610
  io,
21417
21611
  extraArgs,
21418
21612
  lease,
@@ -21486,7 +21680,10 @@ async function runPublicCoderResume(argv, env, io) {
21486
21680
  });
21487
21681
  return await dispatchAdmittedCoder({
21488
21682
  admitted,
21489
- env,
21683
+ env: {
21684
+ ...env,
21685
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21686
+ },
21490
21687
  io,
21491
21688
  extraArgs,
21492
21689
  lease,
@@ -21591,8 +21788,9 @@ async function dispatchAdmittedCollector(input) {
21591
21788
  PI_CODING_AGENT_DIR: env.agentDir,
21592
21789
  AK_ROLE_RUN_DIR: admitted.runDirectory
21593
21790
  };
21594
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
21595
- childEnv.AK_CORRELATION_ID = env.correlationId;
21791
+ const correlationId = admitted.correlationId ?? env.correlationId;
21792
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
21793
+ childEnv.AK_CORRELATION_ID = correlationId;
21596
21794
  }
21597
21795
  let result2;
21598
21796
  try {
@@ -21721,7 +21919,10 @@ async function runPublicCollector(argv, env, io, parseCollectorArgv2) {
21721
21919
  });
21722
21920
  return await dispatchAdmittedCollector({
21723
21921
  admitted,
21724
- env,
21922
+ env: {
21923
+ ...env,
21924
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
21925
+ },
21725
21926
  io,
21726
21927
  extraArgs,
21727
21928
  lease
@@ -22123,8 +22324,9 @@ async function dispatchAdmittedFixer(input) {
22123
22324
  PI_CODING_AGENT_DIR: env.agentDir,
22124
22325
  AK_ROLE_RUN_DIR: admitted.runDirectory
22125
22326
  };
22126
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
22127
- childEnv.AK_CORRELATION_ID = env.correlationId;
22327
+ const correlationId = admitted.correlationId ?? env.correlationId;
22328
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
22329
+ childEnv.AK_CORRELATION_ID = correlationId;
22128
22330
  }
22129
22331
  let result2;
22130
22332
  try {
@@ -22286,7 +22488,10 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
22286
22488
  });
22287
22489
  return await dispatchAdmittedFixer({
22288
22490
  admitted,
22289
- env,
22491
+ env: {
22492
+ ...env,
22493
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22494
+ },
22290
22495
  io,
22291
22496
  extraArgs,
22292
22497
  lease,
@@ -22353,7 +22558,10 @@ async function runPublicFixerResume(argv, env, io) {
22353
22558
  });
22354
22559
  return await dispatchAdmittedFixer({
22355
22560
  admitted,
22356
- env,
22561
+ env: {
22562
+ ...env,
22563
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22564
+ },
22357
22565
  io,
22358
22566
  extraArgs,
22359
22567
  lease,
@@ -22497,8 +22705,9 @@ async function dispatchAdmittedJudge(input) {
22497
22705
  // and role-runtime can record typed provider HTTP observations.
22498
22706
  AK_ROLE_RUN_DIR: admitted.runDirectory
22499
22707
  };
22500
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
22501
- childEnv.AK_CORRELATION_ID = env.correlationId;
22708
+ const correlationId = admitted.correlationId ?? env.correlationId;
22709
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
22710
+ childEnv.AK_CORRELATION_ID = correlationId;
22502
22711
  }
22503
22712
  let result2;
22504
22713
  try {
@@ -22631,7 +22840,10 @@ async function runPublicJudge(argv, env, io, parseJudgeArgv2) {
22631
22840
  });
22632
22841
  return await dispatchAdmittedJudge({
22633
22842
  admitted,
22634
- env,
22843
+ env: {
22844
+ ...env,
22845
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22846
+ },
22635
22847
  io,
22636
22848
  extraArgs,
22637
22849
  lease
@@ -22680,7 +22892,10 @@ async function runPublicResume(argv, env, io) {
22680
22892
  });
22681
22893
  return await dispatchAdmittedJudge({
22682
22894
  admitted,
22683
- env,
22895
+ env: {
22896
+ ...env,
22897
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
22898
+ },
22684
22899
  io,
22685
22900
  extraArgs,
22686
22901
  lease
@@ -22838,8 +23053,9 @@ async function dispatchAdmittedMerger(input) {
22838
23053
  PI_CODING_AGENT_DIR: env.agentDir,
22839
23054
  AK_ROLE_RUN_DIR: admitted.runDirectory
22840
23055
  };
22841
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
22842
- childEnv.AK_CORRELATION_ID = env.correlationId;
23056
+ const correlationId = admitted.correlationId ?? env.correlationId;
23057
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
23058
+ childEnv.AK_CORRELATION_ID = correlationId;
22843
23059
  }
22844
23060
  let result2;
22845
23061
  try {
@@ -23071,7 +23287,10 @@ async function runPublicMerger(argv, env, io, parseMergerArgv2) {
23071
23287
  });
23072
23288
  return await dispatchAdmittedMerger({
23073
23289
  admitted,
23074
- env,
23290
+ env: {
23291
+ ...env,
23292
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23293
+ },
23075
23294
  io,
23076
23295
  extraArgs,
23077
23296
  lease,
@@ -23139,7 +23358,10 @@ async function runPublicMergerResume(argv, env, io) {
23139
23358
  });
23140
23359
  return await dispatchAdmittedMerger({
23141
23360
  admitted,
23142
- env,
23361
+ env: {
23362
+ ...env,
23363
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23364
+ },
23143
23365
  io,
23144
23366
  extraArgs,
23145
23367
  lease,
@@ -23183,6 +23405,7 @@ function buildReviewerActivationExtraArgs(admitted, options) {
23183
23405
  options.packageRoot,
23184
23406
  "code-review"
23185
23407
  );
23408
+ const authorityRefArgs = admitted.authorityRefs.length === 0 ? [] : ["--ak-review-authority-refs", JSON.stringify([...admitted.authorityRefs])];
23186
23409
  return [
23187
23410
  "--no-skills",
23188
23411
  "--skill",
@@ -23199,6 +23422,7 @@ function buildReviewerActivationExtraArgs(admitted, options) {
23199
23422
  "reviewer",
23200
23423
  "--ak-review-base",
23201
23424
  admitted.baseRevision,
23425
+ ...authorityRefArgs,
23202
23426
  "--mode",
23203
23427
  "json",
23204
23428
  ...buildModelArgs7(options.model),
@@ -23210,6 +23434,7 @@ function buildReviewerResumeActivationExtraArgs(admitted, options) {
23210
23434
  options.packageRoot,
23211
23435
  "code-review"
23212
23436
  );
23437
+ const authorityRefArgs = admitted.authorityRefs.length === 0 ? [] : ["--ak-review-authority-refs", JSON.stringify([...admitted.authorityRefs])];
23213
23438
  return [
23214
23439
  "--no-skills",
23215
23440
  "--skill",
@@ -23226,6 +23451,7 @@ function buildReviewerResumeActivationExtraArgs(admitted, options) {
23226
23451
  "reviewer",
23227
23452
  "--ak-review-base",
23228
23453
  admitted.baseRevision,
23454
+ ...authorityRefArgs,
23229
23455
  "--mode",
23230
23456
  "json",
23231
23457
  ...buildModelArgs7(options.model),
@@ -23300,8 +23526,9 @@ async function dispatchAdmittedReviewer(input) {
23300
23526
  PI_CODING_AGENT_DIR: env.agentDir,
23301
23527
  AK_ROLE_RUN_DIR: admitted.runDirectory
23302
23528
  };
23303
- if (env.correlationId !== void 0 && env.correlationId.trim() !== "") {
23304
- childEnv.AK_CORRELATION_ID = env.correlationId;
23529
+ const correlationId = admitted.correlationId ?? env.correlationId;
23530
+ if (correlationId !== void 0 && correlationId.trim() !== "") {
23531
+ childEnv.AK_CORRELATION_ID = correlationId;
23305
23532
  }
23306
23533
  let result2;
23307
23534
  try {
@@ -23418,6 +23645,7 @@ async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
23418
23645
  instruction: parsed.instruction,
23419
23646
  attachmentPaths: parsed.attachmentPaths,
23420
23647
  baseRevision: parsed.baseRevision,
23648
+ authorityRefs: parsed.authorityRefs,
23421
23649
  ...parsed.project === void 0 ? {} : { project: parsed.project },
23422
23650
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23423
23651
  });
@@ -23462,7 +23690,10 @@ async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
23462
23690
  });
23463
23691
  return await dispatchAdmittedReviewer({
23464
23692
  admitted,
23465
- env,
23693
+ env: {
23694
+ ...env,
23695
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23696
+ },
23466
23697
  io,
23467
23698
  extraArgs,
23468
23699
  lease,
@@ -23529,7 +23760,10 @@ async function runPublicReviewerResume(argv, env, io) {
23529
23760
  });
23530
23761
  return await dispatchAdmittedReviewer({
23531
23762
  admitted,
23532
- env,
23763
+ env: {
23764
+ ...env,
23765
+ ...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
23766
+ },
23533
23767
  io,
23534
23768
  extraArgs,
23535
23769
  lease,
@@ -23554,6 +23788,7 @@ var init_reviewer_run = __esm({
23554
23788
  var cli_exports = {};
23555
23789
  __export(cli_exports, {
23556
23790
  CliUsageError: () => CliUsageError,
23791
+ PUBLIC_ROLE_ARGV: () => PUBLIC_ROLE_ARGV,
23557
23792
  buildExplicitInternalActivationArgs: () => buildExplicitInternalActivationArgs,
23558
23793
  helpDocument: () => helpDocument,
23559
23794
  resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint,
@@ -23562,6 +23797,42 @@ __export(cli_exports, {
23562
23797
  import { realpath as realpath5 } from "node:fs/promises";
23563
23798
  import { homedir as homedir3 } from "node:os";
23564
23799
  import { join as join18 } from "node:path";
23800
+ function takePublicGlobalFlag(argv, index) {
23801
+ const token = argv[index];
23802
+ if (token === void 0) return void 0;
23803
+ if (token === "--help" || token === "-h") {
23804
+ return { flag: "help", consume: 1 };
23805
+ }
23806
+ if (token === "--model") {
23807
+ const value = argv[index + 1];
23808
+ if (value === void 0) {
23809
+ return { flag: "model", consume: 1, value: void 0 };
23810
+ }
23811
+ return { flag: "model", consume: 2, value };
23812
+ }
23813
+ if (token.startsWith("--model=")) {
23814
+ return {
23815
+ flag: "model",
23816
+ consume: 1,
23817
+ value: token.slice("--model=".length)
23818
+ };
23819
+ }
23820
+ if (token === "--thinking") {
23821
+ const raw = argv[index + 1];
23822
+ if (raw === void 0) {
23823
+ return { flag: "thinking", consume: 1, raw: void 0 };
23824
+ }
23825
+ return { flag: "thinking", consume: 2, raw };
23826
+ }
23827
+ if (token.startsWith("--thinking=")) {
23828
+ return {
23829
+ flag: "thinking",
23830
+ consume: 1,
23831
+ raw: token.slice("--thinking=".length)
23832
+ };
23833
+ }
23834
+ return void 0;
23835
+ }
23565
23836
  function defaultIo() {
23566
23837
  return {
23567
23838
  stdout: (text) => {
@@ -23591,40 +23862,34 @@ function parseArgv(argv) {
23591
23862
  let help = false;
23592
23863
  const positional = [];
23593
23864
  while (args.length > 0) {
23594
- const token = args.shift();
23595
- if (token === "--") {
23865
+ if (args[0] === "--") {
23866
+ args.shift();
23596
23867
  positional.push(...args);
23597
23868
  break;
23598
23869
  }
23599
- if (token === "--help" || token === "-h") {
23600
- help = true;
23601
- continue;
23602
- }
23603
- if (token === "--model") {
23604
- const value = args.shift();
23605
- if (value === void 0) throw new CliUsageError("--model requires a value");
23606
- model = value;
23607
- continue;
23608
- }
23609
- if (token.startsWith("--model=")) {
23610
- model = token.slice("--model=".length);
23611
- continue;
23612
- }
23613
- if (token === "--thinking") {
23614
- const value = args.shift();
23615
- if (value === void 0) throw new CliUsageError("--thinking requires a value");
23616
- thinking = parseThinking(value);
23617
- continue;
23618
- }
23619
- if (token.startsWith("--thinking=")) {
23620
- thinking = parseThinking(token.slice("--thinking=".length));
23621
- continue;
23622
- }
23623
- if (token.startsWith("-") && token !== "-") {
23624
- positional.push(token);
23870
+ const taken = takePublicGlobalFlag(args, 0);
23871
+ if (taken !== void 0) {
23872
+ if (taken.flag === "help") {
23873
+ help = true;
23874
+ args.splice(0, taken.consume);
23875
+ continue;
23876
+ }
23877
+ if (taken.flag === "model") {
23878
+ if (taken.value === void 0) {
23879
+ throw new CliUsageError("--model requires a value");
23880
+ }
23881
+ model = taken.value;
23882
+ args.splice(0, taken.consume);
23883
+ continue;
23884
+ }
23885
+ if (taken.raw === void 0) {
23886
+ throw new CliUsageError("--thinking requires a value");
23887
+ }
23888
+ thinking = parseThinking(taken.raw);
23889
+ args.splice(0, taken.consume);
23625
23890
  continue;
23626
23891
  }
23627
- positional.push(token);
23892
+ positional.push(args.shift());
23628
23893
  }
23629
23894
  const [command, ...rest] = positional;
23630
23895
  return {
@@ -23957,7 +24222,7 @@ async function runAkRole(argv, env) {
23957
24222
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23958
24223
  },
23959
24224
  io,
23960
- parseJudgeArgv
24225
+ PUBLIC_ROLE_ARGV.judge.parse
23961
24226
  );
23962
24227
  return {
23963
24228
  exitCode: result2.exitCode,
@@ -23991,7 +24256,7 @@ async function runAkRole(argv, env) {
23991
24256
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
23992
24257
  },
23993
24258
  io,
23994
- parseCoderArgv
24259
+ PUBLIC_ROLE_ARGV.coder.parse
23995
24260
  );
23996
24261
  return {
23997
24262
  exitCode: result2.exitCode,
@@ -24025,7 +24290,7 @@ async function runAkRole(argv, env) {
24025
24290
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
24026
24291
  },
24027
24292
  io,
24028
- parseFixerArgv
24293
+ PUBLIC_ROLE_ARGV.fixer.parse
24029
24294
  );
24030
24295
  return {
24031
24296
  exitCode: result2.exitCode,
@@ -24059,7 +24324,7 @@ async function runAkRole(argv, env) {
24059
24324
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
24060
24325
  },
24061
24326
  io,
24062
- parseCollectorArgv
24327
+ PUBLIC_ROLE_ARGV.collector.parse
24063
24328
  );
24064
24329
  return {
24065
24330
  exitCode: result2.exitCode,
@@ -24093,7 +24358,7 @@ async function runAkRole(argv, env) {
24093
24358
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
24094
24359
  },
24095
24360
  io,
24096
- parseReviewerArgv
24361
+ PUBLIC_ROLE_ARGV.reviewer.parse
24097
24362
  );
24098
24363
  return {
24099
24364
  exitCode: result2.exitCode,
@@ -24127,7 +24392,7 @@ async function runAkRole(argv, env) {
24127
24392
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
24128
24393
  },
24129
24394
  io,
24130
- parseDoctorArgv
24395
+ PUBLIC_ROLE_ARGV.doctor.parse
24131
24396
  );
24132
24397
  return {
24133
24398
  exitCode: result2.exitCode,
@@ -24161,7 +24426,7 @@ async function runAkRole(argv, env) {
24161
24426
  ...env.createRunId === void 0 ? {} : { createRunId: env.createRunId }
24162
24427
  },
24163
24428
  io,
24164
- parseMergerArgv
24429
+ PUBLIC_ROLE_ARGV.merger.parse
24165
24430
  );
24166
24431
  return {
24167
24432
  exitCode: result2.exitCode,
@@ -24183,7 +24448,7 @@ async function runAkRole(argv, env) {
24183
24448
  return { exitCode: 1 };
24184
24449
  }
24185
24450
  }
24186
- var THINKING_LEVELS2;
24451
+ var PUBLIC_ROLE_ARGV, THINKING_LEVELS2;
24187
24452
  var init_cli = __esm({
24188
24453
  "src/public-cli/cli.ts"() {
24189
24454
  "use strict";
@@ -24203,6 +24468,15 @@ var init_cli = __esm({
24203
24468
  init_settlement();
24204
24469
  init_explicit_internal();
24205
24470
  init_cli_errors();
24471
+ PUBLIC_ROLE_ARGV = {
24472
+ judge: { parse: parseJudgeArgv },
24473
+ coder: { parse: parseCoderArgv },
24474
+ fixer: { parse: parseFixerArgv },
24475
+ collector: { parse: parseCollectorArgv },
24476
+ doctor: { parse: parseDoctorArgv },
24477
+ merger: { parse: parseMergerArgv },
24478
+ reviewer: { parse: parseReviewerArgv }
24479
+ };
24206
24480
  THINKING_LEVELS2 = /* @__PURE__ */ new Set([
24207
24481
  "off",
24208
24482
  "minimal",