@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.
@@ -0,0 +1,36 @@
1
+ export interface PolicyContradiction {
2
+ enabled: boolean;
3
+ threshold: number;
4
+ /**
5
+ * Schema constraints this type cannot express: type="integer", minimum=0
6
+ */
7
+ maxPairs: number;
8
+ }
9
+ export interface PolicyRetrieval {
10
+ /**
11
+ * Schema constraints this type cannot express: type="integer", minimum=0
12
+ */
13
+ k: number;
14
+ minScore: number;
15
+ }
16
+ export interface PolicyEmbedding {
17
+ model: string;
18
+ /**
19
+ * Schema constraints this type cannot express: type="integer", minimum=0
20
+ */
21
+ dims: number;
22
+ tier: "keyless";
23
+ }
24
+ export interface Policy {
25
+ novelty: {
26
+ enabled: boolean;
27
+ threshold: number;
28
+ };
29
+ contradiction: PolicyContradiction;
30
+ crystallization: {
31
+ enabled: boolean;
32
+ threshold: number;
33
+ };
34
+ retrieval: PolicyRetrieval;
35
+ embedding: PolicyEmbedding;
36
+ }
@@ -0,0 +1,3 @@
1
+ // Generated by @jarenjs/emit from packages/memory/schemas/policy.schema.json.
2
+ // Do not edit: regenerate instead.
3
+ export {};
@@ -2,7 +2,7 @@
2
2
  * Embedding-ranked retrieval over memory units.
3
3
  *
4
4
  * This is Tangle's ranker over its OWN store of full units, beside the
5
- * @jarenjs/ai ledger's `recall({ near })` (which ranks the mirrored
5
+ * @tangleai/context ledger's `recall({ near })` (which ranks the mirrored
6
6
  * ledger records the same way, through the same kernels). Superseded
7
7
  * records never surface — they exist for audit, not for recall. Records
8
8
  * without embeddings never surface either, which is a real bias (see
package/src/retrieval.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Embedding-ranked retrieval over memory units.
3
3
  *
4
4
  * This is Tangle's ranker over its OWN store of full units, beside the
5
- * @jarenjs/ai ledger's `recall({ near })` (which ranks the mirrored
5
+ * @tangleai/context ledger's `recall({ near })` (which ranks the mirrored
6
6
  * ledger records the same way, through the same kernels). Superseded
7
7
  * records never surface — they exist for audit, not for recall. Records
8
8
  * without embeddings never surface either, which is a real bias (see
@@ -21,16 +21,17 @@
21
21
  * The metric is `cosineSimilarity` from `@jarenjs/core/vector`: the one
22
22
  * the suite ranks by, higher-is-better, 0 for a malformed pair.
23
23
  */
24
+ import { DEFAULT_MEMORY_POLICY } from "./policy.js";
24
25
  import { cosineSimilarity } from '@jarenjs/core/vector';
25
- import { sameIdentity } from '@jarenjs/ai';
26
+ import { sameIdentity } from '@tangleai/context/ledger';
26
27
  /**
27
28
  * Rank the live, comparably-embedded units against a query vector and
28
29
  * report what could not be ranked. `queryEmbedding` may be the
29
30
  * `Float32Array` an embedder answers or the `number[]` a record stores.
30
31
  */
31
32
  export function recallByEmbedding(units, queryEmbedding, options = {}) {
32
- const k = options.k ?? 5;
33
- const minScore = options.minScore ?? 0;
33
+ const k = options.k ?? DEFAULT_MEMORY_POLICY.retrieval.k;
34
+ const minScore = options.minScore ?? DEFAULT_MEMORY_POLICY.retrieval.minScore;
34
35
  const identity = options.identity;
35
36
  const scored = [];
36
37
  let skipped = 0;
package/src/store.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * The memory store seam and its default in-memory implementation.
3
3
  *
4
4
  * The contract is four async methods — `get`, `put`, `delete`, `list` —
5
- * the same injection shape as the @jarenjs/ai ledger's storage seam, one
5
+ * the same injection shape as the @tangleai/context ledger's storage seam, one
6
6
  * level up: this store holds validated memory UNITS, not raw strings.
7
7
  * A host backs it with SQLite, OPFS, a graph database, whatever; the
8
8
  * policies in this package only ever see the contract.
package/src/store.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * The memory store seam and its default in-memory implementation.
3
3
  *
4
4
  * The contract is four async methods — `get`, `put`, `delete`, `list` —
5
- * the same injection shape as the @jarenjs/ai ledger's storage seam, one
5
+ * the same injection shape as the @tangleai/context ledger's storage seam, one
6
6
  * level up: this store holds validated memory UNITS, not raw strings.
7
7
  * A host backs it with SQLite, OPFS, a graph database, whatever; the
8
8
  * policies in this package only ever see the contract.