@akagilnc/pi-workflow-roles 0.1.5207 → 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.
@@ -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"() {
@@ -4493,7 +4446,6 @@ function appendSitianRecord(input) {
4493
4446
  identity,
4494
4447
  ...input.subject === void 0 ? {} : { subject: input.subject },
4495
4448
  ...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
4496
- ...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
4497
4449
  timestamp: timestamp2,
4498
4450
  host,
4499
4451
  ...input.source === void 0 ? {} : { source: input.source },
@@ -6828,7 +6780,6 @@ var init_session_dialogue = __esm({
6828
6780
  });
6829
6781
 
6830
6782
  // src/ticket-provenance.ts
6831
- import { createHash as createHash6 } from "node:crypto";
6832
6783
  import { readFile as readFile10, unlink as unlink2 } from "node:fs/promises";
6833
6784
  import { basename as basename4, dirname as dirname8, join as join13, resolve as resolve7 } from "node:path";
6834
6785
  function dialogueSessionSourceRoots(home) {
@@ -6879,175 +6830,6 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
6879
6830
  );
6880
6831
  return { recordFile: path.recordFile, volumeDir: path.sessionDir };
6881
6832
  }
6882
- function projectTicketProvenanceRaw(value) {
6883
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
6884
- const raw = value;
6885
- if (typeof raw.raw !== "string" || !Number.isInteger(raw.s) || raw.s < 0 || !Number.isInteger(raw.sourcePosition) || raw.sourcePosition < 0) {
6886
- return void 0;
6887
- }
6888
- const sourceIdentity = typeof raw.sourceIdentity === "string" && raw.sourceIdentity !== "" ? raw.sourceIdentity : void 0;
6889
- return {
6890
- raw: raw.raw,
6891
- s: raw.s,
6892
- sourcePosition: raw.sourcePosition,
6893
- ...sourceIdentity === void 0 ? {} : { sourceIdentity }
6894
- };
6895
- }
6896
- function projectTicketProvenanceCommit(value) {
6897
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
6898
- const record4 = value;
6899
- if (record4.kind !== TICKET_PROVENANCE_KIND || typeof record4.timestamp !== "string") {
6900
- return void 0;
6901
- }
6902
- const payload = record4.payload;
6903
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return void 0;
6904
- const body = payload;
6905
- if (body.type !== "ticket-provenance-append") return void 0;
6906
- const sessions = projectTicketProvenanceSessions(body.sessions);
6907
- if (sessions === void 0 || !Array.isArray(body.lines)) return void 0;
6908
- const lines = [];
6909
- for (const raw of body.lines) {
6910
- if (typeof raw === "string") {
6911
- lines.push(raw);
6912
- continue;
6913
- }
6914
- const line2 = projectTicketProvenanceLine(raw);
6915
- if (line2 !== void 0) {
6916
- lines.push(line2);
6917
- continue;
6918
- }
6919
- const preserved = projectTicketProvenanceRaw(raw);
6920
- if (preserved === void 0) return void 0;
6921
- lines.push(preserved);
6922
- }
6923
- return { timestamp: record4.timestamp, sessions, lines };
6924
- }
6925
- async function readTicketProvenance(ticketNumber, cwd, home, runDirectory) {
6926
- const { recordFile } = ticketNumber === null ? resolveSitianRecordPath(ticketProvenanceRecordInput(null, cwd, home, runDirectory)) : resolveTicketProvenanceVolume(ticketNumber, cwd, home);
6927
- let text;
6928
- try {
6929
- text = await readFile10(recordFile, "utf8");
6930
- } catch (error) {
6931
- if (error.code === "ENOENT") {
6932
- return {
6933
- header: void 0,
6934
- lines: [],
6935
- unprojectedRaw: [],
6936
- recordFile,
6937
- sourceIdentities: /* @__PURE__ */ new Map(),
6938
- legacySourcePositions: /* @__PURE__ */ new Map()
6939
- };
6940
- }
6941
- throw error;
6942
- }
6943
- const physical = text.split("\n");
6944
- let header;
6945
- const lines = [];
6946
- const unprojectedRaw = [];
6947
- const sourceIdentities = /* @__PURE__ */ new Map();
6948
- const legacySourcePositions = /* @__PURE__ */ new Map();
6949
- const rememberIdentity = (s, identity) => {
6950
- const seen = sourceIdentities.get(s) ?? /* @__PURE__ */ new Set();
6951
- const fresh = !seen.has(identity);
6952
- seen.add(identity);
6953
- sourceIdentities.set(s, seen);
6954
- return fresh;
6955
- };
6956
- const rememberLegacyPosition = (s, position) => {
6957
- const seen = legacySourcePositions.get(s) ?? /* @__PURE__ */ new Set();
6958
- seen.add(position);
6959
- legacySourcePositions.set(s, seen);
6960
- };
6961
- const remapCoverage = (coverage, priorIndexes) => {
6962
- const normalized = /* @__PURE__ */ new Map();
6963
- for (const [s, values] of coverage) {
6964
- const target = priorIndexes[s] ?? s;
6965
- const union = normalized.get(target) ?? /* @__PURE__ */ new Set();
6966
- for (const value of values) union.add(value);
6967
- normalized.set(target, union);
6968
- }
6969
- coverage.clear();
6970
- for (const [s, values] of normalized) coverage.set(s, values);
6971
- };
6972
- let sawFirst = false;
6973
- for (let index = 0; index < physical.length; index += 1) {
6974
- const raw = physical[index];
6975
- if (!raw.trim()) continue;
6976
- let parsed;
6977
- try {
6978
- parsed = JSON.parse(raw);
6979
- } catch {
6980
- unprojectedRaw.push(raw);
6981
- continue;
6982
- }
6983
- if (!sawFirst) {
6984
- sawFirst = true;
6985
- header = projectTicketProvenanceHeader(parsed);
6986
- if (header !== void 0) continue;
6987
- }
6988
- const line2 = projectTicketProvenanceLine(parsed);
6989
- if (line2 !== void 0) {
6990
- lines.push(line2);
6991
- continue;
6992
- }
6993
- const commit = projectTicketProvenanceCommit(parsed);
6994
- if (commit !== void 0) {
6995
- const merged = mergeSessionBounds(header?.sessions, commit.sessions);
6996
- remapCoverage(sourceIdentities, merged.priorIndexes);
6997
- remapCoverage(legacySourcePositions, merged.priorIndexes);
6998
- const remapped = [];
6999
- for (const entry of commit.lines) {
7000
- if (typeof entry === "string") {
7001
- unprojectedRaw.push(entry);
7002
- continue;
7003
- }
7004
- const s = merged.incomingIndexes[entry.s] ?? merged.priorIndexes[entry.s] ?? entry.s;
7005
- if ("raw" in entry) {
7006
- if (entry.sourceIdentity !== void 0) {
7007
- if (rememberIdentity(s, entry.sourceIdentity)) unprojectedRaw.push(entry.raw);
7008
- } else {
7009
- rememberLegacyPosition(s, entry.sourcePosition);
7010
- unprojectedRaw.push(entry.raw);
7011
- }
7012
- continue;
7013
- }
7014
- remapped.push({ ...entry, s });
7015
- if (entry.id === void 0) {
7016
- if (entry.sourceIdentity !== void 0) rememberIdentity(s, entry.sourceIdentity);
7017
- else if (entry.sourcePosition !== void 0) rememberLegacyPosition(s, entry.sourcePosition);
7018
- }
7019
- }
7020
- const now = commit.timestamp;
7021
- header = {
7022
- repo: header?.repo ?? resolveBookKeyFromGit(cwd),
7023
- ticket: ticketNumber,
7024
- createdAt: header?.createdAt ?? now,
7025
- updatedAt: header?.updatedAt !== void 0 && header.updatedAt > now ? header.updatedAt : now,
7026
- sessions: merged.sessions
7027
- };
7028
- const carried = lines.map((entry) => ({
7029
- ...entry,
7030
- s: merged.priorIndexes[entry.s] ?? entry.s
7031
- }));
7032
- lines.splice(0, lines.length, ...mergeFreshIntoCarried(carried, remapped));
7033
- continue;
7034
- }
7035
- unprojectedRaw.push(raw);
7036
- }
7037
- for (const line2 of lines) {
7038
- if (line2.id !== void 0) continue;
7039
- if (line2.sourceIdentity !== void 0) rememberIdentity(line2.s, line2.sourceIdentity);
7040
- else if (line2.sourcePosition !== void 0) rememberLegacyPosition(line2.s, line2.sourcePosition);
7041
- }
7042
- return {
7043
- header,
7044
- lines,
7045
- unprojectedRaw,
7046
- recordFile,
7047
- sourceIdentities,
7048
- legacySourcePositions
7049
- };
7050
- }
7051
6833
  async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
