omnius 1.0.926 → 1.0.927

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/library.js CHANGED
@@ -78254,40 +78254,86 @@ function extractQueryEntities(query) {
78254
78254
  return entities;
78255
78255
  }
78256
78256
  function personalizedPageRank(graph, seedNodeIds, config2) {
78257
+ return personalizedPageRankSnapshot(graph, seedNodeIds, config2).scores;
78258
+ }
78259
+ function personalizedPageRankSnapshot(graph, seedNodeIds, config2) {
78257
78260
  const cfg = { ...DEFAULT_CONFIG3, ...config2 };
78258
78261
  const scores = /* @__PURE__ */ new Map();
78262
+ const adjacency = /* @__PURE__ */ new Map();
78263
+ const empty = { scores, adjacency, assertTime: () => {
78264
+ } };
78259
78265
  if (seedNodeIds.length === 0)
78260
- return scores;
78266
+ return empty;
78261
78267
  const nodeCount = graph.nodeCount();
78262
78268
  if (nodeCount === 0)
78263
- return scores;
78269
+ return empty;
78270
+ const positiveBudget = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : fallback;
78271
+ const maxNodes = positiveBudget(cfg.maxNodes, DEFAULT_CONFIG3.maxNodes);
78272
+ const maxEdges = positiveBudget(cfg.maxEdges, DEFAULT_CONFIG3.maxEdges);
78273
+ const maxDurationMs = typeof cfg.maxDurationMs === "number" && Number.isFinite(cfg.maxDurationMs) && cfg.maxDurationMs > 0 ? cfg.maxDurationMs : DEFAULT_CONFIG3.maxDurationMs;
78274
+ const deadline = performance.now() + maxDurationMs;
78275
+ const assertTime = () => {
78276
+ if (performance.now() >= deadline)
78277
+ throw new PPRTraversalBudgetError("time", maxDurationMs);
78278
+ };
78279
+ let edgeRows = 0;
78280
+ const edgesFor = (nodeId2) => {
78281
+ assertTime();
78282
+ const cached = adjacency.get(nodeId2);
78283
+ if (cached)
78284
+ return cached;
78285
+ if (adjacency.size >= maxNodes)
78286
+ throw new PPRTraversalBudgetError("nodes", maxNodes);
78287
+ const remaining = maxEdges - edgeRows;
78288
+ const edges = graph.currentEdges(nodeId2, remaining + 1);
78289
+ assertTime();
78290
+ if (edges.length > remaining)
78291
+ throw new PPRTraversalBudgetError("edges", maxEdges);
78292
+ edgeRows += edges.length;
78293
+ adjacency.set(nodeId2, edges);
78294
+ return edges;
78295
+ };
78264
78296
  const teleportProb = 1 / seedNodeIds.length;
78265
78297
  const seedSet = new Set(seedNodeIds);
78266
78298
  const allNodes = /* @__PURE__ */ new Set();
78299
+ const expandedNeighbors = /* @__PURE__ */ new Set();
78300
+ const addNode = (nodeId2) => {
78301
+ if (!allNodes.has(nodeId2) && allNodes.size >= maxNodes)
78302
+ throw new PPRTraversalBudgetError("nodes", maxNodes);
78303
+ allNodes.add(nodeId2);
78304
+ };
78267
78305
  for (const seedId of seedNodeIds) {
78268
- allNodes.add(seedId);
78269
- const neighbors2 = graph.neighbors(seedId);
78270
- for (const { node } of neighbors2) {
78271
- allNodes.add(node.id);
78272
- const hop2 = graph.neighbors(node.id);
78273
- for (const { node: n2 } of hop2)
78274
- allNodes.add(n2.id);
78306
+ addNode(seedId);
78307
+ for (const edge of edgesFor(seedId)) {
78308
+ const neighborId = edge.srcId === seedId ? edge.dstId : edge.srcId;
78309
+ addNode(neighborId);
78310
+ if (!expandedNeighbors.has(neighborId)) {
78311
+ expandedNeighbors.add(neighborId);
78312
+ for (const hop2 of edgesFor(neighborId))
78313
+ addNode(hop2.srcId === neighborId ? hop2.dstId : hop2.srcId);
78314
+ }
78275
78315
  }
78276
78316
  }
78317
+ for (const nodeId2 of allNodes)
78318
+ edgesFor(nodeId2);
78277
78319
  for (const nodeId2 of allNodes) {
78278
78320
  scores.set(nodeId2, seedSet.has(nodeId2) ? teleportProb : 0);
78279
78321
  }
78280
78322
  for (let iter = 0; iter < cfg.maxIterations; iter++) {
78323
+ assertTime();
78281
78324
  const newScores = /* @__PURE__ */ new Map();
78282
78325
  let maxDelta = 0;
78283
78326
  for (const nodeId2 of allNodes) {
78327
+ assertTime();
78284
78328
  const teleport = seedSet.has(nodeId2) ? (1 - cfg.damping) * teleportProb : 0;
78285
78329
  let walkSum = 0;
78286
- const inEdges = graph.currentEdges(nodeId2);
78330
+ const inEdges = adjacency.get(nodeId2);
78287
78331
  for (const edge of inEdges) {
78288
78332
  const neighborId = edge.srcId === nodeId2 ? edge.dstId : edge.srcId;
78289
78333
  const neighborScore = scores.get(neighborId) ?? 0;
78290
- const neighborOutDegree = graph.currentEdges(neighborId).length || 1;
78334
+ if (neighborScore === 0)
78335
+ continue;
78336
+ const neighborOutDegree = adjacency.get(neighborId).length || 1;
78291
78337
  walkSum += neighborScore / neighborOutDegree;
78292
78338
  }
78293
78339
  const newScore = teleport + cfg.damping * walkSum;
@@ -78299,10 +78345,10 @@ function personalizedPageRank(graph, seedNodeIds, config2) {
78299
78345
  for (const [id8, score] of newScores)
78300
78346
  scores.set(id8, score);
78301
78347
  if (maxDelta < cfg.convergenceThreshold) {
78302
- return scores;
78348
+ return { scores, adjacency, assertTime };
78303
78349
  }
78304
78350
  }
78305
- return scores;
78351
+ return { scores, adjacency, assertTime };
78306
78352
  }
78307
78353
  function retrieveByPPR(query, graph, episodeStore, config2) {
78308
78354
  const cfg = { ...DEFAULT_CONFIG3, ...config2 };
@@ -78337,15 +78383,17 @@ function retrieveByPPR(query, graph, episodeStore, config2) {
78337
78383
  if (seedNodes.length === 0) {
78338
78384
  return { episodes: [], queryEntities, seedNodes: [], iterations: 0 };
78339
78385
  }
78340
- const pprScores = personalizedPageRank(graph, seedNodes, cfg);
78386
+ const snapshot2 = personalizedPageRankSnapshot(graph, seedNodes, cfg);
78387
+ const pprScores = snapshot2.scores;
78341
78388
  const episodeScores = /* @__PURE__ */ new Map();
78342
78389
  for (const [nodeId2, score] of pprScores) {
78390
+ snapshot2.assertTime();
78343
78391
  if (score < 1e-3)
78344
78392
  continue;
78345
78393
  const node = graph.getNode(nodeId2);
78346
78394
  if (!node)
78347
78395
  continue;
78348
- const edges = graph.currentEdges(nodeId2);
78396
+ const edges = snapshot2.adjacency.get(nodeId2);
78349
78397
  for (const edge of edges) {
78350
78398
  if (edge.sourceEpisodeId) {
78351
78399
  const existing = episodeScores.get(edge.sourceEpisodeId);
@@ -78363,6 +78411,7 @@ function retrieveByPPR(query, graph, episodeStore, config2) {
78363
78411
  if (cfg.currentEmotionalState || cfg.influenceFor || engagementWeight !== 0) {
78364
78412
  const current6 = cfg.currentEmotionalState;
78365
78413
  entries = entries.map(([epId, payload2]) => {
78414
+ snapshot2.assertTime();
78366
78415
  const ep = episodeStore.get(epId);
78367
78416
  let score = payload2.score;
78368
78417
  if (current6) {
@@ -78388,6 +78437,7 @@ function retrieveByPPR(query, graph, episodeStore, config2) {
78388
78437
  const ranked = entries.sort((a, b) => b[1].score - a[1].score).slice(0, cfg.topK);
78389
78438
  const episodes = [];
78390
78439
  for (const [epId, { score, matchedNodes }] of ranked) {
78440
+ snapshot2.assertTime();
78391
78441
  const episode = episodeStore.get(epId);
78392
78442
  if (episode) {
78393
78443
  episodes.push({ episode, pprScore: score, matchedNodes: [...new Set(matchedNodes)] });
@@ -78400,7 +78450,7 @@ function retrieveByPPR(query, graph, episodeStore, config2) {
78400
78450
  iterations: cfg.maxIterations
78401
78451
  };
78402
78452
  }
78403
- var DEFAULT_CONFIG3;
78453
+ var DEFAULT_CONFIG3, PPRTraversalBudgetError;
78404
78454
  var init_pprRetrieval = __esm({
78405
78455
  "packages/memory/dist/pprRetrieval.js"() {
78406
78456
  "use strict";
@@ -78412,7 +78462,20 @@ var init_pprRetrieval = __esm({
78412
78462
  damping: 0.5,
78413
78463
  maxIterations: 50,
78414
78464
  convergenceThreshold: 1e-6,
78415
- topK: 10
78465
+ topK: 10,
78466
+ maxNodes: 1024,
78467
+ maxEdges: 8192,
78468
+ maxDurationMs: 250
78469
+ };
78470
+ PPRTraversalBudgetError = class extends Error {
78471
+ reason;
78472
+ limit;
78473
+ constructor(reason, limit2) {
78474
+ super(`Memory graph ${reason} budget exceeded (${limit2}); use lexical retrieval instead`);
78475
+ this.reason = reason;
78476
+ this.limit = limit2;
78477
+ this.name = "PPRTraversalBudgetError";
78478
+ }
78416
78479
  };
78417
78480
  }
78418
78481
  });
@@ -78822,6 +78885,7 @@ var init_episodeStore = __esm({
78822
78885
  const standardResults = this.search(query, { ...opts, recordRetrieval: false });
78823
78886
  try {
78824
78887
  const pprResult = retrieveByPPR(query.query, this.graph, this, {
78888
+ ...opts.pprBudget,
78825
78889
  damping: 0.5,
78826
78890
  maxIterations: 50,
78827
78891
  convergenceThreshold: 1e-6,
@@ -78861,7 +78925,13 @@ var init_episodeStore = __esm({
78861
78925
  if (opts.recordRetrieval !== false)
78862
78926
  this.recordRetrieved(merged, Date.now());
78863
78927
  return merged;
78864
- } catch {
78928
+ } catch (error) {
78929
+ if (error instanceof PPRTraversalBudgetError) {
78930
+ try {
78931
+ opts.onPprBudgetExceeded?.(error);
78932
+ } catch {
78933
+ }
78934
+ }
78865
78935
  if (opts.recordRetrieval !== false)
78866
78936
  this.recordRetrieved(standardResults, Date.now());
78867
78937
  return standardResults;
@@ -80072,12 +80142,15 @@ var init_temporalGraph = __esm({
80072
80142
  }
80073
80143
  // ─── Temporal queries ────────────────────────────────────────────────────
80074
80144
  /** Get currently valid edges for a node. */
80075
- currentEdges(nodeId2) {
80145
+ currentEdges(nodeId2, limit2) {
80146
+ if (limit2 !== void 0 && (!Number.isSafeInteger(limit2) || limit2 < 1))
80147
+ throw new RangeError("Current edge limit must be a positive safe integer");
80076
80148
  return this.db.prepare(`
80077
80149
  SELECT * FROM kg_edges
80078
80150
  WHERE (src_id = ? OR dst_id = ?) AND valid_until IS NULL
80079
80151
  ORDER BY valid_from DESC
80080
- `).all(nodeId2, nodeId2).map((r) => this.rowToEdge(r));
80152
+ ${limit2 === void 0 ? "" : "LIMIT ?"}
80153
+ `).all(...limit2 === void 0 ? [nodeId2, nodeId2] : [nodeId2, nodeId2, limit2]).map((r) => this.rowToEdge(r));
80081
80154
  }
80082
80155
  /**
80083
80156
  * Get edges valid at a specific world time, optionally as known at an
@@ -86551,6 +86624,7 @@ function buildContextPressureSnapshot(input2, opts = {}) {
86551
86624
  const totalTokens = rawTokens + consolidatedTokens;
86552
86625
  const compressionTargetTokens = Math.ceil(rawTokens * 0.6);
86553
86626
  return {
86627
+ metricScope: "semantic_items",
86554
86628
  generatedAt: now2 ?? Date.now(),
86555
86629
  itemCount: items.length,
86556
86630
  semanticChunkCount: semanticChunkCount ?? new SemanticChunker().chunk(items, { now: now2 }).length,
@@ -87410,6 +87484,7 @@ __export(dist_exports, {
87410
87484
  MemoryTelemetryService: () => MemoryTelemetryService,
87411
87485
  MultimodalIdentityService: () => MultimodalIdentityService,
87412
87486
  OllamaPrefixCacheMemoryAdapter: () => OllamaPrefixCacheMemoryAdapter,
87487
+ PPRTraversalBudgetError: () => PPRTraversalBudgetError,
87413
87488
  PatchHistoryStore: () => PatchHistoryStore,
87414
87489
  PredictionStore: () => PredictionStore,
87415
87490
  ProceduralMemoryStore: () => ProceduralMemoryStore,
@@ -87693,6 +87768,7 @@ var init_log_explore = __esm({
87693
87768
  "packages/execution/dist/tools/log-explore.js"() {
87694
87769
  "use strict";
87695
87770
  init_log_packet();
87771
+ init_output_preview();
87696
87772
  }
87697
87773
  });
87698
87774
 
@@ -365128,7 +365204,8 @@ function buildTerminalTaskReport(input2) {
365128
365204
  const currentEmptyResponseFailure = currentFailureScope && failure && failure.code === "model_empty_response_stall" && failure.phase === "after_transport" && Number.isSafeInteger(failure.consecutiveEmptyResponses) && failure.consecutiveEmptyResponses >= 6;
365129
365205
  const currentInferenceFailure = currentFailureScope && failure && (failure.code === "remote_inference_unavailable" || failure.code === "inference_stream_interrupted" || failure.code === "fallback_approval_required" || failure.code === "fallback_declined") && failure.phase === "after_transport" && failure.retryable === false;
365130
365206
  const currentRepeatedFailure = currentFailureScope && failure && failure.code === "repeated_failed_tool_stall" && failure.phase === "after_tool" && failure.retryable === false && failure.toolName === "shell" && Number.isSafeInteger(failure.repeatedAttempts) && failure.repeatedAttempts >= 6 && /^[a-f0-9]{64}$/.test(failure.operationSha256) && /^[a-f0-9]{64}$/.test(failure.resultSha256);
365131
- const currentRuntimeFailure = Boolean(currentAdmissionFailure || currentEmptyResponseFailure || currentInferenceFailure || currentRepeatedFailure);
365207
+ const currentObservationStall = currentFailureScope && failure && failure.code === "repeated_observation_stall" && failure.phase === "after_tool" && failure.retryable === false && Boolean(failure.toolName) && Number.isSafeInteger(failure.repeatedAttempts) && failure.repeatedAttempts >= 8 && /^[a-f0-9]{64}$/.test(failure.operationSha256) && /^[a-f0-9]{64}$/.test(failure.resultSha256);
365208
+ const currentRuntimeFailure = Boolean(currentAdmissionFailure || currentEmptyResponseFailure || currentInferenceFailure || currentRepeatedFailure || currentObservationStall);
365132
365209
  if (currentAdmissionFailure && failure?.code === "context_admission_failed") {
365133
365210
  const admission = failure.contextAdmission;
365134
365211
  limit2("context_admission_failed", "context_admission", `Context admission blocked the model request before transport. Estimated input: ${admission.estimatedInputTokens} tokens; safety margin: ${admission.safetyMarginTokens}; context ceiling: ${admission.contextLimitTokens ?? "unknown"} (${admission.contextLimitSource}). ${admission.reason}`);
@@ -365142,6 +365219,9 @@ function buildTerminalTaskReport(input2) {
365142
365219
  } else if (currentRepeatedFailure && failure?.code === "repeated_failed_tool_stall") {
365143
365220
  limit2(failure.code, "tool_execution", `The same shell operation returned identical failure evidence ${failure.repeatedAttempts} times without new observations or authoritative progress. The run stopped incomplete; automatic same-input replay is disabled.`);
365144
365221
  nextSteps.add("Inspect the retained failed command evidence and change the missing prerequisite or operation before retrying the unfinished request.");
365222
+ } else if (currentObservationStall && failure?.code === "repeated_observation_stall") {
365223
+ limit2(failure.code, "tool_execution", `The same ${failure.toolName} read returned unchanged evidence ${failure.repeatedAttempts} times despite recovery guidance. No answer or completion was accepted; automatic same-input replay is disabled.`);
365224
+ nextSteps.add("Use the retained observations to answer the original request, or choose a focused read that resolves a specific missing fact before retrying.");
365145
365225
  } else if (failure) {
365146
365226
  limit2("runtime_failure_scope", "evidence_scope", "The runtime failure did not match this run and task epoch; its diagnosis was excluded.");
365147
365227
  }
@@ -366874,6 +366954,16 @@ import { createHash as createHash66 } from "node:crypto";
366874
366954
  var APPEND_ONLY_FRAME_UPDATE_MARKER = "[ACTIVE TASK FRAME UPDATE v1]";
366875
366955
  var APPEND_ONLY_HOST_MESSAGE_MARKER = "[HOST RUNTIME MESSAGE v1: host-authored, not from the user]";
366876
366956
  var APPEND_ONLY_MAX_UPDATE_CHARS = 24e3;
366957
+ var APPEND_ONLY_MAX_FRAME_UPDATE_CHARS = 24e3;
366958
+ var APPEND_ONLY_MAX_FRAME_UPDATES = 8;
366959
+ function frameControlView(content, sources) {
366960
+ let view = content;
366961
+ for (const [id8, body] of [...sources].filter(([, body2]) => body2.length > 0).sort((left, right) => right[1].length - left[1].length)) {
366962
+ const key = createHash66("sha256").update(id8).digest("hex");
366963
+ view = view.replaceAll(body, `[EXACT SOURCE ${key}]`);
366964
+ }
366965
+ return view;
366966
+ }
366877
366967
  function projectionMarker(message3, kinds3) {
366878
366968
  if (typeof message3.content !== "string")
366879
366969
  return void 0;
@@ -366994,6 +367084,10 @@ function projectAppendOnlyOutbound(input2) {
366994
367084
  }]));
366995
367085
  const exactSources = new Map(input2.exactSources ?? []);
366996
367086
  const maxUpdateChars = input2.maxUpdateChars ?? APPEND_ONLY_MAX_UPDATE_CHARS;
367087
+ const maxFrameUpdateChars = input2.maxFrameUpdateChars ?? APPEND_ONLY_MAX_FRAME_UPDATE_CHARS;
367088
+ const maxFrameUpdates = input2.maxFrameUpdates ?? APPEND_ONLY_MAX_FRAME_UPDATES;
367089
+ if (!Number.isSafeInteger(maxFrameUpdateChars) || maxFrameUpdateChars < 0 || !Number.isSafeInteger(maxFrameUpdates) || maxFrameUpdates < 0)
367090
+ throw new RangeError("Append-only frame update limits must be finite nonnegative safe integers");
366997
367091
  const base = [];
366998
367092
  const projections = /* @__PURE__ */ new Map();
366999
367093
  let previouslyProjected = false;
@@ -367012,11 +367106,22 @@ function projectAppendOnlyOutbound(input2) {
367012
367106
 
367013
367107
  ${message3.content}`);
367014
367108
  }
367015
- const full = (reason) => ({
367109
+ const full = (reason, rebase2) => ({
367016
367110
  messages: messages4,
367017
367111
  mode: "full",
367018
367112
  reason,
367019
- state: { key, sent: messages4, base, projections, acceptedReceipts, exactSources, updateChars: 0 }
367113
+ ...rebase2 ? { rebase: rebase2 } : {},
367114
+ state: {
367115
+ key,
367116
+ sent: messages4,
367117
+ base,
367118
+ projections,
367119
+ acceptedReceipts,
367120
+ exactSources,
367121
+ updateChars: 0,
367122
+ frameUpdateChars: 0,
367123
+ frameUpdateCount: 0
367124
+ }
367020
367125
  });
367021
367126
  if (previouslyProjected)
367022
367127
  return full("already_projected_packet");
@@ -367026,6 +367131,7 @@ ${message3.content}`);
367026
367131
  if (currentUnits.length < priorUnits.length || priorUnits.some((unit, index) => !sameUnit(unit, currentUnits[index])))
367027
367132
  return full("history_rewritten");
367028
367133
  const updates = [];
367134
+ const controlUpdates = [];
367029
367135
  for (const kind2 of kinds3) {
367030
367136
  const now2 = projections.get(kind2.marker);
367031
367137
  const before = previous.projections.get(kind2.marker);
@@ -367035,6 +367141,10 @@ ${message3.content}`);
367035
367141
  if (diff)
367036
367142
  updates.push(`[${kind2.label}]
367037
367143
  ${diff}`);
367144
+ const controlDiff = renderProjectionLineDiff(frameControlView(before ?? "", previous.exactSources ?? /* @__PURE__ */ new Map()), frameControlView(now2 ?? "", exactSources));
367145
+ if (controlDiff)
367146
+ controlUpdates.push(`[${kind2.label}]
367147
+ ${controlDiff}`);
367038
367148
  }
367039
367149
  const update = updates.length ? [
367040
367150
  APPEND_ONLY_FRAME_UPDATE_MARKER,
@@ -367050,6 +367160,13 @@ ${content}`
367050
367160
  const updateChars = previous.updateChars + update.length + exactAdditions.reduce((sum2, message3) => sum2 + String(message3.content).length, 0);
367051
367161
  if (updateChars > maxUpdateChars)
367052
367162
  return full("update_budget_exceeded");
367163
+ const frameUpdateChars = (previous.frameUpdateChars ?? previous.updateChars) + (update ? update.length - updates.join("\n").length + controlUpdates.join("\n").length : 0);
367164
+ const frameUpdateCount = (previous.frameUpdateCount ?? previous.sent.filter((message3) => typeof message3.content === "string" && message3.content.startsWith(APPEND_ONLY_FRAME_UPDATE_MARKER)).length) + (update ? 1 : 0);
367165
+ const rebase = { frameUpdateChars, frameUpdateCount, maxFrameUpdateChars, maxFrameUpdates };
367166
+ if (frameUpdateChars > maxFrameUpdateChars)
367167
+ return full("frame_update_budget_exceeded", rebase);
367168
+ if (frameUpdateCount > maxFrameUpdates)
367169
+ return full("frame_update_count_exceeded", rebase);
367053
367170
  const appended = currentUnits.slice(priorUnits.length).flatMap((unit) => unit.messages).map((message3) => message3.role === "system" && typeof message3.content === "string" ? { ...message3, role: "user", content: `${APPEND_ONLY_HOST_MESSAGE_MARKER}
367054
367171
  ${message3.content}` } : message3);
367055
367172
  const sent = [...previous.sent, ...appended, ...exactAdditions, ...update ? [{ role: "user", content: update }] : []];
@@ -367057,7 +367174,7 @@ ${message3.content}` } : message3);
367057
367174
  messages: sent,
367058
367175
  mode: "extended",
367059
367176
  reason: update ? "extended_with_update" : "extended_unchanged",
367060
- state: { key, sent, base, projections, acceptedReceipts, exactSources, updateChars }
367177
+ state: { key, sent, base, projections, acceptedReceipts, exactSources, updateChars, frameUpdateChars, frameUpdateCount }
367061
367178
  };
367062
367179
  }
367063
367180
 
@@ -370739,13 +370856,15 @@ import { z as z25 } from "zod";
370739
370856
 
370740
370857
  // packages/orchestrator/dist/contentAddressedArtifactStore.js
370741
370858
  import { createHash as createHash78, randomUUID as randomUUID50 } from "node:crypto";
370742
- import { constants as constants12, closeSync as closeSync15, existsSync as existsSync33, fsyncSync as fsyncSync8, mkdirSync as mkdirSync26, openSync as openSync15, readFileSync as readFileSync37, readdirSync as readdirSync10, renameSync as renameSync14, statSync as statSync17, unlinkSync as unlinkSync15, writeFileSync as writeFileSync25 } from "node:fs";
370859
+ import { constants as constants12, closeSync as closeSync15, existsSync as existsSync33, fstatSync as fstatSync6, fsyncSync as fsyncSync8, mkdirSync as mkdirSync26, openSync as openSync15, readFileSync as readFileSync37, readSync as readSync3, readdirSync as readdirSync10, renameSync as renameSync14, statSync as statSync17, unlinkSync as unlinkSync15, writeFileSync as writeFileSync25 } from "node:fs";
370743
370860
  import { open as open8, mkdir as mkdir7, link as link3, rename as rename3, unlink as unlink4 } from "node:fs/promises";
370744
370861
  import { join as join49, resolve as resolve30, sep as sep6 } from "node:path";
370745
370862
  var REFERENCE_PREFIX = "omnius-artifact://sha256/";
370746
370863
  var SHA256 = /^[a-f0-9]{64}$/;
370747
370864
  var DEFAULT_MAX_ARTIFACT_BYTES = 32 * 1024 * 1024;
370748
370865
  var DEFAULT_MAX_STORE_BYTES = 512 * 1024 * 1024;
370866
+ var MAX_CONFIGURED_STORE_BYTES = 8 * 1024 * 1024 * 1024;
370867
+ var MAX_LIMITS_CONFIG_BYTES = 4096;
370749
370868
  var DEFAULT_MAX_MANIFEST_ENTRIES = 64;
370750
370869
  var MAX_RANGES_PER_RECORD = 128;
370751
370870
  var MAX_PROVENANCE_PATH_CHARS = 4096;
@@ -370789,6 +370908,54 @@ function finitePositiveInteger(value, label) {
370789
370908
  function checkedLimit(value, fallback, label) {
370790
370909
  return finitePositiveInteger(value ?? fallback, label);
370791
370910
  }
370911
+ function configuredStoreCapacity(rootDir) {
370912
+ const path13 = join49(rootDir, "limits.json");
370913
+ const invalid2 = (reason) => new Error(`artifact store limits configuration ${JSON.stringify(path13)}: ${reason}`);
370914
+ let descriptor2;
370915
+ try {
370916
+ descriptor2 = openSync15(path13, constants12.O_RDONLY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK);
370917
+ } catch (error) {
370918
+ const code2 = error.code;
370919
+ if (code2 === "ENOENT")
370920
+ return void 0;
370921
+ throw invalid2(`cannot open regular configuration file (${code2 ?? "read error"})`);
370922
+ }
370923
+ try {
370924
+ const before = fstatSync6(descriptor2, { bigint: true });
370925
+ if (!before.isFile())
370926
+ throw invalid2("must be a regular file, not a directory or special file");
370927
+ if (before.size > BigInt(MAX_LIMITS_CONFIG_BYTES))
370928
+ throw invalid2(`must not exceed ${MAX_LIMITS_CONFIG_BYTES} bytes`);
370929
+ const buffer = Buffer.alloc(MAX_LIMITS_CONFIG_BYTES + 1);
370930
+ let bytes5 = 0;
370931
+ while (bytes5 < buffer.length) {
370932
+ const count8 = readSync3(descriptor2, buffer, bytes5, buffer.length - bytes5, null);
370933
+ if (count8 === 0)
370934
+ break;
370935
+ bytes5 += count8;
370936
+ }
370937
+ if (bytes5 > MAX_LIMITS_CONFIG_BYTES)
370938
+ throw invalid2(`must not exceed ${MAX_LIMITS_CONFIG_BYTES} bytes`);
370939
+ if (!sameFileSnapshot(before, fstatSync6(descriptor2, { bigint: true })))
370940
+ throw invalid2("changed while being read; retry with a stable file");
370941
+ let value;
370942
+ try {
370943
+ value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(buffer.subarray(0, bytes5)));
370944
+ } catch {
370945
+ throw invalid2("must contain valid UTF-8 JSON");
370946
+ }
370947
+ if (!value || typeof value !== "object" || Array.isArray(value))
370948
+ throw invalid2("must be an object with schema and maxStoreBytes");
370949
+ const config2 = value;
370950
+ if (config2.schema !== "omnius.artifact-store-limits.v1" || Object.keys(config2).some((key) => !["schema", "maxStoreBytes"].includes(key)))
370951
+ throw invalid2("requires schema omnius.artifact-store-limits.v1 and only the maxStoreBytes setting");
370952
+ if (typeof config2.maxStoreBytes !== "number" || !Number.isSafeInteger(config2.maxStoreBytes) || config2.maxStoreBytes <= 0 || config2.maxStoreBytes > MAX_CONFIGURED_STORE_BYTES)
370953
+ throw invalid2(`maxStoreBytes must be a positive safe integer no greater than ${MAX_CONFIGURED_STORE_BYTES}`);
370954
+ return config2.maxStoreBytes;
370955
+ } finally {
370956
+ closeSync15(descriptor2);
370957
+ }
370958
+ }
370792
370959
  function validateMetadataText(value, maxChars, label) {
370793
370960
  if (typeof value !== "string")
370794
370961
  throw new Error(`${label} must be a string`);
@@ -371004,7 +371171,7 @@ var ContentAddressedArtifactStore = class {
371004
371171
  constructor(options = {}) {
371005
371172
  this.rootDir = resolve30(options.rootDir ?? contentAddressedArtifactStoreRoot());
371006
371173
  this.maxArtifactBytes = checkedLimit(options.maxArtifactBytes, DEFAULT_MAX_ARTIFACT_BYTES, "maxArtifactBytes");
371007
- this.maxStoreBytes = checkedLimit(options.maxStoreBytes, DEFAULT_MAX_STORE_BYTES, "maxStoreBytes");
371174
+ this.maxStoreBytes = options.maxStoreBytes !== void 0 ? checkedLimit(options.maxStoreBytes, DEFAULT_MAX_STORE_BYTES, "maxStoreBytes") : configuredStoreCapacity(this.rootDir) ?? DEFAULT_MAX_STORE_BYTES;
371008
371175
  this.maxManifestRecords = checkedLimit(options.maxManifestRecords, DEFAULT_MAX_MANIFEST_ENTRIES, "maxManifestRecords");
371009
371176
  mkdirSync26(this.rootDir, { recursive: true, mode: 448 });
371010
371177
  }
@@ -379122,24 +379289,34 @@ ${fileLines}` : null,
379122
379289
 
379123
379290
  // packages/orchestrator/dist/repeated-failed-shell.js
379124
379291
  import { createHash as createHash89 } from "node:crypto";
379125
- function stableShellOutcomeSha256(result) {
379126
- const receipt = result.executionReceipt;
379292
+ function semanticProcessOutcome(receipt) {
379293
+ if (!receipt)
379294
+ return null;
379295
+ const { startedAtIso: _started, finishedAtIso: _finished, shellRunId: _runId, outputRef: _archive, ...facts } = receipt;
379296
+ return facts;
379297
+ }
379298
+ function stableSemanticOutcomeSha256(result, options = {}) {
379127
379299
  return createHash89("sha256").update(JSON.stringify({
379128
379300
  success: result.success,
379129
379301
  partial: result.partial,
379130
- output: result.operatorDetail?.output ?? result.output,
379302
+ output: options.shell ? result.operatorDetail?.output ?? result.output : result.output,
379131
379303
  error: result.error,
379132
- process: receipt ? {
379133
- exitCode: receipt.exitCode,
379134
- primaryExitCode: receipt.primaryExitCode,
379135
- runnerExitCode: receipt.runnerExitCode,
379136
- timedOut: receipt.timedOut,
379137
- cancelled: receipt.cancelled,
379138
- signal: receipt.signal,
379139
- declaredVerification: receipt.declaredVerification?.outcome
379140
- } : null
379304
+ ...!options.shell ? { llmContent: result.llmContent, data: result.data, operatorDetail: result.operatorDetail } : {},
379305
+ process: semanticProcessOutcome(result.executionReceipt),
379306
+ processes: result.executionReceipts?.map(semanticProcessOutcome),
379307
+ failure: result.failure,
379308
+ materialization: result.artifactMaterialization,
379309
+ sourceObservation: result.sourceObservation,
379310
+ streamedSourceObservation: result.streamedSourceObservation,
379311
+ runtimeSession: result.runtimeSession,
379312
+ documentExtraction: result.documentExtraction,
379313
+ beforeHash: result.beforeHash,
379314
+ afterHash: result.afterHash
379141
379315
  })).digest("hex");
379142
379316
  }
379317
+ function stableShellOutcomeSha256(result) {
379318
+ return stableSemanticOutcomeSha256(result, { shell: true });
379319
+ }
379143
379320
  var RepeatedFailedShellGuard = class {
379144
379321
  ownerScope = "";
379145
379322
  progressKey = "";
@@ -379193,6 +379370,47 @@ var RepeatedFailedShellGuard = class {
379193
379370
  }
379194
379371
  };
379195
379372
 
379373
+ // packages/orchestrator/dist/unchanged-observation-guard.js
379374
+ var UnchangedObservationGuard = class {
379375
+ scope = "";
379376
+ seen = /* @__PURE__ */ new Set();
379377
+ repeats = /* @__PURE__ */ new Map();
379378
+ lastResults = /* @__PURE__ */ new Map();
379379
+ observe(input2) {
379380
+ if (input2.scope !== this.scope) {
379381
+ this.scope = input2.scope;
379382
+ this.seen.clear();
379383
+ this.repeats.clear();
379384
+ this.lastResults.clear();
379385
+ }
379386
+ if (!input2.observation)
379387
+ return 0;
379388
+ const resultSha256 = input2.reused ? this.lastResults.get(input2.operationSha256) : input2.resultSha256;
379389
+ if (!resultSha256)
379390
+ return 0;
379391
+ const priorResult = this.lastResults.get(input2.operationSha256);
379392
+ if (!input2.reused && priorResult && priorResult !== resultSha256)
379393
+ this.repeats.clear();
379394
+ if (!input2.reused) {
379395
+ this.lastResults.set(input2.operationSha256, resultSha256);
379396
+ if (this.lastResults.size > 512)
379397
+ this.lastResults.delete(this.lastResults.keys().next().value);
379398
+ }
379399
+ const key = `${input2.operationSha256}:${resultSha256}`;
379400
+ if (!this.seen.has(key)) {
379401
+ if (input2.reused)
379402
+ return 0;
379403
+ this.seen.add(key);
379404
+ this.repeats.clear();
379405
+ if (this.seen.size > 512)
379406
+ this.seen.delete(this.seen.values().next().value);
379407
+ }
379408
+ const count8 = (this.repeats.get(key) ?? 0) + 1;
379409
+ this.repeats.set(key, count8);
379410
+ return count8;
379411
+ }
379412
+ };
379413
+
379196
379414
  // packages/orchestrator/dist/taskScopeBoundary.js
379197
379415
  import { createHash as createHash90 } from "node:crypto";
379198
379416
  var TASK_SCOPE_BOUNDARY_SCHEMA = "omnius.task-scope-boundary.v1";
@@ -379619,7 +379837,7 @@ function selectedEvidence(ledger) {
379619
379837
  };
379620
379838
  }
379621
379839
  function buildCompletionFinalizationRecord(input2) {
379622
- if (input2.runtimeFailure && (input2.runtimeFailure.schema !== "omnius.terminal-runtime-failure.v1" || input2.runtimeFailure.runId !== input2.runId || input2.runtimeFailure.taskEpoch !== input2.taskEpoch || !(input2.runtimeFailure.code === "context_admission_failed" && input2.runtimeFailure.phase === "before_transport" && input2.runtimeFailure.contextAdmission.decision === "reject" || input2.runtimeFailure.code === "model_empty_response_stall" && input2.runtimeFailure.phase === "after_transport" && Number.isSafeInteger(input2.runtimeFailure.consecutiveEmptyResponses) && input2.runtimeFailure.consecutiveEmptyResponses >= 6 || input2.runtimeFailure.code === "repeated_failed_tool_stall" && input2.runtimeFailure.phase === "after_tool" && input2.runtimeFailure.retryable === false && input2.runtimeFailure.toolName === "shell" && Number.isSafeInteger(input2.runtimeFailure.repeatedAttempts) && input2.runtimeFailure.repeatedAttempts >= 6 && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.operationSha256) && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.resultSha256) || (input2.runtimeFailure.code === "remote_inference_unavailable" || input2.runtimeFailure.code === "inference_stream_interrupted" || input2.runtimeFailure.code === "fallback_approval_required" || input2.runtimeFailure.code === "fallback_declined") && input2.runtimeFailure.phase === "after_transport" && input2.runtimeFailure.retryable === false)))
379840
+ if (input2.runtimeFailure && (input2.runtimeFailure.schema !== "omnius.terminal-runtime-failure.v1" || input2.runtimeFailure.runId !== input2.runId || input2.runtimeFailure.taskEpoch !== input2.taskEpoch || !(input2.runtimeFailure.code === "context_admission_failed" && input2.runtimeFailure.phase === "before_transport" && input2.runtimeFailure.contextAdmission.decision === "reject" || input2.runtimeFailure.code === "model_empty_response_stall" && input2.runtimeFailure.phase === "after_transport" && Number.isSafeInteger(input2.runtimeFailure.consecutiveEmptyResponses) && input2.runtimeFailure.consecutiveEmptyResponses >= 6 || input2.runtimeFailure.code === "repeated_failed_tool_stall" && input2.runtimeFailure.phase === "after_tool" && input2.runtimeFailure.retryable === false && input2.runtimeFailure.toolName === "shell" && Number.isSafeInteger(input2.runtimeFailure.repeatedAttempts) && input2.runtimeFailure.repeatedAttempts >= 6 && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.operationSha256) && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.resultSha256) || input2.runtimeFailure.code === "repeated_observation_stall" && input2.runtimeFailure.phase === "after_tool" && input2.runtimeFailure.retryable === false && Boolean(input2.runtimeFailure.toolName) && Number.isSafeInteger(input2.runtimeFailure.repeatedAttempts) && input2.runtimeFailure.repeatedAttempts >= 8 && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.operationSha256) && /^[a-f0-9]{64}$/.test(input2.runtimeFailure.resultSha256) || (input2.runtimeFailure.code === "remote_inference_unavailable" || input2.runtimeFailure.code === "inference_stream_interrupted" || input2.runtimeFailure.code === "fallback_approval_required" || input2.runtimeFailure.code === "fallback_declined") && input2.runtimeFailure.phase === "after_transport" && input2.runtimeFailure.retryable === false)))
379623
379841
  throw new Error("completion_finalization_runtime_failure_scope_conflict");
379624
379842
  if (input2.runtimeFailure && input2.status === "completed")
379625
379843
  throw new Error("completion_finalization_runtime_failure_conflict");
@@ -382962,7 +383180,7 @@ function renderWorkspaceTree(scan, opts = {}) {
382962
383180
  return;
382963
383181
  } else {
382964
383182
  const size = includeFileSizes && child.file ? ` (${humanBytes(child.file.bytes)})` : "";
382965
- lines.push(`${indent2}${child.file?.rel ?? child.name}${size}`);
383183
+ lines.push(`${indent2}${child.name}${size}`);
382966
383184
  }
382967
383185
  }
382968
383186
  };
@@ -392706,7 +392924,7 @@ var ObservationLedger = class {
392706
392924
  if (!fingerprint2 || SKIP_TOOLS.has(tool))
392707
392925
  return;
392708
392926
  const trimmed = (output ?? "").trim();
392709
- const outputHash = hashText(trimmed);
392927
+ const outputHash = input2.semanticOutcomeSha256 && /^[a-f0-9]{64}$/.test(input2.semanticOutcomeSha256) ? input2.semanticOutcomeSha256 : hashText(trimmed);
392710
392928
  const existing = this.entries.get(fingerprint2);
392711
392929
  if (existing) {
392712
392930
  const identical = existing.outputHash === outputHash && existing.success === success;
@@ -392836,7 +393054,7 @@ function selectReasoningCheckpoint(input2) {
392836
393054
  }
392837
393055
 
392838
393056
  // packages/orchestrator/dist/contextWindowDump.js
392839
- import { existsSync as existsSync56, mkdirSync as mkdirSync42, readdirSync as readdirSync19, readFileSync as readFileSync61, statSync as statSync28, unlinkSync as unlinkSync22, writeFileSync as writeFileSync39, appendFileSync as appendFileSync8, chmodSync as chmodSync2, closeSync as closeSync22, openSync as openSync22, readSync as readSync3, renameSync as renameSync24 } from "node:fs";
393057
+ import { existsSync as existsSync56, mkdirSync as mkdirSync42, readdirSync as readdirSync19, readFileSync as readFileSync61, statSync as statSync28, unlinkSync as unlinkSync22, writeFileSync as writeFileSync39, appendFileSync as appendFileSync8, chmodSync as chmodSync2, closeSync as closeSync22, openSync as openSync22, readSync as readSync4, renameSync as renameSync24 } from "node:fs";
392840
393058
  init_dist3();
392841
393059
  import { join as join72, resolve as resolve38 } from "node:path";
392842
393060
  import { createHash as createHash109, randomUUID as randomUUID55 } from "node:crypto";
@@ -393791,7 +394009,7 @@ function rotatePrivateIndex(indexPath) {
393791
394009
  const buffer = Buffer.alloc(size - start);
393792
394010
  const fd = openSync22(indexPath, "r");
393793
394011
  try {
393794
- readSync3(fd, buffer, 0, buffer.length, start);
394012
+ readSync4(fd, buffer, 0, buffer.length, start);
393795
394013
  } finally {
393796
394014
  closeSync22(fd);
393797
394015
  }
@@ -395250,7 +395468,7 @@ function validateMemoryCompilationPlan(input2) {
395250
395468
  }
395251
395469
 
395252
395470
  // packages/orchestrator/dist/debugArtifactLibrary.js
395253
- import { appendFileSync as appendFileSync9, existsSync as existsSync57, mkdirSync as mkdirSync43, readFileSync as readFileSync62, statSync as statSync29, writeFileSync as writeFileSync40, closeSync as closeSync23, fsyncSync as fsyncSync15, openSync as openSync23, readSync as readSync4, renameSync as renameSync25, unlinkSync as unlinkSync23 } from "node:fs";
395471
+ import { appendFileSync as appendFileSync9, existsSync as existsSync57, mkdirSync as mkdirSync43, readFileSync as readFileSync62, statSync as statSync29, writeFileSync as writeFileSync40, closeSync as closeSync23, fsyncSync as fsyncSync15, openSync as openSync23, readSync as readSync5, renameSync as renameSync25, unlinkSync as unlinkSync23 } from "node:fs";
395254
395472
  import { createHash as createHash110, randomUUID as randomUUID56 } from "node:crypto";
395255
395473
  import { basename as basename21, dirname as dirname40, join as join73, relative as relative19, resolve as resolve39 } from "node:path";
395256
395474
  var DEBUG_LIBRARY_DIR = "debug-library";
@@ -395592,7 +395810,7 @@ function lastJournalEvent(path13) {
395592
395810
  const size = statSync29(path13).size, start = Math.max(0, size - 262144);
395593
395811
  const bytes5 = Buffer.alloc(size - start), fd = openSync23(path13, "r");
395594
395812
  try {
395595
- readSync4(fd, bytes5, 0, bytes5.length, start);
395813
+ readSync5(fd, bytes5, 0, bytes5.length, start);
395596
395814
  } finally {
395597
395815
  closeSync23(fd);
395598
395816
  }
@@ -395642,7 +395860,7 @@ function writeEventAndIndexes(paths3, event, originalPath) {
395642
395860
  if (offset > 0) {
395643
395861
  const fd = openSync23(paths3.eventsJsonlPath, "r"), lastByte = Buffer.alloc(1);
395644
395862
  try {
395645
- readSync4(fd, lastByte, 0, 1, offset - 1);
395863
+ readSync5(fd, lastByte, 0, 1, offset - 1);
395646
395864
  } finally {
395647
395865
  closeSync23(fd);
395648
395866
  }
@@ -395715,7 +395933,7 @@ function updateRunIndex(paths3, event, eventPath) {
395715
395933
  };
395716
395934
  const start = index.journalBytes ?? 0, bytes5 = Buffer.alloc(size - start), fd = openSync23(paths3.eventsJsonlPath, "r");
395717
395935
  try {
395718
- readSync4(fd, bytes5, 0, bytes5.length, start);
395936
+ readSync5(fd, bytes5, 0, bytes5.length, start);
395719
395937
  } finally {
395720
395938
  closeSync23(fd);
395721
395939
  }
@@ -397123,13 +397341,14 @@ var FocusSupervisor = class {
397123
397341
  if (input2.taskEpoch !== void 0)
397124
397342
  this.setTaskEpoch(input2.taskEpoch, input2.turn);
397125
397343
  this.expireDirectiveIfNeeded(input2.turn);
397126
- this.lastContext = input2.context ?? this.lastContext;
397344
+ const previousContext = this.lastContext;
397345
+ this.lastContext = input2.context ?? previousContext;
397127
397346
  if (!this.enabled)
397128
397347
  return this.pass();
397129
- if (input2.context && this.lastContext && this.ignoredDirectiveStreak > 0) {
397130
- const oldP = this.lastContext.pressureRatio ?? 0;
397348
+ if (input2.context && previousContext && this.ignoredDirectiveStreak > 0) {
397349
+ const oldP = previousContext.pressureRatio ?? 0;
397131
397350
  const newP = input2.context.pressureRatio ?? 0;
397132
- const oldS = this.lastContext.signalToNoiseRatio;
397351
+ const oldS = previousContext.signalToNoiseRatio;
397133
397352
  const newS = input2.context.signalToNoiseRatio;
397134
397353
  const pressureShift = oldP > 0 ? Math.abs(newP - oldP) / oldP : 0;
397135
397354
  const snrShift = oldS !== void 0 && oldS > 0 ? Math.abs((newS ?? 0) - oldS) / oldS : 0;
@@ -402594,7 +402813,7 @@ function renderObjectivePhaseSteering(frontier, convergence, authority = "adviso
402594
402813
  }
402595
402814
 
402596
402815
  // packages/orchestrator/dist/taskEffectEvidence.js
402597
- import { constants as constants13, closeSync as closeSync24, fstatSync as fstatSync6, openSync as openSync24, readFileSync as readFileSync64, realpathSync as realpathSync18, statSync as statSync31 } from "node:fs";
402816
+ import { constants as constants13, closeSync as closeSync24, fstatSync as fstatSync7, openSync as openSync24, readFileSync as readFileSync64, realpathSync as realpathSync18, statSync as statSync31 } from "node:fs";
402598
402817
  import { dirname as dirname42, isAbsolute as isAbsolute28, relative as relative22, resolve as resolve42 } from "node:path";
402599
402818
  import { createHash as createHash120 } from "node:crypto";
402600
402819
 
@@ -402754,13 +402973,13 @@ function reopenTaskEffectStateEvidence(input2) {
402754
402973
  continue;
402755
402974
  }
402756
402975
  fd = openSync24(actual, constants13.O_RDONLY | constants13.O_NOFOLLOW);
402757
- const before = fstatSync6(fd);
402976
+ const before = fstatSync7(fd);
402758
402977
  artifact5.byteLength = before.size;
402759
402978
  if (!before.isFile() || before.size > 1024 * 1024) {
402760
402979
  artifacts.push(artifact5);
402761
402980
  continue;
402762
402981
  }
402763
- const bytes5 = readFileSync64(fd), after = fstatSync6(fd);
402982
+ const bytes5 = readFileSync64(fd), after = fstatSync7(fd);
402764
402983
  const current6 = statSync31(candidate);
402765
402984
  if (realpathSync18(candidate) !== actual || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || after.dev !== current6.dev || after.ino !== current6.ino || after.size !== current6.size || after.mtimeMs !== current6.mtimeMs || after.ctimeMs !== current6.ctimeMs) {
402766
402985
  artifact5.status = "changed_during_read";
@@ -404824,6 +405043,7 @@ var AgenticRunner = class _AgenticRunner {
404824
405043
  _lastContextFrameDiagnostics = null;
404825
405044
  _lastContextPressureSnapshot = null;
404826
405045
  _lastFocusContextSnapshot = null;
405046
+ _semanticObservationHashes = /* @__PURE__ */ new Map();
404827
405047
  _lastActiveForgettingReport = null;
404828
405048
  _lastContextConsolidationTurn = -1e3;
404829
405049
  /** WO-CE-BOUNDARY: Context engine instance for structured context assembly */
@@ -405754,7 +405974,7 @@ ${parts.join("\n")}
405754
405974
  const gitContract = this._workspaceContextPaths().length ? renderGitProgressActionContract(this._gitProgress) : null;
405755
405975
  if (gitContract)
405756
405976
  lines.push(gitContract);
405757
- const snapshot2 = this._currentWorkboardSnapshotForFrame();
405977
+ const snapshot2 = this._modelVisibleWorkboard(this._currentWorkboardSnapshotForFrame());
405758
405978
  const action = snapshot2 ? this._deriveWorkboardActionContract(snapshot2) : null;
405759
405979
  if (snapshot2 && action) {
405760
405980
  const byId = new Map(snapshot2.cards.map((card) => [card.id, card]));
@@ -410896,8 +411116,9 @@ ${workflowStatus}` } : {}
410896
411116
  previous: steeringPending ? void 0 : this._appendOnlyOutbound,
410897
411117
  acceptedReceipts,
410898
411118
  exactSources: new Map([...this._canonicalExactSources.get(request) ?? []].filter(([, content]) => request.messages.some((message3) => typeof message3.content === "string" && message3.content.includes(content)))),
410899
- // The exact extended packet below decides whether retained updates fit;
410900
- // a fixed character cap cannot represent a 262k-token model's budget.
411119
+ // Exact-source additions use physical admission below. Independently,
411120
+ // projectAppendOnlyOutbound bounds accumulated control-frame deltas;
411121
+ // a large context window is not permission to retain stale control.
410901
411122
  maxUpdateChars: Number.POSITIVE_INFINITY,
410902
411123
  kinds: [
410903
411124
  { marker: CANONICAL_TASK_FRAME_MARKER, label: "canonical task frame" },
@@ -410929,7 +411150,13 @@ ${workflowStatus}` } : {}
410929
411150
  if (projected.mode === "extended") {
410930
411151
  const extendedBudget = this._outboundRequestBudget({ ...request, messages: projected.messages });
410931
411152
  if (extendedBudget.compactionEligible) {
410932
- this._appendOnlyOutbound = { ...projected.state, sent: request.messages, updateChars: 0 };
411153
+ this._appendOnlyOutbound = {
411154
+ ...projected.state,
411155
+ sent: request.messages,
411156
+ updateChars: 0,
411157
+ frameUpdateChars: 0,
411158
+ frameUpdateCount: 0
411159
+ };
410933
411160
  record9("full", "extension_needs_compaction");
410934
411161
  return;
410935
411162
  }
@@ -411225,12 +411452,12 @@ ${workflowStatus}` } : {}
411225
411452
  }
411226
411453
  if (record9) {
411227
411454
  const focusSnapshot = {
411228
- estimatedTokens: record9.metrics.estimatedTokens,
411455
+ estimatedTokens: exactBudget.totalInputTokens,
411229
411456
  rawDiscoveryChars: record9.metrics.rawDiscoveryToolChars,
411230
411457
  activeEvidenceChars: record9.metrics.activeEvidenceChars,
411231
411458
  activeFrameChars: record9.metrics.activeContextFrameChars,
411232
411459
  signalToNoiseRatio: record9.metrics.signalToNoise.ratio,
411233
- pressureRatio: this._lastContextPressureSnapshot?.rawRatio ?? (this.options.contextWindowSize ? record9.metrics.estimatedTokens / this.options.contextWindowSize : 0),
411460
+ pressureRatio: exactBudget.modelContextTokens ? exactBudget.totalInputTokens / exactBudget.modelContextTokens : 0,
411234
411461
  droppedSignals: this._lastContextFrameDiagnostics?.droppedSignals ?? this._lastContextPressureSnapshot?.droppedSignals,
411235
411462
  truncatedSignals: this._lastContextFrameDiagnostics?.truncatedSignals ?? this._lastContextPressureSnapshot?.truncatedSignals
411236
411463
  };
@@ -412342,9 +412569,11 @@ Use exact start_char/end_char or start_line/end_line ranges, or query/resume_sou
412342
412569
  }
412343
412570
  _buildFocusContextSnapshot() {
412344
412571
  const last = this._lastFocusContextSnapshot;
412572
+ const physical2 = this._lastOutboundRequestBudget;
412345
412573
  return {
412346
- pressureRatio: this._lastContextPressureSnapshot?.rawRatio ?? 0,
412347
- estimatedTokens: this._lastContextPressureSnapshot?.rawTokens ?? last?.estimatedTokens,
412574
+ pressureRatio: physical2 ? physical2.totalInputTokens / physical2.modelContextTokens : last?.pressureRatio ?? 0,
412575
+ estimatedTokens: physical2?.totalInputTokens ?? last?.estimatedTokens ?? this._lastContextPressureSnapshot?.rawTokens,
412576
+ semanticContext: this._lastContextPressureSnapshot?.semanticContext,
412348
412577
  rawDiscoveryChars: last?.rawDiscoveryChars,
412349
412578
  activeEvidenceChars: last?.activeEvidenceChars,
412350
412579
  activeFrameChars: this._lastContextFrameDiagnostics?.totalChars ?? last?.activeFrameChars,
@@ -419358,13 +419587,14 @@ ${sections.join("\n")}` : sections.join("\n");
419358
419587
  targetTokens: input2.targetTokens
419359
419588
  });
419360
419589
  if (helperSnapshot && typeof helperSnapshot === "object") {
419361
- snapshot2 = {
419362
- ...snapshot2,
419363
- ...helperSnapshot
419590
+ snapshot2.semanticContext = {
419591
+ rawTokens: Number(helperSnapshot.rawTokens ?? 0),
419592
+ totalTokens: Number(helperSnapshot.totalTokens ?? 0),
419593
+ unconsolidatedRatio: Number(helperSnapshot.rawRatio ?? 0),
419594
+ targetRawTokenBudget: Number(helperSnapshot.targetTokens ?? input2.targetTokens)
419364
419595
  };
419365
- snapshot2.rawTokens = Number(snapshot2.rawTokens ?? input2.rawTokens);
419366
- snapshot2.targetTokens = Number(snapshot2.targetTokens ?? input2.targetTokens);
419367
- snapshot2.rawRatio = Number(snapshot2.rawRatio ?? (snapshot2.targetTokens > 0 ? (snapshot2.rawTokens / snapshot2.targetTokens).toFixed(3) : 0));
419596
+ snapshot2.droppedSignals = helperSnapshot.droppedSignals;
419597
+ snapshot2.truncatedSignals = helperSnapshot.truncatedSignals;
419368
419598
  }
419369
419599
  }
419370
419600
  } catch {
@@ -430240,6 +430470,8 @@ ${dynamicProjectContext}`
430240
430470
  const MAX_CONSECUTIVE_THINK_ONLY = 6;
430241
430471
  let consecutiveEmptyResponses = 0;
430242
430472
  const repeatedFailedShellGuard = new RepeatedFailedShellGuard();
430473
+ const unchangedObservationGuard = new UnchangedObservationGuard();
430474
+ this._semanticObservationHashes.clear();
430243
430475
  let sameToolFailStreak = 0;
430244
430476
  let sameToolFailName = null;
430245
430477
  let lastFailureHandoffTurn = -1;
@@ -433723,6 +433955,64 @@ Evidence: ${evidencePreview}`.slice(0, 500);
433723
433955
  });
433724
433956
  }
433725
433957
  }
433958
+ if (!this._terminalRuntimeFailure && evidenceScope.runId === this.currentArtifactRunId() && evidenceScope.taskEpoch === this._taskEpoch && failedShellOwnerScope === this._objectiveProgressScopeKey() && !progressOnly) {
433959
+ const canonicalName = resolvedTool?.name ?? tc.name;
433960
+ const operationSha256 = taskExecutionDigest({
433961
+ toolName: canonicalName,
433962
+ args: tc.arguments ?? {},
433963
+ cwd: result.executionReceipt?.cwd ?? this.authoritativeWorkingDirectory()
433964
+ });
433965
+ const resultSha256 = this._completeToolObservationSha256(result, canonicalName);
433966
+ if (resultSha256) {
433967
+ this._semanticObservationHashes.set(tc.id, resultSha256);
433968
+ if (this._semanticObservationHashes.size > 512)
433969
+ this._semanticObservationHashes.delete(this._semanticObservationHashes.keys().next().value);
433970
+ }
433971
+ const repeatedAttempts = unchangedObservationGuard.observe({
433972
+ scope: JSON.stringify([failedShellOwnerScope, this._toolObservationScopeIdentity(result)]),
433973
+ operationSha256,
433974
+ resultSha256,
433975
+ observation: isReadLike && !realFileMutation && !shellFilesystemMutation && (result.runtimeAuthored !== true || result.evidenceOrigin === "reused"),
433976
+ reused: result.evidenceOrigin === "reused"
433977
+ });
433978
+ if (repeatedAttempts >= 3) {
433979
+ const guidance = `UNCHANGED OBSERVATION: this exact read has returned the same complete evidence ${repeatedAttempts} times. A new log/archive ID is not a new finding. Use the retained evidence to answer the user's requested question or design, or select a different, focused observation that resolves a named missing fact (log_explore can inspect omitted output). An available edit tool or inferred repair card does not require implementation. If implementation was requested, perform the remaining change and verification; do not claim it already happened.`;
433980
+ runtimeSystemGuidance = [runtimeSystemGuidance, guidance].filter(Boolean).join("\n\n");
433981
+ this._recordRecoveryControllerDelta({
433982
+ source: "unchanged_observation",
433983
+ turn,
433984
+ diagnosis: `UNCHANGED OBSERVATION: ${canonicalName} returned identical complete evidence ${repeatedAttempts} times; changing archive IDs are presentation.`,
433985
+ nextAction: "Answer the requested question/design using retained evidence, or resolve a named missing fact with a different focused read (log_explore for omitted output). Perform edits and tests only when requested; inferred repair cards do not require them.",
433986
+ verification: "A useful answer or verified requested change must be accepted; another unchanged read is not progress.",
433987
+ review: this._beginRecoveryReview()
433988
+ });
433989
+ }
433990
+ if (repeatedAttempts >= 8 && resultSha256) {
433991
+ this._terminalRuntimeFailure = {
433992
+ schema: "omnius.terminal-runtime-failure.v1",
433993
+ code: "repeated_observation_stall",
433994
+ phase: "after_tool",
433995
+ retryable: false,
433996
+ toolName: canonicalName,
433997
+ runId: evidenceScope.runId,
433998
+ taskEpoch: evidenceScope.taskEpoch,
433999
+ turn,
434000
+ operationSha256,
434001
+ resultSha256,
434002
+ repeatedAttempts
434003
+ };
434004
+ this._completionIncompleteVerification = {
434005
+ reason: "repeated_observation_stall",
434006
+ summary: "Repeated unchanged reads exhausted the recovery budget without an accepted answer; saved evidence remains available."
434007
+ };
434008
+ this.emit({
434009
+ type: "error",
434010
+ turn,
434011
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
434012
+ content: "Stopped after eight unchanged read observations despite recovery guidance; automatic same-input replay is disabled."
434013
+ });
434014
+ }
434015
+ }
433726
434016
  const eventExternalEffectReceipt = settled.external;
433727
434017
  const eventVerificationReceipts = settled.verifications;
433728
434018
  const eventVerificationReceipt = eventVerificationReceipts.at(-1);
@@ -439576,6 +439866,11 @@ ${marker}` : marker);
439576
439866
  args,
439577
439867
  fingerprint: fingerprint2,
439578
439868
  output,
439869
+ semanticOutcomeSha256: this._semanticObservationHashes.get(toolCallId) ?? (provenance2 ? this._completeToolObservationSha256({
439870
+ success: success !== false,
439871
+ output,
439872
+ ...provenance2
439873
+ }, toolName) : void 0),
439579
439874
  success: success !== false,
439580
439875
  turn: this._taskState?.toolCallCount ?? 0
439581
439876
  });
@@ -442580,7 +442875,7 @@ ${trimmedNew}`;
442580
442875
  fingerprint: fingerprint2,
442581
442876
  stateVersion: this._adversaryStateVersion,
442582
442877
  succeeded: input2.result.success === true,
442583
- observationSha256: this._completeToolObservationSha256(input2.result),
442878
+ observationSha256: this._completeToolObservationSha256(input2.result, input2.toolName),
442584
442879
  scopeIdentity: this._toolObservationScopeIdentity(input2.result),
442585
442880
  ...outcomeEvidence
442586
442881
  });
@@ -442602,17 +442897,9 @@ ${trimmedNew}`;
442602
442897
  * Detect the semantic pattern from actual executed calls, while keeping it
442603
442898
  * strictly advisory: it must never become a completion gate.
442604
442899
  */
442605
- _completeToolObservationSha256(result) {
442900
+ _completeToolObservationSha256(result, toolName) {
442606
442901
  try {
442607
- return _createHash("sha256").update(JSON.stringify({
442608
- success: result.success,
442609
- partial: result.partial,
442610
- output: result.output,
442611
- llmContent: result.llmContent,
442612
- error: result.error,
442613
- data: result.data,
442614
- operatorDetail: result.operatorDetail
442615
- })).digest("hex");
442902
+ return stableSemanticOutcomeSha256(result, { shell: toolName !== void 0 && (this.lookupRegisteredTool(toolName)?.name ?? toolName) === "shell" });
442616
442903
  } catch {
442617
442904
  return void 0;
442618
442905
  }
@@ -460542,7 +460829,7 @@ import { isAbsolute as isAbsolute36, join as join81, dirname as dirname45 } from
460542
460829
  init_dist();
460543
460830
  init_dist5();
460544
460831
  import { createHash as createHash134 } from "node:crypto";
460545
- import { openSync as openSync25, closeSync as closeSync25, fstatSync as fstatSync7, readSync as readSync5, constants as constants16 } from "node:fs";
460832
+ import { openSync as openSync25, closeSync as closeSync25, fstatSync as fstatSync8, readSync as readSync6, constants as constants16 } from "node:fs";
460546
460833
  import { fileURLToPath as fileURLToPath9 } from "node:url";
460547
460834
  import { z as z31 } from "zod";
460548
460835
  var NOL_VLLM_RUNTIME_VERSION = "omnius.nol.vllm-runtime.v1";
@@ -460552,7 +460839,7 @@ function nolVllmModuleDigest(url) {
460552
460839
  constants16.O_RDONLY | constants16.O_NOFOLLOW
460553
460840
  );
460554
460841
  try {
460555
- const before = fstatSync7(fd);
460842
+ const before = fstatSync8(fd);
460556
460843
  need5(
460557
460844
  before.isFile() && before.size <= 64 * 1048576,
460558
460845
  "bounded regular host code required"
@@ -460560,11 +460847,11 @@ function nolVllmModuleDigest(url) {
460560
460847
  const bytes5 = Buffer.alloc(before.size + 1);
460561
460848
  let count8 = 0;
460562
460849
  while (count8 < bytes5.length) {
460563
- const n = readSync5(fd, bytes5, count8, bytes5.length - count8, null);
460850
+ const n = readSync6(fd, bytes5, count8, bytes5.length - count8, null);
460564
460851
  if (!n) break;
460565
460852
  count8 += n;
460566
460853
  }
460567
- const after = fstatSync7(fd);
460854
+ const after = fstatSync8(fd);
460568
460855
  need5(
460569
460856
  count8 === before.size && before.dev === after.dev && before.ino === after.ino && before.size === after.size && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs,
460570
460857
  "host code changed during inventory"
@@ -475467,7 +475754,7 @@ import {
475467
475754
  constants as constants23,
475468
475755
  closeSync as closeSync28,
475469
475756
  existsSync as existsSync61,
475470
- fstatSync as fstatSync8,
475757
+ fstatSync as fstatSync9,
475471
475758
  fsyncSync as fsyncSync16,
475472
475759
  lstatSync as lstatSync18,
475473
475760
  mkdirSync as mkdirSync47,
@@ -476244,7 +476531,7 @@ var NativeJournal = class {
476244
476531
  constants23.O_RDONLY | constants23.O_NOFOLLOW
476245
476532
  );
476246
476533
  try {
476247
- const info2 = fstatSync8(keyFd);
476534
+ const info2 = fstatSync9(keyFd);
476248
476535
  need23(
476249
476536
  info2.isFile() && info2.uid === process.getuid() && (info2.mode & 63) === 0 && info2.nlink === 1 && info2.size === 32,
476250
476537
  "Invalid native authority key custody"