/**
 * Structural reader for the tenancy contract `@adonis-agora/context` publishes on its global slots.
 * Never imports that package: with the slot missing, too old, or throwing, tenancy reads as OFF, so
 * the agent behaves exactly as it does without tenancy.
 *
 * The tenant here is the customer a piece of data belongs to (an organization, a clinic…), not a
 * process topology.
 */
import type { ActorResolver } from '../spi/actor-resolver.js';
import type { Actor } from '../types.js';
/** One level of a tenant chain. */
export interface TenantLevel {
    id: string;
    kind: string;
    slug?: string;
    role?: string;
}
/** The active tenant, as context publishes it. */
export interface TenantRef extends TenantLevel {
    source: string;
    parents?: TenantLevel[];
    family?: string;
}
/** How a read or write must be scoped right now. */
export type TenantFilter = {
    mode: 'system';
} | {
    mode: 'all';
} | {
    mode: 'tenantless';
} | {
    mode: 'tenant';
    tenant: TenantRef;
    chain?: TenantLevel[];
};
/** The agent's `tenancy` option (`config/agent.ts`). */
export type AgentTenancyOption = 'inherit' | false | {
    /** `'inherit'` (default) follows `tenancy.enabled` in `config/context.ts`. */
    enabled?: 'inherit' | boolean;
    /** Tenant kinds the agent honours; another kind reads as no tenant. Default: context's. */
    kinds?: string[];
    /**
     * Rows with no tenant: `'tenantless'` (default) shows them only to requests without a tenant;
     * `'shared'` also shows them inside every tenant.
     */
    nullRows?: 'tenantless' | 'shared';
};
/** {@link AgentTenancyOption} resolved against context. */
export interface ResolvedAgentTenancy {
    enabled: boolean;
    kinds?: string[];
    nullRows: 'tenantless' | 'shared';
}
/** Resolve the agent's `tenancy` option. With no (or an old) context, tenancy is off. */
export declare function resolveAgentTenancy(option: AgentTenancyOption | undefined): ResolvedAgentTenancy;
/**
 * How the current request (or job) must be scoped. Tenancy off → `system` (nothing filtered). A
 * tenant of a kind the agent does not honour reads as `tenantless`.
 */
export declare function currentTenantFilter(tenancy: ResolvedAgentTenancy): TenantFilter;
/** The tenant id to stamp on a write right now: the tenant's id in `tenant` mode, else `null`. */
export declare function currentTenantRef(tenancy: ResolvedAgentTenancy): string | null;
/**
 * Whether a row stamped `rowTenant` is visible under `filter` (the matching rule every Agora lib
 * applies). Invisible rows are answered as not found.
 */
export declare function tenantVisible(filter: TenantFilter, rowTenant: string | null | undefined, nullRows?: 'tenantless' | 'shared'): boolean;
/** A tenant set to scope reads by: these ids, plus rows with no tenant when `includeNull`. */
export interface TenantScope {
    tenants: readonly string[];
    includeNull: boolean;
}
/** The {@link TenantScope} of a filter, or `undefined` for "no filtering" (`system` / `all`). */
export declare function scopeOfFilter(filter: TenantFilter, nullRows?: 'tenantless' | 'shared'): TenantScope | undefined;
/** Whether `tenantRef` is inside `scope` (`undefined` scope = everything). */
export declare function inScope(scope: TenantScope | undefined, tenantRef: string | null | undefined): boolean;
/** Display labels for tenant ids, from context's label resolver; ids map to themselves otherwise. */
export declare function tenantLabels(ids: string[], kind?: string): Promise<Record<string, string>>;
/**
 * `actor` with `tenantRef` filled from the active tenant when tenancy is on and the actor has none.
 * A resolver that set `tenantRef` wins.
 */
export declare function withTenantRef(actor: Actor, tenancy: ResolvedAgentTenancy | undefined): Actor;
/** An actor resolver whose actors carry the active tenant (see {@link withTenantRef}). */
export declare function tenantFillingResolver(resolver: ActorResolver, tenancy: ResolvedAgentTenancy): ActorResolver;
//# sourceMappingURL=tenancy.d.ts.map