@akagilnc/pi-workflow-roles 0.1.5295 → 0.1.5301

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.
@@ -7,103 +7,8 @@
7
7
  * #901: LLM submits bounds; the mechanical layer projects source bytes.
8
8
  */
9
9
  import { projectTicketProvenanceSessions, } from "./ticket-provenance-contracts.js";
10
- import { isSafePositiveTicketNumber, requireSafePositiveTicketNumber, } from "./run-ticket-number.js";
10
+ import { isSafePositiveTicketNumber } from "./run-ticket-number.js";
11
11
  export const DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
12
- /**
13
- * Sole shape projection for a typed co-review ticket set (#871).
14
- * Positive safe integers, first-seen order, duplicates dropped. Not content judgment.
15
- * Returns null when `raw` is not an array (callers classify absent vs durable damage).
16
- * Returns a possibly empty list when `raw` is an array (unlawful members skipped).
17
- * When `principalTicket` is set, that ticket is guaranteed as a member (prepended if missing).
18
- */
19
- export function projectCourtTicketNumbers(raw, options) {
20
- if (!Array.isArray(raw))
21
- return null;
22
- const out = [];
23
- const seen = new Set();
24
- for (const item of raw) {
25
- if (!isSafePositiveTicketNumber(item))
26
- continue;
27
- if (seen.has(item))
28
- continue;
29
- seen.add(item);
30
- out.push(item);
31
- }
32
- const principal = options?.principalTicket;
33
- if (principal === undefined)
34
- return out;
35
- requireSafePositiveTicketNumber(principal, "projectCourtTicketNumbers principalTicket");
36
- if (seen.has(principal))
37
- return out;
38
- return [principal, ...out];
39
- }
40
- /**
41
- * Durable-field interpreter for #871 co-review sets.
42
- * Absent key (old-format run) is not damage. Present but empty / non-array /
43
- * partially unlawful / missing principal is damage — callers must fail closed,
44
- * never wash into main-only.
45
- */
46
- export function interpretDurableCourtTicketNumbers(record, options) {
47
- if (!Object.hasOwn(record, "courtTicketNumbers")) {
48
- return { kind: "absent" };
49
- }
50
- const raw = record.courtTicketNumbers;
51
- if (!Array.isArray(raw)) {
52
- return {
53
- kind: "damage",
54
- reason: "courtTicketNumbers is present but not an array",
55
- };
56
- }
57
- if (raw.length === 0) {
58
- return {
59
- kind: "damage",
60
- reason: "courtTicketNumbers is present but empty",
61
- };
62
- }
63
- for (let i = 0; i < raw.length; i += 1) {
64
- const item = raw[i];
65
- if (!isSafePositiveTicketNumber(item)) {
66
- return {
67
- kind: "damage",
68
- reason: `courtTicketNumbers[${i}] is not a safe positive integer`,
69
- };
70
- }
71
- }
72
- // Members are all lawful numbers; sole projection owns dedupe/order.
73
- const tickets = projectCourtTicketNumbers(raw);
74
- if (tickets === null || tickets.length === 0) {
75
- return {
76
- kind: "damage",
77
- reason: "courtTicketNumbers projected empty after lawful members",
78
- };
79
- }
80
- const principal = options?.principalTicket;
81
- if (principal !== undefined) {
82
- if (!isSafePositiveTicketNumber(principal)) {
83
- return {
84
- kind: "damage",
85
- reason: "courtTicketNumbers principal ticket is not a safe positive integer",
86
- };
87
- }
88
- if (!tickets.includes(principal)) {
89
- return {
90
- kind: "damage",
91
- reason: `courtTicketNumbers is missing principal ticket #${principal}`,
92
- };
93
- }
94
- }
95
- return { kind: "ok", tickets: Object.freeze([...tickets]) };
96
- }
97
- /** True when two durable #871 sets are byte-identical sequences. */
98
- export function sameCourtTicketNumbers(left, right) {
99
- if (left.length !== right.length)
100
- return false;
101
- for (let i = 0; i < left.length; i += 1) {
102
- if (left[i] !== right[i])
103
- return false;
104
- }
105
- return true;
106
- }
107
12
  export function validateRecordedDiaristOutput(value) {
108
13
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
109
14
  throw new Error("Diarist output has no execution discriminator");
@@ -856,79 +856,6 @@ var init_run_ticket_number = __esm({
856
856
  });
857
857
 
858
858
  // src/diarist-contracts.ts
859
- function projectCourtTicketNumbers(raw, options) {
860
- if (!Array.isArray(raw)) return null;
861
- const out = [];
862
- const seen = /* @__PURE__ */ new Set();
863
- for (const item of raw) {
864
- if (!isSafePositiveTicketNumber(item)) continue;
865
- if (seen.has(item)) continue;
866
- seen.add(item);
867
- out.push(item);
868
- }
869
- const principal = options?.principalTicket;
870
- if (principal === void 0) return out;
871
- requireSafePositiveTicketNumber(principal, "projectCourtTicketNumbers principalTicket");
872
- if (seen.has(principal)) return out;
873
- return [principal, ...out];
874
- }
875
- function interpretDurableCourtTicketNumbers(record4, options) {
876
- if (!Object.hasOwn(record4, "courtTicketNumbers")) {
877
- return { kind: "absent" };
878
- }
879
- const raw = record4.courtTicketNumbers;
880
- if (!Array.isArray(raw)) {
881
- return {
882
- kind: "damage",
883
- reason: "courtTicketNumbers is present but not an array"
884
- };
885
- }
886
- if (raw.length === 0) {
887
- return {
888
- kind: "damage",
889
- reason: "courtTicketNumbers is present but empty"
890
- };
891
- }
892
- for (let i = 0; i < raw.length; i += 1) {
893
- const item = raw[i];
894
- if (!isSafePositiveTicketNumber(item)) {
895
- return {
896
- kind: "damage",
897
- reason: `courtTicketNumbers[${i}] is not a safe positive integer`
898
- };
899
- }
900
- }
901
- const tickets = projectCourtTicketNumbers(raw);
902
- if (tickets === null || tickets.length === 0) {
903
- return {
904
- kind: "damage",
905
- reason: "courtTicketNumbers projected empty after lawful members"
906
- };
907
- }
908
- const principal = options?.principalTicket;
909
- if (principal !== void 0) {
910
- if (!isSafePositiveTicketNumber(principal)) {
911
- return {
912
- kind: "damage",
913
- reason: "courtTicketNumbers principal ticket is not a safe positive integer"
914
- };
915
- }
916
- if (!tickets.includes(principal)) {
917
- return {
918
- kind: "damage",
919
- reason: `courtTicketNumbers is missing principal ticket #${principal}`
920
- };
921
- }
922
- }
923
- return { kind: "ok", tickets: Object.freeze([...tickets]) };
924
- }
925
- function sameCourtTicketNumbers(left, right) {
926
- if (left.length !== right.length) return false;
927
- for (let i = 0; i < left.length; i += 1) {
928
- if (left[i] !== right[i]) return false;
929
- }
930
- return true;
931
- }
932
859
  function projectDiaristSessions(value) {
933
860
  const raw = value?.sessions;
934
861
  if (raw === void 0) return [];
@@ -7200,43 +7127,6 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
7200
7127
  mutable.correlationId = correlationId;
7201
7128
  mutable.correlationIds = correlationIds;
7202
7129
  }
7203
- async function bindCourtTicketNumbersOnAdmitted(admitted, courtTicketNumbers) {
7204
- if (admitted.ticketNumber === void 0) {
7205
- throw new Error(
7206
- "bindCourtTicketNumbersOnAdmitted requires a bound principal ticketNumber"
7207
- );
7208
- }
7209
- const principal = requireSafePositiveTicketNumber(
7210
- admitted.ticketNumber,
7211
- "bindCourtTicketNumbersOnAdmitted principal ticketNumber"
7212
- );
7213
- for (const item of courtTicketNumbers) {
7214
- if (!isSafePositiveTicketNumber(item)) {
7215
- throw new Error(
7216
- `bindCourtTicketNumbersOnAdmitted requires safe positive integers, got ${String(item)}`
7217
- );
7218
- }
7219
- }
7220
- const projected = projectCourtTicketNumbers(courtTicketNumbers, {
7221
- principalTicket: principal
7222
- });
7223
- if (projected === null || projected.length === 0) {
7224
- throw new Error("bindCourtTicketNumbersOnAdmitted requires a non-empty ticket set");
7225
- }
7226
- const frozen = Object.freeze([...projected]);
7227
- const admittedPath = admitted.admittedRequestPath;
7228
- const current = JSON.parse(await readFile13(admittedPath, "utf8"));
7229
- await writeFile5(
7230
- admittedPath,
7231
- `${JSON.stringify({ ...current, courtTicketNumbers: frozen }, null, 2)}
7232
- `,
7233
- "utf8"
7234
- );
7235
- await mergeInvocationIdentityPage(admitted.runDirectory, {
7236
- courtTicketNumbers: frozen
7237
- });
7238
- admitted.courtTicketNumbers = frozen;
7239
- }
7240
7130
  async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
7241
7131
  if (admitted.ticketNumber === void 0 || !admitted.runDirectory.includes(`${sep3}unbound${sep3}runs${sep3}`)) return void 0;
7242
7132
  const oldRunDirectory = admitted.runDirectory;
@@ -8696,7 +8586,6 @@ var init_invocation = __esm({
8696
8586
  init_run_ticket_number();
8697
8587
  init_role_run_relocation();
8698
8588
  init_doctor_evidence();
8699
- init_diarist_contracts();
8700
8589
  init_collector_config();
8701
8590
  init_github_remote();
8702
8591
  init_fixer_packet();
@@ -13514,9 +13403,6 @@ async function dispatchPostAdmissionTurn(input) {
13514
13403
  io,
13515
13404
  persistRunState
13516
13405
  );
13517
- if (error instanceof StationChildExhaustedError) {
13518
- return { ...settled2, skipAutoResume: true, ...deferredPersist };
13519
- }
13520
13406
  return { ...settled2, ...deferredPersist };
13521
13407
  }
13522
13408
  }
@@ -14219,7 +14105,7 @@ async function runPostAdmissionManualResume(input) {
14219
14105
  }
14220
14106
  return result;
14221
14107
  }
