feat: implement custom context separation profiles (#36)#80
Open
Archita-29 wants to merge 2 commits into
Open
Conversation
keepsloading
requested changes
Jul 11, 2026
keepsloading
left a comment
Member
There was a problem hiding this comment.
@AYUSH-P-SINGH I've reviewed your PR. Overall the separation looks interesting, but I have to request some architectural changes.
- Hardcoded Partitions: Currently you are falling back to
"db_work"whenever a partition isn't found. This couples the identity provider codebase explicitly to a specific context profile type ("work"), which breaks the provider-independent and category-agnostic vision. Partitions shouldn't be hardcoded into the gateway logic like this. - Missing Implementation: In
src/server.mjs, you importbuildCapPacketfrom Memory but then you removed the API credits endpoint without explanation. - Storage Abstraction: The partition logic assumes a single flat store that magically understands
db_work. As per our new architecture roadmap, the storage layer is migrating to SQLite. Context separation profiles should ideally be modeled in the database schema (e.g., via aprofile_idlinking to an identity profile), rather than hardcoding partition keys in the HTTP headers.
Please revise the partition routing logic to be dynamic and agnostic to the actual profile name (e.g., "work", "play", "travel"), and we can proceed. Thanks!
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.
Resolves #36
Summary
This PR implements isolated database partitioning (db_work, db_play, db_travel) to provide strict context separation across user environments, resolving cross-profile context leakage as outlined in #36.
Protocol Alignment
[x] CAP — Context Access Protocol
[x] CCP — Context Contribution Protocol
[x] CRP — Context Rectification Protocol
[ ] Identity Address
[ ] Discovery
[ ] Evidence Model
[ ] Temporal Decay
[ ] Provider Independence
[ ] Documentation
[ ] Community Health
[ ] Other: ___
Changes Made
Data Layer (src/store.mjs)
Updated internal data structures to support an optional database_partition string field across schemas.
Default fallback handles unpartitioned incoming data by routing it safely to "db_work".
Service Layer (src/service.mjs)
Ingestion: Updated ingestCaptureEvent and proposeWikiContext to extract the active partition from options/body parameters and stamp the records appropriately.
Retrieval & Isolation: Updated data retrieval methods (listCaptureEvents, listMemory, listSchemas) to strictly filter records matching the requested target partition, preventing cross-profile context pollution.
API Layer (src/server.mjs)
Added a readDatabasePartition helper utility to cleanly parse out the active profile via the custom X-Database-Partition header or the database_partition query string parameter.
Forwarded the evaluated partition into the matching service layer actions (propose, rectify, request).
Updated CORS Access-Control-Allow-Headers rules to safely permit the X-Database-Partition custom header across browser contexts.