feat(kp3): Implement Unified Cognitive Memory Architecture API#26
Open
feat(kp3): Implement Unified Cognitive Memory Architecture API#26
Conversation
Implements the cognitive memory API as designed in
docs/unified-cognitive-memory-architecture.md:
Foundation tier (Refs & Derivations):
- GET/PUT/DELETE /refs/{ref_name:path} with optimistic locking
- GET /refs/{ref_name:path}/history - version history
- GET /refs - list refs with prefix filter
- GET /passages/{id}/sources - derivation sources
- GET /passages/{id}/derived - derived passages
Cognitive tier (Frames & Cognition):
- POST /frames - create cognitive frame
- GET /frames/{name} - get frame
- GET /frames - list frames
- POST /frames/{name}/fork - fork frame
- POST /frames/{name}/activate - activate frame
- POST /frames/{name}/resolve - resolve to frozen snapshot
- POST /cognition/increment - atomic state transitions
New files:
- schemas.py: Pydantic models for all API endpoints
- cognitive_router.py: FastAPI router for cognitive endpoints
- frames.py: Frame service implementation
- cognition.py: Cognition increment service with optimistic locking
E2E test coverage:
- Scenarios A-T from the design document
- HTTP API tests for all new endpoints
- 16 tests passing against testcontainers Postgres
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the Unified Cognitive Memory Architecture API as designed in
docs/unified-cognitive-memory-architecture.md:Foundation tier (Refs & Derivations):
/refs/{ref_name:path}with optimistic locking (version-based conflict detection)/refs/{ref_name:path}/history- version history tracking/refs- list refs with prefix filter/passages/{id}/sources- derivation provenance/passages/{id}/derived- derived passagesCognitive tier (Frames & Cognition):
/frames- create cognitive frame/frames/{name}, GET/frames- get/list frames/frames/{name}/fork- fork frame for experimentation/frames/{name}/activate- activate frame/frames/{name}/resolve- resolve to frozen snapshot/cognition/increment- atomic state transitions with optimistic lockingNew files:
schemas.py: Pydantic models for all API endpointscognitive_router.py: FastAPI router for cognitive endpointsframes.py: Frame service implementationcognition.py: Cognition increment service with optimistic locking, idempotency, and rollbackTest plan
uv run pytest tests/test_cognitive_e2e.py)To run tests locally:
🤖 Generated with Claude Code