/** * Computes audience disclosure as the minimum admitted level across non-agent members. * Callers must first verify audience freshness and binding. Missing, malformed, or empty * evidence and resolver failures grant nothing. Per-viewer policy preserves artifact- * disclosure precedence: owner/admin authority, then explicit grants, then scope. */ import type { TrustedDeliveryAudience } from "../security/trusted-delivery-audience.js"; import type { DisclosureSubject } from "../types/memory.js"; import type { UUID } from "../types/primitives.js"; import { type ArtifactDisclosure, type ArtifactDisclosureRecord } from "./artifact-disclosure.js"; /** * The universal disclosure level. Deliberately the SAME type as the artifact * read-side answer — one vocabulary, no parallel enum to drift. */ export type DisclosureLevel = ArtifactDisclosure; /** The admission decision for one subject over one attested audience. */ export interface AudienceAdmission { /** Min over all non-agent members: none < redacted < full. */ level: DisclosureLevel; /** Each evaluated member's individual level. */ perEntity: ReadonlyMap; /** * Members whose level is below the subject's required level (`full` — the * subject as stored; a redacted-capped member still blocks full delivery). */ blockingEntityIds: readonly UUID[]; /** * Members whose resolver threw. They are admitted nothing, exactly like an * explicit deny — but a caller reporting "who blocked this" must be able to * tell a deliberate denial from a resolver that failed, or a broken viewer * lookup looks like a policy decision forever. */ resolverFailureEntityIds: readonly UUID[]; } /** The lower of two disclosure levels (none < redacted < full). */ export declare function minDisclosureLevel(a: DisclosureLevel, b: DisclosureLevel): DisclosureLevel; /** * Maps a subject to the artifact-disclosure record so per-viewer evaluation uses the shared * role/grant/scope precedence. */ export declare function disclosureSubjectRecord(subject: DisclosureSubject): ArtifactDisclosureRecord; /** * Compute the admission an attested audience earns for one disclosure subject. * * Iterates `audience.participantEntityIds` EXCLUDING the agent, evaluates each * member through `resolveViewer` (which must implement the * `resolveArtifactDisclosure` tier order — see `disclosureSubjectRecord`), and * returns the minimum level over all members plus the members blocking the * subject's required level (`"full"`, i.e. the subject as stored — a member * capped at redacted or none blocks unredacted delivery). * * Fail-closed: empty or unattested audiences admit `"none"`; a resolver that * throws or answers with anything but a disclosure level marks that member * `"none"`. A malformed subject scope collapses every member to `"none"` — a * corrupt gate definition cannot widen access. * * Pure and clock-free: attestation freshness/membership drift must already be * verified by the caller via `revalidateOwnerExclusiveDisclosure`-style checks. */ export declare function resolveAudienceAdmission(subject: DisclosureSubject, audience: TrustedDeliveryAudience, resolveViewer: (entityId: UUID) => DisclosureLevel): AudienceAdmission; /** * Build the per-viewer resolver a gate must use over an ATTESTED audience, * derived ONLY from the attestation — never from caller-supplied role fields. * Each member's `AccessContext` is minted from the census: the attested * `agentEntityId` is the agent self-read, the attested `canonicalOwnerEntityId` * is the sole OWNER, and every other participant is a bare USER (no role, no * `isOwner`) so the artifact scope ladder fails closed. The resolver then runs * `resolveArtifactDisclosure` over `disclosureSubjectRecord(subject)`, so gate * admission inherits the exact artifact tier order (agent/OWNER full → grant * beats ladder both directions → owner-private fails closed) with zero I/O. */ export declare function attestedAudienceViewerResolver(subject: DisclosureSubject, audience: TrustedDeliveryAudience): (entityId: UUID) => DisclosureLevel; /** * Gate-side evaluation of the `audience_admission` disclosure policy: the * component is admitted only when the ATTESTED audience as a whole earns FULL * disclosure for `subject`. Returns `undefined` when admitted, or a * human-readable failure reason (mirroring `disclosureGateFailure`'s contract) * when the room caps below full — the reason names the capped level and the * count of blocking members so the denial is diagnosable without leaking who. * * Fail-closed by construction: a missing/unattested audience is passed straight * to `resolveAudienceAdmission`, which returns `none` for unusable evidence; * one ungranted non-agent member caps the room. This never widens access * relative to the owner-exclusive gate — an owner-private grant-free subject * admits full only in the degenerate two-party owner DM. */ export declare function audienceAdmissionGateFailure(subject: DisclosureSubject, audience: TrustedDeliveryAudience | undefined): string | undefined;