@akagilnc/pi-workflow-roles 0.1.5365 → 0.1.5375

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 (170) hide show
  1. package/dist/acp-host/production-host.js +5585 -5655
  2. package/dist/activation-ledger-git.js +2 -2
  3. package/dist/activation-ledger-topology.js +1 -7
  4. package/dist/analyst-entry.js +4 -8
  5. package/dist/analyst-gate-cycles-read.js +3 -11
  6. package/dist/analyst-index.js +3 -9
  7. package/dist/analyst-ledger.js +1 -11
  8. package/dist/analyst-metric-families/acceptance-success-rework.js +1 -3
  9. package/dist/analyst-metric-families/round-timeline.js +1 -3
  10. package/dist/analyst-page.js +2 -2
  11. package/dist/archivist-record-topology.js +2 -2
  12. package/dist/audit-escalation.js +2 -1
  13. package/dist/auditor-soul.js +2 -1
  14. package/dist/collector-config.js +6 -8
  15. package/dist/compliance-transport.js +2 -1
  16. package/dist/countersign-contracts.js +2 -1
  17. package/dist/diarist-contracts.js +3 -2
  18. package/dist/doctor-contracts.js +1 -3
  19. package/dist/doctor-evidence.js +7 -8
  20. package/dist/dossier-resolution.js +1 -3
  21. package/dist/engine-detour-usage.js +1 -3
  22. package/dist/gatekeeper-role.js +2 -9
  23. package/dist/gleaner-left-contracts.js +2 -1
  24. package/dist/headless-host/description.js +14 -17
  25. package/dist/headless-host/production-host.js +1665 -1737
  26. package/dist/host-session-record.js +3 -2
  27. package/dist/inspector-contracts.js +2 -1
  28. package/dist/ledger-session-read.js +1 -3
  29. package/dist/merger-contracts.js +9 -9
  30. package/dist/migrate-book-topology.js +348 -314
  31. package/dist/navigator-attendance.js +9 -11
  32. package/dist/navigator-invocation-identity.js +3 -2
  33. package/dist/navigator-public-session.js +3 -5
  34. package/dist/navigator-session-contracts.js +8 -10
  35. package/dist/navigator-work-base.js +5 -8
  36. package/dist/notary-contracts.js +3 -5
  37. package/dist/package-contracts/auditor-output.js +1 -3
  38. package/dist/package-contracts/fixer-packet.js +3 -6
  39. package/dist/package-contracts/gatekeeper-output.js +1 -3
  40. package/dist/package-contracts/navigator-output.js +8 -8
  41. package/dist/package-contracts/terminating-infrastructure.js +5 -9
  42. package/dist/package-contracts/terminating-tools.js +4 -3
  43. package/dist/public-cli/analyst-run.js +3 -2
  44. package/dist/public-cli/auto-resume.js +4 -9
  45. package/dist/public-cli/cli.js +66 -64
  46. package/dist/public-cli/config.js +12 -11
  47. package/dist/public-cli/countersign-run.js +1 -3
  48. package/dist/public-cli/host-providers.js +7 -14
  49. package/dist/public-cli/instruction-seat-run.js +69 -43
  50. package/dist/public-cli/invocation.js +141 -136
  51. package/dist/public-cli/main.js +1919 -1968
  52. package/dist/public-cli/post-admission.js +89 -89
  53. package/dist/public-cli/role-seat-runtime.js +29 -0
  54. package/dist/public-cli/run-lifecycle.js +20 -32
  55. package/dist/public-cli/settlement.js +10 -26
  56. package/dist/public-cli/turn-request.js +14 -0
  57. package/dist/public-role-summons.js +23 -35
  58. package/dist/receipt-delivery-policy.js +1 -3
  59. package/dist/role-run-placement.js +7 -5
  60. package/dist/role-run-relocation.js +12 -19
  61. package/dist/run-terminal-artifacts.js +1 -11
  62. package/dist/run-ticket-number.js +2 -4
  63. package/dist/session-assistant-usage.js +2 -1
  64. package/dist/session-dialogue.js +1 -14
  65. package/dist/sitian-reader.js +2 -4
  66. package/dist/submission-correctable-error.js +2 -1
  67. package/dist/submission-errors.js +2 -1
  68. package/dist/submission-gate.js +2 -1
  69. package/dist/submission-ledger.js +4 -5
  70. package/dist/ticket-provenance-contracts.js +1 -3
  71. package/dist/ticket-provenance.js +2 -1
  72. package/dist/typed-provider-http.js +4 -7
  73. package/dist/unknown-value.js +28 -0
  74. package/dist/user-dialogue-stdin.js +2 -1
  75. package/package.json +1 -1
  76. package/src/acp-host/role-turn-host.ts +4 -2
  77. package/src/activation-ledger-git.ts +3 -2
  78. package/src/activation-ledger-topology.ts +4 -12
  79. package/src/analyst-entry.ts +3 -11
  80. package/src/analyst-gate-cycles-read.ts +3 -15
  81. package/src/analyst-index.ts +3 -13
  82. package/src/analyst-ledger.ts +2 -16
  83. package/src/analyst-metric-families/acceptance-success-rework.ts +2 -4
  84. package/src/analyst-metric-families/round-timeline.ts +2 -4
  85. package/src/analyst-page.ts +2 -2
  86. package/src/archivist-record-topology.ts +2 -2
  87. package/src/audit-escalation.ts +2 -1
  88. package/src/auditor-soul.ts +3 -1
  89. package/src/book-topology-migration-placement.ts +8 -21
  90. package/src/book-topology-migrators-t11.ts +16 -15
  91. package/src/book-topology-mixed-volume-migrators.ts +3 -6
  92. package/src/book-topology-record-class-migrators.ts +7 -10
  93. package/src/book-topology-runs-migrator.ts +4 -3
  94. package/src/collector-config.ts +7 -9
  95. package/src/compliance-transport.ts +2 -1
  96. package/src/countersign-contracts.ts +2 -1
  97. package/src/diarist-contracts.ts +3 -2
  98. package/src/doctor-contracts.ts +3 -1
  99. package/src/doctor-evidence.ts +8 -7
  100. package/src/doctor-role.ts +4 -2
  101. package/src/dossier-resolution.ts +2 -4
  102. package/src/engine-detour-tool.ts +0 -2
  103. package/src/engine-detour-usage.ts +2 -4
  104. package/src/external-host-turn-loop.ts +3 -1
  105. package/src/factory-board.ts +1 -8
  106. package/src/gatekeeper-role.ts +2 -10
  107. package/src/gleaner-left-contracts.ts +3 -1
  108. package/src/headless-host/description.ts +15 -18
  109. package/src/headless-host/role-turn-host.ts +10 -9
  110. package/src/host-session-record.ts +4 -2
  111. package/src/inspector-contracts.ts +2 -1
  112. package/src/ledger-session-read.ts +2 -5
  113. package/src/merger-contracts.ts +10 -9
  114. package/src/navigator-attendance.ts +10 -12
  115. package/src/navigator-invocation-identity.ts +3 -2
  116. package/src/navigator-public-session.ts +4 -6
  117. package/src/navigator-session-contracts.ts +8 -11
  118. package/src/navigator-work-base.ts +5 -8
  119. package/src/navigator-work-context.ts +2 -1
  120. package/src/notary-contracts.ts +4 -6
  121. package/src/oauth-keepalive.ts +5 -18
  122. package/src/package-contracts/auditor-output.ts +2 -4
  123. package/src/package-contracts/fixer-packet.ts +4 -6
  124. package/src/package-contracts/gatekeeper-output.ts +2 -4
  125. package/src/package-contracts/judge-output.ts +0 -1
  126. package/src/package-contracts/navigator-output.ts +8 -8
  127. package/src/package-contracts/terminating-infrastructure.ts +6 -20
  128. package/src/package-contracts/terminating-tools.ts +8 -12
  129. package/src/pi/adapter.ts +0 -1
  130. package/src/pi/role-turn-host.ts +0 -1
  131. package/src/public-cli/analyst-run.ts +4 -2
  132. package/src/public-cli/auto-resume.ts +5 -12
  133. package/src/public-cli/cli.ts +77 -83
  134. package/src/public-cli/config.ts +16 -27
  135. package/src/public-cli/countersign-run.ts +2 -4
  136. package/src/public-cli/host-providers.ts +10 -27
  137. package/src/public-cli/instruction-seat-run.ts +87 -58
  138. package/src/public-cli/invocation.ts +159 -172
  139. package/src/public-cli/post-admission.ts +115 -103
  140. package/src/public-cli/role-seat-runtime.ts +72 -0
  141. package/src/public-cli/run-lifecycle.ts +27 -67
  142. package/src/public-cli/settlement.ts +11 -33
  143. package/src/public-cli/terminal.ts +2 -17
  144. package/src/public-cli/turn-request.ts +26 -0
  145. package/src/public-role-summons.ts +24 -48
  146. package/src/receipt-delivery-policy.ts +1 -4
  147. package/src/reviewer-role.ts +0 -1
  148. package/src/role-envelope.ts +5 -3
  149. package/src/role-run-placement.ts +9 -10
  150. package/src/role-run-relocation.ts +13 -23
  151. package/src/role-runtime.ts +9 -15
  152. package/src/run-terminal-artifacts.ts +2 -16
  153. package/src/run-ticket-number.ts +4 -10
  154. package/src/session-assistant-usage.ts +3 -1
  155. package/src/session-dialogue.ts +1 -4
  156. package/src/session-identity.ts +0 -1
  157. package/src/sitian-reader.ts +2 -4
  158. package/src/submission-correctable-error.ts +3 -1
  159. package/src/submission-errors.ts +2 -1
  160. package/src/submission-gate.ts +3 -1
  161. package/src/submission-ledger.ts +5 -6
  162. package/src/ticket-provenance-contracts.ts +1 -4
  163. package/src/ticket-provenance.ts +3 -1
  164. package/src/ticket-snapshot.ts +2 -4
  165. package/src/ticket-trajectory.ts +1 -8
  166. package/src/typed-provider-http.ts +5 -15
  167. package/src/unknown-value.ts +34 -0
  168. package/src/user-dialogue-stdin.ts +3 -1
  169. package/src/worker-role.ts +2 -5
  170. package/src/worker-submission-gates.ts +5 -7
