CollectionStore

org.llm4s.rag.permissions.CollectionStore

Storage for collections with permission management.

Manages the hierarchical collection structure and enforces permission inheritance rules:

  • SubCollections inherit parent permissions
  • SubCollections can only add restrictions (never loosen)
  • Documents can only be added to leaf collections

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def canQuery(path: CollectionPath, auth: UserAuthorization): Result[Boolean]

Check if a user can query a collection.

Check if a user can query a collection.

This considers the effective permissions (with inheritance).

Value parameters

auth

The user's authorization context

path

The collection path

Attributes

Returns

True if the user can query this collection

def countChunks(path: CollectionPath): Result[Long]

Count chunks in a collection.

Count chunks in a collection.

Value parameters

path

The collection path

Attributes

Returns

Number of chunks

Count documents in a collection.

Count documents in a collection.

Value parameters

path

The collection path

Attributes

Returns

Number of documents (not chunks)

Create a new collection.

Create a new collection.

Validates that:

  • The parent exists (if not a root collection)
  • Permissions don't loosen parent restrictions
  • The path is valid and not already taken

Value parameters

config

The collection configuration

Attributes

Returns

The created collection, or error

def delete(path: CollectionPath): Result[Unit]

Delete a collection.

Delete a collection.

The collection must be empty (no documents or sub-collections).

Value parameters

path

The collection path

Attributes

Returns

Success or error

Ensure a collection exists, creating it if necessary.

Ensure a collection exists, creating it if necessary.

Creates parent collections as needed (as public, non-leaf).

Value parameters

config

The collection configuration

Attributes

Returns

The existing or newly created collection

Find collections accessible by user matching a pattern.

Find collections accessible by user matching a pattern.

This is the key permission-filtered query used during search. Returns only collections where:

  • Pattern matches, AND
  • User has access (public OR user's principals overlap with queryableBy)

Also respects inheritance - if a parent is not accessible, its children are also not accessible.

Value parameters

auth

The user's authorization context

pattern

The pattern to match

Attributes

Returns

Accessible collections matching the pattern

def get(path: CollectionPath): Result[Option[Collection]]

Get a collection by path.

Get a collection by path.

Value parameters

path

The collection path

Attributes

Returns

The collection if found, None otherwise

def getById(id: Int): Result[Option[Collection]]

Get a collection by its database ID.

Get a collection by its database ID.

Value parameters

id

The collection ID

Attributes

Returns

The collection if found, None otherwise

Get effective permissions for a collection considering inheritance.

Get effective permissions for a collection considering inheritance.

Effective permissions are the intersection of:

  • The collection's own queryableBy, AND
  • All ancestor collections' queryableBy sets

If any ancestor is public (empty queryableBy), that level is skipped. If the collection itself is public, returns empty (meaning public).

Value parameters

path

The collection path

Attributes

Returns

The effective permissions set

def list(pattern: CollectionPattern): Result[Seq[Collection]]

List all collections matching a pattern.

List all collections matching a pattern.

Does NOT apply permission filtering - returns all matching collections. Use findAccessible for permission-filtered queries.

Value parameters

pattern

The pattern to match (default: all)

Attributes

Returns

All matching collections

def listChildren(parentPath: CollectionPath): Result[Seq[Collection]]

List direct children of a collection.

List direct children of a collection.

Value parameters

parentPath

The parent collection path

Attributes

Returns

Direct child collections

Get collection statistics.

Get collection statistics.

Value parameters

path

The collection path

Attributes

Returns

Collection statistics

def updateMetadata(path: CollectionPath, metadata: Map[String, String]): Result[Collection]

Update collection metadata.

Update collection metadata.

Value parameters

metadata

The new metadata (replaces existing)

path

The collection path

Attributes

Returns

The updated collection, or error

Update collection permissions.

Update collection permissions.

Validates that new permissions don't loosen parent restrictions.

Value parameters

path

The collection path

queryableBy

The new set of queryable principals

Attributes

Returns

The updated collection, or error

Concrete methods

def exists(path: CollectionPath): Result[Boolean]

Check if a collection exists.

Check if a collection exists.

Value parameters

path

The collection path

Attributes

Returns

True if exists