engrammic-primitives 0.1.0__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.
- engrammic_primitives-0.1.0/.github/workflows/ci.yml +54 -0
- engrammic_primitives-0.1.0/.github/workflows/publish.yml +40 -0
- engrammic_primitives-0.1.0/.github/workflows/release-please.yml +43 -0
- engrammic_primitives-0.1.0/.gitignore +63 -0
- engrammic_primitives-0.1.0/.release-please-manifest.json +3 -0
- engrammic_primitives-0.1.0/CHANGELOG.md +25 -0
- engrammic_primitives-0.1.0/LICENSE +21 -0
- engrammic_primitives-0.1.0/PKG-INFO +68 -0
- engrammic_primitives-0.1.0/README.md +50 -0
- engrammic_primitives-0.1.0/context/README.md +50 -0
- engrammic_primitives-0.1.0/context/specs/01-paradigm.md +48 -0
- engrammic_primitives-0.1.0/context/specs/02-layers.md +89 -0
- engrammic_primitives-0.1.0/context/specs/03-transitions.md +70 -0
- engrammic_primitives-0.1.0/context/specs/04-metacognition.md +193 -0
- engrammic_primitives-0.1.0/context/specs/05-mcp-contract.md +282 -0
- engrammic_primitives-0.1.0/context/specs/06-epistemology.md +88 -0
- engrammic_primitives-0.1.0/context/specs/07-agent-usage.md +144 -0
- engrammic_primitives-0.1.0/docs/architecture-decision.md +165 -0
- engrammic_primitives-0.1.0/docs/brainstorm/2026-04-26-agent-harness-split.md +75 -0
- engrammic_primitives-0.1.0/docs/brainstorm/README.md +54 -0
- engrammic_primitives-0.1.0/docs/manifesto.md +56 -0
- engrammic_primitives-0.1.0/docs/specs/cag-queries.md +1318 -0
- engrammic_primitives-0.1.0/docs/specs/cag-schema.md +753 -0
- engrammic_primitives-0.1.0/docs/specs/mcp-tools.md +184 -0
- engrammic_primitives-0.1.0/justfile +79 -0
- engrammic_primitives-0.1.0/pyproject.toml +54 -0
- engrammic_primitives-0.1.0/release-please-config.json +24 -0
- engrammic_primitives-0.1.0/src/primitives/__init__.py +6 -0
- engrammic_primitives-0.1.0/src/primitives/eag/__init__.py +44 -0
- engrammic_primitives-0.1.0/src/primitives/eag/agents/__init__.py +34 -0
- engrammic_primitives-0.1.0/src/primitives/eag/agents/base.py +135 -0
- engrammic_primitives-0.1.0/src/primitives/eag/agents/tools.py +77 -0
- engrammic_primitives-0.1.0/src/primitives/eag/epistemology/__init__.py +45 -0
- engrammic_primitives-0.1.0/src/primitives/eag/epistemology/confidence.py +138 -0
- engrammic_primitives-0.1.0/src/primitives/eag/epistemology/promotion.py +119 -0
- engrammic_primitives-0.1.0/src/primitives/eag/epistemology/supersession.py +119 -0
- engrammic_primitives-0.1.0/src/primitives/eag/lifecycle.py +127 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/__init__.py +113 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/cluster.py +125 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/ddl.py +82 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/finding.py +164 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/pass_ledger.py +97 -0
- engrammic_primitives-0.1.0/src/primitives/eag/queries/silo.py +54 -0
- engrammic_primitives-0.1.0/src/primitives/eag/store.py +87 -0
- engrammic_primitives-0.1.0/src/primitives/eag/transitions/__init__.py +11 -0
- engrammic_primitives-0.1.0/src/primitives/eag/transitions/predicates.py +30 -0
- engrammic_primitives-0.1.0/src/primitives/extensions/__init__.py +1 -0
- engrammic_primitives-0.1.0/src/primitives/extensions/code.py +41 -0
- engrammic_primitives-0.1.0/src/primitives/protocols.py +337 -0
- engrammic_primitives-0.1.0/src/primitives/py.typed +0 -0
- engrammic_primitives-0.1.0/src/primitives/schema/__init__.py +65 -0
- engrammic_primitives-0.1.0/src/primitives/schema/edges.py +74 -0
- engrammic_primitives-0.1.0/src/primitives/schema/labels.py +123 -0
- engrammic_primitives-0.1.0/src/primitives/scoring/__init__.py +7 -0
- engrammic_primitives-0.1.0/src/primitives/scoring/decay.py +27 -0
- engrammic_primitives-0.1.0/src/primitives/shared/__init__.py +32 -0
- engrammic_primitives-0.1.0/src/primitives/shared/cypher/__init__.py +17 -0
- engrammic_primitives-0.1.0/src/primitives/shared/cypher/helpers.py +64 -0
- engrammic_primitives-0.1.0/src/primitives/shared/fingerprints.py +87 -0
- engrammic_primitives-0.1.0/src/primitives/shared/validators.py +109 -0
- engrammic_primitives-0.1.0/src/primitives/taxonomy/__init__.py +13 -0
- engrammic_primitives-0.1.0/src/primitives/taxonomy/categories.py +39 -0
- engrammic_primitives-0.1.0/tests/test_confidence.py +147 -0
- engrammic_primitives-0.1.0/tests/test_decay.py +75 -0
- engrammic_primitives-0.1.0/tests/test_promotion.py +133 -0
- engrammic_primitives-0.1.0/tests/test_supersession.py +131 -0
- engrammic_primitives-0.1.0/uv.lock +421 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
run: uv python install ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: uv sync --all-extras
|
|
27
|
+
|
|
28
|
+
- name: Run linter
|
|
29
|
+
run: uv run ruff check src tests
|
|
30
|
+
|
|
31
|
+
- name: Run type checker
|
|
32
|
+
run: uv run mypy src
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: uv run pytest tests -v
|
|
36
|
+
|
|
37
|
+
build:
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
needs: test
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: Install uv
|
|
45
|
+
uses: astral-sh/setup-uv@v4
|
|
46
|
+
|
|
47
|
+
- name: Build package
|
|
48
|
+
run: uv build
|
|
49
|
+
|
|
50
|
+
- name: Upload dist
|
|
51
|
+
uses: actions/upload-artifact@v4
|
|
52
|
+
with:
|
|
53
|
+
name: dist
|
|
54
|
+
path: dist/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [release]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v4
|
|
16
|
+
|
|
17
|
+
- name: Build package
|
|
18
|
+
run: uv build
|
|
19
|
+
|
|
20
|
+
- name: Upload dist
|
|
21
|
+
uses: actions/upload-artifact@v4
|
|
22
|
+
with:
|
|
23
|
+
name: dist
|
|
24
|
+
path: dist/
|
|
25
|
+
|
|
26
|
+
publish:
|
|
27
|
+
needs: build
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
environment: pypi
|
|
30
|
+
permissions:
|
|
31
|
+
id-token: write
|
|
32
|
+
steps:
|
|
33
|
+
- name: Download dist
|
|
34
|
+
uses: actions/download-artifact@v4
|
|
35
|
+
with:
|
|
36
|
+
name: dist
|
|
37
|
+
path: dist/
|
|
38
|
+
|
|
39
|
+
- name: Publish to PyPI
|
|
40
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Release Please
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
pull-requests: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release-please:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
outputs:
|
|
15
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
|
16
|
+
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: googleapis/release-please-action@v4
|
|
20
|
+
id: release
|
|
21
|
+
with:
|
|
22
|
+
config-file: release-please-config.json
|
|
23
|
+
manifest-file: .release-please-manifest.json
|
|
24
|
+
|
|
25
|
+
publish:
|
|
26
|
+
needs: release-please
|
|
27
|
+
if: ${{ needs.release-please.outputs.release_created }}
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
environment: pypi
|
|
30
|
+
permissions:
|
|
31
|
+
id-token: write
|
|
32
|
+
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
|
|
36
|
+
- name: Install uv
|
|
37
|
+
uses: astral-sh/setup-uv@v4
|
|
38
|
+
|
|
39
|
+
- name: Build package
|
|
40
|
+
run: uv build
|
|
41
|
+
|
|
42
|
+
- name: Publish to PyPI
|
|
43
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
|
|
24
|
+
# Virtual environments
|
|
25
|
+
.venv/
|
|
26
|
+
venv/
|
|
27
|
+
ENV/
|
|
28
|
+
env.bak/
|
|
29
|
+
venv.bak/
|
|
30
|
+
|
|
31
|
+
# IDE
|
|
32
|
+
.idea/
|
|
33
|
+
.vscode/
|
|
34
|
+
*.swp
|
|
35
|
+
*.swo
|
|
36
|
+
*~
|
|
37
|
+
|
|
38
|
+
# Testing
|
|
39
|
+
.pytest_cache/
|
|
40
|
+
.coverage
|
|
41
|
+
.coverage.*
|
|
42
|
+
htmlcov/
|
|
43
|
+
.mypy_cache/
|
|
44
|
+
.ruff_cache/
|
|
45
|
+
.hypothesis/
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
|
|
49
|
+
# OS
|
|
50
|
+
.DS_Store
|
|
51
|
+
Thumbs.db
|
|
52
|
+
|
|
53
|
+
# Environment
|
|
54
|
+
.env
|
|
55
|
+
.envrc
|
|
56
|
+
*.local
|
|
57
|
+
|
|
58
|
+
# UV
|
|
59
|
+
.uv/
|
|
60
|
+
|
|
61
|
+
# Claude Code
|
|
62
|
+
.claude/
|
|
63
|
+
CLAUDE.md
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project 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).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-05-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- EAG (Epistemic Augmented Generation) paradigm implementation
|
|
15
|
+
- CITE schema with four cognitive layers: Memory, Knowledge, Wisdom, Intelligence
|
|
16
|
+
- Node types: Claim, Fact, Insight, Principle, Strategy, Model
|
|
17
|
+
- Edge types for layer transitions and relationships
|
|
18
|
+
- Scoring primitives: decay, freshness, confidence
|
|
19
|
+
- Promotion and supersession logic
|
|
20
|
+
- KnowledgeStore, LifecycleManager, SignalProvider protocols
|
|
21
|
+
- Code-specific extensions
|
|
22
|
+
- Taxonomy definitions
|
|
23
|
+
|
|
24
|
+
[Unreleased]: https://github.com/anthropics/primitives/compare/v0.1.0...HEAD
|
|
25
|
+
[0.1.0]: https://github.com/anthropics/primitives/releases/tag/v0.1.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Delta Prime
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: engrammic-primitives
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: EAG schema primitives for epistemic context management
|
|
5
|
+
Author-email: Aliasgar Khimani <aliasgar.khimani@engrammic.ai>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: ai-agents,context-management,graphrag,knowledge-graph
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.13
|
|
16
|
+
Requires-Dist: pydantic>=2.0
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Engrammic Primitives
|
|
20
|
+
|
|
21
|
+
EAG schema primitives for building epistemic context systems.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install engrammic-primitives
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from primitives.schema import MemoryNode, KnowledgeNode, WisdomNode
|
|
33
|
+
from primitives.eag import CognitiveTier
|
|
34
|
+
|
|
35
|
+
# Create a memory node
|
|
36
|
+
node = MemoryNode(
|
|
37
|
+
content="User prefers dark mode",
|
|
38
|
+
importance=0.7,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Check cognitive tier
|
|
42
|
+
tier = CognitiveTier.MEMORY
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## When to Use
|
|
46
|
+
|
|
47
|
+
Building your own EAG-compatible system or extending Engrammic.
|
|
48
|
+
|
|
49
|
+
For using Engrammic directly, see:
|
|
50
|
+
- [engrammic-mcp](https://github.com/engrammic/mcp-client) - hosted service
|
|
51
|
+
- [engrammic-engine](https://github.com/engrammic/engine) - local engine
|
|
52
|
+
|
|
53
|
+
## Learn More
|
|
54
|
+
|
|
55
|
+
- [EAG Manifesto](docs/manifesto.md) - the paradigm explained
|
|
56
|
+
|
|
57
|
+
## Modules
|
|
58
|
+
|
|
59
|
+
| Module | Purpose |
|
|
60
|
+
|--------|---------|
|
|
61
|
+
| `primitives.schema` | Node and edge type definitions |
|
|
62
|
+
| `primitives.eag` | EAG-specific implementations |
|
|
63
|
+
| `primitives.protocols` | Storage and lifecycle interfaces |
|
|
64
|
+
| `primitives.scoring` | Decay and freshness formulas |
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
Apache 2.0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Engrammic Primitives
|
|
2
|
+
|
|
3
|
+
EAG schema primitives for building epistemic context systems.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install engrammic-primitives
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from primitives.schema import MemoryNode, KnowledgeNode, WisdomNode
|
|
15
|
+
from primitives.eag import CognitiveTier
|
|
16
|
+
|
|
17
|
+
# Create a memory node
|
|
18
|
+
node = MemoryNode(
|
|
19
|
+
content="User prefers dark mode",
|
|
20
|
+
importance=0.7,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Check cognitive tier
|
|
24
|
+
tier = CognitiveTier.MEMORY
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## When to Use
|
|
28
|
+
|
|
29
|
+
Building your own EAG-compatible system or extending Engrammic.
|
|
30
|
+
|
|
31
|
+
For using Engrammic directly, see:
|
|
32
|
+
- [engrammic-mcp](https://github.com/engrammic/mcp-client) - hosted service
|
|
33
|
+
- [engrammic-engine](https://github.com/engrammic/engine) - local engine
|
|
34
|
+
|
|
35
|
+
## Learn More
|
|
36
|
+
|
|
37
|
+
- [EAG Manifesto](docs/manifesto.md) - the paradigm explained
|
|
38
|
+
|
|
39
|
+
## Modules
|
|
40
|
+
|
|
41
|
+
| Module | Purpose |
|
|
42
|
+
|--------|---------|
|
|
43
|
+
| `primitives.schema` | Node and edge type definitions |
|
|
44
|
+
| `primitives.eag` | EAG-specific implementations |
|
|
45
|
+
| `primitives.protocols` | Storage and lifecycle interfaces |
|
|
46
|
+
| `primitives.scoring` | Decay and freshness formulas |
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
Apache 2.0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# CAG — Cognitive Augmented Generation
|
|
2
|
+
|
|
3
|
+
Reference documentation for the CAG paradigm implemented in this library.
|
|
4
|
+
|
|
5
|
+
## What is CAG
|
|
6
|
+
|
|
7
|
+
CAG (Cognitive Augmented Generation) is a four-layer cognitive architecture for AI agents. Information flows through distinct persistence regimes:
|
|
8
|
+
|
|
9
|
+
- **Memory** — experiences that fade (Gaussian decay)
|
|
10
|
+
- **Knowledge** — facts that persist until contradicted (indefinite supersession)
|
|
11
|
+
- **Wisdom** — beliefs that revise on evidence shift (evidence-gated revision)
|
|
12
|
+
- **Intelligence** — ephemeral reasoning (session-scoped)
|
|
13
|
+
|
|
14
|
+
Unlike RAG, CAG adjudicates (via a Custodian), tracks provenance, supports supersession, and shapes itself around usage (heat). Extraction produces structured claims; the epistemology library is deterministic.
|
|
15
|
+
|
|
16
|
+
Source: arxiv:2604.11364v1 — *The Missing Knowledge Layer in Cognitive Architectures for AI Agents*.
|
|
17
|
+
|
|
18
|
+
## What this library provides
|
|
19
|
+
|
|
20
|
+
`primitives` implements the open, deterministic parts of CAG:
|
|
21
|
+
|
|
22
|
+
- **Epistemology** — confidence math, contradiction detection, promotion rules (R1/R2), corroboration. Pure functions, no LLM at decision time.
|
|
23
|
+
- **Signals** — heat, freshness, priority scoring formulas.
|
|
24
|
+
- **Schema** — node type definitions, `PersistenceLayer` enum, edge catalogue.
|
|
25
|
+
- **Protocols** — `KnowledgeStore`, `LifecycleManager`, `SignalProvider`, `ProvenanceTracker`.
|
|
26
|
+
- **Shared utilities** — used across modules.
|
|
27
|
+
|
|
28
|
+
What is NOT in this library (proprietary to the service layer):
|
|
29
|
+
|
|
30
|
+
- Custodian workers (promotion, synthesis, revision scheduling)
|
|
31
|
+
- Extraction prompts and LLM orchestration
|
|
32
|
+
- Graph + vector write paths
|
|
33
|
+
- Storage backends (Memgraph, Qdrant, Redis, Postgres)
|
|
34
|
+
- API and MCP interface
|
|
35
|
+
|
|
36
|
+
## Specs index
|
|
37
|
+
|
|
38
|
+
| Doc | Contents |
|
|
39
|
+
|-----|----------|
|
|
40
|
+
| [specs/01-paradigm.md](specs/01-paradigm.md) | Why CAG, the category error in RAG, when CAG pays off |
|
|
41
|
+
| [specs/02-layers.md](specs/02-layers.md) | KMWI layer semantics, node types, scoring formulas |
|
|
42
|
+
| [specs/03-transitions.md](specs/03-transitions.md) | Transition catalogue (T1-T9), execution rules, provenance |
|
|
43
|
+
| [specs/06-epistemology.md](specs/06-epistemology.md) | Deterministic primitives: confidence, contradiction, corroboration, provenance invariants |
|
|
44
|
+
|
|
45
|
+
## Reading order
|
|
46
|
+
|
|
47
|
+
1. [01-paradigm.md](specs/01-paradigm.md) — what and why
|
|
48
|
+
2. [02-layers.md](specs/02-layers.md) — KMWI taxonomy
|
|
49
|
+
3. [03-transitions.md](specs/03-transitions.md) — architecture lives here
|
|
50
|
+
4. [06-epistemology.md](specs/06-epistemology.md) — deterministic primitives (maps directly to this library's API)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# 01 — Paradigm: CAG (Cognitive Augmented Generation)
|
|
2
|
+
|
|
3
|
+
## The category error in RAG
|
|
4
|
+
|
|
5
|
+
Plain RAG retrieves documents and appends them to a prompt. Systems built on top tend to apply **one persistence model** (usually some form of decay) uniformly to all information they store. This conflates:
|
|
6
|
+
|
|
7
|
+
- A Slack message from yesterday ("I'm thinking we should use Dagster")
|
|
8
|
+
- A validated fact ("OAuth refresh tokens expire in 30 days")
|
|
9
|
+
- A pattern synthesised from dozens of observations ("this team ships on Fridays")
|
|
10
|
+
- A reasoning chain generated for the current query
|
|
11
|
+
|
|
12
|
+
These have *different persistence semantics*. A decaying Slack message is correct; a decaying validated fact is a bug. The paper (arxiv:2604.11364v1) calls this a category error.
|
|
13
|
+
|
|
14
|
+
## The CAG move
|
|
15
|
+
|
|
16
|
+
Split persistence into four layers, each with its own semantics:
|
|
17
|
+
|
|
18
|
+
| Layer | Semantics | Example |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| **Memory** | Gaussian decay — experiences fade | "User asked about auth on 2026-04-21 14:32" |
|
|
21
|
+
| **Knowledge** | Indefinite supersession — facts until contradicted | "OAuth refresh tokens expire in 30 days" |
|
|
22
|
+
| **Wisdom** | Evidence-gated revision — beliefs update on shift | "This team ships on Fridays" |
|
|
23
|
+
| **Intelligence** | Ephemeral — temporary inference | "For this query, I considered facts A, B, C" |
|
|
24
|
+
|
|
25
|
+
## Four distinctions from RAG
|
|
26
|
+
|
|
27
|
+
CAG is not RAG-with-extras. It differs structurally:
|
|
28
|
+
|
|
29
|
+
1. **Multi-layered persistence** — no single decay model; each layer has its own rules
|
|
30
|
+
2. **Active adjudication** — the Custodian promotes, supersedes, validates. Retrieval is one verb among many
|
|
31
|
+
3. **Usage-shaped** — attention (heat) drives priority for maintenance transitions, not just retrieval
|
|
32
|
+
4. **Graph-structured claim-level extraction** — claims (structured triples), not chunks, are the unit of knowledge
|
|
33
|
+
|
|
34
|
+
## What CAG is *not*
|
|
35
|
+
|
|
36
|
+
- Not a replacement for plain RAG in all contexts — when you just want cheap retrieval-augmented prompting, RAG is fine
|
|
37
|
+
- Not about bigger embeddings or better retrieval tricks; the architecture is the thesis
|
|
38
|
+
- Not AGI-adjacent; it's bookkeeping for agent-authored information, not cognition itself
|
|
39
|
+
|
|
40
|
+
## When CAG pays off
|
|
41
|
+
|
|
42
|
+
CAG's overhead (Custodian, provenance, multi-layer scoring) is justified when:
|
|
43
|
+
- Agents operate over long horizons where facts change
|
|
44
|
+
- Multiple agents share a knowledge substrate and disagree
|
|
45
|
+
- Audit / compliance / temporal queries matter ("what did we believe on 2026-03-01?")
|
|
46
|
+
- Information has authorship that needs tracking (who said what, when)
|
|
47
|
+
|
|
48
|
+
It's overkill for: chat-with-your-PDF, single-agent short-horizon tasks, purely factual FAQ retrieval.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# 02 — The Four Layers (KMWI)
|
|
2
|
+
|
|
3
|
+
## Memory
|
|
4
|
+
|
|
5
|
+
**Semantics:** Gaussian decay. Experiences fade over time. Retrieval weight drops toward zero but content is preserved (until hard-deleted per the Cold Memory policy — see erasure rules).
|
|
6
|
+
|
|
7
|
+
**Node types:**
|
|
8
|
+
- `:Document` — an ingested source (file, page, transcript)
|
|
9
|
+
- `:Passage` — a chunk within a Document
|
|
10
|
+
- `:Utterance` — something an agent or human said in a conversation
|
|
11
|
+
- `:Event` — a system-observed occurrence (tool called, ingestion ran)
|
|
12
|
+
|
|
13
|
+
**Scoring:** `similarity × fresh(t) × heat × proximity(candidate, query_anchors)`
|
|
14
|
+
- `fresh(t)` is the Gaussian per-class decay (ephemeral 7d, standard 90d, durable 540d, permanent 5y)
|
|
15
|
+
- `heat` is ambient access-recency PPR (Heat-PPR)
|
|
16
|
+
- `proximity` is query-time ego-graph PPR (Anchor-PPR)
|
|
17
|
+
|
|
18
|
+
## Knowledge
|
|
19
|
+
|
|
20
|
+
**Semantics:** indefinite supersession. Facts persist until contradicted. No time decay.
|
|
21
|
+
|
|
22
|
+
**Node types:**
|
|
23
|
+
- `:Fact` — a validated proposition
|
|
24
|
+
- `:Claim` — an extracted proposition awaiting promotion (unpromoted Claim is persistent but scored lower)
|
|
25
|
+
|
|
26
|
+
**Structural rule:** every `:Fact` has at least one `DERIVED_FROM` edge to a Memory-layer source. No orphan Facts.
|
|
27
|
+
|
|
28
|
+
**Supersession:** when a new Fact contradicts an existing Fact, the Custodian writes `(:Fact_new)-[:SUPERSEDES]->(:Fact_old)` with `reason ∈ {'contradiction', 'evidence_shift', 'author_update', 'evidence_erased'}`. The old Fact remains queryable — audit and temporal queries (`as_of`) walk the SUPERSEDES chain.
|
|
29
|
+
|
|
30
|
+
**Scoring:** `similarity × confidence × corroboration × proximity × NOT_superseded`
|
|
31
|
+
|
|
32
|
+
## Wisdom
|
|
33
|
+
|
|
34
|
+
**Semantics:** evidence-gated revision. Beliefs update when the underlying fact distribution shifts past a threshold, not on a clock.
|
|
35
|
+
|
|
36
|
+
**Node types:**
|
|
37
|
+
- `:Belief` — a synthesised judgment over many Facts
|
|
38
|
+
- `:Pattern` — a recurring shape detected across Facts
|
|
39
|
+
- `:Commitment` — a declared stance (agent-authored)
|
|
40
|
+
- `:ProposedBelief` — a weak synthesis awaiting validation (status: pending/accepted/rejected)
|
|
41
|
+
|
|
42
|
+
**Transitions in:** Knowledge → Wisdom via synthesis (cluster density threshold). Knowledge → Wisdom via propose (weak confidence creates ProposedBelief). Wisdom → Wisdom via revision (distribution shift >= M%). ProposedBelief → Belief via accept. ProposedBelief → tombstone via reject.
|
|
43
|
+
|
|
44
|
+
Revision writes a new `:Belief` with a `SUPERSEDES` edge to the old Belief, `reason='evidence_shift'`. Old Beliefs remain queryable for audit and `as_of` temporal queries — Beliefs are never replaced in place.
|
|
45
|
+
|
|
46
|
+
> **Cross-layer exception:** `:Commitment` is structurally a Knowledge-layer Claim subtype (multi-labeled `:Claim:Commitment`, SPO-structured, predicate-registry-governed) but carries Wisdom-layer semantics (authored stance via `DECLARED_BY`, reconcilable by the `commitment_reconciler`, revisable on author update). This is the single cross-layer node type in CAG; every other node belongs to exactly one layer.
|
|
47
|
+
|
|
48
|
+
**Scoring:** `similarity × evidence_strength × underlying_fact_recency × proximity × wisdom_status_multiplier`
|
|
49
|
+
- `wisdom_status ∈ {'active', 'stale'}`; stale Beliefs score at 0.1x (defined by erasure cascade)
|
|
50
|
+
|
|
51
|
+
## Intelligence
|
|
52
|
+
|
|
53
|
+
**Semantics:** ephemeral inference. Session-scoped. Temporary computational state.
|
|
54
|
+
|
|
55
|
+
**Node types:**
|
|
56
|
+
- `:ReasoningChain` — a stored reasoning sequence with steps inlined as a `steps: list[ChainStep]` JSON property (not separate nodes)
|
|
57
|
+
- `:QueryContext` — the working set assembled for a specific query
|
|
58
|
+
- `:WorkingHypothesis` — an agent's in-progress hypothesis during reasoning (session-scoped, mutable)
|
|
59
|
+
|
|
60
|
+
**Promotion paths out:**
|
|
61
|
+
- `Intelligence → Knowledge` via consensus: >= K chains from effective_J >= threshold agents agree → promote to Fact
|
|
62
|
+
- `Intelligence → Memory` via trace: reasoning chain completes → compact trace stored as experience
|
|
63
|
+
- `Intelligence → Wisdom` via commit: agent declares a stance from session work → Commitment
|
|
64
|
+
|
|
65
|
+
**Scoring:** session-scoped only. Not retrieved cross-session (the session-end trace lives in Memory afterwards).
|
|
66
|
+
|
|
67
|
+
## Why these four (and not three or five)
|
|
68
|
+
|
|
69
|
+
- Three (conflating Knowledge and Wisdom) loses the authored-vs-synthesised distinction. A Commitment is not a Fact; a Belief about team patterns is not a Fact either. Both are Wisdom.
|
|
70
|
+
- Five (splitting Memory into raw-vs-compressed) is a storage tier, not a persistence-semantics distinction. Doesn't deserve top-level status.
|
|
71
|
+
- The four map cleanly onto distinct transition rules and distinct retrieval-scoring needs. That's the architectural test.
|
|
72
|
+
|
|
73
|
+
## Layer tagging
|
|
74
|
+
|
|
75
|
+
Every node carries a `PersistenceLayer` enum:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
class PersistenceLayer(str, Enum):
|
|
79
|
+
MEMORY = "memory"
|
|
80
|
+
KNOWLEDGE = "knowledge"
|
|
81
|
+
WISDOM = "wisdom"
|
|
82
|
+
INTELLIGENCE = "intelligence"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Used for:
|
|
86
|
+
- Retrieval scoring dispatch
|
|
87
|
+
- Custodian worker routing
|
|
88
|
+
- Telemetry grouping
|
|
89
|
+
- Erasure cascade classification
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# 03 — Transitions: the architecture lives here
|
|
2
|
+
|
|
3
|
+
The layers themselves are a taxonomy. The **transitions** between them define the system's behaviour.
|
|
4
|
+
|
|
5
|
+
## Transition diagram
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Memory --- extract ---> Knowledge --- synthesize ---> Wisdom
|
|
9
|
+
| | | |
|
|
10
|
+
| v v |
|
|
11
|
+
| supersede propose revise
|
|
12
|
+
| (Knowledge-> (creates (Wisdom->Wisdom
|
|
13
|
+
| Knowledge) ProposedBelief) on evidence shift)
|
|
14
|
+
v |
|
|
15
|
+
decay accept/reject
|
|
16
|
+
(retrieval (ProposedBelief ->
|
|
17
|
+
weight -> 0) Belief or tombstone)
|
|
18
|
+
|
|
19
|
+
Intelligence -- consensus ---> Knowledge
|
|
20
|
+
Intelligence -- trace -------> Memory
|
|
21
|
+
Intelligence -- commit ------> Wisdom (Commitment)
|
|
22
|
+
Intelligence -- crystallize -> Wisdom (from WorkingHypothesis)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Transition catalogue
|
|
26
|
+
|
|
27
|
+
| # | Transition | Trigger predicate | Execution | Priority |
|
|
28
|
+
|---|---|---|---|---|
|
|
29
|
+
| T1 | **Memory -> Knowledge** (extract) | passage is hot OR source-changed OR cold-but-queried | signal-driven | `heat × (1 / last_extracted_at)` |
|
|
30
|
+
| T2 | **Knowledge -> Knowledge** (supersede) | new Fact's (s, p, o) conflicts with existing Fact | eager (synchronous in validator) | N/A |
|
|
31
|
+
| T3 | **Knowledge -> Wisdom** (synthesize) | cluster density >= N AND no current Belief covers it | signal-driven | `heat × cluster_density` |
|
|
32
|
+
| T4 | **Wisdom -> Wisdom** (revise) | distribution shift >= M% since last synthesis | signal-driven — Revision = supersede-with-new-Belief, not in-place edit. Preserves audit chain. | `heat × shift_magnitude` |
|
|
33
|
+
| T5 | **Intelligence -> Knowledge** (consensus) | >= K reasoning chains from effective_J >= J agents agree | lazy | consensus timestamp |
|
|
34
|
+
| T6 | **Intelligence -> Memory** (trace) | reasoning chain completes | batched post-session | session end time |
|
|
35
|
+
| T7 | **Intelligence -> Wisdom** (commit) — writes `:Claim:Commitment` (Knowledge-structure, Wisdom-semantics) | agent declares a stance | eager | N/A |
|
|
36
|
+
| T8 | **Memory -> ⊥** (decay) | time-based; retrieval weight -> 0 | compute-at-query | N/A |
|
|
37
|
+
| T9 | **Memory -> ⊥** (hard-delete) | `age > 2 × class.σ` OR GDPR | scheduled GC (hard-delete default) | `age` |
|
|
38
|
+
| T10 | **Knowledge -> Wisdom** (propose) | synthesis confidence in weak range (above min, below auto-promote) | signal-driven | `heat × confidence` |
|
|
39
|
+
| T11 | **Wisdom -> Wisdom** (accept) | validator accepts ProposedBelief | eager | N/A |
|
|
40
|
+
| T12 | **Wisdom -> ⊥** (reject) | validator rejects ProposedBelief | eager | N/A |
|
|
41
|
+
| T13 | **Intelligence -> Wisdom** (crystallize) | agent crystallizes WorkingHypothesis | eager | N/A |
|
|
42
|
+
|
|
43
|
+
## The execution rule
|
|
44
|
+
|
|
45
|
+
- **Eager** for correctness-critical transitions (T2 supersession, T7 commit)
|
|
46
|
+
- **Signal-driven + heat-ranked** for optimisation transitions (T1 extract, T3 synthesize, T4 revise)
|
|
47
|
+
- **Batched / lazy / scheduled** for housekeeping (T5 consensus, T6 trace, T8/T9 decay)
|
|
48
|
+
|
|
49
|
+
## Why transitions, not layers, are the architecture
|
|
50
|
+
|
|
51
|
+
If you know the four layers but not the transitions, you can't build CAG. The layers tell you *what exists*; the transitions tell you *what moves*. A CAG implementation is largely the sum of its transition workers.
|
|
52
|
+
|
|
53
|
+
Consequence: the Custodian (service-layer proprietary) is internally structured as one worker per transition, plus a shared epistemology library. Transitions are first-class design objects.
|
|
54
|
+
|
|
55
|
+
The epistemology library in this package implements the deterministic decision functions that underlie T1, T2, T3, T5, and T7. Scheduling and execution of the transitions themselves lives in the service layer.
|
|
56
|
+
|
|
57
|
+
## Provenance across transitions
|
|
58
|
+
|
|
59
|
+
Every transition that creates a node writes a provenance edge back to its source(s):
|
|
60
|
+
|
|
61
|
+
- T1 extract: `(:Claim)-[:DERIVED_FROM]->(:Passage)` (Extraction owns)
|
|
62
|
+
- T2 supersede: `(:Fact_new)-[:SUPERSEDES]->(:Fact_old)` with reason + timestamp
|
|
63
|
+
- T3 synthesize: `(:Belief)-[:SYNTHESIZED_FROM]->(:Fact)+` (>= N required)
|
|
64
|
+
- T5 consensus: `(:Fact)-[:PROMOTED_FROM]->(:ReasoningChain)+`
|
|
65
|
+
- T6 trace: `(:ReasoningChain)-[:DERIVED_FROM_EVIDENCE]->(:Document|:Passage|:Claim)+`; optionally `(:ReasoningChain)-[:CRYSTALLIZED_INTO]->(:Claim)` for crystallizations
|
|
66
|
+
- T7 commit: `(:Claim:Commitment)-[:DECLARED_BY]->(:Agent)` (per D1); `CRYSTALLIZED_INTO` used for Intelligence->Knowledge linkage
|
|
67
|
+
- T10 propose: `(:ProposedBelief)-[:SYNTHESIZED_FROM]->(:Fact)+` (same as T3, but creates proposal)
|
|
68
|
+
- T11 accept: `(:Belief)-[:PROMOTED_FROM]->(:ProposedBelief)` with `accepted_at` timestamp
|
|
69
|
+
- T12 reject: `(:ProposedBelief)` marked `status='rejected'` with `reason` and `rejected_at`
|
|
70
|
+
- T13 crystallize: `(:Commitment)-[:CRYSTALLIZED_FROM]->(:WorkingHypothesis)`
|