@@ -3,7 +3,8 @@
3
3
  * Seat differences are composition-root fields. An omitted reviewer lens
4
4
  * starts two ordinary single-axis runs here.
5
5
  */
6
- import { dirname, resolve, sep } from "node:path";
6
+ import { dirname, resolve } from "node:path";
7
+ import { isUnboundRunDirectory } from "../role-run-placement.js";
7
8
  import { AUDITOR_DOSSIER_PROMPT } from "../compliance-transport.js";
8
9
  import { bookDirectOfficerRunPointer } from "../archivist-record-pointer.js";
9
10
  import { createPiDoctorAuditor } from "../doctor-auditor.js";
@@ -22,7 +23,7 @@ import { isSafePositiveTicketNumber, readBoardTicketNumber } from "../run-ticket
22
23
  import { NotarySourceRunError, resolveNotarySourceRunLocator } from "../notary-source-run.js";
23
24
  import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
24
25
  import { packagedAdmitsCountersign, packagedBindsBoardTicket, packagedRebindSourceOnResume, packagedRoleMetadata, } from "../packaged-role-registry.js";
25
- import { isAuditorSoulRole, readAuditorResumeBinding } from "../auditor-soul.js";
26
+ import { readAuditorResumeBinding } from "../auditor-soul.js";
26
27
  import { CliUsageError } from "./cli-errors.js";
