@akagilnc/pi-workflow-roles 0.1.4204 → 0.1.4228
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 +1203 -770
- package/dist/atomic-write.js +23 -0
- package/dist/diarist-contracts.js +22 -8
- package/dist/headless-host/production-host.js +1191 -758
- package/dist/ledger-session-read.js +52 -21
- package/dist/migrate-book-topology.js +238 -205
- package/dist/public-cli/case-dossier-delivery.js +0 -1
- package/dist/public-cli/main.js +303 -261
- package/dist/session-dialogue.js +221 -0
- package/dist/sitian-facade.js +1 -0
- package/dist/sitian-volume.js +67 -0
- package/dist/ticket-provenance-contracts.js +122 -39
- package/dist/ticket-provenance.js +289 -204
- package/package.json +1 -1
- package/src/book-topology-migration.ts +0 -7
- package/src/book-topology-record-class-migrators.ts +203 -99
- package/src/diarist-contracts.ts +42 -29
- package/src/diarist-role.ts +77 -31
- package/src/diarist.ts +31 -67
- package/src/ledger-session-read.ts +70 -27
- package/src/package-contracts/reviewer-output.ts +1 -1
- package/src/public-cli/case-dossier-delivery.ts +0 -1
- package/src/reviewer-role.ts +3 -3
- package/src/role-runtime.ts +56 -14
- package/src/session-dialogue.ts +225 -0
- package/src/sitian-appender.ts +1 -1
- package/src/sitian-facade.ts +7 -1
- package/src/sitian-volume.ts +91 -0
- package/src/ticket-provenance-contracts.ts +158 -101
- package/src/ticket-provenance.ts +387 -263
|
@@ -24,47 +24,78 @@ function isRecord(value) {
|
|
|
24
24
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* a malformed line is
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* under-count.
|
|
33
|
-
*
|
|
34
|
-
* Loud failures throw LedgerSessionJsonlError carrying prefixRows so the
|
|
35
|
-
* single parse kernel can still expose facts obtained before the bad line.
|
|
27
|
+
* Sole line-level scan of a session volume (single parse kernel, two readings).
|
|
28
|
+
* Keeps live-tail semantics: a malformed line is reported only when a record
|
|
29
|
+
* terminator completed it; an unfinished final fragment at EOF ends the scan.
|
|
30
|
+
* This reading never throws on a bad line — `readLedgerSessionJsonl` puts the
|
|
31
|
+
* loud failure back on top for the consumers that require it.
|
|
36
32
|
*/
|
|
37
|
-
export async function
|
|
33
|
+
export async function readLedgerSessionJsonlLines(path) {
|
|
38
34
|
const text = await readFile(path, "utf8");
|
|
39
35
|
// split keeps a trailing empty segment iff text ends with "\n", so
|
|
40
36
|
// index < lines.length - 1 means this segment was terminated.
|
|
41
37
|
const lines = text.split("\n");
|
|
42
|
-
const
|
|
38
|
+
const out = [];
|
|
43
39
|
for (let index = 0; index < lines.length; index += 1) {
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
40
|
+
const raw = lines[index];
|
|
41
|
+
if (!raw.trim())
|
|
46
42
|
continue;
|
|
43
|
+
const lineNumber = index + 1;
|
|
47
44
|
let row;
|
|
48
45
|
try {
|
|
49
|
-
row = JSON.parse(
|
|
46
|
+
row = JSON.parse(raw);
|
|
50
47
|
}
|
|
51
48
|
catch (error) {
|
|
52
49
|
if (!(error instanceof SyntaxError))
|
|
53
50
|
throw error;
|
|
54
51
|
const completedByTerminator = index < lines.length - 1;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
// unfinished fragment at EOF — not a line at all
|
|
53
|
+
if (!completedByTerminator)
|
|
54
|
+
break;
|
|
55
|
+
out.push({
|
|
56
|
+
line: lineNumber,
|
|
57
|
+
raw,
|
|
58
|
+
error: `malformed JSONL record in ${path} at line ${lineNumber}: ${error.message}`,
|
|
59
|
+
});
|
|
60
|
+
continue;
|
|
60
61
|
}
|
|
61
62
|
// Syntactically complete line: must be a session object. Silent omission
|
|
62
63
|
// would under-count ledger evidence (failure honesty).
|
|
63
64
|
if (!isRecord(row)) {
|
|
64
65
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
65
|
-
|
|
66
|
+
out.push({
|
|
67
|
+
line: lineNumber,
|
|
68
|
+
raw,
|
|
69
|
+
error: `complete non-object JSONL record in ${path} at line ${lineNumber}: expected object, got ${kind}`,
|
|
70
|
+
});
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
out.push({ line: lineNumber, raw, row });
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Read session JSONL with honest live-tail semantics:
|
|
79
|
+
* a malformed line is tolerated only when it is an unfinished final
|
|
80
|
+
* fragment at EOF (no record terminator after it). Any malformed line
|
|
81
|
+
* completed by a line terminator must fail loudly with file and 1-based
|
|
82
|
+
* line context — even when no non-empty record follows — never silently
|
|
83
|
+
* under-count.
|
|
84
|
+
*
|
|
85
|
+
* Loud failures throw LedgerSessionJsonlError carrying prefixRows so the
|
|
86
|
+
* single parse kernel can still expose facts obtained before the bad line.
|
|
87
|
+
*/
|
|
88
|
+
export async function readLedgerSessionJsonl(path) {
|
|
89
|
+
const rows = [];
|
|
90
|
+
for (const line of await readLedgerSessionJsonlLines(path)) {
|
|
91
|
+
if (line.row === undefined) {
|
|
92
|
+
throw new LedgerSessionJsonlError(line.error ?? `unreadable JSONL record in ${path} at line ${line.line}`, {
|
|
93
|
+
path,
|
|
94
|
+
line: line.line,
|
|
95
|
+
prefixRows: rows,
|
|
96
|
+
});
|
|
66
97
|
}
|
|
67
|
-
rows.push(row);
|
|
98
|
+
rows.push(line.row);
|
|
68
99
|
}
|
|
69
100
|
return rows;
|
|
70
101
|
}
|