@akagilnc/pi-workflow-roles 0.1.3891 → 0.1.3898

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.
@@ -23237,7 +23237,6 @@ async function readSealedSubmission(cwd, runId, homeOrScope) {
23237
23237
  const scoped = recordsForAttempt(owned, scope.attemptId);
23238
23238
  for (let index = scoped.length - 1; index >= 0; index -= 1) {
23239
23239
  const record4 = scoped[index];
23240
- if (record4?.kind === "post-seal-anomaly") return void 0;
23241
23240
  if (record4?.kind !== "sealed") continue;
23242
23241
  const payload = record4.payload;
23243
23242
  if (payload?.type === "sealed" && isAcceptedProjection(payload.projection)) return payload.projection;
@@ -25207,8 +25206,8 @@ async function readLawfulSettlementEntries(sessionFile) {
25207
25206
  throw error instanceof Error && error.knownCause === "session" ? error : sessionReadFailure(error, "session unreadable");
25208
25207
  }
25209
25208
  }
25210
- async function readLawfulJudgeRoleOutcome(admitted, authority) {
25211
- const sealed = await sealedLedgerOutcome(admitted);
25209
+ async function readLawfulJudgeRoleOutcome(admitted, authority, scope) {
25210
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25212
25211
  if (sealed?.role === "judge") {
25213
25212
  const details = sealed.decisiveFacts;
25214
25213
  return {
@@ -25219,10 +25218,10 @@ async function readLawfulJudgeRoleOutcome(admitted, authority) {
25219
25218
  decisiveFacts: withAuditNoReceiptFacts(details)
25220
25219
  };
25221
25220
  }
25222
- return auditEscalationLedgerOutcome(admitted, "judge");
25221
+ return auditEscalationLedgerOutcome(admitted, "judge", scope);
25223
25222
  }
25224
- async function settleLawfulJudgeTerminalResult(admitted, authority) {
25225
- const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority);
25223
+ async function settleLawfulJudgeTerminalResult(admitted, authority, scope) {
25224
+ const roleOutcome = await readLawfulJudgeRoleOutcome(admitted, authority, scope);
25226
25225
  if (roleOutcome === void 0) return void 0;
25227
25226
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25228
25227
  const entries = await readLawfulSettlementEntries(coordinates.sessionFile) ?? [];
@@ -25242,11 +25241,11 @@ async function settleLawfulJudgeTerminalResult(admitted, authority) {
25242
25241
  coordinates.sessionDirectory
25243
25242
  );
25244
25243
  }
25245
- async function trySettleJudgeTerminalResult(admitted, authority) {
25246
- return settleLawfulJudgeTerminalResult(admitted, authority);
25244
+ async function trySettleJudgeTerminalResult(admitted, authority, scope) {
25245
+ return settleLawfulJudgeTerminalResult(admitted, authority, scope);
25247
25246
  }
25248
- async function settleLawfulCoderTerminalResult(admitted, authority, options = {}) {
25249
- const ledgerOutcome = await closedLedgerOutcome(admitted, "coder");
25247
+ async function settleLawfulCoderTerminalResult(admitted, authority, options = {}, scope) {
25248
+ const ledgerOutcome = await closedLedgerOutcome(admitted, "coder", scope);
25250
25249
  if (ledgerOutcome === void 0) return void 0;
25251
25250
  const roleOutcome = ledgerOutcome;
25252
25251
  const output = ledgerOutcome.kind === "accepted" ? ledgerOutcome.decisiveFacts : void 0;
@@ -25356,8 +25355,8 @@ async function publishFixerArtifacts(admitted, roleOutcome, coordinates, options
25356
25355
  { kind: "evidence", path: evidencePath }
25357
25356
  ];
25358
25357
  }
25359
- async function settleLawfulFixerTerminalResult(admitted, authority, options) {
25360
- const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer");
25358
+ async function settleLawfulFixerTerminalResult(admitted, authority, options, scope) {
25359
+ const ledgerOutcome = await closedLedgerOutcome(admitted, "fixer", scope);
25361
25360
  if (ledgerOutcome === void 0) return void 0;
25362
25361
  const roleOutcome = ledgerOutcome;
25363
25362
  const output = ledgerOutcome.kind === "accepted" ? ledgerOutcome.decisiveFacts : void 0;
@@ -25441,11 +25440,11 @@ async function publishCollectorArtifacts(admitted, roleOutcome, coordinates, opt
25441
25440
  { kind: "evidence", path: evidencePath }
25442
25441
  ];
25443
25442
  }
25444
- async function settleLawfulCollectorTerminalResult(admitted, authority) {
25443
+ async function settleLawfulCollectorTerminalResult(admitted, authority, scope) {
25445
25444
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25446
25445
  const { sessionDirectory, sessionFile } = coordinates;
25447
25446
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25448
- const roleOutcome = await sealedLedgerOutcome(admitted);
25447
+ const roleOutcome = await sealedLedgerOutcome(admitted, scope);
25449
25448
  if (roleOutcome?.role !== "collector") {
25450
25449
  const scanStart = currentAttemptStartIndex(entries);
25451
25450
  for (let index = entries.length - 1; index >= scanStart; index -= 1) {
@@ -25496,8 +25495,8 @@ async function settleLawfulCollectorTerminalResult(admitted, authority) {
25496
25495
  sessionDirectory
25497
25496
  );
25498
25497
  }
25499
- async function trySettleCollectorTerminalResult(admitted, authority) {
25500
- return settleLawfulCollectorTerminalResult(admitted, authority);
25498
+ async function trySettleCollectorTerminalResult(admitted, authority, scope) {
25499
+ return settleLawfulCollectorTerminalResult(admitted, authority, scope);
25501
25500
  }
25502
25501
  async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, options = {}) {
25503
25502
  await appendRunAttemptHistory({ role: admitted.role, runId: admitted.runId, sessionFile: coordinates.sessionFile }, roleOutcome);
@@ -25549,13 +25548,13 @@ async function publishDoctorArtifacts(admitted, roleOutcome, coordinates, option
25549
25548
  { kind: "evidence", path: evidencePath }
25550
25549
  ];
25551
25550
  }
25552
- async function settleLawfulDoctorTerminalResult(admitted, authority) {
25553
- const sealed = await sealedLedgerOutcome(admitted);
25551
+ async function settleLawfulDoctorTerminalResult(admitted, authority, scope) {
25552
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25554
25553
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25555
25554
  const { sessionDirectory, sessionFile } = coordinates;
25556
25555
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25557
25556
  if (sealed?.role !== "doctor") {
25558
- const escalation = await auditEscalationLedgerOutcome(admitted, "doctor");
25557
+ const escalation = await auditEscalationLedgerOutcome(admitted, "doctor", scope);
25559
25558
  if (escalation === void 0) return void 0;
25560
25559
  const artifacts2 = await publishDoctorArtifacts(admitted, escalation, coordinates);
25561
25560
  return withOptionalGateProjection(
@@ -25603,8 +25602,8 @@ async function settleLawfulDoctorTerminalResult(admitted, authority) {
25603
25602
  sessionDirectory
25604
25603
  );
25605
25604
  }
25606
- async function trySettleDoctorTerminalResult(admitted, authority) {
25607
- return settleLawfulDoctorTerminalResult(admitted, authority);
25605
+ async function trySettleDoctorTerminalResult(admitted, authority, scope) {
25606
+ return settleLawfulDoctorTerminalResult(admitted, authority, scope);
25608
25607
  }
25609
25608
  function currentAttemptStartIndex(entries) {
25610
25609
  for (let i = entries.length - 1; i >= 0; i -= 1) {
@@ -25738,11 +25737,11 @@ async function settleLawfulAuditorTerminalResult(admitted, authority, scope) {
25738
25737
  async function trySettleAuditorTerminalResult(admitted, authority, scope) {
25739
25738
  return settleLawfulAuditorTerminalResult(admitted, authority, scope);
25740
25739
  }
25741
- async function trySettleCoderTerminalResult(admitted, authority, options = {}) {
25742
- return settleLawfulCoderTerminalResult(admitted, authority, options);
25740
+ async function trySettleCoderTerminalResult(admitted, authority, options = {}, scope) {
25741
+ return settleLawfulCoderTerminalResult(admitted, authority, options, scope);
25743
25742
  }
25744
- async function trySettleFixerTerminalResult(admitted, authority, options) {
25745
- return settleLawfulFixerTerminalResult(admitted, authority, options);
25743
+ async function trySettleFixerTerminalResult(admitted, authority, options, scope) {
25744
+ return settleLawfulFixerTerminalResult(admitted, authority, options, scope);
25746
25745
  }
25747
25746
  function extractReviewerMethodInvocations(entries, options) {
25748
25747
  const observed = [];
@@ -25816,8 +25815,8 @@ async function publishReviewerArtifacts(admitted, roleOutcome, coordinates, opti
25816
25815
  { kind: "evidence", path: evidencePath }
25817
25816
  ];
25818
25817
  }
25819
- async function settleLawfulReviewerTerminalResult(admitted, authority, options) {
25820
- const sealed = await sealedLedgerOutcome(admitted);
25818
+ async function settleLawfulReviewerTerminalResult(admitted, authority, options, scope) {
25819
+ const sealed = await sealedLedgerOutcome(admitted, scope);
25821
25820
  if (sealed?.role !== "reviewer") return void 0;
25822
25821
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25823
25822
  const { sessionDirectory, sessionFile } = coordinates;
@@ -25856,8 +25855,8 @@ async function settleLawfulReviewerTerminalResult(admitted, authority, options)
25856
25855
  sessionDirectory
25857
25856
  );
25858
25857
  }
25859
- async function trySettleReviewerTerminalResult(admitted, authority, options) {
25860
- return settleLawfulReviewerTerminalResult(admitted, authority, options);
25858
+ async function trySettleReviewerTerminalResult(admitted, authority, options, scope) {
25859
+ return settleLawfulReviewerTerminalResult(admitted, authority, options, scope);
25861
25860
  }
25862
25861
  function extractMergerMethodInvocations(entries, options) {
25863
25862
  const observed = [];
@@ -25927,16 +25926,16 @@ async function publishMergerArtifacts(admitted, roleOutcome, coordinates, option
25927
25926
  { kind: "evidence", path: evidencePath }
25928
25927
  ];
25929
25928
  }
25930
- async function settleLawfulMergerTerminalResult(admitted, authority, options) {
25929
+ async function settleLawfulMergerTerminalResult(admitted, authority, options, scope) {
25931
25930
  const coordinates = coordinatesFromAdmitted(authority, admitted);
25932
25931
  const { sessionDirectory, sessionFile } = coordinates;
25933
25932
  const entries = await readLawfulSettlementEntries(sessionFile) ?? [];
25934
- const roleOutcome = await sealedLedgerOutcome(admitted);
25933
+ const roleOutcome = await sealedLedgerOutcome(admitted, scope);
25935
25934
  if (roleOutcome?.role !== "merger") {
25936
25935
  const latestOutcome = await readLatestSubmissionOutcome(
25937
25936
  admitted.projectRoot,
25938
25937
  admitted.runId,
25939
- sealedLedgerHome(admitted)
25938
+ ledgerReadScope(admitted, scope)
25940
25939
  );
25941
25940
  if (latestOutcome?.outcome === "correctable-rejection" && latestOutcome.code === "non-sole-round") {
25942
25941
  return void 0;
@@ -25996,8 +25995,8 @@ async function settleLawfulMergerTerminalResult(admitted, authority, options) {
25996
25995
  sessionDirectory
25997
25996
  );
25998
25997
  }
25999
- async function trySettleMergerTerminalResult(admitted, authority, options) {
26000
- return settleLawfulMergerTerminalResult(admitted, authority, options);
25998
+ async function trySettleMergerTerminalResult(admitted, authority, options, scope) {
25999
+ return settleLawfulMergerTerminalResult(admitted, authority, options, scope);
26001
26000
  }
26002
26001
  function publicationAttemptFromError(path, error) {
26003
26002
  if (error instanceof Error) {
@@ -26386,7 +26385,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
26386
26385
  agentDir: options.agentDir,
26387
26386
  runDirectory: admitted.runDirectory,
26388
26387
  ...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
26389
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
26388
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
26389
+ ...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId }
26390
26390
  };
26391
26391
  }
26392
26392
  var init_turn_request = __esm({
@@ -26936,6 +26936,30 @@ async function readInvocationHost(runDirectory) {
26936
26936
  throw error;
26937
26937
  }
26938
26938
  }
26939
+ async function resolveResumeMethodMaterialAdapters(input) {
26940
+ if (input.shouldLoad === false) {
26941
+ return { kind: "continue", adapters: input.emptyAdapters };
26942
+ }
26943
+ try {
26944
+ const material = await input.loadMaterial();
26945
+ return { kind: "continue", adapters: input.adaptersWith(material) };
26946
+ } catch (error) {
26947
+ const terminal = await presentControlledFailure2(
26948
+ input.admitted,
26949
+ {
26950
+ timedOut: false,
26951
+ code: null,
26952
+ stderr: "",
26953
+ thrown: error,
26954
+ ...input.knownCause === void 0 ? {} : { knownCause: input.knownCause }
26955
+ },
26956
+ input.emptyAdapters,
26957
+ input.authority,
26958
+ input.io
26959
+ );
26960
+ return { kind: "terminal", ...terminal };
26961
+ }
26962
+ }
26939
26963
  async function presentControlledFailure2(admitted, failureInput, adapters, authority, io) {
26940
26964
  const hasThrown = Object.hasOwn(failureInput, "thrown");
26941
26965
  const resumeObservation = await resolveControlledFailureResumeObservation({
@@ -27187,7 +27211,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
27187
27211
  continuation: {
27188
27212
  kind: "resume",
27189
27213
  prompt
27190
- }
27214
+ },
27215
+ ...request.message === void 0 ? {} : { courtAttemptId: randomUUID5() }
27191
27216
  };
27192
27217
  }
27193
27218
  function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
@@ -27222,14 +27247,25 @@ async function runPostAdmissionSeatResume(input) {
27222
27247
  }
27223
27248
  throw error;
27224
27249
  }
27250
+ let adapters = input.adapters;
27251
+ if (input.afterAdmittedLoad !== void 0) {
27252
+ const prepared = await input.afterAdmittedLoad(loaded.admitted);
27253
+ if (prepared.kind === "terminal") {
27254
+ return {
27255
+ exitCode: prepared.exitCode,
27256
+ admitted: prepared.admitted,
27257
+ terminal: prepared.terminal
27258
+ };
27259
+ }
27260
+ adapters = prepared.adapters;
27261
+ }
27225
27262
  try {
27226
27263
  return await runPostAdmissionManualResume({
27227
27264
  admitted: loaded.admitted,
27228
27265
  env: input.env,
27229
27266
  io: input.io,
27230
- adapters: input.adapters,
27267
+ adapters,
27231
27268
  ...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
27232
- forceContinuation: true,
27233
27269
  buildRequestAfterLease: async () => {
27234
27270
  let openCourtAttemptId;
27235
27271
  let admittedForBuild = loaded.admitted;
@@ -27281,7 +27317,7 @@ async function runPostAdmissionSeatResume(input) {
27281
27317
  }
27282
27318
  }
27283
27319
  let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
27284
- if (openCourtAttemptId !== void 0 || request.summons !== void 0) {
27320
+ if (openCourtAttemptId !== void 0 || request.summons !== void 0 || request.message !== void 0) {
27285
27321
  const courtAttemptId = openCourtAttemptId ?? (turnRequest.courtAttemptId !== void 0 && turnRequest.courtAttemptId.length > 0 ? turnRequest.courtAttemptId : randomUUID5());
27286
27322
  turnRequest = { ...turnRequest, courtAttemptId };
27287
27323
  if (openCourtAttemptId === void 0) {
@@ -27354,38 +27390,6 @@ async function runPostAdmissionResumable(input) {
27354
27390
  })
27355
27391
  });
27356
27392
  }
27357
- async function presentSealedAcceptedManualResumeIfAny(input) {
27358
- const { admitted, env, io, adapters, shouldPresent } = input;
27359
- try {
27360
- const existing = await adapters.trySettle(admitted, env.principalAuthority);
27361
- if (existing !== void 0 && existing.roleOutcome.kind === "accepted" && shouldPresent(existing)) {
27362
- existing.autoResumeCount = 0;
27363
- io.stdout(formatTerminalResult(existing));
27364
- return {
27365
- exitCode: exitCodeForTerminalOutcome(existing.roleOutcome),
27366
- admitted,
27367
- terminal: existing
27368
- };
27369
- }
27370
- } catch (error) {
27371
- const disposition = await sealedAcceptanceRedispatchDisposition(admitted);
27372
- if (disposition.kind === "block") {
27373
- return await presentControlledFailure2(
27374
- admitted,
27375
- {
27376
- timedOut: false,
27377
- code: null,
27378
- stderr: "",
27379
- thrown: disposition.reason === "authority-failed" ? disposition.cause : error
27380
- },
27381
- adapters,
27382
- env.principalAuthority,
27383
- io
27384
- );
27385
- }
27386
- }
27387
- return void 0;
27388
- }
27389
27393
  async function runPostAdmissionManualResume(input) {
27390
27394
  const {
27391
27395
  admitted,
@@ -27393,25 +27397,10 @@ async function runPostAdmissionManualResume(input) {
27393
27397
  io,
27394
27398
  adapters,
27395
27399
  effectiveEngine,
27396
- forceContinuation,
27397
27400
  buildRequestAfterLease
27398
27401
  } = input;
27399
27402
  let request = input.request;
27400
27403
  const effectiveModel = env.model;
27401
- const shouldPresent = adapters.shouldPresentSettled ?? ((terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome));
27402
- const sealedIdempotenceInput = {
27403
- admitted,
27404
- env,
27405
- io,
27406
- adapters,
27407
- shouldPresent
27408
- };
27409
- if (forceContinuation !== true && request !== void 0) {
27410
- const presented = await presentSealedAcceptedManualResumeIfAny(
27411
- sealedIdempotenceInput
27412
- );
27413
- if (presented !== void 0) return presented;
27414
- }
27415
27404
  let lease;
27416
27405
  let staleWriterLeaseReclaimed;
27417
27406
  try {
@@ -27438,17 +27427,6 @@ async function runPostAdmissionManualResume(input) {
27438
27427
  );
27439
27428
  }
27440
27429
  request = await buildRequestAfterLease();
27441
- if (request.courtAttemptId === void 0 || request.courtAttemptId.length === 0) {
27442
- const presented = await presentSealedAcceptedManualResumeIfAny(
27443
- sealedIdempotenceInput
27444
- );
27445
- if (presented !== void 0) {
27446
- return {
27447
- ...presented,
27448
- ...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
27449
- };
27450
- }
27451
- }
27452
27430
  }
27453
27431
  handedOffToDispatch = true;
27454
27432
  const result2 = await dispatchPostAdmissionTurn({
@@ -27516,9 +27494,14 @@ function buildCoderTurnRequest(admitted, options) {
27516
27494
  }
27517
27495
  function coderAdapters(methodProvenance) {
27518
27496
  return {
27519
- trySettle: (admitted, authority) => trySettleCoderTerminalResult(admitted, authority, {
27520
- ...methodProvenance === void 0 ? {} : { methodProvenance }
27521
- })
27497
+ trySettle: (admitted, authority, scope) => trySettleCoderTerminalResult(
27498
+ admitted,
27499
+ authority,
27500
+ {
27501
+ ...methodProvenance === void 0 ? {} : { methodProvenance }
27502
+ },
27503
+ scope
27504
+ )
27522
27505
  };
27523
27506
  }
27524
27507
  async function runPublicCoder(argv, env, io, parseCoderArgv2) {
@@ -27612,51 +27595,27 @@ async function runPublicCoder(argv, env, io, parseCoderArgv2) {
27612
27595
  });
27613
27596
  }
27614
27597
  async function runPublicCoderResume(request, env, io) {
27615
- let loaded;
27616
- try {
27617
- loaded = await loadResumableCoderRun(env.home, request.runId, env.principalAuthority);
27618
- } catch (error) {
27619
- if (error instanceof CliUsageError) {
27620
- presentStructuralRejection(error, io);
27621
- return { exitCode: 2 };
27622
- }
27623
- throw error;
27624
- }
27625
- const { admitted } = loaded;
27626
- let methodProvenance;
27627
- if (admitted.phase === "apply") {
27628
- try {
27629
- const material = await loadPackagedMethodSkillMaterial(
27630
- env.packageRoot,
27631
- "tdd"
27632
- );
27633
- methodProvenance = material.provenance;
27634
- } catch (error) {
27635
- return await presentControlledFailure2(
27636
- admitted,
27637
- {
27638
- timedOut: false,
27639
- code: null,
27640
- stderr: "",
27641
- thrown: error,
27642
- knownCause: "activation"
27643
- },
27644
- coderAdapters(),
27645
- env.principalAuthority,
27646
- io
27647
- );
27648
- }
27649
- }
27650
- const turnRequest = buildCoderTurnRequest(
27651
- admitted,
27652
- resumeTurnRequestProjectionOptions(admitted, request, env)
27653
- );
27654
- return await runPostAdmissionManualResume({
27655
- admitted,
27598
+ return await runPostAdmissionSeatResume({
27599
+ request,
27656
27600
  env,
27657
27601
  io,
27658
- request: turnRequest,
27659
- adapters: coderAdapters(methodProvenance),
27602
+ load: (effective) => loadResumableCoderRun(env.home, effective.runId, env.principalAuthority),
27603
+ buildTurnRequest: (admitted, effective) => buildCoderTurnRequest(
27604
+ admitted,
27605
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
27606
+ ),
27607
+ adapters: coderAdapters(),
27608
+ // Apply-only method; plan resume keeps empty provenance (same as initial).
27609
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
27610
+ admitted,
27611
+ authority: env.principalAuthority,
27612
+ io,
27613
+ shouldLoad: admitted.phase === "apply",
27614
+ loadMaterial: () => loadPackagedMethodSkillMaterial(env.packageRoot, "tdd"),
27615
+ adaptersWith: (material) => coderAdapters(material.provenance),
27616
+ emptyAdapters: coderAdapters(),
27617
+ knownCause: "activation"
27618
+ }),
27660
27619
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
27661
27620
  });
27662
27621
  }
@@ -28037,7 +27996,7 @@ async function runPublicCollector(argv, env, io, parseCollectorArgv2) {
28037
27996
  }
28038
27997
  function collectorAdapters() {
28039
27998
  return {
28040
- trySettle: (admitted, authority) => trySettleCollectorTerminalResult(admitted, authority),
27999
+ trySettle: (admitted, authority, scope) => trySettleCollectorTerminalResult(admitted, authority, scope),
28041
28000
  shouldPresentSettled: () => true,
28042
28001
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
28043
28002
  const infrastructureFailure = await readCollectorInfrastructureFailure(sessionFile);
@@ -28697,7 +28656,7 @@ async function runPublicDoctor(argv, env, io, parseDoctorArgv2) {
28697
28656
  }
28698
28657
  function doctorAdapters() {
28699
28658
  return {
28700
- trySettle: (admitted, authority) => trySettleDoctorTerminalResult(admitted, authority),
28659
+ trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
28701
28660
  shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome)
28702
28661
  };
28703
28662
  }
@@ -28757,14 +28716,19 @@ function buildFixerTurnRequest(admitted, options) {
28757
28716
  }
28758
28717
  function fixerAdapters(packageRoot2, methodMaterial) {
28759
28718
  return {
28760
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleFixerTerminalResult(admitted, authority, {
28761
- methodProvenance: methodMaterial.provenance,
28762
- methodSkillPath: methodMaterial.skillPath,
28763
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
28764
- packageRoot2,
28765
- "diagnosing-bugs"
28766
- )
28767
- })
28719
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleFixerTerminalResult(
28720
+ admitted,
28721
+ authority,
28722
+ {
28723
+ methodProvenance: methodMaterial.provenance,
28724
+ methodSkillPath: methodMaterial.skillPath,
28725
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
28726
+ packageRoot2,
28727
+ "diagnosing-bugs"
28728
+ )
28729
+ },
28730
+ scope
28731
+ )
28768
28732
  };
28769
28733
  }
28770
28734
  async function loadFixerMethodMaterial(packageRoot2) {
@@ -28855,44 +28819,24 @@ async function runPublicFixer(argv, env, io, parseFixerArgv2) {
28855
28819
  });
28856
28820
  }
28857
28821
  async function runPublicFixerResume(request, env, io) {
28858
- let loaded;
28859
- try {
28860
- loaded = await loadResumableFixerRun(env.home, request.runId, env.principalAuthority);
28861
- } catch (error) {
28862
- if (error instanceof CliUsageError) {
28863
- presentStructuralRejection(error, io);
28864
- return { exitCode: 2 };
28865
- }
28866
- throw error;
28867
- }
28868
- const { admitted } = loaded;
28869
- let methodMaterial;
28870
- try {
28871
- methodMaterial = await loadFixerMethodMaterial(env.packageRoot);
28872
- } catch (error) {
28873
- return await presentControlledFailure2(
28874
- admitted,
28875
- {
28876
- timedOut: false,
28877
- code: null,
28878
- stderr: "",
28879
- thrown: error
28880
- },
28881
- fixerAdapters(env.packageRoot),
28882
- env.principalAuthority,
28883
- io
28884
- );
28885
- }
28886
- const turnRequest = buildFixerTurnRequest(
28887
- admitted,
28888
- resumeTurnRequestProjectionOptions(admitted, request, env)
28889
- );
28890
- return await runPostAdmissionManualResume({
28891
- admitted,
28822
+ return await runPostAdmissionSeatResume({
28823
+ request,
28892
28824
  env,
28893
28825
  io,
28894
- request: turnRequest,
28895
- adapters: fixerAdapters(env.packageRoot, methodMaterial),
28826
+ load: (effective) => loadResumableFixerRun(env.home, effective.runId, env.principalAuthority),
28827
+ buildTurnRequest: (admitted, effective) => buildFixerTurnRequest(
28828
+ admitted,
28829
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
28830
+ ),
28831
+ adapters: fixerAdapters(env.packageRoot),
28832
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
28833
+ admitted,
28834
+ authority: env.principalAuthority,
28835
+ io,
28836
+ loadMaterial: () => loadFixerMethodMaterial(env.packageRoot),
28837
+ adaptersWith: (material) => fixerAdapters(env.packageRoot, material),
28838
+ emptyAdapters: fixerAdapters(env.packageRoot)
28839
+ }),
28896
28840
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
28897
28841
  });
28898
28842
  }
@@ -29258,7 +29202,7 @@ function buildJudgeTurnRequest(admitted, options) {
29258
29202
  }
29259
29203
  function judgeAdapters() {
29260
29204
  return {
29261
- trySettle: (admitted, authority) => trySettleJudgeTerminalResult(admitted, authority),
29205
+ trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
29262
29206
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
29263
29207
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
29264
29208
  return result2.knownFailure ?? (infrastructureFailure === void 0 ? void 0 : {
@@ -29385,14 +29329,19 @@ function buildMergerTurnRequest(admitted, options) {
29385
29329
  }
29386
29330
  function mergerAdapters(packageRoot2, methodMaterial) {
29387
29331
  return {
29388
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleMergerTerminalResult(admitted, authority, {
29389
- methodProvenance: methodMaterial.provenance,
29390
- methodSkillPath: methodMaterial.skillPath,
29391
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29392
- packageRoot2,
29393
- "resolving-merge-conflicts"
29394
- )
29395
- }),
29332
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleMergerTerminalResult(
29333
+ admitted,
29334
+ authority,
29335
+ {
29336
+ methodProvenance: methodMaterial.provenance,
29337
+ methodSkillPath: methodMaterial.skillPath,
29338
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29339
+ packageRoot2,
29340
+ "resolving-merge-conflicts"
29341
+ )
29342
+ },
29343
+ scope
29344
+ ),
29396
29345
  shouldPresentSettled: (t) => isLawfulTypedTerminalOutcome(t.roleOutcome) || t.roleOutcome.kind === "incomplete"
29397
29346
  };
29398
29347
  }
@@ -29500,45 +29449,25 @@ async function runPublicMerger(argv, env, io, parseMergerArgv2) {
29500
29449
  });
29501
29450
  }
29502
29451
  async function runPublicMergerResume(request, env, io) {
29503
- let loaded;
29504
- try {
29505
- loaded = await loadResumableMergerRun(env.home, request.runId, env.principalAuthority);
29506
- } catch (error) {
29507
- if (error instanceof CliUsageError) {
29508
- presentStructuralRejection(error, io);
29509
- return { exitCode: 2 };
29510
- }
29511
- throw error;
29512
- }
29513
- const { admitted } = loaded;
29514
- let methodMaterial;
29515
- try {
29516
- methodMaterial = await loadMergerMethodMaterial(env.packageRoot);
29517
- } catch (error) {
29518
- return await presentControlledFailure2(
29519
- admitted,
29520
- {
29521
- timedOut: false,
29522
- code: null,
29523
- stderr: "",
29524
- thrown: error,
29525
- knownCause: "activation"
29526
- },
29527
- mergerAdapters(env.packageRoot),
29528
- env.principalAuthority,
29529
- io
29530
- );
29531
- }
29532
- const turnRequest = buildMergerTurnRequest(
29533
- admitted,
29534
- resumeTurnRequestProjectionOptions(admitted, request, env)
29535
- );
29536
- return await runPostAdmissionManualResume({
29537
- admitted,
29452
+ return await runPostAdmissionSeatResume({
29453
+ request,
29538
29454
  env,
29539
29455
  io,
29540
- request: turnRequest,
29541
- adapters: mergerAdapters(env.packageRoot, methodMaterial),
29456
+ load: (effective) => loadResumableMergerRun(env.home, effective.runId, env.principalAuthority),
29457
+ buildTurnRequest: (admitted, effective) => buildMergerTurnRequest(
29458
+ admitted,
29459
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
29460
+ ),
29461
+ adapters: mergerAdapters(env.packageRoot),
29462
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
29463
+ admitted,
29464
+ authority: env.principalAuthority,
29465
+ io,
29466
+ loadMaterial: () => loadMergerMethodMaterial(env.packageRoot),
29467
+ adaptersWith: (material) => mergerAdapters(env.packageRoot, material),
29468
+ emptyAdapters: mergerAdapters(env.packageRoot),
29469
+ knownCause: "activation"
29470
+ }),
29542
29471
  ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29543
29472
  });
29544
29473
  }
@@ -29578,14 +29507,19 @@ function buildReviewerTurnRequest(admitted, options) {
29578
29507
  function reviewerAdapters(packageRoot2, methodMaterial) {
29579
29508
  return {
29580
29509
  beforeDispatch: (admitted) => clearReviewerDispatchRejection(admitted.runDirectory),
29581
- trySettle: (admitted, authority) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(admitted, authority, {
29582
- methodProvenance: methodMaterial.provenance,
29583
- methodSkillPath: methodMaterial.skillPath,
29584
- methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29585
- packageRoot2,
29586
- "code-review"
29587
- )
29588
- }),
29510
+ trySettle: (admitted, authority, scope) => methodMaterial === void 0 ? Promise.resolve(void 0) : trySettleReviewerTerminalResult(
29511
+ admitted,
29512
+ authority,
29513
+ {
29514
+ methodProvenance: methodMaterial.provenance,
29515
+ methodSkillPath: methodMaterial.skillPath,
29516
+ methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
29517
+ packageRoot2,
29518
+ "code-review"
29519
+ )
29520
+ },
29521
+ scope
29522
+ ),
29589
29523
  resolveRunnerKnownFailure: async ({ result: result2, sessionFile }) => {
29590
29524
  const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
29591
29525
  return infrastructureFailure === void 0 ? result2.knownFailure : {
@@ -29684,45 +29618,25 @@ async function runPublicReviewer(argv, env, io, parseReviewerArgv2) {
29684
29618
  });
29685
29619
  }
29686
29620
  async function runPublicReviewerResume(request, env, io) {
29687
- let loaded;
29688
- try {
29689
- loaded = await loadResumableReviewerRun(env.home, request.runId, env.principalAuthority);
29690
- } catch (error) {
29691
- if (error instanceof CliUsageError) {
29692
- presentStructuralRejection(error, io);
29693
- return { exitCode: 2 };
29694
- }
29695
- throw error;
29696
- }
29697
- const { admitted } = loaded;
29698
- let methodMaterial;
29699
- try {
29700
- methodMaterial = await loadReviewerMethodMaterial(env.packageRoot);
29701
- } catch (error) {
29702
- return await presentControlledFailure2(
29703
- admitted,
29704
- {
29705
- timedOut: false,
29706
- code: null,
29707
- stderr: "",
29708
- thrown: error
29709
- },
29710
- reviewerAdapters(env.packageRoot),
29711
- env.principalAuthority,
29712
- io
29713
- );
29714
- }
29715
- const turnRequest = buildReviewerTurnRequest(
29716
- admitted,
29717
- resumeTurnRequestProjectionOptions(admitted, request, env)
29718
- );
29719
- return await runPostAdmissionManualResume({
29720
- admitted,
29621
+ return await runPostAdmissionSeatResume({
29622
+ request,
29721
29623
  env,
29722
29624
  io,
29723
- request: turnRequest,
29724
- ...env.engine === void 0 ? {} : { effectiveEngine: env.engine },
29725
- adapters: reviewerAdapters(env.packageRoot, methodMaterial)
29625
+ load: (effective) => loadResumableReviewerRun(env.home, effective.runId, env.principalAuthority),
29626
+ buildTurnRequest: (admitted, effective) => buildReviewerTurnRequest(
29627
+ admitted,
29628
+ resumeTurnRequestProjectionOptions(admitted, effective, env)
29629
+ ),
29630
+ adapters: reviewerAdapters(env.packageRoot),
29631
+ afterAdmittedLoad: (admitted) => resolveResumeMethodMaterialAdapters({
29632
+ admitted,
29633
+ authority: env.principalAuthority,
29634
+ io,
29635
+ loadMaterial: () => loadReviewerMethodMaterial(env.packageRoot),
29636
+ adaptersWith: (material) => reviewerAdapters(env.packageRoot, material),
29637
+ emptyAdapters: reviewerAdapters(env.packageRoot)
29638
+ }),
29639
+ ...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
29726
29640
  });
29727
29641
  }
29728
29642
  var init_reviewer_run = __esm({