14222
- var StationChildExhaustedError, POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
14108
+ var POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
14223
14109
  var init_post_admission = __esm({
14224
14110
  "src/public-cli/post-admission.ts"() {
14225
14111
  "use strict";
@@ -14241,9 +14127,6 @@ var init_post_admission = __esm({
14241
14127
  init_settlement();
14242
14128
  init_terminal();
14243
14129
  init_auto_resume();
14244
- StationChildExhaustedError = class extends Error {
14245
- name = "StationChildExhaustedError";
14246
- };
14247
14130
  POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE = "ak_post_admission_cleanup_diagnostic";
14248
14131
  }
14249
14132
  });
@@ -14542,30 +14425,6 @@ function courtDiaristEscalateDiagnostic(roleOutcome, submissions) {
14542
14425
  currentConclusion: escalatePayloads[escalatePayloads.length - 1]
14543
14426
  })}`;
14544
14427
  }
14545
- function courtTicketNumbersFromOutcome(roleOutcome, principalTicket, submissions) {
14546
- if (roleOutcome === void 0) return void 0;
14547
- const payloads = courtDiaristPayloadRows(roleOutcome, submissions);
14548
- let latest;
14549
- for (const payload of payloads) {
14550
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
14551
- continue;
14552
- }
14553
- const record4 = payload;
14554
- if (!Object.hasOwn(record4, "courtTicketNumbers")) continue;
14555
- const raw = record4.courtTicketNumbers;
14556
- if (!Array.isArray(raw)) continue;
14557
- const members = projectCourtTicketNumbers(raw);
14558
- if (members === null) continue;
14559
- if (members.length === 0) {
14560
- if (raw.length === 0) {
14561
- latest = projectCourtTicketNumbers([], { principalTicket }) ?? void 0;
14562
- }
14563
- continue;
14564
- }
14565
- latest = projectCourtTicketNumbers(raw, { principalTicket }) ?? void 0;
14566
- }
14567
- return latest;
14568
- }
14569
14428
  function latestPayloadEscalated(roleOutcome) {
14570
14429
  if (roleOutcome === void 0) return false;
14571
14430
  if (roleOutcome.kind === "audit_escalation") return true;
@@ -14605,7 +14464,6 @@ async function invokeCourtDiarist(input, env, io) {
14605
14464
  ...env.credentials === void 0 ? {} : { credentials: env.credentials },
14606
14465
  ...env.signal === void 0 ? {} : { signal: env.signal },
14607
14466
  ...input.correlationId === void 0 ? {} : { correlationId: input.correlationId },
14608
- ...input.boundTicketNumber === void 0 ? {} : { boundTicketNumber: input.boundTicketNumber },
14609
14467
  // Child seat selects from the composition-root table. Do not pass the
14610
14468
  // already-selected parent adapter (#840 / ADR 0082: --host 旗标>席位配置>缺省 pi).
14611
14469
  ...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters }
@@ -14632,78 +14490,15 @@ async function invokeCourtDiarist(input, env, io) {
14632
14490
  }
14633
14491
  };
14634
14492
  }
14635
- const asserted = result.admitted?.ticketNumber;
14636
- if (isSafePositiveTicketNumber(asserted)) {
14637
- const courtTicketNumbers = courtTicketNumbersFromOutcome(
14638
- roleOutcome,
14639
- asserted,
14640
- submissions
14641
- );
14642
- return {
14643
- identity: {
14644
- kind: "ticket",
14645
- ticketNumber: asserted,
14646
- ...courtTicketNumbers === void 0 ? {} : { courtTicketNumbers }
14647
- },
14648
- ...result.admitted === void 0 ? {} : { admitted: result.admitted }
14649
- };
14650
- }
14651
14493
  return {
14652
14494
  identity: { kind: "unbound" },
14653
14495
  ...result.admitted === void 0 ? {} : { admitted: result.admitted }
14654
14496
  };
14655
14497
  }
14656
- async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketNumber) {
14657
- if (env.runCourtDiaristStation !== void 0) {
14658
- await env.runCourtDiaristStation(admitted);
14659
- return;
14660
- }
14661
- if (admitted.ticketNumber === void 0) return;
14662
- let refreshTickets;
14663
- if (admitted.courtTicketNumbers !== void 0) {
14664
- if (admitted.courtTicketNumbers.length === 0 || !admitted.courtTicketNumbers.includes(admitted.ticketNumber)) {
14665
- throw new StationChildExhaustedError(
14666
- `court diarist station: courtTicketNumbers is damaged (empty or missing principal #${admitted.ticketNumber})`
14667
- );
14668
- }
14669
- refreshTickets = admitted.courtTicketNumbers;
14670
- } else {
14671
- refreshTickets = [admitted.ticketNumber];
14672
- }
14673
- const completedIndex = afterTicketNumber === void 0 ? -1 : refreshTickets.indexOf(afterTicketNumber);
14674
- for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
14675
- const outcome = await invokeCourtDiarist(
14676
- {
14677
- instruction: admitted.instruction,
14678
- projectRoot: admitted.projectRoot,
14679
- failureLabel: `ticket #${ticketNumber}`,
14680
- correlationId: admitted.runId,
14681
- // Refresh holds a typed key — hand it off so identity is bound before turn.
14682
- boundTicketNumber: ticketNumber
14683
- },
14684
- env,
14685
- io
14686
- );
14687
- if (outcome.failedWithoutEscalate !== void 0) {
14688
- throw new StationChildExhaustedError(
14689
- outcome.failedWithoutEscalate.diagnostic
14690
- );
14691
- }
14692
- if (outcome.identity.kind === "escalate" && outcome.terminal !== void 0) {
14693
- return {
14694
- terminal: outcome.terminal,
14695
- ...outcome.admitted === void 0 ? {} : { childRunId: outcome.admitted.runId }
14696
- };
14697
- }
14698
- }
14699
- }
14700
14498
  var init_countersign_run = __esm({
14701
14499
  "src/public-cli/countersign-run.ts"() {
14702
14500
  "use strict";
14703
- init_diarist_contracts();
14704
14501
  init_readable_gate_item();
14705
- init_run_ticket_number();
14706
- init_post_admission();
14707
14502
  }
14708
14503
  });
