docs: document space isolation usage
This commit is contained in:
32
README.md
32
README.md
@@ -15,9 +15,9 @@ A single fact like `I have worked with TypeScript since 2025.` can connect the t
|
||||
## Current capabilities
|
||||
|
||||
- SQLite, PostgreSQL, MySQL, and MariaDB connection adapters
|
||||
- Automatic schema initialization for `topics`, `facts`, `fact_topics`, `topic_relations`, `topic_aliases`, and `fact_embeddings`
|
||||
- Automatic schema initialization for `spaces`, `topics`, `facts`, `fact_topics`, `topic_relations`, `topic_aliases`, and `fact_embeddings`
|
||||
- High-level APIs for adding topics and facts
|
||||
- Topic hierarchy APIs for parent/child traversal and lineage lookup
|
||||
- Hard space isolation so independent memory graphs can coexist without cross-linking
|
||||
- Topic alias and canonical resolution APIs so facts and queries can resolve alternate names
|
||||
- Semantic fact indexing and search APIs built around provider-agnostic embeddings
|
||||
- Dedup-aware ingestion hooks that can reuse an existing fact when a semantic near-duplicate is detected
|
||||
@@ -101,6 +101,34 @@ console.log(matches.map((entry) => [entry.statement, entry.score]));
|
||||
await db.close();
|
||||
```
|
||||
|
||||
## Memory spaces
|
||||
|
||||
IdentityDB now supports hard isolation via spaces. If you write facts into `spaceName: 'A'` and `spaceName: 'B'`, they behave like separate dimensions:
|
||||
|
||||
- the same topic name can exist in both spaces
|
||||
- aliases resolve only inside the requested space
|
||||
- hierarchy, connected-topic traversal, semantic search, and duplicate detection stay inside the same space
|
||||
|
||||
```ts
|
||||
await db.upsertSpace({ name: 'A' });
|
||||
await db.upsertSpace({ name: 'B' });
|
||||
|
||||
await db.addFact({
|
||||
spaceName: 'A',
|
||||
statement: 'TypeScript belongs to A.',
|
||||
topics: [{ name: 'TypeScript', category: 'entity', granularity: 'concrete' }],
|
||||
});
|
||||
|
||||
await db.addFact({
|
||||
spaceName: 'B',
|
||||
statement: 'TypeScript belongs to B.',
|
||||
topics: [{ name: 'TypeScript', category: 'entity', granularity: 'concrete' }],
|
||||
});
|
||||
|
||||
const alphaFacts = await db.getTopicFacts('TypeScript', { spaceName: 'A' });
|
||||
const betaFacts = await db.getTopicFacts('TypeScript', { spaceName: 'B' });
|
||||
```
|
||||
|
||||
## Semantic ingestion and duplicate detection
|
||||
|
||||
If you provide an embedding provider during ingestion, IdentityDB can index the new fact automatically and reuse an existing fact when a semantic near-duplicate is already present.
|
||||
|
||||
Reference in New Issue
Block a user