7052
6834
  const source = join13(runDirectory, "records.jsonl");
7053
6835
  let content;
@@ -7077,110 +6859,6 @@ function resolveBoundIndex(bound, sessionLines) {
7077
6859
  }
7078
6860
  return void 0;
7079
6861
  }
7080
- function dialogueIdentity(s, id) {
7081
- return `${s}\0${id}`;
7082
- }
7083
- function rangeDeclarationKey(range) {
7084
- return JSON.stringify({
7085
- from: range.from,
7086
- to: range.to
7087
- });
7088
- }
7089
- function mergeSessionBounds(prior, incoming) {
7090
- const merged = [];
7091
- const indexByIdentity = /* @__PURE__ */ new Map();
7092
- const absorb = (sessions) => {
7093
- const indexes = [];
7094
- for (const session of sessions) {
7095
- const identity = physicalPathIdentity(session.path);
7096
- let targetIndex = indexByIdentity.get(identity);
7097
- if (targetIndex === void 0) {
7098
- targetIndex = merged.length;
7099
- indexByIdentity.set(identity, targetIndex);
7100
- merged.push({ path: session.path, ranges: [] });
7101
- }
7102
- indexes.push(targetIndex);
7103
- const target = merged[targetIndex];
7104
- const seen = new Set(target.ranges.map(rangeDeclarationKey));
7105
- for (const range of session.ranges) {
7106
- const key = rangeDeclarationKey(range);
7107
- if (seen.has(key)) continue;
7108
- seen.add(key);
7109
- target.ranges.push({ from: { ...range.from }, to: { ...range.to } });
7110
- }
7111
- }
7112
- return indexes;
7113
- };
7114
- const priorIndexes = absorb(prior ?? []);
7115
- const incomingIndexes = absorb(incoming);
7116
- return { sessions: merged, priorIndexes, incomingIndexes };
7117
- }
7118
- function undeclaredSessionRanges(prior, merged) {
7119
- const priorKeys = /* @__PURE__ */ new Map();
7120
- for (const session of prior ?? []) {
7121
- const identity = physicalPathIdentity(session.path);
7122
- let keys = priorKeys.get(identity);
7123
- if (keys === void 0) {
7124
- keys = /* @__PURE__ */ new Set();
7125
- priorKeys.set(identity, keys);
7126
- }
7127
- for (const range of session.ranges) keys.add(rangeDeclarationKey(range));
7128
- }
7129
- const out = [];
7130
- for (let s = 0; s < merged.length; s += 1) {
7131
- const session = merged[s];
7132
- const identity = physicalPathIdentity(session.path);
7133
- const declared = priorKeys.get(identity) ?? /* @__PURE__ */ new Set();
7134
- const fresh = session.ranges.filter(
7135
- (range) => !declared.has(rangeDeclarationKey(range))
7136
- );
7137
- if (fresh.length === 0) continue;
7138
- out.push({
7139
- s,
7140
- session: {
7141
- path: session.path,
7142
- ranges: fresh.map((range) => ({
7143
- from: { ...range.from },
7144
- to: { ...range.to }
7145
- }))
7146
- }
7147
- });
7148
- }
7149
- return out;
7150
- }
7151
- function mergeFreshIntoCarried(carried, fresh) {
7152
- const seenSources = /* @__PURE__ */ new Map();
7153
- const bySession = /* @__PURE__ */ new Map();
7154
- const absorb = (lines) => {
7155
- for (const line2 of lines) {
7156
- const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
7157
- const identity = sourceIdentity === void 0 ? void 0 : `${line2.s}\0${sourceIdentity}`;
7158
- const seen = identity === void 0 ? void 0 : seenSources.get(identity);
7159
- if (seen !== void 0) {
7160
- if (line2.sourcePosition !== void 0) {
7161
- Object.assign(seen, { sourcePosition: line2.sourcePosition });
7162
- }
7163
- continue;
7164
- }
7165
- const bucket = bySession.get(line2.s) ?? [];
7166
- bucket.push({ ...line2 });
7167
- if (identity !== void 0) seenSources.set(identity, bucket.at(-1));
7168
- bySession.set(line2.s, bucket);
7169
- }
7170
- };
7171
- absorb(carried);
7172
- absorb(fresh);
7173
- return [...bySession.entries()].sort(([left], [right]) => left - right).flatMap(([, lines]) => lines.map((line2, archiveIndex) => ({ line: line2, archiveIndex })).sort((left, right) => {
7174
- const leftPosition = left.line.sourcePosition;
7175
- const rightPosition = right.line.sourcePosition;
7176
- if (leftPosition === void 0 && rightPosition === void 0) {
7177
- return left.archiveIndex - right.archiveIndex;
7178
- }
7179
- if (leftPosition === void 0) return 1;
7180
- if (rightPosition === void 0) return -1;
7181
- return leftPosition - rightPosition || left.archiveIndex - right.archiveIndex;
7182
- }).map(({ line: line2 }) => line2));
7183
- }
7184
6862
  function stableSourceFacts(sessionLines) {
7185
6863
  const positionByIdentity = /* @__PURE__ */ new Map();
7186
6864
  const facts = [];
@@ -7255,13 +6933,7 @@ async function projectSessionRanges(input) {
7255
6933
  const rows = sessionLines.map((entry) => entry.row);
7256
6934
  const dialogue = adaptSessionDialogue(rows);
7257
6935
  const sourceFacts = stableSourceFacts(sessionLines);
7258
- const sourcePositionByIdentity = /* @__PURE__ */ new Map();
7259
- for (const fact of sourceFacts) {
7260
- sourcePositionByIdentity.set(fact.identity, fact.position);
7261
- }
7262
- const seenIds = input.seenIds;
7263
- const lines = [];
7264
- const raw = [];
6936
+ const entries = [];
7265
6937
  const ranges = normalizeResolvedRanges(
7266
6938
  input.session.ranges,
7267
6939
  sessionLines,
@@ -7270,19 +6942,13 @@ async function projectSessionRanges(input) {
7270
6942
  for (const range of ranges) {
7271
6943
  for (let index = range.fromIndex; index <= range.toIndex; index += 1) {
7272
6944
  const { position: sourcePosition, identity: sourceIdentity } = sourceFacts[index];
7273
- if (input.coveredSourceIdentities.has(sourceIdentity) || input.legacyCoveredSourcePositions.has(sourcePosition)) continue;
7274
6945
  const entry = sessionLines[index];
7275
6946
  if (entry.row === void 0) {
7276
- raw.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
6947
+ entries.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
7277
6948
  continue;
7278
6949
  }
7279
6950
  for (const event of dialogue[index] ?? []) {
7280
- if (event.id !== void 0) {
7281
- const identity = dialogueIdentity(input.s, event.id);
7282
- if (seenIds.has(identity)) continue;
7283
- seenIds.add(identity);
7284
- }
7285
- lines.push({
6951
+ entries.push({
7286
6952
  speaker: event.speaker,
7287
6953
  s: input.s,
7288
6954
  sourcePosition,
@@ -7292,106 +6958,49 @@ async function projectSessionRanges(input) {
7292
6958
  }
7293
6959
  }
7294
6960
  }
7295
- return { lines, raw, sourcePositionByIdentity };
6961
+ return { entries };
7296
6962
  }
7297
6963
  async function reprojectTicketProvenance(input) {
7298
- const prior = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
6964
+ const recordInput = ticketProvenanceRecordInput(
6965
+ input.ticketNumber,
6966
+ input.cwd,
6967
+ input.home,
6968
+ input.runDirectory
6969
+ );
6970
+ const resolved = resolveSitianRecordPath(recordInput);
7299
6971
  if (input.sessions.length === 0) {
7300
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
7301
6972
  return {
7302
- recordFile: prior.recordFile,
7303
- header: prior.header ?? {
7304
- repo: resolveBookKeyFromGit(input.cwd),
7305
- ticket: input.ticketNumber,
7306
- createdAt: now2,
7307
- updatedAt: now2,
7308
- sessions: []
7309
- },
7310
- lines: prior.lines
6973
+ recordFile: resolved.recordFile,
6974
+ lines: []
7311
6975
  };
7312
6976
  }
7313
- const merged = mergeSessionBounds(prior.header?.sessions, input.sessions);
7314
- const deltas = undeclaredSessionRanges(prior.header?.sessions, merged.sessions);
7315
- if (deltas.length === 0) {
7316
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
7317
- return {
7318
- recordFile: prior.recordFile,
7319
- header: prior.header ?? {
7320
- repo: resolveBookKeyFromGit(input.cwd),
7321
- ticket: input.ticketNumber,
7322
- createdAt: now2,
7323
- updatedAt: now2,
7324
- sessions: merged.sessions
7325
- },
7326
- lines: prior.lines
7327
- };
7328
- }
7329
- const seenIds = new Set(
7330
- prior.lines.flatMap(
7331
- (line2) => line2.id === void 0 ? [] : [dialogueIdentity(line2.s, line2.id)]
7332
- )
7333
- );
7334
- const fresh = [];
7335
- const raw = [];
7336
- 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];
7337
6980
  const projected = await projectSessionRanges({
7338
- s: delta.s,
7339
- session: delta.session,
7340
- seenIds,
7341
- coveredSourceIdentities: prior.sourceIdentities.get(delta.s) ?? /* @__PURE__ */ new Set(),
7342
- legacyCoveredSourcePositions: prior.legacySourcePositions.get(delta.s) ?? /* @__PURE__ */ new Set(),
6981
+ s,
6982
+ session,
7343
6983
  ...input.home === void 0 ? {} : { home: input.home }
7344
6984
  });
7345
- fresh.push(...prior.lines.flatMap((line2) => {
7346
- if (line2.s !== delta.s) return [];
7347
- const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
7348
- if (sourceIdentity === void 0) return [];
7349
- const sourcePosition = projected.sourcePositionByIdentity.get(sourceIdentity);
7350
- return sourcePosition === void 0 ? [] : [{ ...line2, sourcePosition }];
7351
- }));
7352
- fresh.push(...projected.lines);
7353
- raw.push(...projected.raw);
7354
- }
7355
- const lines = mergeFreshIntoCarried(prior.lines, fresh);
7356
- const now = (/* @__PURE__ */ new Date()).toISOString();
7357
- const header = {
7358
- repo: prior.header?.repo ?? resolveBookKeyFromGit(input.cwd),
7359
- ticket: input.ticketNumber,
7360
- createdAt: prior.header?.createdAt ?? now,
7361
- updatedAt: now,
7362
- sessions: merged.sessions
7363
- };
7364
- const identityMaterial = JSON.stringify({
7365
- ticket: input.ticketNumber,
7366
- deltas: deltas.map(({ s, session }) => ({
7367
- s,
7368
- path: physicalPathIdentity(session.path),
7369
- ranges: session.ranges
7370
- })),
7371
- lines: [...fresh, ...raw]
7372
- });
7373
- const identity = `ticket-provenance:${createHash6("sha256").update(identityMaterial).digest("hex")}`;
6985
+ entries.push(...projected.entries);
6986
+ }
7374
6987
  const pointer = appendSitianRecord({
7375
- ...ticketProvenanceRecordInput(input.ticketNumber, input.cwd, input.home, input.runDirectory),
7376
- identity,
6988
+ ...recordInput,
7377
6989
  payload: {
7378
6990
  type: "ticket-provenance-append",
7379
- sessions: merged.sessions,
7380
- lines: [...fresh, ...raw]
6991
+ sessions: input.sessions,
6992
+ lines: entries
7381
6993
  }
7382
6994
  });
7383
- const folded = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
7384
6995
  return {
7385
6996
  recordFile: pointer.recordFile,
7386
- header: folded.header ?? header,
7387
- lines: folded.lines
6997
+ lines: entries.filter((entry) => "speaker" in entry)
7388
6998
  };
7389
6999
  }
7390
7000
  var TicketProvenanceInputError;
7391
7001
  var init_ticket_provenance = __esm({
7392
7002
  "src/ticket-provenance.ts"() {
7393
7003
  "use strict";
7394
- init_activation_ledger_git();
7395
7004
  init_activation_ledger_topology();
7396
7005
  init_ledger_session_read();
7397
7006
  init_run_ticket_number();
@@ -19503,7 +19112,7 @@ var init_analyst_metric_family = __esm({
19503
19112
  });
19504
19113
 
19505
19114
  // src/analyst-page.ts
19506
- import { createHash as createHash7 } from "node:crypto";
19115
+ import { createHash as createHash6 } from "node:crypto";
19507
19116
  import { dirname as dirname21, join as join35 } from "node:path";
19508
19117
  function analystIssuePageKey(address) {
19509
19118
  const parts = ["book", address.bookKey];
@@ -19512,7 +19121,7 @@ function analystIssuePageKey(address) {
19512
19121
  } else if (address.scopeRootIdentity !== void 0) {
19513
19122
  parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
19514
19123
  }
19515
- return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
19124
+ return createHash6("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
19516
19125
  }
19517
19126
  function analystIssuePagePath(ledgerHome, address) {
19518
19127
  return join35(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
@@ -23155,17 +22764,8 @@ async function restoreState(cwd, runId, scope) {
23155
22764
  }
23156
22765
  return { sequence: 0 };
23157
22766
  }
23158
- const { file, owned } = located;
23159
- const last = owned.at(-1);
22767
+ const { owned } = located;
23160
22768
  return {
23161
- ...last === void 0 ? {} : {
23162
- prior: {
23163
- identity: last.identity,
23164
- recordFile: file,
23165
- kind: last.kind,
23166
- level: last.level
23167
- }
23168
- },
23169
22769
  sequence: owned.reduce((maximum, record4) => {
23170
22770
  const payload = record4.payload;
23171
22771
  return payload?.type === "candidate" && typeof payload.sequence === "number" ? Math.max(maximum, payload.sequence) : maximum;
@@ -23193,15 +22793,10 @@ async function sealAcceptedSubmission(options) {
23193
22793
  const attemptId = attemptIdentity(options.context, runId);
23194
22794
  const sessionParent = sessionParentFromHostContext(options.context);
23195
22795
  const home = homeFromHostContext(options.context, options.home);
23196
- const state = await restoreState(options.context.cwd, runId, {
23197
- ...home === void 0 ? {} : { home },
23198
- ...sessionParent === void 0 ? {} : { sessionParent }
23199
- });
23200
- const pointer = sitianReport({
22796
+ sitianReport({
23201
22797
  level: "event",
23202
22798
  kind: "sealed",
23203
22799
  subject: { runId, attemptId },
23204
- ...state.prior === void 0 ? {} : { priorEventId: state.prior.identity },
23205
22800
  payload: {
23206
22801
  type: "sealed",
23207
22802
  attemptId,
@@ -23214,7 +22809,6 @@ async function sealAcceptedSubmission(options) {
23214
22809
  ...home !== void 0 ? { home } : {},
23215
22810
  ...sessionParent === void 0 ? {} : { sessionParent }
23216
22811
  });
23217
- state.prior = pointer;
23218
22812
  }
23219
22813
  function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
23220
22814
  throw error;
@@ -23231,31 +22825,28 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
23231
22825
  states.set(runId, pending);
23232
22826
  return pending;
23233
22827
  })();
23234
- const appendFor = (state, context, runId, attemptId, event) => {
22828
+ const appendFor = (context, runId, attemptId, event) => {
23235
22829
  const home = resolveHomeFromContext(context);
23236
22830
  const sessionParent = sessionParentFromHostContext(context);
23237
- const pointer = sitianReport({
22831
+ return sitianReport({
23238
22832
  level: "event",
23239
22833
  kind: event.type,
23240
22834
  subject: { runId, attemptId },
23241
- ...state.prior === void 0 ? {} : { priorEventId: state.prior.identity },
23242
22835
  payload: event,
23243
22836
  source: "role-runtime",
23244
22837
  cwd: context.cwd,
23245
22838
  ...home !== void 0 ? { home } : {},
23246
22839
  ...sessionParent === void 0 ? {} : { sessionParent }
23247
22840
  });
23248
- state.prior = pointer;
23249
- return pointer;
23250
22841
  };
23251
22842
  host.on("turn_end", async (event, context) => {
23252
22843
  try {
23253
22844
  const runId = runIdentity(context);
23254
22845
  const attemptId = attemptIdentity(context, runId);
23255
- const state = await stateFor(context, runId);
23256
22846
  const calls = event.calls.map(({ toolCallId: id, toolName: name }) => ({ id, name }));
23257
22847
  if (calls.length > 0) {
23258
- appendFor(state, context, runId, attemptId, { type: "roundContext", attemptId, calls });
22848
+ await stateFor(context, runId);
22849
+ appendFor(context, runId, attemptId, { type: "roundContext", attemptId, calls });
23259
22850
  }
23260
22851
  } catch (error) {
23261
22852
  failInfrastructure2(error, context);
@@ -23279,7 +22870,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
23279
22870
  const runId = runIdentity(context);
23280
22871
  const attemptId = attemptIdentity(context, runId);
23281
22872
  const state = await stateFor(context, runId);
23282
- const append = (event) => appendFor(state, context, runId, attemptId, event);
22873
+ const append = (event) => appendFor(context, runId, attemptId, event);
23283
22874
  append({
23284
22875
  type: "candidate",
23285
22876
  attemptId,
@@ -23367,7 +22958,7 @@ var init_submission_ledger = __esm({
23367
22958
  });
23368
22959
 
23369
22960
  // src/archivist-record-topology.ts
23370
- import { createHash as createHash8 } from "node:crypto";
22961
+ import { createHash as createHash7 } from "node:crypto";
23371
22962
  import { join as join43 } from "node:path";
23372
22963
  function resolveNavigatorWorkSubjectPlacement(input) {
23373
22964
  let ledgerHome;
@@ -23378,7 +22969,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
23378
22969
  }
23379
22970
  }
23380
22971
  ledgerHome ??= resolveActivationLedgerHome(input.home);
23381
- const digest = createHash8("sha256").update(input.subject).digest("hex").slice(0, 32);
22972
+ const digest = createHash7("sha256").update(input.subject).digest("hex").slice(0, 32);
23382
22973
  return {
23383
22974
  ledgerHome,
23384
22975
  sessionDir: join43(
@@ -23766,9 +23357,9 @@ init_sitian_facade();
23766
23357
  init_submission_ledger();
23767
23358
  init_collector_ledger();
23768
23359
  import { randomUUID as randomUUID8 } from "node:crypto";
23769
- import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
23360
+ import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
23770
23361
  import { join as join46 } from "node:path";
23771
- import { Value as Value5 } from "typebox/value";
23362
+ import { Value as Value4 } from "typebox/value";
23772
23363
 
23773
23364
  // src/activation-trace.ts
23774
23365
  import { Type as Type12 } from "typebox";
@@ -23938,118 +23529,6 @@ function writeStderrJsonlRecord(record4, write = writeSync) {
23938
23529
  }
23939
23530
  }
23940
23531
 
23941
- // src/tool-execution-observation.ts
23942
- import { writeSync as writeSync2 } from "node:fs";
23943
- import { Type as Type13 } from "typebox";
23944
- import { Value as Value3 } from "typebox/value";
23945
- var TOOL_EXECUTION_UPDATE_THROTTLE_MS = 3e4;
23946
- var observationBase = {
23947
- role: Type13.String({ minLength: 1 }),
23948
- toolCallId: Type13.String({ minLength: 1 }),
23949
- toolName: Type13.String({ minLength: 1 }),
23950
- timestamp: Type13.String({ format: "date-time" })
23951
- };
23952
- var toolExecutionObservationRecordSchema = Type13.Union([
23953
- Type13.Object({
23954
- ...observationBase,
23955
- event: Type13.Literal("tool_execution_start")
23956
- }, { additionalProperties: true }),
23957
- Type13.Object({
23958
- ...observationBase,
23959
- event: Type13.Literal("tool_execution_update")
23960
- }, { additionalProperties: true }),
23961
- Type13.Object({
23962
- ...observationBase,
23963
- event: Type13.Literal("tool_execution_end"),
23964
- isError: Type13.Boolean()
23965
- }, { additionalProperties: true })
23966
- ]);
23967
- function validateToolExecutionObservationRecord(record4) {
23968
- if (!Value3.Check(toolExecutionObservationRecordSchema, record4)) {
23969
- throw new TypeError("Tool execution observation record does not match its contract");
23970
- }
23971
- return record4;
23972
- }
23973
- function writeToolExecutionObservationRecord(record4, write = writeSync2) {
23974
- writeStderrJsonlRecord(validateToolExecutionObservationRecord(record4), write);
23975
- }
23976
- function isProducingToolUpdate(partialResult) {
23977
- if (partialResult == null) return false;
23978
- if (typeof partialResult !== "object") return true;
23979
- const content = partialResult.content;
23980
- if (!Array.isArray(content)) return true;
23981
- if (content.length === 0) return false;
23982
- return content.some((part) => {
23983
- if (typeof part !== "object" || part === null) return true;
23984
- const text = part.text;
23985
- if (typeof text === "string") return text.length > 0;
23986
- return true;
23987
- });
23988
- }
23989
- function systemToolExecutionObservationMonoNow() {
23990
- return performance.now();
23991
- }
23992
- function createToolExecutionObservationFace(options) {
23993
- const states = /* @__PURE__ */ new Map();
23994
- async function emit(record4) {
23995
- await options.write(validateToolExecutionObservationRecord(record4));
23996
- }
23997
- function activeRole() {
23998
- if (!options.admitted()) return void 0;
23999
- const role = options.role();
24000
- return role === void 0 || role === "" ? void 0 : role;
24001
- }
24002
- return {
24003
- reset() {
24004
- states.clear();
24005
- },
24006
- async onStart(event) {
24007
- const role = activeRole();
24008
- if (role === void 0) return;
24009
- states.set(event.toolCallId, { lastUpdateEmitMonoMs: void 0 });
24010
- await emit({
24011
- event: "tool_execution_start",
24012
- role,
24013
- toolCallId: event.toolCallId,
24014
- toolName: event.toolName,
24015
- timestamp: options.clock()
24016
- });
24017
- },
24018
- async onUpdate(event) {
24019
- const role = activeRole();
24020
- if (role === void 0) return;
24021
- if (!isProducingToolUpdate(event.partialResult)) return;
24022
- const now = options.monoNow();
24023
- const state = states.get(event.toolCallId) ?? { lastUpdateEmitMonoMs: void 0 };
24024
- if (state.lastUpdateEmitMonoMs !== void 0 && now - state.lastUpdateEmitMonoMs < TOOL_EXECUTION_UPDATE_THROTTLE_MS) {
24025
- return;
24026
- }
24027
- state.lastUpdateEmitMonoMs = now;
24028
- states.set(event.toolCallId, state);
24029
- await emit({
24030
- event: "tool_execution_update",
24031
- role,
24032
- toolCallId: event.toolCallId,
24033
- toolName: event.toolName,
24034
- timestamp: options.clock()
24035
- });
24036
- },
24037
- async onEnd(event) {
24038
- const role = activeRole();
24039
- if (role === void 0) return;
24040
- states.delete(event.toolCallId);
24041
- await emit({
24042
- event: "tool_execution_end",
24043
- role,
24044
- toolCallId: event.toolCallId,
24045
- toolName: event.toolName,
24046
- timestamp: options.clock(),
24047
- isError: event.isError
24048
- });
24049
- }
24050
- };
24051
- }
24052
-
24053
23532
  // src/role-runtime.ts
24054
23533
  init_engine_detour();
24055
23534
  init_engine_material();
@@ -24058,10 +23537,10 @@ init_engine_material();
24058
23537
  init_engine_detour();
24059
23538
  init_engine_detour_usage();
24060
23539
  init_run_terminal_artifacts();
24061
- import { Type as Type14 } from "typebox";
24062
- var engineDetourArgsSchema = Type14.Object(
23540
+ import { Type as Type13 } from "typebox";
23541
+ var engineDetourArgsSchema = Type13.Object(
24063
23542
  {
24064
- argv: Type14.Array(Type14.String({ minLength: 1 }), {
23543
+ argv: Type13.Array(Type13.String({ minLength: 1 }), {
24065
23544
  minItems: 1,
24066
23545
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
24067
23546
  })
@@ -24208,63 +23687,63 @@ import { join as join41, sep as sep6 } from "node:path";
24208
23687
  // src/collector-tool-schemas.ts
24209
23688
  init_open_tool_schema();
24210
23689
  init_terminating_infrastructure();
24211
- import { Type as Type15 } from "typebox";
24212
- var collectorObserveArgsSchema = Type15.Object({}, { additionalProperties: true });
24213
- var collectorRequestArgsSchema = Type15.Object({
24214
- requestId: Type15.String({
23690
+ import { Type as Type14 } from "typebox";
23691
+ var collectorObserveArgsSchema = Type14.Object({}, { additionalProperties: true });
23692
+ var collectorRequestArgsSchema = Type14.Object({
23693
+ requestId: Type14.String({
24215
23694
  minLength: 1,
24216
23695
  description: "\u8BF7\u6C42\u8EAB\u4EFD\uFF08\u914D\u7F6E id \u6216\u89D2\u8272\u5224\u5B9A\u7684\u7A33\u5B9A id\uFF1B\u9996\u5C3E\u65E0\u7A7A\u767D\uFF09"
24217
23696
  }),
24218
- snapshotId: Type15.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
23697
+ snapshotId: Type14.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
24219
23698
  // #836 r16 class 3: body.minLength deleted — manifest-configured requestId
24220
23699
  // ignores body, and the unknown-requestId non-empty condition is a real
24221
23700
  // branch in src/collector-ledger.ts:922-951, not a provider shape gate.
24222
- body: Type15.Optional(Type15.String({
23701
+ body: Type14.Optional(Type14.String({
24223
23702
  description: "\u89D2\u8272\u5224\u5B9A\u7684\u8BF7\u6C42\u6B63\u6587\uFF1Brequest-manifest \u672A\u6536\u5F55\u8BE5 requestId \u65F6\u5FC5\u586B"
24224
23703
  }))
24225
23704
  }, { additionalProperties: true });
24226
23705
  var COLLECTOR_HANDBOOK_MAX_BYTES = 64 * 1024;
24227
- var collectorHandbookWriteArgsSchema = Type15.Object({
24228
- scope: Type15.Union([
24229
- Type15.Literal("general"),
24230
- Type15.Literal("repo")
23706
+ var collectorHandbookWriteArgsSchema = Type14.Object({
23707
+ scope: Type14.Union([
23708
+ Type14.Literal("general"),
23709
+ Type14.Literal("repo")
24231
23710
  ], { description: "general\uFF1D\u901A\u7528\u624B\u518C\uFF1Brepo\uFF1D\u5F53\u524D\u4ED3\u5E93\u5DEE\u5F02" }),
24232
- body: Type15.String({
23711
+ body: Type14.String({
24233
23712
  description: `\u624B\u518C\u5168\u6587\uFF08opaque \u5DE5\u4F5C\u8BB0\u5FC6\uFF1B\u6574\u4EFD\u66FF\u6362\uFF1BUTF-8 \u81F3\u591A ${COLLECTOR_HANDBOOK_MAX_BYTES} \u5B57\u8282\uFF09`
24234
23713
  })
24235
23714
  }, { additionalProperties: true });
24236
- var collectorReadArgsSchema = Type15.Object({
24237
- evidenceId: Type15.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
23715
+ var collectorReadArgsSchema = Type14.Object({
23716
+ evidenceId: Type14.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
24238
23717
  }, { additionalProperties: true });
24239
- var collectorWaitArgsSchema = Type15.Object({
24240
- durationMs: Type15.Integer({
23718
+ var collectorWaitArgsSchema = Type14.Object({
23719
+ durationMs: Type14.Integer({
24241
23720
  minimum: 1,
24242
23721
  description: "\u7B49\u5F85\u6BEB\u79D2\uFF1B\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\uFF08#678\uFF1B\u65E0\u5305\u5185\u5355\u6B21\u4EFB\u610F\u4E0A\u9650\uFF09"
24243
23722
  })
24244
23723
  }, { additionalProperties: true });
24245
- var collectorOpenWaitWindowArgsSchema = Type15.Object({
24246
- startedAt: Type15.Optional(Type15.String({
23724
+ var collectorOpenWaitWindowArgsSchema = Type14.Object({
23725
+ startedAt: Type14.Optional(Type14.String({
24247
23726
  description: "\u7B49\u5F85\u7A97\u8D77\u70B9 ISO \u65F6\u95F4\uFF1B\u65B0\u5EFA PR \u7528\u521B\u5EFA\u6210\u529F\u65F6\u523B\uFF1B\u7701\u7565\uFF1D\u73B0\u5728\uFF08\u89E6\u53D1\u9636\u6BB5\u7ED3\u675F\uFF09"
24248
23727
  }))
24249
23728
  }, { additionalProperties: true });
24250
- var collectorBindTargetArgsSchema = Type15.Object({
24251
- prNumber: Type15.Optional(Type15.Unknown({
23729
+ var collectorBindTargetArgsSchema = Type14.Object({
23730
+ prNumber: Type14.Optional(Type14.Unknown({
24252
23731
  description: "\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24253
23732
  })),
24254
- issueNumber: Type15.Optional(Type15.Unknown({
23733
+ issueNumber: Type14.Optional(Type14.Unknown({
24255
23734
  description: "\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
24256
23735
  }))
24257
23736
  }, { additionalProperties: true });
24258
23737
  var collectorFindingItemDeclaration = (() => {
24259
- const item = Type15.Object(
23738
+ const item = Type14.Object(
24260
23739
  {
24261
- evidenceId: Type15.Unknown({
23740
+ evidenceId: Type14.Unknown({
24262
23741
  description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u6307\u9488\uFF08\u5FC5\u586B\u8BED\u4E49\uFF09"
24263
23742
  }),
24264
- category: Type15.Unknown({
23743
+ category: Type14.Unknown({
24265
23744
  description: "\u7B80\u77ED\u5F52\u7C7B\u6807\u7B7E\uFF0C\u4E0D\u662F\u6458\u8981"
24266
23745
  }),
24267
- summary: Type15.Unknown({
23746
+ summary: Type14.Unknown({
24268
23747
  description: "\u54EA\u4E2A bot\u3001\u4EC0\u4E48\u95EE\u9898\u7684\u6458\u8981\uFF1B\u4E0D\u8A8A\u6284\u6B63\u6587"
24269
23748
  })
24270
23749
  },
@@ -24277,14 +23756,14 @@ var collectorFindingItemDeclaration = (() => {
24277
23756
  return item;
24278
23757
  })();
24279
23758
  var collectorOutputBaseSchema = openToolObject(
24280
- Type15.Object({
23759
+ Type14.Object({
24281
23760
  // No root type:array — host must not shape-reject non-array findings (#676 C).
24282
23761
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
24283
- findings: Type15.Unsafe({
23762
+ findings: Type14.Unsafe({
24284
23763
  description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings \u6307\u9488\u3002",
24285
23764
  items: collectorFindingItemDeclaration
24286
23765
  }),
24287
- unfinishedReasons: Type15.Unknown({
23766
+ unfinishedReasons: Type14.Unknown({
24288
23767
  description: "\u672A\u5B8C\u6210\u539F\u56E0\u3002"
24289
23768
  })
24290
23769
  })
@@ -25126,18 +24605,18 @@ init_open_tool_schema();
25126
24605
  init_terminating_infrastructure();
25127
24606
  init_gleaner_left_contracts();
25128
24607
  init_gleaner_left_contracts();
25129
- import { Type as Type16 } from "typebox";
24608
+ import { Type as Type15 } from "typebox";
25130
24609
  var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
25131
24610
  openToolObject(
25132
- Type16.Object({
25133
- status: Type16.Unknown({
24611
+ Type15.Object({
24612
+ status: Type15.Unknown({
25134
24613
  description: "completed"
25135
24614
  }),
25136
- findings: Type16.Array(
25137
- Type16.Object(
24615
+ findings: Type15.Array(
24616
+ Type15.Object(
25138
24617
  {
25139
- pointer: Type16.Optional(Type16.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
25140
- statement: Type16.Optional(Type16.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
24618
+ pointer: Type15.Optional(Type15.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
24619
+ statement: Type15.Optional(Type15.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
25141
24620
  },
25142
24621
  { additionalProperties: true, description: "\u4E00\u6761\u5F39\u7AE0" }
25143
24622
  ),
@@ -25177,44 +24656,44 @@ init_open_tool_schema();
25177
24656
  init_terminating_infrastructure();
25178
24657
  init_diarist_contracts();
25179
24658
  init_diarist_contracts();
25180
- import { Type as Type17 } from "typebox";
24659
+ import { Type as Type16 } from "typebox";
25181
24660
  var diaristOutputSchema = withTerminatingOutputDeclarations(
25182
24661
  openToolObject(
25183
- Type17.Object({
25184
- status: Type17.Unknown({
24662
+ Type16.Object({
24663
+ status: Type16.Unknown({
25185
24664
  description: "completed | escalate"
25186
24665
  }),
25187
- ticketNumber: Type17.Optional(
25188
- Type17.Unknown({
24666
+ ticketNumber: Type16.Optional(
24667
+ Type16.Unknown({
25189
24668
  description: "\u672C\u5EAD\u5BF9\u8C61\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09\u6216 null/\u7701\u7565\uFF1D\u771F\u65E0\u7968\uFF1B\u4E0B\u6E38\u8D70 typed \u952E\uFF1B\u8BA4\u4E0D\u51FA\u7528 status=escalate\uFF0C\u4E0D\u6D17\u6210\u65E0\u5F55\u3002\u673A\u68B0\u5C42\u4E0D\u91CD\u5224\u3002"
25190
24669
  })
25191
24670
  ),
25192
- courtTicketNumbers: Type17.Optional(
25193
- Type17.Unknown({
24671
+ courtTicketNumbers: Type16.Optional(
24672
+ Type16.Unknown({
25194
24673
  description: "#871 \u672C\u6B21\u5408\u5BA1\u5E94\u5404\u81EA\u6210\u5F55\u7684\u7968\u53F7\u96C6\u5408\uFF08\u6B63\u6574\u6570\u6570\u7EC4\uFF0C\u542B\u4E3B\u7968\uFF09\uFF1B\u5355\u7968\u53EF\u7701\u7565\u3002\u673A\u68B0\u5C42\u53EA\u505A\u7C7B\u578B/\u53BB\u91CD\u6295\u5F71\uFF0C\u4E0D\u4ECE\u6563\u6587\u731C\u7968\u3002"
25195
24674
  })
25196
24675
  ),
25197
- reason: Type17.Optional(
25198
- Type17.String({
24676
+ reason: Type16.Optional(
24677
+ Type16.String({
25199
24678
  description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
25200
24679
  })
25201
24680
  ),
25202
- sessions: Type17.Optional(
25203
- Type17.Array(
25204
- Type17.Object(
24681
+ sessions: Type16.Optional(
24682
+ Type16.Array(
24683
+ Type16.Object(
25205
24684
  {
25206
- path: Type17.Optional(
25207
- Type17.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
24685
+ path: Type16.Optional(
24686
+ Type16.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
25208
24687
  ),
25209
- ranges: Type17.Optional(
25210
- Type17.Array(
25211
- Type17.Object(
24688
+ ranges: Type16.Optional(
24689
+ Type16.Array(
24690
+ Type16.Object(
25212
24691
  {
25213
- from: Type17.Optional(
25214
- Type17.Object(
24692
+ from: Type16.Optional(
24693
+ Type16.Object(
25215
24694
  {
25216
- id: Type17.Optional(Type17.String()),
25217
- line: Type17.Optional(Type17.Unknown())
24695
+ id: Type16.Optional(Type16.String()),
24696
+ line: Type16.Optional(Type16.Unknown())
25218
24697
  },
25219
24698
  {
25220
24699
  additionalProperties: true,
@@ -25222,11 +24701,11 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
25222
24701
  }
25223
24702
  )
25224
24703
  ),
25225
- to: Type17.Optional(
25226
- Type17.Object(
24704
+ to: Type16.Optional(
24705
+ Type16.Object(
25227
24706
  {
25228
- id: Type17.Optional(Type17.String()),
25229
- line: Type17.Optional(Type17.Unknown())
24707
+ id: Type16.Optional(Type16.String()),
24708
+ line: Type16.Optional(Type16.Unknown())
25230
24709
  },
25231
24710
  {
25232
24711
  additionalProperties: true,
@@ -25263,23 +24742,23 @@ var DIARIST_TOOL_SPEC = {
25263
24742
  init_terminating_infrastructure();
25264
24743
  init_secretariat_contracts();
25265
24744
  init_secretariat_contracts();
25266
- import { Type as Type18 } from "typebox";
24745
+ import { Type as Type17 } from "typebox";
25267
24746
  var secretariatVerdictSchema = withTerminatingOutputDeclarations(
25268
- Type18.Object(
24747
+ Type17.Object(
25269
24748
  {
25270
- secretariatStatus: Type18.Unknown({
24749
+ secretariatStatus: Type17.Unknown({
25271
24750
  description: "converged | escalate"
25272
24751
  }),
25273
- ticketNumber: Type18.Optional(
25274
- Type18.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
24752
+ ticketNumber: Type17.Optional(
24753
+ Type17.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
25275
24754
  ),
25276
- note: Type18.Optional(Type18.String({ description: "\u9644\u6CE8" })),
25277
- evidence: Type18.Optional(Type18.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
25278
- decisionGate: Type18.Optional(
25279
- Type18.Object(
24755
+ note: Type17.Optional(Type17.String({ description: "\u9644\u6CE8" })),
24756
+ evidence: Type17.Optional(Type17.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
24757
+ decisionGate: Type17.Optional(
24758
+ Type17.Object(
25280
24759
  {
25281
- question: Type18.Optional(Type18.String()),
25282
- options: Type18.Optional(Type18.Array(Type18.String()))
24760
+ question: Type17.Optional(Type17.String()),
24761
+ options: Type17.Optional(Type17.Array(Type17.String()))
25283
24762
  },
25284
24763
  { additionalProperties: true, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
25285
24764
  )
@@ -25344,13 +24823,13 @@ var AUDITOR_TOOL_SPEC = {
25344
24823
  };
25345
24824
 
25346
24825
  // src/navigator-attendance.ts
25347
- import { createHash as createHash9 } from "node:crypto";
24826
+ import { createHash as createHash8 } from "node:crypto";
25348
24827
  init_navigator_invocation_identity();
25349
24828
  init_packaged_role_registry();
25350
24829
  init_activation_ledger_topology();
25351
24830
  import { resolve as resolve18 } from "node:path";
25352
24831
  import "@earendil-works/pi-coding-agent";
25353
- import { Type as Type20 } from "typebox";
24832
+ import { Type as Type19 } from "typebox";
25354
24833
 
25355
24834
  // src/navigator-public-session.ts
25356
24835
  init_sitian_facade();
@@ -25358,8 +24837,8 @@ import { existsSync as existsSync13 } from "node:fs";
25358
24837
  import { basename as basename11 } from "node:path";
25359
24838
 
25360
24839
  // src/navigator-session-contracts.ts
25361
- import { Type as Type19 } from "typebox";
25362
- import { Value as Value4 } from "typebox/value";
24840
+ import { Type as Type18 } from "typebox";
24841
+ import { Value as Value3 } from "typebox/value";
25363
24842
  var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
25364
24843
  var NAVIGATOR_UNAVAILABLE_KEYS = /* @__PURE__ */ new Set([
25365
24844
  "context",
@@ -25466,26 +24945,26 @@ function navigatorProviderFailureFromPublicTerminal(outcome) {
25466
24945
  if (typed !== void 0) return { source: typed, cause: typed };
25467
24946
  return { source: "unknown", cause: "unknown" };
25468
24947
  }
25469
- var navigatorProviderFailureSchema = Type19.Object({
25470
- source: Type19.Union([
25471
- Type19.Literal("context"),
25472
- Type19.Literal("session"),
25473
- Type19.Literal("model"),
25474
- Type19.Literal("thinking"),
25475
- Type19.Literal("auth"),
25476
- Type19.Literal("quota"),
25477
- Type19.Literal("transport"),
25478
- Type19.Literal("unknown")
24948
+ var navigatorProviderFailureSchema = Type18.Object({
24949
+ source: Type18.Union([
24950
+ Type18.Literal("context"),
24951
+ Type18.Literal("session"),
24952
+ Type18.Literal("model"),
24953
+ Type18.Literal("thinking"),
24954
+ Type18.Literal("auth"),
24955
+ Type18.Literal("quota"),
24956
+ Type18.Literal("transport"),
24957
+ Type18.Literal("unknown")
25479
24958
  ]),
25480
- cause: Type19.Union([
25481
- Type19.Literal("context"),
25482
- Type19.Literal("session"),
25483
- Type19.Literal("model"),
25484
- Type19.Literal("thinking"),
25485
- Type19.Literal("auth"),
25486
- Type19.Literal("quota"),
25487
- Type19.Literal("transport"),
25488
- Type19.Literal("unknown")
24959
+ cause: Type18.Union([
24960
+ Type18.Literal("context"),
24961
+ Type18.Literal("session"),
24962
+ Type18.Literal("model"),
24963
+ Type18.Literal("thinking"),
24964
+ Type18.Literal("auth"),
24965
+ Type18.Literal("quota"),
24966
+ Type18.Literal("transport"),
24967
+ Type18.Literal("unknown")
25489
24968
  ])
25490
24969
  }, { additionalProperties: false });
25491
24970
  function parseNavigatorModelSetting(value) {
@@ -25865,8 +25344,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
25865
25344
  return void 0;
25866
25345
  }
25867
25346
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
25868
- var prepareSchema = Type20.Object({
25869
- prose: Type20.Optional(Type20.Unknown({
25347
+ var prepareSchema = Type19.Object({
25348
+ prose: Type19.Optional(Type19.Unknown({
25870
25349
  description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
25871
25350
  }))
25872
25351
  }, { additionalProperties: true });
@@ -25905,7 +25384,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
25905
25384
  if (provenance === "placeholder") return subjectRoot;
25906
25385
  const normalized = subject.trim().replace(/\s+/g, " ");
25907
25386
  if (normalized === "") return subjectRoot;
25908
- return `${subjectRoot}#${createHash9("sha256").update(normalized).digest("hex").slice(0, 32)}`;
25387
+ return `${subjectRoot}#${createHash8("sha256").update(normalized).digest("hex").slice(0, 32)}`;
25909
25388
  }
25910
25389
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
25911
25390
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
@@ -26314,12 +25793,12 @@ init_judge_role();
26314
25793
  init_open_tool_schema();
26315
25794
  init_terminating_infrastructure();
26316
25795
  init_reviewer_output();
26317
- import { Type as Type21 } from "typebox";
26318
- var reviewerAmendmentsSchema = Type21.Object({
26319
- completeness: Type21.Optional(Type21.String({
25796
+ import { Type as Type20 } from "typebox";
25797
+ var reviewerAmendmentsSchema = Type20.Object({
25798
+ completeness: Type20.Optional(Type20.String({
26320
25799
  description: "completeness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
26321
25800
  })),
26322
- correctness: Type21.Optional(Type21.String({
25801
+ correctness: Type20.Optional(Type20.String({
26323
25802
  description: "correctness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
26324
25803
  }))
26325
25804
  }, {
@@ -26327,15 +25806,15 @@ var reviewerAmendmentsSchema = Type21.Object({
26327
25806
  description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002"
26328
25807
  });
26329
25808
  var REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
26330
- var reviewerOutputVariants = Type21.Union([
26331
- Type21.Object({
26332
- status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26333
- amendments: Type21.Optional(reviewerAmendmentsSchema)
25809
+ var reviewerOutputVariants = Type20.Union([
25810
+ Type20.Object({
25811
+ status: Type20.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
25812
+ amendments: Type20.Optional(reviewerAmendmentsSchema)
26334
25813
  }, { additionalProperties: false }),
26335
- Type21.Object({
26336
- status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26337
- diagnostic: Type21.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
26338
- amendments: Type21.Optional(reviewerAmendmentsSchema)
25814
+ Type20.Object({
25815
+ status: Type20.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
25816
+ diagnostic: Type20.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
25817
+ amendments: Type20.Optional(reviewerAmendmentsSchema)
26339
25818
  }, { additionalProperties: false })
26340
25819
  ]);
26341
25820
  var reviewerOutputSchema = withTerminatingOutputDeclarations(
@@ -26384,7 +25863,7 @@ init_terminating_infrastructure();
26384
25863
  init_worker_output();
26385
25864
  init_fixer_output();
26386
25865
  init_fixer_packet();
26387
- import { Type as Type22 } from "typebox";
25866
+ import { Type as Type21 } from "typebox";
26388
25867
 
26389
25868
  // src/worker-submission-gates.ts
26390
25869
  init_archivist_record_entry();
@@ -26650,20 +26129,20 @@ function fixerBashSeatbeltDenyReason(matched) {
26650
26129
 
26651
26130
  // src/worker-role.ts
26652
26131
  var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002";
26653
- var coderOutputVariants = Type22.Union([
26654
- Type22.Object({
26655
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26656
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26132
+ var coderOutputVariants = Type21.Union([
26133
+ Type21.Object({
26134
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26135
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26657
26136
  }, { additionalProperties: false }),
26658
- Type22.Object({
26659
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26660
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26137
+ Type21.Object({
26138
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26139
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26661
26140
  }, { additionalProperties: false }),
26662
- Type22.Object({
26663
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26664
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26665
- remainingScope: Type22.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26666
- reason: Type22.Optional(Type22.String({
26141
+ Type21.Object({
26142
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26143
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26144
+ remainingScope: Type21.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26145
+ reason: Type21.Optional(Type21.String({
26667
26146
  minLength: 1,
26668
26147
  description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
26669
26148
  }))
@@ -27111,7 +26590,7 @@ function activationStage(role, activate) {
27111
26590
  };
27112
26591
  }
27113
26592
  function validateActivationTraceRecord(record4) {
27114
- if (!Value5.Check(activationTraceRecordSchema, record4)) {
26593
+ if (!Value4.Check(activationTraceRecordSchema, record4)) {
27115
26594
  throw new TypeError("Activation trace record does not match its closed contract");
27116
26595
  }
27117
26596
  return record4;
@@ -27137,7 +26616,7 @@ async function executeActivationStage(role, stage, infrastructure) {
27137
26616
  throw activationError;
27138
26617
  }
27139
26618
  }
27140
- function writeActivationTraceRecord(record4, write = writeSync3) {
26619
+ function writeActivationTraceRecord(record4, write = writeSync2) {
27141
26620
  writeStderrJsonlRecord(record4, write);
27142
26621
  }
27143
26622
  var ActivationBarrierError = class extends Error {
@@ -27914,7 +27393,6 @@ function createRoleRuntimeExtension(dependencies) {
27914
27393
  disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
27915
27394
  pendingInfrastructureFailures.clear();
27916
27395
  pendingSubmissionNonPassByToolCallId.clear();
27917
- observationFace.reset();
27918
27396
  });
27919
27397
  const hostActions = {
27920
27398
  failInfrastructure(error, ctx, toolCallId) {
@@ -28130,29 +27608,6 @@ function createRoleRuntimeExtension(dependencies) {
28130
27608
  };
28131
27609
  const clock = dependencies.activationClock ?? (() => (/* @__PURE__ */ new Date()).toISOString());
28132
27610
  const writeTrace = dependencies.activationTraceWriter ?? writeActivationTraceRecord;
28133
- const observationFace = createToolExecutionObservationFace({
28134
- role: () => selectedRole,
28135
- admitted: () => admitted,
28136
- clock: dependencies.toolExecutionObservationClock ?? clock,
28137
- monoNow: dependencies.toolExecutionObservationMonoNow ?? systemToolExecutionObservationMonoNow,
28138
- write: dependencies.toolExecutionObservationWriter ?? writeToolExecutionObservationRecord
28139
- });
28140
- const observe = async (run, ctx) => {
28141
- try {
28142
- await run();
28143
- } catch (error) {
28144
- failInfrastructure(error, ctx);
28145
- }
28146
- };
28147
- roleHost.on("tool_execution_start", async (event, ctx) => {
28148
- await observe(() => observationFace.onStart(event), ctx);
28149
- });
28150
- roleHost.on("tool_execution_update", async (event, ctx) => {
28151
- await observe(() => observationFace.onUpdate(event), ctx);
28152
- });
28153
- roleHost.on("tool_execution_end", async (event, ctx) => {
28154
- await observe(() => observationFace.onEnd(event), ctx);
28155
- });
28156
27611
  const recordHttpObservation = async (status, provider, ctx) => {
28157
27612
  const runDir = runDirectoryFromHostContext(ctx);
28158
27613
  if (runDir === void 0) return;
@@ -28201,7 +27656,6 @@ function createRoleRuntimeExtension(dependencies) {
28201
27656
  collectorFirstDispatchDone = false;
28202
27657
  receiptDelivery = createReceiptDeliveryPolicy();
28203
27658
  noReceiptRecorded = false;
28204
- observationFace.reset();
28205
27659
  pendingNavigatorPresentation = void 0;
28206
27660
  pendingNavigatorSettlement = void 0;
28207
27661
  pendingInfrastructureFailures.clear();