27
28
  import { admitPublicRole, bindAdmittedTicketNumber, buildInstructionTransportPrompt, materializeCountersignInvocation, persistAdmittedSourceRunPath, recordAdmittedCorrelation, recordChildDiaristRun, relocateAdmittedRunToTicket, withPreparedAttachments, } from "./invocation.js";
28
29
  import { presentControlledFailure, prepareSummonsResumeMaterials, roleTurnOptions, runPostAdmissionOneShot, runPostAdmissionResumable, runPostAdmissionSeatResume, showResumeErrorPointer, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
@@ -31,8 +32,9 @@ import { tryResumeSameTicketSeatRun } from "./seat-ticket-binding.js";
31
32
  import { presentStructuralRejection, readBoundSessionEntries, seatKnownFailureResolver, attachPostAuditProjection, trySettlePublicSeat, } from "./settlement.js";
32
33
  import { warnMissingMethodSkills } from "./machine-method-skills.js";
33
34
  import { formatTerminalResult, isLawfulTypedTerminalOutcome, } from "./terminal.js";
34
- import { admittedSeatTurnDetails, projectRoleTurnRequest, requiredMethodSkills, } from "./turn-request.js";
35
+ import { admittedSeatTurnDetails, projectPublicTurnAxes, projectRoleTurnRequest, requiredMethodSkills, } from "./turn-request.js";
35
36
  import { invokeCourtDiarist, latestPayloadEscalated, } from "./countersign-run.js";
37
+ import { isRecord, errorText } from "../unknown-value.js";
36
38
  const AUDITED_ROLES = new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
37
39
  const SECRETARIAT_STATUS_REASK = "secretariatStatus 不是 converged、escalate 之一。请重新交卷,secretariatStatus 写明其一。";
38
40
  const COUNTERSIGN_STATUS_REASK = "status 不是 converged、continue、escalate 三态之一。请重新交卷,status 写明其一。";
@@ -73,7 +75,7 @@ function unreadablePostSubmissionStatus(admitted, terminal) {
73
75
  if (route === undefined)
74
76
  return undefined;
75
77
  const payload = terminal.roleOutcome.payloads?.at(-1);
76
- const status = payload !== null && typeof payload === "object" && !Array.isArray(payload)
78
+ const status = isRecord(payload)
77
79
  ? payload.status
78
80
  : undefined;
79
81
  return typeof status === "string" && route.statuses.has(status)
@@ -309,6 +311,29 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
309
311
  io.stdout(formatTerminalResult(terminal));
310
312
  return { exitCode: failed ? 1 : 0, terminal };
311
313
  }
314
+ /**
315
+ * One same-parent lookup. Seat branches still build their own summons.
316
+ * A found child resumes that child; no prior run returns undefined so the caller mints.
317
+ */
318
+ function resumeSameParentInstructionSeat(input) {
319
+ return tryResumeSameTicketSeatRun({
320
+ home: input.env.home,
321
+ projectRoot: input.projectRoot,
322
+ role: input.role,
323
+ parentRunPath: input.parentRunPath,
324
+ ...(input.ticketNumber === undefined ? {} : { ticketNumber: input.ticketNumber }),
325
+ freshSummons: input.env.freshSummons,
326
+ summons: input.summons,
327
+ resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, input.env, input.io),
328
+ });
329
+ }
330
+ /** Re-ask words when the parent supplied them; otherwise the caller's own instruction. */
331
+ function sameParentInstruction(env, fallback) {
332
+ const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
333
+ if (resumeInstruction === undefined)
334
+ return fallback;
335
+ return { instruction: resumeInstruction, instructionEmpty: false };
336
+ }
312
337
  /**
313
338
  * Countersign on the shared entry: gate parent resume, deferred materialization,
314
339
  * then the same one-shot settlement as every other seat.
@@ -319,19 +344,20 @@ async function runCountersignBody(parsed, env, io) {
319
344
  : undefined;
320
345
  if (gateParentRunPath !== undefined) {
321
346
  const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
322
- const resumed = await tryResumeSameTicketSeatRun({
323
- home: env.home,
347
+ const resumed = await resumeSameParentInstructionSeat({
348
+ env,
349
+ io,
324
350
  projectRoot: resolve(parsed.project ?? env.cwd),
325
351
  role: "countersign",
326
352
  parentRunPath: gateParentRunPath,
327
- ...(isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {}),
328
- freshSummons: env.freshSummons,
353
+ ...(isSafePositiveTicketNumber(env.boundTicketNumber)
354
+ ? { ticketNumber: env.boundTicketNumber }
355
+ : {}),
329
356
  summons: {
330
357
  sourceRunPath: gateParentRunPath,
331
358
  instruction: resumeInstruction,
332
359
  instructionEmpty: resumeInstruction.trim() === "",
333
360
  },
334
- resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
335
361
  });
336
362
  if (resumed != null)
337
363
  return resumed;
@@ -364,12 +390,7 @@ async function runCountersignBody(parsed, env, io) {
364
390
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
365
391
  }
366
392
  const turnProjection = {
367
- packageRoot: env.packageRoot,
368
- home: env.home,
369
- agentDir: env.agentDir,
370
- ...(env.model === undefined ? {} : { model: env.model }),
371
- ...pickEngineAxis(env),
372
- ...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
393
+ ...projectPublicTurnAxes(env),
373
394
  ...(env.correlationId === undefined || env.correlationId.trim() === ""
374
395
  ? {}
375
396
  : { correlationId: env.correlationId }),
@@ -446,47 +467,47 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
446
467
  let auditorSubject;
447
468
  let auditorSource;
448
469
  let auditorTicket;
470
+ let resolvedNotarySource;
449
471
  if (record.sameParent === "subject-source") {
450
- if (!isAuditorSoulRole(parsed.subject)) {
472
+ if (parsed.subject === undefined) {
451
473
  presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
452
474
  return { exitCode: 2 };
453
475
  }
454
476
  auditorSubject = parsed.subject;
455
- const source = typeof parsed.sourceRun === "string" ? parsed.sourceRun.trim() : "";
456
- if (source === "") {
477
+ if (parsed.sourceRun === undefined) {
457
478
  presentStructuralRejection(new CliUsageError("auditor --source-run requires a run locator"), io);
458
479
  return { exitCode: 2 };
459
480
  }
481
+ const source = parsed.sourceRun;
460
482
  try {
461
483
  const resolved = await resolveNotarySourceRunLocator({ projectRoot, sourceRun: source, home: env.home });
462
484
  auditorSource = resolved.runDirectory;
463
485
  auditorTicket = await readBoardTicketNumber(resolved.runDirectory);
464
486
  }
465
487
  catch (error) {
466
- presentStructuralRejection(new CliUsageError(error instanceof Error ? error.message : String(error)), io);
488
+ presentStructuralRejection(new CliUsageError(errorText(error)), io);
467
489
  return { exitCode: 2 };
468
490
  }
469
491
  if (auditorSource === undefined)
470
492
  return { exitCode: 2 };
471
493
  const sourceDirectory = auditorSource;
472
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
473
494
  const summons = {
474
- ...(resumeInstruction === undefined
475
- ? { instruction: parsed.instruction ?? "", instructionEmpty: (parsed.instruction ?? "").trim() === "" }
476
- : { instruction: resumeInstruction, instructionEmpty: false }),
495
+ ...sameParentInstruction(env, {
496
+ instruction: parsed.instruction ?? "",
497
+ instructionEmpty: (parsed.instruction ?? "").trim() === "",
498
+ }),
477
499
  attachmentPaths: parsed.attachmentPaths ?? [],
478
500
  };
479
501
  const resumed = await withAuditorSoulEnv({
480
502
  subject: auditorSubject,
481
503
  sourceRunDirectory: auditorSource,
482
- run: () => tryResumeSameTicketSeatRun({
483
- home: env.home,
504
+ run: () => resumeSameParentInstructionSeat({
505
+ env,
506
+ io,
484
507
  projectRoot,
485
508
  role,
486
509
  parentRunPath: sourceDirectory,
487
- freshSummons: env.freshSummons,
488
510
  summons,
489
- resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
490
511
  }),
491
512
  });
492
513
  if (resumed != null)
@@ -495,22 +516,21 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
495
516
  if (record.sameParent === "gate-pointer") {
496
517
  const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
497
518
  if (parentRunPath !== undefined) {
498
- const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
499
519
  const summons = {
500
520
  sourceRunPath: parentRunPath,
501
- ...(resumeInstruction === undefined
502
- ? { instruction: parsed.instruction ?? "", instructionEmpty: (parsed.instruction ?? "").trim() === "" }
503
- : { instruction: resumeInstruction, instructionEmpty: false }),
521
+ ...sameParentInstruction(env, {
522
+ instruction: parsed.instruction ?? "",
523
+ instructionEmpty: (parsed.instruction ?? "").trim() === "",
524
+ }),
504
525
  attachmentPaths: parsed.attachmentPaths ?? [],
505
526
  };
506
- const resumed = await tryResumeSameTicketSeatRun({
507
- home: env.home,
527
+ const resumed = await resumeSameParentInstructionSeat({
528
+ env,
529
+ io,
508
530
  projectRoot,
509
531
  role,
510
532
  parentRunPath,
511
- freshSummons: env.freshSummons,
512
533
  summons,
513
- resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
514
534
  });
515
535
  if (resumed != null)
516
536
  return resumed;
@@ -536,23 +556,29 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
536
556
  const summons = {
537
557
  sourceRunPath: source.runDirectory,
538
558
  sourceRun: source,
539
- ...(resumeInstruction === undefined ? {} : { instruction: resumeInstruction, instructionEmpty: false }),
559
+ ...(resumeInstruction === undefined
560
+ ? {}
561
+ : { instruction: resumeInstruction, instructionEmpty: false }),
540
562
  };
541
- const resumed = await tryResumeSameTicketSeatRun({
542
- home: env.home,
563
+ resolvedNotarySource = source;
564
+ const resumed = await resumeSameParentInstructionSeat({
565
+ env,
566
+ io,
543
567
  projectRoot,
544
568
  role,
545
569
  parentRunPath: source.runDirectory,
546
- freshSummons: env.freshSummons,
547
570
  summons,
548
- resume: (runId, materials) => runPublicInstructionSeatResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
549
571
  });
550
572
  if (resumed != null)
551
573
  return resumed;
552
574
  }
553
575
  let admitted;
554
576
  try {
555
- admitted = await admitPublicRole(role, parsed, env, auditorTicket === undefined ? undefined : { assertedTicketNumber: auditorTicket });
577
+ const admissionOverride = {
578
+ ...(auditorTicket === undefined ? {} : { assertedTicketNumber: auditorTicket }),
579
+ ...(resolvedNotarySource === undefined ? {} : { resolvedSourceRun: resolvedNotarySource }),
580
+ };
581
+ admitted = await admitPublicRole(role, parsed, env, auditorTicket === undefined && resolvedNotarySource === undefined ? undefined : admissionOverride);
556
582
  }
557
583
  catch (error) {
558
584
  const rejected = usageExit(error, io);
@@ -589,7 +615,7 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
589
615
  timedOut: false, code: null, stderr: "", thrown: error,
590
616
  }, seatAdapters(admitted, env), env.principalAuthority, io);
591
617
  }
592
- if (outcome.admitted?.runDirectory.includes(`${sep}unbound${sep}runs${sep}`)) {
618
+ if (outcome.admitted !== undefined && isUnboundRunDirectory(outcome.admitted.runDirectory)) {
593
619
  await recordChildDiaristRun(admitted, outcome.admitted.runId);
594
620
  }
595
621
  if (outcome.failedWithoutEscalate !== undefined) {
@@ -760,7 +786,7 @@ async function auditSubmittedRole(turn, env, io, passedOfficer, passedReceipt, p
760
786
  const accepted = turn.terminal.roleOutcome.payloads?.at(-1);
761
787
  if (accepted === undefined)
762
788
  throw new Error("accepted submission has no payload");
763
- const record = accepted !== null && typeof accepted === "object" && !Array.isArray(accepted)
789
+ const record = isRecord(accepted)
764
790
  ? accepted : undefined;
765
791
  const status = admitted.role === "secretariat" ? record?.secretariatStatus : record?.status;
766
792
  if (admitted.role === "secretariat" && status !== "converged" && status !== "escalate") {