dsh-completion-guard 0.8.2 → 0.8.3

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.
@@ -21,7 +21,7 @@ const physicalFs = process.versions.electron ? createRequire(import.meta.url)("o
21
21
 
22
22
  //#endregion
23
23
  //#region src/domain/host-audit-session.ts
24
- const { existsSync: existsSync$4, readFileSync: readFileSync$3, readdirSync, realpathSync: realpathSync$4, statSync: statSync$2 } = physicalFs;
24
+ const { existsSync: existsSync$4, readFileSync: readFileSync$3, readdirSync: readdirSync$1, realpathSync: realpathSync$4, statSync: statSync$2 } = physicalFs;
25
25
  function createHostAuditSession(onPhysicalRead) {
26
26
  const cache = /* @__PURE__ */ new Map();
27
27
  const once = (key, compute) => {
@@ -56,7 +56,7 @@ function createHostAuditSession(onPhysicalRead) {
56
56
  readFile: (path$1) => readBytes(path$1),
57
57
  readJson: (path$1) => once(`json:${path$1}`, () => JSON.parse(session.readFile(path$1).toString("utf8"))),
58
58
  fileDigest: (path$1) => once(`digest:${path$1}`, () => createFileDigest(session.readFile(path$1))),
59
- listDir: (dir) => once(`listdir:${dir}`, () => readdirSync(dir, { withFileTypes: true }).map((entry) => ({
59
+ listDir: (dir) => once(`listdir:${dir}`, () => readdirSync$1(dir, { withFileTypes: true }).map((entry) => ({
60
60
  name: entry.name,
61
61
  isFile: entry.isFile(),
62
62
  isDirectory: entry.isDirectory()
@@ -9092,6 +9092,22 @@ const DESKTOP_GRAPH_ROOT = "dsh/node_modules";
9092
9092
  const DESKTOP_CARRIER_ENTRY = "dsh/node_modules/@deepseek-ai/dsh-desktop-host/lib/cli.js";
9093
9093
  const MAX_ASAR_HEADER_BYTES = 128 * 1024 * 1024;
9094
9094
  const MAX_ASAR_FILE_BYTES = 64 * 1024 * 1024;
9095
+ /**
9096
+ * CG-083-PERF03: operation-scoped asar reads. Within ONE host-lock
9097
+ * validation the same helpers used to re-open the archive and re-read the
9098
+ * header, metadata and module bytes several times; with a session, the index
9099
+ * and every entry's bytes are memoized on that operation's audit session —
9100
+ * they live and die with the validation and are never a cross-entry cache.
9101
+ * Without a session the original direct reads run unchanged.
9102
+ */
9103
+ function memoizedAsarIndex(session, archivePath) {
9104
+ if (!session) return readAsarIndex(archivePath);
9105
+ return session.memo(`desktop-asar-index:${archivePath}`, () => readAsarIndex(archivePath));
9106
+ }
9107
+ function memoizedAsarFile(session, archivePath, index$1, entryPath) {
9108
+ if (!session) return readAsarFile(archivePath, index$1, entryPath);
9109
+ return session.memo(`desktop-asar-bytes:${archivePath}\u0000${entryPath}`, () => readAsarFile(archivePath, index$1, entryPath));
9110
+ }
9095
9111
  /** Read the asar header (the JSON index) without extracting any payload. */
9096
9112
  function readAsarIndex(archivePath) {
9097
9113
  const header = Buffer.alloc(16);
@@ -9196,15 +9212,15 @@ function isRecord(value) {
9196
9212
  * manifest, the `desktop-runtime.json` metadata block, and the official CLI
9197
9213
  * carrier entry the app installs.
9198
9214
  */
9199
- function readDesktopAppRuntime(appAsarPath) {
9215
+ function readDesktopAppRuntime(appAsarPath, session) {
9200
9216
  if (!isAbsolute(appAsarPath)) throw new HostProfileError("desktop_app_invalid", "the app archive path must be absolute");
9201
9217
  if (!existsSync$2(appAsarPath) || !lstatSync$2(appAsarPath).isFile()) throw new HostProfileError("desktop_app_missing", "the official app archive was not found");
9202
9218
  const asarRealpath = realpathSync$2(appAsarPath);
9203
- const index$1 = readAsarIndex(asarRealpath);
9219
+ const index$1 = memoizedAsarIndex(session, asarRealpath);
9204
9220
  if (!asarNode(index$1, DESKTOP_CARRIER_ENTRY.split("/"))) throw new HostProfileError("desktop_app_invalid", "the official CLI carrier entry is missing from the app bundle");
9205
- readAsarFile(asarRealpath, index$1, DESKTOP_CARRIER_ENTRY);
9206
- const manifestBytes = readAsarFile(asarRealpath, index$1, DESKTOP_RUNTIME_MANIFEST_ENTRY);
9207
- const metadataBytes = readAsarFile(asarRealpath, index$1, DESKTOP_RUNTIME_METADATA_ENTRY);
9221
+ memoizedAsarFile(session, asarRealpath, index$1, DESKTOP_CARRIER_ENTRY);
9222
+ const manifestBytes = memoizedAsarFile(session, asarRealpath, index$1, DESKTOP_RUNTIME_MANIFEST_ENTRY);
9223
+ const metadataBytes = memoizedAsarFile(session, asarRealpath, index$1, DESKTOP_RUNTIME_METADATA_ENTRY);
9208
9224
  const manifest = JSON.parse(manifestBytes.toString("utf8"));
9209
9225
  const metadata = JSON.parse(metadataBytes.toString("utf8"));
9210
9226
  if (manifest.name !== DESKTOP_RUNTIME_PACKAGE_NAME) throw new HostProfileError("desktop_app_invalid", "the app runtime manifest is not the official desktop runtime");
@@ -9311,10 +9327,10 @@ function readDesktopTargetGraph(appAsarPath, profileRoot) {
9311
9327
  * graph is an ambiguity no adapter resolves, so its presence fails closed
9312
9328
  * before any digest is computed.
9313
9329
  */
9314
- function auditDesktopInstalledImplementation(appAsarPath, expectations) {
9330
+ function auditDesktopInstalledImplementation(appAsarPath, expectations, session) {
9315
9331
  try {
9316
9332
  const realArchive = realpathSync$2(appAsarPath);
9317
- const index$1 = readAsarIndex(realArchive);
9333
+ const index$1 = memoizedAsarIndex(session, realArchive);
9318
9334
  const { CRITICAL_NAME_SET } = criticalNames();
9319
9335
  const topLevelRoot = DESKTOP_GRAPH_ROOT.split("/");
9320
9336
  const scan = (node, parts, depth) => {
@@ -9332,7 +9348,7 @@ function auditDesktopInstalledImplementation(appAsarPath, expectations) {
9332
9348
  };
9333
9349
  scan(index$1.root, [], 0);
9334
9350
  const fileTable = /* @__PURE__ */ new Map();
9335
- const metadataBytes = readAsarFile(realArchive, index$1, DESKTOP_RUNTIME_METADATA_ENTRY);
9351
+ const metadataBytes = memoizedAsarFile(session, realArchive, index$1, DESKTOP_RUNTIME_METADATA_ENTRY);
9336
9352
  const metadata = JSON.parse(metadataBytes.toString("utf8"));
9337
9353
  if (Array.isArray(metadata.files)) {
9338
9354
  for (const entry of metadata.files) if (entry && typeof entry === "object" && typeof entry.path === "string" && /^[a-f0-9]{64}$/.test(String(entry.sha256))) fileTable.set(`dsh/${entry.path}`, String(entry.sha256));
@@ -9341,7 +9357,7 @@ function auditDesktopInstalledImplementation(appAsarPath, expectations) {
9341
9357
  const parts = [...topLevelRoot, ...expected.name.split("/")];
9342
9358
  const node = asarNode(index$1, parts);
9343
9359
  if (!node || !node.files) return false;
9344
- const manifestBytes = readAsarFile(realArchive, index$1, [...parts, "package.json"].join("/"));
9360
+ const manifestBytes = memoizedAsarFile(session, realArchive, index$1, [...parts, "package.json"].join("/"));
9345
9361
  const manifest = JSON.parse(manifestBytes.toString("utf8"));
9346
9362
  if (manifest.name !== expected.name || manifest.version !== expected.version) return false;
9347
9363
  const inventory = [];
@@ -9363,10 +9379,10 @@ function auditDesktopInstalledImplementation(appAsarPath, expectations) {
9363
9379
  for (const file of inventory) {
9364
9380
  const tableEntry = fileTable.get(`${DESKTOP_GRAPH_ROOT}/${expected.name}/${file}`);
9365
9381
  if (tableEntry === void 0) return false;
9366
- if (tableEntry !== createHash("sha256").update(readAsarFile(realArchive, index$1, [...parts, ...file.split("/")].join("/"))).digest("hex")) return false;
9382
+ if (tableEntry !== createHash("sha256").update(memoizedAsarFile(session, realArchive, index$1, [...parts, ...file.split("/")].join("/"))).digest("hex")) return false;
9367
9383
  }
9368
9384
  for (const file of Object.keys(expected.modules ?? {})) {
9369
- const actual = createHash("sha256").update(readAsarFile(realArchive, index$1, [...parts, ...file.split("/")].join("/"))).digest("hex");
9385
+ const actual = createHash("sha256").update(memoizedAsarFile(session, realArchive, index$1, [...parts, ...file.split("/")].join("/"))).digest("hex");
9370
9386
  if (expected.modules[file] === actual) continue;
9371
9387
  if (file === "package.json") continue;
9372
9388
  return false;
@@ -9421,12 +9437,12 @@ const DESKTOP_IDENTITY_FACTS = {
9421
9437
  * installed-byte audit separately refuses nested critical duplicates, so a
9422
9438
  * nested-only dependency can never be silently resolved here).
9423
9439
  */
9424
- function readDesktopDependency(appAsarPath, name) {
9440
+ function readDesktopDependency(appAsarPath, name, session) {
9425
9441
  const realArchive = realpathSync$2(appAsarPath);
9426
- const index$1 = readAsarIndex(realArchive);
9442
+ const index$1 = memoizedAsarIndex(session, realArchive);
9427
9443
  const manifestPath = `${DESKTOP_GRAPH_ROOT}/${name}/package.json`;
9428
9444
  if (!asarNode(index$1, manifestPath.split("/"))) throw new HostProfileError("host_contract_probe_dependency_unbound", `dependency ${name} has no top-level manifest in the app graph`);
9429
- const bytes$1 = readAsarFile(realArchive, index$1, manifestPath);
9445
+ const bytes$1 = memoizedAsarFile(session, realArchive, index$1, manifestPath);
9430
9446
  const manifest = JSON.parse(bytes$1.toString("utf8"));
9431
9447
  if (manifest.name !== name || typeof manifest.version !== "string" || !parseHostVersion(manifest.version)) throw new HostProfileError("host_contract_probe_dependency_unbound", `dependency ${name} has an invalid manifest identity`);
9432
9448
  return {
@@ -9598,7 +9614,7 @@ function desktopDependencyGraph(archive, expectations, base = createHostAuditSes
9598
9614
 
9599
9615
  //#endregion
9600
9616
  //#region src/domain/host-resolver.ts
9601
- const { existsSync: existsSync$1, lstatSync: lstatSync$1, readFileSync: readFileSync$1, realpathSync: realpathSync$1, renameSync, statSync: statSync$1, writeFileSync: writeFileSync$1 } = physicalFs;
9617
+ const { existsSync: existsSync$1, lstatSync: lstatSync$1, readFileSync: readFileSync$1, realpathSync: realpathSync$1, renameSync: renameSync$1, statSync: statSync$1, writeFileSync: writeFileSync$1 } = physicalFs;
9602
9618
  /**
9603
9619
  * Names registered in any cohort; rows outside the union are unknown.
9604
9620
  *
@@ -10337,8 +10353,8 @@ function verifyDesktopPluginIdentity(profileRoot, expectedPluginVersion) {
10337
10353
  * fresh runtime revalidation, so both compute the same digest. */
10338
10354
  function reevaluateDesktopCoreLock(appAsarPath, profileRoot, trust) {
10339
10355
  const profile = resolve(profileRoot);
10340
- const runtime = readDesktopAppRuntime(appAsarPath);
10341
10356
  const session = createHostAuditSession();
10357
+ const runtime = readDesktopAppRuntime(appAsarPath, session);
10342
10358
  const executable = verifyDesktopCarrier(runtime.asarRealpath, runtime.headerSha256);
10343
10359
  const pluginManifestPath = join(profile, "node_modules", "dsh-completion-guard", "package.json");
10344
10360
  const installedPlugin = session.readJson(pluginManifestPath);
@@ -10352,7 +10368,7 @@ function reevaluateDesktopCoreLock(appAsarPath, profileRoot, trust) {
10352
10368
  }, trust ? JSON.stringify(trust) : void 0, profile);
10353
10369
  if (evaluation.status !== "supported") return evaluation;
10354
10370
  const expectations = trust ? [...trust.packages, ...trust.probeDependencies ?? []] : packages$1;
10355
- if (!auditDesktopInstalledImplementation(runtime.asarRealpath, expectations)) return {
10371
+ if (!auditDesktopInstalledImplementation(runtime.asarRealpath, expectations, session)) return {
10356
10372
  ...evaluation,
10357
10373
  status: "unsupported",
10358
10374
  goalAvailable: false,
@@ -10538,7 +10554,7 @@ function injectActiveProfileHostLock(input) {
10538
10554
  encoding: "utf8",
10539
10555
  flag: "wx"
10540
10556
  });
10541
- renameSync(temporary, patchPath);
10557
+ renameSync$1(temporary, patchPath);
10542
10558
  return patchPath;
10543
10559
  }
10544
10560
  function parseYamlScalar(value) {
@@ -10731,6 +10747,76 @@ function sanitizeUrl(value) {
10731
10747
  return cut === Infinity ? value : value.slice(0, cut);
10732
10748
  }
10733
10749
 
10750
+ //#endregion
10751
+ //#region src/domain/parse-cache.ts
10752
+ /** Pure parser storage only. Never store projections, evidence or authority. */
10753
+ var ParseCache = class {
10754
+ probation = /* @__PURE__ */ new Map();
10755
+ protected = /* @__PURE__ */ new Map();
10756
+ bytes = 0;
10757
+ protectedBytes = 0;
10758
+ constructor(byteBudget, entryBudget = 32768) {
10759
+ this.byteBudget = byteBudget;
10760
+ this.entryBudget = entryBudget;
10761
+ }
10762
+ get(key) {
10763
+ const hot = this.protected.get(key);
10764
+ if (hot) {
10765
+ this.protected.delete(key);
10766
+ this.protected.set(key, hot);
10767
+ return hot.value;
10768
+ }
10769
+ const entry = this.probation.get(key);
10770
+ if (!entry) return void 0;
10771
+ this.probation.delete(key);
10772
+ this.protected.set(key, entry);
10773
+ this.protectedBytes += entry.bytes;
10774
+ while (this.protectedBytes > this.byteBudget * .75) {
10775
+ const oldest = this.protected.keys().next().value;
10776
+ const row$3 = this.protected.get(oldest);
10777
+ this.protected.delete(oldest);
10778
+ this.protectedBytes -= row$3.bytes;
10779
+ this.probation.set(oldest, row$3);
10780
+ }
10781
+ return entry.value;
10782
+ }
10783
+ set(key, value, valueBytes) {
10784
+ const bytes$1 = key.length * 2 + valueBytes + 128;
10785
+ if (bytes$1 > this.byteBudget) return;
10786
+ const cold = this.probation.get(key), hot = this.protected.get(key);
10787
+ if (cold) {
10788
+ this.bytes -= cold.bytes;
10789
+ this.probation.delete(key);
10790
+ }
10791
+ if (hot) {
10792
+ this.bytes -= hot.bytes;
10793
+ this.protectedBytes -= hot.bytes;
10794
+ this.protected.delete(key);
10795
+ }
10796
+ while (this.bytes + bytes$1 > this.byteBudget || this.probation.size + this.protected.size >= this.entryBudget) {
10797
+ const segment = this.probation.size ? this.probation : this.protected;
10798
+ const oldest = segment.keys().next().value;
10799
+ if (oldest === void 0) break;
10800
+ const row$3 = segment.get(oldest);
10801
+ this.bytes -= row$3.bytes;
10802
+ if (segment === this.protected) this.protectedBytes -= row$3.bytes;
10803
+ segment.delete(oldest);
10804
+ }
10805
+ this.probation.set(key, {
10806
+ value,
10807
+ bytes: bytes$1
10808
+ });
10809
+ this.bytes += bytes$1;
10810
+ }
10811
+ /** Deterministic storage diagnostics, without exposing keys or parsed text. */
10812
+ storage() {
10813
+ return {
10814
+ entries: this.probation.size + this.protected.size,
10815
+ bytes: this.bytes
10816
+ };
10817
+ }
10818
+ };
10819
+
10734
10820
  //#endregion
10735
10821
  //#region src/domain/manifest.ts
10736
10822
  const COMMAND_SURFACE_MANIFEST = {
@@ -10923,14 +11009,12 @@ function kindOfScope(directive, body = "") {
10923
11009
  * Backticks are Markdown emphasis, but they are also how a log line or a
10924
11010
  * command is quoted — and a quoted command is data, never an order.
10925
11011
  */
10926
- const MASK_CACHE = /* @__PURE__ */ new Map();
10927
- const MASK_CACHE_LIMIT = 64;
11012
+ const MASK_CACHE = new ParseCache(4 * 1024 * 1024);
10928
11013
  function maskCodeSpans(text) {
10929
11014
  const cached = MASK_CACHE.get(text);
10930
11015
  if (cached !== void 0) return cached;
10931
11016
  const masked = computeMaskedSpans(text);
10932
- if (MASK_CACHE.size >= MASK_CACHE_LIMIT) MASK_CACHE.clear();
10933
- MASK_CACHE.set(text, masked);
11017
+ MASK_CACHE.set(text, masked, masked.length * 2);
10934
11018
  return masked;
10935
11019
  }
10936
11020
  function computeMaskedSpans(text) {
@@ -11334,9 +11418,21 @@ function quotedSpans(text) {
11334
11418
  inside
11335
11419
  };
11336
11420
  }
11337
- /** Blank out every quoted span of the text. */
11421
+ /**
11422
+ * CG-083-PERF02 (profile-guided): maskQuotedSpans is a pure function of the
11423
+ * text and capture re-asks it many times per clause on long histories
11424
+ * (segmentsForBoundary, captureItem, the observer-method scan all mask the
11425
+ * same strings). Memoize by exact input in a bounded map — a pure parse cache
11426
+ * over immutable strings, not a trust cache; any change of text produces a
11427
+ * different key.
11428
+ */
11429
+ const quotedMaskCache = new ParseCache(4 * 1024 * 1024);
11338
11430
  function maskQuotedSpans(text) {
11339
- return quotedSpans(text).masked;
11431
+ const cached = quotedMaskCache.get(text);
11432
+ if (cached !== void 0) return cached;
11433
+ const masked = quotedSpans(text).masked;
11434
+ quotedMaskCache.set(text, masked, masked.length * 2);
11435
+ return masked;
11340
11436
  }
11341
11437
  /** Whether the offset lies inside a quoted span. */
11342
11438
  function insideQuote(masked, index$1) {
@@ -12457,7 +12553,10 @@ function negatedSpanEnd(text, start) {
12457
12553
  const character = text[cursor];
12458
12554
  if (character === "\n" || character === "\r") return cursor;
12459
12555
  if (character === "。" || character === "!" || character === "?" || character === "!" || character === "?") return cursor;
12460
- if (character === "." && (cursor + 1 >= text.length || /\s/.test(text[cursor + 1]))) return cursor;
12556
+ if (character === ".") {
12557
+ if (cursor + 1 >= text.length || /\s/.test(text[cursor + 1])) return cursor;
12558
+ continue;
12559
+ }
12461
12560
  if (character === "但" && text[cursor + 1] !== "是") return cursor;
12462
12561
  if (character === "而" && text[cursor + 1] === "是") return cursor;
12463
12562
  if (character === ";" || character === ";") return cursor;
@@ -14266,7 +14365,35 @@ function extractArtifactPaths(text) {
14266
14365
  }
14267
14366
  return [...found];
14268
14367
  }
14269
- function segmentClauses(text, options = {}) {
14368
+ const clauseSegmentCache = new ParseCache(8 * 1024 * 1024);
14369
+ function copySegments(segments) {
14370
+ return segments.map((segment) => ({
14371
+ ...segment,
14372
+ paths: [...segment.paths],
14373
+ interpretation: {
14374
+ ...segment.interpretation,
14375
+ qualification: { ...segment.interpretation.qualification }
14376
+ }
14377
+ }));
14378
+ }
14379
+ /**
14380
+ * CG-083-PERF02 (profile-guided): segmentClauses is a pure parse of the text,
14381
+ * and the v6 capture path asks the SAME strings many times (splitIndependent
14382
+ * re-parses left/right fragments per delimiter, the coordination and
14383
+ * explanation paths re-parse prefixes). Cache the parse result by exact input
14384
+ * and omitted options — a pure parse cache over immutable strings, not a
14385
+ * trust cache. Every explicit options object bypasses storage, including empty,
14386
+ * inherited and accessor-bearing objects; no enumeration can prove identity.
14387
+ */
14388
+ function segmentClauses(text, options) {
14389
+ if (options !== void 0) return copySegments(segmentClausesUncached(text, options));
14390
+ const cached = clauseSegmentCache.get(text);
14391
+ if (cached !== void 0) return copySegments(cached);
14392
+ const segments = segmentClausesUncached(text);
14393
+ clauseSegmentCache.set(text, copySegments(segments), JSON.stringify(segments).length * 2);
14394
+ return copySegments(segments);
14395
+ }
14396
+ function segmentClausesUncached(text, options = {}) {
14270
14397
  const normalized = normalizeClause(text);
14271
14398
  if (!normalized) return [];
14272
14399
  return interpretMessage(normalized, options).filter((interpretation) => interpretation.text.trim().length > 0).map((interpretation) => ({
@@ -15167,6 +15294,92 @@ function capabilityRemedyPhrase(remedy) {
15167
15294
  }
15168
15295
  }
15169
15296
 
15297
+ //#endregion
15298
+ //#region src/domain/item-fold-index.ts
15299
+ const itemFoldIndexes = /* @__PURE__ */ new WeakMap();
15300
+ const KIND_PREFIXES = {
15301
+ requirement: "R",
15302
+ acceptance: "A",
15303
+ prohibition: "P"
15304
+ };
15305
+ function indexesEnabled() {
15306
+ return process.env.DSH_GUARD_DISABLE_INDEXES !== "1";
15307
+ }
15308
+ function foldIndexOf(items) {
15309
+ let index$1 = itemFoldIndexes.get(items);
15310
+ if (!index$1) {
15311
+ index$1 = {
15312
+ idCounters: /* @__PURE__ */ new Map(),
15313
+ prefixCounters: /* @__PURE__ */ new Map(),
15314
+ duplicates: /* @__PURE__ */ new Map()
15315
+ };
15316
+ itemFoldIndexes.set(items, index$1);
15317
+ }
15318
+ return index$1;
15319
+ }
15320
+ /** Register one insertion into the item map. Cheap and idempotent per id. */
15321
+ function registerFoldItem(items, item) {
15322
+ if (!indexesEnabled()) return;
15323
+ const index$1 = foldIndexOf(items);
15324
+ const kindMax = index$1.idCounters.get(item.kind);
15325
+ const kindNum = Number(item.id.slice(KIND_PREFIXES[item.kind].length));
15326
+ if (Number.isInteger(kindNum) && (kindMax === void 0 || kindNum > kindMax)) index$1.idCounters.set(item.kind, kindNum);
15327
+ for (const prefix of Object.values(KIND_PREFIXES)) {
15328
+ if (!item.id.startsWith(prefix)) continue;
15329
+ const num = Number(item.id.slice(prefix.length));
15330
+ const max = index$1.prefixCounters.get(prefix);
15331
+ if (Number.isInteger(num) && (max === void 0 || num > max)) index$1.prefixCounters.set(prefix, num);
15332
+ }
15333
+ const key = `${item.kind}\0${item.textSha256}\0${item.verification.subject}`;
15334
+ const bucket = index$1.duplicates.get(key);
15335
+ if (bucket) bucket.push(item.id);
15336
+ else index$1.duplicates.set(key, [item.id]);
15337
+ }
15338
+ /** nextId, with the same result as the historical full scan. */
15339
+ function nextIdFromIndex(items, kind) {
15340
+ if (!indexesEnabled()) return void 0;
15341
+ const index$1 = foldIndexOf(items);
15342
+ const max = index$1.idCounters.get(kind);
15343
+ if (max === void 0) {
15344
+ let seeded = 0;
15345
+ for (const item of items.values()) {
15346
+ if (item.kind !== kind) continue;
15347
+ const num = Number(item.id.slice(KIND_PREFIXES[kind].length));
15348
+ if (Number.isInteger(num) && num > seeded) seeded = num;
15349
+ }
15350
+ index$1.idCounters.set(kind, seeded);
15351
+ return `${KIND_PREFIXES[kind]}${String(seeded + 1).padStart(3, "0")}`;
15352
+ }
15353
+ return `${KIND_PREFIXES[kind]}${String(max + 1).padStart(3, "0")}`;
15354
+ }
15355
+ /** nextNumericId (literal prefix scan over all kinds), same result. */
15356
+ function nextNumericIdFromIndex(items, prefix) {
15357
+ if (!indexesEnabled()) return void 0;
15358
+ const index$1 = foldIndexOf(items);
15359
+ const max = index$1.prefixCounters.get(prefix);
15360
+ if (max === void 0) {
15361
+ let seeded = 0;
15362
+ for (const item of items.values()) {
15363
+ if (!item.id.startsWith(prefix)) continue;
15364
+ const num = Number(item.id.slice(prefix.length));
15365
+ if (Number.isInteger(num) && num > seeded) seeded = num;
15366
+ }
15367
+ index$1.prefixCounters.set(prefix, seeded);
15368
+ return seeded + 1;
15369
+ }
15370
+ return max + 1;
15371
+ }
15372
+ /** The pending duplicate the historical scan would have found, if any. */
15373
+ function findPendingDuplicateFromIndex(items, kind, textSha256, subject) {
15374
+ if (!indexesEnabled()) return void 0;
15375
+ const bucket = foldIndexOf(items).duplicates.get(`${kind}\0${textSha256}\0${subject}`);
15376
+ if (!bucket) return void 0;
15377
+ for (const id of bucket) {
15378
+ const existing = items.get(id);
15379
+ if (existing && existing.status === "pending" && existing.textSha256 === textSha256 && existing.verification.subject === subject) return existing;
15380
+ }
15381
+ }
15382
+
15170
15383
  //#endregion
15171
15384
  //#region src/domain/confirm-parse.ts
15172
15385
  const CONFIRM_LINE_PATTERN = /^确认重绑定 (RB-[a-f0-9]{24})$/;
@@ -15700,7 +15913,10 @@ function confirmRebind(p, proposalId, eventId, durable) {
15700
15913
  proposal.status = "stale";
15701
15914
  return true;
15702
15915
  }
15703
- for (const item of replacements) p.items.set(item.id, item);
15916
+ for (const item of replacements) {
15917
+ p.items.set(item.id, item);
15918
+ registerFoldItem(p.items, item);
15919
+ }
15704
15920
  old.status = "superseded";
15705
15921
  old.supersededByItems = replacements.map((item) => item.id);
15706
15922
  old.supersededBy = replacements[0].id;
@@ -17580,6 +17796,13 @@ function verifiedCore(projection) {
17580
17796
  currentActions: core.current_actions
17581
17797
  } };
17582
17798
  }
17799
+ /** Read-only core diagnostics for signing feedback; adoption never becomes
17800
+ * ordinary completion. This grants no certificate or execution authority. */
17801
+ function confirmedV6CoreDiagnostic(projection) {
17802
+ if (projection.boundaryProtocol !== 6 || projection.hostStatus !== "supported" || needsReviewObligations(projection).length) return void 0;
17803
+ const verified = verifiedCore(projection);
17804
+ return "reason" in verified ? void 0 : verified.core;
17805
+ }
17583
17806
  /**
17584
17807
  * The core's condition-release map, but ONLY from a core object that passed
17585
17808
  * the full verification chain above. A corrupt, unconfirmed or unsourceable
@@ -18767,9 +18990,28 @@ function tuplesEqual(left, right) {
18767
18990
  function transitionsEqual(left, right) {
18768
18991
  return stable$1(left) === stable$1(right);
18769
18992
  }
18993
+ /** Canonical digest rules remain strict; untrusted parameters become rejection,
18994
+ * never an exception escaping the live tool or persisted replay. */
18995
+ function checkedPredParamsDigest(parameters) {
18996
+ try {
18997
+ return predParamsDigest(parameters, resolveAllowlist("product"));
18998
+ } catch (error) {
18999
+ if (error instanceof DigestError) return void 0;
19000
+ throw error;
19001
+ }
19002
+ }
19003
+ function bindingParametersProblem(binding) {
19004
+ const parameters = binding.expectedTransition?.parameters;
19005
+ if (parameters !== void 0 && checkedPredParamsDigest(parameters) === void 0) return {
19006
+ itemId: binding.itemId,
19007
+ reasonCode: "expected_transition_parameters_invalid",
19008
+ reason: "predicate parameters violate the frozen key/type/size rules; use the supplied expected_transition parameters unchanged"
19009
+ };
19010
+ }
18770
19011
  function transitionIsSelfConsistent(action, transition) {
18771
19012
  if (!transition?.parameters || transition.predicateId !== ACTION_MANIFEST.actions[action].predicateId || transition.version !== 1 || transition.predParamsKind !== "inline") return false;
18772
- const recomputed = predParamsDigest(transition.parameters, resolveAllowlist("product"));
19013
+ const recomputed = checkedPredParamsDigest(transition.parameters);
19014
+ if (recomputed === void 0) return false;
18773
19015
  return transition.parametersDigest === void 0 || transition.parametersDigest === recomputed;
18774
19016
  }
18775
19017
  function evidenceFact(evidence) {
@@ -18889,7 +19131,8 @@ function expectedTransitionMatches(action, transition, resolved, observed) {
18889
19131
  const expectedPredicate = ACTION_MANIFEST.actions[action].predicateId;
18890
19132
  if (transition.predicateId !== expectedPredicate || transition.version !== 1 || transition.predParamsKind !== "inline" || !transition.parameters) return false;
18891
19133
  const params = transition.parameters;
18892
- const recomputed = predParamsDigest(params, resolveAllowlist("product"));
19134
+ const recomputed = checkedPredParamsDigest(params);
19135
+ if (recomputed === void 0) return false;
18893
19136
  if (transition.parametersDigest && transition.parametersDigest !== recomputed) return false;
18894
19137
  switch (action) {
18895
19138
  case "install":
@@ -18913,7 +19156,8 @@ function expectedTransitionMatches(action, transition, resolved, observed) {
18913
19156
  function nonStatefulTransitionMatches(action, transition, resolved, observed) {
18914
19157
  if (transition.predicateId !== ACTION_MANIFEST.actions[action].predicateId || transition.version !== 1 || transition.predParamsKind !== "inline" || !transition.parameters) return false;
18915
19158
  const params = transition.parameters;
18916
- const recomputed = predParamsDigest(params, resolveAllowlist("product"));
19159
+ const recomputed = checkedPredParamsDigest(params);
19160
+ if (recomputed === void 0) return false;
18917
19161
  if (transition.parametersDigest && transition.parametersDigest !== recomputed) return false;
18918
19162
  if (action === "inspect_remote_updates") return ["remote", "version"].every((key) => stable$1(params[key]) === stable$1(resolved[key])) && stable$1(params.upstream_oid) === stable$1(observed.upstream_oid);
18919
19163
  return stable$1(params) === stable$1({
@@ -19296,7 +19540,7 @@ function simpleRecord(projection, item, binding) {
19296
19540
  /** Preview one evidence binding through the same per-item acceptance checks as
19297
19541
  * certificate construction. This does not decide whole-contract closure. */
19298
19542
  function bindingIndividuallyAccepted(projection, item, binding) {
19299
- if (item.status === "superseded" || item.targetCaptureStatus === "clarification_required" || binding.semanticAction !== item.semanticAction || !tuplesEqual(binding.requestedTarget, item.requestedTarget) || evidenceProblem(projection, item, binding) || projection.policy === "strict" && strictProofProblem(projection, item, binding)) return false;
19543
+ if (bindingParametersProblem(binding) || item.status === "superseded" || item.targetCaptureStatus === "clarification_required" || binding.semanticAction !== item.semanticAction || !tuplesEqual(binding.requestedTarget, item.requestedTarget) || evidenceProblem(projection, item, binding) || projection.policy === "strict" && strictProofProblem(projection, item, binding)) return false;
19300
19544
  const built = isStatefulAction(item.semanticAction ?? "generic_run") ? binding.resolutionEvidenceId ? richStatefulRecord(projection, item, binding) : item.semanticAction === "commit" || item.semanticAction === "push" ? nativeGitRecord(projection, item, binding) : nativeFileRecord(projection, item, binding) : simpleRecord(projection, item, binding);
19301
19545
  return built.record !== void 0 && built.rejected === void 0;
19302
19546
  }
@@ -19307,21 +19551,17 @@ function certifyCheckpoint(projection, bindings, id, commit = true) {
19307
19551
  openItems: certifiableOpenItems(projection).map((item) => item.id),
19308
19552
  rejectedBindings: []
19309
19553
  };
19310
- if (projection.boundaryProtocol === 6 && projection.durabilityWatermark === "confirmed" && projection.coreV2?.certifiable !== true) return {
19311
- status: "incomplete",
19312
- contractRevision: projection.contractRevision,
19313
- openItems: certifiableOpenItems(projection).map((item) => item.id),
19314
- rejectedBindings: [{
19315
- itemId: "*",
19316
- reason: "the current shared-core closure is not verified complete",
19317
- reasonCode: "current_closure_unmet"
19318
- }]
19319
- };
19554
+ const coreIncomplete = projection.boundaryProtocol === 6 && projection.durabilityWatermark === "confirmed" && projection.coreV2?.certifiable !== true;
19320
19555
  const rejectedBindings = [];
19321
19556
  const records = [];
19322
19557
  const nativeDigests = [];
19323
19558
  const referencedFacts = [];
19324
19559
  for (const binding of bindings) {
19560
+ const parameterProblem = bindingParametersProblem(binding);
19561
+ if (parameterProblem) {
19562
+ rejectedBindings.push(parameterProblem);
19563
+ continue;
19564
+ }
19325
19565
  const item = projection.items.get(binding.itemId);
19326
19566
  if (!item || item.status === "superseded") {
19327
19567
  rejectedBindings.push({
@@ -19382,6 +19622,22 @@ function certifyCheckpoint(projection, bindings, id, commit = true) {
19382
19622
  });
19383
19623
  continue;
19384
19624
  }
19625
+ if (binding.semanticAction !== void 0 && binding.semanticAction !== item.semanticAction) {
19626
+ rejectedBindings.push({
19627
+ itemId: item.id,
19628
+ reason: "binding semantic action differs from the captured contract",
19629
+ reasonCode: "semantic_action_mismatch"
19630
+ });
19631
+ continue;
19632
+ }
19633
+ if (binding.requestedTarget !== void 0 && !tuplesEqual(binding.requestedTarget, item.requestedTarget)) {
19634
+ rejectedBindings.push({
19635
+ itemId: item.id,
19636
+ reason: "requested target differs from the captured contract; use the captured requested_target unchanged",
19637
+ reasonCode: "requested_target_mismatch"
19638
+ });
19639
+ continue;
19640
+ }
19385
19641
  const problem = evidenceProblem(projection, item, binding);
19386
19642
  if (problem) {
19387
19643
  rejectedBindings.push(problem);
@@ -19419,6 +19675,16 @@ function certifyCheckpoint(projection, bindings, id, commit = true) {
19419
19675
  if ("nativeDigest" in built && typeof built.nativeDigest === "string") nativeDigests.push(built.nativeDigest);
19420
19676
  referencedFacts.push(...citedEvidence(projection, binding).map(evidenceFact));
19421
19677
  }
19678
+ if (coreIncomplete) return {
19679
+ status: "incomplete",
19680
+ contractRevision: projection.contractRevision,
19681
+ openItems: certifiableOpenItems(projection).map((item) => item.id),
19682
+ rejectedBindings: [...rejectedBindings, {
19683
+ itemId: "*",
19684
+ reason: "the current shared-core closure is not verified complete",
19685
+ reasonCode: "current_closure_unmet"
19686
+ }]
19687
+ };
19422
19688
  const unreusable = needsReviewObligations(projection);
19423
19689
  if (unreusable.length > 0) return {
19424
19690
  status: "incomplete",
@@ -20397,6 +20663,17 @@ function parseArguments$1(raw) {
20397
20663
  function asRecord$1(value) {
20398
20664
  return typeof value === "object" && value !== null ? value : void 0;
20399
20665
  }
20666
+ /**
20667
+ * CG-083-BUG02: the explicit, VERIFIED no-parent state of a repository's
20668
+ * first commit, minted only by the native Git observer after reading the
20669
+ * commit object itself. It is distinct from a missing or unknown parent and
20670
+ * binds into certificates like any other parent identity.
20671
+ */
20672
+ const NATIVE_GIT_ROOT_PARENT_OID = "root";
20673
+ /** CG-083-BUG02 parent identity accepted for a commit readback. */
20674
+ function nativeGitParentOidVerified(parentOid) {
20675
+ return parentOid === NATIVE_GIT_ROOT_PARENT_OID || typeof parentOid === "string" && /^[0-9a-f]{40,64}$/.test(parentOid);
20676
+ }
20400
20677
  function extractTextContent(content) {
20401
20678
  const parts = [];
20402
20679
  for (const block$1 of content) {
@@ -20730,6 +21007,31 @@ function shellOutcome(surface, terminal, resultError, backgrounded) {
20730
21007
  * frozen value is the historical record and this batch must not rewrite it; the
20731
21008
  * derived layer records its source and conflict flag instead of changing history.
20732
21009
  */
21010
+ /**
21011
+ * CG-083-BUG03/R4: the ONE terminal verdict a native observer may rely on for
21012
+ * a persisted shell call. Reuses the evidence layer's AUTHORITATIVE terminal
21013
+ * resolution (the run's own `contextGuardProcess` declaration, then any other
21014
+ * structured meta fact, then the audited renderer markers) and cross-checks
21015
+ * it against the rendered markers: a declared failure is never upgraded, and
21016
+ * a declared verdict that CONTRADICTS the rendered markers is unresolvable
21017
+ * and stays `unknown`. A failed hook, a backgrounded or truncated result, or
21018
+ * an unclassifiable terminal state is therefore never "success". This reads
21019
+ * the CURRENT observation only; the historical frozen `outcome` of
21020
+ * already-recorded evidence is not rewritten.
21021
+ */
21022
+ function shellReadbackOutcome(surface, args, result) {
21023
+ const backgrounded = args.run_in_background === true || /^\[still running after \d+ms; moved to background job [^\]\r\n]+\]$/m.test(result.textContent) || /^started background job \S+\s*$/.test(result.textContent);
21024
+ const outputIncomplete = /\[(?:output truncated;|some output was dropped from memory;)[^\]]*\]/i.test(result.textContent);
21025
+ const declaredFacts = resolveDeclaredTerminalFacts(result.meta, result.textContent).facts;
21026
+ const renderedFacts = extractTerminalFacts(result.textContent);
21027
+ const declared = shellOutcome(surface, declaredFacts, result.error, backgrounded);
21028
+ const rendered = shellOutcome(surface, renderedFacts, result.error, backgrounded);
21029
+ let outcome;
21030
+ if (declared === rendered) outcome = declared;
21031
+ else if (declared === "failure" && rendered === "success" && !renderedFacts.marked) outcome = "failure";
21032
+ else outcome = "unknown";
21033
+ return outputIncomplete && outcome !== "failure" ? "unknown" : outcome;
21034
+ }
20733
21035
  function shellProcessFacts(meta, textContent, frozenOutcome, resultError, surface, backgrounded, parseStatus$1) {
20734
21036
  const { facts: terminal, source } = resolveDeclaredTerminalFacts(meta, textContent);
20735
21037
  const declaredOperations = declaredOperationResults(meta);
@@ -20875,7 +21177,7 @@ function extractToolSubject(call, result, defaultCwd, hostLock) {
20875
21177
  const refspec = native?.refspec;
20876
21178
  const parentOid = native?.parentOid;
20877
21179
  const treeOid = native?.treeOid;
20878
- if (action === "commit" && (typeof parentOid !== "string" || typeof treeOid !== "string" || !/^[0-9a-f]{40,64}$/.test(parentOid) || !/^[0-9a-f]{40,64}$/.test(treeOid))) return {
21180
+ if (action === "commit" && (typeof parentOid !== "string" || typeof treeOid !== "string" || !nativeGitParentOidVerified(parentOid) || !/^[0-9a-f]{40,64}$/.test(treeOid))) return {
20879
21181
  capabilities: [],
20880
21182
  subjects: [],
20881
21183
  surfaces: [],
@@ -21266,6 +21568,7 @@ function supersedeItem(items, oldId, replacement) {
21266
21568
  old.status = "superseded";
21267
21569
  old.supersededBy = replacement.id;
21268
21570
  items.set(replacement.id, replacement);
21571
+ registerFoldItem(items, replacement);
21269
21572
  return true;
21270
21573
  }
21271
21574
 
@@ -21694,6 +21997,7 @@ function supersedeClauseByPartition(projection, item, receipt) {
21694
21997
  interpretedFromUnresolved: item.id
21695
21998
  };
21696
21999
  projection.items.set(id, sub);
22000
+ registerFoldItem(projection.items, sub);
21697
22001
  projection.contractRevision = Math.max(projection.contractRevision, revision);
21698
22002
  return sub;
21699
22003
  };
@@ -21714,6 +22018,8 @@ function supersedeClauseByPartition(projection, item, receipt) {
21714
22018
  }
21715
22019
  /** The next numeric id for a prefix, shared with nextId's numbering. */
21716
22020
  function nextNumericId(items, prefix) {
22021
+ const indexed = nextNumericIdFromIndex(items, prefix);
22022
+ if (indexed !== void 0) return indexed;
21717
22023
  let max = 0;
21718
22024
  for (const item of items.values()) {
21719
22025
  if (!item.id.startsWith(prefix)) continue;
@@ -21937,6 +22243,8 @@ function restoreHistoricalCheckpoint(recorded, bindings, id) {
21937
22243
  };
21938
22244
  }
21939
22245
  function nextId(items, kind) {
22246
+ const indexed = nextIdFromIndex(items, kind);
22247
+ if (indexed !== void 0) return indexed;
21940
22248
  const prefix = kind === "requirement" ? "R" : kind === "acceptance" ? "A" : "P";
21941
22249
  let max = 0;
21942
22250
  for (const item of items.values()) {
@@ -22460,7 +22768,8 @@ function segmentsForBoundary(text, coordinationSplit, v6) {
22460
22768
  * files or embeds prohibitions.
22461
22769
  */
22462
22770
  function insertItems(projection, text, sourceMessageId, scope, authority = "root_instruction", legacy = false, legacyAuthorityProven = false, coordinationSplit = true, unitId, provenance, clarificationText) {
22463
- const before = new Set(projection.items.keys());
22771
+ const freshItems = [];
22772
+ const isFresh = /* @__PURE__ */ new Set();
22464
22773
  let coveredSpans = 0;
22465
22774
  const usedOccurrences = /* @__PURE__ */ new Set();
22466
22775
  for (const segment of segmentsForBoundary(text, coordinationSplit, projection.boundaryProtocol === 6 && !legacy)) {
@@ -22482,6 +22791,26 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22482
22791
  }
22483
22792
  }
22484
22793
  if (span) coveredSpans += 1;
22794
+ const frontedTest = segment.interpretation.fingerprint.startsWith("v6-locative:") && /^\s*(?:in|within)\s+.+?[,,]\s*(?:run|execute)\s+(?:npm|pnpm|yarn|bun)\s+test(?:\s|[.!?]|$)/iu.test(segment.body);
22795
+ if (segment.interpretation.fingerprint.startsWith("v6-test:") || frontedTest) {
22796
+ const locationText = (frontedTest ? /^\s*(?:in|within)\s+(.+?)[,,]\s*(?:run|execute)\b/iu.exec(segment.body) : /(?:\b(?:in|within)\s+|(?:^|[,,\s])在\s*)(.+?)\s*$/iu.exec(segment.body))?.[1]?.replace(/[.!?。!?]$/, "").trim().replace(/\s+before\s+finishing$/iu, "").trim();
22797
+ if (locationText && !/^(?:(?:the|this)\s+)?(?:current\s+)?workspace$/iu.test(locationText)) {
22798
+ const raw = locationText;
22799
+ const target = /^(["'`])([^"'`]+)\1$/u.exec(raw)?.[2] ?? (/^[^\s"'`]+$/u.test(raw) ? raw : void 0);
22800
+ const resolved = target && rootLocatorFlavor(target) && !/(?:^|[\\/])package\.json$/iu.test(target);
22801
+ const item = insert(projection, segment, sourceMessageId, resolved ? target : "scope", "scope", unitId, provenance ? {
22802
+ rawTextSha256: provenance.rawTextSha256,
22803
+ span
22804
+ } : void 0, freshItems);
22805
+ if (resolved) item.targetSource = { kind: "explicit_path" };
22806
+ else {
22807
+ delete item.requestedTarget?.scope;
22808
+ item.targetCaptureStatus = "clarification_required";
22809
+ delete item.targetSource;
22810
+ }
22811
+ continue;
22812
+ }
22813
+ }
22485
22814
  if (segment.interpretation.fingerprint.startsWith("v6-package-script:")) {
22486
22815
  if (/\b(?:in|within)\s+["'`]/iu.test(segment.body)) {
22487
22816
  const target = /\b(?:in|within)\s+(["'`])([^"'`]+)\1(?:\s*[.!?])?\s*$/iu.exec(segment.body)?.[2];
@@ -22489,13 +22818,13 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22489
22818
  const item = insert(projection, segment, sourceMessageId, target, "scope", unitId, provenance ? {
22490
22819
  rawTextSha256: provenance.rawTextSha256,
22491
22820
  span
22492
- } : void 0);
22821
+ } : void 0, freshItems);
22493
22822
  item.targetSource = { kind: "explicit_path" };
22494
22823
  } else {
22495
22824
  const item = insert(projection, segment, sourceMessageId, "scope", "scope", unitId, provenance ? {
22496
22825
  rawTextSha256: provenance.rawTextSha256,
22497
22826
  span
22498
- } : void 0);
22827
+ } : void 0, freshItems);
22499
22828
  delete item.requestedTarget?.scope;
22500
22829
  item.targetCaptureStatus = "clarification_required";
22501
22830
  delete item.targetSource;
@@ -22508,7 +22837,7 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22508
22837
  insert(projection, segment, sourceMessageId, resolved.replace(/[\\/]package\.json$/iu, "") || resolved, "scope", unitId, provenance ? {
22509
22838
  rawTextSha256: provenance.rawTextSha256,
22510
22839
  span
22511
- } : void 0);
22840
+ } : void 0, freshItems);
22512
22841
  continue;
22513
22842
  }
22514
22843
  }
@@ -22516,16 +22845,17 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22516
22845
  insert(projection, segment, sourceMessageId, scope.cwd || "scope", "scope", unitId, provenance ? {
22517
22846
  rawTextSha256: provenance.rawTextSha256,
22518
22847
  span
22519
- } : void 0);
22848
+ } : void 0, freshItems);
22520
22849
  continue;
22521
22850
  }
22522
22851
  for (const path$1 of segment.paths) insert(projection, segment, sourceMessageId, resolveArtifact(path$1, scope), "artifact", unitId, provenance ? {
22523
22852
  rawTextSha256: provenance.rawTextSha256,
22524
22853
  span
22525
- } : void 0);
22854
+ } : void 0, freshItems);
22526
22855
  }
22856
+ for (const added of freshItems) isFresh.add(added.id);
22527
22857
  if (projection.boundaryProtocol === 6 && !legacy && provenance) {
22528
- const fresh = [...projection.items.values()].filter((item) => !before.has(item.id) && item.sourceMessageId === sourceMessageId && item.rawTextSha256 === provenance.rawTextSha256 && item.spans?.[0]?.partIndex === 0).sort((a, b) => a.spans[0].start - b.spans[0].start);
22858
+ const fresh = freshItems.filter((item) => item.sourceMessageId === sourceMessageId && item.rawTextSha256 === provenance.rawTextSha256 && item.spans?.[0]?.partIndex === 0).sort((a, b) => a.spans[0].start - b.spans[0].start);
22529
22859
  for (const method of fresh) {
22530
22860
  const text$1 = maskQuotedSpans(method.normalizedText).trim();
22531
22861
  if (!/^(?:(?:for\s+[^,,]{1,100}[,,]\s*)?(?:use|consult|invoke|call)\b|(?:为|针对|对)[^,,。]{1,80}(?:调用|使用))/iu.test(text$1) || method.kind !== "requirement" || [
@@ -22551,9 +22881,9 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22551
22881
  };
22552
22882
  }
22553
22883
  let parent;
22884
+ const raw = Buffer.from(provenance.rawText, "utf8");
22554
22885
  for (const item of fresh) {
22555
22886
  const own = item.spans[0];
22556
- const raw = Buffer.from(provenance.rawText, "utf8");
22557
22887
  const clause = raw.subarray(own.start, own.end).toString("utf8");
22558
22888
  if (item.semanticAction === "modify" && item.authorityDisposition === "executable_now" && item.requestedTarget?.artifact_id) {
22559
22889
  parent = item;
@@ -22584,8 +22914,8 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22584
22914
  };
22585
22915
  }
22586
22916
  }
22587
- for (const [id, item] of projection.items) {
22588
- if (before.has(id)) continue;
22917
+ for (const item of freshItems) {
22918
+ const id = item.id;
22589
22919
  if (item.kind !== "requirement" || item.waitAuthorization || item.authorityDisposition === "conditional_wait") continue;
22590
22920
  if (item.authorityDisposition !== void 0 && item.authorityDisposition !== "executable_now") continue;
22591
22921
  for (const [otherId, other] of projection.items) {
@@ -22599,13 +22929,13 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22599
22929
  break;
22600
22930
  }
22601
22931
  }
22602
- if (clarificationText) for (const [id, item] of projection.items) {
22603
- if (before.has(id)) continue;
22932
+ if (clarificationText) for (const item of freshItems) {
22933
+ const id = item.id;
22604
22934
  if (item.kind === "prohibition" || item.status !== "pending") continue;
22605
22935
  if (item.authorityDisposition !== "executable_now") continue;
22606
22936
  if (!item.semanticAction || item.semanticAction === "generic_run") continue;
22607
22937
  for (const [otherId, other] of projection.items) {
22608
- if (otherId === id || !before.has(otherId)) continue;
22938
+ if (otherId === id || isFresh.has(otherId)) continue;
22609
22939
  if (other.status !== "pending" || other.kind === "prohibition") continue;
22610
22940
  if (other.waitAuthorization || other.legacyFlags?.length) continue;
22611
22941
  if (!(other.semanticAction === "generic_run" && (other.authorityDisposition === "executable_now" || other.authorityDisposition === "unresolved"))) continue;
@@ -22618,27 +22948,24 @@ function insertItems(projection, text, sourceMessageId, scope, authority = "root
22618
22948
  }
22619
22949
  }
22620
22950
  for (let round = 0; round < 8; round += 1) {
22621
- const unresolved = [...projection.items].filter(([id, item]) => !before.has(id) && item.targetSource?.kind === "environment_default");
22951
+ const unresolved = freshItems.filter((item) => item.targetSource?.kind === "environment_default");
22622
22952
  if (unresolved.length === 0) break;
22623
22953
  let resolvedAny = false;
22624
- for (const [, item] of unresolved) {
22954
+ for (const item of unresolved) {
22625
22955
  resolveInheritedGitTarget(projection, item);
22626
22956
  if (item.targetSource?.kind === "unit_inherited") resolvedAny = true;
22627
22957
  }
22628
22958
  if (!resolvedAny) break;
22629
22959
  }
22630
- for (const [id, item] of projection.items) {
22631
- if (before.has(id)) continue;
22632
- if (legacy) if (legacyAuthorityProven && item.semanticAction !== void 0 && item.semanticAction !== "generic_run" && item.targetCaptureStatus === "resolved") {
22633
- item.authority = authority;
22634
- item.legacyFlags = void 0;
22635
- } else {
22636
- item.authority = "legacy_authority_unclassified";
22637
- item.semanticAction = "generic_run";
22638
- item.legacyFlags = ["legacy_generic_run", "legacy_authority_unclassified"];
22639
- }
22640
- else item.authority = authority;
22960
+ for (const item of freshItems) if (legacy) if (legacyAuthorityProven && item.semanticAction !== void 0 && item.semanticAction !== "generic_run" && item.targetCaptureStatus === "resolved") {
22961
+ item.authority = authority;
22962
+ item.legacyFlags = void 0;
22963
+ } else {
22964
+ item.authority = "legacy_authority_unclassified";
22965
+ item.semanticAction = "generic_run";
22966
+ item.legacyFlags = ["legacy_generic_run", "legacy_authority_unclassified"];
22641
22967
  }
22968
+ else item.authority = authority;
22642
22969
  return coveredSpans;
22643
22970
  }
22644
22971
  /** The 0.6.3 eligibility check identity for a legacy record's own reading. */
@@ -22672,6 +22999,18 @@ function informationReadingNamesWork(text) {
22672
22999
  if (scopes.length === 0) return false;
22673
23000
  return scopes.some((scope) => scope.authorityDisposition !== "informational");
22674
23001
  }
23002
+ /** CG-083-PERF02: the interpretation rule is a pure function of the record's
23003
+ * own bytes; a long history re-asks it per delivery, so memoize by text. */
23004
+ const informationReadingMemo = /* @__PURE__ */ new Map();
23005
+ function informationReadingNamesWorkMemoized(text) {
23006
+ const digest$1 = sha256(text);
23007
+ const cached = informationReadingMemo.get(digest$1);
23008
+ if (cached !== void 0) return cached;
23009
+ const value = informationReadingNamesWork(text);
23010
+ if (informationReadingMemo.size > 512) informationReadingMemo.clear();
23011
+ informationReadingMemo.set(digest$1, value);
23012
+ return value;
23013
+ }
22675
23014
  /**
22676
23015
  * The pure upgrade-eligibility predicate: the records in the current closure
22677
23016
  * scope that may NOT be inherited as a current pass, with the reason that
@@ -22720,7 +23059,7 @@ function eligibilityReviewReasons(projection) {
22720
23059
  findings.push([item.id, "unknown_state_version"]);
22721
23060
  continue;
22722
23061
  }
22723
- if (informationReading && informationReadingNamesWork(item.normalizedText)) {
23062
+ if (informationReading && informationReadingNamesWorkMemoized(item.normalizedText)) {
22724
23063
  findings.push([item.id, "legacy_mixed_information_scope"]);
22725
23064
  continue;
22726
23065
  }
@@ -22858,7 +23197,7 @@ function resolveInheritedGitTarget(projection, item) {
22858
23197
  item.targetCaptureStatus = "clarification_required";
22859
23198
  item.targetCaptureReasonCode = repositories.size > 1 ? "requested_target_repository_ambiguous" : "requested_target_repository_missing";
22860
23199
  }
22861
- function insert(projection, segment, sourceMessageId, subject, surface, unitId, provenance) {
23200
+ function insert(projection, segment, sourceMessageId, subject, surface, unitId, provenance, freshOut) {
22862
23201
  const revision = projection.contractRevision + 1;
22863
23202
  const id = nextId(projection.items, segment.kind);
22864
23203
  const method = extractMethod(segment.body);
@@ -22940,9 +23279,13 @@ function insert(projection, segment, sourceMessageId, subject, surface, unitId,
22940
23279
  item.rawTextSha256 = provenance.rawTextSha256;
22941
23280
  if (provenance.span) item.spans = [provenance.span];
22942
23281
  }
22943
- const duplicate = [...projection.items.values()].find((existing) => existing.kind === segment.kind && existing.status === "pending" && existing.textSha256 === item.textSha256 && existing.verification.subject === subject);
23282
+ const duplicate = indexesEnabled() ? findPendingDuplicateFromIndex(projection.items, segment.kind, item.textSha256, subject) : [...projection.items.values()].find((existing) => existing.kind === segment.kind && existing.status === "pending" && existing.textSha256 === item.textSha256 && existing.verification.subject === subject);
22944
23283
  if (duplicate) supersedeItem(projection.items, duplicate.id, item);
22945
- else projection.items.set(id, item);
23284
+ else {
23285
+ projection.items.set(id, item);
23286
+ registerFoldItem(projection.items, item);
23287
+ }
23288
+ freshOut?.push(item);
22946
23289
  projection.contractRevision = item.revision;
22947
23290
  return item;
22948
23291
  }
@@ -22957,7 +23300,17 @@ function rootLocatorFlavor(cwd) {
22957
23300
  const posixBase = cwd.startsWith("/") && !cwd.startsWith("//") && !cwd.includes("\\") && !cwd.includes("//") && !cwd.split("/").some((part) => part === "." || part === "..");
22958
23301
  return /^[A-Za-z]:\\/.test(cwd) && !cwd.includes("/") && !cwd.slice(3).includes("\\\\") && !cwd.slice(3).includes(":") && !cwd.split("\\").some((part) => part === "." || part === "..") ? "windows" : posixBase ? "posix" : void 0;
22959
23302
  }
22960
- function refreshRootLocatorContext(projection, sourceEvents, scope, asOf) {
23303
+ /**
23304
+ * CG-083-R5: the seq index is scoped to ONE derive call and built from the
23305
+ * exact array that call consumes. It is never cached across calls: the
23306
+ * exported derive API accepts any event array and its immutability is not a
23307
+ * verified premise, so an array that was appended to between two derives must
23308
+ * resolve its newly added sequences.
23309
+ */
23310
+ function buildEventsBySeq(sourceEvents) {
23311
+ return new Map(sourceEvents.map((event) => [event.seq, event]));
23312
+ }
23313
+ function refreshRootLocatorContext(projection, bySeq, scope, asOf) {
22961
23314
  projection.rootLocatorContexts.clear();
22962
23315
  projection.rootLocatorIdentity = void 0;
22963
23316
  if (projection.boundaryProtocol !== 6 || !scope.sessionHeader || typeof scope.cwd !== "string") return;
@@ -22966,8 +23319,8 @@ function refreshRootLocatorContext(projection, sourceEvents, scope, asOf) {
22966
23319
  const refs = projection.currentUnitId ? projection.units.get(projection.currentUnitId)?.rootInputRefs ?? [] : [];
22967
23320
  for (const ref$1 of refs) {
22968
23321
  if (ref$1.seq > asOf) continue;
22969
- const source = sourceEvents.find((event) => event.seq === ref$1.seq && event.type === "user/message" && asRecord(asRecord(event.data)?.source)?.kind === "user");
22970
- if (!source) continue;
23322
+ const source = bySeq.get(ref$1.seq);
23323
+ if (!source || source.type !== "user/message" || asRecord(asRecord(source.data)?.source)?.kind !== "user") continue;
22971
23324
  const content = asRecord(source.data)?.content;
22972
23325
  const raw = Array.isArray(content) ? content.filter((part) => asRecord(part)?.type === "text").map((part) => String(asRecord(part)?.text ?? "")).join("") : "";
22973
23326
  projection.rootLocatorContexts.set(ref$1.seq, {
@@ -23038,6 +23391,7 @@ function deriveProjection(sourceEvents, config, scope, durableConfirmed, hostLoc
23038
23391
  const turnUnitIds = /* @__PURE__ */ new Map();
23039
23392
  let activeTurn;
23040
23393
  const unitSemanticsActive = () => v5BoundarySeq !== void 0 && !scope.sessionHeader?.parentSession && !scope.sessionHeader?.delegationDepth && scope.sessionHeader?.origin !== "subagent";
23394
+ const eventsBySeq = buildEventsBySeq(sourceEvents);
23041
23395
  for (const event of sourceEvents) {
23042
23396
  projection.enabled = enabled;
23043
23397
  projection.lastObservedSourceSeq = Math.max(projection.lastObservedSourceSeq, event.seq);
@@ -23474,7 +23828,7 @@ function deriveProjection(sourceEvents, config, scope, durableConfirmed, hostLoc
23474
23828
  break;
23475
23829
  }
23476
23830
  const id = `C${projection.checkpoints.length + 1}`;
23477
- refreshRootLocatorContext(projection, sourceEvents, scope, event.seq);
23831
+ refreshRootLocatorContext(projection, eventsBySeq, scope, event.seq);
23478
23832
  const result = certifyCheckpoint(projection, call.bindings ?? [], id, false);
23479
23833
  if (result.status !== "certified" || !result.checkpoint || !recordedCertificateMatches(recorded.certificate, result.checkpoint)) {
23480
23834
  projection.integrity = "corrupt";
@@ -23586,7 +23940,7 @@ function deriveProjection(sourceEvents, config, scope, durableConfirmed, hostLoc
23586
23940
  if (item.status !== "pending" || !item.observerMethod?.tools.length) continue;
23587
23941
  if (item.observerMethod.tools.every((_, index$1) => observerMethodEvidence(projection, sourceEvents, item, index$1))) item.status = "passed";
23588
23942
  }
23589
- refreshRootLocatorContext(projection, sourceEvents, scope, sourceEvents.at(-1)?.seq ?? 0);
23943
+ refreshRootLocatorContext(projection, eventsBySeq, scope, sourceEvents.at(-1)?.seq ?? 0);
23590
23944
  applyUpgradeEligibility(projection);
23591
23945
  if (interpretationFacts.length > 64) interpretationFacts.splice(0, interpretationFacts.length - 64);
23592
23946
  projection.interpretationFacts = interpretationFacts;
@@ -24964,6 +25318,17 @@ function foldRootControls(snapshot, sources, requirements, facts, units, waterma
24964
25318
  resumed
24965
25319
  };
24966
25320
  }
25321
+ /** Stable buckets are local to one validated snapshot; rows stay in source order. */
25322
+ function bySource(rows) {
25323
+ const result = /* @__PURE__ */ new Map();
25324
+ for (const row$3 of rows) {
25325
+ const key = row$3.source.source_id;
25326
+ const bucket = result.get(key);
25327
+ if (bucket) bucket.push(row$3);
25328
+ else result.set(key, [row$3]);
25329
+ }
25330
+ return result;
25331
+ }
24967
25332
  /** Pure, host-neutral core/v2 projection. The adapter owns event trust and durability. */
24968
25333
  function projectCoreV2(snapshot) {
24969
25334
  validateCoreSnapshot(snapshot, observation_schema_default);
@@ -25012,10 +25377,11 @@ function projectCoreV2(snapshot) {
25012
25377
  ...[...requirements.values()].filter((req) => units.has(req.unit)).map((req) => req.source.source_id),
25013
25378
  ...listed(snapshot.root_controls ?? []).filter((control) => control.seq <= watermark && units.has(sources.get(control.source.source_id)?.unit)).map((control) => control.source.source_id)
25014
25379
  ]);
25380
+ const coverageBySource = bySource(listed(snapshot.coverage));
25015
25381
  const coverageErrors = [], unknownCoverage = [];
25016
25382
  for (const [key, source] of sources) {
25017
25383
  if (source.kind !== "root" || !activeRootIds.has(key)) continue;
25018
- const spans = listed(snapshot.coverage).filter((c) => c.source.source_id === key).sort((a, b) => a.source.start - b.source.start);
25384
+ const spans = (coverageBySource.get(key) ?? []).slice().sort((a, b) => a.source.start - b.source.start);
25019
25385
  let cursor = 0;
25020
25386
  for (const coverage of spans) {
25021
25387
  const span = coverage.source;
@@ -25079,10 +25445,12 @@ function projectCoreV2(snapshot) {
25079
25445
  }
25080
25446
  const historicalExplained = new Map([...requirements].filter(([, req]) => units.has(req.unit) && req.status === "superseded" && req.superseded_at_seq !== void 0 && req.superseded_at_seq <= watermark && sourceMatches(req.source, sources, true)));
25081
25447
  const structuralGap = (raw, start, end) => Buffer.from(raw.subarray(start, end)).toString("utf8").replace(/^[ \t\r\n,,。.!??;;::、]+|[ \t\r\n,,。.!??;;::、]+$/gu, "").length > 0;
25448
+ const explainedBySource = bySource([...current.values(), ...historicalExplained.values()]);
25449
+ const controlsBySource = bySource(listed(snapshot.root_controls ?? []).filter((control) => control.seq <= watermark && sourceMatches(control.source, sources, true)));
25082
25450
  for (const coverage of listed(snapshot.coverage)) {
25083
25451
  const span = coverage.source, source = sources.get(span.source_id);
25084
25452
  if (!source || !units.has(source.unit) || coverage.kind !== "interpreted") continue;
25085
- const covered = [...[...current.values(), ...historicalExplained.values()].filter((r) => r.source.source_id === span.source_id && r.source.start < span.end && r.source.end > span.start).map((r) => [r.source.start, r.source.end]), ...listed(snapshot.root_controls ?? []).filter((control) => control.seq <= watermark && control.source.source_id === span.source_id && sourceMatches(control.source, sources, true)).map((control) => [control.source.start, control.source.end])].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
25453
+ const covered = [...(explainedBySource.get(span.source_id) ?? []).filter((r) => r.source.start < span.end && r.source.end > span.start).map((r) => [r.source.start, r.source.end]), ...(controlsBySource.get(span.source_id) ?? []).map((control) => [control.source.start, control.source.end])].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
25086
25454
  let cursor = span.start;
25087
25455
  const raw = bytes(source.text);
25088
25456
  for (const [start, end] of covered) {
@@ -25654,17 +26022,75 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25654
26022
  const rootBySeq = new Map(usedRoots.map((root) => [root.seq, root]));
25655
26023
  const revisionByRootSeq = new Map(usedRoots.map((root, index$1) => [root.seq, index$1 + 1]));
25656
26024
  const revisionFor = (seq) => revisionByRootSeq.get(seq);
26025
+ const ix = process.env.DSH_GUARD_DISABLE_INDEXES !== "1";
26026
+ const evidenceList = ix ? [...projection.evidence.values()] : [];
26027
+ const evidenceOrdinal = /* @__PURE__ */ new Map();
26028
+ const evidenceByCallIx = /* @__PURE__ */ new Map();
26029
+ const evidenceBySubjectIx = /* @__PURE__ */ new Map();
26030
+ const readinessByItemIx = /* @__PURE__ */ new Map();
26031
+ if (ix) evidenceList.forEach((fact, ordinal) => {
26032
+ evidenceOrdinal.set(fact, ordinal);
26033
+ const push = (map, key) => {
26034
+ if (key === void 0) return;
26035
+ const bucket = map.get(key);
26036
+ if (bucket) bucket.push(fact);
26037
+ else map.set(key, [fact]);
26038
+ };
26039
+ push(evidenceByCallIx, fact.callId);
26040
+ for (const subject of fact.subjects) push(evidenceBySubjectIx, subject);
26041
+ push(readinessByItemIx, fact.readinessForItemId);
26042
+ });
26043
+ const candidatesForSubjects = (targets) => {
26044
+ if (!ix) return evidenceList.length ? evidenceList : [...projection.evidence.values()];
26045
+ const selected = /* @__PURE__ */ new Set();
26046
+ for (const target of targets) {
26047
+ if (target === void 0) continue;
26048
+ for (const fact of evidenceBySubjectIx.get(target) ?? []) selected.add(fact);
26049
+ }
26050
+ const ordered = [...selected];
26051
+ ordered.sort((left, right) => evidenceOrdinal.get(left) - evidenceOrdinal.get(right));
26052
+ return ordered;
26053
+ };
26054
+ const evidenceByCall = (callId) => ix ? evidenceByCallIx.get(callId) ?? [] : [...projection.evidence.values()].filter((fact) => fact.callId === callId);
26055
+ const evidenceReadyFor = (itemId) => ix ? readinessByItemIx.get(itemId) ?? [] : [...projection.evidence.values()].filter((fact) => fact.readinessForItemId === itemId);
26056
+ const successModifyEffects = ix ? evidenceList.filter((fact) => fact.semanticAction === "modify" && fact.evidenceRole === "effect" && fact.outcome === "success") : void 0;
26057
+ const successFileStateEvidence = ix ? evidenceList.filter((fact) => fact.evidenceRole === "state" && fact.toolName === "context_guard_observe_file" && fact.outcome === "success") : void 0;
26058
+ const testEffectEvidence = ix ? evidenceList.filter((entry) => entry.semanticAction === "test" && entry.evidenceRole === "effect" && entry.parseStatus === "supported" && entry.processFacts?.operationAttribution === "single_operation") : void 0;
26059
+ const rootCache = /* @__PURE__ */ new Map();
26060
+ const rootInfo = (root) => {
26061
+ let info = rootCache.get(root.seq);
26062
+ if (!info) {
26063
+ const text = rootText(root);
26064
+ info = {
26065
+ text,
26066
+ digest: hash(text),
26067
+ bytes: Buffer.from(text, "utf8"),
26068
+ byteLength: Buffer.byteLength(text, "utf8")
26069
+ };
26070
+ rootCache.set(root.seq, info);
26071
+ }
26072
+ return info;
26073
+ };
26074
+ const itemsByRootSeq = /* @__PURE__ */ new Map();
26075
+ for (const item of currentItems) {
26076
+ const seq = sourceSeq(item);
26077
+ if (seq === void 0) continue;
26078
+ const bucket = itemsByRootSeq.get(seq);
26079
+ if (bucket) bucket.push(item);
26080
+ else itemsByRootSeq.set(seq, [item]);
26081
+ }
26082
+ const peersOf = (item) => itemsByRootSeq.get(sourceSeq(item) ?? -1) ?? [];
25657
26083
  const supersessionOf = (item) => {
25658
26084
  if (item.status !== "superseded" || !item.supersededBy) return void 0;
25659
26085
  const successor = projection.items.get(item.supersededBy);
25660
26086
  const seq = successor ? sourceSeq(successor) : void 0;
25661
26087
  const successorRoot = seq === void 0 ? void 0 : rootBySeq.get(seq);
25662
26088
  const successorSpan = successor?.spans?.[0];
25663
- const successorClause = successorRoot && successorSpan?.partIndex === 0 ? Buffer.from(rootText(successorRoot), "utf8").subarray(successorSpan.start, successorSpan.end).toString("utf8") : void 0;
26089
+ const successorClause = successorRoot && successorSpan?.partIndex === 0 ? rootInfo(successorRoot).bytes.subarray(successorSpan.start, successorSpan.end).toString("utf8") : void 0;
25664
26090
  const predecessorSeq = sourceSeq(item);
25665
26091
  const predecessorRoot = predecessorSeq === void 0 ? void 0 : rootBySeq.get(predecessorSeq);
25666
26092
  const predecessorSpan = item.spans?.[0];
25667
- const predecessorClause = predecessorRoot && predecessorSpan?.partIndex === 0 ? Buffer.from(rootText(predecessorRoot), "utf8").subarray(predecessorSpan.start, predecessorSpan.end).toString("utf8") : void 0;
26093
+ const predecessorClause = predecessorRoot && predecessorSpan?.partIndex === 0 ? rootInfo(predecessorRoot).bytes.subarray(predecessorSpan.start, predecessorSpan.end).toString("utf8") : void 0;
25668
26094
  const sourcedReplacement = Boolean(successorClause && predecessorClause && successorClause === predecessorClause && successor?.textSha256 === item.textSha256);
25669
26095
  return successor?.unitId === unit && successor.kind === item.kind && successor.semanticAction === item.semanticAction && targetOf(successor) === targetOf(item) && successor.authorityDisposition === "executable_now" && sourcedReplacement && seq !== void 0 && seq > (sourceSeq(item) ?? -1) && rootBySeq.has(seq) && revisionFor(seq) > revisionFor(sourceSeq(item)) ? {
25670
26096
  seq,
@@ -25674,19 +26100,19 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25674
26100
  };
25675
26101
  if (!currentItems.every((item) => {
25676
26102
  const root = rootBySeq.get(sourceSeq(item) ?? -1);
25677
- return root && item.rawTextSha256 === hash(rootText(root));
26103
+ return root && item.rawTextSha256 === rootInfo(root).digest;
25678
26104
  })) return void 0;
25679
26105
  const sources = usedRoots.map((root) => {
25680
- const text = rootText(root);
26106
+ const info = rootInfo(root);
25681
26107
  return {
25682
26108
  id: `root:${root.seq}`,
25683
26109
  seq: root.seq,
25684
26110
  kind: "root",
25685
26111
  unit,
25686
26112
  revision: revisionFor(root.seq),
25687
- sha256: hash(text),
25688
- byte_length: Buffer.byteLength(text, "utf8"),
25689
- text,
26113
+ sha256: info.digest,
26114
+ byte_length: info.byteLength,
26115
+ text: info.text,
25690
26116
  call_id: null,
25691
26117
  turn: String(row(root.data).turn ?? turn),
25692
26118
  ...projection.rootLocatorContexts.get(root.seq) ? {
@@ -25695,21 +26121,33 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25695
26121
  } : {}
25696
26122
  };
25697
26123
  });
26124
+ const sourceIds = new Set(sources.map((source) => String(source.id)));
26125
+ const sourceById = new Map(sources.map((source) => [String(source.id), source]));
26126
+ const addSource = (row$3) => {
26127
+ const id = String(row$3.id);
26128
+ if (!sourceIds.has(id)) {
26129
+ sourceIds.add(id);
26130
+ sourceById.set(id, row$3);
26131
+ sources.push(row$3);
26132
+ }
26133
+ };
25698
26134
  const requirements = [];
25699
26135
  const facts = [];
25700
26136
  const actions = [];
25701
26137
  const conditions = [];
25702
26138
  const coverage = [];
25703
26139
  for (const root of usedRoots) {
25704
- const text = rootText(root), digest$1 = hash(text), byteLength = Buffer.byteLength(text, "utf8");
26140
+ const info = rootInfo(root);
26141
+ const text = info.text, digest$1 = info.digest, byteLength = info.byteLength;
25705
26142
  const span = (start, end) => ({
25706
26143
  source_id: `root:${root.seq}`,
25707
26144
  start,
25708
26145
  end,
25709
26146
  sha256: digest$1
25710
26147
  });
25711
- const sortedSpans = currentItems.filter((item) => sourceSeq(item) === root.seq).flatMap((item) => {
25712
- const own = sourceSpan(item, text, currentItems.filter((peer) => sourceSeq(peer) === root.seq));
26148
+ const rootItems = itemsByRootSeq.get(root.seq) ?? [];
26149
+ const sortedSpans = rootItems.flatMap((item) => {
26150
+ const own = sourceSpan(item, text, rootItems);
25713
26151
  return own ? [own] : [];
25714
26152
  }).sort((a, b) => a.start - b.start || a.end - b.end);
25715
26153
  let cursor = 0;
@@ -25790,28 +26228,35 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25790
26228
  result
25791
26229
  });
25792
26230
  }
26231
+ const basesByItem = /* @__PURE__ */ new Map();
26232
+ for (const base of currentActionBases(projection, false)) {
26233
+ const bucket = basesByItem.get(base.itemId);
26234
+ if (bucket) bucket.push(base);
26235
+ else basesByItem.set(base.itemId, [base]);
26236
+ }
25793
26237
  const attached = /* @__PURE__ */ new Set();
25794
26238
  for (const item of currentItems) {
25795
26239
  const root = rootBySeq.get(sourceSeq(item) ?? -1);
25796
26240
  if (!root) continue;
25797
26241
  const itemRevision = revisionFor(root.seq);
25798
- const text = rootText(root), digest$1 = hash(text);
26242
+ const info = rootInfo(root);
26243
+ const text = info.text, digest$1 = info.digest;
25799
26244
  const span = (start, end) => ({
25800
26245
  source_id: `root:${root.seq}`,
25801
26246
  start,
25802
26247
  end,
25803
26248
  sha256: digest$1
25804
26249
  });
25805
- const itemSpan = sourceSpan(item, text, currentItems.filter((peer) => sourceSeq(peer) === root.seq));
26250
+ const itemSpan = sourceSpan(item, text, peersOf(item));
25806
26251
  if (!itemSpan) continue;
25807
- if (item.observerMethod && item.rawTextSha256 === hash(text) && item.authority === "root_instruction") {
26252
+ if (item.observerMethod && item.rawTextSha256 === digest$1 && item.authority === "root_instruction") {
25808
26253
  const methodSource = {
25809
26254
  source_id: `root:${root.seq}`,
25810
26255
  start: itemSpan.start,
25811
26256
  end: itemSpan.end,
25812
- sha256: hash(text)
26257
+ sha256: digest$1
25813
26258
  };
25814
- const methodConstraint = Buffer.from(text, "utf8").subarray(itemSpan.start, itemSpan.end).toString("utf8");
26259
+ const methodConstraint = info.bytes.subarray(itemSpan.start, itemSpan.end).toString("utf8");
25815
26260
  for (const [index$1, tool] of item.observerMethod.tools.entries()) {
25816
26261
  const related = projection.items.get(item.observerMethod.targetItemIds[index$1]);
25817
26262
  if (!related || related.rawTextSha256 !== item.rawTextSha256 || related.unitId !== item.unitId || sourceSeq(related) !== root.seq) continue;
@@ -25823,7 +26268,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25823
26268
  const subjectKind$1 = tool === "context_guard_observe_file" ? "filesystem" : "opaque";
25824
26269
  const relatedSpan = related.spans?.[0];
25825
26270
  const targetBytes = Buffer.from(target$1, "utf8");
25826
- const targetAt = relatedSpan ? Buffer.from(text, "utf8").subarray(relatedSpan.start, relatedSpan.end).indexOf(targetBytes) : -1;
26271
+ const targetAt = relatedSpan ? info.bytes.subarray(relatedSpan.start, relatedSpan.end).indexOf(targetBytes) : -1;
25827
26272
  const literalTarget = targetAt >= 0 && relatedSpan !== void 0;
25828
26273
  const targetSource = literalTarget ? {
25829
26274
  source_id: `root:${root.seq}`,
@@ -25868,11 +26313,11 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25868
26313
  });
25869
26314
  if (!fact || !pair) continue;
25870
26315
  const callId = `call:${fact.callId}`, resultId = `result:${fact.callId}`;
25871
- if (!sources.some((source) => source.id === callId)) {
26316
+ if (!sourceIds.has(callId)) {
25872
26317
  const callBytes = String(row(pair.call.data).arguments ?? "");
25873
26318
  const resultBytes = Array.isArray(row(row(pair.result.data).message).content) ? row(row(pair.result.data).message).content.filter((part) => row(part).type === "text").map((part) => String(row(part).text ?? "")).join("\n") : "";
25874
26319
  const callTurn = String(row(pair.call.data).turn ?? turn);
25875
- sources.push({
26320
+ addSource({
25876
26321
  id: callId,
25877
26322
  seq: pair.call.seq,
25878
26323
  kind: "host_call",
@@ -25887,7 +26332,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25887
26332
  target_kind: subjectKind$1,
25888
26333
  origin_root_source_id: `root:${root.seq}`
25889
26334
  });
25890
- sources.push({
26335
+ addSource({
25891
26336
  id: resultId,
25892
26337
  seq: pair.result.seq,
25893
26338
  kind: "host_result",
@@ -25930,7 +26375,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25930
26375
  }))) continue;
25931
26376
  const kind = kindOf(item);
25932
26377
  const named = targetOf(item);
25933
- const raw = Buffer.from(text, "utf8");
26378
+ const raw = info.bytes;
25934
26379
  const namedBytes = named ? Buffer.from(named, "utf8") : void 0;
25935
26380
  const atWithin = namedBytes ? raw.subarray(itemSpan.start, itemSpan.end).indexOf(namedBytes) : -1;
25936
26381
  const at = atWithin >= 0 ? itemSpan.start + atWithin : -1;
@@ -25941,7 +26386,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25941
26386
  const readbackReferent = readbackAntecedents.length === 1 ? readbackAntecedents[0].requestedTarget.artifact_id : void 0;
25942
26387
  const referents = kind === "constraint" ? currentItems.flatMap((candidate) => {
25943
26388
  if (candidate.taskKind !== "context" || sourceSeq(candidate) !== root.seq) return [];
25944
- const own = sourceSpan(candidate, text, currentItems.filter((peer) => sourceSeq(peer) === root.seq));
26389
+ const own = sourceSpan(candidate, text, peersOf(candidate));
25945
26390
  const path$1 = candidate.requestedTarget?.artifact_id;
25946
26391
  const base = projection.rootLocatorContexts.get(root.seq)?.base;
25947
26392
  if (!own || own.end > itemSpan.start || typeof path$1 !== "string" || !base || !portableContains(base, path$1)) return [];
@@ -25966,9 +26411,9 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25966
26411
  const relativeAt = relativeLiteral ? itemSpan.start + raw.subarray(itemSpan.start, itemSpan.end).indexOf(Buffer.from(relativeLiteral, "utf8")) : -1;
25967
26412
  const scopeValue = typeof item.requestedTarget?.scope === "string" ? item.requestedTarget.scope : typeof item.requestedTarget?.artifact_id === "string" ? item.requestedTarget.artifact_id : void 0;
25968
26413
  const editScope = directoryLiteral && scopeValue ? portableResolve(scopeValue, directoryLiteral) : scopeValue;
25969
- const editChoices = item.semanticAction === "modify" && (!item.requestedTarget?.artifact_id || directoryLiteral) && typeof editScope === "string" ? [...projection.evidence.values()].filter((fact) => fact.semanticAction === "modify" && fact.evidenceRole === "effect" && fact.outcome === "success" && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.subjects.length === 1 && typeof fact.subjects[0] === "string" && portableContains(editScope, fact.subjects[0])) : [];
26414
+ const editChoices = item.semanticAction === "modify" && (!item.requestedTarget?.artifact_id || directoryLiteral) && typeof editScope === "string" ? (successModifyEffects ?? [...projection.evidence.values()]).filter((fact) => fact.semanticAction === "modify" && fact.evidenceRole === "effect" && fact.outcome === "success" && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.subjects.length === 1 && typeof fact.subjects[0] === "string" && portableContains(editScope, fact.subjects[0])) : [];
25970
26415
  const selectedEdit = editChoices.length === 1 ? editChoices[0] : void 0;
25971
- const readbackChoices = fileReadback ? [...projection.evidence.values()].filter((fact) => fact.evidenceRole === "state" && fact.toolName === "context_guard_observe_file" && fact.outcome === "success" && fact.toolResultSeq > root.seq && fact.subjects.length === 1 && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && (!anaphoricReadback || typeof readbackReferent === "string" && fact.subjects[0] === readbackReferent) && [...projection.evidence.values()].some((effect) => effect.callId === fact.causedByCallId && effect.semanticAction === "modify" && effect.evidenceRole === "effect" && effect.outcome === "success" && effect.subjects.includes(fact.subjects[0]) && effect.toolResultSeq < fact.toolResultSeq)) : [];
26416
+ const readbackChoices = fileReadback ? (successFileStateEvidence ?? [...projection.evidence.values()]).filter((fact) => fact.evidenceRole === "state" && fact.toolName === "context_guard_observe_file" && fact.outcome === "success" && fact.toolResultSeq > root.seq && fact.subjects.length === 1 && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && (!anaphoricReadback || typeof readbackReferent === "string" && fact.subjects[0] === readbackReferent) && evidenceByCall(fact.causedByCallId ?? "").some((effect) => effect.semanticAction === "modify" && effect.evidenceRole === "effect" && effect.outcome === "success" && effect.subjects.includes(fact.subjects[0]) && effect.toolResultSeq < fact.toolResultSeq)) : [];
25972
26417
  const selectedReadback = readbackChoices.length === 1 ? readbackChoices[0] : void 0;
25973
26418
  const subjectKind = forbiddenFile || fileReadback || [
25974
26419
  "modify",
@@ -25989,9 +26434,9 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
25989
26434
  } : ownConstraintSpan;
25990
26435
  const needsReadiness = item.semanticAction === "test" || item.semanticAction === "verify" && !fileReadback;
25991
26436
  const readinessPredicate = item.semanticAction === "test" ? "test_passed" : "verification_passed";
25992
- const selectedReadiness = needsReadiness && !guarded ? [...projection.evidence.values()].find((fact) => {
26437
+ const selectedReadiness = needsReadiness && !guarded ? evidenceReadyFor(item.id).find((fact) => {
25993
26438
  const pair = sourceByCall.get(fact.callId);
25994
- const assessmentEffect = item.semanticAction !== "verify" || !fact.readinessEffectCallId && fact.readinessInputSha256 === fact.readinessManifestSha256 || [...projection.evidence.values()].some((effect) => effect.callId === fact.readinessEffectCallId && effect.toolResultSeq < fact.toolResultSeq && effect.epoch === fact.epoch && effect.outcome === "success" && effect.parseStatus === "supported" && effect.semanticAction === "modify" && effect.evidenceRole === "effect" && effect.operations?.some((operation) => operation.op === "modify" && operation.path === fact.readinessSelectedPath));
26439
+ const assessmentEffect = item.semanticAction !== "verify" || !fact.readinessEffectCallId && fact.readinessInputSha256 === fact.readinessManifestSha256 || evidenceByCall(fact.readinessEffectCallId ?? "").some((effect) => effect.toolResultSeq < fact.toolResultSeq && effect.epoch === fact.epoch && effect.outcome === "success" && effect.parseStatus === "supported" && effect.semanticAction === "modify" && effect.evidenceRole === "effect" && effect.operations?.some((operation) => operation.op === "modify" && operation.path === fact.readinessSelectedPath));
25995
26440
  return fact.readinessForItemId === item.id && fact.readinessPredicate === readinessPredicate && assessmentEffect && fact.toolName === "context_guard_observe_test_readiness" && fact.outcome === "success" && fact.epoch === projection.epoch && pair?.result.seq === fact.toolResultSeq && pair.call.seq > root.seq && typeof item.requestedTarget?.scope === "string" && fact.subjects.includes(item.requestedTarget.scope);
25996
26441
  }) : void 0;
25997
26442
  const namedTest = item.semanticAction === "test" ? /\b((?:npm|pnpm))\s+test\b/iu.exec(item.normalizedText) : null;
@@ -26014,13 +26459,13 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26014
26459
  const selectedScope = (selectedReadiness || selectedDirectTest) && typeof item.requestedTarget?.scope === "string" ? item.requestedTarget.scope : void 0;
26015
26460
  const target = forbiddenFile?.path ?? selectedScope ?? selectedEdit?.subjects[0] ?? selectedReadback?.subjects[0] ?? (relativeLiteral && named ? named : at >= 0 && named ? named : trimmed);
26016
26461
  if (!target) continue;
26017
- const knownForbiddenEffect = forbiddenFile && [...projection.evidence.values()].some((fact) => fact.epoch === projection.epoch && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.evidenceRole === "effect" && fact.outcome === "success" && fact.subjects.includes(target) && [
26462
+ const knownForbiddenEffect = forbiddenFile && candidatesForSubjects([target]).some((fact) => fact.epoch === projection.epoch && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.evidenceRole === "effect" && fact.outcome === "success" && fact.subjects.includes(target) && [
26018
26463
  "write",
26019
26464
  "write_file",
26020
26465
  "edit",
26021
26466
  "edit_file"
26022
26467
  ].includes(fact.toolName) && fact.operations?.some((operation) => ["create", "modify"].includes(operation.op) && operation.path === target));
26023
- const uncertainForbiddenEffect = forbiddenFile && !knownForbiddenEffect && [...projection.evidence.values()].some((fact) => fact.epoch === projection.epoch && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.evidenceRole === "effect" && fact.subjects.includes(target) && ([
26468
+ const uncertainForbiddenEffect = forbiddenFile && !knownForbiddenEffect && candidatesForSubjects([target]).some((fact) => fact.epoch === projection.epoch && fact.toolResultSeq > root.seq && (sourceByCall.get(fact.callId)?.call.seq ?? -1) > root.seq && fact.evidenceRole === "effect" && fact.subjects.includes(target) && ([
26024
26469
  "write",
26025
26470
  "write_file",
26026
26471
  "edit",
@@ -26098,7 +26543,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26098
26543
  constraint_kind: forbiddenFile ? "exact" : directoryLiteral ? "directory" : relativeLiteral ? "exact" : selectedScope || selectedEdit || selectedReadback ? "work_unit" : "exact",
26099
26544
  ...(forbiddenFile || directoryLiteral || relativeLiteral) && rootBase ? { resolved_constraint: portableResolve(rootBase, forbiddenFile?.literal ?? directoryLiteral ?? relativeLiteral) } : {},
26100
26545
  selection_source_id: kind === "constraint" ? null : selectedReadiness ? `call:${selectedReadiness.callId}` : selectedDirectTest ? `call:${selectedDirectTest.callId}` : selectedEdit ? `call:${selectedEdit.callId}` : selectedReadback ? `call:${selectedReadback.callId}` : relativeLiteral ? (() => {
26101
- const fact = [...projection.evidence.values()].find((entry) => entry.semanticAction === "modify" && entry.evidenceRole === "effect" && entry.outcome === "success" && entry.subjects.includes(target) && sourceByCall.has(entry.callId));
26546
+ const fact = (successModifyEffects ?? [...projection.evidence.values()]).find((entry) => entry.semanticAction === "modify" && entry.evidenceRole === "effect" && entry.outcome === "success" && entry.subjects.includes(target) && sourceByCall.has(entry.callId));
26102
26547
  return fact ? `call:${fact.callId}` : null;
26103
26548
  })() : null
26104
26549
  }
@@ -26109,10 +26554,10 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26109
26554
  const deliveryId = `delivery:${delivery.seq}:revision:${itemRevision}`;
26110
26555
  const deliveredText = Array.isArray(row(row(delivery.data).message).content) ? row(row(delivery.data).message).content.filter((part) => row(part).type === "text").map((part) => String(row(part).text ?? "")).join("\n") : "";
26111
26556
  const isTestReport = /\b(?:report|summari[sz]e)\b[^。.!??]{0,80}\b(?:result|outcome)\b|(?:报告|汇报|说明)[^。.!??]{0,80}(?:结果|运行情况)/iu.test(item.normalizedText);
26112
- const rootTests = currentItems.filter((candidate) => sourceSeq(candidate) === root.seq && candidate.semanticAction === "test");
26557
+ const rootTests = (itemsByRootSeq.get(root.seq) ?? []).filter((candidate) => candidate.semanticAction === "test");
26113
26558
  const reportTest = isTestReport && rootTests.length === 1 ? rootTests[0] : void 0;
26114
26559
  const expectedCommand = reportTest ? /\b(npm|pnpm)\s+test\b/iu.exec(reportTest.normalizedText)?.[0]?.toLowerCase() : void 0;
26115
- const run = expectedCommand ? [...projection.evidence.values()].filter((entry) => {
26560
+ const run = expectedCommand ? (testEffectEvidence ?? [...projection.evidence.values()]).filter((entry) => {
26116
26561
  const pair = sourceByCall.get(entry.callId);
26117
26562
  if (!pair || pair.call.seq <= root.seq || pair.result.seq >= delivery.seq || entry.semanticAction !== "test" || entry.evidenceRole !== "effect" || entry.parseStatus !== "supported" || entry.processFacts?.operationAttribution !== "single_operation" || !projection.auditedForegroundRenderers?.includes(entry.toolName) || persistedToolResultStatus(pair.result.data, entry.callId) === "unknown" || !entry.subjects.includes(String(reportTest?.requestedTarget?.scope ?? ""))) return false;
26118
26563
  let args = {};
@@ -26134,7 +26579,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26134
26579
  const numericReport = declaredExit !== void 0 && reportedExits.length > 0 && reportedExits.every((value) => value === declaredExit);
26135
26580
  const statusReport = run?.processFacts?.outcome === "success" ? /(?:test(?:s)?\s+(?:passed|succeeded)|测试(?:已)?通过|测试成功)/iu.test(assertedText) : trustedFailure ? /(?:test(?:s)?\s+(?:failed|did\s+not\s+pass)|测试(?:未通过|失败))/iu.test(assertedText) : false;
26136
26581
  if (reportTest && (conflictingStatus || !numericReport && !statusReport)) continue;
26137
- if (!sources.some((source) => source.id === deliveryId)) sources.push({
26582
+ if (!sourceIds.has(deliveryId)) addSource({
26138
26583
  id: deliveryId,
26139
26584
  seq: delivery.seq,
26140
26585
  kind: "final_delivery",
@@ -26164,7 +26609,8 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26164
26609
  });
26165
26610
  }
26166
26611
  }
26167
- for (const evidence of guarded ? [] : projection.evidence.values()) {
26612
+ const evidenceCandidates = guarded ? [] : candidatesForSubjects([target, needsReadiness && typeof item.requestedTarget?.scope === "string" ? item.requestedTarget.scope : void 0]);
26613
+ for (const evidence of evidenceCandidates) {
26168
26614
  const inTestScope = needsReadiness && typeof item.requestedTarget?.scope === "string" && evidence.subjects.includes(item.requestedTarget.scope);
26169
26615
  if (evidence.epoch !== projection.epoch || !evidence.subjects.includes(target) && !inTestScope || evidence.toolResultSeq <= root.seq || attached.has(evidence.id) && !fileReadback) continue;
26170
26616
  if (kind === "constraint" && (!forbiddenFile || evidence.evidenceRole !== "effect" || ![
@@ -26179,7 +26625,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26179
26625
  if (fileReadback && (evidence.evidenceRole !== "state" || evidence.toolName !== "context_guard_observe_file")) continue;
26180
26626
  if (evidence.toolName === "context_guard_observe_test_readiness" && evidence.readinessForItemId !== item.id) continue;
26181
26627
  if (evidence.evidenceRole === "state" && evidence.toolName !== "context_guard_observe_test_readiness") {
26182
- if (![...projection.evidence.values()].find((fact) => fact.callId === evidence.causedByCallId && fact.epoch === evidence.epoch && fact.outcome === "success" && fact.toolResultSeq < evidence.toolResultSeq && fact.subjects.includes(target) && fact.semanticAction === evidence.semanticAction) || !["context_guard_observe_file", "context_guard_observe_git"].includes(evidence.toolName)) continue;
26628
+ if (!evidenceByCall(evidence.causedByCallId ?? "").find((fact) => fact.callId === evidence.causedByCallId && fact.epoch === evidence.epoch && fact.outcome === "success" && fact.toolResultSeq < evidence.toolResultSeq && fact.subjects.includes(target) && fact.semanticAction === evidence.semanticAction) || !["context_guard_observe_file", "context_guard_observe_git"].includes(evidence.toolName)) continue;
26183
26629
  }
26184
26630
  const pair = sourceByCall.get(evidence.callId);
26185
26631
  const crossesNewConstraint = kind === "constraint" && forbiddenFile && pair && pair.call.seq <= root.seq && pair.result.seq >= root.seq;
@@ -26188,7 +26634,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26188
26634
  if (item.semanticAction === "test" && evidence.evidenceRole === "effect" && (namedTest ? !isDirectTestFact(evidence) : !selectedReadiness)) continue;
26189
26635
  const outcome = hostResultStatus === "failure" || evidence.outcome === "failure" || evidence.processFacts?.outcome === "failure" ? "failure" : evidence.outcome !== "success" || evidence.processFacts?.outcome === "unknown" || hostResultStatus === "unknown" || evidence.evidenceRole === "effect" && evidence.processFacts && evidence.processFacts.operationAttribution !== "single_operation" || evidence.parseStatus !== "supported" ? "unknown" : "success";
26190
26636
  const callId = `call:${evidence.callId}`, resultId = `result:${evidence.callId}`;
26191
- const existingCall = sources.find((source) => source.id === callId);
26637
+ const existingCall = sourceById.get(callId);
26192
26638
  if (existingCall && existingCall.revision !== itemRevision) continue;
26193
26639
  const callName = String(row(pair.call.data).name ?? "");
26194
26640
  let callArgs = {};
@@ -26207,13 +26653,13 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26207
26653
  const fileCallTarget = fileCall && typeof filePath === "string" && filePath ? portableResolve(rootBase, filePath) : void 0;
26208
26654
  const hostTarget = fileCall ? fileCallTarget : evidence.subjects[0];
26209
26655
  if (!hostTarget || fileCall && evidence.parseStatus !== "supported") continue;
26210
- if (!sources.some((source) => source.id === callId)) {
26656
+ if (!sourceIds.has(callId)) {
26211
26657
  const callTurn = String(row(pair.call.data).turn ?? turn);
26212
26658
  const resultTurn = String(row(pair.result.data).turn ?? callTurn);
26213
26659
  const originRoot = usedRoots.filter((candidate) => candidate.seq <= pair.call.seq && String(row(candidate.data).turn ?? turn) === callTurn).at(-1);
26214
26660
  const callBytes = String(row(pair.call.data).arguments ?? "");
26215
26661
  const resultBytes = Array.isArray(row(row(pair.result.data).message).content) ? row(row(pair.result.data).message).content.filter((part) => row(part).type === "text").map((part) => String(row(part).text ?? "")).join("\n") : "";
26216
- sources.push({
26662
+ addSource({
26217
26663
  id: callId,
26218
26664
  seq: pair.call.seq,
26219
26665
  kind: "host_call",
@@ -26228,7 +26674,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26228
26674
  target_kind: subjectKind,
26229
26675
  ...originRoot ? { origin_root_source_id: `root:${originRoot.seq}` } : {}
26230
26676
  });
26231
- sources.push({
26677
+ addSource({
26232
26678
  id: resultId,
26233
26679
  seq: pair.result.seq,
26234
26680
  kind: "host_result",
@@ -26260,7 +26706,7 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26260
26706
  });
26261
26707
  if (!fileReadback) attached.add(evidence.id);
26262
26708
  }
26263
- for (const base of currentActionBases(projection, false).filter((base$1) => base$1.itemId === item.id)) {
26709
+ for (const base of basesByItem.get(item.id) ?? []) {
26264
26710
  const ready = facts.filter((fact) => fact.requirement_id === item.id && fact.kind === "readiness" && fact.outcome === "success").map((fact) => fact.id);
26265
26711
  if (!ready.length) continue;
26266
26712
  actions.push({
@@ -26283,9 +26729,16 @@ function sessionCoreSnapshot(events, projection, displayOrigins) {
26283
26729
  }
26284
26730
  const latestText = rootText(latestRoot), latestDigest = hash(latestText);
26285
26731
  const resume = isResume(latestText);
26732
+ const unitIdsByRootSeq = /* @__PURE__ */ new Map();
26733
+ for (const entry of projection.units.values()) for (const ref$1 of entry.rootInputRefs) {
26734
+ const bucket = unitIdsByRootSeq.get(ref$1.seq);
26735
+ if (bucket) {
26736
+ if (!bucket.includes(entry.unitId)) bucket.push(entry.unitId);
26737
+ } else unitIdsByRootSeq.set(ref$1.seq, [entry.unitId]);
26738
+ }
26286
26739
  const selectedUnitAtRoot = (seq) => {
26287
- const selected = [...projection.units.values()].filter((entry) => entry.rootInputRefs.some((ref$1) => ref$1.seq === seq));
26288
- return selected.length === 1 ? selected[0]?.unitId : void 0;
26740
+ const selected = unitIdsByRootSeq.get(seq) ?? [];
26741
+ return selected.length === 1 ? selected[0] : void 0;
26289
26742
  };
26290
26743
  const controls = rootControls(usedRoots, requirements, sources, facts, unit, selectedUnitAtRoot);
26291
26744
  return {
@@ -26409,7 +26862,7 @@ function firstStepGuidance(policy = "standard") {
26409
26862
  }
26410
26863
  const FIRST_STEP_GUIDANCE = firstStepGuidance("standard");
26411
26864
  function firstStepGuidanceV6(policy = "standard") {
26412
- return "Context Guard records requirements and verifies completion from persisted host tool results and independent readback. Run ordinary edits, tests, and Git work with host tools; use read-only Guard observers and context_guard_checkpoint when a requirement needs certified completion. Older Guard action and evidence records remain historical and do not authorize or certify current ordinary work." + (policy === "strict" ? " Explicit visual or complete-scope proof still requires a real readback." : "") + " Goal completion protection applies only after explicit /context-guard on adoption; an adopted release contract keeps its separate release checks.";
26865
+ return "Context Guard verifies requirements from persisted host results and independent readback. Use host tools for ordinary edits, tests and Git; read-only Guard observers and context_guard_checkpoint provide required certification. Older Guard action/evidence records are historical: they neither authorize nor certify current work." + (policy === "strict" ? " Explicit visual or complete-scope proof requires real readback." : "") + " Goal protection requires explicit /context-guard on adoption; adopted releases keep separate checks.";
26413
26866
  }
26414
26867
  /**
26415
26868
  * Lifecycle phase derived from durable facts. `enabled` is the log-derived
@@ -27633,4 +28086,4 @@ const RC020_RC1_HOST_PACKAGES = packages.map(({ name, version: version$1, integr
27633
28086
  }));
27634
28087
 
27635
28088
  //#endregion
27636
- export { PROOF_CAPABILITY_MATRIX as $, ACTIVE_HOST_COHORT_ID as $i, admissibleForRemoval as $n, splitTextFragments as $r, releasePreEffectDecision as $t, PROTOCOL_V3_NOTICE as A, CERTIFICATE_VERSION_V2 as Aa, resolveActiveProfileHostLock as Ai, effectuateBoundary as An, interpretClause as Ar, V6_ORDINARY_COMPLETION_RULE_SHORT as At, extractTextContent as B, requestedTargetAuthorizesMutation as Ba, readAsarFile as Bi, rebindResponse as Bn, kindOfScope as Br, isV6PendingRootWait as Bt, SESSION_API_UNSUPPORTED as C, evaluateMinimumHostVersion as Ca, inspectTargetHostGraph as Ci, goalCompletionDenial as Cn, clauseIsGoverned as Cr, CLEANUP_CONDITION_RULE as Ct, projectCoreV2 as D, ACTION_MANIFEST_VERSION as Da, prepareDesktopHostTrust as Di, unitDescendantIds as Dn, hasOrderedCoordination as Dr, MIN_RECOVERY_CHAR_BUDGET as Dt, snapshotSessionEvents as E, ACTION_MANIFEST as Ea, prepareActiveHostTrust as Ei, certificateClosure as En, governedClauseRestrictsExecution as Er, DEFAULT_RECOVERY_CHAR_BUDGET as Et, deriveProjection as F, SUPPORTED_EVIDENCE_ADAPTERS as Fa, DESKTOP_IDENTITY_FACTS as Fi, confirmRebind as Fn, isInformationalFragment as Fr, recoveryDigest as Ft, canonicalArgvFromCommand as G, validateActionTarget as Ga, writeDesktopRuntimeReceipt as Gi, capabilityRemedyPhrase as Gn, opensConditionLead as Gr, contractById as Gt, isDeterministicCheck as H, semanticActionFromCommand as Ha, readDesktopAppRuntime as Hi, CONFIRM_LINE_PATTERN as Hn, maskCodeSpans as Hr, OUTCOME_STRENGTH as Ht, legacyRecordsNeedingReview as I, actionCompatible as Ia, DESKTOP_PROFILE_PACKAGE_NAME as Ii, proposeRebind as In, isOpenObligation as Ir, recoveryTitle as It, parseShellCommand as J, hostTrustDigest as Ji, itemDiagnosis as Jn, qualificationOfClause as Jr, normalizeReservation as Jt, isRunExecutable as K, RC020_RC2_HOST_PACKAGES as Ka, HostTrustError as Ki, deriveItemDiagnosis as Kn, opensWithDirective as Kr, inFlightReservation as Kt, rootLocatorFlavor as L, boundedArtifactChoiceMatches as La, DESKTOP_RUNTIME_PACKAGE_NAME as Li, proposeRebindOutcome as Ln, isQuestionScopeNeedingReview as Lr, renderRecoveryPacket as Lt, PROTOCOL_V5_NOTICE as M, STATEFUL_ACTIONS as Ma, resolveInstalledHostLock as Mi, qualifyBoundary as Mn, introducesActionClause as Mr, cleanupConditionFor as Mt, PROTOCOL_V6_NOTICE as N, STOP_PROTOCOL_VERSION as Na, revalidateDesktopCoreLock as Ni, currentContractDigest as Nn, isExecutableItem as Nr, closingHint as Nt, CAPTURE_V042_NOTICE as O, BOUNDED_ARTIFACT_TYPES as Oa, prepareTargetHostTrust as Oi, BOUNDARY_RECORD_PREFIX as On, hasQuestionScope as Or, V6_ORDINARY_COMPLETION_RULE as Ot, applyUpgradeEligibility as P, STOP_PROTOCOL_VERSION_V2 as Pa, verifyComposedHostLockDump as Pi, createProjection as Pn, isExplanationScope as Pr, openItems as Pt, certifyCheckpoint as Q, registryArchiveModules as Qi, actionHasCertificationPath as Qn, semanticActionOfScope as Qr, releaseCoverage as Qt, supersedeItem as R, isStatefulAction as Ra, auditDesktopInstalledImplementation as Ri, proposeRebindV042 as Rn, isRestatement as Rr, v6CurrentRootBoundaries as Rt, sourcedNamedTestRoot as S, compareHostVersions as Sa, inspectDesktopTargetGraph as Si, v6TestPredicate as Sn, clauseAsksOwnQuestion as Sr, validateProofManifestV2 as St, SessionApiError as T, satisfiesSupportedHostRange as Ta, packageRowsFromPnpmLock as Ti, certifiableOpenItems as Tn, explanationHasActionResidue as Tr, CLEANUP_CONDITION_RULE_SHORT as Tt, persistedToolResultStatus as U, semanticActionFromText as Ua, readDesktopDependency as Ui, isFrozenV042RebindResponse as Un, maskQuotedSpans as Ur, RELEASE_OPERATIONS as Ut, extractToolSubject as V, requestedTargetMatchesResolved as Va, readAsarIndex as Vi, replayRebindResult as Vn, legacyQuestionReadingIsInformational as Vr, sourceItemForCoreRequirement as Vt, withDurability as W, validateActionManifest as Wa, readDesktopTargetGraph as Wi, parseConfirmationMessage as Wn, namedActions as Wr, RELEASE_OPERATION_SURFACES as Wt, segmentAuthorityBlocks as X, qualifyHostTrust as Xi, relevantEvidence as Xn, reportingHeadGoverns as Xr, readbackSettlesContract as Xt, authorityCaptureCounts as Y, parseHostTrust as Yi, nativeFileTwoRole as Yn, questionHeadsClause as Yr, normalizeSettlement as Yt, bindingIndividuallyAccepted as Z, registryArchiveFiles as Zi, DEPENDENCY_FREE_ONLY_CONDITION as Zn, restatedContentOf as Zr, releaseContractFor as Zt, previewFirstStepInjection as _, HOST_VALIDATED_VERSIONS as _a, evaluateActiveHostLock as _i, latestAssistantText as _n, classifyUserInteraction as _r, requiredSubjectsOf as _t, commitTreeSnapshotDigest as a, GOAL_HOST_PACKAGES as aa, digestStrings as ai, CONTROL_RECORD_PREFIX as an, captureClause as ar, bindProofToProjection as at, HOST_WORKDIR_PREFIX as b, SUPPORTED_HOST_RANGE as ba, hostLockRowsFromComposedDump as bi, progressFingerprint as bn, actionVerbMatches as br, sessionQueryV2 as bt, gitCommandMatchesTarget as c, bindExecutableIdentity as ca, sanitizeUrl as ci, assessmentAction as cn, environmentDefaultRepositoryTarget as cr, createProofManifest as ct, verifiedLinearCommitReadback as d, evaluateGraphDerivedHostLock as da, activeRendererModule as di, currentActionBases as dn, extractOperation as dr, proofDigest as dt, ACTIVE_HOST_COHORT_IDS as ea, statefulActionsOfScope as ei, reservationFor as en, capabilityConsequence as er, PROOF_KINDS as et, FIRST_STEP_GUIDANCE as f, evaluateHostCapability as fa, auditedDefaultWorkdirHost as fi, decideTurnBoundary as fn, isInformationalMessage as fr, proofDigestV2 as ft, lifecyclePhase as g, selectHostCohort as ga, combineHostPolicy as gi, isWholeTaskCompletionClaim as gn, classifyTaskIntent as gr, proofV2Rejection as gt, firstStepGuidanceV6 as h, hostVersionFromPackages as ha, auditedHostImplementation as hi, isRootPauseRequest as hn, npmEscapedPackageName as hr, proofOperationMatches as ht, commitIndexSnapshotDigest as i, EXPECTED_HOST_PACKAGES as ia, canonicalizePath as ii, isVerifyingCapability as in, removalIsPartiallyKnown as ir, PROOF_PROTOCOL_VERSION_V2 as it, PROTOCOL_V4_NOTICE as j, SEMANTIC_ACTIONS as ja, resolveDesktopProfileHostLock as ji, isCurrentAcceptedBoundary as jn, interpretMessage as jr, carriesCleanupCondition as jt, DEFAULT_DELEGATION_TOOL_NAMES as k, CERTIFICATE_VERSION as ka, readActiveHostGraph as ki, availableBoundaryQualifications as kn, hasWorkPredicate as kr, V6_ORDINARY_COMPLETION_RULE_COMPACT as kt, parseGitCommandManifest as l, bindLiveGoalCapability as la, sha256 as li, assessmentOutcomePredicate as ln, extractArtifactPaths as lr, createProofManifestV2 as lt, firstStepGuidance as m, evaluateToolSurfaceCapability as ma, auditedForegroundRenderers as mi, decisionBoundaryKey as mn, canonicalRegistryBase as mr, proofHostSurfacesOf as mt, GIT_COMMAND_MANIFEST_IDS as n, BASE_HOST_PACKAGES as na, COMMAND_SURFACE_MANIFEST as ni, evidenceCoverage as nn, partialFailureOf as nr, PROOF_MANIFEST_DOMAIN_V2 as nt, createGitPrestateEnvelope as o, HOST_CAPABILITY_PACKAGE_GROUPS as oa, normalizeClause as oi, NO_PROGRESS_RECORD_PREFIX as on, captureItem as or, bindProofV2ToProjection as ot, claimedBatchHasRealRootInput as p, evaluateHostLock as pa, auditedDefaultWorkdirProvider as pi, decideTurnStopping as pn, segmentClauses as pr, proofEvidenceConstraints as pt, parsePwshCommand as q, createHostAuditSession as qa, acquireHostTrust as qi, evidenceAvailabilityReason as qn, presentExplanationHead as qr, normalizeReleaseContract as qt, GIT_COMMAND_TEMPLATES as r, DEFAULT_HOST_LOCK as ra, validateManifest as ri, evidenceMatchesItem as rn, removalIsComplete as rr, PROOF_PROTOCOL_VERSION as rt, executeRevalidatedGitEffect as s, HOST_COHORTS as sa, sanitizeClauseText as si, NO_PROGRESS_TURNS_BEFORE_STOP as sn, classifyClause as sr, canonicalProjection as st, RC020_RC1_HOST_PACKAGES as t, ACTIVE_HOST_LAUNCHER_VERSION as ta, verbIsNegated as ti, bindingSatisfies as tn, capabilityFactOf as tr, PROOF_KINDS_V2 as tt, revalidateGitPrestate as u, evaluateExternalWaitCapability as ua, HostProfileError as ui, classifyCompletionClaim as un, extractMethod as ur, proofCapabilityReport as ut, projectSessionCoreV2 as v, LATEST_TESTED_HOST_VERSION as va, evaluateConfiguredHostLock as vi, latestRootInstruction as vn, GRANTED_QUALIFICATION as vr, scopeCoverageDigest as vt, SESSION_EVENT_ENVELOPE_INVALID as w, parseHostVersion as wa, packageRowsFromActiveGraph as wi, hasCurrentCertificate as wn, clauseIsProtected as wr, CLEANUP_CONDITION_RULE_COMPACT as wt, captureHostWorkdir as x, SUPPORTED_HOST_VERSIONS as xa, injectActiveProfileHostLock as xi, testOutcomePredicate as xn, clarifiedSpanOf as xr, validateProofManifest as xt, sessionCoreSnapshot as y, MIN_SUPPORTED_HOST_VERSION as ya, hostLockContextFromComposedDump as yi, observeAssistantOutcome as yn, LEGACY_QUALIFICATION as yr, sessionQuery as yt, evidenceFromPersistedToolResult as z, requestedIdentityKey as za, hasDesktopImporterState as zi, rebindAttemptKey as zn, itemHoldsExecutionAuthority as zr, currentV6Feedback as zt };
28089
+ export { segmentAuthorityBlocks as $, createHostAuditSession as $a, acquireHostTrust as $i, evidenceAvailabilityReason as $n, presentExplanationHead as $r, normalizeSettlement as $t, PROTOCOL_V3_NOTICE as A, parseHostVersion as Aa, packageRowsFromActiveGraph as Ai, certifiableOpenItems as An, clauseIsProtected as Ar, MIN_RECOVERY_CHAR_BUDGET as At, evidenceFromPersistedToolResult as B, STOP_PROTOCOL_VERSION_V2 as Ba, verifyComposedHostLockDump as Bi, createProjection as Bn, isExplanationScope as Br, renderRecoveryPacket as Bt, SESSION_API_UNSUPPORTED as C, HOST_VALIDATED_VERSIONS as Ca, evaluateActiveHostLock as Ci, observeAssistantOutcome as Cn, classifyUserInteraction as Cr, sessionQueryV2 as Ct, projectCoreV2 as D, SUPPORTED_HOST_VERSIONS as Da, injectActiveProfileHostLock as Di, goalCompletionDenial as Dn, clarifiedSpanOf as Dr, CLEANUP_CONDITION_RULE_COMPACT as Dt, snapshotSessionEvents as E, SUPPORTED_HOST_RANGE as Ea, hostLockRowsFromComposedDump as Ei, v6TestPredicate as En, actionVerbMatches as Er, CLEANUP_CONDITION_RULE as Et, deriveProjection as F, CERTIFICATE_VERSION as Fa, readActiveHostGraph as Fi, availableBoundaryQualifications as Fn, hasWorkPredicate as Fr, cleanupConditionFor as Ft, persistedToolResultStatus as G, requestedIdentityKey as Ga, hasDesktopImporterState as Gi, rebindAttemptKey as Gn, itemHoldsExecutionAuthority as Gr, sourceItemForCoreRequirement as Gt, extractToolSubject as H, actionCompatible as Ha, DESKTOP_PROFILE_PACKAGE_NAME as Hi, proposeRebind as Hn, isOpenObligation as Hr, confirmedV6CoreDiagnostic as Ht, legacyRecordsNeedingReview as I, CERTIFICATE_VERSION_V2 as Ia, resolveActiveProfileHostLock as Ii, effectuateBoundary as In, interpretClause as Ir, closingHint as It, canonicalArgvFromCommand as J, semanticActionFromCommand as Ja, readDesktopAppRuntime as Ji, CONFIRM_LINE_PATTERN as Jn, maskCodeSpans as Jr, RELEASE_OPERATION_SURFACES as Jt, shellReadbackOutcome as K, requestedTargetAuthorizesMutation as Ka, readAsarFile as Ki, rebindResponse as Kn, kindOfScope as Kr, OUTCOME_STRENGTH as Kt, rootLocatorFlavor as L, SEMANTIC_ACTIONS as La, resolveDesktopProfileHostLock as Li, isCurrentAcceptedBoundary as Ln, interpretMessage as Lr, openItems as Lt, PROTOCOL_V5_NOTICE as M, ACTION_MANIFEST as Ma, prepareActiveHostTrust as Mi, needsReviewObligations as Mn, governedClauseRestrictsExecution as Mr, V6_ORDINARY_COMPLETION_RULE_COMPACT as Mt, PROTOCOL_V6_NOTICE as N, ACTION_MANIFEST_VERSION as Na, prepareDesktopHostTrust as Ni, unitDescendantIds as Nn, hasOrderedCoordination as Nr, V6_ORDINARY_COMPLETION_RULE_SHORT as Nt, CAPTURE_V042_NOTICE as O, compareHostVersions as Oa, inspectDesktopTargetGraph as Oi, hasCurrentCertificate as On, clauseAsksOwnQuestion as Or, CLEANUP_CONDITION_RULE_SHORT as Ot, applyUpgradeEligibility as P, BOUNDED_ARTIFACT_TYPES as Pa, prepareTargetHostTrust as Pi, BOUNDARY_RECORD_PREFIX as Pn, hasQuestionScope as Pr, carriesCleanupCondition as Pt, authorityCaptureCounts as Q, RC020_RC2_HOST_PACKAGES as Qa, HostTrustError as Qi, deriveItemDiagnosis as Qn, opensWithDirective as Qr, normalizeReservation as Qt, supersedeItem as R, STATEFUL_ACTIONS as Ra, resolveInstalledHostLock as Ri, qualifyBoundary as Rn, introducesActionClause as Rr, recoveryDigest as Rt, sourcedNamedTestRoot as S, selectHostCohort as Sa, combineHostPolicy as Si, latestRootInstruction as Sn, classifyTaskIntent as Sr, sessionQuery as St, SessionApiError as T, MIN_SUPPORTED_HOST_VERSION as Ta, hostLockContextFromComposedDump as Ti, testOutcomePredicate as Tn, LEGACY_QUALIFICATION as Tr, validateProofManifestV2 as Tt, isDeterministicCheck as U, boundedArtifactChoiceMatches as Ua, DESKTOP_RUNTIME_PACKAGE_NAME as Ui, proposeRebindOutcome as Un, isQuestionScopeNeedingReview as Ur, currentV6Feedback as Ut, extractTextContent as V, SUPPORTED_EVIDENCE_ADAPTERS as Va, DESKTOP_IDENTITY_FACTS as Vi, confirmRebind as Vn, isInformationalFragment as Vr, v6CurrentRootBoundaries as Vt, nativeGitParentOidVerified as W, isStatefulAction as Wa, auditDesktopInstalledImplementation as Wi, proposeRebindV042 as Wn, isRestatement as Wr, isV6PendingRootWait as Wt, parsePwshCommand as X, validateActionManifest as Xa, readDesktopTargetGraph as Xi, parseConfirmationMessage as Xn, namedActions as Xr, inFlightReservation as Xt, isRunExecutable as Y, semanticActionFromText as Ya, readDesktopDependency as Yi, isFrozenV042RebindResponse as Yn, maskQuotedSpans as Yr, contractById as Yt, parseShellCommand as Z, validateActionTarget as Za, writeDesktopRuntimeReceipt as Zi, capabilityRemedyPhrase as Zn, opensConditionLead as Zr, normalizeReleaseContract as Zt, previewFirstStepInjection as _, evaluateGraphDerivedHostLock as _a, activeRendererModule as _i, decideTurnStopping as _n, extractOperation as _r, proofHostSurfacesOf as _t, commitTreeSnapshotDigest as a, ACTIVE_HOST_COHORT_ID as aa, splitTextFragments as ai, bindingSatisfies as an, admissibleForRemoval as ar, PROOF_MANIFEST_DOMAIN_V2 as at, HOST_WORKDIR_PREFIX as b, evaluateToolSurfaceCapability as ba, auditedForegroundRenderers as bi, isWholeTaskCompletionClaim as bn, canonicalRegistryBase as br, requiredSubjectsOf as bt, gitCommandMatchesTarget as c, BASE_HOST_PACKAGES as ca, COMMAND_SURFACE_MANIFEST as ci, isVerifyingCapability as cn, partialFailureOf as cr, bindProofToProjection as ct, verifiedLinearCommitReadback as d, GOAL_HOST_PACKAGES as da, digestStrings as di, NO_PROGRESS_TURNS_BEFORE_STOP as dn, captureClause as dr, createProofManifest as dt, hostTrustDigest as ea, qualificationOfClause as ei, readbackSettlesContract as en, itemDiagnosis as er, bindingIndividuallyAccepted as et, FIRST_STEP_GUIDANCE as f, HOST_CAPABILITY_PACKAGE_GROUPS as fa, normalizeClause as fi, assessmentAction as fn, captureItem as fr, createProofManifestV2 as ft, lifecyclePhase as g, evaluateExternalWaitCapability as ga, HostProfileError as gi, decideTurnBoundary as gn, extractMethod as gr, proofEvidenceConstraints as gt, firstStepGuidanceV6 as h, bindLiveGoalCapability as ha, sha256 as hi, currentActionBases as hn, extractArtifactPaths as hr, proofDigestV2 as ht, commitIndexSnapshotDigest as i, registryArchiveModules as ia, semanticActionOfScope as ii, reservationFor as in, actionHasCertificationPath as ir, PROOF_KINDS_V2 as it, PROTOCOL_V4_NOTICE as j, satisfiesSupportedHostRange as ja, packageRowsFromPnpmLock as ji, certificateClosure as jn, explanationHasActionResidue as jr, V6_ORDINARY_COMPLETION_RULE as jt, DEFAULT_DELEGATION_TOOL_NAMES as k, evaluateMinimumHostVersion as ka, inspectTargetHostGraph as ki, ancestorConstraintForBinding as kn, clauseIsGoverned as kr, DEFAULT_RECOVERY_CHAR_BUDGET as kt, parseGitCommandManifest as l, DEFAULT_HOST_LOCK as la, validateManifest as li, CONTROL_RECORD_PREFIX as ln, removalIsComplete as lr, bindProofV2ToProjection as lt, firstStepGuidance as m, bindExecutableIdentity as ma, sanitizeUrl as mi, classifyCompletionClaim as mn, environmentDefaultRepositoryTarget as mr, proofDigest as mt, GIT_COMMAND_MANIFEST_IDS as n, qualifyHostTrust as na, reportingHeadGoverns as ni, releaseCoverage as nn, relevantEvidence as nr, PROOF_CAPABILITY_MATRIX as nt, createGitPrestateEnvelope as o, ACTIVE_HOST_COHORT_IDS as oa, statefulActionsOfScope as oi, evidenceCoverage as on, capabilityConsequence as or, PROOF_PROTOCOL_VERSION as ot, claimedBatchHasRealRootInput as p, HOST_COHORTS as pa, sanitizeClauseText as pi, assessmentOutcomePredicate as pn, classifyClause as pr, proofCapabilityReport as pt, withDurability as q, requestedTargetMatchesResolved as qa, readAsarIndex as qi, replayRebindResult as qn, legacyQuestionReadingIsInformational as qr, RELEASE_OPERATIONS as qt, GIT_COMMAND_TEMPLATES as r, registryArchiveFiles as ra, restatedContentOf as ri, releasePreEffectDecision as rn, DEPENDENCY_FREE_ONLY_CONDITION as rr, PROOF_KINDS as rt, executeRevalidatedGitEffect as s, ACTIVE_HOST_LAUNCHER_VERSION as sa, verbIsNegated as si, evidenceMatchesItem as sn, capabilityFactOf as sr, PROOF_PROTOCOL_VERSION_V2 as st, RC020_RC1_HOST_PACKAGES as t, parseHostTrust as ta, questionHeadsClause as ti, releaseContractFor as tn, nativeFileTwoRole as tr, certifyCheckpoint as tt, revalidateGitPrestate as u, EXPECTED_HOST_PACKAGES as ua, canonicalizePath as ui, NO_PROGRESS_RECORD_PREFIX as un, removalIsPartiallyKnown as ur, canonicalProjection as ut, projectSessionCoreV2 as v, evaluateHostCapability as va, auditedDefaultWorkdirHost as vi, decisionBoundaryKey as vn, isInformationalMessage as vr, proofOperationMatches as vt, SESSION_EVENT_ENVELOPE_INVALID as w, LATEST_TESTED_HOST_VERSION as wa, evaluateConfiguredHostLock as wi, progressFingerprint as wn, GRANTED_QUALIFICATION as wr, validateProofManifest as wt, captureHostWorkdir as x, hostVersionFromPackages as xa, auditedHostImplementation as xi, latestAssistantText as xn, npmEscapedPackageName as xr, scopeCoverageDigest as xt, sessionCoreSnapshot as y, evaluateHostLock as ya, auditedDefaultWorkdirProvider as yi, isRootPauseRequest as yn, segmentClauses as yr, proofV2Rejection as yt, NATIVE_GIT_ROOT_PARENT_OID as z, STOP_PROTOCOL_VERSION as za, revalidateDesktopCoreLock as zi, currentContractDigest as zn, isExecutableItem as zr, recoveryTitle as zt };