documentation update
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
# Memory Isolation
|
||||
|
||||
NexusAI implements project-scoped memory — sessions belonging to the same
|
||||
project can share semantic context, and isolated projects can be restricted
|
||||
from drawing on memory outside the project. This document describes how the
|
||||
system works end-to-end.
|
||||
project share semantic context within that project's boundary. All projects
|
||||
are isolated by default.
|
||||
|
||||
## Concepts
|
||||
|
||||
**Session** — a single conversation thread. Identified by `external_id`.
|
||||
|
||||
**Project** — a named grouping of sessions. Has an `isolated` flag (0 or 1).
|
||||
**Project** — a named grouping of sessions. `isolated` is always `1` —
|
||||
the toggle has been removed from the UI and `isolated: 1` is hardcoded on
|
||||
project creation.
|
||||
|
||||
**Semantic search** — at inference time, the user's message is embedded and
|
||||
compared against past episodes in Qdrant to surface relevant context. The
|
||||
@@ -20,11 +21,10 @@ scope of this search is controlled by the project context.
|
||||
| Session state | Semantic search scope |
|
||||
|---|---|
|
||||
| No project | Own session's episodes only |
|
||||
| Assigned to a non-isolated project | All episodes across all sessions in the project |
|
||||
| Assigned to an isolated project | All episodes within the project only |
|
||||
| Assigned to a project | All episodes across all sessions in that project |
|
||||
| Removed from a project | Own session's episodes only (from that point) |
|
||||
|
||||
Sessions with no project assigned behave the same as they always have —
|
||||
Sessions with no project assigned behave as they always have —
|
||||
only their own past episodes are searched.
|
||||
|
||||
## How It Works
|
||||
@@ -44,16 +44,9 @@ if (session.project_id) {
|
||||
}
|
||||
```
|
||||
|
||||
If the session belongs to any project (isolated or not), `projectSessionIds`
|
||||
is populated with the internal integer IDs of all sessions in that project.
|
||||
|
||||
For **non-isolated projects**, this expands the search to all project sessions.
|
||||
For **isolated projects**, the same set is used but the intent is restriction
|
||||
— since `projectSessionIds` only contains project sessions, no external
|
||||
episodes can appear.
|
||||
|
||||
Both cases use the same code path — the `isolated` flag does not change the
|
||||
query logic, only the conceptual meaning.
|
||||
If the session belongs to any project, `projectSessionIds` is populated with
|
||||
the internal integer IDs of all sessions in that project — creating a shared
|
||||
memory pool across all conversations in the project.
|
||||
|
||||
### Step 2 — Qdrant filter construction
|
||||
|
||||
@@ -96,26 +89,11 @@ message, `getProjectSessions` will not include that session's ID, so its
|
||||
episodes disappear from the semantic search scope.
|
||||
|
||||
**New sessions created from ProjectView are assigned after the first message.**
|
||||
The `useChat` hook writes the `project_id` assignment via `updateSession` after
|
||||
`onDone` fires. There is a brief window during the first message where the
|
||||
session has no project assigned. The project is correctly applied from the
|
||||
second message onward.
|
||||
|
||||
## Isolated vs Non-Isolated
|
||||
|
||||
The `isolated` flag is stored on the project but does not currently change the
|
||||
query logic — both isolated and non-isolated projects result in a
|
||||
`projectSessionIds` filter. The distinction is semantic and enforced by
|
||||
the project's membership:
|
||||
|
||||
- **Non-isolated** — intentionally draws from all sessions in the project,
|
||||
creating a shared memory pool for related conversations
|
||||
- **Isolated** — by design contains only sessions explicitly added to it,
|
||||
so the same filter naturally restricts context to project-only episodes
|
||||
|
||||
If cross-project contamination became a concern (e.g. a session accidentally
|
||||
added to the wrong project), removing it from the project immediately restores
|
||||
isolation.
|
||||
`handleNewProjectChat` in `App.jsx` calls `sendMessage` with the project ID,
|
||||
which is passed to `useChat`. After `onDone` fires, `useChat` calls
|
||||
`updateSession` to write the project assignment to the backend. There is a
|
||||
brief window during the first message where the session has no project assigned.
|
||||
The project is correctly applied from the second message onward.
|
||||
|
||||
## Qdrant Payload Structure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user