import { type EdgeModule } from "@decionis/agent-safe-pipeline"; import { HashChain } from "../audit/HashChain.js"; import type { LineWriter } from "../audit/LineAuditSink.js"; import type { EscalationMode, ExecutorConfig, ExecutorMode } from "../config/ExecutorConfig.js"; import { HaltSwitch, type HaltState } from "../incident/HaltSwitch.js"; import type { ExecutionJournal } from "../journal/ExecutionJournal.js"; import { type RecoveryReport } from "../journal/StartupReconciler.js"; import { type AddressResolver } from "../egress/GuardedFetch.js"; import type { FetchLike, HandlerRegistration } from "../handlers/HandlerRegistration.js"; import { PrincipalRegistry, type Principal } from "../identity/PrincipalRegistry.js"; import { WorkloadJwtVerifier } from "../identity/WorkloadJwtVerifier.js"; import { type ExecutorMetrics } from "../incident/Metrics.js"; import { SecurityEvents } from "../incident/SecurityEvents.js"; import { type EvidenceBundle } from "../incident/EvidenceExport.js"; import { CardOutcomes } from "../outcomes/CardOutcomes.js"; import type { CardOutcomeLedger } from "../outcomes/CardOutcomeLedger.js"; import type { OutcomeEvidenceSink } from "../outcomes/CoreOutcomeEvidenceClient.js"; import type { PostureState } from "../posture/HostPosture.js"; import type { ReloadReport, SecretStore } from "../secrets/SecretStore.js"; import { type EscalationDependencies } from "./EscalationResolver.js"; import { type ActionResponse, type CardAuthorizationAnswer, type CardResultResponse, type ReconciliationResponse } from "./Requests.js"; import type { LoadPg } from "../edge/EdgeReplay.js"; export interface ServiceDependencies extends Omit { /** Where audit lines go; stdout in the process, an array in the proof. */ readonly emit?: LineWriter; /** The transport under the guard; `node:https` when absent. An injected one is still policy-checked. */ readonly fetch?: FetchLike; /** Name resolution for the guard; the system resolver when absent. */ readonly resolve?: AddressResolver; /** Reads a CA bundle the configuration names; the filesystem when absent. */ readonly readFile?: (path: string) => string; /** Where security events go; stderr in the process. */ readonly security?: SecurityEvents; /** Whether a posture drift is standing; an enforcement request is refused while it is. */ readonly posture?: PostureState; /** The evidence chain to link audit lines on; a fresh one from genesis when absent. */ readonly chain?: HashChain; readonly metrics?: ExecutorMetrics; /** The principals, when trusted startup code built them; the file or the legacy caller otherwise. */ readonly principals?: PrincipalRegistry; /** Where attempts are journaled; the configured directory unless one is given. */ readonly journal?: ExecutionJournal; /** The stop; one is built from the configuration unless a test hands in its own. */ readonly halt?: HaltSwitch; readonly clock?: () => number; /** Loads the edge evaluator; the configured file unless a test hands in its own. */ readonly loadEdgeModule?: (path: string) => EdgeModule; /** Loads `pg` for the shared replay store; the installed package unless a test hands in its own. */ readonly loadPg?: LoadPg; /** Where card outcome facts are kept; the configured directory unless a test hands in its own. */ readonly cardOutcomeLedger?: CardOutcomeLedger; /** Core's outcome evidence resource; the authority's, with the producer token, unless a test hands in its own. */ readonly outcomeSink?: OutcomeEvidenceSink; } /** What `/v1/control/status` reports: identifiers, counts, and heads, never a value. */ export interface ExecutorStatus { readonly status: "ready"; readonly mode: ExecutorMode; readonly escalation: EscalationMode; readonly actions: readonly string[]; readonly posture: { readonly degraded: boolean; }; readonly principals: { readonly mode: "PRINCIPALS" | "LEGACY"; readonly count: number; }; readonly evidence: { readonly seq: number; readonly hash: string; }; readonly secrets: readonly string[]; readonly halt: HaltState; readonly attempts: { readonly open: number; readonly unknown: number; }; readonly limits: { readonly currencies: readonly string[]; readonly windowSeconds: number | null; } | null; } /** What `/ready` answers, and whether it is ready at all. */ export interface Readiness { readonly ready: boolean; readonly body: Readonly>; } export declare class TrustedExecutorService { private readonly config; private readonly secrets; private readonly capture; private readonly registry; private readonly registered; private readonly clients; private readonly posture; private readonly egress; /** Where an incident's evidence is written, when the configuration names a directory. */ private readonly evidence; /** The security stream this service writes to; a test drives the halt through it. */ readonly events: SecurityEvents; private readonly chain; readonly metrics: ExecutorMetrics; readonly principals: PrincipalRegistry; /** The workload token verifier, when the configuration names a JWKS; the door uses it. */ readonly jwt: WorkloadJwtVerifier | null; private readonly credential; private readonly audit; private readonly journal; readonly haltSwitch: HaltSwitch; private readonly limits; private readonly unsubscribeMetrics; /** The effect observations the verifier finalizes with; the cards family registers into it. */ private readonly effects; /** Card grants held for the issuer's authorization, and the authorizations that claimed one. */ private readonly cards; /** The shared hold store's hourly sweep, while it runs. */ private cardsTimer; /** The edge evaluator, when the configuration asks for it. */ private readonly edge; /** The card purchases' outcome evidence, recorded and stated after the fact; null when off. */ private readonly outcomes; private readonly hasher; private recovery; /** * Authorizations evaluated at the commit boundary and escalated, by id: * answered the same way until their intent expires, so a platform that * re-presents one is told the same thing and nothing is evaluated twice. */ private readonly pendingCommits; /** Bound before any await: one authorization id may claim only one request. */ private readonly cardClaims; private constructor(); /** * Wires the boundary. `handlers` is the adopter's seam: it registers what * this process can run, and the registry is sealed the moment it returns. * Every credential is read from `secrets` at the moment of use. */ static create(config: ExecutorConfig, secrets: SecretStore, handlers: HandlerRegistration, dependencies?: ServiceDependencies): TrustedExecutorService; /** * Where card holds live: this process, or the store every replica shares, * whose rows are sealed under the hold key. A hold or a claim another * replica made is admitted here through the executor's own checks, with * the claim material that replica sealed. */ private static cardHolds; /** The credential the configuration's kind names, over the secret store and the guarded fetch. */ private static credential; private static jwtVerifier; /** The principals file, or the legacy caller; either way checked against what this process runs. */ private static principals; get mode(): ExecutorMode; get escalationMode(): EscalationMode; /** * Loads the edge evaluator's first bundle and starts its refresh schedule. * A first fetch that fails is not a refusal to start: until a bundle * loads, decisions follow the configured `onUnavailable`. */ startEdge(): Promise; /** * Probes the shared hold store, when there is one: a store that cannot be * reached is a refusal to start, since no authorization could then match, * and then sweeps it hourly for what lapsed. */ startCards(): Promise; /** * The card purchases' outcome evidence, when it is on: what it has recorded is written, and * `publish` states it to Decionis now rather than at the next interval. */ get cardOutcomes(): CardOutcomes | null; /** The actions this process can run, for `/ready`. */ get actions(): readonly string[]; /** Stops following credential rotation and closes every outbound connection; the service answers nothing new after this. */ close(): void; /** Identifiers, counts and heads for an operator; never a value. */ status(caller?: Principal): ExecutorStatus; /** * What the last process left open, resolved before this one takes a * request. Read-only: the provider is asked what it did, never told to do * it again. */ recover(): Promise; /** * Readiness, which is not liveness: a halted executor is alive and * deliberately not ready, and so is one that still does not know how an * attempt ended when the deployment asked to wait for that. */ readiness(): Readiness; /** Stops the executor taking new work, on an operator's word and with a reason. */ halt(input: unknown, caller?: Principal): HaltState; /** * Lets work through again; refused while the cause of the halt still * stands, and while `GET /v1/control/open-attempts` lists an attempt whose * outcome is unknown, unless the operator overrides that with a reason. */ resumeWork(input: unknown, caller?: Principal): HaltState; /** The attempts this process does not know the outcome of: identifiers and states only. */ openAttempts(caller?: Principal): { readonly attempts: RecoveryReport["attempts"]; readonly unknown: number; }; /** The unknown count `open-attempts` reports, which the resume gate reads too. */ private openAttemptsUnknown; /** Re-reads every secret file now, on an operator's word; the report names files, never values. */ reloadSecrets(caller?: Principal): Promise; metricsText(caller?: Principal): string; propose(input: unknown, caller?: Principal): Promise; private enforceAfterPosture; /** The stop, checked after the intent is captured and before any authority is asked. */ private assertNotHalted; /** The refusal itself is evidence: the same shape the executor uses for a blocked run. */ private recordRefusal; /** * One spendable hold per card and merchant: a purchase at a merchant where * the card already has one waits until it is authorised or expires, * refused before the authority is asked so the refusal costs no dossier * and no grant. The same card at another merchant holds in parallel. */ private assertCardSpendable; /** The host's own ceilings, before the authority is asked and again before the run. */ private assertWithinLimits; reconcile(input: unknown, caller?: Principal): Promise; /** * Resumes an open escalation. One bounded lookup: if the person has * answered, the authority evaluates the exact intent again and an `ALLOW` * executes once; if not, the state comes back to be presented later. An * intent past its lifetime is refused before anything is asked. */ resume(input: unknown, caller?: Principal): Promise; /** * A fresh decision on a resumed escalation: a card purchase's grant is held * for the issuer, anything else runs once on an `ALLOW`. */ private decide; /** * The attempt, on disk, before the executor may run it. A journal that * cannot take the record refuses the proposal rather than executing * something no one could reconcile afterwards; with * `EXECUTOR_JOURNAL_REQUIRED=false`, outside production, the refusal is * downgraded to an event so a developer can run without a volume. */ private openAttempt; /** * How the attempt ended, so the next start does not have to ask the * provider. An outcome that is unknown is exactly what must not be closed: * the attempt stays open, and the next start, or a caller's own * reconciliation, resolves it by reading the provider. */ private closeAttempt; /** A standing posture drift refuses new enforcement work; nothing that has started is touched. */ private assertPosture; /** The proposer a call is made as: the caller the door authenticated, or the legacy caller when the service is used directly. */ private proposer; /** * An operator may present an attestation only under `escalations.resume`; * without it the operator is no presenter at all, and the refusal is the * door's: a role the route does not admit. */ private static presenter; private operator; /** An intent presented back must be the caller's own: same principal, tenant, and actor. */ private assertOwn; /** * The burst on this card, counted before capture because the store may be * shared and is asked asynchronously; a purchase the binder will refuse * is not counted, and the binder's own refusal follows. */ private cardVelocity; private captureIntent; /** * The banking binder. Every disagreement between what the caller said over * the transport and what the canonical action says is a refusal before the * authority is asked, so a mismatch costs no dossier and no grant. */ private bindBanking; /** * The cards binder: the purchase is read and refused here, a card number * above all, and the target is derived from the card. What comes back is * the expected-effect digest the authority binds its grant to. */ private bindCard; /** The hold's routing as the handoff carries it, from the decision when the authority said. */ private static attestationRequirement; /** Whether the policy sent the hold to a presence provider other than Decionis Presence. */ private static routedToProvider; /** * The two digests a banking intent is bound to, taken from the profile's * own arithmetic. This reaches nothing: `prepare` is pure, which is why * the transport it is handed refuses to be used. */ private bankingDigests; /** * What the adapter observed, for the response and for the stream. An * observation that does not match what was authorised is the institution's * exception: it is named in the evidence, counted, and by default it stops * the executor, because the next proposal would otherwise be made against * a state nobody has reconciled. */ private effect; /** The reason codes an effect block contributes to the response. */ private static effectReasons; /** An intent the caller presents back, re-hashed rather than trusted. */ private presented; private observe; private enforce; /** * Admits a card purchase's decision exactly as a run would and holds its * grant for the issuer's authorization, keyed by the card and the * merchant. Nothing is * claimed and nothing runs; the hard ceilings are committed now, because * this is the last moment this process decides anything about the amount. * A refusal comes back as the executor's own blocked result. */ private holdCard; /** * The issuer's real-time authorization hook. The answer has to come back in * milliseconds, so the only network call is the claim itself: the match is * pure, against a grant decided before the card was presented. A match * claims the grant once, and a second authorization for it is a * `NO_MATCH`; an issuer retrying the same authorization is given the same * answer, with no second claim. What `NO_MATCH` means for the purchase is * the issuer's policy, not this process's. */ authorizeCard(input: unknown, caller?: Principal): Promise; private claimCard; /** * An authorization with no hold. By default it is `NO_MATCH`: nothing was * decided before the card was presented. A deployment that evaluates at * the commit boundary answers it from an evaluation made now, and one * already evaluated and escalated is answered the same way until its * intent expires, so a platform that re-presents it is told the same thing * and nothing is evaluated twice. Once the tap has resumed the hold, the * re-presented authorization finds it before it gets here. */ private withoutGrant; /** * The commit boundary: the authorization becomes the intent, captured as * the commit actor the deployment names and evaluated now, with the * authorization's id in the intent's context so the dossier says what it * decided about. An `ALLOW` is held and claimed in this same call. An * `ESCALATE` is `PENDING`, with the handoff: a platform that can pend keeps * the authorization waiting, the tap arrives through `POST /v1/escalations` * with the handoff's intent, and the re-presented authorization matches the * hold the tap left. A `BLOCK`, a refusal this host makes on its own, and * an authority that did not answer are `NO_MATCH` with their code. In * shadow the evaluation is observed and the authorization is `NO_MATCH`. */ private evaluateAtCommit; /** Bounded like the claims: a full map forgets its oldest, whose intent is nearest its expiry. */ private rememberPending; /** The intent's idempotency key names the authorization; one too long for the key is named by its digest. */ private static commitIdempotencyKey; /** * What the issuer did with an authorization it was told to approve. An * approval is the effect, compared with what the grant authorised; a * decline is a refusal; and a result after the claim's lease is recorded * as indeterminate, because the authority no longer accepts a commit for * it. Recorded once. */ settleCard(authorizationId: string, input: unknown, caller?: Principal): Promise; /** A card attempt's end, in the journal, so a restart does not ask about it again. */ private closeCardAttempt; private noMatch; /** A card request read, or the refusal that names why; a card number is its own refusal. */ private static cardRequest; /** * Whether a re-presented authorization is an increment of the claim it * names: the same card, currency, merchant and category, for more than * before and no more than the grant's ceiling, while the claim is still * open and inside its lease. */ private static incrementOf; private static cardView; private response; /** A resumption that produced no new decision: still held, or refused. */ private held; /** * The bundle: what this process can say about an incident, written where an * operator can pick it up. Only an operator holding the `evidence` scope * may ask, and the reason they give travels with it. */ exportEvidence(input: unknown, caller?: Principal): Promise; private static binding; } //# sourceMappingURL=TrustedExecutorService.d.ts.map