@tangle-network/agent-knowledge 6.2.0 → 7.0.2

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/README.md +31 -1
  3. package/dist/benchmarks/index.d.ts +1 -1
  4. package/dist/benchmarks/index.js +1 -1
  5. package/dist/{benchmarks-CmW6iORW.js → benchmarks-CPl4AO1k.js} +74 -6
  6. package/dist/benchmarks-CPl4AO1k.js.map +1 -0
  7. package/dist/cli.js +1 -1
  8. package/dist/{ids-DRqPZ42_.js → ids-Bevz_pXV.js} +6 -2
  9. package/dist/ids-Bevz_pXV.js.map +1 -0
  10. package/dist/{index-DHebFLgU.d.ts → index-BEVmwlfJ.d.ts} +186 -7
  11. package/dist/index-BEVmwlfJ.d.ts.map +1 -0
  12. package/dist/{index-3z3lFJnE.d.ts → index-D0wc4GYg.d.ts} +2 -2
  13. package/dist/{index-3z3lFJnE.d.ts.map → index-D0wc4GYg.d.ts.map} +1 -1
  14. package/dist/index.d.ts +42 -16
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +86 -35
  17. package/dist/index.js.map +1 -1
  18. package/dist/{inspect-LUMkas6A.js → inspect-CJQGYuKa.js} +156 -33
  19. package/dist/inspect-CJQGYuKa.js.map +1 -0
  20. package/dist/memory/index.d.ts +3 -3
  21. package/dist/memory/index.js +3 -3
  22. package/dist/{memory-C6KPRhoU.js → memory-DAFfGTJH.js} +1093 -194
  23. package/dist/memory-DAFfGTJH.js.map +1 -0
  24. package/dist/sources/index.js +1 -1
  25. package/dist/{types-Cd57BPRt.d.ts → types-BOfmvDe-.d.ts} +21 -6
  26. package/dist/{types-Cd57BPRt.d.ts.map → types-BOfmvDe-.d.ts.map} +1 -1
  27. package/dist/viz/index.d.ts +1 -1
  28. package/docs/architecture.md +10 -6
  29. package/package.json +3 -3
  30. package/dist/benchmarks-CmW6iORW.js.map +0 -1
  31. package/dist/ids-DRqPZ42_.js.map +0 -1
  32. package/dist/index-DHebFLgU.d.ts.map +0 -1
  33. package/dist/inspect-LUMkas6A.js.map +0 -1
  34. package/dist/memory-C6KPRhoU.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { t as sha256 } from "../ids-DRqPZ42_.js";
1
+ import { t as sha256 } from "../ids-Bevz_pXV.js";
2
2
  import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  //#region src/sources/html.ts
@@ -227,21 +227,34 @@ interface ResearchClaimRecord {
227
227
  contested: boolean;
228
228
  firstSeenRound: number;
229
229
  }
230
+ /** Immutable identity of one exact version of an original source URI. */
231
+ interface ResearchSourceVersion {
232
+ /** Canonical source-registry id for this URI and content hash. */
233
+ sourceId: KnowledgeId;
234
+ /** The URI supplied before the source was copied into the raw-source store. */
235
+ uri: string;
236
+ /** SHA-256 of the exact submitted source text. */
237
+ contentHash: string;
238
+ }
230
239
  /**
231
240
  * One immutable claim extraction observed while a source is being verified.
232
241
  *
233
242
  * An observation is deliberately separate from `ResearchClaimRecord`: source
234
243
  * verification happens before source registration, and a process can die in
235
244
  * between. The observation is durable immediately, but it contributes support
236
- * to a claim only after `sourceUri` appears in the ledger's independently
237
- * confirmed `registeredSourceUris` set.
245
+ * to a claim only after its expected registry id, original URI, and content hash
246
+ * appear together in the ledger's independently confirmed `registeredSources` set.
238
247
  */
