jnaapakam 0.3.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.
Files changed (47) hide show
  1. jnaapakam-0.3.0/.github/workflows/ci.yml +30 -0
  2. jnaapakam-0.3.0/.github/workflows/release.yml +74 -0
  3. jnaapakam-0.3.0/.gitignore +11 -0
  4. jnaapakam-0.3.0/CHANGELOG.md +108 -0
  5. jnaapakam-0.3.0/CONTRIBUTING.md +94 -0
  6. jnaapakam-0.3.0/LICENSE +21 -0
  7. jnaapakam-0.3.0/PKG-INFO +785 -0
  8. jnaapakam-0.3.0/PROTOCOL.md +1033 -0
  9. jnaapakam-0.3.0/README.md +741 -0
  10. jnaapakam-0.3.0/examples/crewai/README.md +73 -0
  11. jnaapakam-0.3.0/examples/generational-continuity/README.md +303 -0
  12. jnaapakam-0.3.0/examples/langchain/README.md +64 -0
  13. jnaapakam-0.3.0/examples/openclaw/README.md +63 -0
  14. jnaapakam-0.3.0/mcpize.yaml +44 -0
  15. jnaapakam-0.3.0/pyproject.toml +53 -0
  16. jnaapakam-0.3.0/reference/server.py +31 -0
  17. jnaapakam-0.3.0/requirements.txt +1 -0
  18. jnaapakam-0.3.0/schema/IDENTITY.md +6 -0
  19. jnaapakam-0.3.0/schema/MEMORY.md +15 -0
  20. jnaapakam-0.3.0/schema/SOUL.md +28 -0
  21. jnaapakam-0.3.0/schema/USER.md +6 -0
  22. jnaapakam-0.3.0/src/jnaapakam/__init__.py +0 -0
  23. jnaapakam-0.3.0/src/jnaapakam/cli.py +505 -0
  24. jnaapakam-0.3.0/src/jnaapakam/config.py +96 -0
  25. jnaapakam-0.3.0/src/jnaapakam/lineage.py +290 -0
  26. jnaapakam-0.3.0/src/jnaapakam/llm.py +165 -0
  27. jnaapakam-0.3.0/src/jnaapakam/reconcile.py +253 -0
  28. jnaapakam-0.3.0/src/jnaapakam/retention.py +47 -0
  29. jnaapakam-0.3.0/src/jnaapakam/retrieval.py +74 -0
  30. jnaapakam-0.3.0/src/jnaapakam/server.py +788 -0
  31. jnaapakam-0.3.0/src/jnaapakam/store.py +1765 -0
  32. jnaapakam-0.3.0/tests/conftest.py +71 -0
  33. jnaapakam-0.3.0/tests/test_auth.py +75 -0
  34. jnaapakam-0.3.0/tests/test_forgetting.py +158 -0
  35. jnaapakam-0.3.0/tests/test_generation_api.py +480 -0
  36. jnaapakam-0.3.0/tests/test_generation_cli.py +233 -0
  37. jnaapakam-0.3.0/tests/test_generations.py +914 -0
  38. jnaapakam-0.3.0/tests/test_http_api.py +127 -0
  39. jnaapakam-0.3.0/tests/test_llm_parsing.py +49 -0
  40. jnaapakam-0.3.0/tests/test_migration.py +121 -0
  41. jnaapakam-0.3.0/tests/test_model_selection.py +50 -0
  42. jnaapakam-0.3.0/tests/test_namespaces.py +142 -0
  43. jnaapakam-0.3.0/tests/test_reconcile.py +242 -0
  44. jnaapakam-0.3.0/tests/test_retrieval.py +59 -0
  45. jnaapakam-0.3.0/tests/test_review_regressions.py +328 -0
  46. jnaapakam-0.3.0/tests/test_store.py +101 -0
  47. jnaapakam-0.3.0/tests/test_temporal.py +151 -0
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - run: pip install -e ".[dev]"
21
+ - name: Verify SQLite ships FTS5 on this runner
22
+ run: |
23
+ python - <<'PY'
24
+ import sqlite3
25
+ db = sqlite3.connect(":memory:")
26
+ db.execute("CREATE VIRTUAL TABLE t USING fts5(body)")
27
+ print("FTS5 available; sqlite", sqlite3.sqlite_version)
28
+ PY
29
+ - run: ruff check src tests
30
+ - run: pytest -q
@@ -0,0 +1,74 @@
1
+ name: Publish to PyPI
2
+
3
+ # Publishing is irreversible: a version number can never be reused on PyPI, even
4
+ # after deletion. So this runs only on an explicit tag, and the release job is
5
+ # gated behind a GitHub Environment you can require manual approval on.
6
+ on:
7
+ push:
8
+ tags: ["v*"]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Run the full test suite before building
24
+ run: |
25
+ pip install -e ".[dev]"
26
+ ruff check src tests
27
+ pytest -q
28
+
29
+ - name: Refuse to publish a version that is not release-ready
30
+ run: |
31
+ python - <<'PY'
32
+ import re, pathlib, sys
33
+ version = re.search(
34
+ r'^version = "([^"]+)"', pathlib.Path("pyproject.toml").read_text(), re.M
35
+ ).group(1)
36
+ print(f"pyproject version: {version}")
37
+ if any(marker in version for marker in ("dev", "a", "b", "rc")):
38
+ sys.exit(f"Refusing to publish pre-release version {version!r}. Set a final version first.")
39
+ PY
40
+
41
+ - name: Build sdist and wheel
42
+ run: |
43
+ pip install build
44
+ python -m build
45
+
46
+ - name: Verify the artifacts are well-formed
47
+ run: |
48
+ pip install twine
49
+ twine check dist/*
50
+
51
+ - uses: actions/upload-artifact@v4
52
+ with:
53
+ name: dist
54
+ path: dist/
55
+
56
+ publish:
57
+ needs: build
58
+ runs-on: ubuntu-latest
59
+ # Configure this environment in repo Settings โ†’ Environments and add a required
60
+ # reviewer if you want a human approval step before anything reaches PyPI.
61
+ environment:
62
+ name: pypi
63
+ url: https://pypi.org/p/jnaapakam
64
+ permissions:
65
+ # Required for Trusted Publishing. No API token is stored anywhere.
66
+ id-token: write
67
+ steps:
68
+ - uses: actions/download-artifact@v4
69
+ with:
70
+ name: dist
71
+ path: dist/
72
+
73
+ - name: Publish
74
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ *.db
2
+ *.egg-info/
3
+ *.pyc
4
+ .env
5
+ .venv/
6
+ .worktrees/
7
+ __pycache__/
8
+ build/
9
+ dist/
10
+ inbox/
11
+ uv.lock
@@ -0,0 +1,108 @@
1
+ # Changelog
2
+
3
+ All notable changes to jรฑฤpakaแน are recorded here. The protocol specification is
4
+ [PROTOCOL.md](PROTOCOL.md); this file tracks the reference implementation.
5
+
6
+ ## [0.3.0] โ€” 2026-08-31
7
+
8
+ **Generational continuity.** An agent's model, runtime, tools, hardware and
9
+ capabilities may all change without changing its continuity identity.
10
+
11
+ This is a claim about systems, not minds: jรฑฤpakaแน defines a stable identifier, a
12
+ verifiable memory corpus, an auditable lineage and migration provenance. It makes
13
+ no claim about consciousness or subjective identity.
14
+
15
+ ### Added
16
+
17
+ - **Permanent agent identity** โ€” `urn:jnaapakam:agent:<32 hex>`, minted once and
18
+ independent of the agent's display name, model, provider, runtime, host,
19
+ hardware, OS and generation number. Opening an existing database mints one
20
+ automatically.
21
+ - **Generations** โ€” a portable record of the runtime an agent ran as, with an
22
+ optional manifest describing runtime, inference, environment, hardware,
23
+ workspace revision, capabilities and external state. Every section is optional;
24
+ a minimal generation is `{}`. Unknown sections are preserved verbatim.
25
+ - **Branch-capable lineage** โ€” generations name a parent, so two candidates staged
26
+ from one parent do not corrupt each other's ancestry.
27
+ - **Migration records** โ€” provenance for every transition, with statuses `staged`,
28
+ `validated`, `failed`, `promoted`, `rejected` and `rolled_back`.
29
+ - **Continuity validation** โ€” six checks (`identity`, `memory`, `recall`, `soul`,
30
+ `context`, `behavioral`), each reporting its own result. A check that was not
31
+ requested reports `skipped`, never `pass`.
32
+ - **Integrity metadata** โ€” SHA-256 over the exact bytes of soul files, plus an
33
+ order-independent digest over the memory corpus that survives a restore
34
+ renumbering every row.
35
+ - **Endpoints** โ€” `GET /agent`, `GET /generations`, `GET /generations/diff`,
36
+ `GET /migrations`; `POST /generations`, `/generations/artifacts`,
37
+ `/generations/validate`, `/generations/promote`, `/generations/reject`,
38
+ `/generations/rollback`. All behind the existing bearer authentication.
39
+ - **MCP tools** โ€” `get_agent_identity`, `list_generations`, `diff_generations`.
40
+ Read-only: deciding which runtime *is* the agent stays an operator action, the
41
+ same reason `/clear` and `/restore` are not MCP tools.
42
+ - **CLI** โ€” `jnaapakam agent` and `jnaapakam generation {list,show,create,seal,
43
+ validate,promote,reject,rollback,diff}`. These open the database directly, so
44
+ continuity works offline with no server, token or network. `validate` exits
45
+ non-zero on failure, which makes it usable as a migration gate.
46
+ - **Schema** โ€” `meta`, `generations`, `migrations` and `generation_artifacts`
47
+ tables; `PRAGMA user_version` 3 โ†’ 4.
48
+ - **Example** โ€” [examples/generational-continuity](examples/generational-continuity/),
49
+ a vendor-neutral Generation 1 โ†’ Generation 2 walkthrough.
50
+
51
+ ### Changed
52
+
53
+ - `/backup` now carries `agent_id`, `current_generation`, `corpus_digest`,
54
+ `generations`, `migrations` and `artifacts`. Soul files remain excluded, exactly
55
+ as in v0.2 โ€” only their digests travel.
56
+ - `/restore` adopts the backup's `agent_id` when the target store has no lineage
57
+ of its own, and refuses a different agent when it does. Re-importing an agent's
58
+ own backup no longer forks its lineage.
59
+ - `version` reported by `/status` and `/backup` is now `"0.3"`; the server and MCP
60
+ `serverInfo` report `0.3.0`.
61
+ - The full-text index backfill is gated on `user_version < 3` rather than on the
62
+ current schema version, so future schema bumps no longer trigger a pointless
63
+ reindex.
64
+
65
+ ### Security
66
+
67
+ - Generation manifests and external-state references are treated as untrusted
68
+ metadata: never executed, never dereferenced, never used to build a filesystem
69
+ path, and never placed in an LLM prompt.
70
+ - Manifests carrying a field named like a credential, or a reference URI with
71
+ embedded userinfo, are refused. Manifest size and nesting depth are bounded.
72
+ - The server never reads a file to hash it. Digests arrive precomputed; the CLI
73
+ does the reading, locally, restricted to soul filenames in a directory the
74
+ operator names. An endpoint that hashes a caller-supplied path would be an
75
+ arbitrary-file-read oracle.
76
+ - Artifact names must be plain labels and are rejected if they could be resolved
77
+ against a filesystem.
78
+ - `/restore` validates the entire payload, including manifests and digests, before
79
+ mutating anything.
80
+
81
+ ### Not in this release
82
+
83
+ - **Signatures.** v0.3 provides integrity, not authenticity: a digest proves the
84
+ bytes did not change, but anyone who can write the store can write a digest.
85
+ Do not read one as the other.
86
+
87
+ ### Compatibility
88
+
89
+ - Every v0.2 test passes unchanged.
90
+ - A v0.2 database opens and upgrades in place, gaining an identity without losing
91
+ a memory.
92
+ - A v0.2 backup still restores.
93
+ - A v0.3 backup restored by a v0.2 implementation imports its memories and
94
+ consolidations and ignores the continuity keys โ€” the lineage is dropped, not
95
+ corrupted.
96
+ - The only breaking change is the `version` string, and only for a client
97
+ asserting it exactly.
98
+
99
+ ## [0.2.0]
100
+
101
+ Retrieval as a protocol operation (`/search`, ranking requirements); enforceable
102
+ namespaces; memory correction by supersession; gated contradiction detection and
103
+ soft forgetting; bearer authentication and safe bind defaults; error semantics;
104
+ corrected default port and `/backup` payload.
105
+
106
+ ## [0.1.0]
107
+
108
+ Initial protocol specification and reference implementation.
@@ -0,0 +1,94 @@
1
+ # Contributing to jรฑฤpakaแน
2
+
3
+ Thanks for your interest in contributing! Here's how to get started.
4
+
5
+ ## Areas We Need Help With
6
+
7
+ - ๐Ÿท๏ธ **Multi-agent namespacing** โ€” the largest open design question; see PROTOCOL.md ยง6
8
+ - ๐Ÿงฌ **Signed continuity records** โ€” v0.3 gives integrity, not authenticity; see PROTOCOL.md ยง10.6
9
+ - ๐Ÿ”Œ **Integration examples** โ€” more framework integrations (AutoGen, Semantic Kernel, ADK, etc.)
10
+ - ๐Ÿค– **LLM providers** โ€” additional backend support (Groq, Together, Mistral, local models)
11
+ - ๐Ÿ“Š **Memory visualization** โ€” dashboard or CLI tools to browse memories
12
+ - ๐Ÿ”’ **Security** โ€” encryption at rest
13
+ - ๐Ÿ“ **Benchmarks** โ€” retrieval quality and latency at realistic memory scales
14
+ - ๐Ÿ“ **Documentation** โ€” tutorials, guides, use case examples
15
+
16
+ ## Development Setup
17
+
18
+ ```bash
19
+ git clone https://github.com/yablokolabs/jnaapakam.git
20
+ cd jnaapakam
21
+ python -m venv .venv && source .venv/bin/activate
22
+ pip install -e ".[dev]"
23
+ ```
24
+
25
+ ## Running the Test Suite
26
+
27
+ ```bash
28
+ pytest # all tests
29
+ pytest -q tests/test_store.py
30
+ ruff check src tests # lint
31
+ ```
32
+
33
+ Tests need no API key, no network, and no database setup: the suite uses a
34
+ deterministic rule-based LLM stand-in and temporary SQLite files.
35
+
36
+ To run the server locally:
37
+
38
+ ```bash
39
+ export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY, or LLM_BASE_URL
40
+ jnaapakam serve
41
+ ```
42
+
43
+ ## How to Contribute
44
+
45
+ 1. Fork the repo
46
+ 2. Create a feature branch: `git checkout -b feature/my-feature`
47
+ 3. **Write a failing test first**, then make it pass
48
+ 4. Run `pytest` and `ruff check src tests`
49
+ 5. Submit a PR
50
+
51
+ ## Guidelines
52
+
53
+ - Keep the protocol simple โ€” complexity is the enemy
54
+ - No vendor lock-in โ€” everything should work with any LLM provider
55
+ - Privacy first โ€” no telemetry, no external calls except to the configured LLM
56
+ - Document your changes
57
+
58
+ ## Testing Guidelines
59
+
60
+ The suite is the specification. A few rules that keep it useful:
61
+
62
+ - **Test behavior, not implementation.** Assert on what an endpoint returns or what
63
+ ends up in the store โ€” never that a particular function was called.
64
+ - **Don't assert on mocks.** The LLM stand-in in `tests/conftest.py` is a real
65
+ implementation with deterministic rules. Prefer extending it over patching.
66
+ - **Don't test data shapes for their own sake.** A test that only checks a dict has
67
+ certain keys tells you nothing about whether the system works.
68
+ - **Failure paths matter as much as success paths.** A silently degraded memory is
69
+ worse than a loud error; several tests exist specifically to prevent that.
70
+ - **New model IDs need a guard.** Provider models get retired, and a retired ID
71
+ returns 404. `tests/test_model_selection.py` fails the build if a shipped alias
72
+ points at a known-retired model โ€” add to its list when a model is withdrawn.
73
+
74
+ ## Code Style
75
+
76
+ - Python: PEP 8, type hints appreciated. `ruff` config lives in `pyproject.toml`
77
+ - Keep runtime dependencies minimal โ€” `aiohttp` is the only one, and additions need
78
+ a strong justification. Anything that requires a daemon, a compiled extension, or
79
+ a network call at first run must be optional and runtime-detected
80
+ - Docstrings on public functions; explain *why*, not *what*
81
+
82
+ ## Protocol Changes
83
+
84
+ Changes to `PROTOCOL.md` require discussion in an issue first. The protocol should remain:
85
+ - Simple to implement
86
+ - Framework agnostic
87
+ - Backward compatible when possible
88
+
89
+ When a change is not backward compatible, say so explicitly in the version history
90
+ table and describe what breaks.
91
+
92
+ ## License
93
+
94
+ By contributing, you agree that your contributions will be licensed under the MIT License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yabloko Labs
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.