@akagilnc/pi-workflow-roles 0.1.6111 → 0.1.6115

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.
@@ -2091,6 +2091,9 @@ var init_fixer_output = __esm({
2091
2091
  classResults: Type8.Unknown({
2092
2092
  description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
2093
2093
  }),
2094
+ for: Type8.Unknown({
2095
+ description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
2096
+ }),
2094
2097
  diffItems: diffItemsField,
2095
2098
  testEvidence: Type8.Unknown({
2096
2099
  description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
@@ -4777,15 +4780,11 @@ import {
4777
4780
  writeFileSync as writeFileSync2
4778
4781
  } from "node:fs";
4779
4782
  import { basename as basename7, dirname as dirname7, join as join9, relative as relative2, sep as sep3 } from "node:path";
4780
- function parseProgressText(text, pathForDiagnostic) {
4781
- if (text.trim() === "") return [];
4783
+ function decodeProgressFile(path) {
4784
+ if (!existsSync3(path)) return { lines: [], malformed: [] };
4785
+ const text = readFileSync2(path, "utf8");
4786
+ if (text.trim() === "") return { lines: [], malformed: [] };
4782
4787
  const { records, diagnostics } = parseSitianRecordText(text);
4783
- for (const diagnostic of diagnostics) {
4784
- process.stderr.write(
4785
- `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
4786
- `
4787
- );
4788
- }
4789
4788
  const lines = [];
4790
4789
  for (const record of records) {
4791
4790
  const parsed = record;
@@ -4793,11 +4792,20 @@ function parseProgressText(text, pathForDiagnostic) {
4793
4792
  if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
4794
4793
  lines.push(parsed);
4795
4794
  }
4796
- return lines;
4795
+ return {
4796
+ lines,
4797
+ malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
4798
+ };
4797
4799
  }
4798
4800
  function readProgressFile(path) {
4799
- if (!existsSync3(path)) return [];
4800
- return parseProgressText(readFileSync2(path, "utf8"), path);
4801
+ const { lines, malformed } = decodeProgressFile(path);
4802
+ for (const diagnostic of malformed) {
4803
+ process.stderr.write(
4804
+ `[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
4805
+ `
4806
+ );
4807
+ }
4808
+ return lines;
4801
4809
  }
4802
4810
  function readTicketProgressLines(subjectDirectory) {
4803
4811
  if (basename7(subjectDirectory) === "unbound") {
@@ -4853,6 +4861,26 @@ function statusAndSummaryFromPayload(payload) {
4853
4861
  ...summary === void 0 ? {} : { summary }
4854
4862
  };
4855
4863
  }
4864
+ function readAuditedRound(auditedRunDirectory) {
4865
+ try {
4866
+ const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
4867
+ if (subjectDirectory === void 0) return {};
4868
+ const path = join9(subjectDirectory, CURRENT_FILENAME);
4869
+ const { lines, malformed } = decodeProgressFile(path);
4870
+ if (malformed.length > 0) {
4871
+ throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
4872
+ }
4873
+ const receipts = `runs/${basename7(auditedRunDirectory)}/`;
4874
+ const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
4875
+ return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
4876
+ } catch (error) {
4877
+ return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
4878
+ }
4879
+ }
4880
+ function forOfSealedRow(runDirectory, seat, payload) {
4881
+ const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
4882
+ return typeof reported === "string" ? reported : void 0;
4883
+ }
4856
4884
  function captureWorktreeHead(projectRoot) {
4857
4885
  try {
4858
4886
  const result = spawnSync2("git", ["rev-parse", "HEAD"], {
@@ -4931,11 +4959,13 @@ function landTicketProgress(input) {
4931
4959
  const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
4932
4960
  const sessionRelative = input.sessionFile === void 0 ? "" : relative2(subjectDirectory, input.sessionFile).split(sep3).join("/");
4933
4961
  const { status, summary } = statusAndSummaryFromPayload(input.accepted);
4962
+ const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
4934
4963
  const instruction = input.instruction;
4935
4964
  const line2 = {
4936
4965
  at: (/* @__PURE__ */ new Date()).toISOString(),
4937
4966
  seat: input.role,
4938
4967
  round,
4968
+ ...reviewed === void 0 ? {} : { for: reviewed },
4939
4969
  instruction,
4940
4970
  head: input.sealHead.head,
4941
4971
  ...status === void 0 ? {} : { status },
@@ -7136,22 +7166,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
7136
7166
  ...fields
7137
7167
  }));
7138
7168
  }
7139
- async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
7140
- if (sourceRunPath.trim() === "") {
7141
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
7169
+ function persistAdmittedAuditedLeg(runDirectory, audited) {
7170
+ const { sourceRunPath, auditorSubject } = audited;
7171
+ if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
7172
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
7142
7173
  }
7143
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
7144
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7174
+ updateSectionSync(runDirectory, "admitted", (current) => {
7175
+ if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
7145
7176
  throw new Error(
7146
- `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7177
+ `persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
7147
7178
  );
7148
7179
  }
7149
- const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
7150
- if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
7180
+ const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
7181
+ if (unchanged) return void 0;
7182
+ const { for: _replaced, ...rest } = current;
7151
7183
  return {
7152
- ...current,
7153
- sourceRunPath,
7154
- ...auditorSubject === void 0 ? {} : { auditorSubject }
7184
+ ...rest,
7185
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
7186
+ ...auditorSubject === void 0 ? {} : { auditorSubject },
7187
+ ...audited.for === void 0 ? {} : { for: audited.for }
7155
7188
  };
7156
7189
  });
7157
7190
  }
@@ -15028,6 +15061,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
15028
15061
  else io.stdout(formatTerminalResult(terminal));
15029
15062
  return { exitCode: failed ? 1 : 0, terminal };
15030
15063
  }
15064
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
15065
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
15066
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
15067
+ if (fault === void 0) return;
15068
+ await retainPackageFault({
15069
+ runDirectory: officerRunDirectory,
15070
+ diagnostic: fault,
15071
+ stderr: (text) => io.stderr(text)
15072
+ });
15073
+ }
15031
15074
  function resumeSameParentInstructionSeat(input) {
15032
15075
  return tryResumeSameTicketSeatRun({
15033
15076
  home: input.env.home,
@@ -15047,7 +15090,8 @@ function resumeSameParentInstructionSeat(input) {
15047
15090
  ...materials === void 0 ? {} : { summons: materials }
15048
15091
  },
15049
15092
  input.env,
15050
- input.io
15093
+ input.io,
15094
+ input.parentRunPath
15051
15095
  );
15052
15096
  }
15053
15097
  });
@@ -15123,7 +15167,9 @@ async function runCountersignBody(parsed, env, io) {
15123
15167
  );
15124
15168
  await markRunAdmitted(admitted, env.principalAuthority);
15125
15169
  if (gateParentRunPath !== void 0) {
15126
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
15170
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
15171
+ sourceRunPath: gateParentRunPath
15172
+ });
15127
15173
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
15128
15174
  }
15129
15175
  const turnProjection = roleTurnOptions(env, admitted, {
@@ -15332,12 +15378,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
15332
15378
  throw error;
15333
15379
  }
15334
15380
  if (instructionSourceRunPath !== void 0) {
15335
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
15381
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
15382
+ sourceRunPath: instructionSourceRunPath
15383
+ });
15336
15384
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
15337
- }
15338
- if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15339
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
15385
+ } else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
15386
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
15387
+ sourceRunPath: auditorSource,
15388
+ auditorSubject
15389
+ });
15340
15390
  admitted = { ...admitted, sourceRunPath: auditorSource };