239
248
  interface ResearchClaimEvidence {
240
249
  /** Stable identity of this claim/source/contradiction observation. */
241
250
  id: string;
242
251
  claimId: string;
243
252
  text: string;
253
+ /** Canonical source-registry id expected for this source version. */
254
+ sourceId: KnowledgeId;
244
255
  sourceUri: string;
256
+ /** SHA-256 of the exact source text from which this observation was extracted. */
257
+ sourceContentHash: string;
245
258
  /** Existing claim this observation directly contradicts, when reported. */
246
259
  contradictsClaimId?: string;
247
260
  firstSeenRound: number;
@@ -255,6 +268,8 @@ interface ResearchClaimEvidence {
255
268
  * overwrite each other, so the store addresses ledgers by this id.
256
269
  */
257
270
  interface ResearchClaimLedger {
271
+ /** Persistent contract version; version 2 binds evidence to source content. */
272
+ schemaVersion: 2;
258
273
  id: string;
259
274
  /** The research goal this ledger accumulated evidence for. */
260
275
  goal?: string;
@@ -272,8 +287,8 @@ interface ResearchClaimLedger {
272
287
  * not yet been confirmed. Pending observations never count toward claims.
273
288
  */
274
289
  claimEvidence: ResearchClaimEvidence[];
275
- /** Exact original source URIs confirmed present in the source registry. */
276
- registeredSourceUris: string[];
290
+ /** Exact source-registry identities confirmed after their raw bytes were stored. */
291
+ registeredSources: ResearchSourceVersion[];
277
292
  claims: ResearchClaimRecord[];
278
293
  questions: DeepQuestion[];
279
294
  }
@@ -287,5 +302,5 @@ interface KnowledgeRelease {
287
302
  metadata?: Record<string, unknown>;
288
303
  }
289
304
  //#endregion
290
- export { ResearchClaimEvidence as C, SourceRecord as D, SourceAnchor as E, SourceRegistry as O, KnowledgeWriteParseResult as S, ResearchClaimRecord as T, KnowledgeRelation as _, KnowledgeBaseCandidate as a, KnowledgeUnit as b, KnowledgeEventType as c, KnowledgeGraphNode as d, KnowledgeId as f, KnowledgePolicy as g, KnowledgePage as h, KNOWLEDGE_EVENT_TYPES as i, TrackedClaim as k, KnowledgeGraph as l, KnowledgeLintFinding as m, DeepQuestion as n, KnowledgeClaim as o, KnowledgeIndex as p, DeepQuestionKind as r, KnowledgeEvent as s, ClaimRef as t, KnowledgeGraphEdge as u, KnowledgeRelease as v, ResearchClaimLedger as w, KnowledgeWriteBlock as x, KnowledgeSearchResult as y };
291
- //# sourceMappingURL=types-Cd57BPRt.d.ts.map
305
+ export { TrackedClaim as A, ResearchClaimEvidence as C, SourceAnchor as D, ResearchSourceVersion as E, SourceRecord as O, KnowledgeWriteParseResult as S, ResearchClaimRecord as T, KnowledgeRelation as _, KnowledgeBaseCandidate as a, KnowledgeUnit as b, KnowledgeEventType as c, KnowledgeGraphNode as d, KnowledgeId as f, KnowledgePolicy as g, KnowledgePage as h, KNOWLEDGE_EVENT_TYPES as i, SourceRegistry as k, KnowledgeGraph as l, KnowledgeLintFinding as m, DeepQuestion as n, KnowledgeClaim as o, KnowledgeIndex as p, DeepQuestionKind as r, KnowledgeEvent as s, ClaimRef as t, KnowledgeGraphEdge as u, KnowledgeRelease as v, ResearchClaimLedger as w, KnowledgeWriteBlock as x, KnowledgeSearchResult as y };
306
+ //# sourceMappingURL=types-BOfmvDe-.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-Cd57BPRt.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ;EACA;EACA;EACA;EACA;EACA,UAAU;;EAEV;;EAEA;EACA,WAAW;EACX;;UAGe;EACf;EACA,SAAS;;UAGM;EACf;EACA;EACA;;UAGe;EACf,IAAI;EACJ;EACA,MAAM;EACN;EACA;EACA,WAAW;;UAGI;EACf,UAAU;EACV,UAAU;EACV;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ;EACA;EACA,SAAS;EACT,YAAY;EACZ;EACA;EACA,WAAW;EACX;;UAGe;EACf,IAAI;EACJ;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;;UAGe;EACf,IAAI;EACJ;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,QAAQ;EACR,QAAQ;EACR;EACA;;UAGe;EACf,OAAO;EACP,OAAO;;UAGQ;EACf;EACA;EACA,SAAS;EACT,OAAO;EACP,OAAO;;UAGQ;EACf,MAAM;;;;;;;EAON;;EAEA;;;;;;;;EAQA;EACA;EACA;EACA;;UAGe;EACf;EAUA;EACA;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ,OAAO;EACP;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf;EACA;;UAGe;EACf,QAAQ;EACR;;;;;;;;;;cAWW;KAWD,6BAA6B;UAExB;EACf;EACA,MAAM;EACN;EACA;EACA;EACA,WAAW;;;KAID;;;;;;;;;UAUK;EACf,MAAM;EACN;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf;;EAEA;;EAEA,iBAAiB;;EAEjB;;EAEA,aAAa;;;;;;EAMb;EACA;;;;;;;;;UAUe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;UAYe;;EAEf;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;;;UAWe;EACf;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;;;EAKA,eAAe;;EAEf;EACA,QAAQ;EACR,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA;EACA;EACA,WAAW"}
1
+ {"version":3,"file":"types-BOfmvDe-.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ;EACA;EACA;EACA;EACA;EACA,UAAU;;EAEV;;EAEA;EACA,WAAW;EACX;;UAGe;EACf;EACA,SAAS;;UAGM;EACf;EACA;EACA;;UAGe;EACf,IAAI;EACJ;EACA,MAAM;EACN;EACA;EACA,WAAW;;UAGI;EACf,UAAU;EACV,UAAU;EACV;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ;EACA;EACA,SAAS;EACT,YAAY;EACZ;EACA;EACA,WAAW;EACX;;UAGe;EACf,IAAI;EACJ;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;;UAGe;EACf,IAAI;EACJ;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,QAAQ;EACR,QAAQ;EACR;EACA;;UAGe;EACf,OAAO;EACP,OAAO;;UAGQ;EACf;EACA;EACA,SAAS;EACT,OAAO;EACP,OAAO;;UAGQ;EACf,MAAM;;;;;;;EAON;;EAEA;;;;;;;;EAQA;EACA;EACA;EACA;;UAGe;EACf;EAUA;EACA;EACA;EACA,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ,OAAO;EACP;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf;EACA;;UAGe;EACf,QAAQ;EACR;;;;;;;;;;cAWW;KAWD,6BAA6B;UAExB;EACf;EACA,MAAM;EACN;EACA;EACA;EACA,WAAW;;;KAID;;;;;;;;;UAUK;EACf,MAAM;EACN;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf;;EAEA;;EAEA,iBAAiB;;EAEjB;;EAEA,aAAa;;;;;;EAMb;EACA;;;;;;;;;UAUe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;;EAEf,UAAU;;EAEV;;EAEA;;;;;;;;;;;UAYe;;EAEf;EACA;EACA;;EAEA,UAAU;EACV;;EAEA;;EAEA;EACA;;;;;;;;;;UAWe;;EAEf;EACA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;;;EAKA,eAAe;;EAEf,mBAAmB;EACnB,QAAQ;EACR,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA;EACA;EACA,WAAW"}
@@ -1,4 +1,4 @@
1
- import { d as KnowledgeGraphNode, l as KnowledgeGraph, u as KnowledgeGraphEdge } from "../types-Cd57BPRt.js";
1
+ import { d as KnowledgeGraphNode, l as KnowledgeGraph, u as KnowledgeGraphEdge } from "../types-BOfmvDe-.js";
2
2
  //#region src/viz/index.d.ts
3
3
  interface KnowledgeVizNode extends KnowledgeGraphNode {
4
4
  degree: number;
@@ -38,24 +38,28 @@ When that string is the canonical `<root>/.agent-knowledge` directory, both form
38
38
  | --- | --- |
39
39
  | `.agent-knowledge/index.json` | the built knowledge index (`writeKnowledgeIndex` writes it through this store) |
40
40
  | `.agent-knowledge/events.json` | the knowledge event log, including one `research.iteration` per research-loop round |
41
- | `.agent-knowledge/claim-ledgers/<id>.json` | one research run's claim ledger — corroboration counts, contradiction edges, open deep questions |
41
+ | `.agent-knowledge/claim-ledgers/<id>.json` | one research run's claim ledger: corroboration counts, contradiction edges, open deep questions |
42
42
  | `.agent-knowledge/sources.json` | the immutable source registry |
43
43
  | `.agent-knowledge/mutation.lock.durable`, `mutation-epoch.json`, `file-transactions/` | the cross-process mutation lock and its crash-recovery state |
44
44
 
45
45
  The root is also the directory `withKnowledgeMutation` locks, so every record above is written under one lock and one epoch.
46
46
  There is exactly one writer per file: a second index writer alongside this one is a defect, not a variation.
47
47
 
48
- A claim ledger is the one record several writers legitimately share — a resumed run beside a live one, or several workers researching one goal in parallel.
48
+ A claim ledger is the one record several writers legitimately share, such as a resumed run beside a live one or several workers researching one goal in parallel.
49
49
  They reach it through `mergeClaimLedger(id, merge)`, which holds the mutation lock across the read, the merge, and the write, so no writer can build its record from a value another writer has already replaced.
50
50
  `putClaimLedger` writes the whole record and is correct only for a single writer.
51
- The combining rule is `mergeClaimLedgers`: support and contradiction edges union, `contested` and `addressed` latch on, `firstSeenRound` moves earlier, and every collection is sorted — so the merge is commutative, associative, and idempotent, and the bytes on disk depend on the evidence rather than on scheduling.
51
+ The combining rule is `mergeClaimLedgers`: support and contradiction edges union, `contested` and `addressed` latch on, `firstSeenRound` moves earlier, and every collection is sorted.
52
+ The merge is commutative, associative, and idempotent, so the bytes on disk depend on the evidence rather than on scheduling.
52
53
  Ledgers for two different goals refuse to merge (`ClaimLedgerGoalConflictError`) rather than pooling unrelated evidence into one corroboration count.
53
54
  The live driver exposes the published Set-based `TrackedClaim`; the ledger stores a separate `ResearchClaimRecord` with sorted arrays so JSON serialization cannot erase those sets.
54
- Source verification first persists a `ResearchClaimEvidence` observation that cannot affect claim support or completion, then `runVerifiedResearchLoop` calls `commitSources` only after the source registry write succeeds.
55
- The ledger unions those observations with exact confirmed original source URIs and materializes only their intersection, so a crash on either side resumes safely without treating an absent source as evidence or losing a registered source's claim.
55
+ Source verification snapshots the proposal and persists a `ResearchClaimEvidence` observation containing the expected registry id, original URI, and full content hash; that observation cannot affect claim support or completion by itself.
56
+ After the exact submitted bytes are durable, `runVerifiedResearchLoop` passes the resulting `SourceRecord` to `commitSources`.
57
+ The ledger materializes only observations whose complete source identity matches a confirmed record, so reusing one URI for different bytes cannot activate the wrong claims and a crash on either side resumes safely.
58
+ Unversioned URI-only ledgers cannot prove which bytes produced their observations; reads and writes fail with `ClaimLedgerMigrationRequiredError` and preserve the original file for an explicit archive-and-reverify migration.
56
59
  Before synchronous question generation, the persistent driver records `preparedRounds`; a resume reconstructs and checkpoints any prepared round whose questions were interrupted, and the loop publishes its `research.iteration` event only after that checkpoint succeeds.
57
60
 
58
- Every write in this layer goes through `durable-fs` (`writeFileDurable`, `writeJsonDurableWithinRoot`) — temp file, fsync, atomic rename, fsync parent, through `O_NOFOLLOW` descriptors anchored via `/proc/self/fd` so a directory swapped for a symlink mid-write cannot redirect it outside the root.
61
+ Every write in this layer goes through `durable-fs` (`writeFileDurable`, `writeJsonDurableWithinRoot`): temp file, fsync, atomic rename, and parent fsync.
62
+ `O_NOFOLLOW` descriptors anchored through `/proc/self/fd` prevent a directory swapped for a symlink during a write from redirecting it outside the root.
59
63
  These are exported from the package entrypoint; consumers that keep their own journals should use them rather than reimplement them.
60
64
 
61
65
  ## Runtime Loop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-knowledge",
3
- "version": "6.2.0",
3
+ "version": "7.0.2",
4
4
  "description": "Build, search, evaluate, and improve source-backed knowledge bases.",
5
5
  "homepage": "https://github.com/tangle-network/agent-knowledge#readme",
6
6
  "repository": {
@@ -75,8 +75,8 @@
75
75
  "verify:official-optimizers": "node scripts/verify-official-optimizers.mjs"
76
76
  },
77
77
  "dependencies": {
78
- "@tangle-network/agent-eval": "0.135.2",
79
- "@tangle-network/agent-interface": "0.36.0",
78
+ "@tangle-network/agent-eval": "0.139.1",
79
+ "@tangle-network/agent-interface": "0.40.0",
80
80
  "proper-lockfile": "4.1.2",
81
81
  "zod": "^4.4.3"
82
82
  },