@tangleai/memory 0.20.1 → 0.24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # @tangleai/memory
2
2
 
3
+ ## 0.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @tangleai/context@0.24.1
8
+ - @tangleai/core@0.24.1
9
+
10
+ ## 0.24.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Add the outcomes package for independently evidenced decisions, deterministic scoring, atomic confidence projection, bounded artifact refinement and explicitly approved promotion and rollback. The public operation contract, two-domain adapter kit and keyless example share the same scoped request receipts, one-use held-out gates, full head revision checks and interruption recovery.
15
+
16
+ The store adapter owns outcome records and memory changes in one SQLite transaction. The new pure confidence helper preserves fact fields; existing applyOutcome calls retain their original duplicate-citation and timestamp behavior and do not acquire a durable replay guarantee. No existing persisted memory format changes. Hosts opt into the new lifecycle, provide evidence and approval authority, and use a new artifact key for schema or policy changes. Scripted paired measurements and Node/Bun packed consumers qualify the mechanism; downstream domain integrations and automatic promotion remain separate work.
17
+
18
+ ### Patch Changes
19
+
20
+ - @tangleai/context@0.24.0
21
+ - @tangleai/core@0.24.0
22
+
23
+ ## 0.23.0
24
+
25
+ ### Minor Changes
26
+
27
+ - Derive memory defaults from a registered held-out policy experiment and expose their values, evidence provenance and measured opt-ins through a public contract. Novelty filtering, contradiction resolution and crystallization now default to off; memory retrieval defaults to k 10 and minScore 0, and the independently measured offline hash width is 512.
28
+
29
+ Explicit policy overrides retain their meaning. Use the shipped-legacy policy data with a 64-dimensional hash embedder to reproduce the former settings; existing vectors retain their original embedding identity and require re-embedding to rank with the new offline default. Preserve the full live evidence, bounded-null decision and historical losses, enforce purchase and identity boundaries, and gate generated defaults, public contract compatibility, examples and documentation.
30
+
31
+ ### Patch Changes
32
+
33
+ - @tangleai/context@0.23.0
34
+ - @tangleai/core@0.23.0
35
+
36
+ ## 0.22.0
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies
41
+ - @tangleai/context@0.22.0
42
+ - @tangleai/core@0.22.0
43
+
44
+ ## 0.21.1
45
+
46
+ ### Patch Changes
47
+
48
+ - Update the exact Jaren foundation dependencies and source pin to the published
49
+ 0.84.3 release after verifying its AI-free archives against source-built bytes.
50
+ Retain Tangle's model, context and agent ownership and align the development
51
+ Node pin with 24.20.0. Tangle publication remains a manual author action.
52
+ Allow release preparation after an already committed local release while
53
+ preserving its record and rejecting unprepared version edits.
54
+ - Updated dependencies
55
+ - @tangleai/context@0.21.1
56
+ - @tangleai/core@0.21.1
57
+
58
+ ## 0.21.0
59
+
60
+ ### Minor Changes
61
+
62
+ - Use the models, context and agents owners of the inherited AI mechanisms. MAS
63
+ executable identity version 3 names all executed mechanism versions; an old
64
+ executable checkpoint is refused intact through the existing mismatch path.
65
+ Memory and ledger records retain their schemas and projection contracts.
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies
70
+ - Updated dependencies
71
+ - Updated dependencies
72
+ - @tangleai/core@0.21.0
73
+ - @tangleai/context@0.21.0
74
+
3
75
  ## 0.20.1
4
76
 
5
77
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,68 @@
1
1
  # @tangleai/memory
2
2
 
3
- Tangle AI memory policies novelty gating, crystallization, contradiction resolution, outcome learning over an injected store
3
+ Evidenced memory storage, ingest policies, retrieval and outcome learning over an injected store.
4
4
 
5
- Install with `npm install @tangleai/memory`. The npm distribution provides ESM JavaScript, TypeScript declarations, and the documented package subpaths for Node 24 and Bun 1.4 or newer.
5
+ Install with `npm install @tangleai/memory`. The distribution provides ESM JavaScript, TypeScript declarations and public subpaths for Node 24 and Bun 1.4 or newer.
6
6
 
