Workspace¶
The Workspace dataclass represents a local container for graphs, module state, and the path to the SQLite database file. It is a simple value-object — it holds data but delegates persistence to WorkspaceService and SqliteGraphRepository.
What a Workspace Contains¶
| Field | Type | Description |
|---|---|---|
id |
WorkspaceId |
Unique identifier (UUID v4) |
name |
str |
Human-readable display name |
db_path |
Path |
Absolute path to the SQLite database file |
active_module_ids |
set[str] |
Module IDs currently active in this workspace |
created_at |
datetime |
UTC creation timestamp |
updated_at |
datetime |
UTC last-modified timestamp |
Creating a Workspace¶
Use WorkspaceService.create_workspace() rather than calling Workspace.create() directly — the service also creates the database file and registers the repository.
from knowledge_platform.services.workspace_service import WorkspaceService
svc = WorkspaceService()
ws = svc.create_workspace("Research Notes")
print(ws.db_path) # ~/.knowledge_platform/<uuid>.db
Module Activation¶
Workspaces track which modules are active:
ws.activate_module("outline")
print("outline" in ws.active_module_ids) # True
ws.deactivate_module("outline")
print("outline" in ws.active_module_ids) # False
# Deactivating a non-active module is silent (no error)
ws.deactivate_module("nonexistent")
API Reference¶
knowledge_platform.workspace.workspace.Workspace
dataclass
¶
Aggregates all state for a single user workspace.
A workspace lives in a directory on disk, identified by its id. It owns:
- A reference to the SQLite database path used for persistence.
- The set of module IDs currently active in this workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
WorkspaceId
|
Unique identifier (generated if not provided). |
required |
name
|
str
|
Human-readable display name. |
required |
db_path
|
Path
|
Absolute path to the SQLite database file. |
required |
active_module_ids
|
set[str]
|
Set of module IDs loaded for this workspace. |
set()
|
created_at
|
datetime
|
UTC creation timestamp. |
(lambda: now(utc))()
|
updated_at
|
datetime
|
UTC last-modified timestamp. |
(lambda: now(utc))()
|
Source code in src/knowledge_platform/workspace/workspace.py
Functions¶
activate_module ¶
Mark a module as active in this workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_id
|
str
|
ID of the module to activate. |
required |
Source code in src/knowledge_platform/workspace/workspace.py
create
classmethod
¶
Create a new workspace rooted at directory.
The SQLite file is placed at <directory>/<workspace_id>.db.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Display name for the workspace. |
required |
directory
|
Path
|
Parent directory for the database file. |
required |
Returns:
| Type | Description |
|---|---|
'Workspace'
|
A new :class: |
Source code in src/knowledge_platform/workspace/workspace.py
deactivate_module ¶
Remove a module from the active set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_id
|
str
|
ID of the module to deactivate. |
required |