Documentation
¶
Overview ¶
Package project provides multi-project isolation for contextd-v2.
Project Representation:
Each project represents a user's codebase with:
- Unique project ID (UUID)
- Project name (user-friendly)
- Project path (filesystem location)
- Isolated collections in Qdrant
Collection Naming:
Each project gets isolated collections:
- {project_id}_memories
- {project_id}_checkpoints
- {project_id}_remediations
- {project_id}_sessions
This provides physical isolation between user projects.
Manager Interface:
The Manager provides CRUD operations for projects:
- Create: Create new project with unique ID
- Get: Retrieve project by ID
- List: List all projects
- Delete: Remove project and associated collections
- GetByPath: Find project by filesystem path
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrProjectNotFound = errors.New("project not found") ErrProjectExists = errors.New("project already exists") ErrInvalidProjectID = errors.New("invalid project ID") ErrInvalidProjectName = errors.New("invalid project name") ErrInvalidProjectPath = errors.New("invalid project path") ErrEmptyProjectID = errors.New("project ID cannot be empty") ErrEmptyProjectName = errors.New("project name cannot be empty") ErrEmptyProjectPath = errors.New("project path cannot be empty") )
Common errors.
Functions ¶
func GetAllCollectionNames ¶
GetAllCollectionNames returns all collection names for a project.
func GetCollectionName ¶
func GetCollectionName(projectID string, collectionType CollectionType) (string, error)
GetCollectionName returns the collection name for a project and type. Format: {sanitized_project_id}_{type}
The project ID is sanitized to conform to collection name requirements:
- Lowercase only
- Hyphens and special chars replaced with underscores
- Multiple underscores collapsed
Examples:
- "simple-ctl" -> "simple_ctl_memories"
- "my-project" -> "my_project_checkpoints"
Types ¶
type CollectionType ¶
type CollectionType string
CollectionType represents the type of data stored in a collection.
const ( // CollectionMemories stores ReasoningBank memories. CollectionMemories CollectionType = "memories" // CollectionCheckpoints stores session checkpoints. CollectionCheckpoints CollectionType = "checkpoints" // CollectionRemediations stores error fix patterns. CollectionRemediations CollectionType = "remediations" // CollectionSessions stores session traces. CollectionSessions CollectionType = "sessions" // CollectionCodebase stores code embeddings. CollectionCodebase CollectionType = "codebase" )
type Manager ¶
type Manager interface {
// Create creates a new project with the given name and path.
Create(ctx context.Context, name, path string) (*Project, error)
// Get retrieves a project by ID.
Get(ctx context.Context, id string) (*Project, error)
// List returns all projects.
List(ctx context.Context) ([]*Project, error)
// Delete removes a project by ID.
Delete(ctx context.Context, id string) error
// GetByPath finds a project by its filesystem path.
GetByPath(ctx context.Context, path string) (*Project, error)
}
Manager provides CRUD operations for projects.
func NewManager ¶
func NewManager() Manager
NewManager creates a new project manager with in-memory storage.
type Project ¶
type Project struct {
// ID is the unique project identifier (UUID).
ID string `json:"id"`
// Name is the human-readable project name.
Name string `json:"name"`
// Path is the filesystem location of the project.
Path string `json:"path"`
// CreatedAt is when the project was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the project was last modified.
UpdatedAt time.Time `json:"updated_at"`
}
Project represents a user's codebase with isolated collections.
func NewProject ¶
NewProject creates a new project with a generated UUID.