@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.
@@ -2694,17 +2694,6 @@ function positiveInteger(value) {
2694
2694
  }
2695
2695
  return void 0;
2696
2696
  }
2697
- function nonNegativeInteger(value) {
2698
- if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) return value;
2699
- if (typeof value === "string" && /^(0|[1-9][0-9]*)$/.test(value)) {
2700
- const parsed = Number(value);
2701
- if (Number.isSafeInteger(parsed)) return parsed;
2702
- }
2703
- return void 0;
2704
- }
2705
- function projectSpeaker(value) {
2706
- return value === "owner" || value === "runner" ? value : void 0;
2707
- }
2708
2697
  function projectBound(value) {
2709
2698
  if (!isRecord2(value)) return void 0;
2710
2699
  const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
@@ -2733,42 +2722,6 @@ function projectTicketProvenanceSessions(value) {
2733
2722
  }
2734
2723
  return sessions;
2735
2724
  }
2736
- function projectTicketProvenanceHeader(value) {
2737
- if (!isRecord2(value)) return void 0;
2738
- const ticket = value.ticket === null ? null : positiveInteger(value.ticket);
2739
- if (ticket === void 0) return void 0;
2740
- if (typeof value.repo !== "string") return void 0;
2741
- if (typeof value.createdAt !== "string" || typeof value.updatedAt !== "string") {
2742
- return void 0;
2743
- }
2744
- const sessions = projectTicketProvenanceSessions(value.sessions);
2745
- if (sessions === void 0) return void 0;
2746
- return {
2747
- repo: value.repo,
2748
- ticket,
2749
- createdAt: value.createdAt,
2750
- updatedAt: value.updatedAt,
2751
- sessions
2752
- };
2753
- }
2754
- function projectTicketProvenanceLine(value) {
2755
- if (!isRecord2(value)) return void 0;
2756
- const speaker = projectSpeaker(value.speaker);
2757
- const s = nonNegativeInteger(value.s);
2758
- if (speaker === void 0 || s === void 0) return void 0;
2759
- if (typeof value.text !== "string") return void 0;
2760
- const sourcePosition = nonNegativeInteger(value.sourcePosition);
2761
- const sourceIdentity = typeof value.sourceIdentity === "string" && value.sourceIdentity !== "" ? value.sourceIdentity : void 0;
2762
- const id = typeof value.id === "string" && value.id !== "" ? value.id : void 0;
2763
- return {
2764
- speaker,
2765
- s,
2766
- ...sourcePosition === void 0 ? {} : { sourcePosition },
2767
- ...sourceIdentity === void 0 ? {} : { sourceIdentity },
2768
- ...id === void 0 ? {} : { id },
2769
- text: value.text
2770
- };
2771
- }
2772
2725
  var TICKET_PROVENANCE_KIND;
