@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sole reader for gate-cycle facts of
|
|
2
|
+
* Sole reader for gate-cycle facts of archived officer-pointer history rows
|
|
3
|
+
* (decoded via readOfficerPointers; parent current.json no longer projects officers — #1195).
|
|
3
4
|
*
|
|
4
5
|
* Consumer: Analyst sole ledger scan (classifyScopedRun). Metric families must
|
|
5
6
|
* not open a second disk scan — they consume retained facts.
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
* the current gatekeeper/inspector/notary English face. Projection always uses
|
|
9
10
|
* the current English officer identity (inspector | notary).
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
+
* No archived pointers → empty rounds (lawful zero). A pointer whose
|
|
12
13
|
* officer session fails canonical read/parse must fail loudly (never silently under-count).
|
|
13
14
|
* An accepted gate terminating receipt (isError:false pair on dispatch/officer
|
|
14
15
|
* tool) whose required typed facts are unusable — status, dispatch officer, or
|
|
@@ -308,10 +309,10 @@ function pairGateRounds(volumes) {
|
|
|
308
309
|
.map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
309
310
|
}
|
|
310
311
|
/**
|
|
311
|
-
* Read and pair gate-cycle rounds from
|
|
312
|
-
* run
|
|
313
|
-
*
|
|
314
|
-
*
|
|
312
|
+
* Read and pair gate-cycle rounds from archived officer-pointer history on one
|
|
313
|
+
* parent run; each pointer names the independent officer session 正本.
|
|
314
|
+
* No pointers → [] (lawful zero). A damaged pointer or officer session propagates
|
|
315
|
+
* — damaged topology must not wash to zero rounds.
|
|
315
316
|
*
|
|
316
317
|
* Pass `parentSessionFile` to keep only rounds whose attempt binding names that parent.
|
|
317
318
|
*/
|
|
@@ -2,40 +2,20 @@ import { basename, join } from "node:path";
|
|
|
2
2
|
import { isRecord } from "./unknown-value.js";
|
|
3
3
|
import { latestOfficerPointersFromRecords, RUN_HISTORY_FILE } from "./run-dossier.js";
|
|
4
4
|
import { OFFICER_POINTER_RECORD_KIND } from "./run-dossier-files.js";
|
|
5
|
-
import { readSitianRecords
|
|
5
|
+
import { readSitianRecords } from "./sitian-facade.js";
|
|
6
6
|
import { homeFromRunDirectory } from "./activation-ledger-topology.js";
|
|
7
|
-
import {
|
|
7
|
+
import { resolveLiveRunDirectoryPath, readRoleRunIdentity } from "./public-cli/run-lifecycle.js";
|
|
8
8
|
import { rewriteRunDirectoryPathValue } from "./role-run-relocation.js";
|
|
9
9
|
import { parseRunLeaf, runDirectoryOfSessionFile } from "./role-run-placement.js";
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Historical parent-side pointer shape (ADR 0079 / #675).
|
|
12
|
+
* Production no longer writes these (#1195); retained only so analysts can read
|
|
13
|
+
* already-archived officer volumes. New runs leave officers empty (lawful zero).
|
|
14
|
+
*/
|
|
11
15
|
export const DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
12
16
|
/** History record kind of a booked officer pointer (appender routes it to history.jsonl). */
|
|
13
17
|
export { OFFICER_POINTER_RECORD_KIND };
|
|
14
|
-
/**
|
|
15
|
-
* Book a typed pointer as one history record of the parent run; the settlement
|
|
16
|
-
* seam projects the latest per officer into current.json `officers`.
|
|
17
|
-
* Never fabricates user/assistant/toolResult rows (#675).
|
|
18
|
-
*
|
|
19
|
-
* Latest record wins per officer under one parent (#753 gate-round accounting):
|
|
20
|
-
* a same-parent re-summons supersedes the earlier pointer instead of adding a
|
|
21
|
-
* second one that re-scans the full officer session and multiplies gate-cycle counts.
|
|
22
|
-
*/
|
|
23
|
-
export function bookDirectOfficerRunPointer(options) {
|
|
24
|
-
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
25
|
-
const pointer = {
|
|
26
|
-
version: 1,
|
|
27
|
-
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
28
|
-
officer: options.officer,
|
|
29
|
-
sessionFile: options.sessionFile,
|
|
30
|
-
...(options.runDirectory !== undefined && options.runDirectory.trim() !== ""
|
|
31
|
-
? { runDirectory: options.runDirectory }
|
|
32
|
-
: {}),
|
|
33
|
-
...(submissionToolCallId === "" ? {} : { submissionToolCallId }),
|
|
34
|
-
};
|
|
35
|
-
reportRunRecord(runDirectoryOfSessionFile(options.parentSessionFile), OFFICER_POINTER_RECORD_KIND, pointer, "submission-gate");
|
|
36
|
-
return pointer;
|
|
37
|
-
}
|
|
38
|
-
/** Shared strict pointer IO; internal audit wraps unreadability as a re-summons. */
|
|
18
|
+
/** Decode one archived pointer; relocates session/run paths when the leaf moved. */
|
|
39
19
|
export async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
40
20
|
const where = `${parentRunDirectory} officers`;
|
|
41
21
|
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
@@ -53,20 +33,17 @@ export async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
53
33
|
const leaf = parseRunLeaf(basename(recordedRunDirectory));
|
|
54
34
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
55
35
|
if (leaf !== undefined && parentIdentity !== undefined) {
|
|
56
|
-
const currentRunDirectory = await
|
|
36
|
+
const currentRunDirectory = await resolveLiveRunDirectoryPath(recordedRunDirectory, homeFromRunDirectory(parentRunDirectory), parentIdentity.bookKey);
|
|
57
37
|
if (currentRunDirectory !== undefined) {
|
|
58
38
|
sessionFile = rewriteRunDirectoryPathValue(sessionFile, recordedRunDirectory, currentRunDirectory);
|
|
59
39
|
if (runDirectory !== undefined)
|
|
60
40
|
runDirectory = currentRunDirectory;
|
|
61
41
|
}
|
|
62
42
|
}
|
|
63
|
-
const submissionToolCallId = typeof raw.submissionToolCallId === "string"
|
|
64
|
-
&& raw.submissionToolCallId.trim() !== "" ? raw.submissionToolCallId : undefined;
|
|
65
43
|
return {
|
|
66
44
|
sessionFile,
|
|
67
45
|
...(officer === undefined ? {} : { officer }),
|
|
68
46
|
...(runDirectory === undefined ? {} : { runDirectory }),
|
|
69
|
-
...(submissionToolCallId === undefined ? {} : { submissionToolCallId }),
|
|
70
47
|
};
|
|
71
48
|
}
|
|
72
49
|
/**
|
|
@@ -86,16 +63,3 @@ export async function readOfficerPointers(parentRunDirectory) {
|
|
|
86
63
|
const officers = await readBookedOfficerPointers(parentRunDirectory);
|
|
87
64
|
return Promise.all(Object.keys(officers).sort().map((name) => resolveOfficerPointer(officers[name], parentRunDirectory)));
|
|
88
65
|
}
|
|
89
|
-
/** Missing or unreadable is not a pass: the internal audit caller re-runs the gate. */
|
|
90
|
-
export async function readDirectOfficerRunPointer(parentSessionFile, officer) {
|
|
91
|
-
try {
|
|
92
|
-
const parentRunDirectory = runDirectoryOfSessionFile(parentSessionFile);
|
|
93
|
-
const pointer = await resolveOfficerPointer((await readBookedOfficerPointers(parentRunDirectory))[officer], parentRunDirectory);
|
|
94
|
-
if (pointer.officer !== officer)
|
|
95
|
-
return undefined;
|
|
96
|
-
return { ...pointer, officer, version: 1, kind: DIRECT_OFFICER_RUN_POINTER_KIND };
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
}
|
package/dist/auditor-soul.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { readPageSync } from "./run-dossier.js";
|
|
3
|
+
import { admittedSourceRunPath } from "./public-cli/invocation.js";
|
|
3
4
|
import { basename, join } from "node:path";
|
|
4
5
|
import { parseRunLeaf } from "./role-run-placement.js";
|
|
5
6
|
import { isRecord } from "./unknown-value.js";
|
|
@@ -93,16 +94,17 @@ function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
|
93
94
|
* Resume binding already on the admitted page.
|
|
94
95
|
* Explicit subject wins; otherwise the source-run role is the audited object.
|
|
95
96
|
*/
|
|
96
|
-
export async function readAuditorResumeBinding(
|
|
97
|
-
const record = readPageSync(runDirectory, "admitted");
|
|
97
|
+
export async function readAuditorResumeBinding(admitted) {
|
|
98
|
+
const record = readPageSync(admitted.runDirectory, "admitted");
|
|
98
99
|
if (record === undefined)
|
|
99
100
|
return undefined;
|
|
100
|
-
|
|
101
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
102
|
+
if (sourceRunPath === undefined)
|
|
101
103
|
return undefined;
|
|
102
104
|
const subject = isAuditorSoulRole(record.auditorSubject)
|
|
103
105
|
? record.auditorSubject
|
|
104
|
-
: subjectFromSourceDirectory(
|
|
106
|
+
: subjectFromSourceDirectory(sourceRunPath);
|
|
105
107
|
if (subject === undefined)
|
|
106
108
|
return undefined;
|
|
107
|
-
return { subject, sourceRunDirectory:
|
|
109
|
+
return { subject, sourceRunDirectory: sourceRunPath };
|
|
108
110
|
}
|
|
@@ -5,28 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { basename } from "node:path";
|
|
8
|
-
import { tryBookKeyFromAkRolesPath } from "./activation-ledger-topology.js";
|
|
9
8
|
import { projectThrownFailureLeaf, retainPackageFault } from "./public-cli/settlement.js";
|
|
10
|
-
import { describeErrorIdentity,
|
|
9
|
+
import { describeErrorIdentity, resolveLiveRunDirectoryPath } from "./public-cli/run-lifecycle.js";
|
|
10
|
+
export { resolveLiveRunDirectoryPath } from "./public-cli/run-lifecycle.js";
|
|
11
11
|
import { deliveryLimitFromConfig } from "./receipt-delivery-policy.js";
|
|
12
12
|
import { parseRunLeaf } from "./role-run-placement.js";
|
|
13
13
|
import { projectTurnRequestLiveRunDirectory } from "./role-run-relocation.js";
|
|
14
14
|
import { reportRunRecord } from "./sitian-facade.js";
|
|
15
15
|
import { isOneShotWorkerReminderCode } from "./submission-errors.js";
|
|
16
|
-
/**
|
|
17
|
-
* #1171: mid-turn report-ticket may have moved the leg. Prefer the recorded
|
|
18
|
-
* path when it still exists; otherwise re-locate by run id inside the book.
|
|
19
|
-
* Undefined means vanished and unlocatable — callers must not revive the dead leaf.
|
|
20
|
-
*/
|
|
21
|
-
export async function resolveLiveRunDirectoryPath(recordedPath, home) {
|
|
22
|
-
if (existsSync(recordedPath))
|
|
23
|
-
return recordedPath;
|
|
24
|
-
const parsed = parseRunLeaf(basename(recordedPath));
|
|
25
|
-
const bookKey = tryBookKeyFromAkRolesPath(recordedPath);
|
|
26
|
-
if (parsed === undefined || bookKey === undefined)
|
|
27
|
-
return undefined;
|
|
28
|
-
return await findRunDirectoryById(home, parsed.runId, bookKey, parsed.role);
|
|
29
|
-
}
|
|
30
16
|
/**
|
|
31
17
|
* Prefer the request path when it still exists; otherwise re-locate by run id
|
|
32
18
|
* (resolveLiveRunDirectoryPath). Mutates the live request so later turn-record /
|
package/dist/gatekeeper-role.js
CHANGED
|
@@ -84,7 +84,7 @@ function projectOfficerPayloads(officer, payloads, fallbackStatus) {
|
|
|
84
84
|
// Single this-court seal is the common path. Never fold history into an array receipt.
|
|
85
85
|
return projectOfficerDecision(officer, payloads[payloads.length - 1], fallbackStatus);
|
|
86
86
|
}
|
|
87
|
-
/** Nested officer runId from summoned.runDirectory, else terminal.runId (
|
|
87
|
+
/** Nested officer runId from summoned.runDirectory, else terminal.runId (resume identity). */
|
|
88
88
|
export function officerRunIdFromSummoned(summoned) {
|
|
89
89
|
if (typeof summoned.runDirectory === "string" && summoned.runDirectory.trim() !== "") {
|
|
90
90
|
const fromDir = runIdFromRunDirectory(summoned.runDirectory);
|
|
@@ -159,6 +159,19 @@ function projectOfficerTerminal(officer, summoned) {
|
|
|
159
159
|
}, summoned);
|
|
160
160
|
}
|
|
161
161
|
if (outcome.kind === "accepted") {
|
|
162
|
+
// Nested / prior incomplete (directionUnsettled) is not a gate pass (ADR 0055).
|
|
163
|
+
// Receipt stays this-court or retained; runId comes from the summoned volume
|
|
164
|
+
// (public-role-summons already prefers nested terminal.runId when roles differ).
|
|
165
|
+
// No parent-side officerPayloads / officerRunId copies (#1195).
|
|
166
|
+
if (outcome.decisiveFacts?.directionUnsettled === true) {
|
|
167
|
+
const receipt = thisCourt.length > 0 ? thisCourt[thisCourt.length - 1] : retainedReceipt(outcome);
|
|
168
|
+
return withOfficerRunId({
|
|
169
|
+
status: "needs_reask",
|
|
170
|
+
officer,
|
|
171
|
+
receipt,
|
|
172
|
+
receivedStatus: receivedDiscriminator(receipt, "status"),
|
|
173
|
+
}, summoned);
|
|
174
|
+
}
|
|
162
175
|
// outcome.status is the fixture/compat leaf: production settlement leaves
|
|
163
176
|
// it undefined once payloads are recorded. It may interpret a receipt
|
|
164
177
|
// lacking its own status, never substitute for a missing receipt.
|