@akagilnc/pi-workflow-roles 0.1.5212 → 0.1.5216
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 +30 -420
- package/dist/headless-host/production-host.js +30 -420
- package/dist/migrate-book-topology.js +0 -1
- package/dist/public-cli/main.js +0 -1
- package/dist/ticket-provenance-contracts.js +4 -42
- package/dist/ticket-provenance.js +27 -456
- package/package.json +1 -1
- package/src/diarist.ts +5 -5
- package/src/ticket-provenance-contracts.ts +10 -48
- package/src/ticket-provenance.ts +33 -499
|
@@ -2867,17 +2867,6 @@ function positiveInteger(value) {
|
|
|
2867
2867
|
}
|
|
2868
2868
|
return void 0;
|
|
2869
2869
|
}
|
|
2870
|
-
function nonNegativeInteger(value) {
|
|
2871
|
-
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) return value;
|
|
2872
|
-
if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
|
|
2873
|
-
const parsed = Number(value);
|
|
2874
|
-
if (Number.isSafeInteger(parsed)) return parsed;
|
|
2875
|
-
}
|
|
2876
|
-
return void 0;
|
|
2877
|
-
}
|
|
2878
|
-
function projectSpeaker(value) {
|
|
2879
|
-
return value === "owner" || value === "runner" ? value : void 0;
|
|
2880
|
-
}
|
|
2881
2870
|
function projectBound(value) {
|
|
2882
2871
|
if (!isRecord2(value)) return void 0;
|
|
2883
2872
|
const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
|
|
@@ -2906,42 +2895,6 @@ function projectTicketProvenanceSessions(value) {
|
|
|
2906
2895
|
}
|
|
2907
2896
|
return sessions;
|
|
2908
2897
|
}
|
|
2909
|
-
function projectTicketProvenanceHeader(value) {
|
|
2910
|
-
if (!isRecord2(value)) return void 0;
|
|
2911
|
-
const ticket = value.ticket === null ? null : positiveInteger(value.ticket);
|
|
2912
|
-
if (ticket === void 0) return void 0;
|
|
2913
|
-
if (typeof value.repo !== "string") return void 0;
|
|
2914
|
-
if (typeof value.createdAt !== "string" || typeof value.updatedAt !== "string") {
|
|
2915
|
-
return void 0;
|
|
2916
|
-
}
|
|
2917
|
-
const sessions = projectTicketProvenanceSessions(value.sessions);
|
|
2918
|
-
if (sessions === void 0) return void 0;
|
|
2919
|
-
return {
|
|
2920
|
-
repo: value.repo,
|
|
2921
|
-
ticket,
|
|
2922
|
-
createdAt: value.createdAt,
|
|
2923
|
-
updatedAt: value.updatedAt,
|
|
2924
|
-
sessions
|
|
2925
|
-
};
|
|
2926
|
-
}
|
|
2927
|
-
function projectTicketProvenanceLine(value) {
|
|
2928
|
-
if (!isRecord2(value)) return void 0;
|
|
2929
|
-
const speaker = projectSpeaker(value.speaker);
|
|
2930
|
-
const s = nonNegativeInteger(value.s);
|
|
2931
|
-
if (speaker === void 0 || s === void 0) return void 0;
|
|
2932
|
-
if (typeof value.text !== "string") return void 0;
|
|
2933
|
-
const sourcePosition = nonNegativeInteger(value.sourcePosition);
|
|
2934
|
-
const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== "" ? value.sourceIdentity : void 0;
|
|
2935
|
-
const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
|
|
2936
|
-
return {
|
|
2937
|
-
speaker,
|
|
2938
|
-
s,
|
|
2939
|
-
...sourcePosition === void 0 ? {} : { sourcePosition },
|
|
2940
|
-
...sourceIdentity === void 0 ? {} : { sourceIdentity },
|
|
2941
|
-
...id === void 0 ? {} : { id },
|
|
2942
|
-
text: value.text
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
2898
|
var TICKET_PROVENANCE_KIND;
|
|
2946
2899
|
var init_ticket_provenance_contracts = __esm({
|
|
2947
2900
|
"src/ticket-provenance-contracts.ts"() {
|
|
@@ -6827,7 +6780,6 @@ var init_session_dialogue = __esm({
|
|
|
6827
6780
|
});
|
|
6828
6781
|
|
|
6829
6782
|
// src/ticket-provenance.ts
|
|
6830
|
-
import { createHash as createHash6 } from "node:crypto";
|
|
6831
6783
|
import { readFile as readFile10, unlink as unlink2 } from "node:fs/promises";
|
|
6832
6784
|
import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
|
|
6833
6785
|
function dialogueSessionSourceRoots(home) {
|
|
@@ -6878,175 +6830,6 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
|
6878
6830
|
);
|
|
6879
6831
|
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
6880
6832
|
}
|
|
6881
|
-
function projectTicketProvenanceRaw(value) {
|
|
6882
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
6883
|
-
const raw = value;
|
|
6884
|
-
if (typeof raw.raw !== "string" || !Number.isInteger(raw.s) || raw.s < 0 || !Number.isInteger(raw.sourcePosition) || raw.sourcePosition < 0) {
|
|
6885
|
-
return void 0;
|
|
6886
|
-
}
|
|
6887
|
-
const sourceIdentity = typeof raw.sourceIdentity === "string" && raw.sourceIdentity !== "" ? raw.sourceIdentity : void 0;
|
|
6888
|
-
return {
|
|
6889
|
-
raw: raw.raw,
|
|
6890
|
-
s: raw.s,
|
|
6891
|
-
sourcePosition: raw.sourcePosition,
|
|
6892
|
-
...sourceIdentity === void 0 ? {} : { sourceIdentity }
|
|
6893
|
-
};
|
|
6894
|
-
}
|
|
6895
|
-
function projectTicketProvenanceCommit(value) {
|
|
6896
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
6897
|
-
const record4 = value;
|
|
6898
|
-
if (record4.kind !== TICKET_PROVENANCE_KIND || typeof record4.timestamp !== "string") {
|
|
6899
|
-
return void 0;
|
|
6900
|
-
}
|
|
6901
|
-
const payload = record4.payload;
|
|
6902
|
-
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return void 0;
|
|
6903
|
-
const body = payload;
|
|
6904
|
-
if (body.type !== "ticket-provenance-append") return void 0;
|
|
6905
|
-
const sessions = projectTicketProvenanceSessions(body.sessions);
|
|
6906
|
-
if (sessions === void 0 || !Array.isArray(body.lines)) return void 0;
|
|
6907
|
-
const lines = [];
|
|
6908
|
-
for (const raw of body.lines) {
|
|
6909
|
-
if (typeof raw === "string") {
|
|
6910
|
-
lines.push(raw);
|
|
6911
|
-
continue;
|
|
6912
|
-
}
|
|
6913
|
-
const line2 = projectTicketProvenanceLine(raw);
|
|
6914
|
-
if (line2 !== void 0) {
|
|
6915
|
-
lines.push(line2);
|
|
6916
|
-
continue;
|
|
6917
|
-
}
|
|
6918
|
-
const preserved = projectTicketProvenanceRaw(raw);
|
|
6919
|
-
if (preserved === void 0) return void 0;
|
|
6920
|
-
lines.push(preserved);
|
|
6921
|
-
}
|
|
6922
|
-
return { timestamp: record4.timestamp, sessions, lines };
|
|
6923
|
-
}
|
|
6924
|
-
async function readTicketProvenance(ticketNumber, cwd, home, runDirectory) {
|
|
6925
|
-
const { recordFile } = ticketNumber === null ? resolveSitianRecordPath(ticketProvenanceRecordInput(null, cwd, home, runDirectory)) : resolveTicketProvenanceVolume(ticketNumber, cwd, home);
|
|
6926
|
-
let text;
|
|
6927
|
-
try {
|
|
6928
|
-
text = await readFile10(recordFile, "utf8");
|
|
6929
|
-
} catch (error) {
|
|
6930
|
-
if (error.code === "ENOENT") {
|
|
6931
|
-
return {
|
|
6932
|
-
header: void 0,
|
|
6933
|
-
lines: [],
|
|
6934
|
-
unprojectedRaw: [],
|
|
6935
|
-
recordFile,
|
|
6936
|
-
sourceIdentities: /* @__PURE__ */ new Map(),
|
|
6937
|
-
legacySourcePositions: /* @__PURE__ */ new Map()
|
|
6938
|
-
};
|
|
6939
|
-
}
|
|
6940
|
-
throw error;
|
|
6941
|
-
}
|
|
6942
|
-
const physical = text.split("\n");
|
|
6943
|
-
let header;
|
|
6944
|
-
const lines = [];
|
|
6945
|
-
const unprojectedRaw = [];
|
|
6946
|
-
const sourceIdentities = /* @__PURE__ */ new Map();
|
|
6947
|
-
const legacySourcePositions = /* @__PURE__ */ new Map();
|
|
6948
|
-
const rememberIdentity = (s, identity) => {
|
|
6949
|
-
const seen = sourceIdentities.get(s) ?? /* @__PURE__ */ new Set();
|
|
6950
|
-
const fresh = !seen.has(identity);
|
|
6951
|
-
seen.add(identity);
|
|
6952
|
-
sourceIdentities.set(s, seen);
|
|
6953
|
-
return fresh;
|
|
6954
|
-
};
|
|
6955
|
-
const rememberLegacyPosition = (s, position) => {
|
|
6956
|
-
const seen = legacySourcePositions.get(s) ?? /* @__PURE__ */ new Set();
|
|
6957
|
-
seen.add(position);
|
|
6958
|
-
legacySourcePositions.set(s, seen);
|
|
6959
|
-
};
|
|
6960
|
-
const remapCoverage = (coverage, priorIndexes) => {
|
|
6961
|
-
const normalized = /* @__PURE__ */ new Map();
|
|
6962
|
-
for (const [s, values] of coverage) {
|
|
6963
|
-
const target = priorIndexes[s] ?? s;
|
|
6964
|
-
const union = normalized.get(target) ?? /* @__PURE__ */ new Set();
|
|
6965
|
-
for (const value of values) union.add(value);
|
|
6966
|
-
normalized.set(target, union);
|
|
6967
|
-
}
|
|
6968
|
-
coverage.clear();
|
|
6969
|
-
for (const [s, values] of normalized) coverage.set(s, values);
|
|
6970
|
-
};
|
|
6971
|
-
let sawFirst = false;
|
|
6972
|
-
for (let index = 0; index < physical.length; index += 1) {
|
|
6973
|
-
const raw = physical[index];
|
|
6974
|
-
if (!raw.trim()) continue;
|
|
6975
|
-
let parsed;
|
|
6976
|
-
try {
|
|
6977
|
-
parsed = JSON.parse(raw);
|
|
6978
|
-
} catch {
|
|
6979
|
-
unprojectedRaw.push(raw);
|
|
6980
|
-
continue;
|
|
6981
|
-
}
|
|
6982
|
-
if (!sawFirst) {
|
|
6983
|
-
sawFirst = true;
|
|
6984
|
-
header = projectTicketProvenanceHeader(parsed);
|
|
6985
|
-
if (header !== void 0) continue;
|
|
6986
|
-
}
|
|
6987
|
-
const line2 = projectTicketProvenanceLine(parsed);
|
|
6988
|
-
if (line2 !== void 0) {
|
|
6989
|
-
lines.push(line2);
|
|
6990
|
-
continue;
|
|
6991
|
-
}
|
|
6992
|
-
const commit = projectTicketProvenanceCommit(parsed);
|
|
6993
|
-
if (commit !== void 0) {
|
|
6994
|
-
const merged = mergeSessionBounds(header?.sessions, commit.sessions);
|
|
6995
|
-
remapCoverage(sourceIdentities, merged.priorIndexes);
|
|
6996
|
-
remapCoverage(legacySourcePositions, merged.priorIndexes);
|
|
6997
|
-
const remapped = [];
|
|
6998
|
-
for (const entry of commit.lines) {
|
|
6999
|
-
if (typeof entry === "string") {
|
|
7000
|
-
unprojectedRaw.push(entry);
|
|
7001
|
-
continue;
|
|
7002
|
-
}
|
|
7003
|
-
const s = merged.incomingIndexes[entry.s] ?? merged.priorIndexes[entry.s] ?? entry.s;
|
|
7004
|
-
if ("raw" in entry) {
|
|
7005
|
-
if (entry.sourceIdentity !== void 0) {
|
|
7006
|
-
if (rememberIdentity(s, entry.sourceIdentity)) unprojectedRaw.push(entry.raw);
|
|
7007
|
-
} else {
|
|
7008
|
-
rememberLegacyPosition(s, entry.sourcePosition);
|
|
7009
|
-
unprojectedRaw.push(entry.raw);
|
|
7010
|
-
}
|
|
7011
|
-
continue;
|
|
7012
|
-
}
|
|
7013
|
-
remapped.push({ ...entry, s });
|
|
7014
|
-
if (entry.id === void 0) {
|
|
7015
|
-
if (entry.sourceIdentity !== void 0) rememberIdentity(s, entry.sourceIdentity);
|
|
7016
|
-
else if (entry.sourcePosition !== void 0) rememberLegacyPosition(s, entry.sourcePosition);
|
|
7017
|
-
}
|
|
7018
|
-
}
|
|
7019
|
-
const now = commit.timestamp;
|
|
7020
|
-
header = {
|
|
7021
|
-
repo: header?.repo ?? resolveBookKeyFromGit(cwd),
|
|
7022
|
-
ticket: ticketNumber,
|
|
7023
|
-
createdAt: header?.createdAt ?? now,
|
|
7024
|
-
updatedAt: header?.updatedAt !== void 0 && header.updatedAt > now ? header.updatedAt : now,
|
|
7025
|
-
sessions: merged.sessions
|
|
7026
|
-
};
|
|
7027
|
-
const carried = lines.map((entry) => ({
|
|
7028
|
-
...entry,
|
|
7029
|
-
s: merged.priorIndexes[entry.s] ?? entry.s
|
|
7030
|
-
}));
|
|
7031
|
-
lines.splice(0, lines.length, ...mergeFreshIntoCarried(carried, remapped));
|
|
7032
|
-
continue;
|
|
7033
|
-
}
|
|
7034
|
-
unprojectedRaw.push(raw);
|
|
7035
|
-
}
|
|
7036
|
-
for (const line2 of lines) {
|
|
7037
|
-
if (line2.id !== void 0) continue;
|
|
7038
|
-
if (line2.sourceIdentity !== void 0) rememberIdentity(line2.s, line2.sourceIdentity);
|
|
7039
|
-
else if (line2.sourcePosition !== void 0) rememberLegacyPosition(line2.s, line2.sourcePosition);
|
|
7040
|
-
}
|
|
7041
|
-
return {
|
|
7042
|
-
header,
|
|
7043
|
-
lines,
|
|
7044
|
-
unprojectedRaw,
|
|
7045
|
-
recordFile,
|
|
7046
|
-
sourceIdentities,
|
|
7047
|
-
legacySourcePositions
|
|
7048
|
-
};
|
|
7049
|
-
}
|
|
7050
6833
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
7051
6834
|
const source = join13(runDirectory, "records.jsonl");
|
|
7052
6835
|
let content;
|
|
@@ -7076,110 +6859,6 @@ function resolveBoundIndex(bound, sessionLines) {
|
|
|
7076
6859
|
}
|
|
7077
6860
|
return void 0;
|
|
7078
6861
|
}
|
|
7079
|
-
function dialogueIdentity(s, id) {
|
|
7080
|
-
return `${s}\0${id}`;
|
|
7081
|
-
}
|
|
7082
|
-
function rangeDeclarationKey(range) {
|
|
7083
|
-
return JSON.stringify({
|
|
7084
|
-
from: range.from,
|
|
7085
|
-
to: range.to
|
|
7086
|
-
});
|
|
7087
|
-
}
|
|
7088
|
-
function mergeSessionBounds(prior, incoming) {
|
|
7089
|
-
const merged = [];
|
|
7090
|
-
const indexByIdentity = /* @__PURE__ */ new Map();
|
|
7091
|
-
const absorb = (sessions) => {
|
|
7092
|
-
const indexes = [];
|
|
7093
|
-
for (const session of sessions) {
|
|
7094
|
-
const identity = physicalPathIdentity(session.path);
|
|
7095
|
-
let targetIndex = indexByIdentity.get(identity);
|
|
7096
|
-
if (targetIndex === void 0) {
|
|
7097
|
-
targetIndex = merged.length;
|
|
7098
|
-
indexByIdentity.set(identity, targetIndex);
|
|
7099
|
-
merged.push({ path: session.path, ranges: [] });
|
|
7100
|
-
}
|
|
7101
|
-
indexes.push(targetIndex);
|
|
7102
|
-
const target = merged[targetIndex];
|
|
7103
|
-
const seen = new Set(target.ranges.map(rangeDeclarationKey));
|
|
7104
|
-
for (const range of session.ranges) {
|
|
7105
|
-
const key = rangeDeclarationKey(range);
|
|
7106
|
-
if (seen.has(key)) continue;
|
|
7107
|
-
seen.add(key);
|
|
7108
|
-
target.ranges.push({ from: { ...range.from }, to: { ...range.to } });
|
|
7109
|
-
}
|
|
7110
|
-
}
|
|
7111
|
-
return indexes;
|
|
7112
|
-
};
|
|
7113
|
-
const priorIndexes = absorb(prior ?? []);
|
|
7114
|
-
const incomingIndexes = absorb(incoming);
|
|
7115
|
-
return { sessions: merged, priorIndexes, incomingIndexes };
|
|
7116
|
-
}
|
|
7117
|
-
function undeclaredSessionRanges(prior, merged) {
|
|
7118
|
-
const priorKeys = /* @__PURE__ */ new Map();
|
|
7119
|
-
for (const session of prior ?? []) {
|
|
7120
|
-
const identity = physicalPathIdentity(session.path);
|
|
7121
|
-
let keys = priorKeys.get(identity);
|
|
7122
|
-
if (keys === void 0) {
|
|
7123
|
-
keys = /* @__PURE__ */ new Set();
|
|
7124
|
-
priorKeys.set(identity, keys);
|
|
7125
|
-
}
|
|
7126
|
-
for (const range of session.ranges) keys.add(rangeDeclarationKey(range));
|
|
7127
|
-
}
|
|
7128
|
-
const out = [];
|
|
7129
|
-
for (let s = 0; s < merged.length; s += 1) {
|
|
7130
|
-
const session = merged[s];
|
|
7131
|
-
const identity = physicalPathIdentity(session.path);
|
|
7132
|
-
const declared = priorKeys.get(identity) ?? /* @__PURE__ */ new Set();
|
|
7133
|
-
const fresh = session.ranges.filter(
|
|
7134
|
-
(range) => !declared.has(rangeDeclarationKey(range))
|
|
7135
|
-
);
|
|
7136
|
-
if (fresh.length === 0) continue;
|
|
7137
|
-
out.push({
|
|
7138
|
-
s,
|
|
7139
|
-
session: {
|
|
7140
|
-
path: session.path,
|
|
7141
|
-
ranges: fresh.map((range) => ({
|
|
7142
|
-
from: { ...range.from },
|
|
7143
|
-
to: { ...range.to }
|
|
7144
|
-
}))
|
|
7145
|
-
}
|
|
7146
|
-
});
|
|
7147
|
-
}
|
|
7148
|
-
return out;
|
|
7149
|
-
}
|
|
7150
|
-
function mergeFreshIntoCarried(carried, fresh) {
|
|
7151
|
-
const seenSources = /* @__PURE__ */ new Map();
|
|
7152
|
-
const bySession = /* @__PURE__ */ new Map();
|
|
7153
|
-
const absorb = (lines) => {
|
|
7154
|
-
for (const line2 of lines) {
|
|
7155
|
-
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
7156
|
-
const identity = sourceIdentity === void 0 ? void 0 : `${line2.s}\0${sourceIdentity}`;
|
|
7157
|
-
const seen = identity === void 0 ? void 0 : seenSources.get(identity);
|
|
7158
|
-
if (seen !== void 0) {
|
|
7159
|
-
if (line2.sourcePosition !== void 0) {
|
|
7160
|
-
Object.assign(seen, { sourcePosition: line2.sourcePosition });
|
|
7161
|
-
}
|
|
7162
|
-
continue;
|
|
7163
|
-
}
|
|
7164
|
-
const bucket = bySession.get(line2.s) ?? [];
|
|
7165
|
-
bucket.push({ ...line2 });
|
|
7166
|
-
if (identity !== void 0) seenSources.set(identity, bucket.at(-1));
|
|
7167
|
-
bySession.set(line2.s, bucket);
|
|
7168
|
-
}
|
|
7169
|
-
};
|
|
7170
|
-
absorb(carried);
|
|
7171
|
-
absorb(fresh);
|
|
7172
|
-
return [...bySession.entries()].sort(([left], [right]) => left - right).flatMap(([, lines]) => lines.map((line2, archiveIndex) => ({ line: line2, archiveIndex })).sort((left, right) => {
|
|
7173
|
-
const leftPosition = left.line.sourcePosition;
|
|
7174
|
-
const rightPosition = right.line.sourcePosition;
|
|
7175
|
-
if (leftPosition === void 0 && rightPosition === void 0) {
|
|
7176
|
-
return left.archiveIndex - right.archiveIndex;
|
|
7177
|
-
}
|
|
7178
|
-
if (leftPosition === void 0) return 1;
|
|
7179
|
-
if (rightPosition === void 0) return -1;
|
|
7180
|
-
return leftPosition - rightPosition || left.archiveIndex - right.archiveIndex;
|
|
7181
|
-
}).map(({ line: line2 }) => line2));
|
|
7182
|
-
}
|
|
7183
6862
|
function stableSourceFacts(sessionLines) {
|
|
7184
6863
|
const positionByIdentity = /* @__PURE__ */ new Map();
|
|
7185
6864
|
const facts = [];
|
|
@@ -7254,13 +6933,7 @@ async function projectSessionRanges(input) {
|
|
|
7254
6933
|
const rows = sessionLines.map((entry) => entry.row);
|
|
7255
6934
|
const dialogue = adaptSessionDialogue(rows);
|
|
7256
6935
|
const sourceFacts = stableSourceFacts(sessionLines);
|
|
7257
|
-
const
|
|
7258
|
-
for (const fact of sourceFacts) {
|
|
7259
|
-
sourcePositionByIdentity.set(fact.identity, fact.position);
|
|
7260
|
-
}
|
|
7261
|
-
const seenIds = input.seenIds;
|
|
7262
|
-
const lines = [];
|
|
7263
|
-
const raw = [];
|
|
6936
|
+
const entries = [];
|
|
7264
6937
|
const ranges = normalizeResolvedRanges(
|
|
7265
6938
|
input.session.ranges,
|
|
7266
6939
|
sessionLines,
|
|
@@ -7269,19 +6942,13 @@ async function projectSessionRanges(input) {
|
|
|
7269
6942
|
for (const range of ranges) {
|
|
7270
6943
|
for (let index = range.fromIndex; index <= range.toIndex; index += 1) {
|
|
7271
6944
|
const { position: sourcePosition, identity: sourceIdentity } = sourceFacts[index];
|
|
7272
|
-
if (input.coveredSourceIdentities.has(sourceIdentity) || input.legacyCoveredSourcePositions.has(sourcePosition)) continue;
|
|
7273
6945
|
const entry = sessionLines[index];
|
|
7274
6946
|
if (entry.row === void 0) {
|
|
7275
|
-
|
|
6947
|
+
entries.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
|
|
7276
6948
|
continue;
|
|
7277
6949
|
}
|
|
7278
6950
|
for (const event of dialogue[index] ?? []) {
|
|
7279
|
-
|
|
7280
|
-
const identity = dialogueIdentity(input.s, event.id);
|
|
7281
|
-
if (seenIds.has(identity)) continue;
|
|
7282
|
-
seenIds.add(identity);
|
|
7283
|
-
}
|
|
7284
|
-
lines.push({
|
|
6951
|
+
entries.push({
|
|
7285
6952
|
speaker: event.speaker,
|
|
7286
6953
|
s: input.s,
|
|
7287
6954
|
sourcePosition,
|
|
@@ -7291,106 +6958,49 @@ async function projectSessionRanges(input) {
|
|
|
7291
6958
|
}
|
|
7292
6959
|
}
|
|
7293
6960
|
}
|
|
7294
|
-
return {
|
|
6961
|
+
return { entries };
|
|
7295
6962
|
}
|
|
7296
6963
|
async function reprojectTicketProvenance(input) {
|
|
7297
|
-
const
|
|
6964
|
+
const recordInput = ticketProvenanceRecordInput(
|
|
6965
|
+
input.ticketNumber,
|
|
6966
|
+
input.cwd,
|
|
6967
|
+
input.home,
|
|
6968
|
+
input.runDirectory
|
|
6969
|
+
);
|
|
6970
|
+
const resolved = resolveSitianRecordPath(recordInput);
|
|
7298
6971
|
if (input.sessions.length === 0) {
|
|
7299
|
-
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
7300
6972
|
return {
|
|
7301
|
-
recordFile:
|
|
7302
|
-
|
|
7303
|
-
repo: resolveBookKeyFromGit(input.cwd),
|
|
7304
|
-
ticket: input.ticketNumber,
|
|
7305
|
-
createdAt: now2,
|
|
7306
|
-
updatedAt: now2,
|
|
7307
|
-
sessions: []
|
|
7308
|
-
},
|
|
7309
|
-
lines: prior.lines
|
|
7310
|
-
};
|
|
7311
|
-
}
|
|
7312
|
-
const merged = mergeSessionBounds(prior.header?.sessions, input.sessions);
|
|
7313
|
-
const deltas = undeclaredSessionRanges(prior.header?.sessions, merged.sessions);
|
|
7314
|
-
if (deltas.length === 0) {
|
|
7315
|
-
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
7316
|
-
return {
|
|
7317
|
-
recordFile: prior.recordFile,
|
|
7318
|
-
header: prior.header ?? {
|
|
7319
|
-
repo: resolveBookKeyFromGit(input.cwd),
|
|
7320
|
-
ticket: input.ticketNumber,
|
|
7321
|
-
createdAt: now2,
|
|
7322
|
-
updatedAt: now2,
|
|
7323
|
-
sessions: merged.sessions
|
|
7324
|
-
},
|
|
7325
|
-
lines: prior.lines
|
|
6973
|
+
recordFile: resolved.recordFile,
|
|
6974
|
+
lines: []
|
|
7326
6975
|
};
|
|
7327
6976
|
}
|
|
7328
|
-
const
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
)
|
|
7332
|
-
);
|
|
7333
|
-
const fresh = [];
|
|
7334
|
-
const raw = [];
|
|
7335
|
-
for (const delta of deltas) {
|
|
6977
|
+
const entries = [];
|
|
6978
|
+
for (let s = 0; s < input.sessions.length; s += 1) {
|
|
6979
|
+
const session = input.sessions[s];
|
|
7336
6980
|
const projected = await projectSessionRanges({
|
|
7337
|
-
s
|
|
7338
|
-
session
|
|
7339
|
-
seenIds,
|
|
7340
|
-
coveredSourceIdentities: prior.sourceIdentities.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
7341
|
-
legacyCoveredSourcePositions: prior.legacySourcePositions.get(delta.s) ?? /* @__PURE__ */ new Set(),
|
|
6981
|
+
s,
|
|
6982
|
+
session,
|
|
7342
6983
|
...input.home === void 0 ? {} : { home: input.home }
|
|
7343
6984
|
});
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
|
|
7347
|
-
if (sourceIdentity === void 0) return [];
|
|
7348
|
-
const sourcePosition = projected.sourcePositionByIdentity.get(sourceIdentity);
|
|
7349
|
-
return sourcePosition === void 0 ? [] : [{ ...line2, sourcePosition }];
|
|
7350
|
-
}));
|
|
7351
|
-
fresh.push(...projected.lines);
|
|
7352
|
-
raw.push(...projected.raw);
|
|
7353
|
-
}
|
|
7354
|
-
const lines = mergeFreshIntoCarried(prior.lines, fresh);
|
|
7355
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7356
|
-
const header = {
|
|
7357
|
-
repo: prior.header?.repo ?? resolveBookKeyFromGit(input.cwd),
|
|
7358
|
-
ticket: input.ticketNumber,
|
|
7359
|
-
createdAt: prior.header?.createdAt ?? now,
|
|
7360
|
-
updatedAt: now,
|
|
7361
|
-
sessions: merged.sessions
|
|
7362
|
-
};
|
|
7363
|
-
const identityMaterial = JSON.stringify({
|
|
7364
|
-
ticket: input.ticketNumber,
|
|
7365
|
-
deltas: deltas.map(({ s, session }) => ({
|
|
7366
|
-
s,
|
|
7367
|
-
path: physicalPathIdentity(session.path),
|
|
7368
|
-
ranges: session.ranges
|
|
7369
|
-
})),
|
|
7370
|
-
lines: [...fresh, ...raw]
|
|
7371
|
-
});
|
|
7372
|
-
const identity = `ticket-provenance:${createHash6("sha256").update(identityMaterial).digest("hex")}`;
|
|
6985
|
+
entries.push(...projected.entries);
|
|
6986
|
+
}
|
|
7373
6987
|
const pointer = appendSitianRecord({
|
|
7374
|
-
...
|
|
7375
|
-
identity,
|
|
6988
|
+
...recordInput,
|
|
7376
6989
|
payload: {
|
|
7377
6990
|
type: "ticket-provenance-append",
|
|
7378
|
-
sessions:
|
|
7379
|
-
lines:
|
|
6991
|
+
sessions: input.sessions,
|
|
6992
|
+
lines: entries
|
|
7380
6993
|
}
|
|
7381
6994
|
});
|
|
7382
|
-
const folded = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
|
|
7383
6995
|
return {
|
|
7384
6996
|
recordFile: pointer.recordFile,
|
|
7385
|
-
|
|
7386
|
-
lines: folded.lines
|
|
6997
|
+
lines: entries.filter((entry) => "speaker" in entry)
|
|
7387
6998
|
};
|
|
7388
6999
|
}
|
|
7389
7000
|
var TicketProvenanceInputError;
|
|
7390
7001
|
var init_ticket_provenance = __esm({
|
|
7391
7002
|
"src/ticket-provenance.ts"() {
|
|
7392
7003
|
"use strict";
|
|
7393
|
-
init_activation_ledger_git();
|
|
7394
7004
|
init_activation_ledger_topology();
|
|
7395
7005
|
init_ledger_session_read();
|
|
7396
7006
|
init_run_ticket_number();
|
|
@@ -19502,7 +19112,7 @@ var init_analyst_metric_family = __esm({
|
|
|
19502
19112
|
});
|
|
19503
19113
|
|
|
19504
19114
|
// src/analyst-page.ts
|
|
19505
|
-
import { createHash as
|
|
19115
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
19506
19116
|
import { dirname as dirname21, join as join35 } from "node:path";
|
|
19507
19117
|
function analystIssuePageKey(address) {
|
|
19508
19118
|
const parts = ["book", address.bookKey];
|
|
@@ -19511,7 +19121,7 @@ function analystIssuePageKey(address) {
|
|
|
19511
19121
|
} else if (address.scopeRootIdentity !== void 0) {
|
|
19512
19122
|
parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
|
|
19513
19123
|
}
|
|
19514
|
-
return
|
|
19124
|
+
return createHash6("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
19515
19125
|
}
|
|
19516
19126
|
function analystIssuePagePath(ledgerHome, address) {
|
|
19517
19127
|
return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
@@ -23348,7 +22958,7 @@ var init_submission_ledger = __esm({
|
|
|
23348
22958
|
});
|
|
23349
22959
|
|
|
23350
22960
|
// src/archivist-record-topology.ts
|
|
23351
|
-
import { createHash as
|
|
22961
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
23352
22962
|
import { join as join43 } from "node:path";
|
|
23353
22963
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
23354
22964
|
let ledgerHome;
|
|
@@ -23359,7 +22969,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
23359
22969
|
}
|
|
23360
22970
|
}
|
|
23361
22971
|
ledgerHome ??= resolveActivationLedgerHome(input.home);
|
|
23362
|
-
const digest =
|
|
22972
|
+
const digest = createHash7("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
23363
22973
|
return {
|
|
23364
22974
|
ledgerHome,
|
|
23365
22975
|
sessionDir: join43(
|
|
@@ -25213,7 +24823,7 @@ var AUDITOR_TOOL_SPEC = {
|
|
|
25213
24823
|
};
|
|
25214
24824
|
|
|
25215
24825
|
// src/navigator-attendance.ts
|
|
25216
|
-
import { createHash as
|
|
24826
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
25217
24827
|
init_navigator_invocation_identity();
|
|
25218
24828
|
init_packaged_role_registry();
|
|
25219
24829
|
init_activation_ledger_topology();
|
|
@@ -25774,7 +25384,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
25774
25384
|
if (provenance === "placeholder") return subjectRoot;
|
|
25775
25385
|
const normalized = subject.trim().replace(/\s+/g, " ");
|
|
25776
25386
|
if (normalized === "") return subjectRoot;
|
|
25777
|
-
return `${subjectRoot}#${
|
|
25387
|
+
return `${subjectRoot}#${createHash8("sha256").update(normalized).digest("hex").slice(0, 32)}`;
|
|
25778
25388
|
}
|
|
25779
25389
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
25780
25390
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|