@akagilnc/pi-workflow-roles 0.1.5079 → 0.1.5122

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 (71) hide show
  1. package/dist/acp-host/production-host.js +545 -334
  2. package/dist/atomic-write.js +13 -19
  3. package/dist/auditor-soul.js +2 -1
  4. package/dist/doctor-contracts.js +1 -1
  5. package/dist/gatekeeper-role.js +2 -16
  6. package/dist/headless-host/production-host.js +577 -366
  7. package/dist/merger-contracts.js +1 -1
  8. package/dist/migrate-book-topology.js +18 -14
  9. package/dist/navigator-attendance.js +28 -143
  10. package/dist/navigator-invocation-identity.js +2 -0
  11. package/dist/navigator-public-session.js +13 -1
  12. package/dist/navigator-work-base.js +113 -0
  13. package/dist/notary-contracts.js +0 -2
  14. package/dist/package-contracts/fixer-output.js +1 -1
  15. package/dist/package-contracts/gatekeeper-output.js +1 -1
  16. package/dist/package-contracts/navigator-output.js +1 -1
  17. package/dist/package-contracts/terminating-infrastructure.js +3 -3
  18. package/dist/packaged-role-registry.js +9 -5
  19. package/dist/public-cli/cli.js +24 -1
  20. package/dist/public-cli/countersign-run.js +1 -1
  21. package/dist/public-cli/instruction-seat-run.js +8 -6
  22. package/dist/public-cli/invocation.js +6 -3
  23. package/dist/public-cli/main.js +6711 -6523
  24. package/dist/public-cli/post-admission.js +125 -26
  25. package/dist/public-cli/settlement.js +48 -5
  26. package/dist/receipt-delivery-policy.js +9 -2
  27. package/dist/review-submission.js +3 -3
  28. package/docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md +9 -0
  29. package/extensions/role-runtime.ts +0 -27
  30. package/package.json +2 -1
  31. package/resources/836-deleted-machine-instruction-inventory.md +3 -3
  32. package/resources/collector-bot-handbook.md +4 -0
  33. package/resources/navigator-route-playbook.md +4 -6
  34. package/scripts/build-package.mjs +4 -0
  35. package/souls/coder-output-guide.md +1 -0
  36. package/src/auditor-soul.ts +2 -1
  37. package/src/collector-role.ts +6 -7
  38. package/src/collector-tool-schemas.ts +5 -5
  39. package/src/diarist-role.ts +2 -2
  40. package/src/doctor-contracts.ts +1 -1
  41. package/src/gatekeeper-role.ts +1 -18
  42. package/src/gleaner-left-role.ts +2 -2
  43. package/src/inspector-role.ts +1 -1
  44. package/src/judge-role.ts +1 -1
  45. package/src/merger-contracts.ts +1 -1
  46. package/src/navigator-attendance.ts +38 -164
  47. package/src/navigator-invocation-identity.ts +2 -0
  48. package/src/navigator-public-session.ts +17 -1
  49. package/src/navigator-role.ts +4 -0
  50. package/src/navigator-session-contracts.ts +2 -0
  51. package/src/navigator-work-base.ts +123 -0
  52. package/src/notary-contracts.ts +0 -4
  53. package/src/package-contracts/fixer-output.ts +1 -1
  54. package/src/package-contracts/gatekeeper-output.ts +3 -3
  55. package/src/package-contracts/navigator-output.ts +1 -1
  56. package/src/package-contracts/terminating-infrastructure.ts +3 -6
  57. package/src/packaged-role-registry.ts +5 -1
  58. package/src/public-cli/cli-io.ts +2 -0
  59. package/src/public-cli/cli.ts +38 -4
  60. package/src/public-cli/countersign-run.ts +1 -1
  61. package/src/public-cli/instruction-seat-run.ts +10 -6
  62. package/src/public-cli/invocation.ts +12 -4
  63. package/src/public-cli/post-admission.ts +189 -34
  64. package/src/public-cli/settlement.ts +58 -4
  65. package/src/receipt-delivery-policy.ts +9 -1
  66. package/src/review-submission.ts +3 -3
  67. package/src/reviewer-role.ts +3 -3
  68. package/src/role-runtime-dependencies.ts +1 -5
  69. package/src/role-runtime.ts +52 -38
  70. package/src/secretariat-role.ts +3 -3
  71. package/src/worker-role.ts +3 -3
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Durable work subject and controlling authority for one navigator nest.
3
+ * Settlement user turns keep a path pointer; the navigator system prompt
4
+ * loads the bytes once per agent start from this file (base material).
5
+ */
6
+ import { existsSync, realpathSync } from "node:fs";
7
+ import { readFile } from "node:fs/promises";
8
+ import { basename, dirname, join, resolve } from "node:path";
9
+
10
+ import { writeFileAtomically } from "./atomic-write.ts";
11
+
12
+ export const NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
13
+
14
+ export type NavigatorWorkBase = {
15
+ readonly subject: string;
16
+ readonly authority: string;
17
+ };
18
+
19
+ export function navigatorWorkContextFile(sessionDir: string): string {
20
+ return join(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
21
+ }
22
+
23
+ /** Nest file only: books/.../navigator/<sha256-32>/work-context.json. */
24
+ export function isNavigatorWorkContextFile(path: string): boolean {
25
+ const resolved = resolve(path);
26
+ if (basename(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
27
+ const nest = dirname(resolved);
28
+ if (!/^[0-9a-f]{32}$/.test(basename(nest))) return false;
29
+ return basename(dirname(nest)) === "navigator";
30
+ }
31
+
32
+ function canonicalNavigatorWorkContextFile(path: string): string | undefined {
33
+ if (!isNavigatorWorkContextFile(path)) return undefined;
34
+ try {
35
+ const real = realpathSync(path);
36
+ return isNavigatorWorkContextFile(real) ? real : undefined;
37
+ } catch {
38
+ return undefined;
39
+ }
40
+ }
41
+
42
+ export async function persistNavigatorWorkBase(
43
+ sessionDir: string,
44
+ body: NavigatorWorkBase,
45
+ ): Promise<string | undefined> {
46
+ if (sessionDir.trim() === "" || !existsSync(sessionDir)) return undefined;
47
+ if (body.authority.trim() === "") return undefined;
48
+ const path = navigatorWorkContextFile(sessionDir);
49
+ const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}\n`;
50
+ try {
51
+ const current = await readFile(path, "utf8");
52
+ if (current === next) return path;
53
+ } catch (error) {
54
+ if (!(error instanceof Error && "code" in error && (error as NodeJS.ErrnoException).code === "ENOENT")) {
55
+ throw error;
56
+ }
57
+ }
58
+ await writeFileAtomically(path, next);
59
+ return path;
60
+ }
61
+
62
+ export async function readNavigatorWorkBase(path: string): Promise<NavigatorWorkBase | undefined> {
63
+ const canonical = canonicalNavigatorWorkContextFile(path);
64
+ if (canonical === undefined) return undefined;
65
+ let text: string;
66
+ try {
67
+ text = await readFile(canonical, "utf8");
68
+ } catch (error) {
69
+ if (error instanceof Error && "code" in error && (error as NodeJS.ErrnoException).code === "ENOENT") {
70
+ return undefined;
71
+ }
72
+ throw error;
73
+ }
74
+ let parsed: unknown;
75
+ try {
76
+ parsed = JSON.parse(text);
77
+ } catch {
78
+ return undefined;
79
+ }
80
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return undefined;
81
+ const record = parsed as Record<string, unknown>;
82
+ if (typeof record.subject !== "string" || typeof record.authority !== "string") return undefined;
83
+ if (record.authority.trim() === "") return undefined;
84
+ return { subject: record.subject, authority: record.authority };
85
+ }
86
+
87
+ function jsonObjectFromPrompt(prompt: string): Record<string, unknown> | undefined {
88
+ const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
89
+ if (!head.startsWith("{")) return undefined;
90
+ try {
91
+ const parsed: unknown = JSON.parse(head);
92
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return undefined;
93
+ return parsed as Record<string, unknown>;
94
+ } catch {
95
+ return undefined;
96
+ }
97
+ }
98
+
99
+ export function workContextPathFromPrompt(prompt: string): string | undefined {
100
+ const record = jsonObjectFromPrompt(prompt);
101
+ const path = record?.workContextPath;
102
+ if (typeof path !== "string" || path.trim() === "") return undefined;
103
+ return isNavigatorWorkContextFile(path) ? path : undefined;
104
+ }
105
+
106
+ /** Settlement JSON gains the nest pointer. Non-JSON prompts stay unchanged. */
107
+ export function attachWorkContextPointer(text: string, workContextPath: string): string {
108
+ const record = jsonObjectFromPrompt(text);
109
+ if (record === undefined) return text;
110
+ if (typeof record.workContextPath === "string" && record.workContextPath.trim() !== "") return text;
111
+ const head = text.trimStart().split("\n\n", 1)[0] ?? "";
112
+ const rest = text.trimStart().slice(head.length);
113
+ return `${JSON.stringify({ ...record, workContextPath })}${rest}`;
114
+ }
115
+
116
+ /** System-prompt base for one agent start. Absent or unreadable file yields undefined. */
117
+ export async function loadNavigatorWorkBaseSuffix(prompt: string): Promise<string | undefined> {
118
+ const path = workContextPathFromPrompt(prompt);
119
+ if (path === undefined) return undefined;
120
+ const body = await readNavigatorWorkBase(path);
121
+ if (body === undefined) return undefined;
122
+ return `<work_subject>\n${body.subject}\n</work_subject>\n\n<controlling_authority>\n${body.authority}\n</controlling_authority>`;
123
+ }
@@ -23,10 +23,6 @@ export const NOTARY_TICKET_FLAG = {
23
23
  },
24
24
  } as const;
25
25
 
26
- /** Package-owned kickoff only — callers supply zero prompt bytes (ADR 0067 / #448). */
27
- export const NOTARY_FIXED_KICKOFF =
28
- "符宝郎案卷已受理;来源 run 定位见会话材料。";
29
-
30
26
  export const notaryOutputSchema = reviewSubmissionSchema;
31
27
 
32
28
  export type NotarySourceRunLocator = {
@@ -41,7 +41,7 @@ const completedClassResultsSchema = Type.Array(completedClassResultSchema);
41
41
  // (src/countersign-role.ts) — one shared description across every variant
42
42
  // so openToolObjectFromUnion's identical-declaration collapse drops none of it.
43
43
  const FIXER_STATUS_DESCRIPTION =
44
- "planned | completed | refused | unfinished | partially_completed — 形状指引,非 schema 闸;unfinished 缺前置或违宪约束致本局未完成时可用,缺待决 owner 决定或答复属缺前置。" as const;
44
+ "planned | completed | refused | unfinished | partially_completed。unfinished 缺前置或违宪约束致本局未完成时可用,缺待决 owner 决定或答复属缺前置。" as const;
45
45
  const fixerOutputVariants = Type.Union([
46
46
  Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "如实结果报告" }) }),
47
47
  Type.Object({ status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type.String({ description: "如实结果报告" }), remainingScope: Type.String({ description: "依法不能完成的工作范围" }), blocker: Type.Unsafe({ ...blockerSchema, description: "合法阻断完成的 blocker" }) }),
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Public Gatekeeper (门下省) terminating receipt contracts (#639).
3
- * Direct public seat shares the province decision shape: dispatch | pass.
3
+ * Direct public seat decision shape. status field semantics: dispatch | pass.
4
4
  * No usable result is infrastructure failure via public settlement, not a judgment status (#475).
5
5
  */
6
6
  import { Type } from "typebox";
@@ -14,7 +14,7 @@ export const GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
14
14
  export const gatekeeperDecisionSchema = openToolObject(
15
15
  Type.Object({
16
16
  status: Type.Unknown({
17
- description: "dispatch | pass — 形状指引,非 schema 闸",
17
+ description: "dispatch | pass",
18
18
  }),
19
19
  officer: Type.Unknown({
20
20
  description: "status 为 dispatch 时为 inspector | notary",
@@ -43,7 +43,7 @@ function asStringArray(value: unknown): readonly string[] {
43
43
  }
44
44
 
45
45
  /**
46
- * Project one lawful explicit Gatekeeper decision (dispatch | pass).
46
+ * Project one explicit Gatekeeper decision.
47
47
  * No throw on shape — ADR 0055 / 第 0 条: already-submitted params are retained as-is;
48
48
  * public-terminal projects non-usable releases via typed failure cause.
49
49
  */
@@ -16,7 +16,7 @@ export const navigatorOutputSchema = withTerminatingOutputDeclarations(
16
16
  openToolObject(
17
17
  Type.Object({
18
18
  prose: Type.Unknown({
19
- description: "游奕使散文建议,原样呈现。不要求 candidates/next 等结构化字段。形状指引,非 schema 闸",
19
+ description: "游奕使散文建议,原样呈现。不要求 candidates/next 等结构化字段。",
20
20
  }),
21
21
  }),
22
22
  ),
@@ -28,14 +28,12 @@ export const INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic" as const;
28
28
  const infrastructureFailureNested = Type.Object(
29
29
  {
30
30
  [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type.Unknown({
31
- description:
32
- "非空基础设施失败诊断字符串。无失败时必须省略整个 infrastructureFailure。形状指引,非 schema 闸。",
31
+ description: "基础设施失败诊断字符串。",
33
32
  }),
34
33
  },
35
34
  {
36
35
  additionalProperties: true,
37
- description:
38
- "基础设施真实失败声明(如需)。规范形:{ diagnostic: 非空诊断字符串 };无失败时必须省略。形状指引,非 schema 闸。",
36
+ description: "仅基础设施真实失败时出现。",
39
37
  },
40
38
  );
41
39
  // Open nested required so host cannot pure-shape-reject the declaration fragment.
@@ -67,8 +65,7 @@ export function withTerminatingOutputDeclarations<
67
65
  baseProperties?.ticketNumber === undefined
68
66
  ? {
69
67
  ticketNumber: Type.Unknown({
70
- description:
71
- "可选本票号:尚未绑定时由角色在既有回执中申报;机械层只记录合法正整数,不从散文推导、不验真。缺失或错形不拒收。",
68
+ description: "可选本票号。尚未绑定时由角色在既有回执中申报。",
72
69
  }),
73
70
  }
74
71
  : {}
@@ -52,6 +52,7 @@ export const NOTARY_SESSION_MATERIALS = [
52
52
  "souls/audit-law.md",
53
53
  "souls/ticket-law.md",
54
54
  "souls/gate-output-guide.md",
55
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md",
55
56
  ] as const;
56
57
 
57
58
  /** Shared by public inspector and gatekeeper-province inspector. */
@@ -61,6 +62,7 @@ export const INSPECTOR_SESSION_MATERIALS = [
61
62
  "souls/audit-law.md",
62
63
  "souls/quality-law.md",
63
64
  "souls/gate-output-guide.md",
65
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md",
64
66
  ] as const;
65
67
 
66
68
  /**
@@ -75,6 +77,7 @@ export const AUDITOR_PUBLIC_SESSION_MATERIALS = [
75
77
  "souls/doctor-auditor.md",
76
78
  "souls/audit-law.md",
77
79
  "souls/quality-law.md",
80
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md",
78
81
  ] as const;
79
82
 
80
83
  /**
@@ -107,6 +110,7 @@ export const PUBLIC_ROLE_RECORDS = [
107
110
  "souls/audit-law.md",
108
111
  "souls/quality-law.md",
109
112
  "souls/judge-output-guide.md",
113
+ "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md",
110
114
  ],
111
115
  },
112
116
  {
@@ -384,7 +388,7 @@ export const PUBLIC_ROLE_RECORDS = [
384
388
  activationStage: "load-and-install",
385
389
  receiptStatusKey: "status",
386
390
  // #924: 公用《票面法》三席同装
387
- sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"],
391
+ sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"],
388
392
  },
389
393
  {
390
394
  role: "secretariat",
@@ -1,4 +1,6 @@
1
1
  export type CliIo = {
2
2
  stdout: (text: string) => void;
3
3
  stderr: (text: string) => void;
4
+ /** Public resume presents its failure diagnostic via a durable-file pointer instead. */
5
+ omitFailureStderrDiagnostic?: boolean;
4
6
  };
@@ -1,4 +1,4 @@
1
- import type { DurablePrincipalAuthority } from "../host-contracts.ts";
1
+ import type { DurablePrincipalAuthority, RoleTurnHost } from "../host-contracts.ts";
2
2
  import { piDurablePrincipalAuthority } from "../pi/durable-principal.ts";
3
3
  /**
4
4
  * Public ak-role CLI dispatcher (roles / config / layered help / Judge run).
@@ -49,8 +49,10 @@ import { seatModelOnly } from "./registry.ts";
49
49
  import { CliUsageError } from "./cli-errors.ts";
50
50
  import type { CliIo } from "./cli-io.ts";
51
51
  import { runMachineSkillSetup } from "./machine-method-skills.ts";
52
- import type { PostAdmissionEnv } from "./post-admission.ts";
53
- import type { RoleTurnHost } from "../host-contracts.ts";
52
+ import {
53
+ presentLocatedResumeFailure,
54
+ type PostAdmissionEnv,
55
+ } from "./post-admission.ts";
54
56
  import { appendPiSessionCustomEntry } from "../pi/role-turn-host.ts";
55
57
  import {
56
58
  composeRoleTurnHostAdapters,
@@ -78,6 +80,7 @@ import {
78
80
  type PublicRoleOptionOwner,
79
81
  type TypedOptionConsumer,
80
82
  } from "./option-definitions.ts";
83
+ import { TurnDispatchedFailure } from "./auto-resume.ts";
81
84
  import { continueParentAfterChild, runPublicInstructionSeat, runPublicInstructionSeatResume } from "./instruction-seat-run.ts";
82
85
  import { courtDiaristEscalated } from "./countersign-run.ts";
83
86
  import { runPublicAnalyst } from "./analyst-run.ts";
@@ -1093,6 +1096,9 @@ export async function runAkRole(
1093
1096
  env: CliEnv,
1094
1097
  ): Promise<CliResult> {
1095
1098
  const io = env.io ?? defaultIo();
1099
+ let resumeFailureContext:
1100
+ | { readonly home: string; readonly runId: string; readonly authority: DurablePrincipalAuthority }
1101
+ | undefined;
1096
1102
 
1097
1103
  try {
1098
1104
  // Select the installed package identity once, before any role-owned Skill,
@@ -1207,12 +1213,17 @@ export async function runAkRole(
1207
1213
  // must still exist. Seat and dispatch follow the durable admitted role.
1208
1214
  // #471: unique parser owns {runId, message?}; five role paths only consume it.
1209
1215
  if (parsed.command === "resume") {
1216
+ const resumeRequest = parseResumeRequest(parsed.args);
1217
+ resumeFailureContext = {
1218
+ home,
1219
+ runId: resumeRequest.runId,
1220
+ authority: env.principalAuthority ?? piDurablePrincipalAuthority,
1221
+ };
1210
1222
  const agentDir = resolveAgentDir(env, home);
1211
1223
  const cwd = env.cwd ?? process.cwd();
1212
1224
  const config = await loadAndValidateConfig(home, env.packageRoot);
1213
1225
  const credentials =
1214
1226
  env.credentials ?? (await loadCredentialProviders(agentDir));
1215
- const resumeRequest = parseResumeRequest(parsed.args);
1216
1227
  const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
1217
1228
  // Missing durable role keeps the judge seat table. The resume entry
1218
1229
  // itself is one function; it reads the stored run.
@@ -1243,6 +1254,11 @@ export async function runAkRole(
1243
1254
  && !courtDiaristEscalated(current.terminal.roleOutcome)
1244
1255
  ) {
1245
1256
  const parentRunId = current.admitted.correlationId;
1257
+ resumeFailureContext = {
1258
+ home,
1259
+ runId: parentRunId,
1260
+ authority: env.principalAuthority ?? piDurablePrincipalAuthority,
1261
+ };
1246
1262
  const parentRole = await peekRoleRunRole(home, parentRunId);
1247
1263
  if (parentRole === undefined) break;
1248
1264
  const parentSeat = resolveEffectiveSeat(config, parentRole, credentials, invocationFromParsed(parsed));
@@ -1287,6 +1303,24 @@ export async function runAkRole(
1287
1303
  // tokens (including misspelled role names) are structural rejects.
1288
1304
  throw new CliUsageError(`unknown command: ${parsed.command}`);
1289
1305
  } catch (error) {
1306
+ // A dispatched turn owns its settlement; only pre-dispatch resume failures
1307
+ // fall through to the located-run diagnostic presenter here.
1308
+ if (
1309
+ resumeFailureContext !== undefined
1310
+ && !(error instanceof TurnDispatchedFailure)
1311
+ && await presentLocatedResumeFailure(
1312
+ resumeFailureContext.home,
1313
+ resumeFailureContext.runId,
1314
+ resumeFailureContext.authority,
1315
+ io,
1316
+ error,
1317
+ )
1318
+ ) {
1319
+ return {
1320
+ exitCode: error instanceof CliUsageError ? 2 : 1,
1321
+ ...(error instanceof HostSelectionError ? { hostFailure: error.failure } : {}),
1322
+ };
1323
+ }
1290
1324
  if (error instanceof HostSelectionError) {
1291
1325
  io.stderr(formatCliDiagnostic(formatHostSelectionFailure(error.failure)));
1292
1326
  return { exitCode: 1, hostFailure: error.failure };
@@ -369,7 +369,7 @@ export async function runCountersignCourtDiaristStation(
369
369
  for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
370
370
  const outcome = await invokeCourtDiarist(
371
371
  {
372
- instruction: `整理 #${ticketNumber} 的本案依据。`,
372
+ instruction: admitted.instruction,
373
373
  projectRoot: admitted.projectRoot,
374
374
  failureLabel: `ticket #${ticketNumber}`,
375
375
  correlationId: admitted.runId,
@@ -33,6 +33,7 @@ import {
33
33
  type AdmittedCountersignInvocation,
34
34
  type AdmittedRoleInvocation,
35
35
  type PublicSeatParse,
36
+ type RunDirectoryRelocation,
36
37
  } from "./invocation.ts";
37
38
  import {
38
39
  presentControlledFailure,
@@ -41,6 +42,7 @@ import {
41
42
  runPostAdmissionOneShot,
42
43
  runPostAdmissionResumable,
43
44
  runPostAdmissionSeatResume,
45
+ showResumeErrorPointer,
44
46
  resumeTurnRequestProjectionOptions,
45
47
  type PostAdmissionAdapters,
46
48
  type PostAdmissionEnv,
@@ -143,13 +145,13 @@ async function bindAndRelocateDiarist(
143
145
  admitted: AdmittedRoleInvocation & { role: "diarist" },
144
146
  authority: DurablePrincipalAuthority,
145
147
  lease?: RunWriterLease,
146
- ): Promise<void> {
148
+ ): Promise<RunDirectoryRelocation | undefined> {
147
149
  const boardTicket = await readBoardTicketNumber(admitted.runDirectory);
148
- if (boardTicket === undefined) return;
150
+ if (boardTicket === undefined) return undefined;
149
151
  if (admitted.ticketNumber === undefined) {
150
152
  await bindAdmittedTicketNumber(admitted, boardTicket);
151
153
  }
152
- await relocateAdmittedRunToTicket(admitted, authority, lease);
154
+ return await relocateAdmittedRunToTicket(admitted, authority, lease);
153
155
  }
154
156
 
155
157
  function seatAdapters(
@@ -176,8 +178,8 @@ function seatAdapters(
176
178
  await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
177
179
  },
178
180
  afterDispatch: async (seat: AdmittedRoleInvocation, lease?: RunWriterLease) => {
179
- if (!isBoardTicketSeat(seat)) return;
180
- await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
181
+ if (!isBoardTicketSeat(seat)) return undefined;
182
+ return await bindAndRelocateDiarist(seat, env.principalAuthority, lease);
181
183
  },
182
184
  }
183
185
  : {}),
@@ -824,5 +826,7 @@ export async function continueParentAfterChild(
824
826
  return { exitCode: 0, admitted, terminal: refresh.terminal };
825
827
  }
826
828
  }
827
- return dispatchAdmitted(admitted, env, io);
829
+ const result = await dispatchAdmitted(admitted, env, { ...io, omitFailureStderrDiagnostic: true });
830
+ showResumeErrorPointer(io, result.exitCode, result.terminal);
831
+ return result;
828
832
  }
@@ -87,7 +87,6 @@ import { sha256Hex } from "../sha256.ts";
87
87
  import { rehomeUnboundTicketProvenance } from "../ticket-provenance.ts";
88
88
  import { uuidv7 } from "../uuidv7.ts";
89
89
  import {
90
- NOTARY_FIXED_KICKOFF,
91
90
  type NotarySourceRunLocator,
92
91
  } from "../notary-contracts.ts";
93
92
  import {
@@ -309,6 +308,11 @@ export type AdmittedRoleInvocation =
309
308
  | AdmittedReviewerInvocation
310
309
  | AdmittedMergerInvocation;
311
310
 
311
+ export type RunDirectoryRelocation = {
312
+ readonly oldRunDirectory: string;
313
+ readonly newRunDirectory: string;
314
+ };
315
+
312
316
  /** Persistence projection only — not carried on Admitted (opaque principal owns identity). */
313
317
  type RoleInvocationLedgerSource = Pick<
314
318
  AdmittedRoleInvocationBase,
@@ -642,7 +646,7 @@ export async function relocateAdmittedRunToTicket(
642
646
  admitted: AdmittedRoleInvocation,
643
647
  authority: DurablePrincipalAuthority,
644
648
  heldLease?: { relocate(runDirectory: string): void },
645
- ): Promise<{ oldRunDirectory: string; newRunDirectory: string } | undefined> {
649
+ ): Promise<RunDirectoryRelocation | undefined> {
646
650
  if (admitted.ticketNumber === undefined || !admitted.runDirectory.includes(`${sep}unbound${sep}runs${sep}`)) return undefined;
647
651
  const oldRunDirectory = admitted.runDirectory;
648
652
  const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
@@ -2150,6 +2154,7 @@ type InstructionTransportSource = {
2150
2154
  readonly baseRevision?: string;
2151
2155
  readonly lens?: ReviewerLens;
2152
2156
  readonly authorityRefs?: readonly string[];
2157
+ readonly sourceRunPath?: string;
2153
2158
  };
2154
2159
 
2155
2160
  function admittedTransportPromptKind(
@@ -2172,13 +2177,16 @@ export function buildInstructionTransportPrompt(
2172
2177
  ): string {
2173
2178
  const kind = admittedTransportPromptKind(admitted);
2174
2179
  if (kind === "fixed-kickoff") {
2175
- return appendEngineSessionMaterial([NOTARY_FIXED_KICKOFF], engineMaterial).join("\n");
2180
+ if (admitted.sourceRunPath === undefined || admitted.sourceRunPath.trim() === "") {
2181
+ throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
2182
+ }
2183
+ return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
2176
2184
  }
2177
2185
  if (kind === "baseline") {
2178
2186
  if (admitted.baseRevision === undefined) {
2179
2187
  throw new Error("baseline transport prompt is missing the bound revision");
2180
2188
  }
2181
- const lines = [`左拾遗案已受理。比较基线:${admitted.baseRevision}`];
2189
+ const lines = [admitted.baseRevision];
2182
2190
  if (!admitted.instructionEmpty) {
2183
2191
  lines.push("", admitted.instruction);
2184
2192
  }