@tangle-network/agent-knowledge 8.0.7 → 8.0.9

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,3 +1,3 @@
1
- import { At as AgentMemoryScope, Bt as RetrievalHoldoutSessionState, Dt as AgentMemoryContext, Et as AgentMemoryBranchIsolation, Ft as RetrievalHoldoutCallContext, It as RetrievalHoldoutConfig, Lt as RetrievalHoldoutEligibleItem, Mt as AgentMemoryWriteInput, Nt as AgentMemoryWriteResult, Ot as AgentMemoryHit, Pt as RetrievalHoldoutBypassReason, Rt as RetrievalHoldoutEvent, St as acquireAgentMemoryRunLease, Tt as AgentMemoryAdapter, bt as AgentMemoryRunLease, jt as AgentMemorySearchOptions, kt as AgentMemoryKind, vt as AgentMemoryAcquireRunLease, xt as OwnedAgentMemoryRunLease, yt as AgentMemoryControllerMode, zt as RetrievalHoldoutResult } from "../index-CLNBGN_f.js";
2
- import { $ as runAgentMemoryLearningExperiment, A as AgentMemoryFinalPair, At as BuildAgentMemorySequencesFromBenchmarkCasesOptions, B as applySessionStickyRetrievalHoldout, Bt as AgentMemorySharingPolicy, C as runBoundedMemoryLifecycle, Ct as AgentMemorySequenceArtifact, D as AgentMemoryActivationDriver, Dt as AgentMemorySequenceStep, E as AgentMemoryActivation, Et as AgentMemorySequenceScenario, F as RunAgentMemoryImprovementResult, Ft as RunAgentMemoryLearningExperimentResult, G as toOffPolicyTrajectory, Gt as forkAgentMemoryBranchSnapshot, H as emitRetrievalHoldoutBypass, Ht as CreateAgentMemoryBranchOptions, I as RetrievalHoldoutOffPolicyOptions, It as AgentMemoryBranch, J as GraphitiToolNames, K as GraphitiMcpClientLike, Kt as defaultGetMemoryContext, L as RetrievalHoldoutOffPolicyResult, Lt as AgentMemoryBranchLifetime, M as AgentMemoryPromotionDecision, Mt as RunAgentMemoryExperimentOptions, N as MemoryConfigScenario, Nt as RunAgentMemoryExperimentResult, O as AgentMemoryDimensionComparison, Ot as AgentMemoryTransferCellComparison, P as RunAgentMemoryImprovementOptions, Pt as RunAgentMemoryLearningExperimentOptions, Q as compareAgentMemoryLearning, R as RetrievalHoldoutSessionSummary, Rt as AgentMemoryBranchSnapshot, S as resolveMemoryCleanupTimeoutMs, St as AgentMemorySequence, T as runAgentMemoryImprovement, Tt as AgentMemorySequenceProbeResult, U as resetRetrievalHoldoutRegistry, Ut as ForkAgentMemoryBranchSnapshotOptions, V as deterministicRng, Vt as AgentMemoryVisibility, W as retrievalHoldoutConfigHash, Wt as createAgentMemoryBranch, X as graphitiMemoryAdapterIdentity, Y as createGraphitiMemoryAdapter, Z as runAgentMemoryExperiment, _ as AgentMemoryLifecycleTimeoutError, _t as AgentMemoryLearningArmOrder, a as AgentMemoryScopeSchema, at as AgentMemoryExecutionContext, b as createMemoryExecutionPool, bt as AgentMemoryLearningComparison, c as createNeo4jAgentMemoryAdapter, ct as AgentMemoryExecutionPaidCallInput, d as Mem0HostedMemoryAdapterOptions, dt as AgentMemoryExperimentCandidate, et as agentMemorySequenceJudge, f as Mem0MemoryAdapterOptions, ft as AgentMemoryExperimentCandidateRef, g as mem0MemoryAdapterIdentity, gt as AgentMemoryForgettingComparison, h as createMem0MemoryAdapter, ht as AgentMemoryExperimentRunLease, i as AgentMemoryKindSchema, it as AgentMemoryEvidenceRef, j as AgentMemoryImprovementRunLease, jt as CompareAgentMemoryLearningOptions, k as AgentMemoryFinalEvaluation, kt as AgentMemoryTransferStepSummary, l as Mem0ClientMode, lt as AgentMemoryExecutionPaidCallResult, m as Mem0OssMemoryAdapterOptions, mt as AgentMemoryExperimentRankingRow, n as memoryWriteResultToSourceRecord, nt as buildAgentMemorySequencesFromBenchmarkCases, o as AgentMemoryWriteInputSchema, ot as AgentMemoryExecutionCostMeter, p as Mem0OssClient, pt as AgentMemoryExperimentComparisonRef, q as GraphitiMemoryAdapterOptions, qt as renderMemoryContext, r as AgentMemoryHitSchema, rt as AgentMemoryAttemptEvent, s as Neo4jAgentMemoryAdapterOptions, st as AgentMemoryExecutionCostReceipt, t as memoryHitToSourceRecord, tt as buildAgentMemorySequenceScenarios, u as Mem0HostedClient, ut as AgentMemoryExecutionStep, v as AgentMemoryLifecycleUnsafeError, vt as AgentMemoryLearningCandidateSummary, w as sleepForMemoryRecovery, wt as AgentMemorySequenceProbe, x as memoryRecoveryDelayMs, xt as AgentMemoryMode, y as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, yt as AgentMemoryLearningCellComparison, z as applyRetrievalHoldout, zt as AgentMemoryJournalEntry } from "../index-BPNsQVSx.js";
1
+ import { At as AgentMemoryScope, Bt as RetrievalHoldoutSessionState, Dt as AgentMemoryContext, Et as AgentMemoryBranchIsolation, Ft as RetrievalHoldoutCallContext, It as RetrievalHoldoutConfig, Lt as RetrievalHoldoutEligibleItem, Mt as AgentMemoryWriteInput, Nt as AgentMemoryWriteResult, Ot as AgentMemoryHit, Pt as RetrievalHoldoutBypassReason, Rt as RetrievalHoldoutEvent, St as acquireAgentMemoryRunLease, Tt as AgentMemoryAdapter, bt as AgentMemoryRunLease, jt as AgentMemorySearchOptions, kt as AgentMemoryKind, vt as AgentMemoryAcquireRunLease, xt as OwnedAgentMemoryRunLease, yt as AgentMemoryControllerMode, zt as RetrievalHoldoutResult } from "../index-DypNCZtP.js";
2
+ import { $ as runAgentMemoryLearningExperiment, A as AgentMemoryFinalPair, At as BuildAgentMemorySequencesFromBenchmarkCasesOptions, B as applySessionStickyRetrievalHoldout, Bt as AgentMemorySharingPolicy, C as runBoundedMemoryLifecycle, Ct as AgentMemorySequenceArtifact, D as AgentMemoryActivationDriver, Dt as AgentMemorySequenceStep, E as AgentMemoryActivation, Et as AgentMemorySequenceScenario, F as RunAgentMemoryImprovementResult, Ft as RunAgentMemoryLearningExperimentResult, G as toOffPolicyTrajectory, Gt as forkAgentMemoryBranchSnapshot, H as emitRetrievalHoldoutBypass, Ht as CreateAgentMemoryBranchOptions, I as RetrievalHoldoutOffPolicyOptions, It as AgentMemoryBranch, J as GraphitiToolNames, K as GraphitiMcpClientLike, Kt as defaultGetMemoryContext, L as RetrievalHoldoutOffPolicyResult, Lt as AgentMemoryBranchLifetime, M as AgentMemoryPromotionDecision, Mt as RunAgentMemoryExperimentOptions, N as MemoryConfigScenario, Nt as RunAgentMemoryExperimentResult, O as AgentMemoryDimensionComparison, Ot as AgentMemoryTransferCellComparison, P as RunAgentMemoryImprovementOptions, Pt as RunAgentMemoryLearningExperimentOptions, Q as compareAgentMemoryLearning, R as RetrievalHoldoutSessionSummary, Rt as AgentMemoryBranchSnapshot, S as resolveMemoryCleanupTimeoutMs, St as AgentMemorySequence, T as runAgentMemoryImprovement, Tt as AgentMemorySequenceProbeResult, U as resetRetrievalHoldoutRegistry, Ut as ForkAgentMemoryBranchSnapshotOptions, V as deterministicRng, Vt as AgentMemoryVisibility, W as retrievalHoldoutConfigHash, Wt as createAgentMemoryBranch, X as graphitiMemoryAdapterIdentity, Y as createGraphitiMemoryAdapter, Z as runAgentMemoryExperiment, _ as AgentMemoryLifecycleTimeoutError, _t as AgentMemoryLearningArmOrder, a as AgentMemoryScopeSchema, at as AgentMemoryExecutionContext, b as createMemoryExecutionPool, bt as AgentMemoryLearningComparison, c as createNeo4jAgentMemoryAdapter, ct as AgentMemoryExecutionPaidCallInput, d as Mem0HostedMemoryAdapterOptions, dt as AgentMemoryExperimentCandidate, et as agentMemorySequenceJudge, f as Mem0MemoryAdapterOptions, ft as AgentMemoryExperimentCandidateRef, g as mem0MemoryAdapterIdentity, gt as AgentMemoryForgettingComparison, h as createMem0MemoryAdapter, ht as AgentMemoryExperimentRunLease, i as AgentMemoryKindSchema, it as AgentMemoryEvidenceRef, j as AgentMemoryImprovementRunLease, jt as CompareAgentMemoryLearningOptions, k as AgentMemoryFinalEvaluation, kt as AgentMemoryTransferStepSummary, l as Mem0ClientMode, lt as AgentMemoryExecutionPaidCallResult, m as Mem0OssMemoryAdapterOptions, mt as AgentMemoryExperimentRankingRow, n as memoryWriteResultToSourceRecord, nt as buildAgentMemorySequencesFromBenchmarkCases, o as AgentMemoryWriteInputSchema, ot as AgentMemoryExecutionCostMeter, p as Mem0OssClient, pt as AgentMemoryExperimentComparisonRef, q as GraphitiMemoryAdapterOptions, qt as renderMemoryContext, r as AgentMemoryHitSchema, rt as AgentMemoryAttemptEvent, s as Neo4jAgentMemoryAdapterOptions, st as AgentMemoryExecutionCostReceipt, t as memoryHitToSourceRecord, tt as buildAgentMemorySequenceScenarios, u as Mem0HostedClient, ut as AgentMemoryExecutionStep, v as AgentMemoryLifecycleUnsafeError, vt as AgentMemoryLearningCandidateSummary, w as sleepForMemoryRecovery, wt as AgentMemorySequenceProbe, x as memoryRecoveryDelayMs, xt as AgentMemoryMode, y as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, yt as AgentMemoryLearningCellComparison, z as applyRetrievalHoldout, zt as AgentMemoryJournalEntry } from "../index-Ij4giqqj.js";
3
3
  export { AgentMemoryAcquireRunLease, type AgentMemoryActivation, type AgentMemoryActivationDriver, AgentMemoryAdapter, type AgentMemoryAttemptEvent, AgentMemoryBranch, AgentMemoryBranchIsolation, AgentMemoryBranchLifetime, AgentMemoryBranchSnapshot, AgentMemoryContext, AgentMemoryControllerMode, type AgentMemoryDimensionComparison, type AgentMemoryEvidenceRef, type AgentMemoryExecutionContext, type AgentMemoryExecutionCostMeter, type AgentMemoryExecutionCostReceipt, type AgentMemoryExecutionPaidCallInput, type AgentMemoryExecutionPaidCallResult, type AgentMemoryExecutionStep, type AgentMemoryExperimentCandidate, type AgentMemoryExperimentCandidateRef, type AgentMemoryExperimentComparisonRef, type AgentMemoryExperimentRankingRow, type AgentMemoryExperimentRunLease, type AgentMemoryFinalEvaluation, type AgentMemoryFinalPair, type AgentMemoryForgettingComparison, AgentMemoryHit, AgentMemoryHitSchema, type AgentMemoryImprovementRunLease, AgentMemoryJournalEntry, AgentMemoryKind, AgentMemoryKindSchema, type AgentMemoryLearningArmOrder, type AgentMemoryLearningCandidateSummary, type AgentMemoryLearningCellComparison, type AgentMemoryLearningComparison, AgentMemoryLifecycleTimeoutError, AgentMemoryLifecycleUnsafeError, type AgentMemoryMode, type AgentMemoryPromotionDecision, AgentMemoryRunLease, AgentMemoryScope, AgentMemoryScopeSchema, AgentMemorySearchOptions, type AgentMemorySequence, type AgentMemorySequenceArtifact, type AgentMemorySequenceProbe, type AgentMemorySequenceProbeResult, type AgentMemorySequenceScenario, type AgentMemorySequenceStep, AgentMemorySharingPolicy, type AgentMemoryTransferCellComparison, type AgentMemoryTransferStepSummary, AgentMemoryVisibility, AgentMemoryWriteInput, AgentMemoryWriteInputSchema, AgentMemoryWriteResult, type BuildAgentMemorySequencesFromBenchmarkCasesOptions, type CompareAgentMemoryLearningOptions, CreateAgentMemoryBranchOptions, DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, ForkAgentMemoryBranchSnapshotOptions, GraphitiMcpClientLike, GraphitiMemoryAdapterOptions, GraphitiToolNames, Mem0ClientMode, Mem0HostedClient, Mem0HostedMemoryAdapterOptions, Mem0MemoryAdapterOptions, Mem0OssClient, Mem0OssMemoryAdapterOptions, type MemoryConfigScenario, Neo4jAgentMemoryAdapterOptions, OwnedAgentMemoryRunLease, RetrievalHoldoutBypassReason, RetrievalHoldoutCallContext, RetrievalHoldoutConfig, RetrievalHoldoutEligibleItem, RetrievalHoldoutEvent, RetrievalHoldoutOffPolicyOptions, RetrievalHoldoutOffPolicyResult, RetrievalHoldoutResult, RetrievalHoldoutSessionState, RetrievalHoldoutSessionSummary, type RunAgentMemoryExperimentOptions, type RunAgentMemoryExperimentResult, type RunAgentMemoryImprovementOptions, type RunAgentMemoryImprovementResult, type RunAgentMemoryLearningExperimentOptions, type RunAgentMemoryLearningExperimentResult, acquireAgentMemoryRunLease, agentMemorySequenceJudge, applyRetrievalHoldout, applySessionStickyRetrievalHoldout, buildAgentMemorySequenceScenarios, buildAgentMemorySequencesFromBenchmarkCases, compareAgentMemoryLearning, createAgentMemoryBranch, createGraphitiMemoryAdapter, createMem0MemoryAdapter, createMemoryExecutionPool, createNeo4jAgentMemoryAdapter, defaultGetMemoryContext, deterministicRng, emitRetrievalHoldoutBypass, forkAgentMemoryBranchSnapshot, graphitiMemoryAdapterIdentity, mem0MemoryAdapterIdentity, memoryHitToSourceRecord, memoryRecoveryDelayMs, memoryWriteResultToSourceRecord, renderMemoryContext, resetRetrievalHoldoutRegistry, resolveMemoryCleanupTimeoutMs, retrievalHoldoutConfigHash, runAgentMemoryExperiment, runAgentMemoryImprovement, runAgentMemoryLearningExperiment, runBoundedMemoryLifecycle, sleepForMemoryRecovery, toOffPolicyTrajectory };
