AbstractMemory 0.0.1__tar.gz → 0.0.2__tar.gz

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 (40) hide show
  1. abstractmemory-0.0.2/.gitignore +9 -0
  2. abstractmemory-0.0.2/ACKNOWLEDGMENTS.md +15 -0
  3. abstractmemory-0.0.2/ACKNOWLEDMENTS.md +3 -0
  4. abstractmemory-0.0.2/CHANGELOD.md +3 -0
  5. abstractmemory-0.0.2/CHANGELOG.md +27 -0
  6. abstractmemory-0.0.2/CONTRIBUTING.md +52 -0
  7. {abstractmemory-0.0.1 → abstractmemory-0.0.2}/LICENSE +1 -1
  8. abstractmemory-0.0.2/PKG-INFO +113 -0
  9. abstractmemory-0.0.2/README.md +86 -0
  10. abstractmemory-0.0.2/SECURITY.md +29 -0
  11. abstractmemory-0.0.2/docs/README.md +19 -0
  12. abstractmemory-0.0.2/docs/api.md +95 -0
  13. abstractmemory-0.0.2/docs/architecture.md +138 -0
  14. abstractmemory-0.0.2/docs/development.md +31 -0
  15. abstractmemory-0.0.2/docs/faq.md +119 -0
  16. abstractmemory-0.0.2/docs/getting-started.md +98 -0
  17. abstractmemory-0.0.2/docs/stores.md +80 -0
  18. abstractmemory-0.0.2/llms-full.txt +186 -0
  19. abstractmemory-0.0.2/llms.txt +53 -0
  20. abstractmemory-0.0.2/pyproject.toml +49 -0
  21. abstractmemory-0.0.2/src/abstractmemory/__init__.py +15 -0
  22. abstractmemory-0.0.2/src/abstractmemory/embeddings.py +96 -0
  23. abstractmemory-0.0.2/src/abstractmemory/in_memory_store.py +186 -0
  24. abstractmemory-0.0.2/src/abstractmemory/lancedb_store.py +274 -0
  25. abstractmemory-0.0.2/src/abstractmemory/models.py +126 -0
  26. abstractmemory-0.0.2/src/abstractmemory/store.py +90 -0
  27. abstractmemory-0.0.2/tests/conftest.py +28 -0
  28. abstractmemory-0.0.2/tests/test_in_memory_query_text_fallback.py +20 -0
  29. abstractmemory-0.0.2/tests/test_lancedb_triple_store.py +183 -0
  30. abstractmemory-0.0.2/tests/test_term_canonicalization.py +35 -0
  31. abstractmemory-0.0.2/tests/test_triple_store_limits.py +147 -0
  32. abstractmemory-0.0.1/PKG-INFO +0 -94
  33. abstractmemory-0.0.1/README.md +0 -67
  34. abstractmemory-0.0.1/pyproject.toml +0 -42
  35. abstractmemory-0.0.1/setup.cfg +0 -4
  36. abstractmemory-0.0.1/src/AbstractMemory.egg-info/PKG-INFO +0 -94
  37. abstractmemory-0.0.1/src/AbstractMemory.egg-info/SOURCES.txt +0 -8
  38. abstractmemory-0.0.1/src/AbstractMemory.egg-info/dependency_links.txt +0 -1
  39. abstractmemory-0.0.1/src/AbstractMemory.egg-info/top_level.txt +0 -1
  40. abstractmemory-0.0.1/src/abstractmemory/__init__.py +0 -41
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .DS_Store
5
+ .venv/
6
+ dist/
7
+ build/
8
+ .mypy_cache/
9
+ .ruff_cache/
@@ -0,0 +1,15 @@
1
+ # Acknowledgments
2
+
3
+ AbstractMemory builds on a number of great open-source tools and ideas.
4
+
5
+ ## Libraries
6
+
7
+ - **LanceDB** (`lancedb`) — optional persistent/vector backend used by `LanceDBTripleStore` (see `.[lancedb]` extra in `pyproject.toml`).
8
+ - **pytest** (`pytest`) — development and contract tests (see `.[dev]` extra in `pyproject.toml`).
9
+ - **Hatchling** (`hatchling`) — packaging/build backend (see `[build-system]` in `pyproject.toml`).
10
+
11
+ ## Ecosystem
12
+
13
+ - The broader **AbstractFramework** project for shaping the boundaries between runtime provenance, model execution, and memory storage.
14
+
15
+ If we missed a credit, please open a small PR to update this file.
@@ -0,0 +1,3 @@
1
+ # Acknowledgments (moved)
2
+
3
+ This file is a compatibility alias. See [`ACKNOWLEDGMENTS.md`](ACKNOWLEDGMENTS.md).
@@ -0,0 +1,3 @@
1
+ # Changelog (moved)
2
+
3
+ This file is a compatibility alias. See [`CHANGELOG.md`](CHANGELOG.md).
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (pre-1.0).
7
+
8
+ ## Unreleased
9
+
10
+ ## 0.0.2 - 2026-02-04
11
+
12
+ ### Added
13
+ - User-facing documentation set with getting started, API, stores, architecture diagram, and FAQ.
14
+ - Agent-oriented context files: `llms.txt` and `llms-full.txt`.
15
+
16
+ ### Changed
17
+ - `LanceDBTripleStore` non-semantic queries now apply `order` by `observed_at` before applying `limit` (deterministic behavior aligned with `InMemoryTripleStore`).
18
+
19
+ ### Fixed
20
+ - Ordering/limit interaction for non-semantic queries in `LanceDBTripleStore` (covered by new tests).
21
+
22
+ ## 0.0.1 - 2026-01-12
23
+
24
+ ### Added
25
+ - `TripleAssertion` and `TripleQuery` data models.
26
+ - `InMemoryTripleStore` (dependency-free) and `LanceDBTripleStore` (optional).
27
+ - `AbstractGatewayTextEmbedder` adapter for gateway-managed embeddings.
@@ -0,0 +1,52 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in improving AbstractMemory.
4
+
5
+ This repository uses a `src/` layout and keeps the public API intentionally small.
6
+
7
+ ## Development setup
8
+
9
+ Requirements:
10
+ - Python 3.10+ (see `pyproject.toml`)
11
+
12
+ Install (editable):
13
+
14
+ ```bash
15
+ python -m pip install -e ".[dev]"
16
+ ```
17
+
18
+ Optional (LanceDB backend + tests):
19
+
20
+ ```bash
21
+ python -m pip install -e ".[lancedb]"
22
+ ```
23
+
24
+ More details: [`docs/development.md`](docs/development.md).
25
+
26
+ ## Run tests
27
+
28
+ ```bash
29
+ python -m pytest -q
30
+ ```
31
+
32
+ ## What to contribute
33
+
34
+ Good first contributions:
35
+ - Improve docs (keep statements evidence-based and link to code/tests).
36
+ - Add tests for edge cases and contracts.
37
+ - Make error messages more actionable.
38
+ - Add small, well-scoped features that keep the v0 API minimal.
39
+
40
+ ## Contribution guidelines
41
+
42
+ - Keep changes focused; avoid drive-by refactors.
43
+ - Add tests for behavior changes (especially store/query semantics).
44
+ - Update docs when you change public behavior:
45
+ - `README.md` and `docs/getting-started.md` for user-facing usage
46
+ - `docs/api.md` for public API contracts
47
+ - `CHANGELOG.md` for notable changes
48
+ - If you add a new dependency, keep it optional unless strictly required.
49
+
50
+ ## Security issues
51
+
52
+ Please do not open public issues for vulnerabilities. See [`SECURITY.md`](SECURITY.md).
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 AbstractMemory Team
3
+ Copyright (c) 2024 Laurent-Philippe Albou
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: AbstractMemory
3
+ Version: 0.0.2
4
+ Summary: AbstractMemory: temporal, provenance-aware semantic memory primitives for AbstractFramework.
5
+ Project-URL: AbstractFramework (monorepo), https://github.com/lpalbou/abstractframework
6
+ Author: Laurent-Philippe Albou
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: agents,knowledge-graph,memory,temporal,triples
10
+ Classifier: Development Status :: 1 - Planning
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.10
20
+ Provides-Extra: all
21
+ Requires-Dist: lancedb; extra == 'all'
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
24
+ Provides-Extra: lancedb
25
+ Requires-Dist: lancedb; extra == 'lancedb'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # AbstractMemory (early / WIP)
29
+
30
+ AbstractMemory is a small Python library for **append-only, temporal, provenance-aware triple assertions** with a **deterministic query API** and optional **vector/semantic retrieval**.
31
+
32
+ ## Status
33
+ - This package is still early: API and storage details may change.
34
+ - Implemented today: `TripleAssertion`, `TripleQuery`, `InMemoryTripleStore`, `LanceDBTripleStore`, `AbstractGatewayTextEmbedder`.
35
+ - Source of truth for exports: [`src/abstractmemory/__init__.py`](src/abstractmemory/__init__.py)
36
+ - Requires Python 3.10+ (see [`pyproject.toml`](pyproject.toml))
37
+
38
+ ## Install
39
+
40
+ From PyPI (when published):
41
+
42
+ ```bash
43
+ python -m pip install AbstractMemory
44
+ ```
45
+
46
+ Optional persistent backend + vector search:
47
+
48
+ ```bash
49
+ python -m pip install "AbstractMemory[lancedb]"
50
+ ```
51
+
52
+ Note: the distribution name is `AbstractMemory` (pip is case-insensitive). The import name is `abstractmemory`.
53
+
54
+ From source (recommended for this monorepo package):
55
+
56
+ ```bash
57
+ python -m pip install -e .
58
+ ```
59
+
60
+ Optional persistent backend + vector search:
61
+
62
+ ```bash
63
+ python -m pip install -e ".[lancedb]"
64
+ ```
65
+
66
+ ## Quick example
67
+
68
+ ```python
69
+ from abstractmemory import InMemoryTripleStore, TripleAssertion, TripleQuery
70
+
71
+ store = InMemoryTripleStore()
72
+ store.add(
73
+ [
74
+ TripleAssertion(
75
+ subject="Scrooge",
76
+ predicate="related_to",
77
+ object="Christmas",
78
+ scope="session",
79
+ owner_id="sess-1",
80
+ provenance={"span_id": "span_123"},
81
+ )
82
+ ]
83
+ )
84
+
85
+ hits = store.query(TripleQuery(subject="scrooge", scope="session", owner_id="sess-1"))
86
+ assert hits[0].object == "christmas" # terms are canonicalized (trim + lowercase)
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - Getting started: [`docs/getting-started.md`](docs/getting-started.md)
92
+ - FAQ: [`docs/faq.md`](docs/faq.md)
93
+ - Architecture (with diagrams): [`docs/architecture.md`](docs/architecture.md)
94
+ - Stores/backends: [`docs/stores.md`](docs/stores.md)
95
+ - API reference: [`docs/api.md`](docs/api.md)
96
+ - Development: [`docs/development.md`](docs/development.md)
97
+
98
+ ## Project
99
+
100
+ - Changelog: [`CHANGELOG.md`](CHANGELOG.md)
101
+ - Contributing: [`CONTRIBUTING.md`](CONTRIBUTING.md)
102
+ - Security: [`SECURITY.md`](SECURITY.md)
103
+ - License: [`LICENSE`](LICENSE)
104
+ - Acknowledgments: [`ACKNOWLEDGMENTS.md`](ACKNOWLEDGMENTS.md)
105
+
106
+ ## Design principles (v0)
107
+
108
+ - **Triples-first** representation with temporal fields (`observed_at`, `valid_from`, `valid_until`).
109
+ - Implemented in `TripleAssertion`: [`src/abstractmemory/models.py`](src/abstractmemory/models.py)
110
+ - **Append-only**: represent updates by adding a new assertion with fresh provenance.
111
+ - Implemented by both stores: [`src/abstractmemory/in_memory_store.py`](src/abstractmemory/in_memory_store.py), [`src/abstractmemory/lancedb_store.py`](src/abstractmemory/lancedb_store.py)
112
+ - **No direct AbstractCore dependency**: embeddings can be obtained via an AbstractGateway HTTP API.
113
+ - Implemented by `AbstractGatewayTextEmbedder`: [`src/abstractmemory/embeddings.py`](src/abstractmemory/embeddings.py)
@@ -0,0 +1,86 @@
1
+ # AbstractMemory (early / WIP)
2
+
3
+ AbstractMemory is a small Python library for **append-only, temporal, provenance-aware triple assertions** with a **deterministic query API** and optional **vector/semantic retrieval**.
4
+
5
+ ## Status
6
+ - This package is still early: API and storage details may change.
7
+ - Implemented today: `TripleAssertion`, `TripleQuery`, `InMemoryTripleStore`, `LanceDBTripleStore`, `AbstractGatewayTextEmbedder`.
8
+ - Source of truth for exports: [`src/abstractmemory/__init__.py`](src/abstractmemory/__init__.py)
9
+ - Requires Python 3.10+ (see [`pyproject.toml`](pyproject.toml))
10
+
11
+ ## Install
12
+
13
+ From PyPI (when published):
14
+
15
+ ```bash
16
+ python -m pip install AbstractMemory
17
+ ```
18
+
19
+ Optional persistent backend + vector search:
20
+
21
+ ```bash
22
+ python -m pip install "AbstractMemory[lancedb]"
23
+ ```
24
+
25
+ Note: the distribution name is `AbstractMemory` (pip is case-insensitive). The import name is `abstractmemory`.
26
+
27
+ From source (recommended for this monorepo package):
28
+
29
+ ```bash
30
+ python -m pip install -e .
31
+ ```
32
+
33
+ Optional persistent backend + vector search:
34
+
35
+ ```bash
36
+ python -m pip install -e ".[lancedb]"
37
+ ```
38
+
39
+ ## Quick example
40
+
41
+ ```python
42
+ from abstractmemory import InMemoryTripleStore, TripleAssertion, TripleQuery
43
+
44
+ store = InMemoryTripleStore()
45
+ store.add(
46
+ [
47
+ TripleAssertion(
48
+ subject="Scrooge",
49
+ predicate="related_to",
50
+ object="Christmas",
51
+ scope="session",
52
+ owner_id="sess-1",
53
+ provenance={"span_id": "span_123"},
54
+ )
55
+ ]
56
+ )
57
+
58
+ hits = store.query(TripleQuery(subject="scrooge", scope="session", owner_id="sess-1"))
59
+ assert hits[0].object == "christmas" # terms are canonicalized (trim + lowercase)
60
+ ```
61
+
62
+ ## Documentation
63
+
64
+ - Getting started: [`docs/getting-started.md`](docs/getting-started.md)
65
+ - FAQ: [`docs/faq.md`](docs/faq.md)
66
+ - Architecture (with diagrams): [`docs/architecture.md`](docs/architecture.md)
67
+ - Stores/backends: [`docs/stores.md`](docs/stores.md)
68
+ - API reference: [`docs/api.md`](docs/api.md)
69
+ - Development: [`docs/development.md`](docs/development.md)
70
+
71
+ ## Project
72
+
73
+ - Changelog: [`CHANGELOG.md`](CHANGELOG.md)
74
+ - Contributing: [`CONTRIBUTING.md`](CONTRIBUTING.md)
75
+ - Security: [`SECURITY.md`](SECURITY.md)
76
+ - License: [`LICENSE`](LICENSE)
77
+ - Acknowledgments: [`ACKNOWLEDGMENTS.md`](ACKNOWLEDGMENTS.md)
78
+
79
+ ## Design principles (v0)
80
+
81
+ - **Triples-first** representation with temporal fields (`observed_at`, `valid_from`, `valid_until`).
82
+ - Implemented in `TripleAssertion`: [`src/abstractmemory/models.py`](src/abstractmemory/models.py)
83
+ - **Append-only**: represent updates by adding a new assertion with fresh provenance.
84
+ - Implemented by both stores: [`src/abstractmemory/in_memory_store.py`](src/abstractmemory/in_memory_store.py), [`src/abstractmemory/lancedb_store.py`](src/abstractmemory/lancedb_store.py)
85
+ - **No direct AbstractCore dependency**: embeddings can be obtained via an AbstractGateway HTTP API.
86
+ - Implemented by `AbstractGatewayTextEmbedder`: [`src/abstractmemory/embeddings.py`](src/abstractmemory/embeddings.py)
@@ -0,0 +1,29 @@
1
+ # Security Policy
2
+
3
+ If you discover a security vulnerability, please report it responsibly so we can address it before public disclosure.
4
+
5
+ ## Reporting a vulnerability
6
+
7
+ Please **do not** open a public GitHub issue for security reports.
8
+
9
+ Preferred reporting method (private):
10
+ - Use GitHub’s **“Report a vulnerability”** / **Security Advisory** workflow on the AbstractFramework monorepo:
11
+ - `https://github.com/lpalbou/abstractframework`
12
+
13
+ If private reporting is not available on the repository:
14
+ - Contact the maintainers privately via the repository’s contact channels (e.g. GitHub profile contact).
15
+
16
+ ## What to include
17
+
18
+ To help us triage quickly, include:
19
+ - A clear description of the issue and potential impact
20
+ - The affected component(s) and file paths (if known)
21
+ - Steps to reproduce (or a minimal proof-of-concept)
22
+ - The version(s) impacted (see `pyproject.toml`) and your environment details
23
+ - Any suggested mitigation or patch (optional)
24
+
25
+ ## Disclosure timeline
26
+
27
+ We will do our best to acknowledge receipt promptly and work with you on a coordinated disclosure timeline.
28
+
29
+ Thank you for helping keep users safe.
@@ -0,0 +1,19 @@
1
+ # AbstractMemory Documentation
2
+
3
+ AbstractMemory is a small, dependency-light Python library that provides **append-only, temporal, provenance-aware triple assertions** plus a **deterministic query API**, with optional **vector/semantic retrieval**.
4
+
5
+ ## Start here
6
+ - Getting started: [`getting-started.md`](getting-started.md)
7
+ - FAQ: [`faq.md`](faq.md)
8
+ - Architecture: [`architecture.md`](architecture.md)
9
+ - Stores/backends: [`stores.md`](stores.md)
10
+ - API reference: [`api.md`](api.md)
11
+ - Development: [`development.md`](development.md)
12
+
13
+ ## Related
14
+ - Package overview: [`README.md`](../README.md)
15
+ - Changelog: [`CHANGELOG.md`](../CHANGELOG.md)
16
+ - Contributing: [`CONTRIBUTING.md`](../CONTRIBUTING.md)
17
+ - Security: [`SECURITY.md`](../SECURITY.md)
18
+ - License: [`LICENSE`](../LICENSE)
19
+ - Acknowledgments: [`ACKNOWLEDGMENTS.md`](../ACKNOWLEDGMENTS.md)
@@ -0,0 +1,95 @@
1
+ # API Reference (v0)
2
+
3
+ > This package is early/WIP. The API is intentionally small and may change.
4
+
5
+ ## Public exports
6
+
7
+ All public exports are defined in [`src/abstractmemory/__init__.py`](../src/abstractmemory/__init__.py):
8
+ - Data model: `TripleAssertion`
9
+ - Query model: `TripleQuery`
10
+ - Store interface: `TripleStore` (typing protocol)
11
+ - Stores: `InMemoryTripleStore`, `LanceDBTripleStore`
12
+ - Embeddings: `TextEmbedder` (protocol), `AbstractGatewayTextEmbedder`
13
+
14
+ ## `TripleAssertion`
15
+
16
+ Source: [`src/abstractmemory/models.py`](../src/abstractmemory/models.py)
17
+
18
+ An **append-only semantic assertion** with temporal + provenance metadata.
19
+
20
+ Fields (selected):
21
+ - `subject`, `predicate`, `object` (strings)
22
+ - `scope`: `"run" | "session" | "global"` (string)
23
+ - `owner_id`: identifier within the scope (e.g. a session id)
24
+ - `observed_at`: ISO-8601/RFC-3339 timestamp string (default: current UTC to seconds)
25
+ - `valid_from`, `valid_until`: optional validity window (see `TripleQuery.active_at`)
26
+ - `provenance`: free-form dict (e.g. `{"span_id": "...", "artifact_id": "..."}`)
27
+ - `attributes`: free-form dict (extractor evidence/context, retrieval metadata, etc.)
28
+
29
+ Behavior:
30
+ - `TripleAssertion` is immutable (`@dataclass(frozen=True)`).
31
+ - Terms are **canonicalized on creation** (trim + lowercase). This is part of the matching contract. Evidence: `TripleAssertion.__post_init__` in [`src/abstractmemory/models.py`](../src/abstractmemory/models.py) and [`tests/test_term_canonicalization.py`](../tests/test_term_canonicalization.py).
32
+ - Canonicalization discards original casing/whitespace. Preserve raw strings separately (e.g. in `attributes`) if needed.
33
+ - Serialization helpers: `to_dict()` / `from_dict(...)` (same file).
34
+
35
+ ## `TripleQuery`
36
+
37
+ Source: [`src/abstractmemory/store.py`](../src/abstractmemory/store.py)
38
+
39
+ Used by `TripleStore.query(...)`.
40
+
41
+ Core filters:
42
+ - `subject`, `predicate`, `object` (exact match after canonicalization)
43
+ - `scope`, `owner_id`
44
+ - `since`, `until`: compare `observed_at` timestamps
45
+ - `active_at`: filters by validity window intersection:
46
+ - include if `(valid_from is None or valid_from <= active_at)` and `(valid_until is None or valid_until > active_at)`
47
+ - end is **exclusive** (`valid_until > active_at`), consistent across stores
48
+
49
+ Semantic/vector filters (optional):
50
+ - `query_text`: text to embed for vector search (requires a configured `embedder`)
51
+ - `query_vector`: bypass embedding generation (vector provided by caller)
52
+ - `vector_column`: column name to use (default `"vector"`)
53
+ - `min_score`: cosine similarity threshold
54
+
55
+ Result shaping:
56
+ - `limit`: `<= 0` means “unbounded” (see tests in [`tests/test_triple_store_limits.py`](../tests/test_triple_store_limits.py))
57
+ - `order`: `"asc" | "desc"` (by `observed_at` for non-semantic queries)
58
+
59
+ Vector query results:
60
+ - When using `query_text` or `query_vector`, stores attach retrieval metadata to `TripleAssertion.attributes["_retrieval"]`.
61
+ - In-memory: `{ "score": <cosine>, "metric": "cosine" }`
62
+ - LanceDB: `{ "score": <cosine>, "distance": <_distance>, "metric": "cosine" }`
63
+
64
+ ## `TripleStore` (protocol)
65
+
66
+ Source: [`src/abstractmemory/store.py`](../src/abstractmemory/store.py)
67
+
68
+ Minimal store interface:
69
+ - `add(assertions: Iterable[TripleAssertion]) -> list[str]` (returns generated assertion ids)
70
+ - `query(q: TripleQuery) -> list[TripleAssertion]`
71
+ - `close() -> None`
72
+
73
+ ## Stores
74
+
75
+ Implementation sources:
76
+ - In-memory: [`src/abstractmemory/in_memory_store.py`](../src/abstractmemory/in_memory_store.py)
77
+ - LanceDB: [`src/abstractmemory/lancedb_store.py`](../src/abstractmemory/lancedb_store.py)
78
+
79
+ See [`docs/stores.md`](stores.md) for behavior differences and persistence details.
80
+
81
+ ## Embeddings
82
+
83
+ Source: [`src/abstractmemory/embeddings.py`](../src/abstractmemory/embeddings.py)
84
+
85
+ `TextEmbedder` protocol:
86
+ - `embed_texts(texts: Sequence[str]) -> list[list[float]]`
87
+
88
+ `AbstractGatewayTextEmbedder`:
89
+ - Calls an AbstractGateway embeddings endpoint via HTTP (`POST` JSON `{ "input": [...] }`)
90
+ - Expects an OpenAI-like response shape with a `data` list containing `embedding` (and optionally `index`)
91
+
92
+ Tip: keep a stable provider/model per store instance to preserve a consistent embedding space (the store itself does not enforce this).
93
+
94
+ See also:
95
+ - Common questions and implementation notes: [`docs/faq.md`](faq.md)
@@ -0,0 +1,138 @@
1
+ # AbstractMemory — Architecture (v0 / early)
2
+
3
+ > Updated: 2026-02-04
4
+
5
+ This document describes **what exists in this repository today** and the boundaries it enforces.
6
+
7
+ ## Scope
8
+
9
+ What this package *is*:
10
+ - A small library for **append-only, temporal, provenance-aware triple assertions**.
11
+ - A **deterministic query API** over those assertions, with optional vector/semantic retrieval.
12
+
13
+ What this package is *not* (by design, not implemented here):
14
+ - A text extractor/summarizer (no AbstractCore dependency).
15
+ - A runtime provenance system (spans/artifacts live elsewhere; this package only stores pointers in `provenance`).
16
+ - A full knowledge-graph reasoner (no inference, joins, ontologies in v0).
17
+
18
+ Evidence (module map):
19
+ - Data model: [`src/abstractmemory/models.py`](../src/abstractmemory/models.py)
20
+ - Query model + protocol: [`src/abstractmemory/store.py`](../src/abstractmemory/store.py)
21
+ - Stores: [`src/abstractmemory/in_memory_store.py`](../src/abstractmemory/in_memory_store.py), [`src/abstractmemory/lancedb_store.py`](../src/abstractmemory/lancedb_store.py)
22
+ - Embeddings adapter: [`src/abstractmemory/embeddings.py`](../src/abstractmemory/embeddings.py)
23
+
24
+ ## Component diagram
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ APP[Your app / extractor] --> TA[TripleAssertion\nmodels.py]
29
+ APP --> TQ[TripleQuery\nstore.py]
30
+
31
+ subgraph AbstractMemory
32
+ TA --> IM[InMemoryTripleStore\nin_memory_store.py]
33
+ TA --> LDB[LanceDBTripleStore\nlancedb_store.py]
34
+ TQ --> IM
35
+ TQ --> LDB
36
+
37
+ TE[TextEmbedder\nembeddings.py] --> IM
38
+ TE --> LDB
39
+ AG[AbstractGatewayTextEmbedder\nembeddings.py] --> TE
40
+ end
41
+
42
+ LDB <--> DISK[(LanceDB tables\non disk)]
43
+ AG <--> GW[AbstractGateway\nEmbeddings API]
44
+
45
+ IM --> APP
46
+ LDB --> APP
47
+ ```
48
+
49
+ ## Core representation
50
+
51
+ The primitive is an **append-only triple assertion**:
52
+
53
+ ```
54
+ subject --predicate--> object
55
+ ```
56
+
57
+ Represented by `abstractmemory.models.TripleAssertion` (see [`src/abstractmemory/models.py`](../src/abstractmemory/models.py)):
58
+ - Canonical fields: `subject`, `predicate`, `object` (trimmed + lowercased on creation)
59
+ - Partitioning fields: `scope` (`run|session|global`) + optional `owner_id`
60
+ - Time: `observed_at` (when recorded), optional `valid_from`/`valid_until` (when considered true)
61
+ - Provenance: `provenance` dict (e.g. `span_id`, `artifact_id`)
62
+ - Extra payload: `attributes` dict (evidence/context + retrieval metadata)
63
+
64
+ Evidence:
65
+ - Canonicalization behavior is tested in [`tests/test_term_canonicalization.py`](../tests/test_term_canonicalization.py).
66
+
67
+ ## Storage backends (v0)
68
+
69
+ See also: [`docs/stores.md`](stores.md)
70
+
71
+ ### In-memory (default)
72
+
73
+ `abstractmemory.in_memory_store.InMemoryTripleStore` is dependency-free and stores rows in process memory.
74
+
75
+ Key behavior:
76
+ - Optional vector indexing when constructed with an `embedder`.
77
+ - `query_text` requires an embedder; there is **no keyword fallback** (raises `ValueError`).
78
+
79
+ Evidence:
80
+ - Store implementation: [`src/abstractmemory/in_memory_store.py`](../src/abstractmemory/in_memory_store.py)
81
+ - Contract test: [`tests/test_in_memory_query_text_fallback.py`](../tests/test_in_memory_query_text_fallback.py)
82
+
83
+ ### LanceDB (optional, persistent)
84
+
85
+ `abstractmemory.lancedb_store.LanceDBTripleStore` stores assertions in a local-path LanceDB table.
86
+
87
+ Key behavior:
88
+ - Creates the table on first `add(...)` (schema inferred from inserted rows).
89
+ - Stores `provenance`/`attributes` as JSON strings plus a canonical `text` column.
90
+ - Optional vector column when an `embedder` is configured.
91
+
92
+ Evidence:
93
+ - Store implementation: [`src/abstractmemory/lancedb_store.py`](../src/abstractmemory/lancedb_store.py)
94
+ - Persistence test (reopen and query): [`tests/test_lancedb_triple_store.py`](../tests/test_lancedb_triple_store.py)
95
+
96
+ ## Query semantics (deterministic)
97
+
98
+ See also: [`docs/api.md`](api.md)
99
+
100
+ `abstractmemory.store.TripleQuery` supports:
101
+ - Exact matching on canonicalized `subject`/`predicate`/`object`
102
+ - Partitioning via `scope` + `owner_id`
103
+ - Time filters: `since` / `until` over `observed_at`
104
+ - Validity window filtering: `active_at`
105
+ - include if `(valid_from is None or valid_from <= active_at)` and `(valid_until is None or valid_until > active_at)`
106
+ - `valid_until` is **exclusive** (shared across both stores)
107
+ - Semantic queries:
108
+ - `query_text` → embed then vector search (requires embedder)
109
+ - `query_vector` → caller-supplied vector
110
+ - `min_score` → cosine similarity threshold (implemented by both stores)
111
+
112
+ Important implementation detail (timestamps are strings):
113
+ - Both stores compare/filter timestamps as strings.
114
+ - Use ISO-8601/RFC-3339 in UTC (e.g. `2026-01-01T00:00:00+00:00`) to keep ordering predictable.
115
+
116
+ Evidence:
117
+ - Limit semantics (`limit <= 0` means unbounded): [`tests/test_triple_store_limits.py`](../tests/test_triple_store_limits.py)
118
+
119
+ ## Embeddings boundary (no AbstractCore dependency)
120
+
121
+ AbstractMemory defines a minimal `TextEmbedder` protocol and ships an HTTP adapter:
122
+ - `abstractmemory.embeddings.TextEmbedder`: interface used by stores
123
+ - `abstractmemory.embeddings.AbstractGatewayTextEmbedder`: calls an AbstractGateway embeddings endpoint
124
+
125
+ Evidence:
126
+ - Adapter implementation: [`src/abstractmemory/embeddings.py`](../src/abstractmemory/embeddings.py)
127
+
128
+ ## Roadmap (non-binding)
129
+
130
+ Likely next steps (not implemented in this package as of 2026-02-04):
131
+ - More backends (e.g. SQLite reference store) while keeping the same `TripleStore` protocol
132
+ - Higher-level ingestion helpers (still likely owned by gateway/runtime, not this package)
133
+ - Schema evolution and compaction strategies for long-lived stores
134
+
135
+ Next:
136
+ - Getting started: [`docs/getting-started.md`](getting-started.md)
137
+ - API reference: [`docs/api.md`](api.md)
138
+ - FAQ: [`docs/faq.md`](faq.md)
@@ -0,0 +1,31 @@
1
+ # Development
2
+
3
+ ## Local setup
4
+
5
+ Editable install:
6
+
7
+ ```bash
8
+ python -m pip install -e .
9
+ ```
10
+
11
+ Dev extras (tests):
12
+
13
+ ```bash
14
+ python -m pip install -e ".[dev]"
15
+ ```
16
+
17
+ Optional LanceDB tests/backends:
18
+
19
+ ```bash
20
+ python -m pip install -e ".[lancedb]"
21
+ ```
22
+
23
+ ## Run tests
24
+
25
+ ```bash
26
+ python -m pytest -q
27
+ ```
28
+
29
+ Notes:
30
+ - LanceDB-dependent tests are skipped when `lancedb` is not installed. See [`tests/test_lancedb_triple_store.py`](../tests/test_lancedb_triple_store.py).
31
+ - The test suite bootstraps `sys.path` for monorepo layouts (see [`tests/conftest.py`](../tests/conftest.py)).