import { KeyObject } from "node:crypto"; import { ContractValidationError, type StoreValidationResult } from "./canonical.ts"; import { BOSS_RUN_FEATURE, type BossParticipantBinding } from "./boss-wire.ts"; import type { BrokerGeneration, BrokerRevision, ParticipantBindingEpoch, SubscriberBindingEpoch, SubscriberBindingGeneration } from "./canonical.ts"; import { type BossPolicyState } from "./boss-policy.ts"; import { type ParticipantState } from "./boss-participant-state.ts"; import { type LifecycleSubscriptionRecord, type LifecycleTarget } from "./supervision.ts"; import { INTERCOM_BASE_PROTOCOL_VERSION } from "./boss-semantic-binding-constants.ts"; export { INTERCOM_BASE_PROTOCOL_VERSION }; export declare const BROKER_FEATURE_ATTESTATION_VERSION: "intercom.broker-feature.v1"; export declare const BROKER_IDENTITY_RECORD_VERSION: "intercom.broker-identity.v1"; export declare const BROKER_PROVIDER_ATTESTATION_VERSION: "intercom.broker-provider-attestation.v1"; export declare const BROKER_PEER_EXPECTATION_VERSION: "intercom.broker-peer-expectation.v1"; export declare const LEGACY_ADMIN_MIGRATION_VERSION: "intercom.legacy-admin-migration.v1"; export declare const BROKER_JOURNAL_RECOVERY_VERSION: "intercom.broker-journal-recovery.v1"; export declare const BOSS_RESTRICTED_CLIENT_REQUEST_VERSION: "boss.restricted-client-request.v1"; export declare const BOSS_RESTRICTED_CLIENT_RESULT_VERSION: "boss.restricted-client-result.v1"; export declare const BROKER_FEATURE_SET_HASH_DOMAIN: "agent-intercom-core/broker-feature-set/v1"; export declare const BROKER_IDENTITY_SIGNATURE_DOMAIN: "agent-intercom-core/broker-identity/v1"; export declare const BROKER_PROVIDER_ATTESTATION_SIGNATURE_DOMAIN: "agent-intercom-core/broker-provider-attestation/v1"; export declare const BROKER_PROTECTED_PROVIDER_ROOT: "/usr/lib/agent-intercom/providers/"; export interface BrokerFeatureAttestation { version: typeof BROKER_FEATURE_ATTESTATION_VERSION; feature: string; featureVersion: number; semanticsHash: string; controlEnvelopeVersion?: number; capabilityDigest?: string; optional?: true; } export declare function parseBrokerFeatureAttestation(value: unknown): BrokerFeatureAttestation; export interface BrokerCapabilityAdvertisement { baseProtocolVersion: number; features: BrokerFeatureAttestation[]; protocolFeatureContractHash?: string; featureSetHash?: string; controlEnvelopeVersion?: number; capabilityDigest?: string; } export type BrokerCapabilityAdvertisementDenialCode = "UNKNOWN_FEATURE" | "DUPLICATE_FEATURE" | "FEATURE_DIVERGENCE"; export declare class BrokerCapabilityAdvertisementError extends ContractValidationError { readonly code: BrokerCapabilityAdvertisementDenialCode; constructor(path: string, message: string, code: BrokerCapabilityAdvertisementDenialCode); } export declare function brokerFeatureSetHash(featuresValue: unknown): string; /** Strictly parses the envelope and every advertised feature before any client-specific negotiation. */ export declare function parseBrokerCapabilityAdvertisement(value: unknown): BrokerCapabilityAdvertisement; export type BrokerCompatibilityRequest = { clientKind: "ordinary"; supportedBaseProtocolVersions: number[]; } | { clientKind: "boss"; supportedBaseProtocolVersions: number[]; requiredFeature: typeof BOSS_RUN_FEATURE; expectedProtectedOwnerUid: number; identityVerification: BrokerIdentityVerificationContext; peerExpectation: BrokerPeerExpectation; observedPeer: ObservedBrokerPeer; }; /** Parses the complete request before compatibility evaluation may branch on its discriminator. */ export declare function parseBrokerCompatibilityRequest(value: unknown): BrokerCompatibilityRequest; export type BrokerCompatibilityDecision = { compatible: true; mode: "ordinary" | "boss"; } | { compatible: false; code: "BASE_PROTOCOL_UNSUPPORTED" | "INVALID_COMPATIBILITY_REQUEST" | "BOSS_FEATURE_REQUIRED" | BrokerCapabilityAdvertisementDenialCode | "PROTECTED_IDENTITY_REQUIRED" | "IDENTITY_UNSIGNED" | "IDENTITY_KEY_UNKNOWN" | "IDENTITY_SIGNATURE_INVALID" | "IDENTITY_RECORD_INVALID" | "PROVIDER_ATTESTATION_REQUIRED" | "PROVIDER_ATTESTATION_UNSIGNED" | "PROVIDER_KEY_UNKNOWN" | "PROVIDER_SIGNATURE_INVALID" | "PROVIDER_MISMATCH" | "PROVIDER_ARTIFACT_MISMATCH" | "OWNER_UID_MISMATCH" | "PROTECTED_SERVICE_MISMATCH" | "STALE_BOOT_INSTANCE" | "REGRESSED_BROKER_GENERATION" | "ENDPOINT_MISMATCH" | "PEER_CREDENTIALS_MISSING" | "PEER_MISMATCH"; }; export declare function evaluateBrokerCompatibility(requestValue: unknown, advertisement: BrokerCapabilityAdvertisement, identity?: BrokerIdentityRecord): BrokerCompatibilityDecision; export interface BrokerProviderAttestation { version: typeof BROKER_PROVIDER_ATTESTATION_VERSION; providerPackage: string; providerVersion: string; providerDigest: string; artifactPath: string; artifactOwnerUid: number; artifactOwnerGid: number; artifactMode: string; userWritable: false; attestedAt: string; attestationKeyId: string; signature: string; } export type BrokerPublicKey = KeyObject | string; export type BrokerPublicKeyTrustStore = Readonly>; export declare function brokerProviderAttestationSigningBytes(value: unknown): Uint8Array; export declare function parseBrokerProviderAttestation(value: unknown): BrokerProviderAttestation; export interface BrokerProviderVerificationContext { expectedProviderPackage: string; expectedProviderVersion: string; expectedProviderDigest: string; expectedArtifactRoot: string; expectedArtifactOwnerUid: number; expectedArtifactOwnerGid: number; expectedArtifactMode: string; trustedProviderKeys: BrokerPublicKeyTrustStore; } export type BrokerProviderVerificationDecision = { accepted: true; } | { accepted: false; code: "PROVIDER_ATTESTATION_UNSIGNED" | "PROVIDER_KEY_UNKNOWN" | "PROVIDER_SIGNATURE_INVALID" | "PROVIDER_MISMATCH" | "PROVIDER_ARTIFACT_MISMATCH"; }; export declare function verifyBrokerProviderAttestation(attestationValue: unknown, contextValue: BrokerProviderVerificationContext): BrokerProviderVerificationDecision; export interface BrokerIdentityRecord { version: typeof BROKER_IDENTITY_RECORD_VERSION; owningProviderPackage: string; providerDigest: string; providerVersion: string; baseProtocolVersion: number; features: BrokerFeatureAttestation[]; protocolFeatureContractHash: string; featureSetHash: string; controlEnvelopeVersion: number; capabilityDigest: string; protectedServiceUid: number; ownerUid: number; bootInstance: string; processId: number; brokerGeneration: BrokerGeneration; publicEndpoint: string; authorityEndpoint: string; identityKeyId: string; signature: string; } export declare function parseBrokerIdentityRecord(value: unknown): BrokerIdentityRecord; export declare function brokerIdentitySigningBytes(value: unknown): Uint8Array; export interface BrokerPeerExpectation { version: typeof BROKER_PEER_EXPECTATION_VERSION; endpointClass: "public" | "authority"; ownerUid: number; expectedBrokerServiceUid: number; expectedBrokerProcessId: number; expectedClientUid: number; expectedControllerUid?: number; requiresKernelPeerCredentials: true; requiresServiceCapability: boolean; } export declare function parseBrokerPeerExpectation(value: unknown): BrokerPeerExpectation; export interface ObservedBrokerPeer { kernelPeerCredentialsPresent: boolean; endpointClass: "public" | "authority"; brokerServiceUid: number; brokerProcessId: number; clientUid: number; serviceCapabilityPresented: boolean; } export declare function parseObservedBrokerPeer(value: unknown): ObservedBrokerPeer; export type BrokerPeerDecision = { allowed: true; } | { allowed: false; code: "KERNEL_PEER_CREDENTIALS_REQUIRED" | "ENDPOINT_CLASS_MISMATCH" | "BROKER_UID_MISMATCH" | "BROKER_PID_MISMATCH" | "CLIENT_UID_MISMATCH" | "SERVICE_CAPABILITY_REQUIRED" | "UNEXPECTED_SERVICE_CAPABILITY"; }; export declare function authorizeBrokerPeer(expectationValue: unknown, observedValue: unknown): BrokerPeerDecision; export interface BrokerIdentityVerificationContext { expectedProviderPackage: string; expectedProviderVersion: string; expectedProviderDigest: string; expectedProviderArtifactRoot: string; expectedProviderArtifactOwnerUid: number; expectedProviderArtifactOwnerGid: number; expectedProviderArtifactMode: string; expectedOwnerUid: number; expectedBrokerServiceUid: number; expectedBootInstance: string; minimumBrokerGeneration: BrokerGeneration; expectedPublicEndpoint: string; expectedAuthorityEndpoint: string; trustedIdentityKeys: BrokerPublicKeyTrustStore; trustedProviderKeys: BrokerPublicKeyTrustStore; providerAttestation?: unknown; } export type BrokerIdentityVerificationDecision = { accepted: true; } | { accepted: false; code: "IDENTITY_UNSIGNED" | "IDENTITY_KEY_UNKNOWN" | "IDENTITY_SIGNATURE_INVALID" | "IDENTITY_RECORD_INVALID" | "PROVIDER_ATTESTATION_REQUIRED" | "PROVIDER_ATTESTATION_UNSIGNED" | "PROVIDER_KEY_UNKNOWN" | "PROVIDER_SIGNATURE_INVALID" | "PROVIDER_MISMATCH" | "PROVIDER_ARTIFACT_MISMATCH" | "OWNER_UID_MISMATCH" | "PROTECTED_SERVICE_MISMATCH" | "STALE_BOOT_INSTANCE" | "REGRESSED_BROKER_GENERATION" | "ENDPOINT_MISMATCH"; }; export declare function verifyProtectedBrokerIdentity(identityValue: unknown, contextValue: BrokerIdentityVerificationContext): BrokerIdentityVerificationDecision; export interface LegacyAdminMigrationRecord { version: typeof LEGACY_ADMIN_MIGRATION_VERSION; ownerUid: number; legacyAdminDigest: string; remoteAccessRegistrationsImported: number; remoteAccessSemanticsVersion: 2; legacyAdminState: "revoked_and_removed"; compatibilityProxyMode: "ordinary_data_only"; bossFeatureAdvertisedByProxy: false; protectedRegistryPath: string; migratedAt: string; auditEventId: string; } export declare function parseLegacyAdminMigrationRecord(value: unknown): LegacyAdminMigrationRecord; export interface BrokerJournalRecoveryRecord { version: typeof BROKER_JOURNAL_RECOVERY_VERSION; providerDigest: string; bootInstance: string; brokerGeneration: BrokerGeneration; committedBrokerRevision: BrokerRevision; recoveredAuthorityTransitionIds: string[]; state: "reconciled" | "quarantined"; reason?: string; recoveredAt: string; } export declare function parseBrokerJournalRecoveryRecord(value: unknown): BrokerJournalRecoveryRecord; export declare const BOSS_MANAGER_OPERATIONS: readonly ["manager_get_status", "manager_request_staff", "manager_create_assignment", "manager_cancel_assignment", "manager_create_subscription", "manager_list_subscriptions", "manager_cancel_subscription", "manager_submit_checkpoint", "manager_report_blocker", "manager_submit_proof", "manager_request_adversary_review", "manager_request_council"]; export type BossManagerOperation = (typeof BOSS_MANAGER_OPERATIONS)[number]; export declare const BOSS_PARTICIPANT_OPERATIONS: readonly ["participant_accept_assignment", "participant_reject_assignment", "participant_submit_checkpoint", "participant_submit_assignment", "participant_report_blocker", "participant_report_health"]; export type BossParticipantOperation = (typeof BOSS_PARTICIPANT_OPERATIONS)[number]; export declare const BOSS_REVIEWER_OPERATIONS: readonly ["reviewer_get_proof", "reviewer_submit_review", "reviewer_submit_proof", "reviewer_get_objection_status", "reviewer_report_health"]; export type BossReviewerOperation = (typeof BOSS_REVIEWER_OPERATIONS)[number]; export type BossRestrictedClient = "boss_manager" | "boss_participant" | "boss_reviewer"; export type BossRestrictedOperation = BossManagerOperation | BossParticipantOperation | BossReviewerOperation; export interface BossCheckpointPayload { assignmentId: string; checkpointId: string; summary: string; occurredAt: string; } export interface BossHealthPayload { state: ParticipantState; severity: "info" | "warning" | "error" | "critical"; observedAt: string; } export interface BossRestrictedRequestPayloadByOperation { manager_get_status: Record; manager_request_staff: { role: "scout" | "worker"; count: number; }; manager_create_assignment: { assignmentId: string; participantId: string; objective: string; }; manager_cancel_assignment: { assignmentId: string; reason: string; }; manager_create_subscription: LifecycleSubscriptionRecord; manager_list_subscriptions: Record; manager_cancel_subscription: { subscriptionId: string; }; manager_submit_checkpoint: BossCheckpointPayload; manager_report_blocker: { blockerId: string; reason: string; }; manager_submit_proof: { proofId: string; digest: string; }; manager_request_adversary_review: { proofId: string; }; manager_request_council: { question: string; }; participant_accept_assignment: { assignmentId: string; }; participant_reject_assignment: { assignmentId: string; reason: string; }; participant_submit_checkpoint: BossCheckpointPayload; participant_submit_assignment: { assignmentId: string; resultDigest: string; }; participant_report_blocker: { assignmentId: string; reason: string; }; participant_report_health: BossHealthPayload; reviewer_get_proof: { proofId: string; }; reviewer_submit_review: { reviewId: string; proofId: string; decision: "approved" | "changes_requested" | "rejected"; reason: string; }; reviewer_submit_proof: { proofId: string; digest: string; }; reviewer_get_objection_status: { reviewId: string; }; reviewer_report_health: BossHealthPayload; } export interface BossRestrictedResultPayloadByOperation { manager_get_status: { status: string; }; manager_request_staff: { staffRequestId: string; }; manager_create_assignment: { assignmentId: string; }; manager_cancel_assignment: { assignmentId: string; }; manager_create_subscription: { subscriptionId: string; }; manager_list_subscriptions: { subscriptionIds: string[]; }; manager_cancel_subscription: { subscriptionId: string; }; manager_submit_checkpoint: { assignmentId: string; checkpointId: string; recordedAt: string; }; manager_report_blocker: { blockerId: string; }; manager_submit_proof: { proofId: string; }; manager_request_adversary_review: { reviewId: string; }; manager_request_council: Record; participant_accept_assignment: { assignmentId: string; }; participant_reject_assignment: { assignmentId: string; }; participant_submit_checkpoint: { assignmentId: string; checkpointId: string; recordedAt: string; }; participant_submit_assignment: { assignmentId: string; }; participant_report_blocker: { blockerId: string; }; participant_report_health: { healthEventId: string; }; reviewer_get_proof: { proofId: string; digest: string; }; reviewer_submit_review: { reviewId: string; }; reviewer_submit_proof: { proofId: string; }; reviewer_get_objection_status: { reviewId: string; status: string; }; reviewer_report_health: { healthEventId: string; }; } interface RestrictedRequestBase { version: typeof BOSS_RESTRICTED_CLIENT_REQUEST_VERSION; bossRunId: string; bindingEpoch: ParticipantBindingEpoch; requestId: string; idempotencyKey: string; } type ManagerRequestFor = RestrictedRequestBase & { client: "boss_manager"; managerParticipantId: string; operation: Operation; payload: BossRestrictedRequestPayloadByOperation[Operation]; }; type ParticipantRequestFor = RestrictedRequestBase & { client: "boss_participant"; participantId: string; operation: Operation; payload: BossRestrictedRequestPayloadByOperation[Operation]; }; type ReviewerRequestFor = RestrictedRequestBase & { client: "boss_reviewer"; participantId: string; operation: Operation; payload: BossRestrictedRequestPayloadByOperation[Operation]; }; export type BossManagerRequest = { [Operation in BossManagerOperation]: ManagerRequestFor; }[BossManagerOperation]; export type BossParticipantRequest = { [Operation in BossParticipantOperation]: ParticipantRequestFor; }[BossParticipantOperation]; export type BossReviewerRequest = { [Operation in BossReviewerOperation]: ReviewerRequestFor; }[BossReviewerOperation]; export type BossRestrictedClientRequest = BossManagerRequest | BossParticipantRequest | BossReviewerRequest; export declare function parseBossRestrictedClientRequest(value: unknown): BossRestrictedClientRequest; export declare const BOSS_RESTRICTED_AUTHORIZATION_DENIAL_CODES: readonly ["UNKNOWN_PRINCIPAL", "PRINCIPAL_NOT_ACTIVE", "BINDING_NOT_ACTIVE", "POLICY_BINDING_MISMATCH", "UNAUTHORIZED_ROLE", "PARTICIPANT_MISMATCH", "STALE_BINDING_EPOCH", "CROSS_RUN_REPLAY", "MISSING_AUTHORIZATION_EVIDENCE", "PAYLOAD_AUTHORIZATION_MISMATCH", "REQUEST_ID_CONFLICT", "IDEMPOTENCY_CONFLICT"]; export type BossRestrictedAuthorizationDenialCode = (typeof BOSS_RESTRICTED_AUTHORIZATION_DENIAL_CODES)[number]; export interface BossRestrictedClientIdempotencyRecord { scope: string; bossRunId: string; client: BossRestrictedClient; participantId: string; bindingEpoch: ParticipantBindingEpoch; operation: BossRestrictedOperation; requestId: string; idempotencyKey: string; requestDigest: string; } /** Controller-owned assignment identity used only for pure payload authorization. */ export interface BossRestrictedAssignmentAuthorizationRecord { bossRunId: string; assignmentId: string; managerParticipantId: string; participantId: string; } /** Controller-owned proof ownership and reviewer correlation. */ export interface BossRestrictedProofAuthorizationRecord { bossRunId: string; proofId: string; ownerParticipantId: string; reviewerParticipantIds: string[]; } /** Controller-owned review identity and lifecycle used for submission and objection-status authorization. */ export interface BossRestrictedReviewAuthorizationRecord { bossRunId: string; reviewId: string; proofId: string; requesterParticipantId: string; reviewerParticipantId: string; state: "pending" | "submitted" | "cancelled"; } /** * Controller/Orc authorization for one exact lifecycle target at the current * subscriber binding. targetParticipantIds binds Worker IDs and role selectors * back to the Manager's authoritative participant assignments. */ export interface BossRestrictedSupervisionAuthorizationRecord { bossRunId: string; subscriberPrincipalId: string; subscriberParticipantId: string; subscriberBindingEpoch: SubscriberBindingEpoch; subscriberBindingGeneration: SubscriberBindingGeneration; target: LifecycleTarget; targetParticipantIds: string[]; } export interface BossRestrictedClientAuthorizationContext { policy: BossPolicyState; principalId: string; currentBinding: BossParticipantBinding; assignments?: readonly BossRestrictedAssignmentAuthorizationRecord[]; proofs?: readonly BossRestrictedProofAuthorizationRecord[]; reviews?: readonly BossRestrictedReviewAuthorizationRecord[]; supervision?: readonly BossRestrictedSupervisionAuthorizationRecord[]; subscriptions?: readonly LifecycleSubscriptionRecord[]; idempotencyRecords?: readonly BossRestrictedClientIdempotencyRecord[]; } export type BossRestrictedClientAuthorizationDecision = { allowed: true; idempotency: "new" | "replay"; record: BossRestrictedClientIdempotencyRecord; } | { allowed: false; code: BossRestrictedAuthorizationDenialCode; }; export declare function bossRestrictedClientIdempotencyScope(requestValue: unknown): string; export declare function createBossRestrictedClientIdempotencyRecord(requestValue: unknown): BossRestrictedClientIdempotencyRecord; export declare function authorizeBossRestrictedClientRequest(requestValue: unknown, contextValue: BossRestrictedClientAuthorizationContext): BossRestrictedClientAuthorizationDecision; export declare const RESTRICTED_RESULT_STATUSES: readonly ["ok", "rejected", "feature_not_enabled", "conflict", "unauthorized"]; export type BossRestrictedResultStatus = (typeof RESTRICTED_RESULT_STATUSES)[number]; interface RestrictedResultBinding { version: typeof BOSS_RESTRICTED_CLIENT_RESULT_VERSION; bossRunId: string; bindingEpoch: ParticipantBindingEpoch; requestId: string; idempotencyKey: string; } type RestrictedSuccessResult = RestrictedResultBinding & { operation: Operation; status: "ok"; payload: BossRestrictedResultPayloadByOperation[Operation]; }; type RestrictedErrorResult = RestrictedResultBinding & { operation: Operation; status: "rejected" | "feature_not_enabled" | "conflict"; errorCode: string; }; type RestrictedUnauthorizedResult = RestrictedResultBinding & { operation: Operation; status: "unauthorized"; denialCode: BossRestrictedAuthorizationDenialCode; }; type BoundManagerResult = (RestrictedSuccessResult | RestrictedErrorResult | RestrictedUnauthorizedResult) & { client: "boss_manager"; managerParticipantId: string; }; type BoundParticipantResult = (RestrictedSuccessResult | RestrictedErrorResult | RestrictedUnauthorizedResult) & { client: "boss_participant"; participantId: string; }; type BoundReviewerResult = (RestrictedSuccessResult | RestrictedErrorResult | RestrictedUnauthorizedResult) & { client: "boss_reviewer"; participantId: string; }; export type BossRestrictedClientResult = { [Operation in BossManagerOperation]: BoundManagerResult; }[BossManagerOperation] | { [Operation in BossParticipantOperation]: BoundParticipantResult; }[BossParticipantOperation] | { [Operation in BossReviewerOperation]: BoundReviewerResult; }[BossReviewerOperation]; export declare function parseBossRestrictedClientResult(value: unknown, requestValue?: unknown): BossRestrictedClientResult; export declare function assertBossRestrictedClientResultBinding(resultValue: unknown, requestValue: unknown): void; export declare const validateBrokerProviderAttestationStore: (value: unknown) => StoreValidationResult; export declare const validateBrokerIdentityStore: (value: unknown) => StoreValidationResult; export declare const validateLegacyAdminMigrationStore: (value: unknown) => StoreValidationResult; export declare const validateBrokerJournalRecoveryStore: (value: unknown) => StoreValidationResult; //# sourceMappingURL=boss-service.d.ts.map