@akagilnc/pi-workflow-roles 0.1.4403 → 0.1.4419

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 (60) hide show
  1. package/README.md +4 -3
  2. package/README.zh-CN.md +5 -4
  3. package/THIRD_PARTY_NOTICES.md +8 -6
  4. package/dist/acp-host/production-host.js +249 -624
  5. package/dist/headless-host/production-host.js +251 -626
  6. package/dist/migrate-book-topology.js +23 -6
  7. package/dist/package-resources/method-skill.js +6 -1
  8. package/dist/pi/role-turn-host.js +3 -1
  9. package/dist/public-cli/invocation.js +83 -32
  10. package/dist/public-cli/main.js +240 -306
  11. package/dist/public-cli/option-definitions.js +23 -6
  12. package/dist/public-cli/post-admission.js +0 -4
  13. package/dist/public-cli/run-lifecycle.js +25 -4
  14. package/dist/public-cli/settlement.js +6 -77
  15. package/dist/role-activation-flags.js +1 -0
  16. package/extensions/role-runtime.ts +3 -5
  17. package/package.json +1 -1
  18. package/resources/836-deleted-machine-instruction-inventory.md +1 -1
  19. package/resources/methods/ak-cross-m-review/CONTEXT.md +48 -0
  20. package/resources/methods/ak-cross-m-review/LICENSE +21 -0
  21. package/resources/methods/ak-cross-m-review/SKILL.md +170 -0
  22. package/resources/methods/ak-cross-m-review/prompts/cmr-completeness.md +118 -0
  23. package/resources/methods/ak-cross-m-review/prompts/cmr-reviewer.md +128 -0
  24. package/resources/methods/ak-cross-m-review/provenance.json +41 -0
  25. package/souls/judge.md +1 -1
  26. package/souls/reviewer.md +1 -1
  27. package/src/archivist-record-entry.ts +1 -1
  28. package/src/canonical-skill-binding.ts +2 -2
  29. package/src/host-contracts.ts +2 -0
  30. package/src/package-contracts/reviewer-output.ts +4 -2
  31. package/src/package-resources/method-skill.ts +7 -2
  32. package/src/pi/role-turn-host.ts +3 -1
  33. package/src/public-cli/invocation.ts +108 -39
  34. package/src/public-cli/option-definitions.ts +23 -6
  35. package/src/public-cli/post-admission.ts +0 -4
  36. package/src/public-cli/reviewer-run.ts +39 -16
  37. package/src/public-cli/run-lifecycle.ts +33 -3
  38. package/src/public-cli/settlement.ts +8 -73
  39. package/src/reviewer-role.ts +27 -16
  40. package/src/role-activation-flags.ts +1 -0
  41. package/src/role-runtime-dependencies.ts +2 -4
  42. package/src/role-runtime.ts +9 -26
  43. package/src/worker-role.ts +1 -1
  44. package/dist/adr-path-refs.js +0 -23
  45. package/dist/public-cli/reviewer-dispatch-rejection.js +0 -77
  46. package/dist/reviewer-dispatch.js +0 -14
  47. package/dist/reviewer-git-snapshot.js +0 -32
  48. package/dist/reviewer-pinned-git.js +0 -308
  49. package/dist/reviewer-preflight-error.js +0 -15
  50. package/dist/reviewer-prompt-identity.js +0 -10
  51. package/resources/methods/code-review/SKILL.md +0 -92
  52. package/resources/methods/code-review/agents/openai.yaml +0 -3
  53. package/resources/methods/code-review/provenance.json +0 -26
  54. package/src/adr-path-refs.ts +0 -25
  55. package/src/public-cli/reviewer-dispatch-rejection.ts +0 -106
  56. package/src/reviewer-dispatch.ts +0 -39
  57. package/src/reviewer-git-snapshot.ts +0 -45
  58. package/src/reviewer-pinned-git.ts +0 -330
  59. package/src/reviewer-preflight-error.ts +0 -14
  60. package/src/reviewer-prompt-identity.ts +0 -17
@@ -1559,10 +1559,10 @@ __export(session_assistant_usage_exports, {
1559
1559
  });
1560
1560
  import { join as join5 } from "node:path";
