@akagilnc/pi-workflow-roles 0.1.4422 → 0.1.4444
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 +193 -151
- package/dist/diarist-contracts.js +2 -11
- package/dist/headless-host/production-host.js +193 -151
- package/dist/ticket-provenance-contracts.js +6 -25
- package/dist/ticket-provenance.js +223 -90
- package/package.json +1 -1
- package/src/diarist-contracts.ts +1 -19
- package/src/diarist-role.ts +3 -31
- package/src/diarist.ts +5 -19
- package/src/ledger-session-read.ts +1 -2
- package/src/role-runtime.ts +2 -24
- package/src/ticket-provenance-contracts.ts +11 -38
- package/src/ticket-provenance.ts +228 -109
package/src/role-runtime.ts
CHANGED
|
@@ -99,7 +99,6 @@ import {
|
|
|
99
99
|
} from "./secretariat-contracts.ts";
|
|
100
100
|
import {
|
|
101
101
|
DIARIST_ACCEPTED_TEXT,
|
|
102
|
-
projectDiaristAmendments,
|
|
103
102
|
projectDiaristSessions,
|
|
104
103
|
} from "./diarist-contracts.ts";
|
|
105
104
|
import { commitDiaristProjection } from "./diarist.ts";
|
|
@@ -961,26 +960,10 @@ function readDiaristRunCoordinates(ctx: HostContext): {
|
|
|
961
960
|
const DIARIST_BOUNDS_REASK =
|
|
962
961
|
"边界无法使用。请重交 sessions:每卷 path + ranges,每端以原生 id 或本轮行号二选一指名。" as const;
|
|
963
962
|
|
|
964
|
-
/** Build reask text that hands unparsable source lines back for amendment. */
|
|
965
|
-
function diaristUnparsableReask(
|
|
966
|
-
rows: readonly { readonly s: number; readonly line: number; readonly raw: string }[],
|
|
967
|
-
): string {
|
|
968
|
-
const payload = rows.map((row) => ({
|
|
969
|
-
s: row.s,
|
|
970
|
-
line: row.line,
|
|
971
|
-
raw: row.raw,
|
|
972
|
-
}));
|
|
973
|
-
return [
|
|
974
|
-
"下列源行未能录入,请经 amendments 补写(每条 s + line + speaker + text);其余边界可保持不变。",
|
|
975
|
-
JSON.stringify(payload),
|
|
976
|
-
].join("\n");
|
|
977
|
-
}
|
|
978
|
-
|
|
979
963
|
/**
|
|
980
964
|
* #708 / #779 / #901: 起居郎 public seat on the shared filed-officer envelope.
|
|
981
|
-
* LLM judges ticket + dialogue bounds
|
|
982
|
-
*
|
|
983
|
-
* lines reask via ParentQueueReaskError (same mechanism as countersign). Machine
|
|
965
|
+
* LLM judges ticket + dialogue bounds; mechanical layer reprojects the unique
|
|
966
|
+
* records.jsonl. Unusable bounds reask via ParentQueueReaskError. Machine
|
|
984
967
|
* facts never come from model self-report (锚定宪法).
|
|
985
968
|
*/
|
|
986
969
|
export function createDiaristRoleRuntime(
|
|
@@ -1011,7 +994,6 @@ export function createDiaristRoleRuntime(
|
|
|
1011
994
|
if (sessions === undefined) {
|
|
1012
995
|
throw new ParentQueueReaskError(DIARIST_BOUNDS_REASK);
|
|
1013
996
|
}
|
|
1014
|
-
const amendments = projectDiaristAmendments(parameters);
|
|
1015
997
|
let facts;
|
|
1016
998
|
try {
|
|
1017
999
|
facts = await commitDiaristProjection({
|
|
@@ -1019,7 +1001,6 @@ export function createDiaristRoleRuntime(
|
|
|
1019
1001
|
cwd: coords.projectRoot,
|
|
1020
1002
|
home: coords.home,
|
|
1021
1003
|
sessions,
|
|
1022
|
-
amendments,
|
|
1023
1004
|
});
|
|
1024
1005
|
} catch (error) {
|
|
1025
1006
|
// Bound/session input failures → reask via typed identity (not message prefix).
|
|
@@ -1032,9 +1013,6 @@ export function createDiaristRoleRuntime(
|
|
|
1032
1013
|
}
|
|
1033
1014
|
throw error;
|
|
1034
1015
|
}
|
|
1035
|
-
if (facts.unparsable.length > 0) {
|
|
1036
|
-
throw new ParentQueueReaskError(diaristUnparsableReask(facts.unparsable));
|
|
1037
|
-
}
|
|
1038
1016
|
}
|
|
1039
1017
|
return parameters;
|
|
1040
1018
|
},
|
|
@@ -48,29 +48,20 @@ export type TicketProvenanceHeader = {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* 一条对话(存于不可变投影提交;旧 snapshot 中也可为裸行)。
|
|
51
|
-
* `id`
|
|
52
|
-
* 靠录中前后有定位的条目锚定。
|
|
51
|
+
* `id` 按源事实存在则记、不存在不编;`s` 保留卷定位。
|
|
53
52
|
*/
|
|
54
53
|
export type TicketProvenanceLine = {
|
|
55
54
|
readonly speaker: TicketProvenanceSpeaker;
|
|
56
55
|
/** 卷下标(册子头 `sessions` 的位置)。 */
|
|
57
56
|
readonly s: number;
|
|
58
|
-
|
|
57
|
+
/** Logical source order for display. */
|
|
58
|
+
readonly sourcePosition?: number;
|
|
59
|
+
/** Replay-invariant structural identity used for id-less cumulative coverage. */
|
|
60
|
+
readonly sourceIdentity?: string;
|
|
59
61
|
readonly id?: string;
|
|
60
62
|
readonly text: string;
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
/**
|
|
64
|
-
* 坏行补写:绑定源卷与行,带说话人与正文。
|
|
65
|
-
* 编没编由符宝郎读录核旨,代码不判断(`unparsable-line-to-diarist`)。
|
|
66
|
-
*/
|
|
67
|
-
export type TicketProvenanceAmendment = {
|
|
68
|
-
readonly s: number;
|
|
69
|
-
readonly line: number;
|
|
70
|
-
readonly speaker: TicketProvenanceSpeaker;
|
|
71
|
-
readonly text: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
65
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
75
66
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76
67
|
}
|
|
@@ -136,28 +127,6 @@ export function projectTicketProvenanceSessions(
|
|
|
136
127
|
return sessions;
|
|
137
128
|
}
|
|
138
129
|
|
|
139
|
-
/**
|
|
140
|
-
* 投影补写集合。缺该字段=无补写(不拒收);成员形状不成立的整条跳过——
|
|
141
|
-
* 它没有绑定位置,放不回去。
|
|
142
|
-
*/
|
|
143
|
-
export function projectTicketProvenanceAmendments(
|
|
144
|
-
value: unknown,
|
|
145
|
-
): readonly TicketProvenanceAmendment[] {
|
|
146
|
-
if (!Array.isArray(value)) return [];
|
|
147
|
-
const out: TicketProvenanceAmendment[] = [];
|
|
148
|
-
for (const raw of value) {
|
|
149
|
-
if (!isRecord(raw)) continue;
|
|
150
|
-
const s = nonNegativeInteger(raw.s);
|
|
151
|
-
const line = positiveInteger(raw.line);
|
|
152
|
-
const speaker = projectSpeaker(raw.speaker);
|
|
153
|
-
const text = raw.text;
|
|
154
|
-
if (s === undefined || line === undefined || speaker === undefined) continue;
|
|
155
|
-
if (typeof text !== "string") continue;
|
|
156
|
-
out.push({ s, line, speaker, text });
|
|
157
|
-
}
|
|
158
|
-
return out;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
130
|
/** 读回册子头(文件第一行)。形状不成立即 undefined——按无册处理,不猜。 */
|
|
162
131
|
export function projectTicketProvenanceHeader(
|
|
163
132
|
value: unknown,
|
|
@@ -190,12 +159,16 @@ export function projectTicketProvenanceLine(
|
|
|
190
159
|
const s = nonNegativeInteger(value.s);
|
|
191
160
|
if (speaker === undefined || s === undefined) return undefined;
|
|
192
161
|
if (typeof value.text !== "string") return undefined;
|
|
193
|
-
const
|
|
162
|
+
const sourcePosition = nonNegativeInteger(value.sourcePosition);
|
|
163
|
+
const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== ""
|
|
164
|
+
? value.sourceIdentity
|
|
165
|
+
: undefined;
|
|
194
166
|
const id = typeof value.id === "string" && value.id !== "" ? value.id : undefined;
|
|
195
167
|
return {
|
|
196
168
|
speaker,
|
|
197
169
|
s,
|
|
198
|
-
...(
|
|
170
|
+
...(sourcePosition === undefined ? {} : { sourcePosition }),
|
|
171
|
+
...(sourceIdentity === undefined ? {} : { sourceIdentity }),
|
|
199
172
|
...(id === undefined ? {} : { id }),
|
|
200
173
|
text: value.text,
|
|
201
174
|
};
|