@@ -87,6 +87,8 @@ interface KnowledgePage {
87
87
  sourceIds: string[];
88
88
  tags: string[];
89
89
  outLinks: string[];
90
+ /** Stable page ids this page explicitly builds on. */
91
+ cites?: KnowledgeId[];
90
92
  /** Page ids this page explicitly refutes. */
91
93
  contradicts?: KnowledgeId[];
92
94
  /** Present only when this page's own evidence has refuted the page. */
@@ -142,7 +144,7 @@ interface KnowledgeSearchResult {
142
144
  reasons: string[];
143
145
  }
144
146
  interface KnowledgeLintFinding {
145
- type: 'broken-link' | 'orphan' | 'no-outlinks' | 'uncited-claim' | 'missing-source' | 'duplicate-title' | 'duplicate-page-id' | 'duplicate-source-hash' | 'missing-frontmatter' | 'ungradeable-evidence' | 'missing-evidence-path' | 'nonportable-evidence' | 'broken-contradiction' | 'invalid-invalidation';
147
+ type: 'broken-link' | 'broken-citation' | 'ambiguous-citation' | 'orphan' | 'no-outlinks' | 'uncited-claim' | 'missing-source' | 'duplicate-title' | 'duplicate-page-id' | 'duplicate-source-hash' | 'missing-frontmatter' | 'ungradeable-evidence' | 'missing-evidence-path' | 'nonportable-evidence' | 'broken-contradiction' | 'invalid-invalidation';
146
148
  severity: 'info' | 'warning' | 'error';
147
149
  page?: string;
148
150
  message: string;
@@ -323,4 +325,4 @@ interface KnowledgeRelease {
323
325
  }
324
326
  //#endregion
325
327
  export { SourceRegistry as A, KnowledgeWriteParseResult as C, ResearchSourceVersion as D, ResearchClaimRecord as E, SourceAnchor as O, KnowledgeWriteBlock as S, ResearchClaimLedger as T, KnowledgePolicy as _, KnowledgeBaseCandidate as a, KnowledgeSearchResult as b, KnowledgeEventType as c, KnowledgeGraphNode as d, KnowledgeId as f, KnowledgePageInvalidation as g, KnowledgePage as h, KNOWLEDGE_EVENT_TYPES as i, TrackedClaim as j, SourceRecord 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, KnowledgeRelation as v, ResearchClaimEvidence as w, KnowledgeUnit as x, KnowledgeRelease as y };
326
- //# sourceMappingURL=types-CXZS0w00.d.ts.map
328
+ //# sourceMappingURL=types-CTT16XnO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CTT16XnO.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;;;;;;;;;;UAWe;EACf;EACA;EACA;EACA;EACA;EACA,WAAW;;UAGI;EACf,IAAI;EACJ;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;;EAEA,QAAQ;;EAER,cAAc;;EAEd,eAAe;;UAGA;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;EAiBA;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-CXZS0w00.js";
1
+ import { d as KnowledgeGraphNode, l as KnowledgeGraph, u as KnowledgeGraphEdge } from "../types-CTT16XnO.js";
2
2
  //#region src/viz/index.d.ts
3
3
  interface KnowledgeVizNode extends KnowledgeGraphNode {
4
4
  degree: number;
@@ -0,0 +1,182 @@
1
+ # Knowledge retrieval and use receipts
2
+
3
+ A knowledge page appearing in a prompt, a final answer resembling a prior result, and a citation in a generated document are three different facts. None of them alone proves that a particular agent retrieved a particular page and used it in a downstream decision.
4
+
5
+ This module records two immutable links:
6
+
7
+ ```text
8
+ exact visible knowledge snapshot
9
+ ↓
10
+ retrieval receipt
11
+ ↓
12
+ selected returned result
13
+ ↓
14
+ knowledge-use receipt
15
+ ↓
16
+ decision / artifact / experiment / candidate / message
17
+ ```
18
+
19
+ The receipts establish provenance. They do not decide whether using the knowledge was wise, whether the downstream result is correct, or whether it is novel. Those are Eval questions over the retained evidence.
20
+
21
+ ## Visibility snapshot
22
+
23
+ `createKnowledgeVisibilitySnapshot()` binds the ordered set of pages visible to one retrieval operation. Every entry records:
24
+
25
+ - position;
26
+ - stable page id;
27
+ - origin (`here`, `inherited:<runId>`, or `shared`);
28
+ - path;
29
+ - canonical page digest;
30
+ - source ids;
31
+ - whether the page was invalidated.
32
+
33
+ Order is identity-bearing because retrieval algorithms may use order as a tie break or candidate window. Page text, frontmatter, citations, contradictions, invalidation state, path, and source joins are included in each page digest.
34
+
35
+ ```ts
36
+ import { createKnowledgeVisibilitySnapshot } from '@tangle-network/agent-knowledge'
37
+
38
+ const visibility = createKnowledgeVisibilitySnapshot(await stores.loadChain(runId))
39
+ console.log(visibility.snapshotDigest)
40
+ ```
41
+
42
+ A repeated path at the same origin is refused. The same stable page id may remain visible at different origins; ambiguity-safe citation resolution is handled separately.
43
+
44
+ ## Retrieval receipt
45
+
46
+ `createKnowledgeRetrievalReceipt()` binds:
47
+
48
+ - run id;
49
+ - optional actor, profile, and execution identities;
50
+ - exact query;
51
+ - retriever id, version, and configuration digest;
52
+ - the complete visibility snapshot;
53
+ - every ranked returned page, origin, path, digest, score, snippet, and reason;
54
+ - trace or artifact evidence references;
55
+ - bounded scalar attributes;
56
+ - creation timestamp.
57
+
58
+ A result is accepted only when its exact page bytes, path, id, and origin occur in the visibility snapshot. Ranks must be unique and contiguous from one. Scores must be finite, and normalized scores must lie in `[0, 1]`.
59
+
60
+ ```ts
61
+ import { canonicalCandidateDigest } from '@tangle-network/agent-interface'
62
+ import { createKnowledgeRetrievalReceipt } from '@tangle-network/agent-knowledge'
63
+
64
+ const receipt = createKnowledgeRetrievalReceipt({
65
+ runId,
66
+ actorId: 'root:s0',
67
+ profileDigest,
68
+ executionRef,
69
+ query: 'prior obstruction calibrated verifier',
70
+ retriever: {
71
+ id: 'inspectable-token-overlap',
72
+ version: '1.0.0',
73
+ configDigest: canonicalCandidateDigest({ tokenizer: 'unicode-words', limit: 5 }),
74
+ },
75
+ visiblePages,
76
+ results,
77
+ evidenceRefs: [{ kind: 'event', uri: `event://${runId}/retrieval-1` }],
78
+ })
79
+ ```
80
+
81
+ `verifyKnowledgeRetrievalReceipt()` recomputes the visibility and receipt digests and checks every result-to-visibility join. `assertKnowledgeRetrievalMatchesVisibility()` additionally proves that the receipt still describes a supplied page snapshot; a later page mutation fails this check.
82
+
83
+ ## Use receipt
84
+
85
+ `createKnowledgeUseReceipt()` selects one exact rank returned by a verified retrieval and binds it to a downstream consumer:
86
+
87
+ ```ts
88
+ const use = createKnowledgeUseReceipt({
89
+ retrieval: receipt,
90
+ selectedRank: 1,
91
+ relation: 'extends',
92
+ consumer: {
93
+ kind: 'artifact',
94
+ uri: `artifact://${runId}/DECISION.md`,
95
+ digest: decisionArtifactDigest,
96
+ },
97
+ evidenceRefs: [{ kind: 'span', uri: `trace://${runId}/span/knowledge-use-1` }],
98
+ })
99
+ ```
100
+
101
+ Relations are descriptive:
102
+
103
+ - `supports`
104
+ - `contradicts`
105
+ - `extends`
106
+ - `rederives`
107
+ - `background`
108
+
109
+ Consumer kinds are:
110
+
111
+ - `decision`
112
+ - `artifact`
113
+ - `experiment`
114
+ - `candidate`
115
+ - `message`
116
+ - `other`
117
+
118
+ The use receipt copies the selected result's rank, page id, origin, path, and digest. It references the retrieval receipt digest. `verifyKnowledgeUseReceipt()` refuses verification against a different retrieval, a result that was not returned, a changed selected page, or any mutation of the relation or consumer identity.
119
+
120
+ ## Canonical serialization
121
+
122
+ Optional actor, profile, execution, consumer-digest, and evidence-excerpt fields are omitted when absent. They are never emitted with a JavaScript `undefined` value. Empty evidence and attribute collections remain explicit empty arrays or objects because they are part of the receipt contract.
123
+
124
+ Attribute values are deliberately limited to strings, finite numbers, booleans, and `null`. Nested arbitrary objects are refused rather than passed through a language-specific serializer. More structured evidence belongs in an artifact or a versioned contract referenced by digest.
125
+
126
+ The receipt digest covers the complete canonical material except the digest field itself. A verifier recomputes both the visibility snapshot digest and the outer receipt digest; copying a digest onto modified content does not verify.
127
+
128
+ ## What a receipt proves
129
+
130
+ A valid retrieval receipt proves:
131
+
132
+ > Under this exact run/actor/profile/execution identity, this exact retriever configuration searched this exact ordered knowledge snapshot with this exact query and returned these exact ranked page versions.
133
+
134
+ A valid use receipt additionally proves:
135
+
136
+ > The consumer selected this exact returned page version and declared this exact relation while producing this exact downstream consumer identity.
137
+
138
+ It does **not** prove:
139
+
140
+ - that the page's claim is true;
141
+ - that the declared relation is semantically correct;
142
+ - that the consumer complied with the page;
143
+ - that the downstream artifact passed its verifier;
144
+ - that the result is novel rather than a re-derivation;
145
+ - that knowledge improved the outcome.
146
+
147
+ Those claims require Eval findings, artifact checks, paired experiments, novelty/reuse adjudication, and downstream outcome evidence.
148
+
149
+ ## Trace integration
150
+
151
+ Both receipts accept canonical Eval `EvidenceRef` values. A Runtime or product adapter should emit a trace event/span containing the receipt digest and retain the receipt itself as an artifact or durable record. The trace is an index into the receipt; it is not a second copy of its truth.
152
+
153
+ Recommended event attributes:
154
+
155
+ ```text
156
+ knowledge.receipt.kind
157
+ knowledge.receipt.digest
158
+ knowledge.visibility.digest
159
+ knowledge.retriever.id
160
+ knowledge.retriever.version
161
+ knowledge.result.count
162
+ knowledge.used.page_id
163
+ knowledge.used.origin
164
+ knowledge.consumer.kind
165
+ knowledge.consumer.uri
166
+ knowledge.relation
167
+ ```
168
+
169
+ Do not encode absent token, cost, model, status, or artifact state as zero or success while attaching these receipts. Knowledge provenance cannot repair incomplete execution evidence.
170
+
171
+ ## Experiment use
172
+
173
+ For a knowledge-compounding comparison, record separately:
174
+
175
+ 1. knowledge available to the arm;
176
+ 2. knowledge retrieved;
177
+ 3. knowledge selected for use;
178
+ 4. the downstream decision or artifact;
179
+ 5. the verifier outcome;
180
+ 6. whether the contribution duplicated, verified, extended, corrected, newly applied, or independently discovered the prior result.
181
+
182
+ This separation prevents final-prose similarity or citation count from masquerading as causal evidence that accumulated knowledge improved research.
@@ -0,0 +1,106 @@
1
+ # Run-scoped citations
2
+
3
+ A run-scoped knowledge chain contains three visibility classes:
4
+
5
+ 1. pages written by the current run (`here`);
6
+ 2. pages written by declared ancestors (`inherited:<runId>`);
7
+ 3. pages in an optional curated shared store (`shared`).
8
+
9
+ `createRunScopedStores()` preserves every visible page and its origin. It does not shadow a page merely because a nearer store has the same stable id.
10
+
11
+ ## Persisted citation form
12
+
13
+ A page records stable page references in `cites` frontmatter:
14
+
15
+ ```yaml
16
+ ---
17
+ id: later-result
18
+ cites:
19
+ - prior-result
20
+ ---
21
+ ```
22
+
23
+ An unqualified id is valid only when exactly one visible page has that id. When duplicate ids are intentional, qualify the origin:
24
+
25
+ ```yaml
26
+ cites:
27
+ - here::current-result
28
+ - inherited:run-2026-08-16::prior-result
29
+ - shared::instrument-calibration
30
+ ```
31
+
32
+ Use `parseKnowledgeCitationReference()` and `formatKnowledgeCitationReference()` rather than assembling qualified strings in application code.
33
+
34
+ ## Resolution
35
+
36
+ ```ts
37
+ import {
38
+ assertCurrentRunCitationsResolved,
39
+ createRunScopedStores,
40
+ resolveRunScopedCitation,
41
+ } from '@tangle-network/agent-knowledge'
42
+
43
+ const stores = createRunScopedStores({
44
+ root: './runs',
45
+ sharedRoot: './curated-knowledge',
46
+ })
47
+
48
+ const resolved = await resolveRunScopedCitation(stores, 'run-b', {
49
+ pageId: 'prior-result',
50
+ })
51
+
52
+ if (resolved.status !== 'resolved') {
53
+ console.error(resolved.status, resolved.candidates)
54
+ }
55
+
56
+ await assertCurrentRunCitationsResolved(stores, 'run-b')
57
+ ```
58
+
59
+ Resolution has three non-coercing outcomes:
60
+
61
+ - `resolved`: exactly one visible page matches;
62
+ - `missing`: no visible page matches;
63
+ - `ambiguous`: more than one visible page matches.
64
+
65
+ Missing and ambiguous references remain explicit. They never select the nearest page, the newest page, or the shared page by default.
66
+
67
+ ## Product-owned lineage
68
+
69
+ A product that already owns run ancestry should provide a `RunLineageAuthority` rather than copying its manifest into `lineage.json`:
70
+
71
+ ```ts
72
+ const stores = createRunScopedStores({
73
+ root: './runs',
74
+ runStorePath: (runId) => `./runs/${runId}/knowledge-base`,
75
+ sharedRoot: './curated-knowledge',
76
+ lineageAuthority: {
77
+ async parentOf(runId) {
78
+ const manifest = await readRunManifest(runId)
79
+ return manifest.parentRunId
80
+ },
81
+ },
82
+ })
83
+ ```
84
+
85
+ A read-only authority must already contain the lineage before `init()` is called. `init()` verifies the requested parent against that authority and fails on disagreement. An authority that also implements `record()` may durably create the lineage itself.
86
+
87
+ The default file-backed authority is idempotent. Reopening a run with the same parent is accepted; reopening it with another parent is a lineage conflict.
88
+
89
+ ## Lint and graph behavior
90
+
91
+ `auditCurrentRunCitations()` checks current-run pages against one materialized visibility chain. `lintCurrentRunCitations()` converts missing, ambiguous, and self-citations into blocking package lint findings.
92
+
93
+ Within one knowledge index, unambiguous `cites` relations become graph edges with reason `citation`. Duplicate target ids do not produce a guessed edge; the relation remains unresolved until it is qualified or the duplicate is removed.
94
+
95
+ ## Migration rule
96
+
97
+ For an existing application-owned store:
98
+
99
+ 1. freeze the old reader and writer behavior with golden fixtures;
100
+ 2. expose the existing run manifest as a `RunLineageAuthority`;
101
+ 3. dual-read the same frozen corpus through both implementations;
102
+ 4. classify every mismatch without coercion;
103
+ 5. switch new reads and writes only after parity is demonstrated;
104
+ 6. retain historical bytes and delete the duplicate live owner.
105
+
106
+ A migration is not complete while two implementations can independently write lineage, page identities, or citation relations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-knowledge",
3
- "version": "8.0.7",
3
+ "version": "8.0.9",
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": {
@@ -71,31 +71,36 @@
71
71
  "lint": "biome check src tests",
72
72
  "format": "biome format --write src tests",
73
73
  "check:skills": "node scripts/check-skills.mjs",
74
- "verify:package": "pnpm run check:skills && publint && attw --pack --profile esm-only . && node scripts/verify-package.mjs",
75
- "verify:official-optimizers": "node scripts/verify-official-optimizers.mjs"
74
+ "verify:package": "pnpm run check:version-bump && pnpm run check:skills && pnpm run check:api-surface && publint && attw --pack --profile esm-only . && node scripts/verify-package.mjs",
75
+ "verify:official-optimizers": "node scripts/verify-official-optimizers.mjs",
76
+ "check:version-bump": "node scripts/check-version-bump.mjs",
77
+ "check:api-surface": "node scripts/check-api-surface.mjs",
78
+ "api:surface": "node scripts/check-api-surface.mjs --write"
76
79
  },
77
80
  "dependencies": {
81
+ "@types/proper-lockfile": "4.1.4",
78
82
  "proper-lockfile": "4.1.2",
79
83
  "zod": "^4.4.3"
80
84
  },
81
85
  "peerDependencies": {
82
- "@tangle-network/agent-eval": ">=0.147.0 <0.148.0",
83
- "@tangle-network/agent-interface": "^1.0.0"
86
+ "@tangle-network/agent-eval": ">=0.148.0 <0.149.0",
87
+ "@tangle-network/agent-interface": "^1.1.0"
84
88
  },
85
89
  "devDependencies": {
86
90
  "@arethetypeswrong/cli": "^0.18.5",
87
91
  "@biomejs/biome": "^2.5.5",
88
92
  "@neo4j-labs/agent-memory": "0.4.1",
89
- "@tangle-network/agent-eval": "0.147.0",
90
- "@tangle-network/agent-interface": "1.0.0",
93
+ "@tangle-network/agent-eval": "0.148.0",
94
+ "@tangle-network/agent-interface": "1.1.0",
91
95
  "@types/node": "^26.1.1",
92
- "@types/proper-lockfile": "4.1.4",
93
96
  "mem0ai": "3.1.2",
97
+ "oxc-parser": "0.144.0",
94
98
  "publint": "^0.3.22",
95
99
  "tsdown": "^0.22.14",
96
100
  "typescript": "^7.0.2",
97
101
  "vite": "8.1.5",
98
- "vitest": "^4.1.10"
102
+ "vitest": "^4.1.10",
103
+ "yaml": "2.9.0"
99
104
  },
100
105
  "pnpm": {
101
106
  "ignoredBuiltDependencies": [