@tangle-network/agent-knowledge 21.0.0 → 22.0.1

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.
@@ -1,13 +1,14 @@
1
1
  import { i as textSourceId, n as slugify, r as stableId, t as sha256 } from "./ids-Bevz_pXV.js";
2
- import { r as searchKnowledge } from "./search-BBr5eUyT.js";
2
+ import { r as searchKnowledge } from "./search-aZdP2685.js";
3
3
  import { canonicalCandidateBytes, canonicalCandidateDigest, sha256Bytes, sha256DigestSchema } from "@tangle-network/agent-interface";
4
4
  import { contentHash } from "@tangle-network/agent-eval";
5
5
  import { z } from "zod";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
7
  import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync } from "node:fs";
8
- import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm } from "node:fs/promises";
8
+ import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
9
9
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
+ import { hostname } from "node:os";
11
12
  //#region src/adapters.ts
12
13
  const textSourceAdapter = {
13
14
  id: "text",
@@ -639,8 +640,10 @@ async function applyKnowledgeFileTransaction(input) {
639
640
  });
640
641
  }
641
642
  async function assertKnowledgeFileTransactionApplied(root, transaction) {
642
- for (const entry of transaction.entries) await withSafeDescendant(root, entry.path, async (target) => {
643
- if (!fileMatches(await readRegularFile(target), entry.afterHash, entry.afterMode)) throw new Error(`knowledge file transaction did not commit: ${entry.path}`);
643
+ await mapFileIo(transaction.entries, async (entry) => {
644
+ await withSafeDescendant(root, entry.path, async (target) => {
645
+ if (!fileMatches(await readRegularFile(target), entry.afterHash, entry.afterMode)) throw new Error(`knowledge file transaction did not commit: ${entry.path}`);
646
+ });
644
647
  });
645
648
  }
646
649
  async function finishKnowledgeFileTransaction(input) {
@@ -792,8 +795,10 @@ async function assertKnowledgeFileTransactionTerminal(root, transaction, directi
792
795
  await assertKnowledgeFileTransactionApplied(root, transaction);
793
796
  return;
794
797
  }
795
- for (const entry of transaction.entries) await withSafeDescendant(root, entry.path, async (target) => {
796
- if (!fileMatches(await readRegularFile(target), entry.beforeHash, entry.beforeMode)) throw new Error(`knowledge file transaction did not roll back: ${entry.path}`);
798
+ await mapFileIo(transaction.entries, async (entry) => {
799
+ await withSafeDescendant(root, entry.path, async (target) => {
800
+ if (!fileMatches(await readRegularFile(target), entry.beforeHash, entry.beforeMode)) throw new Error(`knowledge file transaction did not roll back: ${entry.path}`);
801
+ });
797
802
  });
798
803
  }
799
804
  async function withTransactionRoot(root, transactionRoot, create, use) {
@@ -880,8 +885,45 @@ function fileMatches(file, hash, mode) {
880
885
  //#endregion
881
886
  //#region src/mutation-lock.ts
882
887
  const DEFAULT_STALE_MS = 9e5;
883
- const DEFAULT_READ_RETRIES = 100;
884
888
  const DEFAULT_READ_WAIT_MS = 25;
889
+ const MAX_POLL_MS = 250;
890
+ function sleep(ms) {
891
+ return new Promise((resolve) => setTimeout(resolve, ms));
892
+ }
893
+ /**
894
+ * How long a writer waits for the store lock, behind this process's writers and then another
895
+ * process's hold, before it fails naming the holder. It is the default stale window: by then the
896
+ * holder released, or stopped heartbeating and its lock was taken over, or it held the store
897
+ * longer than a crashed holder could wedge it.
898
+ *
899
+ * Holds measured on Discovery's archive USB disk had a median of 30.4 s and reached 92.6 s, and
900
+ * the 60 s same-process admission this replaces failed a queued `knowledge_record` terminally
901
+ * there, losing the write (agent-knowledge#251). On flash the same holds take 58-86 ms.
902
+ */
903
+ const WRITER_WAIT_MS = DEFAULT_STALE_MS;
904
+ /**
905
+ * How long a reader waits out writes before failing, when the caller sets no `retries`. It covers
906
+ * the slowest hold measured (92.6 s); the 2.5 s it replaces failed 18.3% of reads on that disk.
907
+ * A read changes nothing, so failing one loses no work, which is why it waits less than a writer.
908
+ */
909
+ const READER_WAIT_MS = 12e4;
910
+ /** Diagnostic record of the current cross-process holder, read only to name it in a timeout. */
911
+ const LOCK_OWNER_FILE = "mutation.lock.owner.json";
912
+ const holderLabels = new AsyncLocalStorage();
913
+ /**
914
+ * Name the store mutations `body` performs, so a writer or reader that times out behind them can
915
+ * say who held the store. Internal: tools label their writes with the tool and actor.
916
+ */
917
+ function withKnowledgeMutationLabel(label, body) {
918
+ return holderLabels.run(label, body);
919
+ }
920
+ function describeHolder(holder, now = Date.now()) {
921
+ const heldS = Math.max(0, Math.round((now - holder.since) / 1e3));
922
+ return `${holder.label} (pid ${holder.pid} on ${holder.host}, holding since ${new Date(holder.since).toISOString()}, ${heldS} s)`;
923
+ }
924
+ function seconds(ms) {
925
+ return `${Math.round(ms / 100) / 10} s`;
926
+ }
885
927
  let lockfileModule;
886
928
  function loadLockfile() {
887
929
  lockfileModule ??= import("proper-lockfile");
@@ -890,14 +932,13 @@ function loadLockfile() {
890
932
  const activeRoots = new AsyncLocalStorage();
891
933
  const activeReadRoots = new AsyncLocalStorage();
892
934
  const gates = /* @__PURE__ */ new Map();
893
- /** How long a same-process writer waits for admission before failing like a contended lock. */
894
- const WRITER_ADMISSION_MS = 6e4;
895
935
  function gateOf(root) {
896
936
  let gate = gates.get(root);
897
937
  if (!gate) {
898
938
  gate = {
899
939
  readers: 0,
900
940
  writing: false,
941
+ holder: void 0,
901
942
  readersWaiting: [],
902
943
  writersWaiting: []
903
944
  };
@@ -917,34 +958,51 @@ function admitNext(root, gate, afterWrite) {
917
958
  gate.writersWaiting.shift()();
918
959
  } else if (gate.readers === 0) gates.delete(root);
919
960
  }
920
- async function enterGate(root, mode, timeoutMs) {
961
+ /** Who a same-process waiter is waiting behind, for its timeout error. */
962
+ function describeGate(gate) {
963
+ const queued = gate.writersWaiting.length;
964
+ const behind = gate.holder ? describeHolder(gate.holder) : gate.readers > 0 ? `${gate.readers} reader(s) of this process` : "no admitted writer";
965
+ return queued > 0 ? `${behind}; ${queued} writer(s) still queued` : behind;
966
+ }
967
+ async function enterGate(root, mode, timeoutMs, label = "a knowledge mutation") {
921
968
  const gate = gateOf(root);
922
969
  const release = mode === "read" ? () => {
923
970
  gate.readers -= 1;
924
971
  if (gate.readers === 0) admitNext(root, gate, false);
925
972
  } : () => {
926
973
  gate.writing = false;
974
+ gate.holder = void 0;
927
975
  admitNext(root, gate, true);
928
976
  };
977
+ const hold = () => {
978
+ if (mode === "write") gate.holder = {
979
+ label,
980
+ pid: process.pid,
981
+ host: hostname(),
982
+ since: Date.now()
983
+ };
984
+ return once(release);
985
+ };
929
986
  if (mode === "read" ? !gate.writing && gate.writersWaiting.length === 0 : !gate.writing && gate.readers === 0 && gate.writersWaiting.length === 0) {
930
987
  if (mode === "read") gate.readers += 1;
931
988
  else gate.writing = true;
932
- return once(release);
989
+ return hold();
933
990
  }
934
991
  const waiting = mode === "read" ? gate.readersWaiting : gate.writersWaiting;
935
992
  return new Promise((resolve, reject) => {
936
993
  let timer;
937
994
  const admit = () => {
938
995
  if (timer) clearTimeout(timer);
939
- resolve(once(release));
996
+ resolve(hold());
940
997
  };
941
998
  waiting.push(admit);
942
999
  timer = setTimeout(() => {
943
1000
  const position = waiting.indexOf(admit);
944
1001
  if (position < 0) return;
945
1002
  waiting.splice(position, 1);
1003
+ const behind = describeGate(gate);
946
1004
  admitNext(root, gate, mode === "write");
947
- reject(mode === "read" ? /* @__PURE__ */ new Error("knowledge read could not observe a stable mutation epoch") : Object.assign(/* @__PURE__ */ new Error(`knowledge store is locked by this process: ${root}`), { code: "ELOCKED" }));
1005
+ reject(mode === "read" ? /* @__PURE__ */ new Error(`knowledge read could not observe a stable mutation epoch: ${root}; waited ${seconds(timeoutMs)} behind ${behind}`) : Object.assign(/* @__PURE__ */ new Error(`knowledge store is locked by this process: ${root}; waited ${seconds(timeoutMs)} behind ${behind}`), { code: "ELOCKED" }));
948
1006
  }, timeoutMs);
949
1007
  timer.unref?.();
950
1008
  });
@@ -989,21 +1047,17 @@ async function withKnowledgeMutation(root, mutate, options = {}) {
989
1047
  const existing = activeRoots.getStore()?.get(resolvedRoot);
990
1048
  if (existing?.active) return await runInlineMutation(existing.lock, mutate);
991
1049
  if (activeReadRoots.getStore()?.has(resolvedRoot)) throw new Error("a knowledge mutation cannot start inside a read of the same store");
1050
+ const label = holderLabels.getStore() ?? options.resumeTransaction?.purpose ?? "a knowledge mutation";
992
1051
  const started = performance.now();
993
- const leave = await enterGate(resolvedRoot, "write", noRetries(options.retries) ? 0 : WRITER_ADMISSION_MS);
1052
+ const leave = await enterGate(resolvedRoot, "write", noRetries(options.retries) ? 0 : WRITER_WAIT_MS, label);
994
1053
  try {
995
1054
  return await withSafeDirectory(resolvedRoot, ".agent-knowledge", true, async (cacheDir) => {
996
- const acquired = await acquireDurableFileLock(resolvedRoot, {
997
- lockfilePath: join(cacheDir, "mutation.lock.durable"),
1055
+ const acquired = await acquireStoreLock(resolvedRoot, cacheDir, {
998
1056
  staleMs: options.staleMs,
999
- retries: options.retries ?? {
1000
- retries: 100,
1001
- factor: 1.1,
1002
- minTimeout: 10,
1003
- maxTimeout: 200,
1004
- randomize: true
1005
- }
1057
+ retries: options.retries,
1058
+ started
1006
1059
  });
1060
+ await recordLockOwner(cacheDir, label);
1007
1061
  const held = performance.now();
1008
1062
  try {
1009
1063
  return await runOwnedMutation(resolvedRoot, cacheDir, acquired, options, mutate);
@@ -1022,6 +1076,54 @@ async function withKnowledgeMutation(root, mutate, options = {}) {
1022
1076
  leave();
1023
1077
  }
1024
1078
  }
1079
+ /**
1080
+ * Take the cross-process file lock. A caller that sets `retries` keeps that attempt budget; every
1081
+ * other writer polls until one deadline shared with its in-process wait, so a hold longer than a
1082
+ * fixed number of attempts delays a write instead of failing it.
1083
+ */
1084
+ async function acquireStoreLock(root, cacheDir, options) {
1085
+ const lockfilePath = join(cacheDir, "mutation.lock.durable");
1086
+ const deadline = options.started + WRITER_WAIT_MS;
1087
+ let pause = 10;
1088
+ for (;;) try {
1089
+ return await acquireDurableFileLock(root, {
1090
+ lockfilePath,
1091
+ staleMs: options.staleMs,
1092
+ retries: options.retries ?? 0
1093
+ });
1094
+ } catch (error) {
1095
+ const remaining = deadline - performance.now();
1096
+ if (options.retries !== void 0 || error.code !== "ELOCKED" || remaining <= 0) throw await namedLockError(error, root, cacheDir, performance.now() - options.started);
1097
+ await sleep(Math.min(remaining, pause * (.5 + Math.random())));
1098
+ pause = Math.min(MAX_POLL_MS, pause * 1.5);
1099
+ }
1100
+ }
1101
+ /** A contended file lock, restated with the holder its owner record names. */
1102
+ async function namedLockError(error, root, cacheDir, waitedMs) {
1103
+ if (error?.code !== "ELOCKED") return error;
1104
+ const owner = await readLockOwner(cacheDir);
1105
+ return Object.assign(new Error(`knowledge store is locked by another process: ${root}; waited ${seconds(waitedMs)} for ${owner ? describeHolder(owner) : "a holder that recorded no owner"}`, { cause: error }), { code: "ELOCKED" });
1106
+ }
1107
+ /** Record who holds the file lock, for a waiter's timeout. Diagnostic only, so not fsynced. */
1108
+ async function recordLockOwner(cacheDir, label) {
1109
+ const owner = {
1110
+ label,
1111
+ pid: process.pid,
1112
+ host: hostname(),
1113
+ since: Date.now()
1114
+ };
1115
+ try {
1116
+ await writeFile(join(cacheDir, LOCK_OWNER_FILE), `${JSON.stringify(owner)}\n`);
1117
+ } catch {}
1118
+ }
1119
+ async function readLockOwner(cacheDir) {
1120
+ try {
1121
+ const value = JSON.parse(await readFile(join(cacheDir, LOCK_OWNER_FILE), "utf8"));
1122
+ return typeof value.label === "string" && Number.isSafeInteger(value.pid) && typeof value.host === "string" && Number.isFinite(value.since) ? value : void 0;
1123
+ } catch {
1124
+ return;
1125
+ }
1126
+ }
1025
1127
  function noRetries(retries) {
1026
1128
  return retries === 0 || typeof retries === "object" && !Array.isArray(retries) && retries.retries === 0;
1027
1129
  }
@@ -1168,27 +1270,46 @@ async function withKnowledgeRead(root, read, options = {}) {
1168
1270
  if (activeReadRoots.getStore()?.has(resolvedRoot)) return await read();
1169
1271
  const readRoots = new Set(activeReadRoots.getStore());
1170
1272
  readRoots.add(resolvedRoot);
1171
- const retries = options.retries ?? DEFAULT_READ_RETRIES;
1172
- const leave = await enterGate(resolvedRoot, "read", (retries + 1) * (options.waitMs ?? DEFAULT_READ_WAIT_MS));
1273
+ const started = performance.now();
1274
+ const retries = options.retries;
1275
+ const budgetMs = retries === void 0 ? READER_WAIT_MS : (retries + 1) * (options.waitMs ?? DEFAULT_READ_WAIT_MS);
1276
+ const deadline = started + budgetMs;
1277
+ const leave = await enterGate(resolvedRoot, "read", budgetMs);
1173
1278
  try {
1174
1279
  return await activeReadRoots.run(readRoots, async () => {
1175
- for (let attempt = 0; attempt <= retries; attempt += 1) {
1280
+ let pause = options.waitMs ?? DEFAULT_READ_WAIT_MS;
1281
+ for (let attempt = 0; retries === void 0 || attempt <= retries; attempt += 1) {
1282
+ if (attempt > 0 && retries === void 0 && performance.now() >= deadline) break;
1176
1283
  const before = await readMutationEpoch(resolvedRoot);
1177
- if (isOdd(before)) {
1178
- await waitForActiveMutationEpoch(resolvedRoot, before, options);
1179
- continue;
1284
+ let active = before;
1285
+ if (!isOdd(before)) {
1286
+ const result = await read();
1287
+ const after = await readMutationEpoch(resolvedRoot);
1288
+ if (before === after) return result;
1289
+ if (!isOdd(after)) continue;
1290
+ active = after;
1180
1291
  }
1181
- const result = await read();
1182
- const after = await readMutationEpoch(resolvedRoot);
1183
- if (before === after && !isOdd(after)) return result;
1184
- if (isOdd(after)) await waitForActiveMutationEpoch(resolvedRoot, after, options);
1292
+ await waitForActiveMutationEpoch(resolvedRoot, active, options, pause);
1293
+ if (retries === void 0) pause = Math.min(MAX_POLL_MS, pause * 1.5);
1185
1294
  }
1186
- throw new Error("knowledge read could not observe a stable mutation epoch");
1295
+ throw new Error(`knowledge read could not observe a stable mutation epoch: ${resolvedRoot}; waited ${seconds(performance.now() - started)} for ${await describeWriter(resolvedRoot)}`);
1187
1296
  });
1188
1297
  } finally {
1189
1298
  leave();
1190
1299
  }
1191
1300
  }
1301
+ /** The writer a reader gave up on: this process's admitted writer, else the recorded owner. */
1302
+ async function describeWriter(root) {
1303
+ const local = gates.get(root)?.holder;
1304
+ if (local) return describeHolder(local);
1305
+ let owner;
1306
+ try {
1307
+ owner = await withSafeDirectory(root, ".agent-knowledge", false, readLockOwner);
1308
+ } catch {
1309
+ owner = void 0;
1310
+ }
1311
+ return owner ? describeHolder(owner) : "a writer that recorded no owner";
1312
+ }
1192
1313
  async function acquireDurableFileLock(target, options) {
1193
1314
  const stale = Math.max(5e3, options.staleMs ?? DEFAULT_STALE_MS);
1194
1315
  const update = Math.max(1e3, Math.floor(stale / 3));
@@ -1260,9 +1381,9 @@ async function writeMutationEpoch(cacheDir, epoch) {
1260
1381
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1261
1382
  });
1262
1383
  }
1263
- async function waitForActiveMutationEpoch(root, epoch, options) {
1384
+ async function waitForActiveMutationEpoch(root, epoch, options, pauseMs) {
1264
1385
  if (!await hasActiveMutationLock(root, options)) await healAbandonedMutationEpoch(root, epoch, options);
1265
- await new Promise((resolve) => setTimeout(resolve, options.waitMs ?? DEFAULT_READ_WAIT_MS));
1386
+ await sleep(pauseMs);
1266
1387
  }
1267
1388
  async function healAbandonedMutationEpoch(root, expectedEpoch, options) {
1268
1389
  await withSafeDirectory(root, ".agent-knowledge", false, async (cacheDir) => {
@@ -4873,6 +4994,6 @@ function explainKnowledgeTarget(index, target) {
4873
4994
  };
4874
4995
  }
4875
4996
  //#endregion
4876
- export { snapshotSourceTextInput as $, ClaimLedgerGoalConflictError as $t, validateKnowledgePage as A, prepareKnowledgeFileTransaction as An, knowledgePageFromMarkdown as At, DEADLINE_EXIT_CODE as B, readRegularFileWithinRoot as Bn, KnowledgeGraphEdgeSchema as Bt, immutablePageDigest as C, withKnowledgeMutation as Cn, resolveKnowledgeCitations as Ct, normalizeVisibilityArtifact as D, commitKnowledgeFileMutations as Dn, initKnowledgeBase as Dt, nonEmpty as E, assertKnowledgeMutationPath as En, SCAFFOLD_PAGE_BASENAMES as Et, detectNearDuplicatePages as F, canonicalRelativeWithinRoot as Fn, extractWikilinks as Ft, gradeFor as G, withSafeDescendant as Gn, KnowledgeRelationSchema as Gt, assertGradeableEvidence as H, removeDurable as Hn, KnowledgeIndexSchema as Ht, normalizePageText as I, isKernelAnchoredPath as In, normalizeLinkTarget as It, buildKnowledgeIndex as J, writeFileDurableWithinRoot as Jn, ResearchClaimRecordSchema as Jt, verdictFor as K, withSafeDirectory as Kn, ResearchClaimEvidenceSchema as Kt, validateKnowledgeIndex as L, isMissingFile as Ln, DeepQuestionSchema as Lt, verifyKnowledgeVisibilitySnapshot as M, DEFAULT_PAGES_DIRECTORY as Mn, loadKnowledgePages as Mt, visibilityIdentity as N, normalizePagesDirectory as Nn, writeJson as Nt, normalizeVisibilityRef as O, finishKnowledgeFileTransaction as On, isKnowledgePagePath as Ot, visibilityIndexOf as P, canonicalPathsEqual as Pn, WIKILINK_REGEX as Pt, loadSourceRegistry as Q, textSourceAdapter as Qn, KNOWLEDGE_EVENT_TYPES as Qt, lintKnowledgeIndex as R, listRegularFilesWithinRoot as Rn, KnowledgeBaseCandidateSchema as Rt, encodeKnowledgeVisibilitySnapshot as S, runInKnowledgeMutationScope as Sn, resolveKnowledgeCitation as St, knowledgeVisibilityArtifactRef as T, applyKnowledgeFileTransaction as Tn, resolveRunScopedCitations as Tt, claimCheckKey as U, renameDurable as Un, KnowledgePageInvalidationSchema as Ut, UncheckableClaimError as V, relativeWithinRoot as Vn, KnowledgeGraphNodeSchema as Vt, gradeClaims as W, syncDirectory as Wn, KnowledgePageSchema as Wt, addSourcePath as X, writeJsonDurableWithinRoot as Xn, SourceAnchorSchema as Xt, writeKnowledgeIndex as Y, writeJsonDurable as Yn, ResearchSourceVersionSchema as Yt, addSourceText as Z, mediaTypeFor$1 as Zn, SourceRecordSchema as Zt, KNOWLEDGE_USE_RECEIPT_SCHEMA_VERSION as _, acquireDurableFileLock as _n, assertRunScopedCitationsResolved as _t, applyKnowledgeWriteBlocksFile as a, claimId as an, KB_EVENTS_PATH as at, decodeKnowledgeVisibilitySnapshot as b, measureKnowledgeMutation as bn, formatKnowledgeCitationReference as bt, KnowledgeDuplicateIntakeError as c, emptyClaimLedger as cn, MemoryKbStore as ct, createFileRunLineageAuthority as d, mergeClaimLedgers as dn, knowledgePageRelations as dt, assertDeepQuestionIntegrity as en, sourceRegistryPath as et, createRunScopedStores as f, mergeTrackedClaims as fn, KnowledgeCitationAuditError as ft, KNOWLEDGE_RECEIPT_DIGEST_ALGORITHM as g, parseFrontmatter as gn, assertKnowledgeCitationsResolved as gt, originatedPages as h, formatFrontmatter as hn, assertKnowledgeCitationAudit as ht, applyKnowledgeWriteBlocks as i, claimEvidenceId as in, KB_CLAIM_LEDGER_DIR as it, validateOrigin as j, rollbackKnowledgeFileTransaction as jn, layoutFor as jt, snapshotImmutableVisibility as k, knowledgeFileTransactionPlanHash as kn, isScaffoldPath as kt, assertKnowledgeWriteIntake as l, linkClaimContradictions as ln, assertClaimLedgerId as lt, loadKnowledgeToolChain as m, researchSourceVersionKey as mn, assertCurrentRunCitationsResolved as mt, inspectKnowledgeIndex as n, assertResearchClaimLedgerIntegrity as nn, ClaimLedgerMigrationRequiredError as nt, isSafeKnowledgePath as o, claimSourceHost as on, KB_INDEX_PATH as ot, isKnowledgeToolChain as p, normalizeClaimText as pn, KnowledgeCitationResolutionError as pt, verifyGradeableEvidence as q, writeFileDurable as qn, ResearchClaimLedgerSchema as qt, stringMetadata as r, assertTrackedClaimIntegrity as rn, FileSystemKbStore as rt, parseKnowledgeWriteBlocks as s, deepQuestionId as sn, KB_STORE_DIR as st, explainKnowledgeTarget as t, assertResearchClaimEvidenceIntegrity as tn, writeSourceRegistry as tt, RUN_LINEAGE_BASENAME as u, materializeRegisteredClaimEvidence as un, buildKnowledgeGraph as ut, assertSchemaVersion as v, inspectPendingKnowledgeMutation as vn, auditCurrentRunCitations as vt, knowledgePageDigest as w, withKnowledgeRead as wn, resolveRunScopedCitation as wt, digest as x, recoverPendingKnowledgeMutation as xn, parseKnowledgeCitationReference as xt, createKnowledgeVisibilitySnapshot as y, isKnowledgeMutationHeld as yn, auditKnowledgeCitations as yt, CHECKABLE_RUNG_THRESHOLD as z, readRegularFileNoFollow as zn, KnowledgeEventSchema as zt };
4997
+ export { snapshotSourceTextInput as $, textSourceAdapter as $n, ClaimLedgerGoalConflictError as $t, validateKnowledgePage as A, knowledgeFileTransactionPlanHash as An, knowledgePageFromMarkdown as At, DEADLINE_EXIT_CODE as B, readRegularFileNoFollow as Bn, KnowledgeGraphEdgeSchema as Bt, immutablePageDigest as C, withKnowledgeMutation as Cn, resolveKnowledgeCitations as Ct, normalizeVisibilityArtifact as D, assertKnowledgeMutationPath as Dn, initKnowledgeBase as Dt, nonEmpty as E, applyKnowledgeFileTransaction as En, SCAFFOLD_PAGE_BASENAMES as Et, detectNearDuplicatePages as F, canonicalPathsEqual as Fn, extractWikilinks as Ft, gradeFor as G, syncDirectory as Gn, KnowledgeRelationSchema as Gt, assertGradeableEvidence as H, relativeWithinRoot as Hn, KnowledgeIndexSchema as Ht, normalizePageText as I, canonicalRelativeWithinRoot as In, normalizeLinkTarget as It, buildKnowledgeIndex as J, writeFileDurable as Jn, ResearchClaimRecordSchema as Jt, verdictFor as K, withSafeDescendant as Kn, ResearchClaimEvidenceSchema as Kt, validateKnowledgeIndex as L, isKernelAnchoredPath as Ln, DeepQuestionSchema as Lt, verifyKnowledgeVisibilitySnapshot as M, rollbackKnowledgeFileTransaction as Mn, loadKnowledgePages as Mt, visibilityIdentity as N, DEFAULT_PAGES_DIRECTORY as Nn, writeJson as Nt, normalizeVisibilityRef as O, commitKnowledgeFileMutations as On, isKnowledgePagePath as Ot, visibilityIndexOf as P, normalizePagesDirectory as Pn, WIKILINK_REGEX as Pt, loadSourceRegistry as Q, mediaTypeFor$1 as Qn, KNOWLEDGE_EVENT_TYPES as Qt, lintKnowledgeIndex as R, isMissingFile as Rn, KnowledgeBaseCandidateSchema as Rt, encodeKnowledgeVisibilitySnapshot as S, runInKnowledgeMutationScope as Sn, resolveKnowledgeCitation as St, knowledgeVisibilityArtifactRef as T, withKnowledgeRead as Tn, resolveRunScopedCitations as Tt, claimCheckKey as U, removeDurable as Un, KnowledgePageInvalidationSchema as Ut, UncheckableClaimError as V, readRegularFileWithinRoot as Vn, KnowledgeGraphNodeSchema as Vt, gradeClaims as W, renameDurable as Wn, KnowledgePageSchema as Wt, addSourcePath as X, writeJsonDurable as Xn, SourceAnchorSchema as Xt, writeKnowledgeIndex as Y, writeFileDurableWithinRoot as Yn, ResearchSourceVersionSchema as Yt, addSourceText as Z, writeJsonDurableWithinRoot as Zn, SourceRecordSchema as Zt, KNOWLEDGE_USE_RECEIPT_SCHEMA_VERSION as _, acquireDurableFileLock as _n, assertRunScopedCitationsResolved as _t, applyKnowledgeWriteBlocksFile as a, claimId as an, KB_EVENTS_PATH as at, decodeKnowledgeVisibilitySnapshot as b, measureKnowledgeMutation as bn, formatKnowledgeCitationReference as bt, KnowledgeDuplicateIntakeError as c, emptyClaimLedger as cn, MemoryKbStore as ct, createFileRunLineageAuthority as d, mergeClaimLedgers as dn, knowledgePageRelations as dt, assertDeepQuestionIntegrity as en, sourceRegistryPath as et, createRunScopedStores as f, mergeTrackedClaims as fn, KnowledgeCitationAuditError as ft, KNOWLEDGE_RECEIPT_DIGEST_ALGORITHM as g, parseFrontmatter as gn, assertKnowledgeCitationsResolved as gt, originatedPages as h, formatFrontmatter as hn, assertKnowledgeCitationAudit as ht, applyKnowledgeWriteBlocks as i, claimEvidenceId as in, KB_CLAIM_LEDGER_DIR as it, validateOrigin as j, prepareKnowledgeFileTransaction as jn, layoutFor as jt, snapshotImmutableVisibility as k, finishKnowledgeFileTransaction as kn, isScaffoldPath as kt, assertKnowledgeWriteIntake as l, linkClaimContradictions as ln, assertClaimLedgerId as lt, loadKnowledgeToolChain as m, researchSourceVersionKey as mn, assertCurrentRunCitationsResolved as mt, inspectKnowledgeIndex as n, assertResearchClaimLedgerIntegrity as nn, ClaimLedgerMigrationRequiredError as nt, isSafeKnowledgePath as o, claimSourceHost as on, KB_INDEX_PATH as ot, isKnowledgeToolChain as p, normalizeClaimText as pn, KnowledgeCitationResolutionError as pt, verifyGradeableEvidence as q, withSafeDirectory as qn, ResearchClaimLedgerSchema as qt, stringMetadata as r, assertTrackedClaimIntegrity as rn, FileSystemKbStore as rt, parseKnowledgeWriteBlocks as s, deepQuestionId as sn, KB_STORE_DIR as st, explainKnowledgeTarget as t, assertResearchClaimEvidenceIntegrity as tn, writeSourceRegistry as tt, RUN_LINEAGE_BASENAME as u, materializeRegisteredClaimEvidence as un, buildKnowledgeGraph as ut, assertSchemaVersion as v, inspectPendingKnowledgeMutation as vn, auditCurrentRunCitations as vt, knowledgePageDigest as w, withKnowledgeMutationLabel as wn, resolveRunScopedCitation as wt, digest as x, recoverPendingKnowledgeMutation as xn, parseKnowledgeCitationReference as xt, createKnowledgeVisibilitySnapshot as y, isKnowledgeMutationHeld as yn, auditKnowledgeCitations as yt, CHECKABLE_RUNG_THRESHOLD as z, listRegularFilesWithinRoot as zn, KnowledgeEventSchema as zt };
4877
4998
 
4878
- //# sourceMappingURL=inspect-DXN6SE2o.js.map
4999
+ //# sourceMappingURL=inspect-DBxyQSdt.js.map