@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
|
@@ -2366,21 +2366,6 @@ function projectTicketProvenanceSessions(value) {
|
|
|
2366
2366
|
}
|
|
2367
2367
|
return sessions;
|
|
2368
2368
|
}
|
|
2369
|
-
function projectTicketProvenanceAmendments(value) {
|
|
2370
|
-
if (!Array.isArray(value)) return [];
|
|
2371
|
-
const out = [];
|
|
2372
|
-
for (const raw of value) {
|
|
2373
|
-
if (!isRecord(raw)) continue;
|
|
2374
|
-
const s = nonNegativeInteger(raw.s);
|
|
2375
|
-
const line2 = positiveInteger(raw.line);
|
|
2376
|
-
const speaker = projectSpeaker(raw.speaker);
|
|
2377
|
-
const text = raw.text;
|
|
2378
|
-
if (s === void 0 || line2 === void 0 || speaker === void 0) continue;
|
|
2379
|
-
if (typeof text !== "string") continue;
|
|
2380
|
-
out.push({ s, line: line2, speaker, text });
|
|
2381
|
-
}
|
|
2382
|
-
return out;
|
|
2383
|
-
}
|
|
2384
2369
|
function projectTicketProvenanceHeader(value) {
|
|
2385
2370
|
if (!isRecord(value)) return void 0;
|
|
2386
2371
|
const ticket = positiveInteger(value.ticket);
|
|
@@ -2405,12 +2390,14 @@ function projectTicketProvenanceLine(value) {
|
|
|
2405
2390
|
const s = nonNegativeInteger(value.s);
|
|
2406
2391
|
if (speaker === void 0 || s === void 0) return void 0;
|
|
2407
2392
|
if (typeof value.text !== "string") return void 0;
|
|
2408
|
-
const
|
|
2393
|
+
const sourcePosition = nonNegativeInteger(value.sourcePosition);
|
|
2394
|
+
const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== "" ? value.sourceIdentity : void 0;
|
|
2409
2395
|
const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
|
|
2410
2396
|
return {
|
|
2411
2397
|
speaker,
|
|
2412
2398
|
s,
|
|
2413
|
-
...
|
|
2399
|
+
...sourcePosition === void 0 ? {} : { sourcePosition },
|
|
2400
|
+
...sourceIdentity === void 0 ? {} : { sourceIdentity },
|
|
2414
2401
|
...id === void 0 ? {} : { id },
|
|
2415
2402
|
text: value.text
|
|
2416
2403
|
};
|
|
@@ -2502,11 +2489,6 @@ function projectDiaristSessions(value) {
|
|
|
2502
2489
|
if (raw === void 0) return [];
|
|
2503
2490
|
return projectTicketProvenanceSessions(raw);
|
|
2504
2491
|
}
|
|
2505
|
-
function projectDiaristAmendments(value) {
|
|
2506
|
-
const raw = value?.amendments;
|
|
2507
|
-
if (raw === void 0) return [];
|
|
2508
|
-
return projectTicketProvenanceAmendments(raw);
|
|
2509
|
-
}
|
|
2510
2492
|
var DIARIST_OUTPUT_TOOL_NAME, DIARIST_ACCEPTED_TEXT;
|
|
2511
2493
|
var init_diarist_contracts = __esm({
|
|
2512
2494
|
"src/diarist-contracts.ts"() {
|
|
@@ -16951,6 +16933,20 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
|
16951
16933
|
);
|
|
16952
16934
|
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
16953
16935
|
}
|
|
16936
|
+
function projectTicketProvenanceRaw(value) {
|
|
16937
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
16938
|
+
const raw = value;
|
|
16939
|
+
if (typeof raw.raw !== "string" || !Number.isInteger(raw.s) || raw.s < 0 || !Number.isInteger(raw.sourcePosition) || raw.sourcePosition < 0) {
|
|
16940
|
+
return void 0;
|
|
16941
|
+
}
|
|
16942
|
+
const sourceIdentity = typeof raw.sourceIdentity === "string" && raw.sourceIdentity !== "" ? raw.sourceIdentity : void 0;
|
|
16943
|
+
return {
|
|
16944
|
+
raw: raw.raw,
|
|
16945
|
+
s: raw.s,
|
|
16946
|
+
sourcePosition: raw.sourcePosition,
|
|
16947
|
+
...sourceIdentity === void 0 ? {} : { sourceIdentity }
|
|
16948
|
+
};
|
|
16949
|
+
}
|
|
16954
16950
|
function projectTicketProvenanceCommit(value) {
|
|
16955
16951
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
16956
16952
|
const record4 = value;
|
|
@@ -16965,9 +16961,18 @@ function projectTicketProvenanceCommit(value) {
|
|
|
16965
16961
|
if (sessions === void 0 || !Array.isArray(body.lines)) return void 0;
|
|
16966
16962
|
const lines = [];
|
|
16967
16963
|
for (const raw of body.lines) {
|
|
16964
|
+
if (typeof raw === "string") {
|
|
16965
|
+
lines.push(raw);
|
|
16966
|
+
continue;
|
|
16967
|
+
}
|
|
16968
16968
|
const line2 = projectTicketProvenanceLine(raw);
|
|
16969
|
-
if (line2
|
|
16970
|
-
|
|
16969
|
+
if (line2 !== void 0) {
|
|
16970
|
+
lines.push(line2);
|
|
16971
|
+
continue;
|
|
16972
|
+
}
|
|
16973
|
+
const preserved = projectTicketProvenanceRaw(raw);
|
|
16974
|
+
if (preserved === void 0) return void 0;
|
|
16975
|
+
lines.push(preserved);
|
|
16971
16976
|
}
|
|
16972
16977
|
return { timestamp: record4.timestamp, sessions, lines };
|
|
16973
16978
|
}
|
|
@@ -16978,7 +16983,14 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
16978
16983
|
text = await readFile17(recordFile, "utf8");
|
|
16979
16984
|
} catch (error) {
|
|
16980
16985
|
if (error.code === "ENOENT") {
|
|
16981
|
-
return {
|
|
16986
|
+
return {
|
|
16987
|
+
header: void 0,
|
|
16988
|
+
lines: [],
|
|
16989
|
+
unprojectedRaw: [],
|
|
16990
|
+
recordFile,
|
|
16991
|
+
sourceIdentities: /* @__PURE__ */ new Map(),
|
|
16992
|
+
legacySourcePositions: /* @__PURE__ */ new Map()
|
|
16993
|
+
};
|
|
16982
16994
|
}
|
|
16983
16995
|
throw error;
|
|
16984
16996
|
}
|
|
@@ -16986,6 +16998,31 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
16986
16998
|
let header;
|
|
16987
16999
|
const lines = [];
|
|
16988
17000
|
const unprojectedRaw = [];
|
|
17001
|
+
const sourceIdentities = /* @__PURE__ */ new Map();
|
|
17002
|
+
const legacySourcePositions = /* @__PURE__ */ new Map();
|
|
17003
|
+
const rememberIdentity = (s, identity) => {
|
|
17004
|
+
const seen = sourceIdentities.get(s) ?? /* @__PURE__ */ new Set();
|
|
17005
|
+
const fresh = !seen.has(identity);
|
|
17006
|
+
seen.add(identity);
|
|
17007
|
+
sourceIdentities.set(s, seen);
|
|
17008
|
+
return fresh;
|
|
17009
|
+
};
|
|
17010
|
+
const rememberLegacyPosition = (s, position) => {
|
|
17011
|
+
const seen = legacySourcePositions.get(s) ?? /* @__PURE__ */ new Set();
|
|
17012
|
+
seen.add(position);
|
|
17013
|
+
legacySourcePositions.set(s, seen);
|
|
17014
|
+
};
|
|
17015
|
+
const remapCoverage = (coverage, priorIndexes) => {
|
|
17016
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
17017
|
+
for (const [s, values] of coverage) {
|
|
17018
|
+
const target = priorIndexes[s] ?? s;
|
|
17019
|
+
const union = normalized.get(target) ?? /* @__PURE__ */ new Set();
|
|
17020
|
+
for (const value of values) union.add(value);
|
|
17021
|
+
normalized.set(target, union);
|
|
17022
|
+
}
|
|
17023
|
+
coverage.clear();
|
|
17024
|
+
for (const [s, values] of normalized) coverage.set(s, values);
|
|
17025
|
+
};
|
|
16989
17026
|
let sawFirst = false;
|
|
16990
17027
|
for (let index = 0; index < physical.length; index += 1) {
|
|
16991
17028
|
const raw = physical[index];
|
|
@@ -17010,10 +17047,30 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
17010
17047
|
const commit = projectTicketProvenanceCommit(parsed);
|
|
17011
17048
|
if (commit !== void 0) {
|
|
17012
17049
|
const merged = mergeSessionBounds(header?.sessions, commit.sessions);
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
|
|
17050
|
+
remapCoverage(sourceIdentities, merged.priorIndexes);
|
|
17051
|
+
remapCoverage(legacySourcePositions, merged.priorIndexes);
|
|
17052
|
+
const remapped = [];
|
|
17053
|
+
for (const entry of commit.lines) {
|
|
17054
|
+
if (typeof entry === "string") {
|
|
17055
|
+
unprojectedRaw.push(entry);
|
|
17056
|
+
continue;
|
|
17057
|
+
}
|
|
17058
|
+
const s = merged.incomingIndexes[entry.s] ?? merged.priorIndexes[entry.s] ?? entry.s;
|
|
17059
|
+
if ("raw" in entry) {
|
|
17060
|
+
if (entry.sourceIdentity !== void 0) {
|
|
17061
|
+
if (rememberIdentity(s, entry.sourceIdentity)) unprojectedRaw.push(entry.raw);
|
|
17062
|
+
} else {
|
|
17063
|
+
rememberLegacyPosition(s, entry.sourcePosition);
|
|
17064
|
+
unprojectedRaw.push(entry.raw);
|
|
17065
|
+
}
|
|
17066
|
+
continue;
|
|
17067
|
+
}
|
|
17068
|
+
remapped.push({ ...entry, s });
|
|
17069
|
+
if (entry.id === void 0) {
|
|
17070
|
+
if (entry.sourceIdentity !== void 0) rememberIdentity(s, entry.sourceIdentity);
|
|
17071
|
+
else if (entry.sourcePosition !== void 0) rememberLegacyPosition(s, entry.sourcePosition);
|
|
17072
|
+
}
|
|
17073
|
+
}
|
|
17017
17074
|
const now = commit.timestamp;
|
|
17018
17075
|
header = {
|
|
17019
17076
|
repo: header?.repo ?? resolveBookKeyFromGit(cwd),
|
|
@@ -17031,7 +17088,19 @@ async function readTicketProvenance(ticketNumber, cwd, home) {
|
|
|
17031
17088
|
}
|
|
17032
17089
|
unprojectedRaw.push(raw);
|
|
17033
17090
|
}
|
|
17034
|
-
|
|
17091
|
+
for (const line2 of lines) {
|
|
17092
|
+
if (line2.id !== void 0) continue;
|
|
17093
|
+
if (line2.sourceIdentity !== void 0) rememberIdentity(line2.s, line2.sourceIdentity);
|
|
17094
|
+
else if (line2.sourcePosition !== void 0) rememberLegacyPosition(line2.s, line2.sourcePosition);
|
|
17095
|
+
}
|
|
17096
|
+
return {
|
|
17097
|
+
header,
|
|
17098
|
+
lines,
|
|
17099
|
+
unprojectedRaw,
|
|
17100
|
+
recordFile,
|
|
17101
|
+
sourceIdentities,
|
|
17102
|
+
legacySourcePositions
|
|
17103
|
+
};
|
|
17035
17104
|
}
|
|
17036
17105
|
function resolveBoundIndex(bound, sessionLines) {
|
|
17037
17106
|
if (typeof bound.id === "string" && bound.id !== "") {
|
|
@@ -17050,8 +17119,8 @@ function resolveBoundIndex(bound, sessionLines) {
|
|
|
17050
17119
|
}
|
|
17051
17120
|
return void 0;
|
|
17052
17121
|
}
|
|
17053
|
-
function
|
|
17054
|
-
return `${s}
|
|
17122
|
+
function dialogueIdentity(s, id) {
|
|
17123
|
+
return `${s}\0${id}`;
|
|
17055
17124
|
}
|
|
17056
17125
|
function rangeDeclarationKey(range) {
|
|
17057
17126
|
return JSON.stringify({
|
|
@@ -17102,7 +17171,8 @@ function undeclaredSessionRanges(prior, merged) {
|
|
|
17102
17171
|
const out = [];
|
|
17103
17172
|
for (let s = 0; s < merged.length; s += 1) {
|
|
17104
17173
|
const session = merged[s];
|
|
17105
|
-
const
|
|
17174
|
+
const identity = physicalPathIdentity(session.path);
|
|
17175
|
+
const declared = priorKeys.get(identity) ?? /* @__PURE__ */ new Set();
|
|
17106
17176
|
const fresh = session.ranges.filter(
|
|
17107
17177
|
(range) => !declared.has(rangeDeclarationKey(range))
|
|
17108
17178
|
);
|
|
@@ -17120,36 +17190,61 @@ function undeclaredSessionRanges(prior, merged) {
|
|
|
17120
17190
|
}
|
|
17121
17191
|
return out;
|
|
17122
17192
|
}
|
|
17123
|
-
function compareLinePosition(left, right) {
|
|
17124
|
-
if (left.s !== right.s) return left.s - right.s;
|
|
17125
|
-
const leftLine = left.line ?? Number.MAX_SAFE_INTEGER;
|
|
17126
|
-
const rightLine = right.line ?? Number.MAX_SAFE_INTEGER;
|
|
17127
|
-
return leftLine - rightLine;
|
|
17128
|
-
}
|
|
17129
17193
|
function mergeFreshIntoCarried(carried, fresh) {
|
|
17130
|
-
const
|
|
17131
|
-
const
|
|
17132
|
-
const
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17194
|
+
const seenSources = /* @__PURE__ */ new Map();
|
|
17195
|
+
const bySession = /* @__PURE__ */ new Map();
|
|
17196
|
+
const absorb = (lines) => {
|
|
17197
|
+
for (const line2 of lines) {
|
|
17198
|
+
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
17199
|
+
const identity = sourceIdentity === void 0 ? void 0 : `${line2.s}\0${sourceIdentity}`;
|
|
17200
|
+
const seen = identity === void 0 ? void 0 : seenSources.get(identity);
|
|
17201
|
+
if (seen !== void 0) {
|
|
17202
|
+
if (line2.sourcePosition !== void 0) {
|
|
17203
|
+
Object.assign(seen, { sourcePosition: line2.sourcePosition });
|
|
17204
|
+
}
|
|
17205
|
+
continue;
|
|
17206
|
+
}
|
|
17207
|
+
const bucket = bySession.get(line2.s) ?? [];
|
|
17208
|
+
bucket.push({ ...line2 });
|
|
17209
|
+
if (identity !== void 0) seenSources.set(identity, bucket.at(-1));
|
|
17210
|
+
bySession.set(line2.s, bucket);
|
|
17211
|
+
}
|
|
17212
|
+
};
|
|
17213
|
+
absorb(carried);
|
|
17214
|
+
absorb(fresh);
|
|
17215
|
+
return [...bySession.entries()].sort(([left], [right]) => left - right).flatMap(([, lines]) => lines.map((line2, archiveIndex) => ({ line: line2, archiveIndex })).sort((left, right) => {
|
|
17216
|
+
const leftPosition = left.line.sourcePosition;
|
|
17217
|
+
const rightPosition = right.line.sourcePosition;
|
|
17218
|
+
if (leftPosition === void 0 && rightPosition === void 0) {
|
|
17219
|
+
return left.archiveIndex - right.archiveIndex;
|
|
17220
|
+
}
|
|
17221
|
+
if (leftPosition === void 0) return 1;
|
|
17222
|
+
if (rightPosition === void 0) return -1;
|
|
17223
|
+
return leftPosition - rightPosition || left.archiveIndex - right.archiveIndex;
|
|
17224
|
+
}).map(({ line: line2 }) => line2));
|
|
17225
|
+
}
|
|
17226
|
+
function stableSourceFacts(sessionLines) {
|
|
17227
|
+
const positionByIdentity = /* @__PURE__ */ new Map();
|
|
17228
|
+
const facts = [];
|
|
17229
|
+
let precedingId = "<start>";
|
|
17230
|
+
let idlessOffset = 0;
|
|
17231
|
+
for (const entry of sessionLines) {
|
|
17232
|
+
const id = entry.row === void 0 ? void 0 : nativeEventId(entry.row);
|
|
17233
|
+
if (id !== void 0) {
|
|
17234
|
+
precedingId = id;
|
|
17235
|
+
idlessOffset = 0;
|
|
17236
|
+
} else {
|
|
17237
|
+
idlessOffset += 1;
|
|
17143
17238
|
}
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
|
|
17239
|
+
const identity = id === void 0 ? `after\0${precedingId}\0${idlessOffset}` : `id\0${id}`;
|
|
17240
|
+
let position = positionByIdentity.get(identity);
|
|
17241
|
+
if (position === void 0) {
|
|
17242
|
+
position = positionByIdentity.size;
|
|
17243
|
+
positionByIdentity.set(identity, position);
|
|
17148
17244
|
}
|
|
17149
|
-
|
|
17245
|
+
facts.push({ position, identity });
|
|
17150
17246
|
}
|
|
17151
|
-
|
|
17152
|
-
return out;
|
|
17247
|
+
return facts;
|
|
17153
17248
|
}
|
|
17154
17249
|
function normalizeResolvedRanges(ranges, sessionLines, sessionPath) {
|
|
17155
17250
|
const resolved = [];
|
|
@@ -17201,9 +17296,14 @@ async function projectSessionRanges(input) {
|
|
|
17201
17296
|
}
|
|
17202
17297
|
const rows = sessionLines.map((entry) => entry.row);
|
|
17203
17298
|
const dialogue = adaptSessionDialogue(rows);
|
|
17299
|
+
const sourceFacts = stableSourceFacts(sessionLines);
|
|
17300
|
+
const sourcePositionByIdentity = /* @__PURE__ */ new Map();
|
|
17301
|
+
for (const fact of sourceFacts) {
|
|
17302
|
+
sourcePositionByIdentity.set(fact.identity, fact.position);
|
|
17303
|
+
}
|
|
17204
17304
|
const seenIds = input.seenIds;
|
|
17205
17305
|
const lines = [];
|
|
17206
|
-
const
|
|
17306
|
+
const raw = [];
|
|
17207
17307
|
const ranges = normalizeResolvedRanges(
|
|
17208
17308
|
input.session.ranges,
|
|
17209
17309
|
sessionLines,
|
|
@@ -17211,38 +17311,30 @@ async function projectSessionRanges(input) {
|
|
|
17211
17311
|
);
|
|
17212
17312
|
for (const range of ranges) {
|
|
17213
17313
|
for (let index = range.fromIndex; index <= range.toIndex; index += 1) {
|
|
17314
|
+
const { position: sourcePosition, identity: sourceIdentity } = sourceFacts[index];
|
|
17315
|
+
if (input.coveredSourceIdentities.has(sourceIdentity) || input.legacyCoveredSourcePositions.has(sourcePosition)) continue;
|
|
17214
17316
|
const entry = sessionLines[index];
|
|
17215
17317
|
if (entry.row === void 0) {
|
|
17216
|
-
|
|
17217
|
-
const amendment = input.amendmentsByKey.get(key);
|
|
17218
|
-
if (amendment !== void 0) {
|
|
17219
|
-
lines.push({
|
|
17220
|
-
speaker: amendment.speaker,
|
|
17221
|
-
s: input.s,
|
|
17222
|
-
line: entry.line,
|
|
17223
|
-
text: amendment.text
|
|
17224
|
-
});
|
|
17225
|
-
} else {
|
|
17226
|
-
unparsable.push({ s: input.s, line: entry.line, raw: entry.raw });
|
|
17227
|
-
}
|
|
17318
|
+
raw.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
|
|
17228
17319
|
continue;
|
|
17229
17320
|
}
|
|
17230
17321
|
for (const event of dialogue[index] ?? []) {
|
|
17231
17322
|
if (event.id !== void 0) {
|
|
17232
|
-
|
|
17233
|
-
seenIds.
|
|
17323
|
+
const identity = dialogueIdentity(input.s, event.id);
|
|
17324
|
+
if (seenIds.has(identity)) continue;
|
|
17325
|
+
seenIds.add(identity);
|
|
17234
17326
|
}
|
|
17235
17327
|
lines.push({
|
|
17236
17328
|
speaker: event.speaker,
|
|
17237
17329
|
s: input.s,
|
|
17238
|
-
|
|
17239
|
-
...event.id === void 0 ? {} : { id: event.id },
|
|
17330
|
+
sourcePosition,
|
|
17331
|
+
...event.id === void 0 ? { sourceIdentity } : { id: event.id },
|
|
17240
17332
|
text: event.text
|
|
17241
17333
|
});
|
|
17242
17334
|
}
|
|
17243
17335
|
}
|
|
17244
17336
|
}
|
|
17245
|
-
return { lines,
|
|
17337
|
+
return { lines, raw, sourcePositionByIdentity };
|
|
17246
17338
|
}
|
|
17247
17339
|
async function reprojectTicketProvenance(input) {
|
|
17248
17340
|
const prior = await readTicketProvenance(input.ticketNumber, input.cwd, input.home);
|
|
@@ -17257,8 +17349,7 @@ async function reprojectTicketProvenance(input) {
|
|
|
17257
17349
|
updatedAt: now2,
|
|
17258
17350
|
sessions: []
|
|
17259
17351
|
},
|
|
17260
|
-
lines: prior.lines
|
|
17261
|
-
unparsable: []
|
|
17352
|
+
lines: prior.lines
|
|
17262
17353
|
};
|
|
17263
17354
|
}
|
|
17264
17355
|
const merged = mergeSessionBounds(prior.header?.sessions, input.sessions);
|
|
@@ -17274,34 +17365,34 @@ async function reprojectTicketProvenance(input) {
|
|
|
17274
17365
|
updatedAt: now2,
|
|
17275
17366
|
sessions: merged.sessions
|
|
17276
17367
|
},
|
|
17277
|
-
lines: prior.lines
|
|
17278
|
-
unparsable: []
|
|
17368
|
+
lines: prior.lines
|
|
17279
17369
|
};
|
|
17280
17370
|
}
|
|
17281
|
-
const amendmentsByKey = /* @__PURE__ */ new Map();
|
|
17282
|
-
for (const amendment of input.amendments ?? []) {
|
|
17283
|
-
const cumulativeIndex = merged.incomingIndexes[amendment.s];
|
|
17284
|
-
if (cumulativeIndex === void 0) continue;
|
|
17285
|
-
amendmentsByKey.set(amendmentKey(cumulativeIndex, amendment.line), {
|
|
17286
|
-
...amendment,
|
|
17287
|
-
s: cumulativeIndex
|
|
17288
|
-
});
|
|
17289
|
-
}
|
|
17290
17371
|
const seenIds = new Set(
|
|
17291
|
-
prior.lines.flatMap(
|
|
17372
|
+
prior.lines.flatMap(
|
|
17373
|
+
(line2) => line2.id === void 0 ? [] : [dialogueIdentity(line2.s, line2.id)]
|
|
17374
|
+
)
|
|
17292
17375
|
);
|
|
17293
17376
|
const fresh = [];
|
|
17294
|
-
const
|
|
17377
|
+
const raw = [];
|
|
17295
17378
|
for (const delta of deltas) {
|
|
17296
17379
|
const projected = await projectSessionRanges({
|
|
17297
17380
|
s: delta.s,
|
|
17298
17381
|
session: delta.session,
|
|
17299
|
-
amendmentsByKey,
|
|
17300
17382
|
seenIds,
|
|
17383
|
+
coveredSourceIdentities: prior.sourceIdentities.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
17384
|
+
legacyCoveredSourcePositions: prior.legacySourcePositions.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
17301
17385
|
...input.home === void 0 ? {} : { home: input.home }
|
|
17302
17386
|
});
|
|
17387
|
+
fresh.push(...prior.lines.flatMap((line2) => {
|
|
17388
|
+
if (line2.s !== delta.s) return [];
|
|
17389
|
+
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
17390
|
+
if (sourceIdentity === void 0) return [];
|
|
17391
|
+
const sourcePosition = projected.sourcePositionByIdentity.get(sourceIdentity);
|
|
17392
|
+
return sourcePosition === void 0 ? [] : [{ ...line2, sourcePosition }];
|
|
17393
|
+
}));
|
|
17303
17394
|
fresh.push(...projected.lines);
|
|
17304
|
-
|
|
17395
|
+
raw.push(...projected.raw);
|
|
17305
17396
|
}
|
|
17306
17397
|
const lines = mergeFreshIntoCarried(prior.lines, fresh);
|
|
17307
17398
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -17312,9 +17403,6 @@ async function reprojectTicketProvenance(input) {
|
|
|
17312
17403
|
updatedAt: now,
|
|
17313
17404
|
sessions: merged.sessions
|
|
17314
17405
|
};
|
|
17315
|
-
if (unparsable.length > 0) {
|
|
17316
|
-
return { recordFile: prior.recordFile, header, lines, unparsable };
|
|
17317
|
-
}
|
|
17318
17406
|
const identityMaterial = JSON.stringify({
|
|
17319
17407
|
ticket: input.ticketNumber,
|
|
17320
17408
|
deltas: deltas.map(({ s, session }) => ({
|
|
@@ -17322,7 +17410,7 @@ async function reprojectTicketProvenance(input) {
|
|
|
17322
17410
|
path: physicalPathIdentity(session.path),
|
|
17323
17411
|
ranges: session.ranges
|
|
17324
17412
|
})),
|
|
17325
|
-
lines: fresh
|
|
17413
|
+
lines: [...fresh, ...raw]
|
|
17326
17414
|
});
|
|
17327
17415
|
const identity = `ticket-provenance:${createHash8("sha256").update(identityMaterial).digest("hex")}`;
|
|
17328
17416
|
const pointer = appendSitianRecord({
|
|
@@ -17331,15 +17419,14 @@ async function reprojectTicketProvenance(input) {
|
|
|
17331
17419
|
payload: {
|
|
17332
17420
|
type: "ticket-provenance-append",
|
|
17333
17421
|
sessions: merged.sessions,
|
|
17334
|
-
lines: fresh
|
|
17422
|
+
lines: [...fresh, ...raw]
|
|
17335
17423
|
}
|
|
17336
17424
|
});
|
|
17337
17425
|
const folded = await readTicketProvenance(input.ticketNumber, input.cwd, input.home);
|
|
17338
17426
|
return {
|
|
17339
17427
|
recordFile: pointer.recordFile,
|
|
17340
17428
|
header: folded.header ?? header,
|
|
17341
|
-
lines: folded.lines
|
|
17342
|
-
unparsable: []
|
|
17429
|
+
lines: folded.lines
|
|
17343
17430
|
};
|
|
17344
17431
|
}
|
|
17345
17432
|
var TicketProvenanceInputError;
|
|
@@ -22417,33 +22504,6 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
|
22417
22504
|
description: "\u672C\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF1B\u7A7A\u5217\u8868\uFF1D\u672C\u8F6E\u65E0\u5BF9\u8BDD\u53EF\u5212\u3002\u7AEF\u70B9\u65E0\u6CD5\u6307\u540D\u65F6\u8D70 reask\uFF0C\u4E0D\u4E2D\u6B62\u3002"
|
|
22418
22505
|
}
|
|
22419
22506
|
)
|
|
22420
|
-
),
|
|
22421
|
-
amendments: Type19.Optional(
|
|
22422
|
-
Type19.Array(
|
|
22423
|
-
Type19.Object(
|
|
22424
|
-
{
|
|
22425
|
-
s: Type19.Optional(
|
|
22426
|
-
Type19.Unknown({ description: "\u5377\u4E0B\u6807\uFF08sessions \u4F4D\u7F6E\uFF09" })
|
|
22427
|
-
),
|
|
22428
|
-
line: Type19.Optional(
|
|
22429
|
-
Type19.Unknown({ description: "\u6E90\u5377 1-based \u884C\u53F7" })
|
|
22430
|
-
),
|
|
22431
|
-
speaker: Type19.Optional(
|
|
22432
|
-
Type19.String({ description: "owner | runner" })
|
|
22433
|
-
),
|
|
22434
|
-
text: Type19.Optional(
|
|
22435
|
-
Type19.String({ description: "\u8865\u5199\u6B63\u6587\uFF08\u539F\u8BDD\uFF09" })
|
|
22436
|
-
)
|
|
22437
|
-
},
|
|
22438
|
-
{
|
|
22439
|
-
additionalProperties: true,
|
|
22440
|
-
description: "\u4E00\u6761\u574F\u884C\u8865\u5199\uFF1B\u7F3A\u5B57\u6BB5\u7684\u6210\u5458\u673A\u68B0\u8DF3\u8FC7"
|
|
22441
|
-
}
|
|
22442
|
-
),
|
|
22443
|
-
{
|
|
22444
|
-
description: "\u53EF\u9009\uFF1B\u673A\u68B0\u89E3\u6790\u4E0D\u4E86\u7684\u884C\u4EA4\u6B64\u8865\u5199\u3002\u7F3A\u672C\u5B57\u6BB5\uFF1D\u65E0\u8865\u5199\uFF0C\u4E0D\u62D2\u6536\u3002"
|
|
22445
|
-
}
|
|
22446
|
-
)
|
|
22447
22507
|
)
|
|
22448
22508
|
})
|
|
22449
22509
|
)
|
|
@@ -22451,8 +22511,8 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
|
22451
22511
|
var DIARIST_TOOL_SPEC = {
|
|
22452
22512
|
name: DIARIST_OUTPUT_TOOL_NAME,
|
|
22453
22513
|
label: "\u8D77\u5C45\u90CE\u8F93\u51FA",
|
|
22454
|
-
description: "\u8D77\u5C45\u90CE\u4EA4\u672C\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF08sessions\uFF09\
|
|
22455
|
-
promptSnippet: "\u8D77\u5C45\u90CE\u4EA4\u8FB9\u754C
|
|
22514
|
+
description: "\u8D77\u5C45\u90CE\u4EA4\u672C\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF08sessions\uFF09\uFF1B\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u5219 escalate\u3002",
|
|
22515
|
+
promptSnippet: "\u8D77\u5C45\u90CE\u4EA4\u8FB9\u754C",
|
|
22456
22516
|
parameters: diaristOutputSchema
|
|
22457
22517
|
};
|
|
22458
22518
|
|
|
@@ -22580,14 +22640,12 @@ async function commitDiaristProjection(input) {
|
|
|
22580
22640
|
ticketNumber: input.ticketNumber,
|
|
22581
22641
|
cwd: input.cwd,
|
|
22582
22642
|
...input.home === void 0 ? {} : { home: input.home },
|
|
22583
|
-
sessions: input.sessions
|
|
22584
|
-
...input.amendments === void 0 ? {} : { amendments: input.amendments }
|
|
22643
|
+
sessions: input.sessions
|
|
22585
22644
|
});
|
|
22586
22645
|
return {
|
|
22587
22646
|
ticketNumber: input.ticketNumber,
|
|
22588
22647
|
volumeRecordFile: result.recordFile,
|
|
22589
|
-
lineCount: result.lines.length
|
|
22590
|
-
unparsable: result.unparsable
|
|
22648
|
+
lineCount: result.lines.length
|
|
22591
22649
|
};
|
|
22592
22650
|
}
|
|
22593
22651
|
|
|
@@ -24894,17 +24952,6 @@ function readDiaristRunCoordinates(ctx) {
|
|
|
24894
24952
|
};
|
|
24895
24953
|
}
|
|
24896
24954
|
var DIARIST_BOUNDS_REASK = "\u8FB9\u754C\u65E0\u6CD5\u4F7F\u7528\u3002\u8BF7\u91CD\u4EA4 sessions\uFF1A\u6BCF\u5377 path + ranges\uFF0C\u6BCF\u7AEF\u4EE5\u539F\u751F id \u6216\u672C\u8F6E\u884C\u53F7\u4E8C\u9009\u4E00\u6307\u540D\u3002";
|
|
24897
|
-
function diaristUnparsableReask(rows) {
|
|
24898
|
-
const payload = rows.map((row) => ({
|
|
24899
|
-
s: row.s,
|
|
24900
|
-
line: row.line,
|
|
24901
|
-
raw: row.raw
|
|
24902
|
-
}));
|
|
24903
|
-
return [
|
|
24904
|
-
"\u4E0B\u5217\u6E90\u884C\u672A\u80FD\u5F55\u5165\uFF0C\u8BF7\u7ECF amendments \u8865\u5199\uFF08\u6BCF\u6761 s + line + speaker + text\uFF09\uFF1B\u5176\u4F59\u8FB9\u754C\u53EF\u4FDD\u6301\u4E0D\u53D8\u3002",
|
|
24905
|
-
JSON.stringify(payload)
|
|
24906
|
-
].join("\n");
|
|
24907
|
-
}
|
|
24908
24955
|
function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
24909
24956
|
return createFiledOfficerRuntime(
|
|
24910
24957
|
roleHost,
|
|
@@ -24926,15 +24973,13 @@ function createDiaristRoleRuntime(roleHost, dependencies) {
|
|
|
24926
24973
|
if (sessions === void 0) {
|
|
24927
24974
|
throw new ParentQueueReaskError(DIARIST_BOUNDS_REASK);
|
|
24928
24975
|
}
|
|
24929
|
-
const amendments = projectDiaristAmendments(parameters);
|
|
24930
24976
|
let facts;
|
|
24931
24977
|
try {
|
|
24932
24978
|
facts = await commitDiaristProjection({
|
|
24933
24979
|
ticketNumber,
|
|
24934
24980
|
cwd: coords.projectRoot,
|
|
24935
24981
|
home: coords.home,
|
|
24936
|
-
sessions
|
|
24937
|
-
amendments
|
|
24982
|
+
sessions
|
|
24938
24983
|
});
|
|
24939
24984
|
} catch (error) {
|
|
24940
24985
|
if (error instanceof ParentQueueReaskError) throw error;
|
|
@@ -24946,9 +24991,6 @@ ${error.message}`
|
|
|
24946
24991
|
}
|
|
24947
24992
|
throw error;
|
|
24948
24993
|
}
|
|
24949
|
-
if (facts.unparsable.length > 0) {
|
|
24950
|
-
throw new ParentQueueReaskError(diaristUnparsableReask(facts.unparsable));
|
|
24951
|
-
}
|
|
24952
24994
|
}
|
|
24953
24995
|
return parameters;
|
|
24954
24996
|
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Machine facts about the volume come from the mechanical reproject seam, never
|
|
5
5
|
* from model self-report (锚定宪法); this module owns the receipt shape only.
|
|
6
6
|
*
|
|
7
|
-
* #901: LLM submits bounds
|
|
7
|
+
* #901: LLM submits bounds; the mechanical layer projects source bytes.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { projectTicketProvenanceSessions, } from "./ticket-provenance-contracts.js";
|
|
10
10
|
import { isSafePositiveTicketNumber, requireSafePositiveTicketNumber, } from "./run-ticket-number.js";
|
|
11
11
|
export const DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
|
|
12
12
|
export const DIARIST_ACCEPTED_TEXT = "起居郎回执已接受";
|
|
@@ -131,12 +131,3 @@ export function projectDiaristSessions(value) {
|
|
|
131
131
|
return [];
|
|
132
132
|
return projectTicketProvenanceSessions(raw);
|
|
133
133
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Project optional amendments. Absent / non-array → empty (not a rejection).
|
|
136
|
-
*/
|
|
137
|
-
export function projectDiaristAmendments(value) {
|
|
138
|
-
const raw = value?.amendments;
|
|
139
|
-
if (raw === undefined)
|
|
140
|
-
return [];
|
|
141
|
-
return projectTicketProvenanceAmendments(raw);
|
|
142
|
-
}
|