14709
14504
 
@@ -14990,84 +14785,14 @@ async function runCountersignBody(parsed, env, io) {
14990
14785
  ...ticketNumber === void 0 ? {} : { ticketNumber }
14991
14786
  });
14992
14787
  };
14993
- let typedTicket;
14994
- let typedCourtTicketNumbers;
14995
- let identityDiaristRan = false;
14996
- let childDiaristRunId;
14997
- let pausedDiaristTerminal;
14998
- if (gateParentRunPath === void 0 && env.runCourtDiaristStation === void 0) {
14999
- let outcome;
15000
- try {
15001
- outcome = await invokeCourtDiarist({
15002
- instruction: parsed.instruction ?? "",
15003
- projectRoot: admitted.projectRoot,
15004
- failureLabel: "unbound summons",
15005
- correlationId: admitted.runId,
15006
- ...env.boundTicketNumber === void 0 ? {} : { boundTicketNumber: env.boundTicketNumber }
15007
- }, env, io);
15008
- } catch (error) {
15009
- await materializeAdmission(
15010
- isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : void 0
15011
- );
15012
- await markRunAdmitted(admitted, env.principalAuthority);
15013
- return await presentControlledFailure2(admitted, {
15014
- timedOut: false,
15015
- code: null,
15016
- stderr: "",
15017
- thrown: error
15018
- }, seatAdapters(admitted, env), env.principalAuthority, io);
15019
- }
15020
- identityDiaristRan = true;
15021
- if (outcome.identity.kind === "escalate") pausedDiaristTerminal = outcome.terminal;
15022
- if (outcome.admitted?.runDirectory.includes(`${sep4}unbound${sep4}runs${sep4}`)) {
15023
- childDiaristRunId = outcome.admitted.runId;
15024
- }
15025
- if (outcome.failedWithoutEscalate !== void 0) {
15026
- const diagnostic = outcome.failedWithoutEscalate.diagnostic;
15027
- await materializeAdmission(
15028
- isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : void 0
15029
- );
15030
- if (childDiaristRunId !== void 0) await recordChildDiaristRun(admitted, childDiaristRunId);
15031
- await markRunAdmitted(admitted, env.principalAuthority);
15032
- return await presentControlledFailure2(admitted, {
15033
- timedOut: false,
15034
- code: null,
15035
- stderr: "",
15036
- thrown: new Error(diagnostic)
15037
- }, seatAdapters(admitted, env), env.principalAuthority, io);
15038
- }
15039
- if (outcome.identity.kind === "ticket") {
15040
- typedTicket = outcome.identity.ticketNumber;
15041
- typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
15042
- }
15043
- }
15044
- await materializeAdmission(typedTicket);
14788
+ await materializeAdmission(
14789
+ isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : void 0
14790
+ );
15045
14791
  await markRunAdmitted(admitted, env.principalAuthority);
