@akagilnc/pi-workflow-roles 0.1.5289 → 0.1.5301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/README.zh-CN.md +7 -3
- package/dist/acp-host/production-host.js +97 -462
- package/dist/diarist-contracts.js +20 -96
- package/dist/headless-host/production-host.js +97 -462
- package/dist/migrate-book-topology.js +75 -77
- package/dist/public-cli/countersign-run.js +3 -124
- package/dist/public-cli/instruction-seat-run.js +5 -97
- package/dist/public-cli/invocation.js +0 -33
- package/dist/public-cli/main.js +10 -362
- package/dist/public-cli/post-admission.js +2 -14
- package/dist/public-cli/run-lifecycle.js +0 -85
- package/dist/public-role-summons.js +2 -2
- package/dist/ticket-provenance.js +25 -29
- package/package.json +1 -1
- package/resources/diarist-collect.md +4 -4
- package/src/diarist-contracts.ts +24 -116
- package/src/diarist-role.ts +39 -50
- package/src/diarist.ts +9 -29
- package/src/public-cli/countersign-run.ts +7 -184
- package/src/public-cli/instruction-seat-run.ts +6 -101
- package/src/public-cli/invocation.ts +2 -64
- package/src/public-cli/post-admission.ts +2 -15
- package/src/public-cli/run-lifecycle.ts +0 -117
- package/src/public-role-summons.ts +3 -3
- package/src/role-runtime.ts +13 -7
- package/src/ticket-provenance.ts +31 -44
|
@@ -7,103 +7,8 @@
|
|
|
7
7
|
* #901: LLM submits bounds; the mechanical layer projects source bytes.
|
|
8
8
|
*/
|
|
9
9
|
import { projectTicketProvenanceSessions, } from "./ticket-provenance-contracts.js";
|
|
10
|
-
import { isSafePositiveTicketNumber
|
|
10
|
+
import { isSafePositiveTicketNumber } from "./run-ticket-number.js";
|
|
11
11
|
export const DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
|
|
12
|
-
/**
|
|
13
|
-
* Sole shape projection for a typed co-review ticket set (#871).
|
|
14
|
-
* Positive safe integers, first-seen order, duplicates dropped. Not content judgment.
|
|
15
|
-
* Returns null when `raw` is not an array (callers classify absent vs durable damage).
|
|
16
|
-
* Returns a possibly empty list when `raw` is an array (unlawful members skipped).
|
|
17
|
-
* When `principalTicket` is set, that ticket is guaranteed as a member (prepended if missing).
|
|
18
|
-
*/
|
|
19
|
-
export function projectCourtTicketNumbers(raw, options) {
|
|
20
|
-
if (!Array.isArray(raw))
|
|
21
|
-
return null;
|
|
22
|
-
const out = [];
|
|
23
|
-
const seen = new Set();
|
|
24
|
-
for (const item of raw) {
|
|
25
|
-
if (!isSafePositiveTicketNumber(item))
|
|
26
|
-
continue;
|
|
27
|
-
if (seen.has(item))
|
|
28
|
-
continue;
|
|
29
|
-
seen.add(item);
|
|
30
|
-
out.push(item);
|
|
31
|
-
}
|
|
32
|
-
const principal = options?.principalTicket;
|
|
33
|
-
if (principal === undefined)
|
|
34
|
-
return out;
|
|
35
|
-
requireSafePositiveTicketNumber(principal, "projectCourtTicketNumbers principalTicket");
|
|
36
|
-
if (seen.has(principal))
|
|
37
|
-
return out;
|
|
38
|
-
return [principal, ...out];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Durable-field interpreter for #871 co-review sets.
|
|
42
|
-
* Absent key (old-format run) is not damage. Present but empty / non-array /
|
|
43
|
-
* partially unlawful / missing principal is damage — callers must fail closed,
|
|
44
|
-
* never wash into main-only.
|
|
45
|
-
*/
|
|
46
|
-
export function interpretDurableCourtTicketNumbers(record, options) {
|
|
47
|
-
if (!Object.hasOwn(record, "courtTicketNumbers")) {
|
|
48
|
-
return { kind: "absent" };
|
|
49
|
-
}
|
|
50
|
-
const raw = record.courtTicketNumbers;
|
|
51
|
-
if (!Array.isArray(raw)) {
|
|
52
|
-
return {
|
|
53
|
-
kind: "damage",
|
|
54
|
-
reason: "courtTicketNumbers is present but not an array",
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
if (raw.length === 0) {
|
|
58
|
-
return {
|
|
59
|
-
kind: "damage",
|
|
60
|
-
reason: "courtTicketNumbers is present but empty",
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
for (let i = 0; i < raw.length; i += 1) {
|
|
64
|
-
const item = raw[i];
|
|
65
|
-
if (!isSafePositiveTicketNumber(item)) {
|
|
66
|
-
return {
|
|
67
|
-
kind: "damage",
|
|
68
|
-
reason: `courtTicketNumbers[${i}] is not a safe positive integer`,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Members are all lawful numbers; sole projection owns dedupe/order.
|
|
73
|
-
const tickets = projectCourtTicketNumbers(raw);
|
|
74
|
-
if (tickets === null || tickets.length === 0) {
|
|
75
|
-
return {
|
|
76
|
-
kind: "damage",
|
|
77
|
-
reason: "courtTicketNumbers projected empty after lawful members",
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const principal = options?.principalTicket;
|
|
81
|
-
if (principal !== undefined) {
|
|
82
|
-
if (!isSafePositiveTicketNumber(principal)) {
|
|
83
|
-
return {
|
|
84
|
-
kind: "damage",
|
|
85
|
-
reason: "courtTicketNumbers principal ticket is not a safe positive integer",
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (!tickets.includes(principal)) {
|
|
89
|
-
return {
|
|
90
|
-
kind: "damage",
|
|
91
|
-
reason: `courtTicketNumbers is missing principal ticket #${principal}`,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return { kind: "ok", tickets: Object.freeze([...tickets]) };
|
|
96
|
-
}
|
|
97
|
-
/** True when two durable #871 sets are byte-identical sequences. */
|
|
98
|
-
export function sameCourtTicketNumbers(left, right) {
|
|
99
|
-
if (left.length !== right.length)
|
|
100
|
-
return false;
|
|
101
|
-
for (let i = 0; i < left.length; i += 1) {
|
|
102
|
-
if (left[i] !== right[i])
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
12
|
export function validateRecordedDiaristOutput(value) {
|
|
108
13
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
109
14
|
throw new Error("Diarist output has no execution discriminator");
|
|
@@ -130,3 +35,22 @@ export function projectDiaristSessions(value) {
|
|
|
130
35
|
return [];
|
|
131
36
|
return projectTicketProvenanceSessions(raw);
|
|
132
37
|
}
|
|
38
|
+
/** Present multi-ticket bounds take precedence over the legacy single-ticket sessions. */
|
|
39
|
+
export function projectDiaristTicketSessions(value) {
|
|
40
|
+
const raw = value.ticketSessions;
|
|
41
|
+
if (!Array.isArray(raw))
|
|
42
|
+
return undefined;
|
|
43
|
+
const perTicket = new Map();
|
|
44
|
+
for (const entry of raw) {
|
|
45
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry))
|
|
46
|
+
return undefined;
|
|
47
|
+
const { ticketNumber, sessions: rawSessions } = entry;
|
|
48
|
+
if (!isSafePositiveTicketNumber(ticketNumber))
|
|
49
|
+
return undefined;
|
|
50
|
+
const sessions = projectTicketProvenanceSessions(rawSessions);
|
|
51
|
+
if (sessions === undefined)
|
|
52
|
+
return undefined;
|
|
53
|
+
perTicket.set(ticketNumber, [...(perTicket.get(ticketNumber) ?? []), ...sessions]);
|
|
54
|
+
}
|
|
55
|
+
return Array.from(perTicket, ([ticketNumber, sessions]) => ({ ticketNumber, sessions }));
|
|
56
|
+
}
|