import { type TurnInitiator, type TurnInitiatorContext } from "@opengeni/contracts"; import type { Database } from "./database.js"; import type { SessionCommandActor } from "./session-control.js"; export declare const UNATTRIBUTED_LEGACY_INITIATOR: TurnInitiator; export type FrozenTurnInitiator = { initiator: TurnInitiator; context: TurnInitiatorContext; /** Exact causal human frozen only after the caller/attempt authority is validated. */ initiatingHumanSubjectId?: string | null; }; /** The scheduler label is frozen authority proof shared with migrations 0275/0414, * not presentation copy. Preserve its exact historical bytes. * A legacy task has no asserted service identity. Its occurrence is still * initiated by the scheduler, not by the missing-attribution sentinel. */ export declare function frozenScheduledOccurrenceInitiator(task: { createdBy: TurnInitiator; createdByContext: TurnInitiatorContext; }, scheduler: FrozenTurnInitiator): FrozenTurnInitiator; /** Read only private, server-frozen lineage/context, never request JSON. */ export declare function frozenCredentialRestriction(context: Readonly> | null | undefined): "developer_setup" | undefined; /** Every coalesced causal source retains its ceiling, not only the first one. */ export declare function contextWithFrozenCredentialRestrictions(context: TurnInitiatorContext, sources: readonly (Readonly> | null | undefined)[]): TurnInitiatorContext; /** * Bound agent provenance without discarding its causal authority. Once the * chain exceeds the cap, retain the first hop and the newest hops in order; * consumers can still identify the root attempt while recent diagnostics stay * useful. The omitted middle is signalled separately by `viaTruncated`. */ export declare function clipAgentProvenanceHops(hops: Array>): Array>; export declare function initiatorContextForStorage(initiator: TurnInitiator, context?: TurnInitiatorContext): TurnInitiatorContext; export declare function initiatorFromStorage(kind: string, subjectId: string, context: TurnInitiatorContext): TurnInitiator; /** * Who sent a person's message, for the model: the label frozen with the turn * at acceptance (never re-read). Service, key, agent and scheduler turns have * no person behind the prompt, so they get none. */ export declare function humanTurnSenderLabel(row: { initiatorKind: string; initiatorContext: unknown; }): string | null; /** * Whether two messages come from the same sender: the same person, or for a * message without a person behind it (a workspace key, a service), the same * exact sender. A queue edit keeps its message's authority, including the * sender's own (Only me) accounts, only when its own sender resubmits it; * anyone else's edit is their own new message. */ export declare function sameTurnSender(left: Pick, right: Pick): boolean; export declare function initiatorColumns(value: FrozenTurnInitiator): { initiatorKind: TurnInitiator["kind"]; initiatorSubjectId: string; initiatorContext: TurnInitiatorContext; }; export declare function creatorColumns(value: FrozenTurnInitiator): { createdByKind: TurnInitiator["kind"]; createdBySubjectId: string; createdByContext: TurnInitiatorContext; }; /** Freeze the exact target turn's provenance without changing the new service principal. */ export declare function contextForCausalTurn(current: TurnInitiatorContext, causal: FrozenTurnInitiator, reference: { sessionId: string; turnId: string; }): TurnInitiatorContext; export declare function frozenInitiatorForCommandActor(db: Database, workspaceId: string, actor: SessionCommandActor, subjectLabel?: string): Promise;