import { SubscriptionPersonalAuthorityV2, XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; type SubscriptionProvider = "xai" | "claude"; export type FrozenSubscriptionExecutionAuthority = { snapshot: XaiProviderAccountAuthoritySnapshotV1; subjectId: string | null; }; export declare function subscriptionExecutionAuthorityFromTurn(turn: Pick, provider: SubscriptionProvider): FrozenSubscriptionExecutionAuthority; /** * Resolve the organization or workspace pool for acceptance that has no exact * accepting human (service/operator actors, organization API keys, bridges, * non-subject creators, and internal producers without causal authority). * The result is never user-scoped, so this cannot widen access to a personal * pool. The transaction must already carry the account/workspace RLS context. * Claude is on the shared core (its C3 receipt exists): its v1 value is the * column default, never computed from live state and never read (design 5.3, * "v1 columns after a provider's cutover"). */ export declare function sharedPoolSubscriptionAuthoritySnapshotsInTransaction(_db: Database, _workspaceId: string): Promise<{ xai: XaiProviderAccountAuthoritySnapshotV1; claude: XaiProviderAccountAuthoritySnapshotV1; }>; /** * Pool scope for agent-originated work delivered to `sessionId` (Agent Message, * Agent Steer, agent-submitted prompts). The pool belongs to the receiving * session's accepted work, never to the sender. It comes from, in order: the * receiver's execution-context turn (its latest started user/API turn, the * same context the claim path uses for informational input), its most recently * accepted turn, or its frozen initial snapshot before any turn exists. * * A user-scoped (personal) pool is retained only when its exact owner is the * same human who caused this work. Otherwise the receiver falls back to its * organization or workspace pool, so another human's work never inherits a * personal pool. Call under the receiving session's lock. */ export declare function receiverSubscriptionAuthorityInTransaction(db: Database, input: { workspaceId: string; sessionId: string; causalHumanSubjectId: string | null; }): Promise>; /** * The v2 accepted authority for agent-originated work delivered to * `sessionId` (Agent Message, Agent Steer; design 3.7, EP-T14), for every * provider on the shared core (the frozen value holds each provider's * entry, all with the same owner, so one rule narrows them all): the same * receiving source as the v1 pools above, copied and never recomputed. Its * personal entry is kept only when the receiving source's exact owner is the * human who caused this work; otherwise the empty value (shared capacity * only). A child session without turns uses its exact spawning parent turn's * value. A source accepted before the cutover (no v2 value) yields the empty * value. Returns `null` (write nothing; v1 authoritative) unless some * provider's cutover is active. Call under the receiving session's lock. */ export declare function receiverSubscriptionAuthorityV2InTransaction(db: Database, input: { accountId: string; workspaceId: string; sessionId: string; causalHumanSubjectId: string | null; }): Promise; /** The Codex name of the receiver's v2 value (kept for existing callers). */ export declare const receiverCodexSubscriptionAuthorityV2InTransaction: typeof receiverSubscriptionAuthorityV2InTransaction; /** Reads accepted authority only. This helper never resolves a current account pool. */ export declare function subscriptionAuthorityForTurnInTransaction(db: Database, provider: SubscriptionProvider, workspaceId: string, sessionId: string, turnId: string): Promise; export declare function getAcceptedSubscriptionTurnAuthority(db: Database, provider: SubscriptionProvider, workspaceId: string, sessionId: string, turnId: string): Promise<{ version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; }>; export declare function getAcceptedSubscriptionTaskAuthority(db: Database, provider: SubscriptionProvider, workspaceId: string, taskId: string): Promise; /** * The Codex v2 value a scheduled firing copies (M3 PR 3b, EP-T15): the task's * value frozen at creation, never recomputed. When the task's current * revision was authorized by anyone but its owner, the firing gets the empty * value (another person's edit never inherits the owner's personal entry). */ export declare function getScheduledTaskSubscriptionAuthority(db: Database, input: { workspaceId: string; taskId: string; taskAuthorityRevision?: number; revisionAuthorizerSubjectId: string | null; }): Promise; export declare function getAcceptedSubscriptionParentAuthority(db: Database, provider: SubscriptionProvider, workspaceId: string, childSessionId: string): Promise; export {};