7
- See the [Tangle documentation](https://github.com/jklarenbeek/tangleai#readme) for architecture, examples, and runtime requirements. All public Tangle packages use one coordinated version.
7
+ The selected default disables novelty filtering, contradiction resolution and crystallization (each lowers to threshold 2). Memory retrieval uses k = 10 and minScore = 0. The pipeline's offline embedder is `hash-trigram-512`; its width was selected by lexical evidence recall independently of the live answer experiment. Explicit thresholds and retrieval overrides retain their meaning. Existing vectors keep their model/dimension identity and must be re-embedded before they can rank against a different embedder.
8
+
9
+ ```ts
10
+ import {
11
+ DEFAULT_MEMORY_POLICY, POLICY_PROVENANCE, policyThresholds,
12
+ MEASURED_MEMORY_POLICIES, SHIPPED_LEGACY_POLICY, SHIPPED_LEGACY_CELL_ID,
13
+ } from '@tangleai/memory/policy';
14
+
15
+ const thresholds = policyThresholds(); // selected default: all three thresholds are 2
16
+ console.log(DEFAULT_MEMORY_POLICY.retrieval); // { k: 10, minScore: 0 }
17
+ console.log(POLICY_PROVENANCE.reportId); // exact source report for the decision
18
+ ```
19
+
20
+ `MEASURED_MEMORY_POLICIES[cellId]` contains measured alternatives with their original effective values and labels. `SHIPPED_LEGACY_POLICY` aliases the historical shipped cell (novelty 0.97, contradiction 0.8, crystallization 0.9, maxPairs 20, k 10, minScore 0, hash width 64). This is opt-in data, not a recommended provider profile. To reproduce its pipeline settings:
21
+
22
+ ```ts
23
+ import { createMemoryUnitStore } from '@tangleai/memory';
24
+ import { createPipeline } from '@tangleai/pipeline';
25
+ import { createHashEmbedder } from '@tangleai/models/embed';
26
+
27
+ const store = createMemoryUnitStore();
28
+ const legacyPipeline = createPipeline({
29
+ store,
30
+ thresholds: policyThresholds(SHIPPED_LEGACY_POLICY),
31
+ embedder: createHashEmbedder({ dims: SHIPPED_LEGACY_POLICY.embedding.dims }),
32
+ });
33
+ // Use SHIPPED_LEGACY_POLICY.retrieval explicitly when recalling its memories.
34
+ ```
35
+
36
+ The [registered report](https://github.com/jklarenbeek/tangleai/blob/main/docs/LOCOMO_POLICY.md) selected inert: the challenger gained F1 0.000719 over 89 held-out questions, with 95% interval [-0.001464, 0.003216]. Its paired SD was 0.011458; the registered minimum detectable effect was 0.002380 (1.96 × standard error, a precision diagnostic rather than a powered equivalence test). Every clause except a positive overall interval passed. This does not prove equivalence or a general absence of benefit. The result is bounded to one dataset, model and sample; disabling resolution can leave conflicting observations retrievable.
37
+
38
+ `POLICY_PROVENANCE` carries report, registration, cell, source, challenger and transition identities, per-field measurement tiers, decision clauses and power. `POLICY_CONTRACT_REVISION` is the Jaren contract revision; JSON contracts are exported at `@tangleai/memory/schemas/policy.contract.json` and `@tangleai/memory/schemas/policy.schema.json`. Config profiles reference this owner rather than copy its values. Generation reads validated benchmark evidence only during development; runtime packages never import benchmark files.
39
+
40
+ From the repository root:
41
+
42
+ ```sh
43
+ npm run policy:check
44
+ npm run policy:contract:check
45
+ npm run emit:policy -- --check
46
+ ```
47
+
48
+ The drift check validates the immutable live evidence, regenerates the expected artifact in memory, checks the registry reference and probes the public runtime behavior. `npm run policy:generate` writes a default only from a complete eligible confirmation; regenerate declarations with `npm run emit:policy` after a contract change. Contract compatibility is checked against the committed v1 fixture.
49
+
50
+ ## Outcome confidence
51
+
52
+ `applyOutcome(store, report, {options}?)` adjusts confidence once per cited entry
53
+ in that call: success +0.15, failure −0.25, partial +0.05 by default, starting at
54
+ 0.5 when absent and clamping to [0.1, 1]. It preserves the legacy behavior:
55
+ duplicate citations apply repeatedly, repeated calls apply again, and `report.at`
56
+ replaces fact time. Its four-method store interface supplies no durable replay
57
+ receipt or atomic multi-memory guarantee; a failed later write can leave an
58
+ earlier write applied. A host-supplied report is not independently resolved by
59
+ this helper.
60
+
61
+ `projectOutcomeConfidence(unit, outcome, options?)` is the shared pure arithmetic
62
+ helper. It returns a detached unit and preserves all fields except confidence.
63
+ For independently evidenced scoring, sorted unique authorized citations,
64
+ preserved fact timestamps and atomic receipt-plus-memory updates, use
65
+ `@tangleai/outcomes` with its own memory store or `@tangleai/store`'s
66
+ `createOutcomeStore(db)`. Missing cited ids are terminal counted skips there;
67
+ a completed projection never reapplies after the id is restored. See the
68
+ [outcome adapter kit](../outcomes/docs/ADAPTERS.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangleai/memory",
3
- "version": "0.20.1",
3
+ "version": "0.24.1",
4
4
  "description": "Tangle AI memory policies — novelty gating, crystallization, contradiction resolution, outcome learning — over an injected store",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,17 +46,24 @@
46
46
  "import": "./src/retrieval.js",
47
47
  "default": "./src/retrieval.js"
48
48
  },
49
- "./package.json": "./package.json"
49
+ "./package.json": "./package.json",
50
+ "./policy": {
51
+ "types": "./src/policy.d.ts",
52
+ "import": "./src/policy.js",
53
+ "default": "./src/policy.js"
54
+ },
55
+ "./schemas/policy.schema.json": "./schemas/policy.schema.json",
56
+ "./schemas/policy.contract.json": "./schemas/policy.contract.json"
50
57
  },
51
58
  "engines": {
52
59
  "node": ">=24"
53
60
  },
54
61
  "sideEffects": false,
55
62
  "dependencies": {
56
- "@jarenjs/ai": "0.83.3",
57
- "@tangleai/core": "^0.20.1",
58
- "@jarenjs/core": "0.83.3",
59
- "@jarenjs/validate": "0.83.3"
63
+ "@tangleai/core": "^0.24.1",
64
+ "@jarenjs/core": "0.86.0",
65
+ "@jarenjs/validate": "0.86.0",
66
+ "@tangleai/context": "^0.24.1"
60
67
  },
61
68
  "private": false,
62
69
  "types": "./src/index.d.ts",
@@ -0,0 +1,256 @@
1
+ {
2
+ "$contract": "0.1",
3
+ "id": "tangle-memory-policy",
4
+ "version": "1",
5
+ "operations": {
6
+ "policy.provenance": {
7
+ "kind": "read",
8
+ "input": {
9
+ "type": "object",
10
+ "additionalProperties": false,
11
+ "required": [],
12
+ "properties": {}
13
+ },
14
+ "output": {
15
+ "type": "object",
16
+ "additionalProperties": false,
17
+ "required": [
18
+ "reportId",
19
+ "registrationId",
20
+ "cellId",
21
+ "sourceId",
22
+ "transitionId",
23
+ "challengerId",
24
+ "ingestTier",
25
+ "retrievalTier",
26
+ "embeddingTier",
27
+ "qualifiesAsDefault",
28
+ "statement",
29
+ "power",
30
+ "interval",
31
+ "clauses"
32
+ ],
33
+ "properties": {
34
+ "reportId": {
35
+ "type": "string"
36
+ },
37
+ "registrationId": {
38
+ "type": "string"
39
+ },
40
+ "cellId": {
41
+ "type": "string"
42
+ },
43
+ "sourceId": {
44
+ "type": "string"
45
+ },
46
+ "transitionId": {
47
+ "type": "string"
48
+ },
49
+ "challengerId": {
50
+ "type": "string"
51
+ },
52
+ "ingestTier": {
53
+ "const": "live"
54
+ },
55
+ "retrievalTier": {
56
+ "const": "live"
57
+ },
58
+ "embeddingTier": {
59
+ "const": "keyless"
60
+ },
61
+ "qualifiesAsDefault": {
62
+ "type": "boolean"
63
+ },
64
+ "statement": {
65
+ "type": "string"
66
+ },
67
+ "power": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "required": [
71
+ "pairedSd",
72
+ "standardError",
73
+ "minimumDetectableEffect",
74
+ "tiedPairs",
75
+ "actingSetSize"
76
+ ],
77
+ "properties": {
78
+ "pairedSd": {
79
+ "type": "number"
80
+ },
81
+ "standardError": {
82
+ "type": "number"
83
+ },
84
+ "minimumDetectableEffect": {
85
+ "type": "number"
86
+ },
87
+ "tiedPairs": {
88
+ "type": "integer",
89
+ "minimum": 0
90
+ },
91
+ "actingSetSize": {
92
+ "type": "integer",
93
+ "minimum": 0
94
+ }
95
+ }
96
+ },
97
+ "interval": {
98
+ "type": "object",
99
+ "additionalProperties": false,
100
+ "required": [
101
+ "low",
102
+ "high"
103
+ ],
104
+ "properties": {
105
+ "low": {
106
+ "type": "number"
107
+ },
108
+ "high": {
109
+ "type": "number"
110
+ }
111
+ }
112
+ },
113
+ "clauses": {
114
+ "type": "array",
115
+ "items": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": [
119
+ "clause",
120
+ "passed",
121
+ "detail"
122
+ ],
123
+ "properties": {
124
+ "clause": {
125
+ "type": "string"
126
+ },
127
+ "passed": {
128
+ "type": "boolean"
129
+ },
130
+ "detail": {
131
+ "type": "string"
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ },
139
+ "policy.read": {
140
+ "kind": "read",
141
+ "input": {
142
+ "type": "object",
143
+ "additionalProperties": false,
144
+ "required": [],
145
+ "properties": {}
146
+ },
147
+ "output": {
148
+ "type": "object",
149
+ "additionalProperties": false,
150
+ "required": [
151
+ "novelty",
152
+ "contradiction",
153
+ "crystallization",
154
+ "retrieval",
155
+ "embedding"
156
+ ],
157
+ "properties": {
158
+ "novelty": {
159
+ "type": "object",
160
+ "additionalProperties": false,
161
+ "required": [
162
+ "enabled",
163
+ "threshold"
164
+ ],
165
+ "properties": {
166
+ "enabled": {
167
+ "type": "boolean"
168
+ },
169
+ "threshold": {
170
+ "type": "number"
171
+ }
172
+ }
173
+ },
174
+ "contradiction": {
175
+ "type": "object",
176
+ "additionalProperties": false,
177
+ "required": [
178
+ "enabled",
179
+ "threshold",
180
+ "maxPairs"
181
+ ],
182
+ "properties": {
183
+ "enabled": {
184
+ "type": "boolean"
185
+ },
186
+ "threshold": {
187
+ "type": "number"
188
+ },
189
+ "maxPairs": {
190
+ "type": "integer",
191
+ "minimum": 0
192
+ }
193
+ }
194
+ },
195
+ "crystallization": {
196
+ "type": "object",
197
+ "additionalProperties": false,
198
+ "required": [
199
+ "enabled",
200
+ "threshold"
201
+ ],
202
+ "properties": {
203
+ "enabled": {
204
+ "type": "boolean"
205
+ },
206
+ "threshold": {
207
+ "type": "number"
208
+ }
209
+ }
210
+ },
211
+ "retrieval": {
212
+ "type": "object",
213
+ "additionalProperties": false,
214
+ "required": [
215
+ "k",
216
+ "minScore"
217
+ ],
218
+ "properties": {
219
+ "k": {
220
+ "type": "integer",
221
+ "minimum": 0
222
+ },
223
+ "minScore": {
224
+ "type": "number"
225
+ }
226
+ }
227
+ },
228
+ "embedding": {
229
+ "type": "object",
230
+ "additionalProperties": false,
231
+ "required": [
232
+ "model",
233
+ "dims",
234
+ "tier"
235
+ ],
236
+ "properties": {
237
+ "model": {
238
+ "type": "string"
239
+ },
240
+ "dims": {
241
+ "type": "integer",
242
+ "minimum": 0
243
+ },
244
+ "tier": {
245
+ "type": "string",
246
+ "enum": [
247
+ "keyless"
248
+ ]
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
@@ -0,0 +1,110 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://tangleai.dev/schemas/memory-policy-values",
4
+ "title": "MemoryPolicyValues",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "novelty",
9
+ "contradiction",
10
+ "crystallization",
11
+ "retrieval",
12
+ "embedding"
13
+ ],
14
+ "properties": {
15
+ "novelty": {
16
+ "type": "object",
17
+ "additionalProperties": false,
18
+ "required": [
19
+ "enabled",
20
+ "threshold"
21
+ ],
22
+ "properties": {
23
+ "enabled": {
24
+ "type": "boolean"
25
+ },
26
+ "threshold": {
27
+ "type": "number"
28
+ }
29
+ }
30
+ },
31
+ "contradiction": {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "required": [
35
+ "enabled",
36
+ "threshold",
37
+ "maxPairs"
38
+ ],
39
+ "properties": {
40
+ "enabled": {
41
+ "type": "boolean"
42
+ },
43
+ "threshold": {
44
+ "type": "number"
45
+ },
46
+ "maxPairs": {
47
+ "type": "integer",
48
+ "minimum": 0
49
+ }
50
+ }
51
+ },
52
+ "crystallization": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": [
56
+ "enabled",
57
+ "threshold"
58
+ ],
59
+ "properties": {
60
+ "enabled": {
61
+ "type": "boolean"
62
+ },
63
+ "threshold": {
64
+ "type": "number"
65
+ }
66
+ }
67
+ },
68
+ "retrieval": {
69
+ "type": "object",
70
+ "additionalProperties": false,
71
+ "required": [
72
+ "k",
73
+ "minScore"
74
+ ],
75
+ "properties": {
76
+ "k": {
77
+ "type": "integer",
78
+ "minimum": 0
79
+ },
80
+ "minScore": {
81
+ "type": "number"
82
+ }
83
+ }
84
+ },
85
+ "embedding": {
86
+ "type": "object",
87
+ "additionalProperties": false,
88
+ "required": [
89
+ "model",
90
+ "dims",
91
+ "tier"
92
+ ],
93
+ "properties": {
94
+ "model": {
95
+ "type": "string"
96
+ },
97
+ "dims": {
98
+ "type": "integer",
99
+ "minimum": 0
100
+ },
101
+ "tier": {
102
+ "type": "string",
103
+ "enum": [
104
+ "keyless"
105
+ ]
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
@@ -5,7 +5,7 @@
5
5
  * memflow called `llm.invoke()` inline and regex-scraped JSON out of the
6
6
  * reply. Here the judge is INJECTED: any async function answering the
7
7
  * verdict shape. The intended production judge is two lines of
8
- * @jarenjs/ai — `createStructuredOutput({ client, schema:
8
+ * @tangleai/models — `createStructuredOutput({ client, schema:
9
9
  * CONTRADICTION_VERDICT_SCHEMA })` over `contradictionMessages(a, b)` —
10
10
  * which buys schema-constrained decoding and the bounded repair loop
11
11
  * instead of a regex. The tests inject a table.
@@ -33,9 +33,9 @@
33
33
  */
34
34
  import type { JsonSchema, MemoryUnit } from '@tangleai/core/schemas/memory';
35
35
  import type { MemoryStore } from './store.ts';
36
- export declare const DEFAULT_CONTRADICTION_THRESHOLD = 0.75;
37
- export declare const DEFAULT_MAX_PAIRS = 20;
38
- /** What a judge must answer. Wire it to @jarenjs/ai `createStructuredOutput`
36
+ export declare const DEFAULT_CONTRADICTION_THRESHOLD: number;
37
+ export declare const DEFAULT_MAX_PAIRS: number;
38
+ /** What a judge must answer. Wire it to @tangleai/models `createStructuredOutput`
39
39
  * as the `schema` and the repair loop enforces it for free. */
40
40
  export declare const CONTRADICTION_VERDICT_SCHEMA: JsonSchema;
41
41
  export interface ContradictionVerdict {
@@ -5,7 +5,7 @@
5
5
  * memflow called `llm.invoke()` inline and regex-scraped JSON out of the
6
6
  * reply. Here the judge is INJECTED: any async function answering the
7
7
  * verdict shape. The intended production judge is two lines of
8
- * @jarenjs/ai — `createStructuredOutput({ client, schema:
8
+ * @tangleai/models — `createStructuredOutput({ client, schema:
9
9
  * CONTRADICTION_VERDICT_SCHEMA })` over `contradictionMessages(a, b)` —
10
10
  * which buys schema-constrained decoding and the bounded repair loop
11
11
  * instead of a regex. The tests inject a table.
@@ -33,9 +33,10 @@
33
33
  */
34
34
  import { cosineSimilarity } from '@jarenjs/core/vector';
35
35
  import { createMemoryUnit } from "./ingest.js";
36
- export const DEFAULT_CONTRADICTION_THRESHOLD = 0.75;
37
- export const DEFAULT_MAX_PAIRS = 20;
38
- /** What a judge must answer. Wire it to @jarenjs/ai `createStructuredOutput`
36
+ import { policyThresholds, DEFAULT_MEMORY_POLICY } from "./policy.js";
37
+ export const DEFAULT_CONTRADICTION_THRESHOLD = policyThresholds().contradiction;
38
+ export const DEFAULT_MAX_PAIRS = DEFAULT_MEMORY_POLICY.contradiction.maxPairs;
39
+ /** What a judge must answer. Wire it to @tangleai/models `createStructuredOutput`
39
40
  * as the `schema` and the repair loop enforces it for free. */
40
41
  export const CONTRADICTION_VERDICT_SCHEMA = {
41
42
  $id: 'https://tangleai.dev/schemas/contradiction-verdict.json',
@@ -7,7 +7,7 @@
7
7
  * against a live Memgraph; here the plan is a value you can assert on.
8
8
  *
9
9
  * Policy (unchanged from memflow):
10
- * - pairwise similarity >= threshold (default 0.92) marks a duplicate pair
10
+ * - pairwise similarity >= threshold (selected policy; disabled by default) marks a duplicate pair
11
11
  * - the higher-confidence record survives; ties keep the first
12
12
  * - a record participates in at most one merge per pass — a chain
13
13
  * A~B~C collapses over successive passes, not in one ambiguous step
@@ -34,7 +34,7 @@
34
34
  */
35
35
  import type { MemoryUnit } from '@tangleai/core/schemas/memory';
36
36
  import type { MemoryStore } from './store.ts';
37
- export declare const DEFAULT_CRYSTALLIZE_THRESHOLD = 0.92;
37
+ export declare const DEFAULT_CRYSTALLIZE_THRESHOLD: number;
38
38
  export declare const CONFIDENCE_BOOST = 0.05;
39
39
  export declare const CONFIDENCE_FLOOR = 0.1;
40
40
  export interface CrystallizeMerge {
@@ -7,7 +7,7 @@
7
7
  * against a live Memgraph; here the plan is a value you can assert on.
8
8
  *
9
9
  * Policy (unchanged from memflow):
10
- * - pairwise similarity >= threshold (default 0.92) marks a duplicate pair
10
+ * - pairwise similarity >= threshold (selected policy; disabled by default) marks a duplicate pair
11
11
  * - the higher-confidence record survives; ties keep the first
12
12
  * - a record participates in at most one merge per pass — a chain
13
13
  * A~B~C collapses over successive passes, not in one ambiguous step
@@ -33,8 +33,9 @@
33
33
  * different outcomes.
34
34
  */
35
35
  import { cosineSimilarity } from '@jarenjs/core/vector';
36
- import { sameIdentity } from '@jarenjs/ai';
37
- export const DEFAULT_CRYSTALLIZE_THRESHOLD = 0.92;
36
+ import { sameIdentity } from '@tangleai/context/ledger';
37
+ import { policyThresholds, DEFAULT_MEMORY_POLICY } from "./policy.js";
38
+ export const DEFAULT_CRYSTALLIZE_THRESHOLD = policyThresholds().crystallize;
38
39
  export const CONFIDENCE_BOOST = 0.05;
39
40
  export const CONFIDENCE_FLOOR = 0.1;
40
41
  /** Decide which records to merge. Pure. */
package/src/index.d.ts CHANGED
@@ -9,7 +9,9 @@ export { planCrystallization, applyCrystallization, DEFAULT_CRYSTALLIZE_THRESHOL
9
9
  export type { CrystallizeMerge, CrystallizePlan, CrystallizeOptions, CrystallizeOutcome } from './crystallize.ts';
10
10
  export { planContradictionPairs, resolveContradictions, contradictionMessages, CONTRADICTION_VERDICT_SCHEMA, DEFAULT_CONTRADICTION_THRESHOLD, DEFAULT_MAX_PAIRS, } from './contradiction.ts';
11
11
  export type { ContradictionVerdict, ContradictionPair, ChatMessage, ResolveOptions, ResolveOutcome, } from './contradiction.ts';
12
- export { applyOutcome, outcomeAdjustment, DEFAULT_OUTCOME_OPTIONS } from './outcome.ts';
12
+ export { applyOutcome, projectOutcomeConfidence, outcomeAdjustment, DEFAULT_OUTCOME_OPTIONS } from './outcome.ts';
13
13
  export type { OutcomeOptions, ApplyOutcomeResult } from './outcome.ts';
14
14
  export { rankByEmbedding, recallByEmbedding } from './retrieval.ts';
15
15
  export type { RankOptions, RankedMemory, RankedRecall } from './retrieval.ts';
16
+ export { DEFAULT_MEMORY_POLICY, POLICY_PROVENANCE, MEASURED_MEMORY_POLICIES, SHIPPED_LEGACY_POLICY, SHIPPED_LEGACY_CELL_ID, POLICY_CONTRACT_REVISION, policyThresholds } from './policy.ts';
17
+ export type { MemoryPolicyValues } from './policy.ts';
package/src/index.js CHANGED
@@ -4,5 +4,6 @@ export { createMemoryUnit, memoryId } from "./ingest.js";
4
4
  export { noveltyGate, DEFAULT_NOVELTY_THRESHOLD } from "./novelty.js";
5
5
  export { planCrystallization, applyCrystallization, DEFAULT_CRYSTALLIZE_THRESHOLD, CONFIDENCE_BOOST, CONFIDENCE_FLOOR, } from "./crystallize.js";
6
6
  export { planContradictionPairs, resolveContradictions, contradictionMessages, CONTRADICTION_VERDICT_SCHEMA, DEFAULT_CONTRADICTION_THRESHOLD, DEFAULT_MAX_PAIRS, } from "./contradiction.js";
7
- export { applyOutcome, outcomeAdjustment, DEFAULT_OUTCOME_OPTIONS } from "./outcome.js";
7
+ export { applyOutcome, projectOutcomeConfidence, outcomeAdjustment, DEFAULT_OUTCOME_OPTIONS } from "./outcome.js";
8
8
  export { rankByEmbedding, recallByEmbedding } from "./retrieval.js";
9
+ export { DEFAULT_MEMORY_POLICY, POLICY_PROVENANCE, MEASURED_MEMORY_POLICIES, SHIPPED_LEGACY_POLICY, SHIPPED_LEGACY_CELL_ID, POLICY_CONTRACT_REVISION, policyThresholds } from "./policy.js";
package/src/ingest.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Turning raw observations into memory units.
3
3
  *
4
4
  * Ids are content-addressed — `m-<fnv1a(text)>-<length>` via the same
5
- * `hashContent` the @jarenjs/ai recall slots use — so ingesting the same
5
+ * `hashContent` the @tangleai/context recall slots use — so ingesting the same
6
6
  * observation twice produces the same id and the second write is an
7
7
  * overwrite, not a duplicate. Idempotence by construction beats
8
8
  * deduplication by policy; the crystallizer then only has to handle