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:

  1. Create builder with this method

  2. Configure dependencies using builder methods

  3. Call build() to create container instance

  4. Call initialize() to load state and start background processes

  5. Use container for predictions and learning

  6. 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

userId

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

IllegalArgumentException

if userId is null, empty, or contains invalid characters