15391
+ } else {
15392
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
15393
+ if (auditedRunDirectory !== void 0) {
15394
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
15395
+ }
15341
15396
  }
15342
15397
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
15343
15398
  const runAdmitted = async () => {
@@ -15412,7 +15467,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
15412
15467
  await relocateAdmittedRunToTicket(admitted, authority);
15413
15468
  return admitted;
15414
15469
  }
15415
- async function runPublicInstructionSeatResume(request, env, io) {
15470
+ async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
15416
15471
  let selectedRequest = request;
15417
15472
  const resume = async () => {
15418
15473
  const held = [];
@@ -15443,6 +15498,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
15443
15498
  return { ...loaded, admitted };
15444
15499
  },
15445
15500
  buildTurnRequest: async (admitted, effective) => {
15501
+ if (resummonedFor !== void 0) {
15502
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
15503
+ }
15446
15504
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
15447
15505
  const projection = resumeTurnRequestProjectionOptions(
15448
15506
  admitted,
@@ -15961,6 +16019,7 @@ var init_instruction_seat_run = __esm({
15961
16019
  init_terminal();
15962
16020
  init_turn_request();
15963
16021
  init_countersign_run();
16022
+ init_ticket_progress();
15964
16023
  init_unknown_value();
15965
16024
  AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
15966
16025
  SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
@@ -1047,6 +1047,9 @@ var init_fixer_output = __esm({
1047
1047
  classResults: Type8.Unknown({
1048
1048
  description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
1049
1049
  }),
1050
+ for: Type8.Unknown({
1051
+ description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
1052
+ }),
1050
1053
  diffItems: diffItemsField,
1051
1054
  testEvidence: Type8.Unknown({
1052
1055
  description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
@@ -6297,15 +6300,11 @@ import {
6297
6300
  writeFileSync as writeFileSync2
6298
6301
  } from "node:fs";
6299
6302
  import { basename as basename7, dirname as dirname10, join as join12, relative as relative3, sep as sep4 } from "node:path";
6300
- function parseProgressText(text, pathForDiagnostic) {
6301
- if (text.trim() === "") return [];
6303
+ function decodeProgressFile(path) {
6304
+ if (!existsSync4(path)) return { lines: [], malformed: [] };
6305
+ const text = readFileSync3(path, "utf8");
6306
+ if (text.trim() === "") return { lines: [], malformed: [] };
6302
6307
  const { records, diagnostics } = parseSitianRecordText(text);
6303
- for (const diagnostic of diagnostics) {
6304
- process.stderr.write(
6305
- `[ticket-progress] ${pathForDiagnostic} has malformed row(s); keeps reachable rows and retains the diagnostic: line ${diagnostic.line}: ${diagnostic.error}
6306
- `
6307
- );
6308
- }
6309
6308
  const lines = [];
6310
6309
  for (const record of records) {
6311
6310
  const parsed = record;
@@ -6313,11 +6312,20 @@ function parseProgressText(text, pathForDiagnostic) {
6313
6312
  if (typeof parsed.seat !== "string" || typeof parsed.round !== "string") continue;
6314
6313
  lines.push(parsed);
6315
6314
  }
6316
- return lines;
6315
+ return {
6316
+ lines,
6317
+ malformed: diagnostics.map((diagnostic) => `line ${diagnostic.line}: ${diagnostic.error}`)
6318
+ };
6317
6319
  }
6318
6320
  function readProgressFile(path) {
6319
- if (!existsSync4(path)) return [];
6320
- return parseProgressText(readFileSync3(path, "utf8"), path);
6321
+ const { lines, malformed } = decodeProgressFile(path);
6322
+ for (const diagnostic of malformed) {
6323
+ process.stderr.write(
6324
+ `[ticket-progress] ${path} has malformed row(s); keeps reachable rows and retains the diagnostic: ${diagnostic}
6325
+ `
6326
+ );
6327
+ }
6328
+ return lines;
6321
6329
  }
6322
6330
  function readTicketProgressLines(subjectDirectory) {
6323
6331
  if (basename7(subjectDirectory) === "unbound") {
@@ -6373,6 +6381,26 @@ function statusAndSummaryFromPayload(payload) {
6373
6381
  ...summary === void 0 ? {} : { summary }
6374
6382
  };
6375
6383
  }
6384
+ function readAuditedRound(auditedRunDirectory) {
6385
+ try {
6386
+ const subjectDirectory = subjectDirectoryOfRun(auditedRunDirectory);
6387
+ if (subjectDirectory === void 0) return {};
6388
+ const path = join12(subjectDirectory, CURRENT_FILENAME);
6389
+ const { lines, malformed } = decodeProgressFile(path);
6390
+ if (malformed.length > 0) {
6391
+ throw new Error(`${path} has malformed row(s): ${malformed.join("; ")}`);
6392
+ }
6393
+ const receipts = `runs/${basename7(auditedRunDirectory)}/`;
6394
+ const latest = lines.filter((line2) => line2.receipt.startsWith(receipts)).at(-1);
6395
+ return latest === void 0 ? {} : { for: `${latest.seat}#${latest.round}` };
6396
+ } catch (error) {
6397
+ return { fault: `audited round unavailable for ${auditedRunDirectory}: ${errorText(error)}` };
6398
+ }
6399
+ }
6400
+ function forOfSealedRow(runDirectory, seat, payload) {
6401
+ const reported = packagedGateStageLabel(seat) !== void 0 ? readPageSync(runDirectory, "admitted")?.for : seat === "fixer" && isRecord(payload) ? payload.for : void 0;
6402
+ return typeof reported === "string" ? reported : void 0;
6403
+ }
6376
6404
  function captureWorktreeHead(projectRoot) {
6377
6405
  try {
6378
6406
  const result = spawnSync2("git", ["rev-parse", "HEAD"], {
@@ -6451,11 +6479,13 @@ function landTicketProgress(input) {
6451
6479
  const round = unbound ? "" : nextRoundFromLines(existing, input.role, lens);
6452
6480
  const sessionRelative = input.sessionFile === void 0 ? "" : relative3(subjectDirectory, input.sessionFile).split(sep4).join("/");
6453
6481
  const { status, summary } = statusAndSummaryFromPayload(input.accepted);
6482
+ const reviewed = forOfSealedRow(runDirectory, input.role, input.accepted);
6454
6483
  const instruction = input.instruction;
6455
6484
  const line2 = {
6456
6485
  at: (/* @__PURE__ */ new Date()).toISOString(),
6457
6486
  seat: input.role,
6458
6487
  round,
6488
+ ...reviewed === void 0 ? {} : { for: reviewed },
6459
6489
  instruction,
6460
6490
  head: input.sealHead.head,
6461
6491
  ...status === void 0 ? {} : { status },
@@ -8363,22 +8393,25 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
8363
8393
  ...fields
8364
8394
  }));
8365
8395
  }
8366
- async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
8367
- if (sourceRunPath.trim() === "") {
8368
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
8396
+ function persistAdmittedAuditedLeg(runDirectory, audited) {
8397
+ const { sourceRunPath, auditorSubject } = audited;
8398
+ if (sourceRunPath !== void 0 && sourceRunPath.trim() === "") {
8399
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
8369
8400
  }
8370
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
8371
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
8401
+ updateSectionSync(runDirectory, "admitted", (current) => {
8402
+ if (sourceRunPath !== void 0 && typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
8372
8403
  throw new Error(
8373
- `persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
8404
+ `persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
8374
8405
  );
8375
8406
  }
8376
- const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
8377
- if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
8407
+ const unchanged = current.for === audited.for && (sourceRunPath === void 0 || current.sourceRunPath === sourceRunPath) && (auditorSubject === void 0 || current.auditorSubject === auditorSubject);
8408
+ if (unchanged) return void 0;
8409
+ const { for: _replaced, ...rest } = current;
8378
8410
  return {
8379
- ...current,
8380
- sourceRunPath,
8381
- ...auditorSubject === void 0 ? {} : { auditorSubject }
8411
+ ...rest,
8412
+ ...sourceRunPath === void 0 ? {} : { sourceRunPath },
8413
+ ...auditorSubject === void 0 ? {} : { auditorSubject },
8414
+ ...audited.for === void 0 ? {} : { for: audited.for }
8382
8415
  };
8383
8416
  });
8384
8417
  }
@@ -16376,6 +16409,16 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
16376
16409
  else io.stdout(formatTerminalResult(terminal));
16377
16410
  return { exitCode: failed ? 1 : 0, terminal };
16378
16411
  }
16412
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
16413
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
16414
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
16415
+ if (fault === void 0) return;
16416
+ await retainPackageFault({
16417
+ runDirectory: officerRunDirectory,
16418
+ diagnostic: fault,
16419
+ stderr: (text) => io.stderr(text)
16420
+ });
16421
+ }
16379
16422
  function resumeSameParentInstructionSeat(input) {
16380
16423
  return tryResumeSameTicketSeatRun({
16381
16424
  home: input.env.home,
@@ -16395,7 +16438,8 @@ function resumeSameParentInstructionSeat(input) {
16395
16438
  ...materials === void 0 ? {} : { summons: materials }
16396
16439
  },
16397
16440
  input.env,
16398
- input.io
16441
+ input.io,
16442
+ input.parentRunPath
16399
16443
  );
16400
16444
  }
16401
16445
  });
@@ -16471,7 +16515,9 @@ async function runCountersignBody(parsed, env, io) {
16471
16515
  );
16472
16516
  await markRunAdmitted(admitted, env.principalAuthority);
16473
16517
  if (gateParentRunPath !== void 0) {
16474
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
16518
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
16519
+ sourceRunPath: gateParentRunPath
16520
+ });
16475
16521
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
16476
16522
  }
16477
16523
  const turnProjection = roleTurnOptions(env, admitted, {
@@ -16680,12 +16726,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
16680
16726
  throw error;
16681
16727
  }
16682
16728
  if (instructionSourceRunPath !== void 0) {
16683
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
16729
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
16730
+ sourceRunPath: instructionSourceRunPath
16731
+ });
16684
16732
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
16685
- }
16686
- if (record.sameParent === "subject-source" && auditorSource !== void 0) {
16687
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
16733
+ } else if (record.sameParent === "subject-source" && auditorSource !== void 0) {
16734
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
16735
+ sourceRunPath: auditorSource,
16736
+ auditorSubject
16737
+ });
16688
16738
  admitted = { ...admitted, sourceRunPath: auditorSource };
16739
+ } else {
16740
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
16741
+ if (auditedRunDirectory !== void 0) {
16742
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
16743
+ }
16689
16744
  }
16690
16745
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
16691
16746
  const runAdmitted = async () => {
@@ -16760,7 +16815,7 @@ async function inheritKnownTicketFromSource(admitted, authority) {
16760
16815
  await relocateAdmittedRunToTicket(admitted, authority);
16761
16816
  return admitted;
16762
16817
  }
16763
- async function runPublicInstructionSeatResume(request, env, io) {
16818
+ async function runPublicInstructionSeatResume(request, env, io, resummonedFor) {
16764
16819
  let selectedRequest = request;
16765
16820
  const resume = async () => {
16766
16821
  const held = [];
@@ -16791,6 +16846,9 @@ async function runPublicInstructionSeatResume(request, env, io) {
16791
16846
  return { ...loaded, admitted };
16792
16847
  },
16793
16848
  buildTurnRequest: async (admitted, effective) => {
16849
+ if (resummonedFor !== void 0) {
16850
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
16851
+ }
16794
16852
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
16795
16853
  const projection = resumeTurnRequestProjectionOptions(
16796
16854
  admitted,
@@ -17309,6 +17367,7 @@ var init_instruction_seat_run = __esm({
17309
17367
  init_terminal();
17310
17368
  init_turn_request();
17311
17369
  init_countersign_run();
17370
+ init_ticket_progress();
17312
17371
  init_unknown_value();
17313
17372
  AUDITED_ROLES = /* @__PURE__ */ new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
17314
17373
  SECRETARIAT_STATUS_REASK = "status \u4E0D\u662F converged\u3001escalate \u4E4B\u4E00\u3002\u8BF7\u91CD\u65B0\u4EA4\u5377\uFF0Cstatus \u5199\u660E\u5176\u4E00\u3002";
@@ -9114,6 +9114,9 @@ var init_fixer_output = __esm({
9114
9114
  classResults: typebox_exports.Unknown({
9115
9115
  description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
9116
9116
  }),
9117
+ for: typebox_exports.Unknown({
9118
+ description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
9119
+ }),
9117
9120
  diffItems: diffItemsField,
9118
9121
  testEvidence: typebox_exports.Unknown({
9119
9122
  description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
@@ -20,6 +20,9 @@ const fixerOutputObject = Type.Object({
20
20
  classResults: Type.Unknown({
21
21
  description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u6BCF\u7C7B\u5199 name\u3001shape\uFF08\u9519\u8BEF\u5F62\u72B6\u4E00\u53E5\uFF09\u3002\u6309\u4EE3\u7801\u5F62\u72B6\u8BA4\u7684\u7C7B\u5199 search\uFF08\u5B9E\u9645\u8DD1\u7684\u641C\u7D22\u547D\u4EE4\uFF0C\u539F\u6837\uFF09\u3001hits\uFF08\u547D\u4EE4\u8F93\u51FA\u7684\u6BCF\u4E2A\u547D\u4E2D\u4E00\u884C { where: path:line, outcome: \u5DF2\u4FEE | \u4E0D\u540C\u7C7B\uFF1A\u7406\u7531 }\uFF09\uFF1B\u6309\u60C5\u5F62\u8BA4\u7684\u7C7B\u5199 cases\uFF08\u6BCF\u79CD\u524D\u5E8F\u7ECF\u5386\u4E00\u884C { case: \u5BF9\u8C61\u5148\u7ECF\u5386\u4E86\u4EC0\u4E48, entry: \u4ECE\u771F\u5B9E\u5165\u53E3\u600E\u4E48\u8D70\u5230\u5B83, before: \u4FEE\u524D\u7ED3\u679C, after: \u4FEE\u540E\u7ED3\u679C }\uFF09\u3002\u5220\u5E76\u7C7B\u5199 files\uFF08\u672C\u7968\u8D77\u70B9\u5230 HEAD \u7684 git diff --name-status \u91CC\u6BCF\u4E2A\u6587\u4EF6\u4E00\u884C { file, hits: \u8BE5\u7C7B\u5728\u6B64\u6587\u4EF6\u7684\u547D\u4E2D path:line \u5217\u8868\uFF0C\u6CA1\u6709\u4E3A\u7A7A, outcome: \u5DF2\u4FEE | \u65E0\uFF1A\u6BD4\u5BF9\u4E86\u54EA\u51E0\u5904\u3001\u4E3A\u4EC0\u4E48\u4E0D\u7B97 | \u672A\u4FEE\uFF1A\u7406\u7531 }\uFF09\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 remainingScope\u3001blocker\u3002"
22
22
  }),
23
+ for: Type.Unknown({
24
+ description: "\u4FEE\u7684\u662F\u54EA\u4EFD\u5224\u8BCD\uFF1A<\u5E2D>#<\u8F6E>\uFF0C\u5982 judge#5\uFF0C\u539F\u6837\u843D\u5230\u8FDB\u5EA6\u884C\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002"
25
+ }),
23
26
  diffItems: diffItemsField,
24
27
  testEvidence: Type.Unknown({
25
28
  description: "\u4EC5 diff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u586B\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1B\u6CA1\u6709\u5C31\u586B null\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
@@ -22,16 +22,17 @@ import { NotarySourceRunError, resolveNotarySourceRunLocator } from "../notary-s
22
22
  import { packagedAdmitsCountersign, isNavigatorSeat, packagedBindsBoardTicket, packagedRebindSourceOnResume, packagedRoleMetadata, receiptStatus, } from "../packaged-role-registry.js";
23
23
  import { readAuditorResumeBinding } from "../auditor-soul.js";
24
24
  import { CliUsageError } from "./cli-errors.js";
25
- import { admitPublicRole, admittedSourceRunPath, bindAdmittedTicketNumber, appendCallerFileFlagPaths, buildInstructionTransportPrompt, materializeCountersignInvocation, persistAdmittedAuditedSubmissionToolCallId, persistAdmittedSourceRunPath, readAdmittedAuditedSubmissionToolCallId, recordAdmittedCorrelation, recordChildDiaristRun, relocateAdmittedRunToTicket, } from "./invocation.js";
25
+ import { admitPublicRole, admittedSourceRunPath, bindAdmittedTicketNumber, appendCallerFileFlagPaths, buildInstructionTransportPrompt, materializeCountersignInvocation, persistAdmittedAuditedLeg, persistAdmittedAuditedSubmissionToolCallId, readAdmittedAuditedSubmissionToolCallId, recordAdmittedCorrelation, recordChildDiaristRun, relocateAdmittedRunToTicket, } from "./invocation.js";
26
26
  import { bindDiaristAssertedTicketNumber, presentControlledFailure, packageFaultNoteFor, prepareSummonsResumeMaterials, roleTurnOptions, runPostAdmissionOneShot, runPostAdmissionResumable, runPostAdmissionSeatResume, showResumeErrorPointer, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
27
27
  import { presentTerminal } from "./auto-resume.js";
28
28
  import { loadResumablePublicRole, markRunAdmitted, readCurrentCourt, } from "./run-lifecycle.js";
29
29
  import { tryResumeSameTicketSeatRun } from "./seat-ticket-binding.js";
30
- import { ledgerReadScope, presentStructuralRejection, readBoundSessionEntries, trySettlePublicSeat, } from "./settlement.js";
30
+ import { ledgerReadScope, presentStructuralRejection, readBoundSessionEntries, retainPackageFault, trySettlePublicSeat, } from "./settlement.js";
31
31
  import { warnMissingMethodSkills } from "./machine-method-skills.js";
32
32
  import { formatTerminalResult, isLawfulTypedTerminalOutcome, } from "./terminal.js";
33
33
  import { admittedSeatTurnDetails, projectRoleTurnRequest, requiredMethodSkills, } from "./turn-request.js";
34
34
  import { invokeCourtDiarist, latestPayloadEscalated, } from "./countersign-run.js";
35
+ import { readAuditedRound } from "../ticket-progress.js";
35
36
  import { errorText } from "../unknown-value.js";
36
37
  const AUDITED_ROLES = new Set(["judge", "fixer", "coder", "secretariat", "countersign", "doctor"]);
37
38
  const SECRETARIAT_STATUS_REASK = "status 不是 converged、escalate 之一。请重新交卷,status 写明其一。";
@@ -568,6 +569,25 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
568
569
  io.stdout(formatTerminalResult(terminal));
569
570
  return { exitCode: failed ? 1 : 0, terminal };
570
571
  }
572
+ /**
573
+ * #1200: every officer admission that names an audited leg — gate summons and
574
+ * a caller's own `--source-run`, first mint and re-summons alike — pins
575
+ *「审 谁#轮」before the officer runs, in the same page write as the source
576
+ * path when this admission is the one that records it. A row that cannot be
577
+ * read keeps its cause on the officer run; the officer still runs and its rows
578
+ * carry no `for`.
579
+ */
580
+ async function pinAuditedLegAtAdmission(officerRunDirectory, auditedRunDirectory, io, source) {
581
+ const { for: auditedRound, fault } = readAuditedRound(auditedRunDirectory);
582
+ persistAdmittedAuditedLeg(officerRunDirectory, { for: auditedRound, ...source });
583
+ if (fault === undefined)
584
+ return;
585
+ await retainPackageFault({
586
+ runDirectory: officerRunDirectory,
587
+ diagnostic: fault,
588
+ stderr: (text) => io.stderr(text),
589
+ });
590
+ }
571
591
  /**
572
592
  * One same-parent lookup. Seat branches still build their own summons.
573
593
  * A found child resumes that child. No prior run, explicit new, or a typed
@@ -592,7 +612,7 @@ function resumeSameParentInstructionSeat(input) {
592
612
  runDirectory,
593
613
  ...(reask === undefined ? {} : { message: reask }),
594
614
  ...(materials === undefined ? {} : { summons: materials }),
595
- }, input.env, input.io);
615
+ }, input.env, input.io, input.parentRunPath);
596
616
  },
597
617
  });
598
618
  }
@@ -677,7 +697,9 @@ async function runCountersignBody(parsed, env, io) {
677
697
  await materializeAdmission(isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : undefined);
678
698
  await markRunAdmitted(admitted, env.principalAuthority);
679
699
  if (gateParentRunPath !== undefined) {
680
- await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
700
+ await pinAuditedLegAtAdmission(admitted.runDirectory, gateParentRunPath, io, {
701
+ sourceRunPath: gateParentRunPath,
702
+ });
681
703
  admitted = { ...admitted, sourceRunPath: gateParentRunPath };
682
704
  }
683
705
  // #1208 C1 / #1166 J11: one shared initial-prompt seam (incl. file flags).
@@ -879,13 +901,25 @@ export async function runPublicInstructionSeat(argv, env, io, role, parseArgv) {
879
901
  throw error;
880
902
  }
881
903
  if (instructionSourceRunPath !== undefined) {
882
- await persistAdmittedSourceRunPath(admitted, instructionSourceRunPath);
904
+ await pinAuditedLegAtAdmission(admitted.runDirectory, instructionSourceRunPath, io, {
905
+ sourceRunPath: instructionSourceRunPath,
906
+ });
883
907
  admitted = { ...admitted, sourceRunPath: instructionSourceRunPath };
884
908
  }
885
- if (record.sameParent === "subject-source" && auditorSource !== undefined) {
886
- await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
909
+ else if (record.sameParent === "subject-source" && auditorSource !== undefined) {
910
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditorSource, io, {
911
+ sourceRunPath: auditorSource,
912
+ auditorSubject,
913
+ });
887
914
  admitted = { ...admitted, sourceRunPath: auditorSource };
888
915
  }
916
+ else {
917
+ // The admission itself already recorded the source (source-locator seats).
918
+ const auditedRunDirectory = admittedSourceRunPath(admitted);
919
+ if (auditedRunDirectory !== undefined) {
920
+ await pinAuditedLegAtAdmission(admitted.runDirectory, auditedRunDirectory, io);
921
+ }
922
+ }
889
923
  // #1208 C2: same helper as resume — inherit the audited source's known ticket.
890
924
  admitted = await inheritKnownTicketFromSource(admitted, env.principalAuthority);
891
925
  const runAdmitted = async () => {
@@ -950,7 +984,9 @@ async function inheritKnownTicketFromSource(admitted, authority) {
950
984
  await relocateAdmittedRunToTicket(admitted, authority);
951
985
  return admitted;
952
986
  }
953
- export async function runPublicInstructionSeatResume(request, env, io) {
987
+ export async function runPublicInstructionSeatResume(request, env, io,
988
+ /** #1200: the audited leg a same-parent re-summons names; absent on every other resume. */
989
+ resummonedFor) {
954
990
  let selectedRequest = request;
955
991
  const resume = async () => {
956
992
  const held = [];
@@ -979,6 +1015,12 @@ export async function runPublicInstructionSeatResume(request, env, io) {
979
1015
  return { ...loaded, admitted };
980
1016
  },
981
1017
  buildTurnRequest: async (admitted, effective) => {
1018
+ // #1200: the turn is built once this leg has taken the summons — inside
1019
+ // its writer lease wherever the resume holds one — and before the host
1020
+ // turn. A summons the lease refuses never gets here and pins nothing.
1021
+ if (resummonedFor !== undefined) {
1022
+ await pinAuditedLegAtAdmission(admitted.runDirectory, resummonedFor, io);
1023
+ }
982
1024
  const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
983
1025
  const projection = resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared);
984
1026
  // #1208: internal summons only — shared resolver owns review dialogue.
@@ -162,24 +162,34 @@ async function mergeInvocationIdentityPage(runDirectory, fields) {
162
162
  }));
163
163
  }
164
164
  /**
165
- * Persist parent --source-run path onto the admitted section for officer resume lookup (#747).
166
- * Reuses the existing notary sourceRunPath key; does not invent a new field name.
165
+ * What this officer audits, on its admitted section in one page write.
166
+ * `for` (#1200) is the audited leg's「席#轮」at this admission: a new value
167
+ * replaces the old one, none clears it. `sourceRunPath` (#747) is the parent
168
+ * --source-run path kept for officer resume lookup, given only by the admission
169
+ * that first records it; it reuses the existing notary key and is never replaced.
167
170
  */
168
- export async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
169
- if (sourceRunPath.trim() === "") {
170
- throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
171
+ export function persistAdmittedAuditedLeg(runDirectory, audited) {
172
+ const { sourceRunPath, auditorSubject } = audited;
173
+ if (sourceRunPath !== undefined && sourceRunPath.trim() === "") {
174
+ throw new Error("persistAdmittedAuditedLeg requires a non-empty sourceRunPath");
171
175
  }
172
- updateSectionSync(admitted.runDirectory, "admitted", (current) => {
173
- if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
174
- throw new Error(`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`);
176
+ updateSectionSync(runDirectory, "admitted", (current) => {
177
+ if (sourceRunPath !== undefined
178
+ && typeof current.sourceRunPath === "string"
179
+ && current.sourceRunPath !== sourceRunPath) {
180
+ throw new Error(`persistAdmittedAuditedLeg refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`);
175
181
  }
176
- const sameSubject = auditorSubject === undefined || current.auditorSubject === auditorSubject;
177
- if (current.sourceRunPath === sourceRunPath && sameSubject)
182
+ const unchanged = current.for === audited.for
183
+ && (sourceRunPath === undefined || current.sourceRunPath === sourceRunPath)
184
+ && (auditorSubject === undefined || current.auditorSubject === auditorSubject);
185
+ if (unchanged)
178
186
  return undefined;
187
+ const { for: _replaced, ...rest } = current;
179
188
  return {
180
- ...current,
181
- sourceRunPath,
189
+ ...rest,
190
+ ...(sourceRunPath === undefined ? {} : { sourceRunPath }),
182
191
  ...(auditorSubject === undefined ? {} : { auditorSubject }),
192
+ ...(audited.for === undefined ? {} : { for: audited.for }),
183
193
  };
184
194
  });
185
195
  }