forUser
Initiates the container configuration process for a specified user identity.
This method creates a new builder instance scoped to a specific user ID, enabling multi-tenant scenarios where multiple users can have independent KARL containers within the same application instance. Each user's data, learning state, and interactions are completely isolated from other users.
User ID considerations:
Must be unique and stable across application sessions
Used as the primary key for data storage and retrieval operations
Should follow your application's user identification scheme
Cannot be changed after container creation without losing learned state
Container lifecycle:
Create builder with this method
Configure dependencies using builder methods
Call build() to create container instance
Call initialize() to load state and start background processes
Use container for predictions and learning
Call saveState() and release() when shutting down
Return
A new KarlContainerBuilder instance configured with the specified user ID, ready for dependency configuration and container instantiation.
Parameters
The unique, persistent identifier for the user. This identifier must remain consistent across application sessions to maintain continuity of learned behaviors and stored state. The ID is used as the primary key for all user-scoped data operations including interaction storage, model state persistence, and instruction management.
See also
for configuration options
for container lifecycle operations
Throws
if userId is null, empty, or contains invalid characters