1561
1561
  async function readAssistantUsageFromSessionFile(sessionFile) {
1562
- const { readFile: readFile25 } = await import("node:fs/promises");
1562
+ const { readFile: readFile24 } = await import("node:fs/promises");
1563
1563
  let text;
1564
1564
  try {
1565
- text = await readFile25(sessionFile, "utf8");
1565
+ text = await readFile24(sessionFile, "utf8");
1566
1566
  } catch (error) {
1567
1567
  if (error?.code === "ENOENT") return void 0;
1568
1568
  throw error;
@@ -3104,6 +3104,7 @@ function projectActivationFlags(request) {
3104
3104
  }
3105
3105
  if (activation.role === "reviewer") {
3106
3106
  flags.set("ak-review-base", activation.baseRevision);
3107
+ flags.set("ak-review-lens", activation.lens);
3107
3108
  flags.set("ak-review-authority-refs", JSON.stringify(activation.authorityRefs));
3108
3109
  if (activation.ticketNumber !== void 0) {
3109
3110
  flags.set("ak-review-ticket-number", String(activation.ticketNumber));
@@ -3547,7 +3548,7 @@ function piUserDialogueBody(request) {
3547
3548
  const _exhaustive = request.continuation;
3548
3549
  return _exhaustive;
3549
3550
  })();
3550
- return applyPiNativeSkillInvocation(request.methods, rawPrompt);
3551
+ return request.continuation.kind === "resume" && request.activation.role === "reviewer" ? rawPrompt : applyPiNativeSkillInvocation(request.methods, rawPrompt);
3551
3552
  }
3552
3553
  async function resolveSelectedPi(command, cwd, env) {
3553
3554
  const searchPath = env.PATH ?? (platform === "win32" ? process.env.PATH ?? "" : "/usr/bin:/bin");
@@ -5602,6 +5603,7 @@ async function loadResumableRunRecord(home, runId, authority) {
5602
5603
  let prerequisitesPath;
5603
5604
  let prerequisites;
5604
5605
  let baseRevision;
5606
+ let lens;
5605
5607
  let authorityRefs;
5606
5608
  let mergerInputPath;
5607
5609
  let derived;
@@ -5655,6 +5657,9 @@ async function loadResumableRunRecord(home, runId, authority) {
5655
5657
  if (typeof record4.baseRevision === "string" && record4.baseRevision.trim() !== "") {
5656
5658
  baseRevision = record4.baseRevision;
5657
5659
  }
5660
+ if (isReviewerLens(record4.lens)) {
5661
+ lens = record4.lens;
5662
+ }
5658
5663
  if (typeof record4.prNumber === "number" && Number.isSafeInteger(record4.prNumber) && record4.prNumber >= 1) {
5659
5664
  prNumber = record4.prNumber;
5660
5665
  }
@@ -5792,6 +5797,7 @@ async function loadResumableRunRecord(home, runId, authority) {
5792
5797
  ...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
5793
5798
  ...prerequisites === void 0 ? {} : { prerequisites },
5794
5799
  ...baseRevision === void 0 ? {} : { baseRevision },
5800
+ ...lens === void 0 ? {} : { lens },
5795
5801
  ...authorityRefs === void 0 ? {} : { authorityRefs },
5796
5802
  ...mergerInputPath === void 0 ? {} : { mergerInputPath },
5797
5803
  ...derived === void 0 ? {} : { derived },
@@ -6600,18 +6606,32 @@ var init_option_definitions = __esm({
6600
6606
  zh: "\u5FC5\u586B\uFF1B\u9489\u4F4F\u5BA1\u67E5\u76EE\u6807\u7684 fixed-point revision\u3002"
6601
6607
  }
6602
6608
  },
6609
+ {
6610
+ id: "lens",
6611
+ owner: "reviewer",
6612
+ canonical: "--lens",
6613
+ aliases: [],
6614
+ valueMetavar: "completeness|correctness",
6615
+ required: true,
6616
+ repeatable: false,
6617
+ form: "option",
6618
+ description: {
6619
+ en: "Required single review lens: completeness or correctness (no default).",
6620
+ zh: "\u5FC5\u586B\u5355 lens\uFF1Acompleteness \u6216 correctness\uFF08\u65E0\u9ED8\u8BA4\u503C\uFF09\u3002"
6621
+ }
6622
+ },
6603
6623
  {
6604
6624
  id: "authority-ref",
6605
6625
  owner: "reviewer",
6606
6626
  canonical: "--authority-ref",
6607
6627
  aliases: [],
6608
6628
  valueMetavar: "ref",
6609
- required: false,
6629
+ required: true,
6610
6630
  repeatable: true,
6611
6631
  form: "option",
6612
6632
  description: {
6613
- en: "Durable authority reference/URL (repeatable; refs only, not inline prose).",
6614
- zh: "\u6301\u4E45 authority \u5F15\u7528/URL\uFF08\u53EF\u91CD\u590D\uFF1B\u4EC5 ref\uFF0C\u975E\u5185\u8054\u6563\u6587\uFF09\u3002"
6633
+ en: "Required durable authority reference/URL (repeatable; refs only, not inline prose).",
6634
+ zh: "\u5FC5\u586B\u6301\u4E45 authority \u5F15\u7528/URL\uFF08\u53EF\u91CD\u590D\uFF1B\u4EC5 ref\uFF0C\u975E\u5185\u8054\u6563\u6587\uFF09\u3002"
6615
6635
  }
6616
6636
  }
6617
6637
  ];
@@ -6954,10 +6974,13 @@ var init_option_definitions = __esm({
6954
6974
  },
6955
6975
  reviewer: {
6956
6976
  command: "reviewer",
6957
- summary: "Fixed-target two-axis review (Standards + Spec).",
6958
- usage: ["ak-role reviewer --base <revision> [options] <instruction>"],
6977
+ summary: "Fixed-target single-lens review (completeness or correctness).",
6978
+ usage: [
6979
+ "ak-role reviewer --base <revision> --lens completeness|correctness --authority-ref <ref> [options] <instruction>"
6980
+ ],
6959
6981
  examples: [
6960
- 'ak-role reviewer --base main "Review the branch against the governing issue and repository authority."'
6982
+ 'ak-role reviewer --base main --lens completeness --authority-ref docs/adr/0001.md "Review the branch."',
6983
+ "ak-role reviewer --base main --lens correctness --authority-ref CLAUDE.md --authority-ref docs/adr/0001.md"
6961
6984
  ]
6962
6985
  },
6963
6986
  collector: {
@@ -7161,12 +7184,14 @@ __export(invocation_exports, {
7161
7184
  buildJudgeTransportPrompt: () => buildJudgeTransportPrompt,
7162
7185
  buildMergerTransportPrompt: () => buildMergerTransportPrompt,
7163
7186
  buildNotaryTransportPrompt: () => buildNotaryTransportPrompt,
7187
+ buildReviewerSkillArgProjection: () => buildReviewerSkillArgProjection,
7164
7188
  buildReviewerTransportPrompt: () => buildReviewerTransportPrompt,
7165
7189
  buildSecretariatTransportPrompt: () => buildSecretariatTransportPrompt,
7166
7190
  deriveMergerEnvelopeFromActiveMerge: () => deriveMergerEnvelopeFromActiveMerge,
7167
7191
  ensureRunArtifactsDir: () => ensureRunArtifactsDir,
7168
7192
  freezeAttachmentsIntoRun: () => freezeAttachmentsIntoRun,
7169
7193
  homeFromRunDirectory: () => homeFromRunDirectory,
7194
+ isReviewerLens: () => isReviewerLens,
7170
7195
  issueAdmissionPlacement: () => issueAdmissionPlacement,
7171
7196
  loadAdmittedJudgeRequest: () => loadAdmittedJudgeRequest,
7172
7197
  observeLaunchedRolePackageIdentity: () => observeLaunchedRolePackageIdentity,
@@ -7197,6 +7222,8 @@ __export(invocation_exports, {
7197
7222
  recordLaunchedRolePackageIdentity: () => recordLaunchedRolePackageIdentity,
7198
7223
  relocateAdmittedRunToTicket: () => relocateAdmittedRunToTicket,
7199
7224
  requireAuthorityRef: () => requireAuthorityRef,
7225
+ requireReviewerBaseRevision: () => requireReviewerBaseRevision,
7226
+ requireReviewerLens: () => requireReviewerLens,
7200
7227
  resolveDoctorCaseRunsPath: () => resolveDoctorCaseRunsPath,
7201
7228
  resolveGitHubRemoteRepository: () => resolveGitHubRemoteRepository
7202
7229
  });
@@ -7567,6 +7594,35 @@ function requireOptionPath(flag, value) {
7567
7594
  }
7568
7595
  return value;
7569
7596
  }
7597
+ function requireSkillArgToken(value, messages) {
7598
+ if (value === void 0 || value.trim() === "") {
7599
+ throw new CliUsageError(messages.empty);
7600
+ }
7601
+ if (/\s/.test(value)) {
7602
+ throw new CliUsageError(messages.whitespace);
7603
+ }
7604
+ if (value.startsWith("-")) {
7605
+ throw new CliUsageError(messages.optionLike);
7606
+ }
7607
+ return value;
7608
+ }
7609
+ function requireReviewerBaseRevision(value) {
7610
+ return requireSkillArgToken(value, {
7611
+ empty: "--base requires a nonempty revision",
7612
+ whitespace: "--base requires a single-token revision",
7613
+ optionLike: "--base requires a single-token revision"
7614
+ });
7615
+ }
7616
+ function isReviewerLens(value) {
7617
+ return value === "completeness" || value === "correctness";
7618
+ }
7619
+ function requireReviewerLens(value) {
7620
+ const trimmed = (value ?? "").trim();
7621
+ if (!isReviewerLens(trimmed)) {
7622
+ throw new CliUsageError("--lens requires completeness or correctness");
7623
+ }
7624
+ return trimmed;
7625
+ }
7570
7626
  function isRejectedPublicSpelling(owner, token) {
7571
7627
  for (const entry of REJECTED_PUBLIC_SPELLINGS) {
7572
7628
  if (entry.owner !== owner) continue;
@@ -7580,15 +7636,11 @@ function roleOptions(owner) {
7580
7636
  return optionsForOwner(owner);
7581
7637
  }
7582
7638
  function requireAuthorityRef(value) {
7583
- if (value === void 0 || value.trim() === "") {
7584
- throw new CliUsageError("--authority-ref requires a nonempty durable reference");
7585
- }
7586
- if (/\s/.test(value)) {
7587
- throw new CliUsageError(
7588
- "--authority-ref requires a durable reference, not inline Spec prose"
7589
- );
7590
- }
7591
- return value;
7639
+ return requireSkillArgToken(value, {
7640
+ empty: "--authority-ref requires a nonempty durable reference",
7641
+ whitespace: "--authority-ref requires a durable reference, not inline Spec prose",
7642
+ optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
7643
+ });
7592
7644
  }
7593
7645
  function parseJudgeArgv(args) {
7594
7646
  const dd = args.indexOf("--");
@@ -8892,6 +8944,7 @@ function parseReviewerArgv(args) {
8892
8944
  const authorityRefs = [];
8893
8945
  let project;
8894
8946
  let baseRevision;
8947
+ let lens;
8895
8948
  const positional = [];
8896
8949
  const tokens = [...args];
8897
8950
  const definitions = roleOptions("reviewer");
@@ -8909,7 +8962,11 @@ function parseReviewerArgv(args) {
8909
8962
  continue;
8910
8963
  }
8911
8964
  if (taken.def.id === "base") {
8912
- baseRevision = requireOptionPath(taken.def.canonical, taken.value);
8965
+ baseRevision = requireReviewerBaseRevision(taken.value);
8966
+ continue;
8967
+ }
8968
+ if (taken.def.id === "lens") {
8969
+ lens = requireReviewerLens(taken.value);
8913
8970
  continue;
8914
8971
  }
8915
8972
  if (taken.def.id === "authority-ref") {
@@ -8929,6 +8986,7 @@ function parseReviewerArgv(args) {
8929
8986
  instruction: positional.join(" "),
8930
8987
  attachmentPaths,
8931
8988
  baseRevision,
8989
+ lens,
8932
8990
  authorityRefs,
8933
8991
  ...project === void 0 ? {} : { project }
8934
8992
  };
@@ -8937,11 +8995,13 @@ async function admitReviewerInvocation(options) {
8937
8995
  if (options.project !== void 0) {
8938
8996
  requireOptionPath("--project", options.project);
8939
8997
  }
8940
- if (options.baseRevision.trim() === "") {
8941
- throw new CliUsageError("--base requires a nonempty revision");
8998
+ const baseRevision = requireReviewerBaseRevision(options.baseRevision);
8999
+ const lens = requireReviewerLens(options.lens);
9000
+ if (options.authorityRefs.length === 0) {
9001
+ throw new CliUsageError("reviewer requires --authority-ref <ref>");
8942
9002
  }
8943
9003
  const authorityRefs = Object.freeze(
8944
- (options.authorityRefs ?? []).map((ref) => requireAuthorityRef(ref))
9004
+ options.authorityRefs.map((ref) => requireAuthorityRef(ref))
8945
9005
  );
8946
9006
  const projectRoot = resolve9(options.project ?? options.cwd);
8947
9007
  const runId = (options.createRunId ?? uuidv7)();
@@ -8972,7 +9032,8 @@ async function admitReviewerInvocation(options) {
8972
9032
  principal,
8973
9033
  instruction,
8974
9034
  instructionEmpty,
8975
- baseRevision: options.baseRevision,
9035
+ baseRevision,
9036
+ lens,
8976
9037
  authorityRefs: [...authorityRefs],
8977
9038
  attachments: attachments.map((a) => ({
8978
9039
  provenancePath: a.provenancePath,
@@ -8999,14 +9060,20 @@ async function admitReviewerInvocation(options) {
8999
9060
  runDirectory,
9000
9061
  principal,
9001
9062
  admittedRequestPath,
9002
- baseRevision: options.baseRevision,
9063
+ baseRevision,
9064
+ lens,
9003
9065
  authorityRefs
9004
9066
  };
9005
9067
  }
9068
+ function buildReviewerSkillArgProjection(admitted) {
9069
+ return [
9070
+ `--base ${admitted.baseRevision}`,
9071
+ `--lens ${admitted.lens}`,
9072
+ ...admitted.authorityRefs.map((ref) => `--authority ${ref}`)
9073
+ ].join(" ");
9074
+ }
9006
9075
  function buildReviewerTransportPrompt(admitted, engineMaterial) {
9007
- const lines = [
9008
- `\u672C\u6B21\u5BA1\u67E5\u7684\u56FA\u5B9A\u57FA\u70B9\uFF1A${admitted.baseRevision}`
9009
- ];
9076
+ const lines = [buildReviewerSkillArgProjection(admitted)];
9010
9077
  if (!admitted.instructionEmpty && admitted.instruction.trim() !== "") {
9011
9078
  lines.push("", admitted.instruction);
9012
9079
  }
@@ -10716,10 +10783,10 @@ function pairGateRounds(volumes) {
10716
10783
  return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
10717
10784
  }
10718
10785
  async function resolveOfficerSessionFromPointerFile(pointerPath) {
10719
- const { readFile: readFile25 } = await import("node:fs/promises");
10786
+ const { readFile: readFile24 } = await import("node:fs/promises");
10720
10787
  let raw;
10721
10788
  try {
10722
- raw = JSON.parse(await readFile25(pointerPath, "utf8"));
10789
+ raw = JSON.parse(await readFile24(pointerPath, "utf8"));
10723
10790
  } catch (error) {
10724
10791
  throw new Error(
10725
10792
  `direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
@@ -11483,387 +11550,6 @@ var init_known_failure = __esm({
11483
11550
  }
11484
11551
  });
11485
11552
 
11486
- // src/reviewer-git-snapshot.ts
11487
- function parseReviewerRefSnapshot(raw) {
11488
- const refs = {};
11489
- for (const line2 of raw.split("\n")) {
11490
- if (!line2) continue;
11491
- const fields = line2.split("\0");
11492
- if (fields.length !== 5 || !fields[0] || !fields[1] || !fields[3]) {
11493
- throw new Error(`Malformed Git ref snapshot line: ${line2}`);
11494
- }
11495
- const peeledCommitId = fields[3] === "commit" ? fields[1] : fields[4] === "commit" && fields[2] ? fields[2] : null;
11496
- refs[fields[0]] = Object.freeze({
11497
- objectId: fields[1],
11498
- peeledCommitId
11499
- });
11500
- }
11501
- return refs;
11502
- }
11503
- function reviewerRefSnapshotArgs() {
11504
- return ["for-each-ref", "--format=%(refname)%00%(objectname)%00%(*objectname)%00%(objecttype)%00%(*objecttype)", ...REVIEW_REF_PREFIXES];
11505
- }
11506
- function immutableReviewerRefs(refs) {
11507
- return Object.freeze(Object.fromEntries(Object.entries(refs).sort(([a], [b]) => a.localeCompare(b)).map(([name, entry]) => [name, Object.freeze({ objectId: entry.objectId, peeledCommitId: entry.peeledCommitId })])));
11508
- }
11509
- var REVIEW_REF_PREFIXES;
11510
- var init_reviewer_git_snapshot = __esm({
11511
- "src/reviewer-git-snapshot.ts"() {
11512
- "use strict";
11513
- REVIEW_REF_PREFIXES = ["refs/heads", "refs/tags", "refs/remotes"];
11514
- }
11515
- });
11516
-
11517
- // src/reviewer-preflight-error.ts
11518
- var ReviewerCorrectablePreflightError;
11519
- var init_reviewer_preflight_error = __esm({
11520
- "src/reviewer-preflight-error.ts"() {
11521
- "use strict";
11522
- ReviewerCorrectablePreflightError = class extends Error {
11523
- constructor(code, diagnostic = `${code} constraint failed`, options) {
11524
- super(`${code}: ${diagnostic}`, options);
11525
- this.code = code;
11526
- this.diagnostic = diagnostic;
11527
- this.name = "ReviewerCorrectablePreflightError";
11528
- }
11529
- code;
11530
- diagnostic;
11531
- };
11532
- }
11533
- });
11534
-
11535
- // src/reviewer-pinned-git.ts
11536
- import { execFile as execFile3 } from "node:child_process";
11537
- import { access as access3, realpath as realpath6 } from "node:fs/promises";
11538
- import { promisify as promisify3 } from "node:util";
11539
- async function execGit(args, options) {
11540
- try {
11541
- return await execFileAsync3("git", args, {
11542
- ...options,
11543
- env: { ...process.env, LC_ALL: "C" }
11544
- });
11545
- } catch (error) {
11546
- const source = error;
11547
- const wrapped = new Error("git process failed", { cause: error });
11548
- Object.assign(wrapped, { code: source.code ?? null, signal: source.signal ?? null, timedOut: source.killed === true && source.signal === "SIGTERM", aborted: source.name === "AbortError", stderr: String(source.stderr ?? ""), stdout: String(source.stdout ?? "") });
11549
- throw wrapped;
11550
- }
11551
- }
11552
- function exitCode(error) {
11553
- const code = typeof error === "object" && error !== null ? error.code : void 0;
11554
- return typeof code === "number" ? code : void 0;
11555
- }
11556
- function gitStderr(error) {
11557
- if (typeof error !== "object" || error === null) return "";
11558
- const stderr = error.stderr;
11559
- return typeof stderr === "string" ? stderr : "";
11560
- }
11561
- function isConfirmedMissingOriginRemote(error) {
11562
- return /No such remote ['"]origin['"]/.test(gitStderr(error));
11563
- }
11564
- function isConfirmedPinnedPathAbsent(error, path) {
11565
- const stderr = gitStderr(error);
11566
- const quoted = `'${path}'`;
11567
- return stderr.includes(`path ${quoted} does not exist in `) || stderr.includes(`path ${quoted} exists on disk, but not in `);
11568
- }
11569
- async function repositoryIsAvailable(root) {
11570
- try {
11571
- await access3(`${root}/.git`);
11572
- return { available: true };
11573
- } catch (cause) {
11574
- return { available: false, cause };
11575
- }
11576
- }
11577
- function shortNameFromPinnedRef(refName) {
11578
- const short = refName.startsWith("refs/heads/") ? refName.slice("refs/heads/".length) : refName.startsWith("refs/tags/") ? refName.slice("refs/tags/".length) : refName.startsWith("refs/remotes/") ? refName.slice("refs/remotes/".length).replace(/^[^/]+\//, "") : refName;
11579
- const trimmed = short.trim();
11580
- return trimmed === "" ? void 0 : trimmed;
11581
- }
11582
- async function gitText2(root, args) {
11583
- const { stdout } = await execGit(["-C", root, ...args], { encoding: "utf8" });
11584
- return stdout.trim();
11585
- }
11586
- async function createReviewerPinnedGitReader(root = process.cwd()) {
11587
- const discoveredRoot = await gitText2(root, ["rev-parse", "--show-toplevel"]);
11588
- const repositoryRoot = await realpath6(discoveredRoot);
11589
- const objectFormat = await gitText2(repositoryRoot, ["rev-parse", "--show-object-format"]);
11590
- if (objectFormat !== "sha1" && objectFormat !== "sha256") throw new Error("Unsupported Git object format");
11591
- const oidWidth = objectFormat === "sha1" ? 40 : 64;
11592
- const targetHead = await gitText2(repositoryRoot, ["rev-parse", "HEAD^{commit}"]);
11593
- const reachableCommitIds = Object.freeze((await gitText2(repositoryRoot, ["rev-list", targetHead])).split("\n").filter(Boolean));
11594
- const refs = parseReviewerRefSnapshot(await gitText2(repositoryRoot, reviewerRefSnapshotArgs()));
11595
- const pin = immutableReviewerPin({ repositoryRoot, objectFormat, targetHead, refs });
11596
- const invalid = (code, diagnostic, cause) => {
11597
- throw new ReviewerCorrectablePreflightError(code, diagnostic, cause === void 0 ? void 0 : { cause });
11598
- };
11599
- const symbolic = (base) => {
11600
- const selected = Object.hasOwn(refs, base) ? base : (() => {
11601
- const candidates = [`refs/heads/${base}`, `refs/tags/${base}`, `refs/remotes/${base}`].filter((name) => Object.hasOwn(refs, name));
11602
- if (candidates.length > 1) invalid("base-invalid", "base revision is ambiguous across pinned refs");
11603
- return candidates[0];
11604
- })();
11605
- if (selected === void 0) return void 0;
11606
- const commit = refs[selected]?.peeledCommitId;
11607
- if (commit === null) invalid("base-invalid", "base revision ref must resolve to a commit");
11608
- return commit ?? void 0;
11609
- };
11610
- return Object.freeze({
11611
- pin,
11612
- async snapshot() {
11613
- const liveObjectFormat = await gitText2(repositoryRoot, ["rev-parse", "--show-object-format"]);
11614
- if (liveObjectFormat !== "sha1" && liveObjectFormat !== "sha256") throw new Error("Unsupported Git object format");
11615
- return immutableReviewerPin({ repositoryRoot, objectFormat: liveObjectFormat, targetHead: await gitText2(repositoryRoot, ["rev-parse", "HEAD^{commit}"]), refs: parseReviewerRefSnapshot(await gitText2(repositoryRoot, reviewerRefSnapshotArgs())) });
11616
- },
11617
- async resolve(base) {
11618
- if (!/^[A-Za-z0-9._/~^+-]+$/.test(base) || base.startsWith("-") || base.includes("..") || base.includes("@{")) {
11619
- invalid("base-invalid", "base revision syntax is invalid or uses a forbidden revision form");
11620
- }
11621
- let commit;
11622
- const headExpression = /^HEAD((?:~[0-9]+|\^[0-9]+)*)$/.exec(base);
11623
- if (headExpression) {
11624
- try {
11625
- commit = await gitText2(repositoryRoot, ["rev-parse", "--verify", `${targetHead}${headExpression[1]}^{commit}`]);
11626
- } catch (error) {
11627
- if (exitCode(error) === 128) {
11628
- const repository = await repositoryIsAvailable(repositoryRoot);
11629
- if (repository.available) invalid("base-invalid", "base revision HEAD ancestry expression must resolve to a reachable commit", error);
11630
- }
11631
- throw error;
11632
- }
11633
- } else if (new RegExp(`^[0-9a-f]{${oidWidth}}$`).test(base)) commit = base;
11634
- else if (new RegExp(`^[0-9a-f]{4,${oidWidth - 1}}$`).test(base) && !(objectFormat === "sha256" && base.length === 40)) {
11635
- const matches = reachableCommitIds.filter((candidate) => candidate.startsWith(base));
11636
- if (matches.length !== 1) invalid("base-invalid", "base revision abbreviation must identify exactly one reachable commit");
11637
- commit = matches[0];
11638
- } else commit = symbolic(base);
11639
- if (commit === void 0) invalid("base-invalid", "base revision must name an existing pinned ref or reachable commit");
11640
- try {
11641
- commit = await gitText2(repositoryRoot, ["rev-parse", "--verify", `${commit}^{commit}`]);
11642
- } catch (error) {
11643
- if (exitCode(error) === 128) {
11644
- const repository = await repositoryIsAvailable(repositoryRoot);
11645
- if (repository.available) invalid("base-invalid", "base revision must resolve to an existing commit", error);
11646
- }
11647
- throw error;
11648
- }
11649
- try {
11650
- await gitText2(repositoryRoot, ["merge-base", "--is-ancestor", commit, targetHead]);
11651
- } catch (error) {
11652
- if (exitCode(error) === 1) invalid("base-invalid", "base revision must be an ancestor of the pinned target", error);
11653
- throw error;
11654
- }
11655
- return commit;
11656
- },
11657
- async range(base) {
11658
- let mergeBase;
11659
- try {
11660
- mergeBase = await gitText2(repositoryRoot, ["merge-base", base, targetHead]);
11661
- } catch (error) {
11662
- if (exitCode(error) === 1) {
11663
- invalid("range-invalid", "review range requires a common ancestor for base and pinned target", error);
11664
- }
11665
- throw error;
11666
- }
11667
- if (!mergeBase) invalid("range-invalid", "review range requires a common ancestor for base and pinned target");
11668
- const diffCommand = `git diff ${mergeBase}...${targetHead}`;
11669
- const [{ stdout: diff }, commitsText] = await Promise.all([
11670
- execGit(["-C", repositoryRoot, "diff", `${mergeBase}...${targetHead}`], { encoding: "buffer", maxBuffer: 64 * 1024 * 1024 }),
11671
- gitText2(repositoryRoot, ["rev-list", "--reverse", `${mergeBase}..${targetHead}`])
11672
- ]);
11673
- if (diff.length === 0) invalid("range-invalid", "review range must contain a non-empty diff between base and pinned target");
11674
- return Object.freeze({ base: mergeBase, target: targetHead, diffCommand, diffSha256: sha256Hex(Uint8Array.from(diff)), commits: Object.freeze(commitsText ? commitsText.split("\n") : []) });
11675
- },
11676
- async featureTokens() {
11677
- const names = /* @__PURE__ */ new Set();
11678
- for (const [refName, entry] of Object.entries(pin.refs)) {
11679
- if (entry.peeledCommitId !== targetHead) continue;
11680
- const short = shortNameFromPinnedRef(refName);
11681
- if (short !== void 0) names.add(short);
11682
- }
11683
- return Object.freeze([...names]);
11684
- },
11685
- async listSpecCandidatePaths() {
11686
- const roots = ["docs", "specs", ".scratch"];
11687
- const text = await gitText2(repositoryRoot, [
11688
- "ls-tree",
11689
- "-r",
11690
- "--name-only",
11691
- targetHead,
11692
- "--",
11693
- ...roots
11694
- ]);
11695
- return Object.freeze(text === "" ? [] : text.split("\n").filter((line2) => line2.length > 0));
11696
- },
11697
- async originRepository() {
11698
- let remoteUrl;
11699
- try {
11700
- remoteUrl = await gitText2(repositoryRoot, ["remote", "get-url", "origin"]);
11701
- } catch (error) {
11702
- if (isConfirmedMissingOriginRemote(error)) return void 0;
11703
- throw error;
11704
- }
11705
- return parseGitHubOriginRemote(remoteUrl);
11706
- },
11707
- async commitMessagesNewestFirst(base) {
11708
- const text = await gitText2(repositoryRoot, [
11709
- "log",
11710
- "--format=%s",
11711
- `${base}..${targetHead}`
11712
- ]);
11713
- return Object.freeze(text === "" ? [] : text.split("\n"));
11714
- },
11715
- async readPinnedText(path) {
11716
- if (path.length === 0 || path.startsWith("/") || path.includes("\0") || path.split("/").some((part) => part === ".." || part === "")) {
11717
- return void 0;
11718
- }
11719
- try {
11720
- const { stdout } = await execGit(
11721
- ["-C", repositoryRoot, "show", `${targetHead}:${path}`],
11722
- { encoding: "utf8", maxBuffer: 8 * 1024 * 1024 }
11723
- );
11724
- return stdout;
11725
- } catch (error) {
11726
- if (isConfirmedPinnedPathAbsent(error, path)) return void 0;
11727
- throw error;
11728
- }
11729
- }
11730
- });
11731
- }
11732
- function parseGitHubOriginRemote(remoteUrl) {
11733
- const trimmed = remoteUrl.trim();
11734
- if (trimmed.length === 0) return void 0;
11735
- const scp = /^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/i.exec(trimmed);
11736
- if (scp) return normalizeOrigin(scp[1], scp[2]);
11737
- const ssh = /^ssh:\/\/git@github\.com\/([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(trimmed);
11738
- if (ssh) return normalizeOrigin(ssh[1], ssh[2]);
11739
- let parsed;
11740
- try {
11741
- parsed = new URL(trimmed);
11742
- } catch {
11743
- return void 0;
11744
- }
11745
- if (!/^github\.com$/i.test(parsed.hostname)) return void 0;
11746
- if (parsed.search !== "" || parsed.hash !== "") return void 0;
11747
- const parts = parsed.pathname.split("/").filter((p) => p.length > 0);
11748
- if (parts.length !== 2) return void 0;
11749
- return normalizeOrigin(parts[0], parts[1]);
11750
- }
11751
- function normalizeOrigin(ownerRaw, repoRaw) {
11752
- const owner = ownerRaw.trim();
11753
- const repo = stripGitSuffix2(repoRaw.trim());
11754
- if (owner.length === 0 || repo.length === 0) return void 0;
11755
- if (/[/?#@\\]/.test(owner) || /[/?#@\\]/.test(repo)) return void 0;
11756
- return Object.freeze({ owner, repo });
11757
- }
11758
- function stripGitSuffix2(name) {
11759
- return name.toLowerCase().endsWith(".git") ? name.slice(0, -4) : name;
11760
- }
11761
- var execFileAsync3, immutableReviewerPin;
11762
- var init_reviewer_pinned_git = __esm({
11763
- "src/reviewer-pinned-git.ts"() {
11764
- "use strict";
11765
- init_reviewer_git_snapshot();
11766
- init_sha256();
11767
- init_reviewer_preflight_error();
11768
- execFileAsync3 = promisify3(execFile3);
11769
- immutableReviewerPin = (pin) => Object.freeze({
11770
- repositoryRoot: pin.repositoryRoot,
11771
- objectFormat: pin.objectFormat,
11772
- targetHead: pin.targetHead,
11773
- refs: immutableReviewerRefs(pin.refs)
11774
- });
11775
- }
11776
- });
11777
-
11778
- // src/adr-path-refs.ts
11779
- var init_adr_path_refs = __esm({
11780
- "src/adr-path-refs.ts"() {
11781
- "use strict";
11782
- }
11783
- });
11784
-
11785
- // src/reviewer-prompt-identity.ts
11786
- var init_reviewer_prompt_identity = __esm({
11787
- "src/reviewer-prompt-identity.ts"() {
11788
- "use strict";
11789
- }
11790
- });
11791
-
11792
- // src/reviewer-dispatch.ts
11793
- var REVIEWER_PREFLIGHT_VIOLATIONS;
11794
- var init_reviewer_dispatch = __esm({
11795
- "src/reviewer-dispatch.ts"() {
11796
- "use strict";
11797
- init_reviewer_pinned_git();
11798
- init_adr_path_refs();
11799
- init_sha256();
11800
- init_reviewer_prompt_identity();
11801
- REVIEWER_PREFLIGHT_VIOLATIONS = [
11802
- "base-invalid",
11803
- "range-invalid",
11804
- "prompt-identity-invalid",
11805
- "target-drift"
11806
- ];
11807
- }
11808
- });
11809
-
11810
- // src/public-cli/reviewer-dispatch-rejection.ts
11811
- import { readFile as readFile15, unlink as unlink3 } from "node:fs/promises";
11812
- import { join as join24 } from "node:path";
11813
- function isReviewerPreflightViolation(value) {
11814
- return typeof value === "string" && REVIEWER_PREFLIGHT_VIOLATIONS.includes(value);
11815
- }
11816
- function reviewerDispatchRejectionPath(runDirectory) {
11817
- return join24(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
11818
- }
11819
- async function clearReviewerDispatchRejection(runDirectory) {
11820
- try {
11821
- await unlink3(reviewerDispatchRejectionPath(runDirectory));
11822
- } catch (error) {
11823
- if (error instanceof Error && "code" in error && error.code === "ENOENT") {
11824
- return;
11825
- }
11826
- throw error;
11827
- }
11828
- }
11829
- async function readReviewerDispatchRejection(runDirectory) {
11830
- let raw;
11831
- try {
11832
- raw = await readFile15(reviewerDispatchRejectionPath(runDirectory), "utf8");
11833
- } catch (error) {
11834
- if (error instanceof Error && "code" in error && error.code === "ENOENT") {
11835
- return void 0;
11836
- }
11837
- throw error;
11838
- }
11839
- const parsed = JSON.parse(raw);
11840
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
11841
- const error = new Error("Reviewer dispatch rejection page must be a JSON object");
11842
- error.name = "ReviewerDispatchRejectionContractError";
11843
- throw error;
11844
- }
11845
- const record4 = parsed;
11846
- if (typeof record4.diagnostic !== "string" || record4.diagnostic.trim() === "" || !Array.isArray(record4.violations) || record4.violations.length === 0 || record4.violations.some((value) => !isReviewerPreflightViolation(value))) {
11847
- const error = new Error("Reviewer dispatch rejection page has unusable required fields");
11848
- error.name = "ReviewerDispatchRejectionContractError";
11849
- throw error;
11850
- }
11851
- return {
11852
- cause: "activation",
11853
- diagnostic: record4.diagnostic,
11854
- identity: { name: "ReviewerDispatchRejectionError" },
11855
- details: { violations: Object.freeze([...record4.violations]) }
11856
- };
11857
- }
11858
- var REVIEWER_DISPATCH_REJECTION_FILE;
11859
- var init_reviewer_dispatch_rejection = __esm({
11860
- "src/public-cli/reviewer-dispatch-rejection.ts"() {
11861
- "use strict";
11862
- init_reviewer_dispatch();
11863
- REVIEWER_DISPATCH_REJECTION_FILE = "typed-known-failure.json";
11864
- }
11865
- });
11866
-
11867
11553
  // src/collector-evidence.ts
11868
11554
  import { createHash as createHash5 } from "node:crypto";
11869
11555
  function createSystemCollectorClock() {
@@ -13025,7 +12711,7 @@ var init_collector_ledger = __esm({
13025
12711
  // src/engine-detour-usage.ts
13026
12712
  import { randomUUID as randomUUID3 } from "node:crypto";
13027
12713
  import { readFileSync as readFileSync3 } from "node:fs";
13028
- import { dirname as dirname13, join as join25 } from "node:path";
12714
+ import { dirname as dirname13, join as join24 } from "node:path";
13029
12715
  function engineDetourStdoutByteLength(stdout) {
13030
12716
  return Buffer.byteLength(stdout, "utf8");
13031
12717
  }
@@ -13161,7 +12847,7 @@ function projectEngineDetourToolUsageForPublicTerminal(usage, options) {
13161
12847
  function readInvocationRecord(runDirectory) {
13162
12848
  try {
13163
12849
  const raw = JSON.parse(
13164
- readFileSync3(join25(runDirectory, "invocation.json"), "utf8")
12850
+ readFileSync3(join24(runDirectory, "invocation.json"), "utf8")
13165
12851
  );
13166
12852
  return isRecord7(raw) ? raw : void 0;
13167
12853
  } catch (error) {
@@ -13194,7 +12880,7 @@ function runDirectoryFromSessionDirectory(sessionDirectory) {
13194
12880
  return dirname13(sessionDirectory);
13195
12881
  }
13196
12882
  function sessionFileFromSessionDirectory(sessionDirectory) {
13197
- return join25(sessionDirectory, "session.jsonl");
12883
+ return join24(sessionDirectory, "session.jsonl");
13198
12884
  }
13199
12885
  function mintEngineDetourInvocationScope(input) {
13200
12886
  const engine = input.effectiveEngine?.trim();
@@ -13291,8 +12977,8 @@ var init_dossier_resolution = __esm({
13291
12977
 
13292
12978
  // src/package-resources/method-skill.ts
13293
12979
  import { createHash as createHash6 } from "node:crypto";
13294
- import { readFile as readFile16, realpath as realpath7 } from "node:fs/promises";
13295
- import { join as join26 } from "node:path";
12980
+ import { readFile as readFile15, realpath as realpath6 } from "node:fs/promises";
12981
+ import { join as join25 } from "node:path";
13296
12982
  function gitBlobOid(bytes) {
13297
12983
  const body = typeof bytes === "string" ? Buffer.from(bytes, "utf8") : Buffer.from(bytes);
13298
12984
  const header = Buffer.from(`blob ${body.byteLength}\0`, "utf8");
@@ -13309,10 +12995,10 @@ function packagedMethodSkillRelativeDirectory(name) {
13309
12995
  return `${METHOD_SKILL_RELATIVE_ROOT}/${name}`;
13310
12996
  }
13311
12997
  function resolvePackagedMethodSkillRoot(packageRoot, name) {
13312
- return join26(packageRoot, packagedMethodSkillRelativeDirectory(name));
12998
+ return join25(packageRoot, packagedMethodSkillRelativeDirectory(name));
13313
12999
  }
13314
13000
  function resolvePackagedMethodSkillPath(packageRoot, name) {
13315
- return join26(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
13001
+ return join25(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
13316
13002
  }
13317
13003
  function isRecord9(value) {
13318
13004
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -13406,11 +13092,11 @@ function parseProvenance(raw, expectedName) {
13406
13092
  }
13407
13093
  async function loadPackagedMethodSkillMaterial(packageRoot, name) {
13408
13094
  const rootDirectory = resolvePackagedMethodSkillRoot(packageRoot, name);
13409
- const skillPathConfigured = join26(rootDirectory, "SKILL.md");
13410
- const provenancePath = join26(rootDirectory, "provenance.json");
13095
+ const skillPathConfigured = join25(rootDirectory, "SKILL.md");
13096
+ const provenancePath = join25(rootDirectory, "provenance.json");
13411
13097
  let provenanceRaw;
13412
13098
  try {
13413
- provenanceRaw = await readFile16(provenancePath, "utf8");
13099
+ provenanceRaw = await readFile15(provenancePath, "utf8");
13414
13100
  } catch (error) {
13415
13101
  throw new PackagedMethodSkillUnavailableError(name, provenancePath, error);
13416
13102
  }
@@ -13424,10 +13110,10 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
13424
13110
  }
13425
13111
  const provenance = parseProvenance(provenanceJson, name);
13426
13112
  for (const [rel, expected] of Object.entries(provenance.files)) {
13427
- const absolute = join26(rootDirectory, rel);
13113
+ const absolute = join25(rootDirectory, rel);
13428
13114
  let bytes;
13429
13115
  try {
13430
- bytes = await readFile16(absolute);
13116
+ bytes = await readFile15(absolute);
13431
13117
  } catch (error) {
13432
13118
  throw new PackagedMethodSkillUnavailableError(name, absolute, error);
13433
13119
  }
@@ -13442,8 +13128,8 @@ async function loadPackagedMethodSkillMaterial(packageRoot, name) {
13442
13128
  let skillPath;
13443
13129
  let raw;
13444
13130
  try {
13445
- skillPath = await realpath7(skillPathConfigured);
13446
- raw = await readFile16(skillPath, "utf8");
13131
+ skillPath = await realpath6(skillPathConfigured);
13132
+ raw = await readFile15(skillPath, "utf8");
13447
13133
  } catch (error) {
13448
13134
  throw new PackagedMethodSkillUnavailableError(name, skillPathConfigured, error);
13449
13135
  }
@@ -13515,7 +13201,12 @@ var init_method_skill = __esm({
13515
13201
  REQUIRED_COMPANIONS = {
13516
13202
  tdd: ["tests.md", "mocking.md", "agents/openai.yaml"],
13517
13203
  "diagnosing-bugs": ["agents/openai.yaml", "scripts/hitl-loop.template.sh"],
13518
- "code-review": ["agents/openai.yaml"],
13204
+ "ak-cross-m-review": [
13205
+ "CONTEXT.md",
13206
+ "LICENSE",
13207
+ "prompts/cmr-completeness.md",
13208
+ "prompts/cmr-reviewer.md"
13209
+ ],
13519
13210
  "resolving-merge-conflicts": ["agents/openai.yaml"]
13520
13211
  };
13521
13212
  }
@@ -13992,7 +13683,6 @@ __export(settlement_exports, {
13992
13683
  publishMergerArtifacts: () => publishMergerArtifacts,
13993
13684
  publishReviewerArtifacts: () => publishReviewerArtifacts,
13994
13685
  raceNavigatorGrace: () => raceNavigatorGrace,
13995
- readBoundEvidenceChildKnownFailure: () => readBoundEvidenceChildKnownFailure,
13996
13686
  readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
13997
13687
  readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
13998
13688
  readLawfulJudgeRoleOutcome: () => readLawfulJudgeRoleOutcome,
@@ -14033,15 +13723,15 @@ __export(settlement_exports, {
14033
13723
  withSubmissions: () => withSubmissions
14034
13724
  });
14035
13725
  import { randomUUID as randomUUID4 } from "node:crypto";
14036
- import { appendFile as appendFile2, readFile as readFile17, readdir as readdir6, writeFile as writeFile7 } from "node:fs/promises";
14037
- import { dirname as dirname14, join as join27 } from "node:path";
13726
+ import { appendFile as appendFile2, readFile as readFile16, readdir as readdir6, writeFile as writeFile7 } from "node:fs/promises";
13727
+ import { dirname as dirname14, join as join26 } from "node:path";
14038
13728
  function sealedLedgerHome(admitted) {
14039
13729
  return homeFromRunDirectory(admitted.runDirectory);
14040
13730
  }
14041
13731
  function ledgerReadScope(admitted, scope) {
14042
13732
  return {
14043
13733
  home: sealedLedgerHome(admitted),
14044
- sessionParent: join27(admitted.runDirectory, "session", "session.jsonl"),
13734
+ sessionParent: join26(admitted.runDirectory, "session", "session.jsonl"),
14045
13735
  ...scope?.courtAttemptId === void 0 || scope.courtAttemptId.length === 0 ? {} : { attemptId: scope.courtAttemptId }
14046
13736
  };
14047
13737
  }
@@ -14177,7 +13867,7 @@ function presentControlledFailure(failure2, io) {
14177
13867
  }
14178
13868
  async function inspectJudgeSession(sessionFile) {
14179
13869
  try {
14180
- await readFile17(sessionFile, "utf8");
13870
+ await readFile16(sessionFile, "utf8");
14181
13871
  return { state: "present" };
14182
13872
  } catch (error) {
14183
13873
  if (isMissingPathError3(error)) return { state: "missing" };
@@ -14409,7 +14099,7 @@ function sessionReadFailure(error, fallbackMessage) {
14409
14099
  return failed;
14410
14100
  }
14411
14101
  async function readBoundSessionEntries(sessionFile) {
14412
- const text = await readFile17(sessionFile, "utf8");
14102
+ const text = await readFile16(sessionFile, "utf8");
14413
14103
  const entries = [];
14414
14104
  for (const line2 of text.trim().split("\n").filter(Boolean)) {
14415
14105
  try {
@@ -14495,37 +14185,6 @@ async function readSessionProviderStop(sessionFile) {
14495
14185
  return void 0;
14496
14186
  }
14497
14187
  }
14498
- async function readBoundEvidenceChildKnownFailure(sessionFile) {
14499
- const childDirectory = join27(dirname14(sessionFile), "evidence-children");
14500
- let names;
14501
- try {
14502
- names = await readdir6(childDirectory);
14503
- } catch (error) {
14504
- if (isMissingPathError3(error)) return void 0;
14505
- throw sessionReadFailure(error, "failed to read bound evidence-child session directory");
14506
- }
14507
- for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
14508
- let entries;
14509
- try {
14510
- entries = await readBoundSessionEntries(join27(childDirectory, file));
14511
- } catch (error) {
14512
- throw sessionReadFailure(error, "failed to read discovered evidence-child session");
14513
- }
14514
- const header = entries.find((entry) => entry.type === "session");
14515
- if (!isRecord11(header) || header.parentSession !== sessionFile) continue;
14516
- const stop = extractSessionProviderStop(entries);
14517
- if (stop === void 0) continue;
14518
- const primary = knownFailureFromProviderStop(stop);
14519
- return {
14520
- ...primary,
14521
- details: {
14522
- ...primary.details ?? {},
14523
- secondaryEvidence: "evidence-child"
14524
- }
14525
- };
14526
- }
14527
- return void 0;
14528
- }
14529
14188
  async function loadBoundAuditorVolumes(sessionFile) {
14530
14189
  let parentEntries;
14531
14190
  try {
@@ -14536,7 +14195,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
14536
14195
  }
14537
14196
  const parentId = parentEntries.find((entry) => entry.type === "session")?.id;
14538
14197
  if (parentId === void 0) return void 0;
14539
- const childDirectories = [join27(dirname14(sessionFile), "auditor-roles")];
14198
+ const childDirectories = [join26(dirname14(sessionFile), "auditor-roles")];
14540
14199
  const valid = [];
14541
14200
  let sawAnyDirectory = false;
14542
14201
  for (const childDirectory of childDirectories) {
@@ -14551,7 +14210,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
14551
14210
  for (const file of names.filter((name) => name.endsWith(".jsonl")).sort().reverse()) {
14552
14211
  let entries;
14553
14212
  try {
14554
- entries = await readBoundSessionEntries(join27(childDirectory, file));
14213
+ entries = await readBoundSessionEntries(join26(childDirectory, file));
14555
14214
  } catch (error) {
14556
14215
  throw sessionReadFailure(error, "failed to read discovered auditor session");
14557
14216
  }
@@ -14676,19 +14335,6 @@ function resolutionOf(knownFailure, typedHttp = { settled: false }) {
14676
14335
  }
14677
14336
  async function resolveAuditedRunnerFailureResolution(input) {
14678
14337
  if (input.runner !== void 0) return resolutionOf(input.runner);
14679
- if (input.runDirectory !== void 0) {
14680
- try {
14681
- const rejection = await readReviewerDispatchRejection(input.runDirectory);
14682
- if (rejection !== void 0) return resolutionOf(rejection);
14683
- } catch (error) {
14684
- const failure2 = error instanceof Error ? error : new Error(String(error));
14685
- return resolutionOf({
14686
- cause: "activation",
14687
- identity: thrownIdentity(failure2),
14688
- diagnostic: failure2.message || failure2.name
14689
- });
14690
- }
14691
- }
14692
14338
  try {
14693
14339
  const auditorCompliance = await readBoundAuditorComplianceFailure(input.sessionFile);
14694
14340
  if (auditorCompliance !== void 0) return resolutionOf(auditorCompliance);
@@ -14726,17 +14372,6 @@ async function resolveAuditedRunnerFailureResolution(input) {
14726
14372
  diagnostic: failure2.message || failure2.name
14727
14373
  });
14728
14374
  }
14729
- try {
14730
- const evidenceChildFailure = await readBoundEvidenceChildKnownFailure(input.sessionFile);
14731
- if (evidenceChildFailure !== void 0) return resolutionOf(evidenceChildFailure);
14732
- } catch (error) {
14733
- const failure2 = sessionReadFailure(error, "failed to recover bound evidence-child failure");
14734
- return resolutionOf({
14735
- cause: "session",
14736
- identity: thrownIdentity(failure2),
14737
- diagnostic: failure2.message || failure2.name
14738
- });
14739
- }
14740
14375
  const parentStop = await readSessionProviderStop(input.sessionFile);
14741
14376
  let httpObservation;
14742
14377
  if (input.runDirectory !== void 0) {
@@ -15068,8 +14703,8 @@ function projectTerminalGateFact(rounds) {
15068
14703
  };
15069
14704
  }
15070
14705
  async function extractGateFactFromSessionDirectory(sessionDirectory, options = {}) {
15071
- const directories = [join27(sessionDirectory, "auditor-roles")];
15072
- const parentSessionFile = options.parentSessionFile ?? join27(sessionDirectory, "session.jsonl");
14706
+ const directories = [join26(sessionDirectory, "auditor-roles")];
14707
+ const parentSessionFile = options.parentSessionFile ?? join26(sessionDirectory, "session.jsonl");
15073
14708
  const rounds = await readAnalystGateCyclesFromAuditorRoles(directories, {
15074
14709
  parentSessionFile
15075
14710
  });
@@ -15199,8 +14834,8 @@ async function extractNavigatorFactFromAdmittedSession(sessionFile) {
15199
14834
  async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
15200
14835
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15201
14836
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15202
- const reportPath = join27(artifactsDir, "report.json");
15203
- const evidencePath = join27(artifactsDir, "evidence.json");
14837
+ const reportPath = join26(artifactsDir, "report.json");
14838
+ const evidencePath = join26(artifactsDir, "evidence.json");
15204
14839
  await writeFile7(
15205
14840
  reportPath,
15206
14841
  `${JSON.stringify(
@@ -15244,8 +14879,8 @@ async function publishJudgeArtifacts(admitted, roleOutcome, coordinates) {
15244
14879
  async function publishCoderArtifacts(admitted, roleOutcome, coordinates, options = {}) {
15245
14880
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15246
14881
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15247
- const reportPath = join27(artifactsDir, "report.json");
15248
- const evidencePath = join27(artifactsDir, "evidence.json");
14882
+ const reportPath = join26(artifactsDir, "report.json");
14883
+ const evidencePath = join26(artifactsDir, "evidence.json");
15249
14884
  await writeFile7(
15250
14885
  reportPath,
15251
14886
  `${JSON.stringify(
@@ -15402,8 +15037,8 @@ function extractFixerMethodInvocations(entries, options) {
15402
15037
  async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options) {
15403
15038
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15404
15039
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15405
- const reportPath = join27(artifactsDir, "report.json");
15406
- const evidencePath = join27(artifactsDir, "evidence.json");
15040
+ const reportPath = join26(artifactsDir, "report.json");
15041
+ const evidencePath = join26(artifactsDir, "evidence.json");
15407
15042
  await writeFile7(
15408
15043
  reportPath,
15409
15044
  `${JSON.stringify(
@@ -15500,8 +15135,8 @@ async function settleFixerTerminalResult(admitted, authority, options, scope) {
15500
15135
  async function publishCollectorArtifacts(admitted, roleOutcome, coordinates) {
15501
15136
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15502
15137
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15503
- const reportPath = join27(artifactsDir, "report.json");
15504
- const evidencePath = join27(artifactsDir, "evidence.json");
15138
+ const reportPath = join26(artifactsDir, "report.json");
15139
+ const evidencePath = join26(artifactsDir, "evidence.json");
15505
15140
  await writeFile7(
15506
15141
  reportPath,
15507
15142
  `${JSON.stringify(
@@ -15633,8 +15268,8 @@ function extractDoctorCandidateAuditNoReceiptFact(entries) {
15633
15268
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
15634
15269
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15635
15270
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15636
- const reportPath = join27(artifactsDir, "report.json");
15637
- const evidencePath = join27(artifactsDir, "evidence.json");
15271
+ const reportPath = join26(artifactsDir, "report.json");
15272
+ const evidencePath = join26(artifactsDir, "evidence.json");
15638
15273
  await writeFile7(
15639
15274
  reportPath,
15640
15275
  `${JSON.stringify(
@@ -15928,7 +15563,7 @@ function extractReviewerMethodInvocations(entries, options) {
15928
15563
  const text = sessionMessageText(message);
15929
15564
  if (text.length === 0) continue;
15930
15565
  const hit = observePackagedMethodSkillInvocation(text, {
15931
- name: "code-review",
15566
+ name: "ak-cross-m-review",
15932
15567
  allowedLocations: options.allowedLocations
15933
15568
  });
15934
15569
  if (hit !== void 0) observed.push(hit);
@@ -15938,8 +15573,8 @@ function extractReviewerMethodInvocations(entries, options) {
15938
15573
  async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, options) {
15939
15574
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
15940
15575
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
15941
- const reportPath = join27(artifactsDir, "report.json");
15942
- const evidencePath = join27(artifactsDir, "evidence.json");
15576
+ const reportPath = join26(artifactsDir, "report.json");
15577
+ const evidencePath = join26(artifactsDir, "evidence.json");
15943
15578
  await writeFile7(
15944
15579
  reportPath,
15945
15580
  `${JSON.stringify(
@@ -15964,6 +15599,7 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
15964
15599
  sessionFile: coordinates.sessionFile,
15965
15600
  admittedRequestPath: admitted.admittedRequestPath,
15966
15601
  baseRevision: admitted.baseRevision,
15602
+ lens: admitted.lens,
15967
15603
  authorityRefs: [...admitted.authorityRefs],
15968
15604
  ...admitted.instructionEmpty ? {} : { callerProvenance: admitted.instruction },
15969
15605
  attachments: admitted.attachments.map((a) => ({
@@ -16053,8 +15689,8 @@ function extractMergerMethodInvocations(entries, options) {
16053
15689
  async function publishMergerArtifacts(admitted, roleOutcome, coordinates, options) {
16054
15690
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
16055
15691
  const artifactsDir = await ensureRunArtifactsDir(admitted.runDirectory);
16056
- const reportPath = join27(artifactsDir, "report.json");
16057
- const evidencePath = join27(artifactsDir, "evidence.json");
15692
+ const reportPath = join26(artifactsDir, "report.json");
15693
+ const evidencePath = join26(artifactsDir, "evidence.json");
16058
15694
  await writeFile7(
16059
15695
  reportPath,
16060
15696
  `${JSON.stringify(
@@ -16210,7 +15846,7 @@ async function writeFailureJsonRetainingCause(preferredCandidates, uniqueFallbac
16210
15846
  const candidates = [
16211
15847
  ...preferredCandidates,
16212
15848
  // One unique name per fallback dir — collisions on fixed names cannot exhaust this.
16213
- ...uniqueFallbackDirs.map((dir) => join27(dir, `${stem}.${randomUUID4()}.json`))
15849
+ ...uniqueFallbackDirs.map((dir) => join26(dir, `${stem}.${randomUUID4()}.json`))
16214
15850
  ];
16215
15851
  for (let i = 0; i < candidates.length; i += 1) {
16216
15852
  const path = candidates[i];
@@ -16261,20 +15897,20 @@ async function publishFailureArtifacts(admitted, failure2, authority) {
16261
15897
  baseDir
16262
15898
  );
16263
15899
  const errorCandidates = underArtifacts ? [
16264
- join27(baseDir, "error.json"),
16265
- join27(baseDir, "error.settlement.json"),
16266
- join27(admitted.runDirectory, "error.settlement.json")
15900
+ join26(baseDir, "error.json"),
15901
+ join26(baseDir, "error.settlement.json"),
15902
+ join26(admitted.runDirectory, "error.settlement.json")
16267
15903
  ] : [
16268
- join27(baseDir, "error.settlement.json"),
16269
- join27(baseDir, "error.json")
15904
+ join26(baseDir, "error.settlement.json"),
15905
+ join26(baseDir, "error.json")
16270
15906
  ];
16271
15907
  const evidenceCandidates = underArtifacts ? [
16272
- join27(baseDir, "evidence.json"),
16273
- join27(baseDir, "evidence.settlement.json"),
16274
- join27(admitted.runDirectory, "evidence.settlement.json")
15908
+ join26(baseDir, "evidence.json"),
15909
+ join26(baseDir, "evidence.settlement.json"),
15910
+ join26(admitted.runDirectory, "evidence.settlement.json")
16275
15911
  ] : [
16276
- join27(baseDir, "evidence.settlement.json"),
16277
- join27(baseDir, "evidence.json")
15912
+ join26(baseDir, "evidence.settlement.json"),
15913
+ join26(baseDir, "evidence.json")
16278
15914
  ];
16279
15915
  const errorPayloadBase = {
16280
15916
  kind: "error",
@@ -16486,7 +16122,6 @@ var init_settlement = __esm({
16486
16122
  init_doctor_auditor();
16487
16123
  init_judge_auditor();
16488
16124
  init_known_failure();
16489
- init_reviewer_dispatch_rejection();
16490
16125
  init_run_lifecycle();
16491
16126
  init_compliance_transport();
16492
16127
  init_collector_ledger();
@@ -16563,17 +16198,17 @@ var init_seat_ticket_binding = __esm({
16563
16198
  });
16564
16199
 
16565
16200
  // src/session-identity.ts
16566
- import { mkdir as mkdir3, readFile as readFile18, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
16567
- import { dirname as dirname15, join as join28 } from "node:path";
16201
+ import { mkdir as mkdir3, readFile as readFile17, rename as rename2, writeFile as writeFile8 } from "node:fs/promises";
16202
+ import { dirname as dirname15, join as join27 } from "node:path";
16568
16203
  function createSessionIdentityAuthority(authority, sessionBindingFile) {
16569
- const bindingPath = (principal) => join28(authority.decode(principal).sessionDirectory, sessionBindingFile);
16204
+ const bindingPath = (principal) => join27(authority.decode(principal).sessionDirectory, sessionBindingFile);
16570
16205
  return {
16571
16206
  resolveSessionFile(principal) {
16572
16207
  return authority.decode(principal).sessionFile;
16573
16208
  },
16574
16209
  async load(principal) {
16575
16210
  try {
16576
- const value = JSON.parse(await readFile18(bindingPath(principal), "utf8"));
16211
+ const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
16577
16212
  if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
16578
16213
  throw new Error("durable session binding is invalid");
16579
16214
  }
@@ -16734,14 +16369,14 @@ var init_session_dialogue = __esm({
16734
16369
 
16735
16370
  // src/ticket-provenance.ts
16736
16371
  import { createHash as createHash7 } from "node:crypto";
16737
- import { readFile as readFile19 } from "node:fs/promises";
16738
- import { basename as basename8, dirname as dirname16, join as join29, resolve as resolve12 } from "node:path";
16372
+ import { readFile as readFile18 } from "node:fs/promises";
16373
+ import { basename as basename8, dirname as dirname16, join as join28, resolve as resolve12 } from "node:path";
16739
16374
  function dialogueSessionSourceRoots(home) {
16740
16375
  const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
16741
16376
  return [
16742
- join29(machineHome, ".claude", "projects"),
16743
- join29(machineHome, ".codex", "sessions"),
16744
- join29(machineHome, ".pi", "agent", "sessions")
16377
+ join28(machineHome, ".claude", "projects"),
16378
+ join28(machineHome, ".codex", "sessions"),
16379
+ join28(machineHome, ".pi", "agent", "sessions")
16745
16380
  ];
16746
16381
  }
16747
16382
  function isLedgerRoleSessionFile(absolute, home) {
@@ -16807,7 +16442,7 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
16807
16442
  const { recordFile } = resolveTicketProvenanceVolume(ticketNumber, cwd, home);
16808
16443
  let text;
16809
16444
  try {
16810
- text = await readFile19(recordFile, "utf8");
16445
+ text = await readFile18(recordFile, "utf8");
16811
16446
  } catch (error) {
16812
16447
  if (error.code === "ENOENT") {
16813
16448
  return { header: void 0, lines: [], unprojectedRaw: [], recordFile };
@@ -17205,9 +16840,9 @@ __export(case_dossier_delivery_exports, {
17205
16840
  loadCaseDossierReadingMaterial: () => loadCaseDossierReadingMaterial,
17206
16841
  projectCaseDossierPointerSection: () => projectCaseDossierPointerSection
17207
16842
  });
17208
- import { mkdtemp as mkdtemp2, readFile as readFile20, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
16843
+ import { mkdtemp as mkdtemp2, readFile as readFile19, rm as rm2, writeFile as writeFile9 } from "node:fs/promises";
17209
16844
  import { tmpdir as tmpdir2 } from "node:os";
17210
- import { join as join30 } from "node:path";
16845
+ import { join as join29 } from "node:path";
17211
16846
  async function projectCaseDossierPointerSection(input) {
17212
16847
  if (input.ticketNumber === void 0) {
17213
16848
  return [
@@ -17234,9 +16869,9 @@ async function deliverCaseDossierAsAttachment(input) {
17234
16869
  projectRoot: input.projectRoot,
17235
16870
  home: input.home
17236
16871
  });
17237
- const stagingDir = await mkdtemp2(join30(tmpdir2(), "ak-case-dossier-"));
16872
+ const stagingDir = await mkdtemp2(join29(tmpdir2(), "ak-case-dossier-"));
17238
16873
  try {
17239
- const stagingPath = join30(stagingDir, CASE_DOSSIER_ATTACH_FILE);
16874
+ const stagingPath = join29(stagingDir, CASE_DOSSIER_ATTACH_FILE);
17240
16875
  await writeFile9(stagingPath, `${section}
17241
16876
  `, "utf8");
17242
16877
  return await freezeAttachmentsIntoRun(
@@ -17249,7 +16884,7 @@ async function deliverCaseDossierAsAttachment(input) {
17249
16884
  }
17250
16885
  }
17251
16886
  async function loadCaseDossierReadingMaterial(runDirectory) {
17252
- const frozenPath = join30(
16887
+ const frozenPath = join29(
17253
16888
  runDirectory,
17254
16889
  "attachments",
17255
16890
  CASE_DOSSIER_ATTACH_KEY,
@@ -17257,7 +16892,7 @@ async function loadCaseDossierReadingMaterial(runDirectory) {
17257
16892
  );
17258
16893
  let section;
17259
16894
  try {
17260
- section = await readFile20(frozenPath, "utf8");
16895
+ section = await readFile19(frozenPath, "utf8");
17261
16896
  } catch (error) {
17262
16897
  if (error.code === "ENOENT") return void 0;
17263
16898
  throw error;
@@ -17280,14 +16915,14 @@ var init_case_dossier_delivery = __esm({
17280
16915
  });
17281
16916
 
17282
16917
  // src/host-transition-prior-native.ts
17283
- import { access as access4, readdir as readdir7 } from "node:fs/promises";
17284
- import { dirname as dirname17, join as join31 } from "node:path";
16918
+ import { access as access3, readdir as readdir7 } from "node:fs/promises";
16919
+ import { dirname as dirname17, join as join30 } from "node:path";
17285
16920
  function isEnoent3(error) {
17286
16921
  return typeof error === "object" && error !== null && error.code === "ENOENT";
17287
16922
  }
17288
16923
  async function listPiNativeRecordPaths(sessionFile) {
17289
16924
  try {
17290
- await access4(sessionFile);
16925
+ await access3(sessionFile);
17291
16926
  return [sessionFile];
17292
16927
  } catch (error) {
17293
16928
  if (isEnoent3(error)) return [];
@@ -17306,9 +16941,9 @@ async function listSitianRecordPaths(sessionParent) {
17306
16941
  const recordPaths = [];
17307
16942
  for (const entry of entries) {
17308
16943
  if (!entry.isDirectory()) continue;
17309
- const recordFile = join31(sessionRoot, entry.name, "records.jsonl");
16944
+ const recordFile = join30(sessionRoot, entry.name, "records.jsonl");
17310
16945
  try {
17311
- await access4(recordFile);
16946
+ await access3(recordFile);
17312
16947
  recordPaths.push(recordFile);
17313
16948
  } catch (error) {
17314
16949
  if (!isEnoent3(error)) throw error;
@@ -17376,7 +17011,7 @@ var init_public_run_credentials = __esm({
17376
17011
  import { constants as fsConstants2 } from "node:fs";
17377
17012
  import { randomUUID as randomUUID5 } from "node:crypto";
17378
17013
  import { lstat as lstat6, mkdir as mkdir4, open as open2 } from "node:fs/promises";
17379
- import { join as join32 } from "node:path";
17014
+ import { join as join31 } from "node:path";
17380
17015
  async function persistReturnedRunState(admitted, authority, options) {
17381
17016
  if (options?.lawful === true) {
17382
17017
  await markRunTerminal(admitted.runDirectory);
@@ -17491,7 +17126,7 @@ function jsonSafeReplacer() {
17491
17126
  };
17492
17127
  }
17493
17128
  async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
17494
- const filePath = join32(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
17129
+ const filePath = join31(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
17495
17130
  const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
17496
17131
  `;
17497
17132
  const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
@@ -17764,7 +17399,7 @@ var init_auto_resume = __esm({
17764
17399
  // src/public-cli/post-admission.ts
17765
17400
  import { randomUUID as randomUUID6 } from "node:crypto";
17766
17401
  import { writeFile as writeFile10 } from "node:fs/promises";
17767
- import { isAbsolute as isAbsolute8, join as join33, resolve as resolve13 } from "node:path";
17402
+ import { isAbsolute as isAbsolute8, join as join32, resolve as resolve13 } from "node:path";
17768
17403
  function describeCaughtError(error) {
17769
17404
  if (error instanceof Error) {
17770
17405
  const code = error.code;
@@ -17803,7 +17438,7 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
17803
17438
  try {
17804
17439
  const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
17805
17440
  await writeFile10(
17806
- join33(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
17441
+ join32(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
17807
17442
  `${JSON.stringify({ version: 1, ...payload }, null, 2)}
17808
17443
  `,
17809
17444
  { encoding: "utf8", flag: "wx" }
@@ -17916,7 +17551,7 @@ async function dispatchPostAdmissionTurn(input) {
17916
17551
  const rows = await readRecordedSubmissionRows(
17917
17552
  admitted.projectRoot,
17918
17553
  admitted.runId,
17919
- { home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join33(admitted.runDirectory, "session", "session.jsonl") }
17554
+ { home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join32(admitted.runDirectory, "session", "session.jsonl") }
17920
17555
  );
17921
17556
  const asserted = rows.filter((row) => row.kind === "accepted" && row.role === admitted.role).map((row) => row.accepted).find((payload) => {
17922
17557
  if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return false;
@@ -18007,7 +17642,6 @@ async function dispatchPostAdmissionTurn(input) {
18007
17642
  };
18008
17643
  }
18009
17644
  await clearTypedProviderHttpObservation(admitted.runDirectory);
18010
- await clearReviewerDispatchRejection(admitted.runDirectory);
18011
17645
  if (adapters.beforeDispatch !== void 0) {
18012
17646
  try {
18013
17647
  await adapters.beforeDispatch(admitted, lease);
@@ -18076,7 +17710,7 @@ async function dispatchPostAdmissionTurn(input) {
18076
17710
  let stderrLogWriteFailure;
18077
17711
  try {
18078
17712
  await writeFile10(
18079
- join33(admitted.runDirectory, "stderr.log"),
17713
+ join32(admitted.runDirectory, "stderr.log"),
18080
17714
  result.stderr,
18081
17715
  "utf8"
18082
17716
  );
@@ -18326,7 +17960,7 @@ async function dispatchAfterWriterLease(input) {
18326
17960
  }
18327
17961
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
18328
17962
  const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
18329
- return pathContainedIn(join33(runDirectory, "attachments"), absolute);
17963
+ return pathContainedIn(join32(runDirectory, "attachments"), absolute);
18330
17964
  }
18331
17965
  async function prepareSummonsResumeMaterials(runDirectory, summons) {
18332
17966
  if (summons === void 0) return void 0;
@@ -18642,7 +18276,6 @@ var init_post_admission = __esm({
18642
18276
  init_public_run_credentials();
18643
18277
  init_run_lifecycle();
18644
18278
  init_activation_ledger_topology();
18645
- init_reviewer_dispatch_rejection();
18646
18279
  init_settlement();
18647
18280
  init_terminal();
18648
18281
  init_auto_resume();
@@ -20100,7 +19733,7 @@ __export(public_role_summons_exports, {
20100
19733
  summonPublicRole: () => summonPublicRole
20101
19734
  });
20102
19735
  import { existsSync as existsSync10 } from "node:fs";
20103
- import { join as join34 } from "node:path";
19736
+ import { join as join33 } from "node:path";
20104
19737
  function createCapturingIo() {
20105
19738
  const chunks = [];
20106
19739
  return {
@@ -20123,7 +19756,7 @@ function parentDir(path) {
20123
19756
  function walkPackageRoot(start) {
20124
19757
  let dir = start;
20125
19758
  for (let i = 0; i < 12; i += 1) {
20126
- if (existsSync10(join34(dir, "package.json")) && existsSync10(join34(dir, "souls"))) {
19759
+ if (existsSync10(join33(dir, "package.json")) && existsSync10(join33(dir, "souls"))) {
20127
19760
  return dir;
20128
19761
  }
20129
19762
  const parent = parentDir(dir);
@@ -20234,7 +19867,7 @@ async function createSummonEnv(options, afterHost) {
20234
19867
  async function summonPublicRole(options) {
20235
19868
  const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
20236
19869
  const home = await resolveSummonHome(options);
20237
- const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join34(home, ".pi", "agent");
19870
+ const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join33(home, ".pi", "agent");
20238
19871
  const {
20239
19872
  loadCredentialProviders: loadCredentialProviders2,
20240
19873
  loadPublicCliConfig: loadPublicCliConfig2,
@@ -20623,7 +20256,7 @@ var init_doctor_auditor = __esm({
20623
20256
 
20624
20257
  // src/archivist-record-topology.ts
20625
20258
  import { createHash as createHash8 } from "node:crypto";
20626
- import { join as join35 } from "node:path";
20259
+ import { join as join34 } from "node:path";
20627
20260
  function resolveNavigatorWorkSubjectPlacement(input) {
20628
20261
  let ledgerHome;
20629
20262
  if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
@@ -20636,7 +20269,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
20636
20269
  const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
20637
20270
  return {
20638
20271
  ledgerHome,
20639
- sessionDir: join35(
20272
+ sessionDir: join34(
20640
20273
  activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
20641
20274
  NAVIGATOR_RECORD_KIND,
20642
20275
  digest
@@ -20676,11 +20309,11 @@ import {
20676
20309
  statSync as statSync3,
20677
20310
  writeFileSync as writeFileSync2
20678
20311
  } from "node:fs";
20679
- import { dirname as dirname18, resolve as resolve14, join as join36 } from "node:path";
20312
+ import { dirname as dirname18, resolve as resolve14, join as join35 } from "node:path";
20680
20313
  import { StringDecoder } from "node:string_decoder";
20681
20314
  import { SessionManager } from "@earendil-works/pi-coding-agent";
20682
20315
  function readCurrentSession(sessionDir) {
20683
- const ledger = join36(sessionDir, CURRENT_SESSION_LEDGER);
20316
+ const ledger = join35(sessionDir, CURRENT_SESSION_LEDGER);
20684
20317
  try {
20685
20318
  const value = JSON.parse(readFileSync4(ledger, "utf8"));
20686
20319
  if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
@@ -20695,7 +20328,7 @@ function readCurrentSession(sessionDir) {
20695
20328
  }
20696
20329
  }
20697
20330
  function writeCurrentSession(sessionDir, sessionFile) {
20698
- const ledger = join36(sessionDir, CURRENT_SESSION_LEDGER);
20331
+ const ledger = join35(sessionDir, CURRENT_SESSION_LEDGER);
20699
20332
  try {
20700
20333
  writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
20701
20334
  `, { flag: "wx" });
@@ -20711,7 +20344,7 @@ function isCurrentSessionClaimRace(error) {
20711
20344
  return errnoCode(error.cause) === "EEXIST";
20712
20345
  }
20713
20346
  function currentSessionLedgerPath(sessionDir) {
20714
- return join36(sessionDir, CURRENT_SESSION_LEDGER);
20347
+ return join35(sessionDir, CURRENT_SESSION_LEDGER);
20715
20348
  }
20716
20349
  function readBoundedSessionHeader(filePath) {
20717
20350
  const fd = openSync(filePath, "r");
@@ -20798,7 +20431,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
20798
20431
  const matched = [];
20799
20432
  for (const name of names) {
20800
20433
  if (!name.endsWith(".jsonl")) continue;
20801
- const filePath = join36(absoluteSessionDir, name);
20434
+ const filePath = join35(absoluteSessionDir, name);
20802
20435
  let st;
20803
20436
  try {
20804
20437
  st = statSync3(filePath);
@@ -20910,7 +20543,7 @@ function createRecordSessionOpen(options) {
20910
20543
  if (!physicallyContainedIn(ledgerHome, parentResolved)) {
20911
20544
  throw new Error("Durable record ownership requires a parent session inside the ledger home");
20912
20545
  }
20913
- sessionDir = join36(dirname18(parentResolved), options.kind);
20546
+ sessionDir = join35(dirname18(parentResolved), options.kind);
20914
20547
  parentSession = parentFile;
20915
20548
  mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
20916
20549
  }
@@ -20959,7 +20592,7 @@ function createRecordSession(options) {
20959
20592
  return createRecordSessionOpen(options).session;
20960
20593
  }
20961
20594
  function bookDirectOfficerRunPointer(options) {
20962
- const nest = join36(dirname18(options.parentSessionFile), "auditor-roles");
20595
+ const nest = join35(dirname18(options.parentSessionFile), "auditor-roles");
20963
20596
  mkdirSync2(nest, { recursive: true });
20964
20597
  const pointer = {
20965
20598
  version: 1,
@@ -20969,7 +20602,7 @@ function bookDirectOfficerRunPointer(options) {
20969
20602
  ...options.runDirectory !== void 0 && options.runDirectory.trim() !== "" ? { runDirectory: options.runDirectory } : {}
20970
20603
  };
20971
20604
  writeFileSync2(
20972
- join36(nest, `${options.officer}.pointer.json`),
20605
+ join35(nest, `${options.officer}.pointer.json`),
20973
20606
  `${JSON.stringify(pointer)}
20974
20607
  `,
20975
20608
  "utf8"
@@ -20995,7 +20628,7 @@ var init_archivist_record_entry = __esm({
20995
20628
  import { randomUUID as randomUUID10 } from "node:crypto";
20996
20629
 
20997
20630
  // src/role-runtime-dependencies.ts
20998
- import { readFile as readFile23 } from "node:fs/promises";
20631
+ import { readFile as readFile22 } from "node:fs/promises";
20999
20632
  import { fileURLToPath as fileURLToPath2 } from "node:url";
21000
20633
 
21001
20634
  // src/canonical-skill-binding.ts
@@ -22037,7 +21670,7 @@ ${helpContext}
22037
21670
  // src/navigator-work-context.ts
22038
21671
  init_doctor_evidence();
22039
21672
  init_host_contracts();
22040
- import { readFile as readFile21 } from "node:fs/promises";
21673
+ import { readFile as readFile20 } from "node:fs/promises";
22041
21674
  import { resolve as resolve16 } from "node:path";
22042
21675
  init_notary_source_run();
22043
21676
  init_packaged_role_registry();
@@ -22050,7 +21683,7 @@ function navigatorInputReference(getFlag, role) {
22050
21683
  }
22051
21684
  async function loadNavigatorWorkContext(options) {
22052
21685
  const reference = navigatorInputReference(options.getFlag, options.role);
22053
- const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile21(reference, "utf8");
21686
+ const input = reference === void 0 || options.role === "doctor" || options.role === "notary" ? void 0 : await readFile20(reference, "utf8");
22054
21687
  const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
22055
21688
  let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
22056
21689
  let subject = input ?? `work subject: ${subjectKey}`;
@@ -22107,7 +21740,7 @@ async function loadNavigatorWorkContext(options) {
22107
21740
  let authorityMaterial;
22108
21741
  for (const path of authorityFiles) {
22109
21742
  try {
22110
- const content = await readFile21(path, "utf8");
21743
+ const content = await readFile20(path, "utf8");
22111
21744
  if (content.trim() !== "") {
22112
21745
  authorityMaterial = content;
22113
21746
  break;
@@ -22166,7 +21799,7 @@ init_sitian_facade();
22166
21799
  init_submission_ledger();
22167
21800
  init_collector_ledger();
22168
21801
  import { readFileSync as readFileSync6, writeSync as writeSync4 } from "node:fs";
22169
- import { join as join40 } from "node:path";
21802
+ import { join as join39 } from "node:path";
22170
21803
  import { Value as Value4 } from "typebox/value";
22171
21804
 
22172
21805
  // src/activation-trace.ts
@@ -22724,16 +22357,16 @@ init_collector_evidence();
22724
22357
  init_collector_github();
22725
22358
 
22726
22359
  // src/collector-handbook.ts
22727
- import { readFile as readFile22 } from "node:fs/promises";
22728
- import { join as join39, sep as sep5 } from "node:path";
22360
+ import { readFile as readFile21 } from "node:fs/promises";
22361
+ import { join as join38, sep as sep5 } from "node:path";
22729
22362
 
22730
22363
  // src/atomic-write.ts
22731
22364
  import { randomUUID as randomUUID7 } from "node:crypto";
22732
22365
  import { rename as rename3, rm as rm3, writeFile as writeFile11 } from "node:fs/promises";
22733
- import { dirname as dirname22, join as join38 } from "node:path";
22366
+ import { dirname as dirname22, join as join37 } from "node:path";
22734
22367
  async function writeFileAtomically(destination, contents) {
22735
22368
  const parent = dirname22(destination);
22736
- const temporary = join38(parent, `.atomic-write-${randomUUID7()}.tmp`);
22369
+ const temporary = join37(parent, `.atomic-write-${randomUUID7()}.tmp`);
22737
22370
  try {
22738
22371
  await writeFile11(temporary, contents);
22739
22372
  await rename3(temporary, destination);
@@ -22859,7 +22492,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
22859
22492
  throw new Error(`\u901A\u8FDB\u53F8\u624B\u518C\u62D2\u7EDD\u4E0D\u5B89\u5168 bookKey ${JSON.stringify(bookKey)}`);
22860
22493
  }
22861
22494
  const ledgerHome = resolveActivationLedgerHomeForPath(sessionPath);
22862
- const root = join39(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
22495
+ const root = join38(activationBookDirectory(ledgerHome, bookKey), "collector-handbook");
22863
22496
  return { ledgerHome, bookKey, root };
22864
22497
  }
22865
22498
  function collectorHandbookRepoFileName(repositoryCanonical) {
@@ -22871,9 +22504,9 @@ function collectorHandbookRepoFileName(repositoryCanonical) {
22871
22504
  return `${repositoryCanonical.replaceAll("/", "__")}.md`;
22872
22505
  }
22873
22506
  function createCollectorHandbookStore(input) {
22874
- const generalPath = join39(input.handbookRoot, "general.md");
22875
- const repoDir = join39(input.handbookRoot, "repos");
22876
- const repoPath = join39(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
22507
+ const generalPath = join38(input.handbookRoot, "general.md");
22508
+ const repoDir = join38(input.handbookRoot, "repos");
22509
+ const repoPath = join38(repoDir, collectorHandbookRepoFileName(input.repositoryCanonical));
22877
22510
  const assertHandbookBudget = (body, label) => {
22878
22511
  const byteLength = Buffer.byteLength(body, "utf8");
22879
22512
  if (byteLength > COLLECTOR_HANDBOOK_MAX_BYTES) {
@@ -22887,7 +22520,7 @@ function createCollectorHandbookStore(input) {
22887
22520
  ensureRealDirectoryTree(input.ledgerHome, parentDir2);
22888
22521
  assertLedgerFileInsideHome(path, input.ledgerHome);
22889
22522
  try {
22890
- const body = await readFile22(path, "utf8");
22523
+ const body = await readFile21(path, "utf8");
22891
22524
  assertHandbookBudget(body, "\u6B63\u6587");
22892
22525
  return body;
22893
22526
  } catch (error) {
@@ -24180,14 +23813,20 @@ ${soul}
24180
23813
  // src/reviewer-role.ts
24181
23814
  init_open_tool_schema();
24182
23815
  init_terminating_infrastructure();
24183
- init_reviewer_pinned_git();
24184
23816
  init_reviewer_output();
24185
23817
  import { Type as Type24 } from "typebox";
24186
23818
  var reviewerAmendmentsSchema = Type24.Object({
24187
- standards: Type24.Optional(Type24.String({ description: "\u6807\u51C6\u8F74\u5F39\u7AE0\u6B63\u6587" })),
24188
- spec: Type24.Optional(Type24.String({ description: "\u89C4\u683C\u8F74\u5F39\u7AE0\u6B63\u6587" }))
24189
- }, { additionalProperties: true, description: "\u9010\u8F74\u5F39\u7AE0\u6B63\u6587\uFF1B\u65E0\u5F39\u7AE0\u7684\u8F74\u53EF\u7701\u7565\u3002" });
24190
- var REVIEWER_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8";
23819
+ completeness: Type24.Optional(Type24.String({
23820
+ description: "completeness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
23821
+ })),
23822
+ correctness: Type24.Optional(Type24.String({
23823
+ description: "correctness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
23824
+ }))
23825
+ }, {
23826
+ additionalProperties: true,
23827
+ description: "\u6240\u9009 lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u672A\u9009 lens \u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens \u5B57\u6BB5\u3002\u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002"
23828
+ });
23829
+ var REVIEWER_STATUS_DESCRIPTION = "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
24191
23830
  var reviewerOutputVariants = Type24.Union([
24192
23831
  Type24.Object({
24193
23832
  status: Type24.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
@@ -24195,7 +23834,7 @@ var reviewerOutputVariants = Type24.Union([
24195
23834
  }, { additionalProperties: false }),
24196
23835
  Type24.Object({
24197
23836
  status: Type24.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
24198
- diagnostic: Type24.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E" }),
23837
+ diagnostic: Type24.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
24199
23838
  amendments: Type24.Optional(reviewerAmendmentsSchema)
24200
23839
  }, { additionalProperties: false })
24201
23840
  ]);
@@ -24212,15 +23851,15 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
24212
23851
  soul = (await dependencies.loadSoul()).trim();
24213
23852
  if (!soul) throw new Error("Reviewer soul is empty");
24214
23853
  fixedBaseRevision = admitted.baseRevision;
24215
- const loaded = await dependencies.loadCanonicalSkillBinding("code-review");
24216
- if (loaded.name !== "code-review") throw new Error("Canonical Skill binding loader returned tdd for code-review");
23854
+ const loaded = await dependencies.loadCanonicalSkillBinding("ak-cross-m-review");
23855
+ if (loaded.name !== "ak-cross-m-review") throw new Error("Canonical Skill binding loader returned tdd for ak-cross-m-review");
24217
23856
  binding = loaded;
24218
23857
  if (!registered) {
24219
23858
  registered = true;
24220
23859
  pi.registerTool({
24221
23860
  name: REVIEWER_OUTPUT_TOOL_NAME,
24222
23861
  label: "\u5FA1\u53F2\u53F0\u8F93\u51FA",
24223
- description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002\u672C\u5E2D\u81EA\u8C03 code-review skill\u3002",
23862
+ description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002\u672C\u5E2D\u81EA\u8C03 ak-cross-m-review skill\u3002",
24224
23863
  promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
24225
23864
  parameters: reviewerOutputSchema,
24226
23865
  async execute(_id, parameters) {
@@ -24766,7 +24405,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
24766
24405
  const loaded = await dependencies.loadCanonicalSkillBinding("tdd");
24767
24406
  if (loaded.name !== "tdd") {
24768
24407
  throw new Error(
24769
- "Canonical Skill binding loader returned code-review for tdd"
24408
+ "Canonical Skill binding loader returned ak-cross-m-review for tdd"
24770
24409
  );
24771
24410
  }
24772
24411
  binding = loaded;
@@ -24946,16 +24585,16 @@ var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
24946
24585
  })
24947
24586
  }),
24948
24587
  Object.freeze({
24949
- name: "ak-review-scope-keys",
24588
+ name: "ak-review-lens",
24950
24589
  definition: Object.freeze({
24951
- description: "Optional comma-separated exact class keys limiting Reviewer scope",
24590
+ description: "Caller-selected single review lens: completeness or correctness",
24952
24591
  type: "string"
24953
24592
  })
24954
24593
  }),
24955
24594
  Object.freeze({
24956
24595
  name: "ak-review-authority-refs",
24957
24596
  definition: Object.freeze({
24958
- description: "JSON array of durable authority references for Spec-axis material only",
24597
+ description: "JSON array of durable authority references projected as Skill --authority inputs",
24959
24598
  type: "string"
24960
24599
  })
24961
24600
  }),
@@ -24987,18 +24626,6 @@ var STATION_CHILD_FLAG = Object.freeze({
24987
24626
  })
24988
24627
  });
24989
24628
  function decodeReviewerAdmittedInputs(getFlag) {
24990
- let reviewScopeKeys;
24991
- const rawScopeKeys = getFlag("ak-review-scope-keys");
24992
- if (rawScopeKeys !== void 0) {
24993
- if (typeof rawScopeKeys !== "string" || rawScopeKeys.length === 0) {
24994
- throw new Error("Reviewer scope keys must be a nonempty comma-separated string");
24995
- }
24996
- const parsed = rawScopeKeys.split(",");
24997
- if (parsed.some((key) => key.trim().length === 0) || new Set(parsed).size !== parsed.length) {
24998
- throw new Error("Reviewer scope keys contain a blank or exact duplicate key");
24999
- }
25000
- reviewScopeKeys = Object.freeze(parsed);
25001
- }
25002
24629
  let authorityRefs;
25003
24630
  const rawAuthorityRefs = getFlag("ak-review-authority-refs");
25004
24631
  if (rawAuthorityRefs !== void 0) {
@@ -25027,9 +24654,13 @@ function decodeReviewerAdmittedInputs(getFlag) {
25027
24654
  if (typeof baseRevision !== "string" || !baseRevision.trim()) {
25028
24655
  throw new Error("Reviewer role requires --ak-review-base");
25029
24656
  }
24657
+ const rawLens = getFlag("ak-review-lens");
24658
+ if (rawLens !== "completeness" && rawLens !== "correctness") {
24659
+ throw new Error("Reviewer role requires --ak-review-lens completeness|correctness");
24660
+ }
25030
24661
  return Object.freeze({
25031
24662
  baseRevision,
25032
- ...reviewScopeKeys === void 0 ? {} : { reviewScopeKeys },
24663
+ lens: rawLens,
25033
24664
  ...authorityRefs === void 0 ? {} : { authorityRefs },
25034
24665
  ...ticketNumber === void 0 ? {} : { ticketNumber }
25035
24666
  });
@@ -25344,7 +24975,7 @@ function readDiaristTicketAssertion(submitted) {
25344
24975
  function readRoleRunCoordinates(ctx, label) {
25345
24976
  const runDirectory = runDirectoryFromHostContext(ctx);
25346
24977
  if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
25347
- const admittedPath = join40(runDirectory, "admitted-request.json");
24978
+ const admittedPath = join39(runDirectory, "admitted-request.json");
25348
24979
  const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
25349
24980
  if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
25350
24981
  throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
@@ -25981,10 +25612,6 @@ function createRoleRuntimeExtension(dependencies) {
25981
25612
  }
25982
25613
  return dependencies.loadReviewerSoul();
25983
25614
  },
25984
- async createPinnedGitReader() {
25985
- if (dependencies.createReviewerPinnedGitReader === void 0) throw new Error("Reviewer runtime dependencies are not configured");
25986
- return dependencies.createReviewerPinnedGitReader();
25987
- },
25988
25615
  async loadCanonicalSkillBinding(name) {
25989
25616
  if (dependencies.loadCanonicalSkillBinding === void 0) {
25990
25617
  throw new Error("Reviewer runtime dependencies are not configured");
@@ -26424,7 +26051,6 @@ function createRoleRuntimeExtension(dependencies) {
26424
26051
  }
26425
26052
 
26426
26053
  // src/role-runtime-dependencies.ts
26427
- init_reviewer_pinned_git();
26428
26054
  init_auditor_soul();
26429
26055
  init_session_opening_materials();
26430
26056
  var navigatorRoutePlaybookPath = fileURLToPath2(
@@ -26440,13 +26066,12 @@ function createRoleRuntimeDependencies(packageRoot) {
26440
26066
  packageRoot,
26441
26067
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
26442
26068
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
26443
- loadFixPacket: (path) => readFile23(path, "utf8"),
26069
+ loadFixPacket: (path) => readFile22(path, "utf8"),
26444
26070
  loadCoderSoul: () => loadMainRoleSessionMaterials("coder"),
26445
- loadCoderTask: (path) => readFile23(path, "utf8"),
26071
+ loadCoderTask: (path) => readFile22(path, "utf8"),
26446
26072
  loadReviewerSoul: () => loadMainRoleSessionMaterials("reviewer"),
26447
- createReviewerPinnedGitReader: () => createReviewerPinnedGitReader(),
26448
26073
  loadCollectorSoul: () => loadMainRoleSessionMaterials("collector"),
26449
- loadCollectorHandbookSeed: () => readFile23(collectorHandbookSeedPath, "utf8"),
26074
+ loadCollectorHandbookSeed: () => readFile22(collectorHandbookSeedPath, "utf8"),
26450
26075
  createCollectorTransport: () => createGhCollectorGitHubTransport(),
26451
26076
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
26452
26077
  loadDoctorCase,
@@ -26461,13 +26086,13 @@ function createRoleRuntimeDependencies(packageRoot) {
26461
26086
  loadSecretariatSoul: () => loadMainRoleSessionMaterials("secretariat"),
26462
26087
  loadNotarySourceRun: loadNotarySourceRunLocator,
26463
26088
  loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
26464
- loadMergerInput: async (path) => JSON.parse(await readFile23(path, "utf8")),
26089
+ loadMergerInput: async (path) => JSON.parse(await readFile22(path, "utf8")),
26465
26090
  async loadCanonicalSkillBinding(name) {
26466
26091
  if (name === "tdd") {
26467
26092
  return loadPackagedCanonicalSkillBinding(packageRoot, "tdd");
26468
26093
  }
26469
- if (name === "code-review") {
26470
- return loadPackagedCanonicalSkillBinding(packageRoot, "code-review");
26094
+ if (name === "ak-cross-m-review") {
26095
+ return loadPackagedCanonicalSkillBinding(packageRoot, "ak-cross-m-review");
26471
26096
  }
26472
26097
  return loadCanonicalSkillBinding(name);
26473
26098
  },
@@ -26487,7 +26112,7 @@ function createRoleRuntimeDependencies(packageRoot) {
26487
26112
  authority: options.authority,
26488
26113
  invocationId: options.invocationId,
26489
26114
  loadSoul: () => loadMainRoleSessionMaterials("navigator"),
26490
- loadRoutePlaybook: () => readFile23(navigatorRoutePlaybookPath, "utf8"),
26115
+ loadRoutePlaybook: () => readFile22(navigatorRoutePlaybookPath, "utf8"),
26491
26116
  loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
26492
26117
  createSession: navigatorSessionFactory,
26493
26118
  ...options.contextError === void 0 ? {} : { contextError: options.contextError },
@@ -26499,9 +26124,9 @@ function createRoleRuntimeDependencies(packageRoot) {
26499
26124
  // src/role-envelope.ts
26500
26125
  init_engine_detour();
26501
26126
  import { randomUUID as randomUUID8 } from "node:crypto";
26502
- import { mkdir as mkdir5, readFile as readFile24, writeFile as writeFile12 } from "node:fs/promises";
26127
+ import { mkdir as mkdir5, readFile as readFile23, writeFile as writeFile12 } from "node:fs/promises";
26503
26128
  import { createServer } from "node:net";
26504
- import { basename as basename9, dirname as dirname23, join as join41 } from "node:path";
26129
+ import { basename as basename9, dirname as dirname23, join as join40 } from "node:path";
26505
26130
  import { fileURLToPath as fileURLToPath3 } from "node:url";
26506
26131
 
26507
26132
  // src/gatekeeper-pass-envelope.ts
@@ -26649,10 +26274,10 @@ async function prepareRoleEnvelope(options) {
26649
26274
  for (const method of request.methods) {
26650
26275
  if (method.kind !== "skill") continue;
26651
26276
  const name = basename9(dirname23(method.path));
26652
- const raw = await readFile24(method.path, "utf8");
26277
+ const raw = await readFile23(method.path, "utf8");
26653
26278
  methodSkills.set(name, { path: method.path, body: stripSkillFrontmatter(raw).trim() });
26654
26279
  }
26655
- let sessionFile = options.sessionFile ?? join41(request.runDirectory, "session", "session.jsonl");
26280
+ let sessionFile = options.sessionFile ?? join40(request.runDirectory, "session", "session.jsonl");
26656
26281
  await mkdir5(dirname23(sessionFile), { recursive: true });
26657
26282
  if (request.continuation.kind !== "resume") {
26658
26283
  try {
@@ -27059,7 +26684,7 @@ async function prepareRoleEnvelope(options) {
27059
26684
  message: { role: "user", content: prompt }
27060
26685
  });
27061
26686
  }
27062
- const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile24(path, "utf8")))).join("\n\n");
26687
+ const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile23(path, "utf8")))).join("\n\n");
27063
26688
  const promptResults = await emit("before_agent_start", {
27064
26689
  prompt,
27065
26690
  systemPrompt: methodPrompt,
@@ -27120,7 +26745,7 @@ async function prepareRoleEnvelope(options) {
27120
26745
  init_session_identity();
27121
26746
 
27122
26747
  // src/headless-host/description.ts
27123
- import { join as join42 } from "node:path";
26748
+ import { join as join41 } from "node:path";
27124
26749
  function isClaudePrintDescription(description) {
27125
26750
  return description.protocol === "claude-print";
27126
26751
  }
@@ -27128,7 +26753,7 @@ function isCodexExecDescription(description) {
27128
26753
  return description.protocol === "codex-exec";
27129
26754
  }
27130
26755
  function resolveHeadlessBinary(description, operatorHome) {
27131
- return join42(operatorHome, ...description.binaryFromHome);
26756
+ return join41(operatorHome, ...description.binaryFromHome);
27132
26757
  }
27133
26758
  function headlessTurnArgs(options) {
27134
26759
  const { description } = options;
@@ -27384,7 +27009,7 @@ import { spawn as spawn4, spawnSync } from "node:child_process";
27384
27009
  import { randomUUID as randomUUID9 } from "node:crypto";
27385
27010
  import { existsSync as existsSync13 } from "node:fs";
27386
27011
  import { writeFile as writeFile13 } from "node:fs/promises";
27387
- import { dirname as dirname24, isAbsolute as isAbsolute11, join as join43, resolve as resolve20 } from "node:path";
27012
+ import { dirname as dirname24, isAbsolute as isAbsolute11, join as join42, resolve as resolve20 } from "node:path";
27388
27013
 
27389
27014
  // src/external-host-turn-loop.ts
27390
27015
  init_host_contracts();
@@ -27603,7 +27228,7 @@ function formatCodexFailurePayload(payload) {
27603
27228
  function cwdIsGitWorkTree(cwd) {
27604
27229
  let dir = cwd;
27605
27230
  for (; ; ) {
27606
- if (existsSync13(join43(dir, ".git"))) return true;
27231
+ if (existsSync13(join42(dir, ".git"))) return true;
27607
27232
  const parent = dirname24(dir);
27608
27233
  if (parent === dir) return false;
27609
27234
  dir = parent;
@@ -27810,17 +27435,17 @@ function createHeadlessRoleTurnHost(config) {
27810
27435
  await config.sessionIdentity.bind(request.principal, sessionId);
27811
27436
  }
27812
27437
  const env = { ...process.env, ...config.env ?? {} };
27813
- const systemPromptPath = join43(request.runDirectory, "headless-system-prompt.txt");
27438
+ const systemPromptPath = join42(request.runDirectory, "headless-system-prompt.txt");
27814
27439
  await writeFile13(systemPromptPath, systemPrompt, "utf8");
27815
27440
  let mcpConfigPath;
27816
27441
  let outputSchemaPath;
27817
27442
  if (codex) {
27818
- outputSchemaPath = join43(request.runDirectory, "headless-output-schema.json");
27443
+ outputSchemaPath = join42(request.runDirectory, "headless-output-schema.json");
27819
27444
  const closed = closeJsonSchemaForCodex(prepared.jsonSchema);
27820
27445
  await writeFile13(outputSchemaPath, `${JSON.stringify(closed, null, 2)}
27821
27446
  `, "utf8");
27822
27447
  } else {
27823
- mcpConfigPath = join43(request.runDirectory, "headless-mcp-config.json");
27448
+ mcpConfigPath = join42(request.runDirectory, "headless-mcp-config.json");
27824
27449
  await writeFile13(
27825
27450
  mcpConfigPath,
27826
27451
  `${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}