@akagilnc/pi-workflow-roles 0.1.5714 → 0.1.5753
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.
- package/dist/acp-host/production-host.js +517 -516
- package/dist/analyst-gate-cycles-read.js +7 -6
- package/dist/archivist-record-pointer.js +9 -45
- package/dist/auditor-soul.js +7 -5
- package/dist/external-host-turn-loop.js +2 -16
- package/dist/gatekeeper-role.js +14 -1
- package/dist/headless-host/production-host.js +517 -516
- package/dist/judge-role.js +1 -1
- package/dist/migrate-book-topology.js +61 -51
- package/dist/navigator-public-session.js +17 -8
- package/dist/notary-contracts.js +2 -2
- package/dist/notary-source-run.js +2 -2
- package/dist/packaged-role-registry.js +0 -10
- package/dist/public-cli/cli.js +13 -6
- package/dist/public-cli/instruction-seat-run.js +157 -138
- package/dist/public-cli/invocation.js +35 -0
- package/dist/public-cli/main.js +497 -505
- package/dist/public-cli/post-admission.js +11 -12
- package/dist/public-cli/run-lifecycle.js +56 -34
- package/dist/public-cli/seat-ticket-binding.js +8 -7
- package/dist/public-cli/settlement.js +4 -126
- package/dist/public-cli/terminal.js +3 -3
- package/dist/public-role-summons.js +14 -6
- package/dist/review-submission.js +47 -14
- package/dist/role-run-relocation.js +4 -3
- package/dist/role-submission-declarations.js +5 -5
- package/dist/run-dossier.js +6 -21
- package/dist/run-terminal-artifacts.js +11 -0
- package/dist/secretariat-contracts.js +0 -4
- package/dist/submission-gate.js +58 -42
- package/dist/submission-ledger.js +3 -2
- package/package.json +1 -1
- package/souls/notary.md +6 -5
- package/src/analyst-gate-cycles-read.ts +7 -6
- package/src/analyst-ledger.ts +2 -2
- package/src/archivist-record-pointer.ts +10 -64
- package/src/auditor-soul.ts +7 -5
- package/src/countersign-role.ts +5 -5
- package/src/external-host-turn-loop.ts +2 -23
- package/src/gatekeeper-role.ts +24 -3
- package/src/judge-role.ts +1 -1
- package/src/navigator-public-session.ts +22 -10
- package/src/notary-contracts.ts +3 -2
- package/src/notary-source-run.ts +2 -7
- package/src/packaged-role-registry.ts +0 -13
- package/src/public-cli/cli.ts +18 -4
- package/src/public-cli/instruction-seat-run.ts +213 -155
- package/src/public-cli/invocation.ts +39 -0
- package/src/public-cli/post-admission.ts +11 -9
- package/src/public-cli/run-lifecycle.ts +80 -33
- package/src/public-cli/seat-ticket-binding.ts +9 -7
- package/src/public-cli/settlement.ts +3 -167
- package/src/public-cli/terminal.ts +3 -3
- package/src/public-role-summons.ts +40 -12
- package/src/review-submission.ts +72 -21
- package/src/role-run-relocation.ts +4 -3
- package/src/role-runtime.ts +3 -3
- package/src/role-submission-declarations.ts +5 -5
- package/src/run-dossier.ts +7 -19
- package/src/run-terminal-artifacts.ts +13 -0
- package/src/secretariat-contracts.ts +0 -19
- package/src/submission-gate.ts +75 -62
- package/src/submission-ledger.ts +3 -6
package/src/judge-role.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { JUDGE_OUTPUT_TOOL_NAME };
|
|
|
13
13
|
export type { JudgeVerdict };
|
|
14
14
|
|
|
15
15
|
/** The only judge audit order: 符宝郎, then 审刑院. */
|
|
16
|
-
const JUDGE_GATES: readonly GatekeeperSubject[] = [
|
|
16
|
+
export const JUDGE_GATES: readonly GatekeeperSubject[] = [
|
|
17
17
|
{ kind: "judge_draft" },
|
|
18
18
|
{ kind: "judge_compliance" },
|
|
19
19
|
];
|
|
@@ -61,11 +61,18 @@ export function runIdFromNavigatorDirectory(runDirectory: string): string | unde
|
|
|
61
61
|
* unknown id or principal unavailable — not resumable. Any other disk role
|
|
62
62
|
* is not this navigator host run. Other throws propagate. Never reads stderr prose.
|
|
63
63
|
*/
|
|
64
|
-
export async function navigatorHostRunResumable(
|
|
64
|
+
export async function navigatorHostRunResumable(
|
|
65
|
+
home: string,
|
|
66
|
+
runId: string,
|
|
67
|
+
runDirectory?: string,
|
|
68
|
+
): Promise<boolean> {
|
|
65
69
|
const { piDurablePrincipalAuthority } = await import("./pi/durable-principal.ts");
|
|
66
70
|
const { loadResumablePublicRole } = await import("./public-cli/run-lifecycle.ts");
|
|
67
71
|
try {
|
|
68
|
-
const loaded = await loadResumablePublicRole(
|
|
72
|
+
const loaded = await loadResumablePublicRole(
|
|
73
|
+
home, runId, piDurablePrincipalAuthority,
|
|
74
|
+
runDirectory === undefined ? undefined : { runDirectory },
|
|
75
|
+
);
|
|
69
76
|
return isNavigatorSeat(loaded.admitted.role);
|
|
70
77
|
} catch (error) {
|
|
71
78
|
if (error instanceof CliUsageError) return false;
|
|
@@ -79,6 +86,7 @@ export type NavigatorPublicSummon = (options: {
|
|
|
79
86
|
readonly cwd: string;
|
|
80
87
|
readonly home?: string;
|
|
81
88
|
readonly resumeRunId?: string;
|
|
89
|
+
readonly resumeRunDirectory?: string;
|
|
82
90
|
/** Shared-lifecycle cancel forwarded from HostContext.signal (#675 / #959). */
|
|
83
91
|
readonly signal?: AbortSignal;
|
|
84
92
|
/** #1160 attendance auto byStatus prepare — host mounts structured schema. */
|
|
@@ -95,7 +103,7 @@ export function createNativeNavigatorSessionFactory(deps?: {
|
|
|
95
103
|
/** Test/composition inject — production leaves unset and uses public-role-summons. */
|
|
96
104
|
readonly summonPublicRole?: NavigatorPublicSummon;
|
|
97
105
|
/** Test inject — production uses navigatorHostRunResumable (typed CLI load). */
|
|
98
|
-
readonly hostRunResumable?: (home: string, runId: string) => Promise<boolean>;
|
|
106
|
+
readonly hostRunResumable?: (home: string, runId: string, runDirectory?: string) => Promise<boolean>;
|
|
99
107
|
}): NavigatorSessionFactory {
|
|
100
108
|
return async ({ context, tool }) => {
|
|
101
109
|
// Model is enforced at prepare (attendance seat resolve) and at prompt (summon).
|
|
@@ -105,8 +113,8 @@ export function createNativeNavigatorSessionFactory(deps?: {
|
|
|
105
113
|
let noReceipt: Partial<NoReceiptLifecycleFacts> | undefined;
|
|
106
114
|
let routePlaybookReadFailure: string | undefined;
|
|
107
115
|
let disposed = false;
|
|
108
|
-
/**
|
|
109
|
-
let
|
|
116
|
+
/** Existing in-memory host continuity, retaining the directory already selected. */
|
|
117
|
+
let hostRun: { runId: string; runDirectory: string } | undefined;
|
|
110
118
|
|
|
111
119
|
const summon: NavigatorPublicSummon = deps?.summonPublicRole
|
|
112
120
|
?? (async (options) => {
|
|
@@ -130,7 +138,7 @@ export function createNativeNavigatorSessionFactory(deps?: {
|
|
|
130
138
|
// Admission after every await: dispose during preflight must not start summon
|
|
131
139
|
// (ADR 0018 / #959 — legal HostContext may omit signal).
|
|
132
140
|
if (disposed) return;
|
|
133
|
-
const resumeRunId =
|
|
141
|
+
const resumeRunId = hostRun?.runId;
|
|
134
142
|
|
|
135
143
|
// Call contract only: forward shared-lifecycle signal; do not own AbortController here
|
|
136
144
|
// (ADR 0018 / #959 — cancel ownership stays on the attendance/envelope seam).
|
|
@@ -153,12 +161,16 @@ export function createNativeNavigatorSessionFactory(deps?: {
|
|
|
153
161
|
if (disposed) return;
|
|
154
162
|
summoned = await summon(baseSummon);
|
|
155
163
|
} else {
|
|
156
|
-
const canResume = await resumable(summonHome, resumeRunId);
|
|
164
|
+
const canResume = await resumable(summonHome, resumeRunId, hostRun?.runDirectory);
|
|
157
165
|
if (disposed) return;
|
|
158
166
|
if (canResume) {
|
|
159
|
-
summoned = await summon({
|
|
167
|
+
summoned = await summon({
|
|
168
|
+
...baseSummon,
|
|
169
|
+
resumeRunId,
|
|
170
|
+
...(hostRun === undefined ? {} : { resumeRunDirectory: hostRun.runDirectory }),
|
|
171
|
+
});
|
|
160
172
|
} else {
|
|
161
|
-
|
|
173
|
+
hostRun = undefined;
|
|
162
174
|
summoned = await summon(baseSummon);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
@@ -217,7 +229,7 @@ export function createNativeNavigatorSessionFactory(deps?: {
|
|
|
217
229
|
const nextRunId = runIdFromNavigatorDirectory(runDirectory);
|
|
218
230
|
if (nextRunId !== undefined) {
|
|
219
231
|
// In-memory only for this attendance lifetime (#1178) — no side-branch pointer ledger.
|
|
220
|
-
|
|
232
|
+
hostRun = { runId: nextRunId, runDirectory };
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
|
package/src/notary-contracts.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Lawful explicit releases: converged | continue | escalate.
|
|
4
4
|
* No usable result is infrastructure failure via public settlement, not a judgment status (#475).
|
|
5
5
|
*/
|
|
6
|
-
import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME,
|
|
6
|
+
import { REVIEW_SUBMISSION_OUTPUT_TOOL_NAME, courtReviewSubmissionSchema } from "./review-submission.ts";
|
|
7
7
|
|
|
8
8
|
import { isRecord } from "./unknown-value.ts";
|
|
9
9
|
|
|
@@ -25,7 +25,8 @@ export const NOTARY_TICKET_FLAG = {
|
|
|
25
25
|
},
|
|
26
26
|
} as const;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/** #1195: generation-required clauses; package still records missing tables as-is. */
|
|
29
|
+
export const notaryOutputSchema = courtReviewSubmissionSchema;
|
|
29
30
|
|
|
30
31
|
export type NotarySourceRunLocator = {
|
|
31
32
|
readonly runDirectory: string;
|
package/src/notary-source-run.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
resolveActivationLedgerHome,
|
|
14
14
|
} from "./activation-ledger-topology.ts";
|
|
15
15
|
import type { NotarySourceRunLocator } from "./notary-contracts.ts";
|
|
16
|
-
import { findRunDirectoryById, readRoleRunIdentity } from "./public-cli/run-lifecycle.ts";
|
|
16
|
+
import { findRunDirectoryById, resolveLiveRunDirectoryPath, readRoleRunIdentity } from "./public-cli/run-lifecycle.ts";
|
|
17
17
|
import { formatRunLeaf, parseRunLeaf } from "./role-run-placement.ts";
|
|
18
18
|
|
|
19
19
|
async function readRetainedIdentity(runDirectory: string) {
|
|
@@ -106,12 +106,7 @@ export async function resolveNotarySourceRunLocator(options: {
|
|
|
106
106
|
basename(subjectDirectory) === "unbound" &&
|
|
107
107
|
resolve(dirname(subjectDirectory)) === resolve(bookDirectory);
|
|
108
108
|
if (isLegacyUnboundLocator) {
|
|
109
|
-
candidate = (await
|
|
110
|
-
options.home,
|
|
111
|
-
identity.runId,
|
|
112
|
-
bookKey,
|
|
113
|
-
identity.role,
|
|
114
|
-
)) ?? candidate;
|
|
109
|
+
candidate = (await resolveLiveRunDirectoryPath(candidate, options.home ?? ledgerHome, bookKey)) ?? candidate;
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
112
|
|
|
@@ -315,8 +315,6 @@ export const PUBLIC_ROLE_RECORDS = [
|
|
|
315
315
|
presentSettled: "always",
|
|
316
316
|
summonResume: false,
|
|
317
317
|
admission: "court-materials",
|
|
318
|
-
/** Durable custom entry names this officer. */
|
|
319
|
-
durableOfficerEntry: true,
|
|
320
318
|
sameParent: "none",
|
|
321
319
|
phases: [null],
|
|
322
320
|
outputTool: COUNTERSIGN_OUTPUT_TOOL_NAME,
|
|
@@ -342,8 +340,6 @@ export const PUBLIC_ROLE_RECORDS = [
|
|
|
342
340
|
phases: [null],
|
|
343
341
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
344
342
|
settlement: "accepted",
|
|
345
|
-
/** Project the durable 给事中 officer entry onto the shared accepted-tool settlement. */
|
|
346
|
-
projectCountersignTerminal: true,
|
|
347
343
|
activationFlags: [
|
|
348
344
|
{ field: "ticketNumber" },
|
|
349
345
|
],
|
|
@@ -671,15 +667,6 @@ export function packagedAuditToolName(role: string): string | undefined {
|
|
|
671
667
|
return record.auditTool;
|
|
672
668
|
}
|
|
673
669
|
|
|
674
|
-
/** Durable officer entry whose name is the seat role. */
|
|
675
|
-
export function packagedDurableOfficerEntry(officer: unknown): boolean {
|
|
676
|
-
return typeof officer === "string" && PUBLIC_ROLE_RECORDS.some((record) =>
|
|
677
|
-
"durableOfficerEntry" in record
|
|
678
|
-
&& record.durableOfficerEntry === true
|
|
679
|
-
&& record.role === officer
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
|
|
683
670
|
/** Admitted-request role whose navigator subject is the public instruction. */
|
|
684
671
|
export function packagedPublicInstructionSubject(role: unknown): boolean {
|
|
685
672
|
return typeof role === "string" && PUBLIC_ROLE_RECORDS.some((record) =>
|
package/src/public-cli/cli.ts
CHANGED
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
type NamedRoleTurnHostAdapter,
|
|
61
61
|
} from "./role-turn-host-resolution.ts";
|
|
62
62
|
import {
|
|
63
|
+
admittedSourceRunPath,
|
|
63
64
|
parseAnalystArgv,
|
|
64
65
|
parsePublicSeatArgv,
|
|
65
66
|
type PublicSeatArgvOwner,
|
|
@@ -83,6 +84,7 @@ import { latestPayloadEscalated } from "./countersign-run.ts";
|
|
|
83
84
|
import { runPublicAnalyst } from "./analyst-run.ts";
|
|
84
85
|
import {
|
|
85
86
|
AUTO_RESUME_LIMIT,
|
|
87
|
+
findRunDirectoryById,
|
|
86
88
|
peekRoleRunRole,
|
|
87
89
|
type PublicResumeRequest,
|
|
88
90
|
} from "./run-lifecycle.ts";
|
|
@@ -1084,7 +1086,7 @@ export async function runAkRole(
|
|
|
1084
1086
|
): Promise<CliResult> {
|
|
1085
1087
|
const io = env.io ?? defaultIo();
|
|
1086
1088
|
let resumeFailureContext:
|
|
1087
|
-
| { readonly home: string; readonly runId: string; readonly authority: DurablePrincipalAuthority }
|
|
1089
|
+
| { readonly home: string; readonly runId: string; readonly authority: DurablePrincipalAuthority; readonly runDirectory?: string }
|
|
1088
1090
|
| undefined;
|
|
1089
1091
|
|
|
1090
1092
|
try {
|
|
@@ -1200,14 +1202,19 @@ export async function runAkRole(
|
|
|
1200
1202
|
// must still exist. Seat and dispatch follow the durable admitted role.
|
|
1201
1203
|
// #471: unique parser owns {runId, message?}; five role paths only consume it.
|
|
1202
1204
|
if (parsed.command === "resume") {
|
|
1203
|
-
|
|
1205
|
+
let resumeRequest = parseResumeRequest(parsed.args);
|
|
1204
1206
|
resumeFailureContext = {
|
|
1205
1207
|
home,
|
|
1206
1208
|
runId: resumeRequest.runId,
|
|
1207
1209
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority,
|
|
1208
1210
|
};
|
|
1211
|
+
const runDirectory = await findRunDirectoryById(home, resumeRequest.runId);
|
|
1212
|
+
if (runDirectory !== undefined) {
|
|
1213
|
+
resumeRequest = { ...resumeRequest, runDirectory };
|
|
1214
|
+
resumeFailureContext = { ...resumeFailureContext, runDirectory };
|
|
1215
|
+
}
|
|
1209
1216
|
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
1210
|
-
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
1217
|
+
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId, resumeRequest);
|
|
1211
1218
|
// Missing durable role keeps the judge seat table. The resume entry
|
|
1212
1219
|
// itself is one function; it reads the stored run.
|
|
1213
1220
|
const seatRole = resumeRole ?? "judge";
|
|
@@ -1238,12 +1245,18 @@ export async function runAkRole(
|
|
|
1238
1245
|
&& !latestPayloadEscalated(current.terminal.roleOutcome)
|
|
1239
1246
|
) {
|
|
1240
1247
|
const parentRunId = current.admitted.correlationId;
|
|
1248
|
+
const parentSource = admittedSourceRunPath(current.admitted);
|
|
1241
1249
|
resumeFailureContext = {
|
|
1242
1250
|
home,
|
|
1243
1251
|
runId: parentRunId,
|
|
1252
|
+
...(parentSource === undefined ? {} : { runDirectory: parentSource }),
|
|
1244
1253
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority,
|
|
1245
1254
|
};
|
|
1246
|
-
const parentRole = await peekRoleRunRole(
|
|
1255
|
+
const parentRole = await peekRoleRunRole(
|
|
1256
|
+
home,
|
|
1257
|
+
parentRunId,
|
|
1258
|
+
parentSource === undefined ? undefined : { runDirectory: parentSource },
|
|
1259
|
+
);
|
|
1247
1260
|
if (parentRole === undefined) break;
|
|
1248
1261
|
const parentSeat = resolveEffectiveSeat(
|
|
1249
1262
|
parts.config,
|
|
@@ -1309,6 +1322,7 @@ export async function runAkRole(
|
|
|
1309
1322
|
resumeFailureContext.authority,
|
|
1310
1323
|
io,
|
|
1311
1324
|
error,
|
|
1325
|
+
resumeFailureContext.runDirectory,
|
|
1312
1326
|
)
|
|
1313
1327
|
) {
|
|
1314
1328
|
return {
|