2773
2726
  var init_ticket_provenance_contracts = __esm({
2774
2727
  "src/ticket-provenance-contracts.ts"() {
@@ -4731,7 +4684,6 @@ function appendSitianRecord(input) {
4731
4684
  identity,
4732
4685
  ...input.subject === void 0 ? {} : { subject: input.subject },
4733
4686
  ...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
4734
- ...input.priorEventId === void 0 ? {} : { priorEventId: input.priorEventId },
4735
4687
  timestamp: timestamp2,
4736
4688
  host,
4737
4689
  ...input.source === void 0 ? {} : { source: input.source },
@@ -7708,7 +7660,6 @@ var init_session_dialogue = __esm({
7708
7660
  });
7709
7661
 
7710
7662
  // src/ticket-provenance.ts
7711
- import { createHash as createHash6 } from "node:crypto";
7712
7663
  import { readFile as readFile12, unlink as unlink2 } from "node:fs/promises";
7713
7664
  import { basename as basename5, dirname as dirname11, join as join16, resolve as resolve9 } from "node:path";
7714
7665
  function dialogueSessionSourceRoots(home) {
@@ -7759,175 +7710,6 @@ function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
7759
7710
  );
7760
7711
  return { recordFile: path.recordFile, volumeDir: path.sessionDir };
7761
7712
  }
7762
- function projectTicketProvenanceRaw(value) {
7763
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
7764
- const raw = value;
7765
- if (typeof raw.raw !== "string" || !Number.isInteger(raw.s) || raw.s < 0 || !Number.isInteger(raw.sourcePosition) || raw.sourcePosition < 0) {
7766
- return void 0;
7767
- }
7768
- const sourceIdentity = typeof raw.sourceIdentity === "string" && raw.sourceIdentity !== "" ? raw.sourceIdentity : void 0;
7769
- return {
7770
- raw: raw.raw,
7771
- s: raw.s,
7772
- sourcePosition: raw.sourcePosition,
7773
- ...sourceIdentity === void 0 ? {} : { sourceIdentity }
7774
- };
7775
- }
7776
- function projectTicketProvenanceCommit(value) {
7777
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
7778
- const record4 = value;
7779
- if (record4.kind !== TICKET_PROVENANCE_KIND || typeof record4.timestamp !== "string") {
7780
- return void 0;
7781
- }
7782
- const payload = record4.payload;
7783
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return void 0;
7784
- const body = payload;
7785
- if (body.type !== "ticket-provenance-append") return void 0;
7786
- const sessions = projectTicketProvenanceSessions(body.sessions);
7787
- if (sessions === void 0 || !Array.isArray(body.lines)) return void 0;
7788
- const lines = [];
7789
- for (const raw of body.lines) {
7790
- if (typeof raw === "string") {
7791
- lines.push(raw);
7792
- continue;
7793
- }
7794
- const line2 = projectTicketProvenanceLine(raw);
7795
- if (line2 !== void 0) {
7796
- lines.push(line2);
7797
- continue;
7798
- }
7799
- const preserved = projectTicketProvenanceRaw(raw);
7800
- if (preserved === void 0) return void 0;
7801
- lines.push(preserved);
7802
- }
7803
- return { timestamp: record4.timestamp, sessions, lines };
7804
- }
7805
- async function readTicketProvenance(ticketNumber, cwd, home, runDirectory) {
7806
- const { recordFile } = ticketNumber === null ? resolveSitianRecordPath(ticketProvenanceRecordInput(null, cwd, home, runDirectory)) : resolveTicketProvenanceVolume(ticketNumber, cwd, home);
7807
- let text;
7808
- try {
7809
- text = await readFile12(recordFile, "utf8");
7810
- } catch (error) {
7811
- if (error.code === "ENOENT") {
7812
- return {
7813
- header: void 0,
7814
- lines: [],
7815
- unprojectedRaw: [],
7816
- recordFile,
7817
- sourceIdentities: /* @__PURE__ */ new Map(),
7818
- legacySourcePositions: /* @__PURE__ */ new Map()
7819
- };
7820
- }
7821
- throw error;
7822
- }
7823
- const physical = text.split("\n");
7824
- let header;
7825
- const lines = [];
7826
- const unprojectedRaw = [];
7827
- const sourceIdentities = /* @__PURE__ */ new Map();
7828
- const legacySourcePositions = /* @__PURE__ */ new Map();
7829
- const rememberIdentity = (s, identity) => {
7830
- const seen = sourceIdentities.get(s) ?? /* @__PURE__ */ new Set();
7831
- const fresh = !seen.has(identity);
7832
- seen.add(identity);
7833
- sourceIdentities.set(s, seen);
7834
- return fresh;
7835
- };
7836
- const rememberLegacyPosition = (s, position) => {
7837
- const seen = legacySourcePositions.get(s) ?? /* @__PURE__ */ new Set();
7838
- seen.add(position);
7839
- legacySourcePositions.set(s, seen);
7840
- };
7841
- const remapCoverage = (coverage, priorIndexes) => {
7842
- const normalized = /* @__PURE__ */ new Map();
7843
- for (const [s, values] of coverage) {
7844
- const target = priorIndexes[s] ?? s;
7845
- const union = normalized.get(target) ?? /* @__PURE__ */ new Set();
7846
- for (const value of values) union.add(value);
7847
- normalized.set(target, union);
7848
- }
7849
- coverage.clear();
7850
- for (const [s, values] of normalized) coverage.set(s, values);
7851
- };
7852
- let sawFirst = false;
7853
- for (let index = 0; index < physical.length; index += 1) {
7854
- const raw = physical[index];
7855
- if (!raw.trim()) continue;
7856
- let parsed;
7857
- try {
7858
- parsed = JSON.parse(raw);
7859
- } catch {
7860
- unprojectedRaw.push(raw);
7861
- continue;
7862
- }
7863
- if (!sawFirst) {
7864
- sawFirst = true;
7865
- header = projectTicketProvenanceHeader(parsed);
7866
- if (header !== void 0) continue;
7867
- }
7868
- const line2 = projectTicketProvenanceLine(parsed);
7869
- if (line2 !== void 0) {
7870
- lines.push(line2);
7871
- continue;
7872
- }
7873
- const commit = projectTicketProvenanceCommit(parsed);
7874
- if (commit !== void 0) {
7875
- const merged = mergeSessionBounds(header?.sessions, commit.sessions);
7876
- remapCoverage(sourceIdentities, merged.priorIndexes);
7877
- remapCoverage(legacySourcePositions, merged.priorIndexes);
7878
- const remapped = [];
7879
- for (const entry of commit.lines) {
7880
- if (typeof entry === "string") {
7881
- unprojectedRaw.push(entry);
7882
- continue;
7883
- }
7884
- const s = merged.incomingIndexes[entry.s] ?? merged.priorIndexes[entry.s] ?? entry.s;
7885
- if ("raw" in entry) {
7886
- if (entry.sourceIdentity !== void 0) {
7887
- if (rememberIdentity(s, entry.sourceIdentity)) unprojectedRaw.push(entry.raw);
7888
- } else {
7889
- rememberLegacyPosition(s, entry.sourcePosition);
7890
- unprojectedRaw.push(entry.raw);
7891
- }
7892
- continue;
7893
- }
7894
- remapped.push({ ...entry, s });
7895
- if (entry.id === void 0) {
7896
- if (entry.sourceIdentity !== void 0) rememberIdentity(s, entry.sourceIdentity);
7897
- else if (entry.sourcePosition !== void 0) rememberLegacyPosition(s, entry.sourcePosition);
7898
- }
7899
- }
7900
- const now = commit.timestamp;
7901
- header = {
7902
- repo: header?.repo ?? resolveBookKeyFromGit(cwd),
7903
- ticket: ticketNumber,
7904
- createdAt: header?.createdAt ?? now,
7905
- updatedAt: header?.updatedAt !== void 0 && header.updatedAt > now ? header.updatedAt : now,
7906
- sessions: merged.sessions
7907
- };
7908
- const carried = lines.map((entry) => ({
7909
- ...entry,
7910
- s: merged.priorIndexes[entry.s] ?? entry.s
7911
- }));
7912
- lines.splice(0, lines.length, ...mergeFreshIntoCarried(carried, remapped));
7913
- continue;
7914
- }
7915
- unprojectedRaw.push(raw);
7916
- }
7917
- for (const line2 of lines) {
7918
- if (line2.id !== void 0) continue;
7919
- if (line2.sourceIdentity !== void 0) rememberIdentity(line2.s, line2.sourceIdentity);
7920
- else if (line2.sourcePosition !== void 0) rememberLegacyPosition(line2.s, line2.sourcePosition);
7921
- }
7922
- return {
7923
- header,
7924
- lines,
7925
- unprojectedRaw,
7926
- recordFile,
7927
- sourceIdentities,
7928
- legacySourcePositions
7929
- };
7930
- }
7931
7713
  async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
7932
7714
  const source = join16(runDirectory, "records.jsonl");
7933
7715
  let content;
@@ -7957,110 +7739,6 @@ function resolveBoundIndex(bound, sessionLines) {
7957
7739
  }
7958
7740
  return void 0;
7959
7741
  }
7960
- function dialogueIdentity(s, id) {
7961
- return `${s}\0${id}`;
7962
- }
7963
- function rangeDeclarationKey(range) {
7964
- return JSON.stringify({
7965
- from: range.from,
7966
- to: range.to
7967
- });
7968
- }
7969
- function mergeSessionBounds(prior, incoming) {
7970
- const merged = [];
7971
- const indexByIdentity = /* @__PURE__ */ new Map();
7972
- const absorb = (sessions) => {
7973
- const indexes = [];
7974
- for (const session of sessions) {
7975
- const identity = physicalPathIdentity(session.path);
7976
- let targetIndex = indexByIdentity.get(identity);
7977
- if (targetIndex === void 0) {
7978
- targetIndex = merged.length;
7979
- indexByIdentity.set(identity, targetIndex);
7980
- merged.push({ path: session.path, ranges: [] });
7981
- }
7982
- indexes.push(targetIndex);
7983
- const target = merged[targetIndex];
7984
- const seen = new Set(target.ranges.map(rangeDeclarationKey));
7985
- for (const range of session.ranges) {
7986
- const key = rangeDeclarationKey(range);
7987
- if (seen.has(key)) continue;
7988
- seen.add(key);
7989
- target.ranges.push({ from: { ...range.from }, to: { ...range.to } });
7990
- }
7991
- }
7992
- return indexes;
7993
- };
7994
- const priorIndexes = absorb(prior ?? []);
7995
- const incomingIndexes = absorb(incoming);
7996
- return { sessions: merged, priorIndexes, incomingIndexes };
7997
- }
7998
- function undeclaredSessionRanges(prior, merged) {
7999
- const priorKeys = /* @__PURE__ */ new Map();
8000
- for (const session of prior ?? []) {
8001
- const identity = physicalPathIdentity(session.path);
8002
- let keys = priorKeys.get(identity);
8003
- if (keys === void 0) {
8004
- keys = /* @__PURE__ */ new Set();
8005
- priorKeys.set(identity, keys);
8006
- }
8007
- for (const range of session.ranges) keys.add(rangeDeclarationKey(range));
8008
- }
8009
- const out = [];
8010
- for (let s = 0; s < merged.length; s += 1) {
8011
- const session = merged[s];
8012
- const identity = physicalPathIdentity(session.path);
8013
- const declared = priorKeys.get(identity) ?? /* @__PURE__ */ new Set();
8014
- const fresh = session.ranges.filter(
8015
- (range) => !declared.has(rangeDeclarationKey(range))
8016
- );
8017
- if (fresh.length === 0) continue;
8018
- out.push({
8019
- s,
8020
- session: {
8021
- path: session.path,
8022
- ranges: fresh.map((range) => ({
8023
- from: { ...range.from },
8024
- to: { ...range.to }
8025
- }))
8026
- }
8027
- });
8028
- }
8029
- return out;
8030
- }
8031
- function mergeFreshIntoCarried(carried, fresh) {
8032
- const seenSources = /* @__PURE__ */ new Map();
8033
- const bySession = /* @__PURE__ */ new Map();
8034
- const absorb = (lines) => {
8035
- for (const line2 of lines) {
8036
- const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
8037
- const identity = sourceIdentity === void 0 ? void 0 : `${line2.s}\0${sourceIdentity}`;
8038
- const seen = identity === void 0 ? void 0 : seenSources.get(identity);
8039
- if (seen !== void 0) {
8040
- if (line2.sourcePosition !== void 0) {
8041
- Object.assign(seen, { sourcePosition: line2.sourcePosition });
8042
- }
8043
- continue;
8044
- }
8045
- const bucket = bySession.get(line2.s) ?? [];
8046
- bucket.push({ ...line2 });
8047
- if (identity !== void 0) seenSources.set(identity, bucket.at(-1));
8048
- bySession.set(line2.s, bucket);
8049
- }
8050
- };
8051
- absorb(carried);
8052
- absorb(fresh);
8053
- return [...bySession.entries()].sort(([left], [right]) => left - right).flatMap(([, lines]) => lines.map((line2, archiveIndex) => ({ line: line2, archiveIndex })).sort((left, right) => {
8054
- const leftPosition = left.line.sourcePosition;
8055
- const rightPosition = right.line.sourcePosition;
8056
- if (leftPosition === void 0 && rightPosition === void 0) {
8057
- return left.archiveIndex - right.archiveIndex;
8058
- }
8059
- if (leftPosition === void 0) return 1;
8060
- if (rightPosition === void 0) return -1;
8061
- return leftPosition - rightPosition || left.archiveIndex - right.archiveIndex;
8062
- }).map(({ line: line2 }) => line2));
8063
- }
8064
7742
  function stableSourceFacts(sessionLines) {
8065
7743
  const positionByIdentity = /* @__PURE__ */ new Map();
8066
7744
  const facts = [];
@@ -8135,13 +7813,7 @@ async function projectSessionRanges(input) {
8135
7813
  const rows = sessionLines.map((entry) => entry.row);
8136
7814
  const dialogue = adaptSessionDialogue(rows);
8137
7815
  const sourceFacts = stableSourceFacts(sessionLines);
8138
- const sourcePositionByIdentity = /* @__PURE__ */ new Map();
8139
- for (const fact of sourceFacts) {
8140
- sourcePositionByIdentity.set(fact.identity, fact.position);
8141
- }
8142
- const seenIds = input.seenIds;
8143
- const lines = [];
8144
- const raw = [];
7816
+ const entries = [];
8145
7817
  const ranges = normalizeResolvedRanges(
8146
7818
  input.session.ranges,
8147
7819
  sessionLines,
@@ -8150,19 +7822,13 @@ async function projectSessionRanges(input) {
8150
7822
  for (const range of ranges) {
8151
7823
  for (let index = range.fromIndex; index <= range.toIndex; index += 1) {
8152
7824
  const { position: sourcePosition, identity: sourceIdentity } = sourceFacts[index];
8153
- if (input.coveredSourceIdentities.has(sourceIdentity) || input.legacyCoveredSourcePositions.has(sourcePosition)) continue;
8154
7825
  const entry = sessionLines[index];
8155
7826
  if (entry.row === void 0) {
8156
- raw.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
7827
+ entries.push({ raw: entry.raw, s: input.s, sourcePosition, sourceIdentity });
8157
7828
  continue;
8158
7829
  }
8159
7830
  for (const event of dialogue[index] ?? []) {
8160
- if (event.id !== void 0) {
8161
- const identity = dialogueIdentity(input.s, event.id);
8162
- if (seenIds.has(identity)) continue;
8163
- seenIds.add(identity);
8164
- }
8165
- lines.push({
7831
+ entries.push({
8166
7832
  speaker: event.speaker,
8167
7833
  s: input.s,
8168
7834
  sourcePosition,
@@ -8172,106 +7838,49 @@ async function projectSessionRanges(input) {
8172
7838
  }
8173
7839
  }
8174
7840
  }
8175
- return { lines, raw, sourcePositionByIdentity };
7841
+ return { entries };
8176
7842
  }
8177
7843
  async function reprojectTicketProvenance(input) {
8178
- const prior = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
7844
+ const recordInput = ticketProvenanceRecordInput(
7845
+ input.ticketNumber,
7846
+ input.cwd,
7847
+ input.home,
7848
+ input.runDirectory
7849
+ );
7850
+ const resolved = resolveSitianRecordPath(recordInput);
8179
7851
  if (input.sessions.length === 0) {
8180
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
8181
7852
  return {
8182
- recordFile: prior.recordFile,
8183
- header: prior.header ?? {
8184
- repo: resolveBookKeyFromGit(input.cwd),
8185
- ticket: input.ticketNumber,
8186
- createdAt: now2,
8187
- updatedAt: now2,
8188
- sessions: []
8189
- },
8190
- lines: prior.lines
8191
- };
8192
- }
8193
- const merged = mergeSessionBounds(prior.header?.sessions, input.sessions);
8194
- const deltas = undeclaredSessionRanges(prior.header?.sessions, merged.sessions);
8195
- if (deltas.length === 0) {
8196
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
8197
- return {
8198
- recordFile: prior.recordFile,
8199
- header: prior.header ?? {
8200
- repo: resolveBookKeyFromGit(input.cwd),
8201
- ticket: input.ticketNumber,
8202
- createdAt: now2,
8203
- updatedAt: now2,
8204
- sessions: merged.sessions
8205
- },
8206
- lines: prior.lines
7853
+ recordFile: resolved.recordFile,
7854
+ lines: []
8207
7855
  };
8208
7856
  }
8209
- const seenIds = new Set(
8210
- prior.lines.flatMap(
8211
- (line2) => line2.id === void 0 ? [] : [dialogueIdentity(line2.s, line2.id)]
8212
- )
8213
- );
8214
- const fresh = [];
8215
- const raw = [];
8216
- for (const delta of deltas) {
7857
+ const entries = [];
7858
+ for (let s = 0; s < input.sessions.length; s += 1) {
7859
+ const session = input.sessions[s];
8217
7860
  const projected = await projectSessionRanges({
8218
- s: delta.s,
8219
- session: delta.session,
8220
- seenIds,
8221
- coveredSourceIdentities: prior.sourceIdentities.get(delta.s) ?? /* @__PURE__ */ new Set(),
8222
- legacyCoveredSourcePositions: prior.legacySourcePositions.get(delta.s) ?? /* @__PURE__ */ new Set(),
7861
+ s,
7862
+ session,
8223
7863
  ...input.home === void 0 ? {} : { home: input.home }
8224
7864
  });
8225
- fresh.push(...prior.lines.flatMap((line2) => {
8226
- if (line2.s !== delta.s) return [];
8227
- const sourceIdentity = line2.id === void 0 ? line2.sourceIdentity : `id\0${line2.id}`;
8228
- if (sourceIdentity === void 0) return [];
8229
- const sourcePosition = projected.sourcePositionByIdentity.get(sourceIdentity);
8230
- return sourcePosition === void 0 ? [] : [{ ...line2, sourcePosition }];
8231
- }));
8232
- fresh.push(...projected.lines);
8233
- raw.push(...projected.raw);
8234
- }
8235
- const lines = mergeFreshIntoCarried(prior.lines, fresh);
8236
- const now = (/* @__PURE__ */ new Date()).toISOString();
8237
- const header = {
8238
- repo: prior.header?.repo ?? resolveBookKeyFromGit(input.cwd),
8239
- ticket: input.ticketNumber,
8240
- createdAt: prior.header?.createdAt ?? now,
8241
- updatedAt: now,
8242
- sessions: merged.sessions
8243
- };
8244
- const identityMaterial = JSON.stringify({
8245
- ticket: input.ticketNumber,
8246
- deltas: deltas.map(({ s, session }) => ({
8247
- s,
8248
- path: physicalPathIdentity(session.path),
8249
- ranges: session.ranges
8250
- })),
8251
- lines: [...fresh, ...raw]
8252
- });
8253
- const identity = `ticket-provenance:${createHash6("sha256").update(identityMaterial).digest("hex")}`;
7865
+ entries.push(...projected.entries);
7866
+ }
8254
7867
  const pointer = appendSitianRecord({
8255
- ...ticketProvenanceRecordInput(input.ticketNumber, input.cwd, input.home, input.runDirectory),
8256
- identity,
7868
+ ...recordInput,
8257
7869
  payload: {
8258
7870
  type: "ticket-provenance-append",
8259
- sessions: merged.sessions,
8260
- lines: [...fresh, ...raw]
7871
+ sessions: input.sessions,
7872
+ lines: entries
8261
7873
  }
8262
7874
  });
8263
- const folded = await readTicketProvenance(input.ticketNumber, input.cwd, input.home, input.runDirectory);
8264
7875
  return {
8265
7876
  recordFile: pointer.recordFile,
8266
- header: folded.header ?? header,
8267
- lines: folded.lines
7877
+ lines: entries.filter((entry) => "speaker" in entry)
8268
7878
  };
8269
7879
  }
8270
7880
  var TicketProvenanceInputError;
8271
7881
  var init_ticket_provenance = __esm({
8272
7882
  "src/ticket-provenance.ts"() {
8273
7883
  "use strict";
8274
- init_activation_ledger_git();
8275
7884
  init_activation_ledger_topology();
8276
7885
  init_ledger_session_read();
8277
7886
  init_run_ticket_number();
@@ -12040,17 +11649,8 @@ async function restoreState(cwd, runId, scope) {
12040
11649
  }
12041
11650
  return { sequence: 0 };
12042
11651
  }
12043
- const { file, owned } = located;
12044
- const last = owned.at(-1);
11652
+ const { owned } = located;
12045
11653
  return {
12046
- ...last === void 0 ? {} : {
12047
- prior: {
12048
- identity: last.identity,
12049
- recordFile: file,
12050
- kind: last.kind,
12051
- level: last.level
12052
- }
12053
- },
12054
11654
  sequence: owned.reduce((maximum, record4) => {
12055
11655
  const payload = record4.payload;
12056
11656
  return payload?.type === "candidate" && typeof payload.sequence === "number" ? Math.max(maximum, payload.sequence) : maximum;
@@ -12078,15 +11678,10 @@ async function sealAcceptedSubmission(options) {
12078
11678
  const attemptId = attemptIdentity(options.context, runId);
12079
11679
  const sessionParent = sessionParentFromHostContext(options.context);
12080
11680
  const home = homeFromHostContext(options.context, options.home);
12081
- const state = await restoreState(options.context.cwd, runId, {
12082
- ...home === void 0 ? {} : { home },
12083
- ...sessionParent === void 0 ? {} : { sessionParent }
12084
- });
12085
- const pointer = sitianReport({
11681
+ sitianReport({
12086
11682
  level: "event",
12087
11683
  kind: "sealed",
12088
11684
  subject: { runId, attemptId },
12089
- ...state.prior === void 0 ? {} : { priorEventId: state.prior.identity },
12090
11685
  payload: {
12091
11686
  type: "sealed",
12092
11687
  attemptId,
@@ -12099,7 +11694,6 @@ async function sealAcceptedSubmission(options) {
12099
11694
  ...home !== void 0 ? { home } : {},
12100
11695
  ...sessionParent === void 0 ? {} : { sessionParent }
12101
11696
  });
12102
- state.prior = pointer;
12103
11697
  }
12104
11698
  function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (error) => {
12105
11699
  throw error;
@@ -12116,31 +11710,28 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
12116
11710
  states.set(runId, pending);
12117
11711
  return pending;
12118
11712
  })();
12119
- const appendFor = (state, context, runId, attemptId, event) => {
11713
+ const appendFor = (context, runId, attemptId, event) => {
12120
11714
  const home = resolveHomeFromContext(context);
12121
11715
  const sessionParent = sessionParentFromHostContext(context);
12122
- const pointer = sitianReport({
11716
+ return sitianReport({
12123
11717
  level: "event",
12124
11718
  kind: event.type,
12125
11719
  subject: { runId, attemptId },
12126
- ...state.prior === void 0 ? {} : { priorEventId: state.prior.identity },
12127
11720
  payload: event,
12128
11721
  source: "role-runtime",
12129
11722
  cwd: context.cwd,
12130
11723
  ...home !== void 0 ? { home } : {},
12131
11724
  ...sessionParent === void 0 ? {} : { sessionParent }
12132
11725
  });
12133
- state.prior = pointer;
12134
- return pointer;
12135
11726
  };
12136
11727
  host.on("turn_end", async (event, context) => {
12137
11728
  try {
12138
11729
  const runId = runIdentity(context);
12139
11730
  const attemptId = attemptIdentity(context, runId);
12140
- const state = await stateFor(context, runId);
12141
11731
  const calls = event.calls.map(({ toolCallId: id, toolName: name }) => ({ id, name }));
12142
11732
  if (calls.length > 0) {
12143
- appendFor(state, context, runId, attemptId, { type: "roundContext", attemptId, calls });
11733
+ await stateFor(context, runId);
11734
+ appendFor(context, runId, attemptId, { type: "roundContext", attemptId, calls });
12144
11735
  }
12145
11736
  } catch (error) {
12146
11737
  failInfrastructure2(error, context);
@@ -12164,7 +11755,7 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
12164
11755
  const runId = runIdentity(context);
12165
11756
  const attemptId = attemptIdentity(context, runId);
12166
11757
  const state = await stateFor(context, runId);
12167
- const append = (event) => appendFor(state, context, runId, attemptId, event);
11758
+ const append = (event) => appendFor(context, runId, attemptId, event);
12168
11759
  append({
12169
11760
  type: "candidate",
12170
11761
  attemptId,
@@ -19920,7 +19511,7 @@ var init_analyst_metric_family = __esm({
19920
19511
  });
19921
19512
 
19922
19513
  // src/analyst-page.ts
19923
- import { createHash as createHash7 } from "node:crypto";
19514
+ import { createHash as createHash6 } from "node:crypto";
19924
19515
  import { dirname as dirname22, join as join37 } from "node:path";
19925
19516
  function analystIssuePageKey(address) {
19926
19517
  const parts = ["book", address.bookKey];
@@ -19929,7 +19520,7 @@ function analystIssuePageKey(address) {
19929
19520
  } else if (address.scopeRootIdentity !== void 0) {
19930
19521
  parts.push("root", physicalPathIdentity(address.scopeRootIdentity));
19931
19522
  }
19932
- return createHash7("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
19523
+ return createHash6("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
19933
19524
  }
19934
19525
  function analystIssuePagePath(ledgerHome, address) {
19935
19526
  return join37(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
@@ -23367,7 +22958,7 @@ var init_run_lifecycle = __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 join42 } 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: join42(
@@ -23758,7 +23349,7 @@ import { readFile as readFile26 } from "node:fs/promises";
23758
23349
  import { join as join47 } from "node:path";
23759
23350
 
23760
23351
  // src/navigator-attendance.ts
23761
- import { createHash as createHash9 } from "node:crypto";
23352
+ import { createHash as createHash8 } from "node:crypto";
23762
23353
  init_navigator_invocation_identity();
23763
23354
  init_packaged_role_registry();
23764
23355
  init_activation_ledger_topology();
@@ -24319,7 +23910,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
24319
23910
  if (provenance === "placeholder") return subjectRoot;
24320
23911
  const normalized = subject.trim().replace(/\s+/g, " ");
24321
23912
  if (normalized === "") return subjectRoot;
24322
- return `${subjectRoot}#${createHash9("sha256").update(normalized).digest("hex").slice(0, 32)}`;
23913
+ return `${subjectRoot}#${createHash8("sha256").update(normalized).digest("hex").slice(0, 32)}`;
24323
23914
  }
24324
23915
  function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
24325
23916
  if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
@@ -24821,9 +24412,9 @@ init_sitian_facade();
24821
24412
  init_submission_ledger();
24822
24413
  init_collector_ledger();
24823
24414
  import { randomUUID as randomUUID8 } from "node:crypto";
24824
- import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
24415
+ import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
24825
24416
  import { join as join46 } from "node:path";
24826
- import { Value as Value5 } from "typebox/value";
24417
+ import { Value as Value4 } from "typebox/value";
24827
24418
 
24828
24419
  // src/activation-trace.ts
24829
24420
  import { Type as Type14 } from "typebox";
@@ -24993,118 +24584,6 @@ function writeStderrJsonlRecord(record4, write = writeSync) {
24993
24584
  }
24994
24585
  }
24995
24586
 
24996
- // src/tool-execution-observation.ts
24997
- import { writeSync as writeSync2 } from "node:fs";
24998
- import { Type as Type15 } from "typebox";
24999
- import { Value as Value4 } from "typebox/value";
25000
- var TOOL_EXECUTION_UPDATE_THROTTLE_MS = 3e4;
25001
- var observationBase = {
25002
- role: Type15.String({ minLength: 1 }),
25003
- toolCallId: Type15.String({ minLength: 1 }),
25004
- toolName: Type15.String({ minLength: 1 }),
25005
- timestamp: Type15.String({ format: "date-time" })
25006
- };
25007
- var toolExecutionObservationRecordSchema = Type15.Union([
25008
- Type15.Object({
25009
- ...observationBase,
25010
- event: Type15.Literal("tool_execution_start")
25011
- }, { additionalProperties: true }),
25012
- Type15.Object({
25013
- ...observationBase,
25014
- event: Type15.Literal("tool_execution_update")
25015
- }, { additionalProperties: true }),
25016
- Type15.Object({
25017
- ...observationBase,
25018
- event: Type15.Literal("tool_execution_end"),
25019
- isError: Type15.Boolean()
25020
- }, { additionalProperties: true })
25021
- ]);
25022
- function validateToolExecutionObservationRecord(record4) {
25023
- if (!Value4.Check(toolExecutionObservationRecordSchema, record4)) {
25024
- throw new TypeError("Tool execution observation record does not match its contract");
25025
- }
25026
- return record4;
25027
- }
25028
- function writeToolExecutionObservationRecord(record4, write = writeSync2) {
25029
- writeStderrJsonlRecord(validateToolExecutionObservationRecord(record4), write);
25030
- }
25031
- function isProducingToolUpdate(partialResult) {
25032
- if (partialResult == null) return false;
25033
- if (typeof partialResult !== "object") return true;
25034
- const content = partialResult.content;
25035
- if (!Array.isArray(content)) return true;
25036
- if (content.length === 0) return false;
25037
- return content.some((part) => {
25038
- if (typeof part !== "object" || part === null) return true;
25039
- const text = part.text;
25040
- if (typeof text === "string") return text.length > 0;
25041
- return true;
25042
- });
25043
- }
25044
- function systemToolExecutionObservationMonoNow() {
25045
- return performance.now();
25046
- }
25047
- function createToolExecutionObservationFace(options) {
25048
- const states = /* @__PURE__ */ new Map();
25049
- async function emit(record4) {
25050
- await options.write(validateToolExecutionObservationRecord(record4));
25051
- }
25052
- function activeRole() {
25053
- if (!options.admitted()) return void 0;
25054
- const role = options.role();
25055
- return role === void 0 || role === "" ? void 0 : role;
25056
- }
25057
- return {
25058
- reset() {
25059
- states.clear();
25060
- },
25061
- async onStart(event) {
25062
- const role = activeRole();
25063
- if (role === void 0) return;
25064
- states.set(event.toolCallId, { lastUpdateEmitMonoMs: void 0 });
25065
- await emit({
25066
- event: "tool_execution_start",
25067
- role,
25068
- toolCallId: event.toolCallId,
25069
- toolName: event.toolName,
25070
- timestamp: options.clock()
25071
- });
25072
- },
25073
- async onUpdate(event) {
25074
- const role = activeRole();
25075
- if (role === void 0) return;
25076
- if (!isProducingToolUpdate(event.partialResult)) return;
25077
- const now = options.monoNow();
25078
- const state = states.get(event.toolCallId) ?? { lastUpdateEmitMonoMs: void 0 };
25079
- if (state.lastUpdateEmitMonoMs !== void 0 && now - state.lastUpdateEmitMonoMs < TOOL_EXECUTION_UPDATE_THROTTLE_MS) {
25080
- return;
25081
- }
25082
- state.lastUpdateEmitMonoMs = now;
25083
- states.set(event.toolCallId, state);
25084
- await emit({
25085
- event: "tool_execution_update",
25086
- role,
25087
- toolCallId: event.toolCallId,
25088
- toolName: event.toolName,
25089
- timestamp: options.clock()
25090
- });
25091
- },
25092
- async onEnd(event) {
25093
- const role = activeRole();
25094
- if (role === void 0) return;
25095
- states.delete(event.toolCallId);
25096
- await emit({
25097
- event: "tool_execution_end",
25098
- role,
25099
- toolCallId: event.toolCallId,
25100
- toolName: event.toolName,
25101
- timestamp: options.clock(),
25102
- isError: event.isError
25103
- });
25104
- }
25105
- };
25106
- }
25107
-
25108
24587
  // src/role-runtime.ts
25109
24588
  init_engine_detour();
25110
24589
  init_engine_material();
@@ -25113,10 +24592,10 @@ init_engine_material();
25113
24592
  init_engine_detour();
25114
24593
  init_engine_detour_usage();
25115
24594
  init_run_terminal_artifacts();
25116
- import { Type as Type16 } from "typebox";
25117
- var engineDetourArgsSchema = Type16.Object(
24595
+ import { Type as Type15 } from "typebox";
24596
+ var engineDetourArgsSchema = Type15.Object(
25118
24597
  {
25119
- argv: Type16.Array(Type16.String({ minLength: 1 }), {
24598
+ argv: Type15.Array(Type15.String({ minLength: 1 }), {
25120
24599
  minItems: 1,
25121
24600
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
25122
24601
  })
@@ -25263,63 +24742,63 @@ import { join as join45, sep as sep6 } from "node:path";
25263
24742
  // src/collector-tool-schemas.ts
25264
24743
  init_open_tool_schema();
25265
24744
  init_terminating_infrastructure();
25266
- import { Type as Type17 } from "typebox";
25267
- var collectorObserveArgsSchema = Type17.Object({}, { additionalProperties: true });
25268
- var collectorRequestArgsSchema = Type17.Object({
25269
- requestId: Type17.String({
24745
+ import { Type as Type16 } from "typebox";
24746
+ var collectorObserveArgsSchema = Type16.Object({}, { additionalProperties: true });
24747
+ var collectorRequestArgsSchema = Type16.Object({
24748
+ requestId: Type16.String({
25270
24749
  minLength: 1,
25271
24750
  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"
25272
24751
  }),
25273
- snapshotId: Type17.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
24752
+ snapshotId: Type16.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" }),
25274
24753
  // #836 r16 class 3: body.minLength deleted — manifest-configured requestId
25275
24754
  // ignores body, and the unknown-requestId non-empty condition is a real
25276
24755
  // branch in src/collector-ledger.ts:922-951, not a provider shape gate.
25277
- body: Type17.Optional(Type17.String({
24756
+ body: Type16.Optional(Type16.String({
25278
24757
  description: "\u89D2\u8272\u5224\u5B9A\u7684\u8BF7\u6C42\u6B63\u6587\uFF1Brequest-manifest \u672A\u6536\u5F55\u8BE5 requestId \u65F6\u5FC5\u586B"
25279
24758
  }))
25280
24759
  }, { additionalProperties: true });
25281
24760
  var COLLECTOR_HANDBOOK_MAX_BYTES = 64 * 1024;
25282
- var collectorHandbookWriteArgsSchema = Type17.Object({
25283
- scope: Type17.Union([
25284
- Type17.Literal("general"),
25285
- Type17.Literal("repo")
24761
+ var collectorHandbookWriteArgsSchema = Type16.Object({
24762
+ scope: Type16.Union([
24763
+ Type16.Literal("general"),
24764
+ Type16.Literal("repo")
25286
24765
  ], { description: "general\uFF1D\u901A\u7528\u624B\u518C\uFF1Brepo\uFF1D\u5F53\u524D\u4ED3\u5E93\u5DEE\u5F02" }),
25287
- body: Type17.String({
24766
+ body: Type16.String({
25288
24767
  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`
25289
24768
  })
25290
24769
  }, { additionalProperties: true });
25291
- var collectorReadArgsSchema = Type17.Object({
25292
- evidenceId: Type17.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
24770
+ var collectorReadArgsSchema = Type16.Object({
24771
+ evidenceId: Type16.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
25293
24772
  }, { additionalProperties: true });
25294
- var collectorWaitArgsSchema = Type17.Object({
25295
- durationMs: Type17.Integer({
24773
+ var collectorWaitArgsSchema = Type16.Object({
24774
+ durationMs: Type16.Integer({
25296
24775
  minimum: 1,
25297
24776
  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"
25298
24777
  })
25299
24778
  }, { additionalProperties: true });
25300
- var collectorOpenWaitWindowArgsSchema = Type17.Object({
25301
- startedAt: Type17.Optional(Type17.String({
24779
+ var collectorOpenWaitWindowArgsSchema = Type16.Object({
24780
+ startedAt: Type16.Optional(Type16.String({
25302
24781
  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"
25303
24782
  }))
25304
24783
  }, { additionalProperties: true });
25305
- var collectorBindTargetArgsSchema = Type17.Object({
25306
- prNumber: Type17.Optional(Type17.Unknown({
24784
+ var collectorBindTargetArgsSchema = Type16.Object({
24785
+ prNumber: Type16.Optional(Type16.Unknown({
25307
24786
  description: "\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
25308
24787
  })),
25309
- issueNumber: Type17.Optional(Type17.Unknown({
24788
+ issueNumber: Type16.Optional(Type16.Unknown({
25310
24789
  description: "\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
25311
24790
  }))
25312
24791
  }, { additionalProperties: true });
25313
24792
  var collectorFindingItemDeclaration = (() => {
25314
- const item = Type17.Object(
24793
+ const item = Type16.Object(
25315
24794
  {
25316
- evidenceId: Type17.Unknown({
24795
+ evidenceId: Type16.Unknown({
25317
24796
  description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u6307\u9488\uFF08\u5FC5\u586B\u8BED\u4E49\uFF09"
25318
24797
  }),
25319
- category: Type17.Unknown({
24798
+ category: Type16.Unknown({
25320
24799
  description: "\u7B80\u77ED\u5F52\u7C7B\u6807\u7B7E\uFF0C\u4E0D\u662F\u6458\u8981"
25321
24800
  }),
25322
- summary: Type17.Unknown({
24801
+ summary: Type16.Unknown({
25323
24802
  description: "\u54EA\u4E2A bot\u3001\u4EC0\u4E48\u95EE\u9898\u7684\u6458\u8981\uFF1B\u4E0D\u8A8A\u6284\u6B63\u6587"
25324
24803
  })
25325
24804
  },
@@ -25332,14 +24811,14 @@ var collectorFindingItemDeclaration = (() => {
25332
24811
  return item;
25333
24812
  })();
25334
24813
  var collectorOutputBaseSchema = openToolObject(
25335
- Type17.Object({
24814
+ Type16.Object({
25336
24815
  // No root type:array — host must not shape-reject non-array findings (#676 C).
25337
24816
  // Nested item declarations ride `items` for registration preservation (ADR 0057).
25338
- findings: Type17.Unsafe({
24817
+ findings: Type16.Unsafe({
25339
24818
  description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings \u6307\u9488\u3002",
25340
24819
  items: collectorFindingItemDeclaration
25341
24820
  }),
25342
- unfinishedReasons: Type17.Unknown({
24821
+ unfinishedReasons: Type16.Unknown({
25343
24822
  description: "\u672A\u5B8C\u6210\u539F\u56E0\u3002"
25344
24823
  })
25345
24824
  })
@@ -26181,18 +25660,18 @@ init_open_tool_schema();
26181
25660
  init_terminating_infrastructure();
26182
25661
  init_gleaner_left_contracts();
26183
25662
  init_gleaner_left_contracts();
26184
- import { Type as Type18 } from "typebox";
25663
+ import { Type as Type17 } from "typebox";
26185
25664
  var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
26186
25665
  openToolObject(
26187
- Type18.Object({
26188
- status: Type18.Unknown({
25666
+ Type17.Object({
25667
+ status: Type17.Unknown({
26189
25668
  description: "completed"
26190
25669
  }),
26191
- findings: Type18.Array(
26192
- Type18.Object(
25670
+ findings: Type17.Array(
25671
+ Type17.Object(
26193
25672
  {
26194
- pointer: Type18.Optional(Type18.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
26195
- statement: Type18.Optional(Type18.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
25673
+ pointer: Type17.Optional(Type17.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
25674
+ statement: Type17.Optional(Type17.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
26196
25675
  },
26197
25676
  { additionalProperties: true, description: "\u4E00\u6761\u5F39\u7AE0" }
26198
25677
  ),
@@ -26232,44 +25711,44 @@ init_open_tool_schema();
26232
25711
  init_terminating_infrastructure();
26233
25712
  init_diarist_contracts();
26234
25713
  init_diarist_contracts();
26235
- import { Type as Type19 } from "typebox";
25714
+ import { Type as Type18 } from "typebox";
26236
25715
  var diaristOutputSchema = withTerminatingOutputDeclarations(
26237
25716
  openToolObject(
26238
- Type19.Object({
26239
- status: Type19.Unknown({
25717
+ Type18.Object({
25718
+ status: Type18.Unknown({
26240
25719
  description: "completed | escalate"
26241
25720
  }),
26242
- ticketNumber: Type19.Optional(
26243
- Type19.Unknown({
25721
+ ticketNumber: Type18.Optional(
25722
+ Type18.Unknown({
26244
25723
  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"
26245
25724
  })
26246
25725
  ),
26247
- courtTicketNumbers: Type19.Optional(
26248
- Type19.Unknown({
25726
+ courtTicketNumbers: Type18.Optional(
25727
+ Type18.Unknown({
26249
25728
  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"
26250
25729
  })
26251
25730
  ),
26252
- reason: Type19.Optional(
26253
- Type19.String({
25731
+ reason: Type18.Optional(
25732
+ Type18.String({
26254
25733
  description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
26255
25734
  })
26256
25735
  ),
26257
- sessions: Type19.Optional(
26258
- Type19.Array(
26259
- Type19.Object(
25736
+ sessions: Type18.Optional(
25737
+ Type18.Array(
25738
+ Type18.Object(
26260
25739
  {
26261
- path: Type19.Optional(
26262
- Type19.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
25740
+ path: Type18.Optional(
25741
+ Type18.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })
26263
25742
  ),
26264
- ranges: Type19.Optional(
26265
- Type19.Array(
26266
- Type19.Object(
25743
+ ranges: Type18.Optional(
25744
+ Type18.Array(
25745
+ Type18.Object(
26267
25746
  {
26268
- from: Type19.Optional(
26269
- Type19.Object(
25747
+ from: Type18.Optional(
25748
+ Type18.Object(
26270
25749
  {
26271
- id: Type19.Optional(Type19.String()),
26272
- line: Type19.Optional(Type19.Unknown())
25750
+ id: Type18.Optional(Type18.String()),
25751
+ line: Type18.Optional(Type18.Unknown())
26273
25752
  },
26274
25753
  {
26275
25754
  additionalProperties: true,
@@ -26277,11 +25756,11 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
26277
25756
  }
26278
25757
  )
26279
25758
  ),
26280
- to: Type19.Optional(
26281
- Type19.Object(
25759
+ to: Type18.Optional(
25760
+ Type18.Object(
26282
25761
  {
26283
- id: Type19.Optional(Type19.String()),
26284
- line: Type19.Optional(Type19.Unknown())
25762
+ id: Type18.Optional(Type18.String()),
25763
+ line: Type18.Optional(Type18.Unknown())
26285
25764
  },
26286
25765
  {
26287
25766
  additionalProperties: true,
@@ -26318,23 +25797,23 @@ var DIARIST_TOOL_SPEC = {
26318
25797
  init_terminating_infrastructure();
26319
25798
  init_secretariat_contracts();
26320
25799
  init_secretariat_contracts();
26321
- import { Type as Type20 } from "typebox";
25800
+ import { Type as Type19 } from "typebox";
26322
25801
  var secretariatVerdictSchema = withTerminatingOutputDeclarations(
26323
- Type20.Object(
25802
+ Type19.Object(
26324
25803
  {
26325
- secretariatStatus: Type20.Unknown({
25804
+ secretariatStatus: Type19.Unknown({
26326
25805
  description: "converged | escalate"
26327
25806
  }),
26328
- ticketNumber: Type20.Optional(
26329
- Type20.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
25807
+ ticketNumber: Type19.Optional(
25808
+ Type19.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
26330
25809
  ),
26331
- note: Type20.Optional(Type20.String({ description: "\u9644\u6CE8" })),
26332
- evidence: Type20.Optional(Type20.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
26333
- decisionGate: Type20.Optional(
26334
- Type20.Object(
25810
+ note: Type19.Optional(Type19.String({ description: "\u9644\u6CE8" })),
25811
+ evidence: Type19.Optional(Type19.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
25812
+ decisionGate: Type19.Optional(
25813
+ Type19.Object(
26335
25814
  {
26336
- question: Type20.Optional(Type20.String()),
26337
- options: Type20.Optional(Type20.Array(Type20.String()))
25815
+ question: Type19.Optional(Type19.String()),
25816
+ options: Type19.Optional(Type19.Array(Type19.String()))
26338
25817
  },
26339
25818
  { additionalProperties: true, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
26340
25819
  )
@@ -26409,12 +25888,12 @@ init_judge_role();
26409
25888
  init_open_tool_schema();
26410
25889
  init_terminating_infrastructure();
26411
25890
  init_reviewer_output();
26412
- import { Type as Type21 } from "typebox";
26413
- var reviewerAmendmentsSchema = Type21.Object({
26414
- completeness: Type21.Optional(Type21.String({
25891
+ import { Type as Type20 } from "typebox";
25892
+ var reviewerAmendmentsSchema = Type20.Object({
25893
+ completeness: Type20.Optional(Type20.String({
26415
25894
  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"
26416
25895
  })),
26417
- correctness: Type21.Optional(Type21.String({
25896
+ correctness: Type20.Optional(Type20.String({
26418
25897
  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"
26419
25898
  }))
26420
25899
  }, {
@@ -26422,15 +25901,15 @@ var reviewerAmendmentsSchema = Type21.Object({
26422
25901
  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"
26423
25902
  });
26424
25903
  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";
26425
- var reviewerOutputVariants = Type21.Union([
26426
- Type21.Object({
26427
- status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26428
- amendments: Type21.Optional(reviewerAmendmentsSchema)
25904
+ var reviewerOutputVariants = Type20.Union([
25905
+ Type20.Object({
25906
+ status: Type20.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
25907
+ amendments: Type20.Optional(reviewerAmendmentsSchema)
26429
25908
  }, { additionalProperties: false }),
26430
- Type21.Object({
26431
- status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
26432
- 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" }),
26433
- amendments: Type21.Optional(reviewerAmendmentsSchema)
25909
+ Type20.Object({
25910
+ status: Type20.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
25911
+ 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" }),
25912
+ amendments: Type20.Optional(reviewerAmendmentsSchema)
26434
25913
  }, { additionalProperties: false })
26435
25914
  ]);
26436
25915
  var reviewerOutputSchema = withTerminatingOutputDeclarations(
@@ -26479,7 +25958,7 @@ init_terminating_infrastructure();
26479
25958
  init_worker_output();
26480
25959
  init_fixer_output();
26481
25960
  init_fixer_packet();
26482
- import { Type as Type22 } from "typebox";
25961
+ import { Type as Type21 } from "typebox";
26483
25962
 
26484
25963
  // src/worker-submission-gates.ts
26485
25964
  init_archivist_record_entry();
@@ -26745,20 +26224,20 @@ function fixerBashSeatbeltDenyReason(matched) {
26745
26224
 
26746
26225
  // src/worker-role.ts
26747
26226
  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";
26748
- var coderOutputVariants = Type22.Union([
26749
- Type22.Object({
26750
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26751
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26227
+ var coderOutputVariants = Type21.Union([
26228
+ Type21.Object({
26229
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26230
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26752
26231
  }, { additionalProperties: false }),
26753
- Type22.Object({
26754
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26755
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26232
+ Type21.Object({
26233
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26234
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
26756
26235
  }, { additionalProperties: false }),
26757
- Type22.Object({
26758
- status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26759
- report: Type22.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26760
- remainingScope: Type22.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26761
- reason: Type22.Optional(Type22.String({
26236
+ Type21.Object({
26237
+ status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
26238
+ report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
26239
+ remainingScope: Type21.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
26240
+ reason: Type21.Optional(Type21.String({
26762
26241
  minLength: 1,
26763
26242
  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"
26764
26243
  }))
@@ -27206,7 +26685,7 @@ function activationStage(role, activate) {
27206
26685
  };
27207
26686
  }
27208
26687
  function validateActivationTraceRecord(record4) {
27209
- if (!Value5.Check(activationTraceRecordSchema, record4)) {
26688
+ if (!Value4.Check(activationTraceRecordSchema, record4)) {
27210
26689
  throw new TypeError("Activation trace record does not match its closed contract");
27211
26690
  }
27212
26691
  return record4;
@@ -27232,7 +26711,7 @@ async function executeActivationStage(role, stage, infrastructure) {
27232
26711
  throw activationError;
27233
26712
  }
27234
26713
  }
27235
- function writeActivationTraceRecord(record4, write = writeSync3) {
26714
+ function writeActivationTraceRecord(record4, write = writeSync2) {
27236
26715
  writeStderrJsonlRecord(record4, write);
27237
26716
  }
27238
26717
  var ActivationBarrierError = class extends Error {
@@ -28009,7 +27488,6 @@ function createRoleRuntimeExtension(dependencies) {
28009
27488
  disposeNavigatorAttendanceNonBlocking(attendanceToDispose);
28010
27489
  pendingInfrastructureFailures.clear();
28011
27490
  pendingSubmissionNonPassByToolCallId.clear();
28012
- observationFace.reset();
28013
27491
  });
28014
27492
  const hostActions = {
28015
27493
  failInfrastructure(error, ctx, toolCallId) {
@@ -28225,29 +27703,6 @@ function createRoleRuntimeExtension(dependencies) {
28225
27703
  };
28226
27704
  const clock = dependencies.activationClock ?? (() => (/* @__PURE__ */ new Date()).toISOString());
28227
27705
  const writeTrace = dependencies.activationTraceWriter ?? writeActivationTraceRecord;
28228
- const observationFace = createToolExecutionObservationFace({
28229
- role: () => selectedRole,
28230
- admitted: () => admitted,
28231
- clock: dependencies.toolExecutionObservationClock ?? clock,
28232
- monoNow: dependencies.toolExecutionObservationMonoNow ?? systemToolExecutionObservationMonoNow,
28233
- write: dependencies.toolExecutionObservationWriter ?? writeToolExecutionObservationRecord
28234
- });
28235
- const observe = async (run, ctx) => {
28236
- try {
28237
- await run();
28238
- } catch (error) {
28239
- failInfrastructure(error, ctx);
28240
- }
28241
- };
28242
- roleHost.on("tool_execution_start", async (event, ctx) => {
28243
- await observe(() => observationFace.onStart(event), ctx);
28244
- });
28245
- roleHost.on("tool_execution_update", async (event, ctx) => {
28246
- await observe(() => observationFace.onUpdate(event), ctx);
28247
- });
28248
- roleHost.on("tool_execution_end", async (event, ctx) => {
28249
- await observe(() => observationFace.onEnd(event), ctx);
28250
- });
28251
27706
  const recordHttpObservation = async (status, provider, ctx) => {
28252
27707
  const runDir = runDirectoryFromHostContext(ctx);
28253
27708
  if (runDir === void 0) return;
@@ -28296,7 +27751,6 @@ function createRoleRuntimeExtension(dependencies) {
28296
27751
  collectorFirstDispatchDone = false;
28297
27752
  receiptDelivery = createReceiptDeliveryPolicy();
28298
27753
  noReceiptRecorded = false;
28299
- observationFace.reset();
28300
27754
  pendingNavigatorPresentation = void 0;
28301
27755
  pendingNavigatorSettlement = void 0;
28302
27756
  pendingInfrastructureFailures.clear();