@akagilnc/pi-workflow-roles 0.1.4905 → 0.1.4911

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.
@@ -3725,8 +3725,6 @@ var init_packaged_role_registry = __esm({
3725
3725
  settleMethod: "ak-cross-m-review",
3726
3726
  /** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
3727
3727
  parallelLenses: true,
3728
- /** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
3729
- freshExecutionCopy: true,
3730
3728
  phases: [null],
3731
3729
  bareCommand: false,
3732
3730
  outputTool: REVIEWER_OUTPUT_TOOL_NAME,
@@ -4241,9 +4239,9 @@ async function readRunTerminalArtifact(runDirectory) {
4241
4239
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
4242
4240
  consider(await readTerminalArtifactAtPath(join5(artifactsDir, file), file));
4243
4241
  }
4244
- for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
4242
+ for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
4245
4243
  consider(
4246
- await readTerminalArtifactAtPath(join5(runDirectory, relative4), "error.json")
4244
+ await readTerminalArtifactAtPath(join5(runDirectory, relative3), "error.json")
4247
4245
  );
4248
4246
  }
4249
4247
  for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
@@ -10603,11 +10601,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
10603
10601
  `${flag} requires a comma-separated list of N or book:N`
10604
10602
  );
10605
10603
  }
10606
- const sep7 = trimmed.lastIndexOf(":");
10607
- if (sep7 > 0) {
10608
- const rhs = trimmed.slice(sep7 + 1);
10604
+ const sep6 = trimmed.lastIndexOf(":");
10605
+ if (sep6 > 0) {
10606
+ const rhs = trimmed.slice(sep6 + 1);
10609
10607
  if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
10610
- const bookKey = trimmed.slice(0, sep7);
10608
+ const bookKey = trimmed.slice(0, sep6);
10611
10609
  if (bookKey.trim() === "") {
10612
10610
  throw new CliUsageError(
10613
10611
  `${flag} book:N requires a non-empty book key, got ${raw}`
@@ -14923,8 +14921,8 @@ async function clearOppositeTerminalArtifactFace(runDirectory) {
14923
14921
  for (const file of RUN_TERMINAL_ARTIFACT_FILES) {
14924
14922
  await removeFaceIfPresent(join26(artifactsDir, file));
14925
14923
  }
14926
- for (const relative4 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
14927
- await removeFaceIfPresent(join26(runDirectory, relative4));
14924
+ for (const relative3 of RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS) {
14925
+ await removeFaceIfPresent(join26(runDirectory, relative3));
14928
14926
  }
14929
14927
  for (const path of await listSeamOwnedUniqueErrorFacePaths(runDirectory)) {
14930
14928
  await removeFaceIfPresent(path);
@@ -17731,7 +17729,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
17731
17729
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
17732
17730
  };
17733
17731
  }
17734
- function roleTurnOptions(env, admitted, continuation, extra) {
17732
+ function roleTurnOptions(env, admitted, continuation) {
17735
17733
  const correlationId = admitted.correlationId ?? env.correlationId;
17736
17734
  return {
17737
17735
  packageRoot: env.packageRoot,
@@ -17742,7 +17740,6 @@ function roleTurnOptions(env, admitted, continuation, extra) {
17742
17740
  ...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
17743
17741
  ...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
17744
17742
  continuation,
17745
- ...extra?.cwd === void 0 ? {} : { cwd: extra.cwd },
17746
17743
  ...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
17747
17744
  };
17748
17745
  }
@@ -17802,8 +17799,7 @@ async function runPostAdmissionSeatResume(input) {
17802
17799
  }
17803
17800
  adapters = prepared.adapters;
17804
17801
  }
17805
- let env = input.env;
17806
- let preparedCleanup;
17802
+ const env = input.env;
17807
17803
  const buildRequestAfterLease = async () => {
17808
17804
  let openCourtAttemptId;
17809
17805
  const admittedForBuild = loaded.admitted;
@@ -17858,11 +17854,6 @@ async function runPostAdmissionSeatResume(input) {
17858
17854
  return turnRequest;
17859
17855
  };
17860
17856
  try {
17861
- if (input.afterAdmittedPrepare !== void 0) {
17862
- const prepared = await input.afterAdmittedPrepare(loaded.admitted);
17863
- if (prepared.env !== void 0) env = prepared.env;
17864
- preparedCleanup = prepared.cleanup;
17865
- }
17866
17857
  if (env.stationChild === true) {
17867
17858
  let firstTurn;
17868
17859
  const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
@@ -17939,10 +17930,6 @@ async function runPostAdmissionSeatResume(input) {
17939
17930
  return { exitCode: 2 };
17940
17931
  }
17941
17932
  throw error;
17942
- } finally {
17943
- if (preparedCleanup !== void 0) {
17944
- await preparedCleanup();
17945
- }
17946
17933
  }
17947
17934
  }
17948
17935
  async function runPostAdmissionOneShot(input) {
@@ -18100,7 +18087,7 @@ var init_seat_ticket_binding = __esm({
18100
18087
 
18101
18088
  // src/public-cli/turn-request.ts
18102
18089
  function projectRoleTurnRequest(admitted, roleDetails, options) {
18103
- const cwd = options.cwd ?? admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
18090
+ const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
18104
18091
  if (cwd === void 0) throw new Error("admitted invocation missing working directory");
18105
18092
  if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
18106
18093
  return {
@@ -18409,13 +18396,6 @@ function initialPrompt(admitted, env) {
18409
18396
  })
18410
18397
  );
18411
18398
  }
18412
- function hostTurnCwd(env) {
18413
- return env.executionCwd === void 0 ? void 0 : { cwd: env.executionCwd };
18414
- }
18415
- function wantsFreshExecutionCopy(role) {
18416
- const record4 = roleRecord(role);
18417
- return "freshExecutionCopy" in record4 && record4.freshExecutionCopy === true;
18418
- }
18419
18399
  function infraFailure(role) {
18420
18400
  const resolveRunnerKnownFailure = seatKnownFailureResolver(role);
18421
18401
  return resolveRunnerKnownFailure === void 0 ? {} : { resolveRunnerKnownFailure };
@@ -18506,7 +18486,6 @@ async function dispatchAdmitted(admitted, env, io) {
18506
18486
  const adapters = seatAdapters(admitted, env, material);
18507
18487
  const execute = async (activeEnv) => {
18508
18488
  const auto = "inCallAutoResume" in record4 && record4.inCallAutoResume === true;
18509
- const cwd = hostTurnCwd(activeEnv);
18510
18489
  if (auto) {
18511
18490
  return await runPostAdmissionResumable({
18512
18491
  admitted,
@@ -18514,7 +18493,7 @@ async function dispatchAdmitted(admitted, env, io) {
18514
18493
  io,
18515
18494
  buildInitialRequest: () => buildInstructionSeatTurnRequest(
18516
18495
  admitted,
18517
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }, cwd)
18496
+ roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
18518
18497
  ),
18519
18498
  buildResumeRequest: () => buildInstructionSeatTurnRequest(
18520
18499
  admitted,
@@ -18524,7 +18503,7 @@ async function dispatchAdmitted(admitted, env, io) {
18524
18503
  packageRoot: activeEnv.packageRoot,
18525
18504
  ...pickEngineAxis(activeEnv)
18526
18505
  })
18527
- }, cwd)
18506
+ })
18528
18507
  ),
18529
18508
  adapters,
18530
18509
  ...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
@@ -18536,32 +18515,13 @@ async function dispatchAdmitted(admitted, env, io) {
18536
18515
  io,
18537
18516
  request: buildInstructionSeatTurnRequest(
18538
18517
  admitted,
18539
- roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) }, cwd)
18518
+ roleTurnOptions(activeEnv, admitted, { kind: "initial", prompt: initialPrompt(admitted, activeEnv) })
18540
18519
  ),
18541
18520
  adapters,
18542
18521
  ...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
18543
18522
  });
18544
18523
  };
18545
- if (!wantsFreshExecutionCopy(admitted.role)) return execute(env);
18546
- try {
18547
- if (env.executionCwd !== void 0) return await execute(env);
18548
- const { withEphemeralReviewerWorktree: withEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
18549
- return await withEphemeralReviewerWorktree2({
18550
- projectRoot: admitted.projectRoot,
18551
- onCleanupDiagnostic: (diagnostic) => {
18552
- io.stderr(`${diagnostic}
18553
- `);
18554
- },
18555
- run: (executionCwd) => execute({ ...env, executionCwd })
18556
- });
18557
- } catch (error) {
18558
- return await presentControlledFailure2(admitted, {
18559
- timedOut: false,
18560
- code: null,
18561
- stderr: "",
18562
- thrown: error
18563
- }, adapters, env.principalAuthority, io);
18564
- }
18524
+ return execute(env);
18565
18525
  }
18566
18526
  async function runOmittedLensBatch(argv, parsed, env, io) {
18567
18527
  const { summonParallelReviewerLenses: summonParallelReviewerLenses2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
@@ -18984,9 +18944,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
18984
18944
  return runAdmitted();
18985
18945
  }
18986
18946
  async function runPublicInstructionSeatResume(request, env, io) {
18987
- const execution = {
18988
- ...env.executionCwd === void 0 ? {} : { cwd: env.executionCwd }
18989
- };
18990
18947
  return runPostAdmissionSeatResume({
18991
18948
  request,
18992
18949
  env,
@@ -19006,13 +18963,11 @@ async function runPublicInstructionSeatResume(request, env, io) {
19006
18963
  return loaded;
19007
18964
  },
19008
18965
  buildTurnRequest: async (admitted, effective) => {
19009
- const activeEnv = execution.cwd === void 0 ? env : { ...env, executionCwd: execution.cwd };
19010
18966
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
19011
18967
  return buildInstructionSeatTurnRequest(
19012
18968
  admitted,
19013
18969
  {
19014
- ...resumeTurnRequestProjectionOptions(admitted, effective, activeEnv, summonsPrepared),
19015
- ...execution.cwd === void 0 ? {} : { cwd: execution.cwd }
18970
+ ...resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared)
19016
18971
  }
19017
18972
  );
19018
18973
  },
@@ -19035,25 +18990,6 @@ async function runPublicInstructionSeatResume(request, env, io) {
19035
18990
  ...knownCause === void 0 ? {} : { knownCause }
19036
18991
  });
19037
18992
  },
19038
- afterAdmittedPrepare: async (admitted) => {
19039
- if (!wantsFreshExecutionCopy(admitted.role)) return {};
19040
- if (execution.cwd !== void 0) {
19041
- return { env: { ...env, executionCwd: execution.cwd } };
19042
- }
19043
- const { openEphemeralReviewerWorktree: openEphemeralReviewerWorktree2 } = await Promise.resolve().then(() => (init_public_role_summons(), public_role_summons_exports));
19044
- const opened = await openEphemeralReviewerWorktree2({
19045
- projectRoot: admitted.projectRoot,
19046
- onCleanupDiagnostic: (diagnostic) => {
19047
- io.stderr(`${diagnostic}
19048
- `);
19049
- }
19050
- });
19051
- execution.cwd = opened.executionCwd;
19052
- return {
19053
- env: { ...env, executionCwd: opened.executionCwd },
19054
- cleanup: opened.close
19055
- };
19056
- },
19057
18993
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
19058
18994
  });
19059
18995
  }
@@ -22120,18 +22056,15 @@ var init_cli = __esm({
22120
22056
  var public_role_summons_exports = {};
22121
22057
  __export(public_role_summons_exports, {
22122
22058
  AK_ROLE_PACKAGE_ROOT_ENV: () => AK_ROLE_PACKAGE_ROOT_ENV,
22123
- openEphemeralReviewerWorktree: () => openEphemeralReviewerWorktree,
22124
22059
  resolveSummonsPackageRoot: () => resolveSummonsPackageRoot,
22125
22060
  summonGateOfficer: () => summonGateOfficer,
22126
22061
  summonParallelReviewerLenses: () => summonParallelReviewerLenses,
22127
- summonPublicRole: () => summonPublicRole,
22128
- withEphemeralReviewerWorktree: () => withEphemeralReviewerWorktree
22062
+ summonPublicRole: () => summonPublicRole
22129
22063
  });
22130
22064
  import { execFile as execFile3 } from "node:child_process";
22131
22065
  import { existsSync as existsSync9 } from "node:fs";
22132
- import { mkdir as mkdir4, mkdtemp as mkdtemp4, realpath as realpath7, rm as rm6 } from "node:fs/promises";
22133
- import { tmpdir as tmpdir4 } from "node:os";
22134
- import { join as join38, relative as relative3, sep as sep5 } from "node:path";
22066
+ import { realpath as realpath7 } from "node:fs/promises";
22067
+ import { join as join38 } from "node:path";
22135
22068
  import { promisify as promisify3 } from "node:util";
22136
22069
  function createCapturingIo() {
22137
22070
  const chunks = [];
@@ -22333,8 +22266,7 @@ async function summonPublicRole(options) {
22333
22266
  ...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
22334
22267
  ...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
22335
22268
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
22336
- ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
22337
- ...options.executionCwd === void 0 ? {} : { executionCwd: options.executionCwd }
22269
+ ...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
22338
22270
  }
22339
22271
  };
22340
22272
  } catch (error) {
@@ -22414,106 +22346,13 @@ function withReviewerLens(argv, lens) {
22414
22346
  if (separator === -1) return [...argv, "--lens", lens];
22415
22347
  return [...argv.slice(0, separator), "--lens", lens, ...argv.slice(separator)];
22416
22348
  }
22417
- async function resolveReviewerWorktreeRoots(projectRoot) {
22349
+ async function resolveReviewerGitToplevel(projectRoot) {
22418
22350
  const callerProjectRoot = await realpath7(projectRoot);
22419
- const sourceProjectRoot = await realpath7((await execFileAsync3(
22351
+ return await realpath7((await execFileAsync3(
22420
22352
  "git",
22421
22353
  ["rev-parse", "--show-toplevel"],
22422
22354
  { cwd: callerProjectRoot }
22423
22355
  )).stdout.trim());
22424
- const callerRelative = relative3(sourceProjectRoot, callerProjectRoot);
22425
- const projectRelative = callerRelative === "" || callerRelative === "." || callerRelative.startsWith(`..${sep5}`) || callerRelative === ".." ? "" : callerRelative;
22426
- return { callerProjectRoot, sourceProjectRoot, projectRelative };
22427
- }
22428
- function reviewerSandboxPath(worktreeAxis, projectRelative) {
22429
- return projectRelative === "" ? worktreeAxis : join38(worktreeAxis, projectRelative);
22430
- }
22431
- async function openEphemeralReviewerWorktree(options) {
22432
- const { sourceProjectRoot, projectRelative } = await resolveReviewerWorktreeRoots(
22433
- options.projectRoot
22434
- );
22435
- const { stdout: headStdout } = await execFileAsync3(
22436
- "git",
22437
- ["rev-parse", "--verify", "HEAD^{commit}"],
22438
- { cwd: sourceProjectRoot }
22439
- );
22440
- const targetCommit = headStdout.trim();
22441
- const root = await mkdtemp4(join38(tmpdir4(), "ak-reviewer-sandbox-"));
22442
- const worktreeRoot = join38(root, "work");
22443
- let registered = false;
22444
- const rollback = async (cause) => {
22445
- const cleanupErrors = [];
22446
- if (registered) {
22447
- try {
22448
- await execFileAsync3("git", ["worktree", "remove", "--force", worktreeRoot], {
22449
- cwd: sourceProjectRoot
22450
- });
22451
- } catch (error) {
22452
- cleanupErrors.push(error);
22453
- }
22454
- }
22455
- try {
22456
- await rm6(root, { recursive: true, force: true });
22457
- } catch (error) {
22458
- cleanupErrors.push(error);
22459
- }
22460
- if (cleanupErrors.length > 0) {
22461
- options.onCleanupDiagnostic?.([
22462
- "reviewer worktree cleanup failed",
22463
- ...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
22464
- ].join("\n"));
22465
- }
22466
- throw cause;
22467
- };
22468
- try {
22469
- await execFileAsync3("git", ["worktree", "add", "--detach", worktreeRoot, targetCommit], {
22470
- cwd: sourceProjectRoot
22471
- });
22472
- registered = true;
22473
- if (projectRelative !== "") {
22474
- await mkdir4(reviewerSandboxPath(worktreeRoot, projectRelative), { recursive: true });
22475
- }
22476
- } catch (error) {
22477
- await rollback(error);
22478
- }
22479
- let closed = false;
22480
- return {
22481
- executionCwd: reviewerSandboxPath(worktreeRoot, projectRelative),
22482
- close: async () => {
22483
- if (closed) return;
22484
- closed = true;
22485
- const cleanupErrors = [];
22486
- try {
22487
- await execFileAsync3("git", ["worktree", "remove", worktreeRoot], {
22488
- cwd: sourceProjectRoot
22489
- });
22490
- } catch (error) {
22491
- cleanupErrors.push(error);
22492
- }
22493
- try {
22494
- await rm6(root, { recursive: true, force: true });
22495
- } catch (error) {
22496
- cleanupErrors.push(error);
22497
- }
22498
- if (cleanupErrors.length > 0) {
22499
- options.onCleanupDiagnostic?.([
22500
- "reviewer worktree cleanup failed",
22501
- ...cleanupErrors.map((error) => error instanceof Error ? error.message : String(error))
22502
- ].join("\n"));
22503
- }
22504
- }
22505
- };
22506
- }
22507
- async function withEphemeralReviewerWorktree(options) {
22508
- const sandbox = await openEphemeralReviewerWorktree({
22509
- projectRoot: options.projectRoot,
22510
- ...options.onCleanupDiagnostic === void 0 ? {} : { onCleanupDiagnostic: options.onCleanupDiagnostic }
22511
- });
22512
- try {
22513
- return await options.run(sandbox.executionCwd);
22514
- } finally {
22515
- await sandbox.close();
22516
- }
22517
22356
  }
22518
22357
  async function summonParallelReviewerLenses(options) {
22519
22358
  const describeFailure = (error) => {
@@ -22531,7 +22370,6 @@ async function summonParallelReviewerLenses(options) {
22531
22370
  return { completeness: failure2, correctness: failure2 };
22532
22371
  };
22533
22372
  let sourceProjectRoot;
22534
- let projectRelative;
22535
22373
  let targetCommit;
22536
22374
  const statusArgs = [
22537
22375
  "status",
@@ -22542,9 +22380,7 @@ async function summonParallelReviewerLenses(options) {
22542
22380
  ":(top,exclude).claude/worktrees/**"
22543
22381
  ];
22544
22382
  try {
22545
- const roots = await resolveReviewerWorktreeRoots(options.projectRoot);
22546
- sourceProjectRoot = roots.sourceProjectRoot;
22547
- projectRelative = roots.projectRelative;
22383
+ sourceProjectRoot = await resolveReviewerGitToplevel(options.projectRoot);
22548
22384
  const { stdout: statusStdout } = await execFileAsync3("git", statusArgs, {
22549
22385
  cwd: sourceProjectRoot
22550
22386
  });
@@ -22570,65 +22406,37 @@ async function summonParallelReviewerLenses(options) {
22570
22406
  } catch (error) {
22571
22407
  return dualFailure(error);
22572
22408
  }
22573
- const root = await mkdtemp4(join38(tmpdir4(), "ak-reviewer-lenses-"));
22574
- const completenessRoot = join38(root, "completeness");
22575
- const correctnessRoot = join38(root, "correctness");
22576
- const worktrees = [completenessRoot, correctnessRoot];
22577
- const created = /* @__PURE__ */ new Set();
22578
- let results;
22579
- const creation = await Promise.allSettled(
22580
- worktrees.map(async (path) => {
22581
- await execFileAsync3("git", ["worktree", "add", "--detach", path, targetCommit], {
22582
- cwd: sourceProjectRoot
22583
- });
22584
- created.add(path);
22585
- if (projectRelative !== "") {
22586
- await mkdir4(reviewerSandboxPath(path, projectRelative), { recursive: true });
22587
- }
22588
- })
22589
- );
22590
- const creationFailures = creation.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
22591
- if (creationFailures.length > 0) {
22592
- const failure2 = failedResult(new AggregateError(
22593
- creationFailures,
22594
- "parallel reviewer worktree creation failed"
22595
- ));
22596
- results = { completeness: failure2, correctness: failure2 };
22597
- } else {
22598
- const summon = (lens, worktreeAxis) => {
22599
- const sandbox = reviewerSandboxPath(worktreeAxis, projectRelative);
22600
- return summonPublicRole({
22601
- role: "reviewer",
22602
- argv: withReviewerLens(options.argv, lens),
22603
- cwd: options.cwd,
22604
- executionCwd: sandbox,
22605
- // Ordinary single-axis public semantics — not a nested court station.
22606
- stationChild: false,
22607
- home: options.home,
22608
- ...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
22609
- ...options.credentials === void 0 ? {} : { credentials: options.credentials },
22610
- ...options.model === void 0 ? {} : { model: options.model },
22611
- ...options.host === void 0 ? {} : { host: options.host },
22612
- ...options.engine === void 0 ? {} : { engine: options.engine },
22613
- ...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
22614
- ...options.signal === void 0 ? {} : { signal: options.signal },
22615
- ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
22616
- ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
22617
- ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
22618
- ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
22619
- ...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
22620
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
22621
- });
22622
- };
22623
- const settled = await Promise.allSettled([
22624
- summon("completeness", completenessRoot),
22625
- summon("correctness", correctnessRoot)
22626
- ]);
22627
- results = {
22628
- completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
22629
- correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
22630
- };
22631
- }
22409
+ const summon = (lens) => {
22410
+ return summonPublicRole({
22411
+ role: "reviewer",
22412
+ argv: withReviewerLens(options.argv, lens),
22413
+ cwd: options.cwd,
22414
+ // Ordinary single-axis public semantics — not a nested court station.
22415
+ stationChild: false,
22416
+ home: options.home,
22417
+ ...options.agentDir === void 0 ? {} : { agentDir: options.agentDir },
22418
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
22419
+ ...options.model === void 0 ? {} : { model: options.model },
22420
+ ...options.host === void 0 ? {} : { host: options.host },
22421
+ ...options.engine === void 0 ? {} : { engine: options.engine },
22422
+ ...options.engineModel === void 0 ? {} : { engineModel: options.engineModel },
22423
+ ...options.signal === void 0 ? {} : { signal: options.signal },
22424
+ ...options.correlationId === void 0 ? {} : { correlationId: options.correlationId },
22425
+ ...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
22426
+ ...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
22427
+ ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
22428
+ ...options.principalAuthority === void 0 ? {} : { principalAuthority: options.principalAuthority },
22429
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
22430
+ });
22431
+ };
22432
+ const settled = await Promise.allSettled([
22433
+ summon("completeness"),
22434
+ summon("correctness")
22435
+ ]);
22436
+ let results = {
22437
+ completeness: settled[0].status === "fulfilled" ? settled[0].value : failedResult(settled[0].reason),
22438
+ correctness: settled[1].status === "fulfilled" ? settled[1].value : failedResult(settled[1].reason)
22439
+ };
22632
22440
  let sealDiagnostic;
22633
22441
  try {
22634
22442
  const { stdout: headBeforeStdout } = await execFileAsync3(
@@ -22673,30 +22481,6 @@ ${describeFailure(error)}`;
22673
22481
  correctness: withSealFailure(results.correctness)
22674
22482
  };
22675
22483
  }
22676
- const cleanup = await Promise.allSettled(
22677
- [...created].map((path) => execFileAsync3("git", ["worktree", "remove", path], { cwd: sourceProjectRoot }))
22678
- );
22679
- const cleanupFailures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
22680
- if (cleanupFailures.length === 0) {
22681
- const rootCleanup = await Promise.allSettled([rm6(root, { recursive: true, force: true })]);
22682
- cleanupFailures.push(...rootCleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
22683
- }
22684
- if (cleanupFailures.length > 0) {
22685
- const diagnostic = [
22686
- "parallel reviewer worktree cleanup failed",
22687
- ...cleanupFailures.map((failure2) => failure2 instanceof Error ? failure2.message : String(failure2))
22688
- ].join("\n");
22689
- const withCleanupDiagnostic = (result) => ({
22690
- ...result,
22691
- stderr: [result.stderr, diagnostic].filter(
22692
- (text) => typeof text === "string" && text !== ""
22693
- ).join("\n")
22694
- });
22695
- results = {
22696
- completeness: withCleanupDiagnostic(results.completeness),
22697
- correctness: withCleanupDiagnostic(results.correctness)
22698
- };
22699
- }
22700
22484
  return results;
22701
22485
  }
22702
22486
  async function summonGateOfficer(options) {
@@ -24903,7 +24687,7 @@ init_collector_github();
24903
24687
  init_atomic_write();
24904
24688
  init_activation_ledger_topology();
24905
24689
  import { readFile as readFile24 } from "node:fs/promises";
24906
- import { join as join42, sep as sep6 } from "node:path";
24690
+ import { join as join42, sep as sep5 } from "node:path";
24907
24691
 
24908
24692
  // src/collector-tool-schemas.ts
24909
24693
  init_open_tool_schema();
@@ -24998,7 +24782,7 @@ function resolveCollectorHandbookRoot(sessionPath) {
24998
24782
  if (typeof sessionPath !== "string" || sessionPath.trim().length === 0) {
24999
24783
  throw new Error("\u901A\u8FDB\u53F8\u624B\u518C\u8981\u6C42\u975E\u7A7A session \u8DEF\u5F84\uFF0C\u4E14\u4F4D\u4E8E books/<bookKey>/");
25000
24784
  }
25001
- const segments = sessionPath.split(sep6);
24785
+ const segments = sessionPath.split(sep5);
25002
24786
  let bookKey;
25003
24787
  for (let i = 0; i + 3 < segments.length; i += 1) {
25004
24788
  if (segments[i] === ".ak-roles" && segments[i + 1] === "books") {
@@ -26533,11 +26317,11 @@ function reliableWindow(cwd, baseline, head) {
26533
26317
  const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
26534
26318
  if (raw.length === 0) return [];
26535
26319
  return raw.split("\n").flatMap((line2) => {
26536
- const sep7 = line2.indexOf("");
26537
- if (sep7 < 0) return [];
26320
+ const sep6 = line2.indexOf("");
26321
+ if (sep6 < 0) return [];
26538
26322
  return [{
26539
- subject: line2.slice(sep7 + 1),
26540
- merge: line2.slice(0, sep7).trim().includes(" ")
26323
+ subject: line2.slice(sep6 + 1),
26324
+ merge: line2.slice(0, sep6).trim().includes(" ")
26541
26325
  }];
26542
26326
  });
26543
26327
  }
@@ -28647,7 +28431,7 @@ function createRoleRuntimeDependencies(packageRoot) {
28647
28431
  // src/role-envelope.ts
28648
28432
  init_engine_detour();
28649
28433
  import { randomUUID as randomUUID9 } from "node:crypto";
28650
- import { appendFile as appendFile3, mkdir as mkdir6, writeFile as writeFile11 } from "node:fs/promises";
28434
+ import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
28651
28435
  import { createServer } from "node:net";
28652
28436
  import { dirname as dirname25, join as join46 } from "node:path";
28653
28437
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -28745,7 +28529,7 @@ async function requireGatekeeperPass(options) {
28745
28529
  }
28746
28530
 
28747
28531
  // src/host-native-method.ts
28748
- import { access as access4, lstat as lstat7, mkdir as mkdir5, readdir as readdir9, readFile as readFile26, readlink, realpath as realpath8, symlink } from "node:fs/promises";
28532
+ import { access as access4, lstat as lstat7, mkdir as mkdir4, readdir as readdir9, readFile as readFile26, readlink, realpath as realpath8, symlink } from "node:fs/promises";
28749
28533
  import { basename as basename11, dirname as dirname24, join as join45 } from "node:path";
28750
28534
  var HOST_METHOD_PLUGIN_NAME = "ak-methods";
28751
28535
  var packagedMethodsDir = (root) => join45(root, "resources", "methods");
@@ -28868,7 +28652,7 @@ async function installWorkspaceMethodSkills(cwd, packageRoot) {
28868
28652
  const detail = stat2.isSymbolicLink() ? `symlink to ${await readlink(link)}` : "non-symlink entry";
28869
28653
  throw new Error(`workspace method catalog conflict at ${link}: ${detail}`);
28870
28654
  }
28871
- await mkdir5(dirname24(link), { recursive: true });
28655
+ await mkdir4(dirname24(link), { recursive: true });
28872
28656
  try {
28873
28657
  await symlink(target, link);
28874
28658
  } catch (error) {
@@ -28923,9 +28707,9 @@ async function prepareRoleEnvelope(options) {
28923
28707
  let infrastructureRoundFailure;
28924
28708
  const hostAbort = new AbortController();
28925
28709
  const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
28926
- await mkdir6(request.runDirectory, { recursive: true });
28710
+ await mkdir5(request.runDirectory, { recursive: true });
28927
28711
  let sessionFile = options.sessionFile ?? join46(request.runDirectory, "session", "session.jsonl");
28928
- await mkdir6(dirname25(sessionFile), { recursive: true });
28712
+ await mkdir5(dirname25(sessionFile), { recursive: true });
28929
28713
  if (request.continuation.kind !== "resume") {
28930
28714
  try {
28931
28715
  await writeFile11(
@@ -14118,8 +14118,6 @@ var init_packaged_role_registry = __esm({
14118
14118
  settleMethod: "ak-cross-m-review",
14119
14119
  /** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
14120
14120
  parallelLenses: true,
14121
- /** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
14122
- freshExecutionCopy: true,
14123
14121
  phases: [null],
14124
14122
  bareCommand: false,
14125
14123
  outputTool: REVIEWER_OUTPUT_TOOL_NAME,
@@ -156,8 +156,6 @@ const PUBLIC_ROLE_RECORDS = [
156
156
  settleMethod: "ak-cross-m-review",
157
157
  /** Omitted public lens starts two ordinary single-axis runs (ADR 0052). */
158
158
  parallelLenses: true,
159
- /** Every turn runs in a fresh worktree; durable projectRoot stays the caller project (#946). */
160
- freshExecutionCopy: true,
161
159
  phases: [null],
162
160
  bareCommand: false,
163
161
  outputTool: REVIEWER_OUTPUT_TOOL_NAME,