Documentation
¶
Overview ¶
Package tenant derives the isolation unit a conversation belongs to.
A tenant is coarser than a session: one Slack channel is one tenant, but that channel may hold many sessions (one per thread, or one per user). The split matters because the two answer different questions:
- SessionID decides which conversation history a turn appends to.
- Tenant decides which working directory that turn runs in.
Keeping them separate is what lets a channel share one workdir across all its threads while each thread keeps its own history.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirName ¶
DirName maps a tenant key to a single safe path segment. Keys carry ':' and platform-chosen characters; a tenant root must never be able to reach a sibling tenant, so anything outside [A-Za-z0-9._-] becomes '_' and a run of dots can not survive.
func FromContext ¶
FromContext reports the tenant behind the current session, or "" when the context carries no session id. Anything that needs per-tenant state — a workspace root, a client pool slot — keys off this rather than re-deriving it.
func Key ¶
Key derives the tenant key from an opaque SessionID by a fixed rule: the platform segment plus the first routing segment.
slack:C123ABC -> slack:C123ABC
slack:C123ABC:U456 -> slack:C123ABC
slack:C123ABC:t:171234.56 -> slack:C123ABC
cli:default -> cli:default
-> "" (no session, no tenant)
Every Slack session scope therefore lands on the same tenant for a given channel, which is why session granularity and workdir granularity can be chosen independently.
This is the only place the rule lives. Platforms stay free to encode whatever they like after the second segment; nothing here parses further.
func LocalDirName ¶ added in v0.1.6
LocalDirName maps a tenant key to a single safe path segment under localBase. When omitPlatform is true, only the first routing segment is used:
slack:C123 -> C123 chat-api:slack_D0AK... -> slack_D0AK...
func RoutingSegment ¶ added in v0.1.6
RoutingSegment returns the first routing segment of a tenant key, dropping the platform prefix.
slack:C123ABC -> C123ABC chat-api:slack_x -> slack_x cli:default -> default bare-id -> bare-id
Types ¶
This section is empty.