15046
- if (childDiaristRunId !== void 0) {
15047
- await recordChildDiaristRun(admitted, childDiaristRunId);
15048
- }
15049
- if (pausedDiaristTerminal !== void 0) {
15050
- io.stdout(formatTerminalResult(pausedDiaristTerminal));
15051
- return { exitCode: 0, admitted, terminal: pausedDiaristTerminal };
15052
- }
15053
14792
  if (gateParentRunPath !== void 0) {
15054
14793
  await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
15055
14794
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
15056
14795
  }
15057
- if (identityDiaristRan && typedTicket !== void 0) {
15058
- try {
15059
- await bindAdmittedTicketNumber(admitted, typedTicket);
15060
- await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
15061
- await bindCourtTicketNumbersOnAdmitted(admitted, typedCourtTicketNumbers ?? [typedTicket]);
15062
- } catch (error) {
15063
- return await presentControlledFailure2(admitted, {
15064
- timedOut: false,
15065
- code: null,
15066
- stderr: "",
15067
- thrown: error
15068
- }, seatAdapters(admitted, env), env.principalAuthority, io);
15069
- }
15070
- }
15071
14796
  const turnProjection = {
15072
14797
  packageRoot: env.packageRoot,
15073
14798
  home: env.home,
@@ -15097,13 +14822,6 @@ async function runCountersignBody(parsed, env, io) {
15097
14822
  ...seatAdapters(admitted, env),
15098
14823
  beforeDispatch: async (admittedSeat, lease) => {
15099
14824
  if (!packagedAdmitsCountersign(admittedSeat.role)) return;
15100
- if (!identityDiaristRan || typedTicket !== void 0) {
15101
- const refresh = await runCountersignCourtDiaristStation(admittedSeat, env, io);
15102
- if (refresh !== void 0) {
15103
- io.stdout(formatTerminalResult(refresh.terminal));
15104
- return refresh.terminal;
15105
- }
15106
- }
15107
14825
  await relocateAdmittedRunToTicket(admittedSeat, env.principalAuthority, lease);
15108
14826
  Object.assign(turnRequest, buildInstructionSeatTurnRequest(admittedSeat, turnProjection));
15109
14827
  }
@@ -15435,13 +15153,6 @@ async function continueParentAfterChild(parentRunId, child, env, io) {
15435
15153
  return runPublicInstructionSeatResume({ runId: parentRunId }, env, io);
15436
15154
  }
15437
15155
  const admitted = loaded.admitted;
15438
- if (admitted.role === "countersign" && admitted.ticketNumber !== void 0 && child.role === "diarist") {
15439
- const refresh = await runCountersignCourtDiaristStation(admitted, env, io, child.ticketNumber);
15440
- if (refresh !== void 0) {
15441
- io.stdout(formatTerminalResult(refresh.terminal));
15442
- return { exitCode: 0, admitted, terminal: refresh.terminal };
15443
- }
15444
- }
15445
15156
  const resolved = await queueConclusionFromChild(child, env, io);
15446
15157
  if (resolved !== void 0 && "stop" in resolved) return resolved.stop;
15447
15158
  if (resolved !== void 0 && resolved.status === "escalate") {
@@ -18987,8 +18698,8 @@ async function summonPublicRole(options) {
18987
18698
  // Nested court stations keep station-child semantics; dual-lens
18988
18699
  // ordinary Reviewer axes opt out (#946 / ADR 0082).
18989
18700
  ...options.stationChild === false ? {} : { stationChild: true },
18990
- // Forward composition-root adapters so nested court stations (e.g.
18991
- // countersign → diarist) select the same faux/production table (#924).
18701
+ // Forward composition-root adapters so nested stations (e.g.
18702
+ // secretariat → diarist) select the same faux/production table (#924).
18992
18703
  ...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
18993
18704
  ...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
18994
18705
  ...options.signal === void 0 ? {} : { signal: options.signal },
@@ -19272,10 +18983,10 @@ async function summonGateOfficer(options) {
19272
18983
  );
19273
18984
  }
19274
18985
  const correlationId = parentRunId;
19275
- const { isSafePositiveTicketNumber: isSafePositiveTicketNumber2, readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
18986
+ const { isSafePositiveTicketNumber: isSafePositiveTicketNumber3, readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
19276
18987
  const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
19277
18988
  const submittedTicket = options.submission !== null && typeof options.submission === "object" && !Array.isArray(options.submission) ? options.submission.ticketNumber : void 0;
19278
- const courtTicket = isSafePositiveTicketNumber2(submittedTicket) ? submittedTicket : parentTicket;
18989
+ const courtTicket = isSafePositiveTicketNumber3(submittedTicket) ? submittedTicket : parentTicket;
19279
18990
  const instruction = options.reask ?? gateReviewInstruction ?? "";
19280
18991
  return summonPublicRole({
19281
18992
  role: options.officer,
@@ -20167,52 +19878,10 @@ function parsePersistedTicketIdentity(record4) {
20167
19878
  ...ticketNumber === void 0 ? {} : { ticketNumber }
20168
19879
  };
20169
19880
  }
20170
- function readDurableCourtTicketNumbersPage(record4, principalTicket, pageLabel) {
20171
- const interpreted = interpretDurableCourtTicketNumbers(record4, {
20172
- ...principalTicket === void 0 ? {} : { principalTicket }
20173
- });
20174
- if (interpreted.kind === "damage") {
20175
- return {
20176
- kind: "damage",
20177
- reason: `role run ${pageLabel} courtTicketNumbers is damaged: ${interpreted.reason}`
20178
- };
20179
- }
20180
- if (interpreted.kind === "ok") {
20181
- return { kind: "ok", tickets: interpreted.tickets };
20182
- }
20183
- return { kind: "absent" };
20184
- }
20185
- function mergeDurableCourtTicketNumbers(input) {
20186
- const fromAdmitted = input.admittedRecord === void 0 ? { kind: "absent" } : readDurableCourtTicketNumbersPage(
20187
- input.admittedRecord,
20188
- input.principalTicket,
20189
- "admitted-request"
20190
- );
20191
- const fromInvocation = input.invocationRecord === void 0 ? { kind: "absent" } : readDurableCourtTicketNumbersPage(
20192
- input.invocationRecord,
20193
- input.principalTicket,
20194
- "invocation"
20195
- );
20196
- if (fromAdmitted.kind === "damage") return fromAdmitted;
20197
- if (fromInvocation.kind === "damage") return fromInvocation;
20198
- if (fromAdmitted.kind === "ok" && fromInvocation.kind === "ok") {
20199
- if (!sameCourtTicketNumbers(fromAdmitted.tickets, fromInvocation.tickets)) {
20200
- return {
20201
- kind: "damage",
20202
- reason: "role run courtTicketNumbers differs between admitted-request and invocation"
20203
- };
20204
- }
20205
- return { kind: "ok", tickets: fromAdmitted.tickets };
20206
- }
20207
- if (fromAdmitted.kind === "ok") return { kind: "ok", tickets: fromAdmitted.tickets };
20208
- if (fromInvocation.kind === "ok") return { kind: "ok", tickets: fromInvocation.tickets };
20209
- return { kind: "ok" };
20210
- }
20211
19881
  function restoredTicketFields(fields) {
20212
19882
  return {
20213
19883
  ...fields.correlationId === void 0 ? {} : { correlationId: fields.correlationId },
20214
- ...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber },
20215
- ...fields.courtTicketNumbers === void 0 ? {} : { courtTicketNumbers: fields.courtTicketNumbers }
19884
+ ...fields.ticketNumber === void 0 ? {} : { ticketNumber: fields.ticketNumber }
20216
19885
  };
20217
19886
  }
20218
19887
  async function loadResumableRunRecord(home, runId, authority) {
@@ -20244,10 +19913,6 @@ async function loadResumableRunRecord(home, runId, authority) {
20244
19913
  let derived;
20245
19914
  let correlationId;
20246
19915
  let ticketNumber;
20247
- let courtTicketNumbers;
20248
- let courtTicketNumbersDamage;
20249
- let admittedIdentityRecord;
20250
- let invocationIdentityRecord;
20251
19916
  let prNumber;
20252
19917
  let repository;
20253
19918
  let repositoryDisplay;
@@ -20369,7 +20034,6 @@ async function loadResumableRunRecord(home, runId, authority) {
20369
20034
  };
20370
20035
  }
20371
20036
  }
20372
- admittedIdentityRecord = record4;
20373
20037
  const fromAdmitted = parsePersistedTicketIdentity(record4);
20374
20038
  correlationId = fromAdmitted.correlationId;
20375
20039
  ticketNumber = fromAdmitted.ticketNumber;
@@ -20388,7 +20052,6 @@ async function loadResumableRunRecord(home, runId, authority) {
20388
20052
  );
20389
20053
  if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
20390
20054
  const rec = invocationRaw;
20391
- invocationIdentityRecord = rec;
20392
20055
  if (typeof rec.provider === "string" && typeof rec.model === "string") {
20393
20056
  model = {
20394
20057
  provider: rec.provider,
@@ -20413,16 +20076,6 @@ async function loadResumableRunRecord(home, runId, authority) {
20413
20076
  );
20414
20077
  }
20415
20078
  }
20416
- const mergedSet = mergeDurableCourtTicketNumbers({
20417
- admittedRecord: admittedIdentityRecord,
20418
- invocationRecord: invocationIdentityRecord,
20419
- principalTicket: ticketNumber
20420
- });
20421
- if (mergedSet.kind === "damage") {
20422
- courtTicketNumbersDamage = mergedSet.reason;
20423
- } else if (mergedSet.tickets !== void 0) {
20424
- courtTicketNumbers = mergedSet.tickets;
20425
- }
20426
20079
  const sourceRunLeaf = basename10(sourceRunPath ?? "").split("@");
20427
20080
  const referencedRunId = sourceRun?.runId ?? sourceRunLeaf[0];
20428
20081
  const referencedRole = sourceRun?.role ?? sourceRunLeaf[1];
@@ -20460,8 +20113,6 @@ async function loadResumableRunRecord(home, runId, authority) {
20460
20113
  ...derived === void 0 ? {} : { derived },
20461
20114
  ...correlationId === void 0 ? {} : { correlationId },
20462
20115
  ...ticketNumber === void 0 ? {} : { ticketNumber },
20463
- ...courtTicketNumbers === void 0 ? {} : { courtTicketNumbers },
20464
- ...courtTicketNumbersDamage === void 0 ? {} : { courtTicketNumbersDamage },
20465
20116
  ...prNumber === void 0 ? {} : { prNumber },
20466
20117
  ...repository === void 0 ? {} : { repository },
20467
20118
  ...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
@@ -20536,9 +20187,7 @@ function admitResumedRole(loaded) {
20536
20187
  case "court-materials": {
20537
20188
  const admitted = {
20538
20189
  role: "countersign",
20539
- ...base,
20540
- ...base.courtTicketNumbers === void 0 ? {} : { courtTicketNumbers: base.courtTicketNumbers },
20541
- ...fields.courtTicketNumbersDamage === void 0 ? {} : { courtTicketNumbersDamage: fields.courtTicketNumbersDamage }
20190
+ ...base
20542
20191
  };
20543
20192
  return admitted;
20544
20193
  }
@@ -20745,7 +20394,6 @@ var init_run_lifecycle = __esm({
20745
20394
  init_typed_provider_http();
20746
20395
  init_typed_provider_http();
20747
20396
  init_collector_config();
20748
- init_diarist_contracts();
20749
20397
  init_role_run_relocation();
20750
20398
  init_engine_material();
20751
20399
  init_packaged_role_registry();
@@ -22986,11 +22634,6 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
22986
22634
  description: "\u672C\u5EAD\u5BF9\u8C61\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09\u6216 null/\u7701\u7565\uFF1D\u771F\u65E0\u7968\uFF1B\u4E0B\u6E38\u8D70 typed \u952E\uFF1B\u8BA4\u4E0D\u51FA\u7528 status=escalate\uFF0C\u4E0D\u6D17\u6210\u65E0\u5F55\u3002\u673A\u68B0\u5C42\u4E0D\u91CD\u5224\u3002"
22987
22635
  })
22988
22636
  ),
22989
- courtTicketNumbers: Type18.Optional(
22990
- Type18.Unknown({
22991
- description: "#871 \u672C\u6B21\u5408\u5BA1\u5E94\u5404\u81EA\u6210\u5F55\u7684\u7968\u53F7\u96C6\u5408\uFF08\u6B63\u6574\u6570\u6570\u7EC4\uFF0C\u542B\u4E3B\u7968\uFF09\uFF1B\u5355\u7968\u53EF\u7701\u7565\u3002\u673A\u68B0\u5C42\u53EA\u505A\u7C7B\u578B/\u53BB\u91CD\u6295\u5F71\uFF0C\u4E0D\u4ECE\u6563\u6587\u731C\u7968\u3002"
22992
- })
22993
- ),
22994
22637
  reason: Type18.Optional(
22995
22638
  Type18.String({
22996
22639
  description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"