@splitin/verification-engine 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hash.ts","../src/errors.ts","../src/canonical.ts","../src/index.ts","../src/registry.ts","../src/memory-store.ts","../src/queue.ts","../src/memory-queue.ts","../src/types.ts","../src/guards.ts","../src/platform.ts","../src/rate-budget.ts","../src/routing.ts","../src/seed.ts","../src/store.ts","../src/status.ts"],"names":["sha256Hex","assertAdapterConformsToManifest","isCountryCode","metadataContainsForbiddenIdentifier","adapter","isTerminalStatus","toSafeProviderFailure","ProviderOperationPendingError","status","ProviderError","input"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,YAAA,GAAA,EAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,aAAA,EAAA,MAAA,aAAA;AAAA,EAAA,KAAA,EAAA,MAAA,KAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,SAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAAO,SAAS,WAAW,KAAA,EAA2B;AACpD,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,KAAA,EAAO,CAAC,SAAS,IAAA,CAAK,QAAA,CAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAChF;AAEA,eAAsB,UAAU,OAAA,EAA+C;AAC7E,EAAA,MAAM,KAAA,GAAQ,OAAO,OAAA,KAAY,QAAA,GAAW,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,OAAO,CAAA,GAAI,OAAA;AAChF,EAAA,OAAO,UAAA,CAAW,IAAI,UAAA,CAAW,MAAM,MAAA,CAAO,OAAO,MAAA,CAAO,SAAA,EAAW,KAAqB,CAAC,CAAC,CA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AG,OAAO,KAAA;AAC/E,EAAA,OAAO,WAAA;AACT","file":"index.cjs","sourcesContent":["export function bytesToHex(value: Uint8Array): string {\n return Array.from(value, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\nexport async function sha256Hex(payload: string | Uint8Array): Promise<string> {\n const bytes = typeof payload === 'string' ? new TextEncoder().encode(payload) : payload;\n return bytesToHex(new Uint8Array(await crypto.subtle.digest('SHA-256', bytes as BufferSource)));\n}\n\nexport async function hmacSha256Hex(secret: string, payload: string | Uint8Array): Promise<string> {\n const key = await crypto.subtle.importKey(\n 'raw',\n new TextEncoder().encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign'],\n );\n const bytes = typeof payload === 'string' ? new TextEncoder().encode(payload) : payload;\n return bytesToHex(new Uint8Array(await crypto.subtle.sign('HMAC', key, bytes as BufferSource)));\n}\n\nexport function randomToken(cryptoImpl: Crypto = globalThis.crypto): string {\n const bytes = new Uint8Array(32);\n cryptoImpl.getRandomValues(bytes);\n return bytesToHex(bytes);\n}\n\nexport function newId(prefix: string, cryptoImpl: Crypto = globalThis.crypto): string {\n return `${prefix}_${cryptoImpl.randomUUID().replace(/-/g, '')}`;\n}\n\nexport async function cohortBucket(tenantKey: string, subjectHash: string): Promise<number> {\n const hex = await sha256Hex(`${tenantKey}:${subjectHash}`);\n return Number.parseInt(hex.slice(0, 8), 16) % 100;\n}\n","export type EngineErrorCode =\n | 'AUTHORIZATION_DENIED'\n | 'CLIENT_ROUTE_INJECTION'\n | 'NO_ELIGIBLE_ROUTE'\n | 'ATTEMPT_NOT_FOUND'\n | 'ATTEMPT_PINNED'\n | 'ATTEMPT_TERMINAL'\n | 'OPERATION_PENDING'\n | 'PRODUCTION_NOT_ACTIVATED'\n | 'WEBHOOK_SECURITY_INCIDENT'\n | 'WEBHOOK_UNAUTHENTICATED'\n | 'CONTINUATION_DENIED'\n | 'GOVERNANCE_TWO_ACTOR'\n | 'INVALID_TRANSITION'\n | 'INVALID_COMMAND'\n | 'PROVIDER_UNAVAILABLE'\n | 'DESTINATION_NOT_ALLOWLISTED';\n\nexport class EngineError extends Error {\n constructor(\n readonly code: EngineErrorCode,\n message: string,\n readonly retryable = false,\n readonly retryAfterSeconds?: number,\n ) {\n super(message);\n this.name = 'EngineError';\n }\n}\n\nexport class AuthorizationError extends EngineError {\n constructor(message = 'The actor is not authorized for this verification operation.') {\n super('AUTHORIZATION_DENIED', message, false);\n this.name = 'AuthorizationError';\n }\n}\n\nexport class ClientRouteInjectionError extends EngineError {\n constructor(message = 'Verification routing is server-owned and cannot be selected by the client.') {\n super('CLIENT_ROUTE_INJECTION', message, false);\n this.name = 'ClientRouteInjectionError';\n }\n}\n\nexport class WebhookSecurityIncidentError extends EngineError {\n constructor(message = 'A webhook event key collided with a different body digest.') {\n super('WEBHOOK_SECURITY_INCIDENT', message, false);\n this.name = 'WebhookSecurityIncidentError';\n }\n}\n","/** Canonical JSON: recursively sorted object keys, no insignificant whitespace. */\nexport function canonicalize(value: unknown): string {\n return JSON.stringify(sortValue(value));\n}\n\nfunction sortValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortValue);\n if (value && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n return Object.fromEntries(\n Object.keys(record).sort().map((key) => [key, sortValue(record[key])]),\n );\n }\n return value;\n}\n\nexport async function digestCanonical(value: unknown): Promise<string> {\n const { sha256Hex } = await import('./hash.ts');\n return sha256Hex(canonicalize(value));\n}\n","export { EngineError, AuthorizationError, ClientRouteInjectionError, WebhookSecurityIncidentError } from './errors.ts';\nexport type { EngineErrorCode } from './errors.ts';\nexport { canonicalize, digestCanonical } from './canonical.ts';\nexport { sha256Hex, hmacSha256Hex, cohortBucket } from './hash.ts';\nexport { createProviderRegistry } from './registry.ts';\nexport type { ProviderRegistry } from './registry.ts';\nexport { createMemoryStore } from './memory-store.ts';\nexport { createMemoryQueue } from './memory-queue.ts';\nexport { createVerificationPlatform } from './platform.ts';\nexport type { CreateVerificationPlatformInput, VerificationPlatform } from './platform.ts';\nexport { backoffSeconds } from './queue.ts';\nexport type { VerificationQueue } from './queue.ts';\nexport { createRateBudget } from './rate-budget.ts';\nexport type { RateBudget } from './rate-budget.ts';\nexport type { VerificationStore, PolicyStore } from './store.ts';\nexport { seedSandboxExamples } from './seed.ts';\nexport { selectRoute } from './routing.ts';\nexport { applyMonotonicStatus, canTransitionStatus } from './status.ts';\nexport { assertNoClientRouting } from './guards.ts';\nexport * from './types.ts';\n","import {\n assertAdapterConformsToManifest,\n type VerificationAdapterV1,\n type VerificationProviderCode,\n type VerificationProviderEnvironment,\n} from '@splitin/verification-adapter-sdk';\n\nimport { EngineError } from './errors.ts';\n\nexport interface ProviderRegistry {\n get(provider: VerificationProviderCode, environment?: VerificationProviderEnvironment): VerificationAdapterV1;\n list(): VerificationAdapterV1[];\n has(provider: VerificationProviderCode): boolean;\n}\n\n/**\n * Explicit code imports only. Database rows cannot load packages.\n */\nexport function createProviderRegistry(input: { adapters: VerificationAdapterV1[] }): ProviderRegistry {\n if (!input.adapters.length) {\n throw new EngineError('INVALID_COMMAND', 'A verification provider registry requires at least one compiled-in adapter.');\n }\n const adapters = new Map<string, VerificationAdapterV1>();\n for (const adapter of input.adapters) {\n assertAdapterConformsToManifest(adapter);\n const key = registryKey(adapter.provider, adapter.environment);\n if (adapters.has(key)) {\n throw new EngineError('INVALID_COMMAND', `Duplicate compiled-in adapter for ${key}.`);\n }\n adapters.set(key, adapter);\n }\n return {\n get(provider, environment) {\n if (environment) {\n const exact = adapters.get(registryKey(provider, environment));\n if (exact) return exact;\n }\n const match = [...adapters.values()].find((adapter) => adapter.provider === provider\n && (!environment || adapter.environment === environment));\n if (!match) {\n throw new EngineError('NO_ELIGIBLE_ROUTE', `No compiled-in adapter is registered for provider \"${provider}\".`);\n }\n return match;\n },\n list: () => [...adapters.values()],\n has: (provider) => [...adapters.values()].some((adapter) => adapter.provider === provider),\n };\n}\n\nexport function registryKey(provider: string, environment: string): string {\n return `${provider}:${environment}`;\n}\n","import { hmacSha256Hex, newId } from './hash.ts';\nimport type { PolicyStore, VerificationStore } from './store.ts';\nimport type {\n AppealRecord,\n AttemptRecord,\n AuditEventRecord,\n CircuitRecord,\n ConfigurationRevisionRecord,\n ContinuationRecord,\n DecisionRecord,\n HealthObservationRecord,\n IdempotencyClaimRecord,\n JobRecord,\n ManualDecisionProposalRecord,\n PolicyVersionRecord,\n ProtectedActionRequirementRecord,\n ProviderDefinitionRecord,\n ProviderResourceLineageRecord,\n QueueJobKind,\n RedactionStatus,\n ReviewCaseRecord,\n RouteChangeRequestRecord,\n RouteRecord,\n TenantRecord,\n VerificationPackageCode,\n VerificationProviderCode,\n VerificationProviderEnvironment,\n WebhookEventRecord,\n} from './types.ts';\n\nclass AsyncMutex {\n private chain: Promise<void> = Promise.resolve();\n\n run<T>(fn: () => Promise<T>): Promise<T> {\n const run = this.chain.then(fn, fn);\n this.chain = run.then(() => undefined, () => undefined);\n return run;\n }\n}\n\nfunction clone<T>(value: T): T {\n return structuredClone(value);\n}\n\nexport interface MemoryStoreOptions {\n hashSecret?: string;\n now?: () => Date;\n seedTenantKey?: string;\n}\n\nexport function createMemoryStore(options: MemoryStoreOptions = {}): VerificationStore & PolicyStore {\n const hashSecret = options.hashSecret ?? 'test-verification-hash-secret';\n const nowFn = options.now ?? (() => new Date());\n const seedTenantKey = options.seedTenantKey ?? 'default';\n const mutex = new AsyncMutex();\n const keyLocks = new Map<string, AsyncMutex>();\n\n const tenants = new Map<string, TenantRecord>();\n const configs = new Map<string, ConfigurationRevisionRecord>();\n const providers = new Map<string, ProviderDefinitionRecord>();\n const routes = new Map<string, RouteRecord>();\n const routeChanges = new Map<string, RouteChangeRequestRecord>();\n const policies = new Map<string, PolicyVersionRecord>();\n const requirements = new Map<string, ProtectedActionRequirementRecord>();\n const attempts = new Map<string, AttemptRecord>();\n const lineage = new Map<string, ProviderResourceLineageRecord>();\n const decisions = new Map<string, DecisionRecord>();\n const idempotency = new Map<string, IdempotencyClaimRecord>();\n const webhooks = new Map<string, WebhookEventRecord>();\n const health = new Map<string, HealthObservationRecord>();\n const circuits = new Map<string, CircuitRecord>();\n const appeals = new Map<string, AppealRecord>();\n const reviews = new Map<string, ReviewCaseRecord>();\n const proposals = new Map<string, ManualDecisionProposalRecord>();\n const continuations = new Map<string, ContinuationRecord>();\n const audit = new Map<string, AuditEventRecord>();\n const jobs = new Map<string, JobRecord>();\n\n const iso = () => nowFn().toISOString();\n const k = (...parts: string[]) => parts.join('::');\n const lockFor = (key: string) => {\n let lock = keyLocks.get(key);\n if (!lock) {\n lock = new AsyncMutex();\n keyLocks.set(key, lock);\n }\n return lock;\n };\n\n const seedTenant: TenantRecord = {\n tenantKey: seedTenantKey,\n displayName: 'Default tenant',\n continuationDestinations: ['verification.resume', 'application.home'],\n createdAt: iso(),\n };\n tenants.set(seedTenantKey, seedTenant);\n\n const sandboxPolicy: PolicyVersionRecord = {\n tenantKey: seedTenantKey,\n id: 'pol_sandbox_example',\n version: 'sandbox-example-1',\n environment: 'sandbox',\n lifecycle: 'active',\n reason: 'Seeded sandbox example policy',\n expiresAt: null,\n proposedByActorId: 'system:seed',\n approvedByActorId: 'system:seed-approver',\n approvedAt: iso(),\n activatedAt: iso(),\n createdAt: iso(),\n decisionRetentionDays: null,\n providerRedactionDelayDays: null,\n appealHoldDays: null,\n legalHold: false,\n };\n policies.set(k(seedTenantKey, sandboxPolicy.id), sandboxPolicy);\n\n const store: VerificationStore = {\n now: nowFn,\n async hashSubject(tenantKey, subjectReference) {\n return hmacSha256Hex(hashSecret, `subject:${tenantKey}:${subjectReference}`);\n },\n async hashResource(tenantKey, resourceType, resourceReference) {\n return hmacSha256Hex(hashSecret, `resource:${tenantKey}:${resourceType}:${resourceReference}`);\n },\n transact(fn) {\n return mutex.run(() => fn(store));\n },\n async getTenant(tenantKey) {\n return tenants.get(tenantKey) ? clone(tenants.get(tenantKey)!) : null;\n },\n async ensureTenant(tenantKey, displayName = tenantKey) {\n const existing = tenants.get(tenantKey);\n if (existing) return clone(existing);\n const created: TenantRecord = {\n tenantKey,\n displayName,\n continuationDestinations: ['verification.resume'],\n createdAt: iso(),\n };\n tenants.set(tenantKey, created);\n return clone(created);\n },\n async getConfigurationRevision(tenantKey, id) {\n const row = configs.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listConfigurationRevisions(tenantKey) {\n return [...configs.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveConfigurationRevision(revision) {\n configs.set(k(revision.tenantKey, revision.id), clone(revision));\n },\n async upsertProviderDefinition(definition) {\n providers.set(k(definition.tenantKey, definition.provider, definition.environment), clone(definition));\n },\n async getProviderDefinition(tenantKey, provider, environment) {\n const row = providers.get(k(tenantKey, provider, environment));\n return row ? clone(row) : null;\n },\n async listProviderDefinitions(tenantKey) {\n return [...providers.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async getRoute(tenantKey, routeId) {\n const row = routes.get(k(tenantKey, routeId));\n return row ? clone(row) : null;\n },\n async listRoutes(tenantKey) {\n return [...routes.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async listActiveRoutes(tenantKey, environment) {\n return [...routes.values()]\n .filter((row) => row.tenantKey === tenantKey && row.environment === environment && row.lifecycle === 'active')\n .map(clone);\n },\n async saveRoute(route) {\n routes.set(k(route.tenantKey, route.id), clone(route));\n },\n async saveRouteChangeRequest(request) {\n routeChanges.set(k(request.tenantKey, request.id), clone(request));\n },\n async getRouteChangeRequest(tenantKey, id) {\n const row = routeChanges.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listRouteChangeRequests(tenantKey) {\n return [...routeChanges.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async getActivePolicy(tenantKey, environment) {\n const match = [...policies.values()].find(\n (row) => row.tenantKey === tenantKey && row.environment === environment && row.lifecycle === 'active',\n );\n return match ? clone(match) : null;\n },\n async getPolicyVersion(tenantKey, id) {\n const row = policies.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listPolicyVersions(tenantKey) {\n return [...policies.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async savePolicyVersion(policy) {\n if (policy.lifecycle === 'active') {\n for (const [key, row] of policies) {\n if (row.tenantKey === policy.tenantKey && row.environment === policy.environment && row.lifecycle === 'active' && row.id !== policy.id) {\n policies.set(key, { ...row, lifecycle: 'retired' });\n }\n }\n }\n policies.set(k(policy.tenantKey, policy.id), clone(policy));\n },\n async listProtectedActionRequirements(tenantKey, action, policyVersionId) {\n return [...requirements.values()]\n .filter((row) => row.tenantKey === tenantKey && row.action === action && row.policyVersionId === policyVersionId)\n .map(clone);\n },\n async saveProtectedActionRequirement(requirement) {\n requirements.set(k(requirement.tenantKey, requirement.id), clone(requirement));\n },\n async getContinuationDestinations(tenantKey) {\n const tenant = tenants.get(tenantKey);\n return tenant ? [...tenant.continuationDestinations] : ['verification.resume'];\n },\n async getAttempt(tenantKey, attemptId) {\n const row = attempts.get(k(tenantKey, attemptId));\n return row ? clone(row) : null;\n },\n async getAttemptByIdempotencyKey(tenantKey, key) {\n const match = [...attempts.values()].find((row) => row.tenantKey === tenantKey && row.idempotencyKey === key);\n return match ? clone(match) : null;\n },\n async findAttemptByProviderResource(tenantKey, provider, providerResourceId) {\n const match = [...attempts.values()].find(\n (row) => row.tenantKey === tenantKey && row.provider === provider && row.providerResourceId === providerResourceId,\n );\n return match ? clone(match) : null;\n },\n async listAttempts(tenantKey) {\n return [...attempts.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async listLiveAttempts(tenantKey, subjectHash, packageCode: VerificationPackageCode) {\n const live = new Set(['created', 'pending_user_input', 'paused', 'processing', 'manual_review_required']);\n return [...attempts.values()]\n .filter((row) => row.tenantKey === tenantKey && row.subjectHash === subjectHash && row.packageCode === packageCode && live.has(row.canonicalStatus))\n .map(clone);\n },\n async insertAttempt(attempt) {\n const key = k(attempt.tenantKey, attempt.id);\n if (attempts.has(key)) throw new Error('Attempt already exists.');\n const idemKey = k(attempt.tenantKey, 'idem', attempt.idempotencyKey);\n if ([...attempts.values()].some((row) => row.tenantKey === attempt.tenantKey && row.idempotencyKey === attempt.idempotencyKey)) {\n throw new Error('Idempotency key already used.');\n }\n attempts.set(key, clone(attempt));\n void idemKey;\n return clone(attempt);\n },\n async updateAttempt(attempt) {\n attempts.set(k(attempt.tenantKey, attempt.id), clone(attempt));\n },\n async insertLineage(row) {\n lineage.set(k(row.tenantKey, row.id), clone(row));\n },\n async listLineage(tenantKey, attemptId) {\n return [...lineage.values()].filter((row) => row.tenantKey === tenantKey && row.attemptId === attemptId).map(clone);\n },\n async getValidDecision(tenantKey, subjectHash, packageCode, at) {\n const matches = [...decisions.values()]\n .filter((row) => (\n row.tenantKey === tenantKey\n && row.subjectHash === subjectHash\n && row.packageCode === packageCode\n && row.status === 'verified'\n && !row.revokedAt\n && (!row.expiresAt || row.expiresAt > at.toISOString())\n ))\n .sort((left, right) => right.effectiveAt.localeCompare(left.effectiveAt));\n return matches[0] ? clone(matches[0]) : null;\n },\n async insertDecision(decision) {\n decisions.set(k(decision.tenantKey, decision.id), clone(decision));\n },\n async listDecisions(tenantKey, subjectHash) {\n return [...decisions.values()]\n .filter((row) => row.tenantKey === tenantKey && (!subjectHash || row.subjectHash === subjectHash))\n .map(clone);\n },\n async revokeDecision(tenantKey, decisionId, at) {\n const row = decisions.get(k(tenantKey, decisionId));\n if (row) decisions.set(k(tenantKey, decisionId), { ...row, status: 'revoked', revokedAt: at });\n },\n async claimIdempotency(claim) {\n return lockFor(k(claim.tenantKey, claim.claimKey)).run(async () => {\n const existing = idempotency.get(k(claim.tenantKey, claim.claimKey));\n if (existing) return { disposition: 'existing' as const, claim: clone(existing) };\n idempotency.set(k(claim.tenantKey, claim.claimKey), clone(claim));\n return { disposition: 'claimed' as const, claim: clone(claim) };\n });\n },\n async completeIdempotency(tenantKey, key, resultRef) {\n const row = idempotency.get(k(tenantKey, key));\n if (row) {\n idempotency.set(k(tenantKey, key), {\n ...row,\n state: 'completed',\n resultRef,\n completedAt: iso(),\n });\n }\n },\n async failIdempotency(tenantKey, key, errorCode) {\n const row = idempotency.get(k(tenantKey, key));\n if (row) {\n idempotency.set(k(tenantKey, key), {\n ...row,\n state: 'failed',\n errorCode,\n completedAt: iso(),\n });\n }\n },\n async getIdempotencyClaim(tenantKey, key) {\n const row = idempotency.get(k(tenantKey, key));\n return row ? clone(row) : null;\n },\n async claimWebhookEvent(input) {\n const key = k(input.tenantKey, input.provider, input.providerEventKey);\n const existing = webhooks.get(key);\n if (existing) {\n if (existing.bodySha256 !== input.bodySha256) {\n const dead: WebhookEventRecord = { ...existing, state: 'dead_letter' };\n webhooks.set(key, dead);\n return { disposition: 'mismatch' as const, event: clone(dead) };\n }\n return { disposition: 'duplicate' as const, event: clone(existing) };\n }\n const event: WebhookEventRecord = {\n tenantKey: input.tenantKey,\n id: newId('wh'),\n provider: input.provider,\n providerEventKey: input.providerEventKey,\n providerResourceId: input.providerResourceId,\n eventType: input.eventType,\n occurredAt: input.occurredAt,\n bodySha256: input.bodySha256,\n safeMetadata: input.safeMetadata,\n state: 'accepted',\n receivedAt: iso(),\n };\n webhooks.set(key, event);\n return { disposition: 'claimed', event: clone(event) };\n },\n async getWebhookEvent(tenantKey, provider, eventKey) {\n const row = webhooks.get(k(tenantKey, provider, eventKey));\n return row ? clone(row) : null;\n },\n async getWebhookEventById(tenantKey, eventId) {\n const row = [...webhooks.values()].find((event) => event.tenantKey === tenantKey && event.id === eventId);\n return row ? clone(row) : null;\n },\n async settleWebhookEvent(tenantKey, eventId, outcome) {\n for (const [key, row] of webhooks) {\n if (row.tenantKey === tenantKey && row.id === eventId) {\n webhooks.set(key, { ...row, state: outcome });\n }\n }\n },\n async recordHealth(observation) {\n health.set(k(observation.tenantKey, observation.id), clone(observation));\n },\n async listHealth(tenantKey, provider?: VerificationProviderCode) {\n return [...health.values()]\n .filter((row) => row.tenantKey === tenantKey && (!provider || row.provider === provider))\n .map(clone);\n },\n async getCircuit(tenantKey, provider, environment: VerificationProviderEnvironment) {\n const key = k(tenantKey, provider, environment);\n const existing = circuits.get(key);\n if (existing) return clone(existing);\n const created: CircuitRecord = {\n tenantKey,\n provider,\n environment,\n state: 'closed',\n reasonCode: null,\n openUntil: null,\n consecutiveFailures: 0,\n drainedByActorId: null,\n updatedAt: iso(),\n };\n circuits.set(key, created);\n return clone(created);\n },\n async saveCircuit(circuit) {\n circuits.set(k(circuit.tenantKey, circuit.provider, circuit.environment), clone(circuit));\n },\n async listCircuits(tenantKey) {\n return [...circuits.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveAppeal(appeal) {\n appeals.set(k(appeal.tenantKey, appeal.id), clone(appeal));\n },\n async getAppeal(tenantKey, id) {\n const row = appeals.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listAppeals(tenantKey) {\n return [...appeals.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveReviewCase(reviewCase) {\n reviews.set(k(reviewCase.tenantKey, reviewCase.id), clone(reviewCase));\n },\n async getReviewCase(tenantKey, id) {\n const row = reviews.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listReviewCases(tenantKey) {\n return [...reviews.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveManualDecisionProposal(proposal) {\n proposals.set(k(proposal.tenantKey, proposal.id), clone(proposal));\n },\n async getManualDecisionProposal(tenantKey, id) {\n const row = proposals.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listManualDecisionProposals(tenantKey) {\n return [...proposals.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveContinuation(continuation) {\n continuations.set(k(continuation.tenantKey, continuation.key), clone(continuation));\n },\n async getContinuation(tenantKey, key) {\n const row = continuations.get(k(tenantKey, key));\n return row ? clone(row) : null;\n },\n async appendAudit(event) {\n audit.set(k(event.tenantKey, event.id), clone(event));\n },\n async listAudit(tenantKey) {\n return [...audit.values()].filter((row) => row.tenantKey === tenantKey).map(clone);\n },\n async saveJob(job) {\n jobs.set(k(job.tenantKey, job.id), clone(job));\n },\n async getJob(tenantKey, id) {\n const row = jobs.get(k(tenantKey, id));\n return row ? clone(row) : null;\n },\n async listJobs(tenantKey, kind?: QueueJobKind) {\n return [...jobs.values()].filter((row) => row.tenantKey === tenantKey && (!kind || row.kind === kind)).map(clone);\n },\n async claimJobs(input) {\n const claimed: JobRecord[] = [];\n const pending = ['scheduled', 'retryable', 'processing'];\n for (const [key, job] of jobs) {\n if (claimed.length >= input.limit) break;\n if (job.tenantKey !== input.tenantKey || !input.kinds.includes(job.kind)) continue;\n if (!pending.includes(job.state) && job.state !== 'processing') continue;\n if (job.state === 'processing' && job.leaseExpiresAt && job.leaseExpiresAt > input.now.toISOString()) continue;\n if (job.nextAttemptAt > input.now.toISOString()) continue;\n const next: JobRecord = {\n ...job,\n state: job.kind === 'redact' ? 'processing' : 'processing',\n leaseId: newId('lease'),\n leaseExpiresAt: new Date(input.now.getTime() + input.leaseSeconds * 1000).toISOString(),\n attemptCount: job.attemptCount + 1,\n };\n jobs.set(key, next);\n claimed.push(clone(next));\n }\n return claimed;\n },\n async updateJob(job) {\n jobs.set(k(job.tenantKey, job.id), clone(job));\n },\n async updateRedactionStatus(tenantKey, jobId, status: RedactionStatus) {\n const row = jobs.get(k(tenantKey, jobId));\n if (row) jobs.set(k(tenantKey, jobId), { ...row, state: status });\n },\n };\n\n return store;\n}\n","import type { JobRecord, QueueJobKind } from './types.ts';\n\nexport interface VerificationQueue {\n enqueue(job: JobRecord): Promise<void>;\n claim(input: {\n tenantKey: string;\n kinds: QueueJobKind[];\n workerId: string;\n leaseSeconds: number;\n limit: number;\n now: Date;\n }): Promise<JobRecord[]>;\n complete(tenantKey: string, jobId: string, leaseId: string): Promise<void>;\n retry(\n tenantKey: string,\n jobId: string,\n leaseId: string,\n options: { errorCode: string; retryAfterSeconds: number; deadLetter?: boolean },\n ): Promise<void>;\n}\n\nexport function backoffSeconds(attemptCount: number, retryAfterSeconds?: number, random = Math.random): number {\n if (retryAfterSeconds && retryAfterSeconds > 0) return retryAfterSeconds;\n const base = Math.min(2 ** Math.max(0, attemptCount), 300);\n const jitter = random() * base * 0.25;\n return Math.max(1, Math.round(base + jitter));\n}\n","import type { VerificationStore } from './store.ts';\nimport { backoffSeconds, type VerificationQueue } from './queue.ts';\nimport type { JobRecord, QueueJobKind } from './types.ts';\nimport { EngineError } from './errors.ts';\n\nexport function createMemoryQueue(store: VerificationStore, options: { random?: () => number } = {}): VerificationQueue {\n const random = options.random ?? Math.random;\n return {\n async enqueue(job: JobRecord) {\n await store.saveJob(job);\n },\n async claim(input) {\n return store.claimJobs(input);\n },\n async complete(tenantKey, jobId, leaseId) {\n const job = await store.getJob(tenantKey, jobId);\n if (!job || job.leaseId !== leaseId) {\n throw new EngineError('OPERATION_PENDING', 'The queue lease is no longer valid.');\n }\n await store.updateJob({\n ...job,\n state: job.kind === 'redact' ? 'redacted' : 'completed',\n leaseId: null,\n leaseExpiresAt: null,\n });\n },\n async retry(tenantKey, jobId, leaseId, retry) {\n const job = await store.getJob(tenantKey, jobId);\n if (!job || job.leaseId !== leaseId) {\n throw new EngineError('OPERATION_PENDING', 'The queue lease is no longer valid.');\n }\n const delay = backoffSeconds(job.attemptCount, retry.retryAfterSeconds, random);\n await store.updateJob({\n ...job,\n state: retry.deadLetter ? 'dead_letter' : 'retryable',\n leaseId: null,\n leaseExpiresAt: null,\n lastErrorCode: retry.errorCode,\n nextAttemptAt: new Date(store.now().getTime() + delay * 1000).toISOString(),\n });\n },\n };\n}\n\nexport type { QueueJobKind };\n","import type {\n ActorContext,\n ProtectedActionDenial,\n ProviderLaunchEnvelope,\n ProviderOrganizationInput,\n ProviderRelationshipInput,\n VerificationCanonicalStatus,\n VerificationPackageCode,\n VerificationProviderCode,\n VerificationProviderEnvironment,\n} from '@splitin/verification-adapter-sdk';\n\nexport type {\n ActorContext,\n ProtectedActionDenial,\n VerificationCanonicalStatus,\n VerificationPackageCode,\n VerificationProviderCode,\n VerificationProviderEnvironment,\n};\n\nexport const FORBIDDEN_CLIENT_ROUTE_KEYS = [\n 'provider',\n 'templateId',\n 'template_id',\n 'workflowId',\n 'workflow_id',\n 'apiOrigin',\n 'api_origin',\n 'configurationRevision',\n 'configuration_revision',\n 'adapterVersion',\n 'manifestDigest',\n 'policyVersion',\n 'routeId',\n] as const;\n\nexport const LIVE_ATTEMPT_STATUSES: VerificationCanonicalStatus[] = [\n 'created',\n 'pending_user_input',\n 'paused',\n 'processing',\n 'manual_review_required',\n];\n\nexport const GOVERNANCE_TRANSITIONS = [\n 'approve',\n 'deny',\n 'request_more_information',\n 'revoke',\n 'expire',\n] as const;\n\nexport type GovernanceTransition = (typeof GOVERNANCE_TRANSITIONS)[number];\n\nexport type CircuitState = 'closed' | 'open' | 'half_open';\nexport type RouteLifecycle = 'draft' | 'approved' | 'active' | 'retired';\nexport type PolicyLifecycle = 'draft' | 'approved' | 'active' | 'retired';\nexport type IdempotencyState = 'claimed' | 'completed' | 'failed';\nexport type WebhookEventState = 'accepted' | 'processing' | 'completed' | 'retryable' | 'dead_letter';\nexport type RedactionStatus =\n | 'scheduled'\n | 'processing'\n | 'retryable'\n | 'redacted'\n | 'not_applicable'\n | 'dead_letter';\nexport type QueueJobKind = 'webhook' | 'reconcile' | 'redact';\nexport type AppealStatus = 'open' | 'approved' | 'denied' | 'more_information_requested' | 'revoked' | 'expired';\nexport type ReviewStatus = AppealStatus | 'in_review';\nexport type ProposalStatus = 'proposed' | 'approved' | 'rejected';\nexport type DecisionStatus = 'verified' | 'declined' | 'revoked' | 'expired';\n\n/** Application-defined reason codes the SDK stores without interpreting housing or biometric policy. */\nexport const APPLICATION_REASON_CODES = [\n 'underage',\n 'unsupported_capability',\n 'biometric_alternative_requested',\n 'manual_review_required',\n 'document_unreadable',\n 'more_information_requested',\n] as const;\n\nexport function isApplicationReasonCode(value: string): value is ApplicationReasonCode {\n return (APPLICATION_REASON_CODES as readonly string[]).includes(value);\n}\n\nexport type ApplicationReasonCode = (typeof APPLICATION_REASON_CODES)[number];\n\nexport type EngineOperation =\n | 'start'\n | 'resume'\n | 'status'\n | 'retry'\n | 'pause'\n | 'cancel'\n | 'redact'\n | 'ingest_webhook'\n | 'process_webhook'\n | 'reconcile'\n | 'appeal'\n | 'review'\n | 'evaluate_protected_action'\n | 'admin.health'\n | 'admin.routes'\n | 'admin.circuits'\n | 'admin.attempts'\n | 'admin.audit'\n | 'admin.propose_route'\n | 'admin.approve_route'\n | 'admin.propose_policy'\n | 'admin.approve_policy'\n | 'admin.activate_policy'\n | 'admin.emergency_drain';\n\nexport interface AuthorizeFn {\n (actor: ActorContext, operation: EngineOperation, resource: { type: string; id?: string }): Promise<boolean> | boolean;\n}\n\nexport interface EngineRuntime {\n now?: () => Date;\n crypto?: Crypto;\n productionEnabled?: boolean;\n seedSandboxExamples?: boolean;\n continuationTtlSeconds?: number;\n webhookLeaseSeconds?: number;\n maxWorkerAttempts?: number;\n workerConcurrency?: number;\n defaultDecisionTtlSeconds?: number;\n rateBudgetPerProvider?: number;\n random?: () => number;\n}\n\nexport interface StartVerificationCommand {\n packageCode: VerificationPackageCode;\n countryCode: string;\n subjectReference: string;\n idempotencyKey: string;\n action?: string | null;\n resourceType?: string | null;\n resourceReference?: string | null;\n organization?: ProviderOrganizationInput | null;\n relationship?: ProviderRelationshipInput | null;\n associatedPerson?: ProviderAssociatedPersonLike | null;\n legalFirstName?: string | null;\n legalLastName?: string | null;\n email?: string | null;\n requestOrigin?: string | null;\n metadata?: Record<string, string | number | boolean | null>;\n evidenceReferences?: string[];\n}\n\ninterface ProviderAssociatedPersonLike {\n subjectReference: string;\n legalFirstName: string;\n legalLastName: string;\n email?: string | null;\n relationshipKind: string;\n claimedOwnershipPercentage?: number | null;\n}\n\nexport interface ResumeVerificationCommand {\n attemptId: string;\n requestOrigin?: string | null;\n}\n\nexport interface RetryVerificationCommand extends StartVerificationCommand {\n parentAttemptId: string;\n}\n\nexport interface RedactCommand {\n subjectReference: string;\n attemptId?: string | null;\n requestReference?: string | null;\n}\n\nexport interface ProtectedActionCommand {\n action: string;\n resourceType: string;\n resourceReference: string;\n subjectReference: string;\n destinationKey?: string;\n}\n\nexport interface IngestWebhookCommand {\n provider: VerificationProviderCode;\n request: Request;\n tenantKey: string;\n}\n\nexport interface AppealSubmitCommand {\n attemptId: string;\n reason: string;\n expiresAt?: string | null;\n}\n\nexport interface AppealTransitionCommand {\n appealId: string;\n transition: GovernanceTransition;\n reason: string;\n}\n\nexport interface ReviewProposeCommand {\n attemptId: string;\n proposedStatus: DecisionStatus;\n reason: string;\n expiresAt?: string | null;\n}\n\nexport interface ReviewDecideCommand {\n proposalId: string;\n transition: Extract<GovernanceTransition, 'approve' | 'deny'>;\n reason: string;\n}\n\nexport interface ReviewCaseTransitionCommand {\n reviewCaseId: string;\n transition: GovernanceTransition;\n reason: string;\n}\n\nexport interface SafeAttemptView {\n attemptId: string;\n packageCode: VerificationPackageCode;\n status: VerificationCanonicalStatus;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n adapterVersion: string;\n manifestDigest: string;\n configurationRevision: string;\n policyVersion: string;\n canResume: boolean;\n canRetry: boolean;\n expiresAt: string | null;\n safeErrorCode: string | null;\n retryAfter: string | null;\n supportPath: string | null;\n launch: ProviderLaunchEnvelope | null;\n}\n\nexport interface ProtectedActionAllow {\n allowed: true;\n}\n\nexport type ProtectedActionResult = ProtectedActionAllow | ProtectedActionDenial;\n\nexport interface TenantRecord {\n tenantKey: string;\n displayName: string;\n continuationDestinations: string[];\n createdAt: string;\n}\n\nexport interface ConfigurationRevisionRecord {\n tenantKey: string;\n id: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n revision: number;\n configurationDigest: string;\n lifecycle: 'draft' | 'approved' | 'retired';\n proposedByActorId: string | null;\n approvedByActorId: string | null;\n approvedAt: string | null;\n createdAt: string;\n}\n\nexport interface ProviderDefinitionRecord {\n tenantKey: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n adapterVersion: string;\n manifestDigest: string;\n compiledInRegistry: boolean;\n productionEligible: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RouteRecord {\n tenantKey: string;\n id: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n packageCode: VerificationPackageCode;\n countryCode: string | null;\n requiredCapability: string | null;\n priority: number;\n cohortMin: number;\n cohortMax: number;\n windowStart: string | null;\n windowEnd: string | null;\n allowlistRequired: boolean;\n allowlistedSubjectHashes: string[];\n configurationRevisionId: string;\n policyVersionId: string;\n lifecycle: RouteLifecycle;\n proposedByActorId: string | null;\n approvedByActorId: string | null;\n approvedAt: string | null;\n activatedAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RouteChangeRequestRecord {\n tenantKey: string;\n id: string;\n routeId: string | null;\n proposedPayload: Record<string, string | number | boolean | null>;\n status: ProposalStatus;\n reason: string;\n policyVersion: string;\n proposedByActorId: string;\n approvedByActorId: string | null;\n approvedAt: string | null;\n expiresAt: string | null;\n createdAt: string;\n}\n\nexport interface PolicyVersionRecord {\n tenantKey: string;\n id: string;\n version: string;\n environment: VerificationProviderEnvironment;\n lifecycle: PolicyLifecycle;\n reason: string;\n expiresAt: string | null;\n proposedByActorId: string | null;\n approvedByActorId: string | null;\n approvedAt: string | null;\n activatedAt: string | null;\n createdAt: string;\n decisionRetentionDays: number | null;\n providerRedactionDelayDays: number | null;\n appealHoldDays: number | null;\n legalHold: boolean;\n}\n\nexport interface ProtectedActionRequirementRecord {\n tenantKey: string;\n id: string;\n action: string;\n packageCode: VerificationPackageCode;\n policyVersionId: string;\n createdAt: string;\n}\n\nexport interface AttemptRecord {\n tenantKey: string;\n id: string;\n subjectHash: string;\n packageCode: VerificationPackageCode;\n countryCode: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n adapterVersion: string;\n manifestDigest: string;\n configurationRevision: string;\n policyVersion: string;\n providerResourceId: string | null;\n providerStatus: string | null;\n canonicalStatus: VerificationCanonicalStatus;\n statusVersion: number;\n idempotencyKey: string;\n parentAttemptId: string | null;\n purposeAction: string | null;\n purposeResourceHash: string | null;\n routeId: string;\n selectionReason: string;\n normalizedReasonCodes: string[];\n expiresAt: string | null;\n createClaimId: string | null;\n createClaimExpiresAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ProviderResourceLineageRecord {\n tenantKey: string;\n id: string;\n attemptId: string;\n resourceType: string;\n providerResourceId: string;\n relationshipCode: string;\n providerStatus: string;\n occurredAt: string;\n}\n\nexport interface DecisionRecord {\n tenantKey: string;\n id: string;\n subjectHash: string;\n packageCode: VerificationPackageCode;\n attemptId: string | null;\n status: DecisionStatus;\n source: 'provider' | 'manual';\n policyVersion: string;\n reasonCodes: string[];\n effectiveAt: string;\n expiresAt: string | null;\n revokedAt: string | null;\n proposerActorId: string | null;\n approverActorId: string | null;\n createdAt: string;\n}\n\nexport interface IdempotencyClaimRecord {\n tenantKey: string;\n claimKey: string;\n operation: string;\n attemptId: string | null;\n state: IdempotencyState;\n resultRef: string | null;\n errorCode: string | null;\n createdAt: string;\n completedAt: string | null;\n}\n\nexport interface WebhookEventRecord {\n tenantKey: string;\n id: string;\n provider: VerificationProviderCode;\n providerEventKey: string;\n providerResourceId: string;\n eventType: string;\n occurredAt: string;\n bodySha256: string;\n safeMetadata: Record<string, string | boolean | number | null>;\n state: WebhookEventState;\n receivedAt: string;\n}\n\nexport interface WebhookLeaseRecord {\n tenantKey: string;\n eventId: string;\n leaseId: string | null;\n workerId: string | null;\n expiresAt: string | null;\n attemptCount: number;\n nextAttemptAt: string;\n lastErrorCode: string | null;\n}\n\nexport interface JobRecord {\n tenantKey: string;\n id: string;\n kind: QueueJobKind;\n attemptId: string | null;\n eventId: string | null;\n subjectHash: string | null;\n providerResourceId: string | null;\n state: 'scheduled' | 'processing' | 'retryable' | 'completed' | 'dead_letter' | RedactionStatus;\n leaseId: string | null;\n leaseExpiresAt: string | null;\n attemptCount: number;\n nextAttemptAt: string;\n lastErrorCode: string | null;\n createdAt: string;\n}\n\nexport interface HealthObservationRecord {\n tenantKey: string;\n id: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n operation: string;\n outcome: 'success' | 'retryable_failure' | 'terminal_failure' | 'unknown_status';\n safeCode: string;\n observedAt: string;\n latencyMs: number | null;\n}\n\nexport interface CircuitRecord {\n tenantKey: string;\n provider: VerificationProviderCode;\n environment: VerificationProviderEnvironment;\n state: CircuitState;\n reasonCode: string | null;\n openUntil: string | null;\n consecutiveFailures: number;\n drainedByActorId: string | null;\n updatedAt: string;\n}\n\nexport interface AppealRecord {\n tenantKey: string;\n id: string;\n attemptId: string;\n subjectHash: string;\n status: AppealStatus;\n reason: string;\n policyVersion: string;\n proposedByActorId: string;\n decidedByActorId: string | null;\n expiresAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ReviewCaseRecord {\n tenantKey: string;\n id: string;\n attemptId: string;\n subjectHash: string;\n status: ReviewStatus;\n reason: string;\n policyVersion: string;\n assignedActorId: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ManualDecisionProposalRecord {\n tenantKey: string;\n id: string;\n reviewCaseId: string | null;\n attemptId: string;\n proposedStatus: DecisionStatus;\n reason: string;\n policyVersion: string;\n expiresAt: string | null;\n proposedByActorId: string;\n approvedByActorId: string | null;\n status: ProposalStatus;\n createdAt: string;\n}\n\nexport interface ContinuationRecord {\n tenantKey: string;\n key: string;\n tokenHash: string;\n action: string;\n resourceHash: string;\n subjectHash: string;\n destinationKey: string;\n expiresAt: string;\n consumedAt: string | null;\n}\n\nexport interface AuditEventRecord {\n tenantKey: string;\n id: string;\n actorId: string;\n actorType: ActorContext['actorType'];\n operation: string;\n resourceType: string;\n resourceId: string | null;\n reasonCode: string | null;\n safeMetadata: Record<string, string | number | boolean | null>;\n occurredAt: string;\n}\n\nexport interface WebhookClaimResult {\n disposition: 'claimed' | 'duplicate' | 'mismatch' | 'in_progress' | 'dead_letter';\n event: WebhookEventRecord;\n}\n\nexport interface IngestWebhookResult {\n accepted: true;\n duplicate: boolean;\n eventId: string;\n}\n\nexport type RateAcquireResult = { allowed: boolean; retryAfterSeconds?: number };\n","import { isCountryCode, metadataContainsForbiddenIdentifier } from '@splitin/verification-adapter-sdk';\n\nimport { ClientRouteInjectionError, EngineError } from './errors.ts';\nimport { FORBIDDEN_CLIENT_ROUTE_KEYS } from './types.ts';\n\nexport function assertNoClientRouting(command: object): void {\n const record = command as Record<string, unknown>;\n for (const key of FORBIDDEN_CLIENT_ROUTE_KEYS) {\n if (record[key] !== undefined && record[key] !== null) {\n throw new ClientRouteInjectionError();\n }\n }\n}\n\nexport function assertStartCommand(command: {\n packageCode: string;\n countryCode: string;\n subjectReference: string;\n idempotencyKey: string;\n metadata?: unknown;\n}): void {\n if (!command.packageCode || !command.subjectReference || !command.idempotencyKey) {\n throw new EngineError('INVALID_COMMAND', 'A verification start command is missing required fields.');\n }\n if (!isCountryCode(command.countryCode)) {\n throw new EngineError('INVALID_COMMAND', 'A verification start command must include an ISO country code.');\n }\n if (metadataContainsForbiddenIdentifier(command.metadata)) {\n throw new EngineError('INVALID_COMMAND', 'Attempt metadata must not contain government identifiers.');\n }\n}\n\nexport function twoActorApproved(proposedBy: string | null | undefined, approvedBy: string | null | undefined): boolean {\n return Boolean(proposedBy && approvedBy && proposedBy !== approvedBy);\n}\n","import {\n isTerminalStatus,\n ProviderError,\n ProviderOperationPendingError,\n toSafeProviderFailure,\n type ActorContext,\n type ProtectedActionDenial,\n type ProviderAttemptCommand,\n type ProviderHealthObservation,\n type ProviderLaunchEnvelope,\n type VerificationAdapterV1,\n type VerificationCanonicalStatus,\n} from '@splitin/verification-adapter-sdk';\n\nimport { digestCanonical } from './canonical.ts';\nimport {\n AuthorizationError,\n EngineError,\n WebhookSecurityIncidentError,\n} from './errors.ts';\nimport { assertNoClientRouting, assertStartCommand, twoActorApproved } from './guards.ts';\nimport { newId, randomToken, sha256Hex } from './hash.ts';\nimport { backoffSeconds, type VerificationQueue } from './queue.ts';\nimport { createRateBudget } from './rate-budget.ts';\nimport type { ProviderRegistry } from './registry.ts';\nimport { selectRoute } from './routing.ts';\nimport { seedSandboxExamples } from './seed.ts';\nimport { applyMonotonicStatus } from './status.ts';\nimport type { PolicyStore, VerificationStore } from './store.ts';\nimport { isApplicationReasonCode } from './types.ts';\nimport type {\n AppealSubmitCommand,\n AppealTransitionCommand,\n AttemptRecord,\n AuthorizeFn,\n EngineOperation,\n EngineRuntime,\n IngestWebhookCommand,\n IngestWebhookResult,\n JobRecord,\n ProtectedActionAllow,\n ProtectedActionCommand,\n ProtectedActionResult,\n RedactCommand,\n RedactionStatus,\n ResumeVerificationCommand,\n RetryVerificationCommand,\n ReviewCaseTransitionCommand,\n ReviewDecideCommand,\n ReviewProposeCommand,\n RouteRecord,\n SafeAttemptView,\n StartVerificationCommand,\n} from './types.ts';\n\nexport interface CreateVerificationPlatformInput {\n registry: ProviderRegistry;\n store: VerificationStore;\n queue: VerificationQueue;\n policyStore?: PolicyStore;\n authorize: AuthorizeFn;\n runtime?: EngineRuntime;\n}\n\nexport interface VerificationPlatform {\n start(actor: ActorContext, command: StartVerificationCommand): Promise<SafeAttemptView>;\n resume(actor: ActorContext, command: ResumeVerificationCommand): Promise<SafeAttemptView>;\n status(actor: ActorContext, attemptId: string): Promise<SafeAttemptView>;\n retry(actor: ActorContext, command: RetryVerificationCommand): Promise<SafeAttemptView>;\n pause(actor: ActorContext, attemptId: string): Promise<SafeAttemptView>;\n cancel(actor: ActorContext, attemptId: string): Promise<SafeAttemptView>;\n redact(actor: ActorContext, command: RedactCommand): Promise<{ jobId: string; status: string }>;\n ingestWebhook(command: IngestWebhookCommand): Promise<IngestWebhookResult>;\n processWebhookJob(tenantKey: string, job: JobRecord): Promise<void>;\n reconcile(actor: ActorContext, attemptId?: string): Promise<{ reconciled: number }>;\n appeal: {\n submit(actor: ActorContext, command: AppealSubmitCommand): Promise<{ appealId: string }>;\n transition(actor: ActorContext, command: AppealTransitionCommand): Promise<{ status: string }>;\n };\n review: {\n propose(actor: ActorContext, command: ReviewProposeCommand): Promise<{ proposalId: string; reviewCaseId: string }>;\n decide(actor: ActorContext, command: ReviewDecideCommand): Promise<{ status: string }>;\n transitionCase(actor: ActorContext, command: ReviewCaseTransitionCommand): Promise<{ status: string }>;\n };\n admin: {\n health(actor: ActorContext): Promise<unknown>;\n routes(actor: ActorContext): Promise<unknown>;\n circuits(actor: ActorContext): Promise<unknown>;\n attempts(actor: ActorContext): Promise<unknown>;\n audit(actor: ActorContext): Promise<unknown>;\n proposeRoute(actor: ActorContext, input: { route: Omit<RouteRecord, 'lifecycle' | 'approvedByActorId' | 'approvedAt' | 'activatedAt'>; reason: string }): Promise<{ requestId: string }>;\n approveRoute(actor: ActorContext, requestId: string, reason: string): Promise<{ routeId: string }>;\n proposePolicy(actor: ActorContext, input: {\n version: string;\n environment: 'sandbox' | 'production';\n reason: string;\n expiresAt?: string | null;\n decisionRetentionDays?: number | null;\n providerRedactionDelayDays?: number | null;\n appealHoldDays?: number | null;\n legalHold?: boolean;\n }): Promise<{ policyId: string }>;\n approvePolicy(actor: ActorContext, policyId: string, reason: string): Promise<{ policyId: string }>;\n activatePolicy(actor: ActorContext, policyId: string): Promise<{ policyId: string }>;\n emergencyDrain(actor: ActorContext, provider: string, environment: 'sandbox' | 'production', reason: string): Promise<{ state: string }>;\n };\n evaluateProtectedAction(actor: ActorContext, command: ProtectedActionCommand): Promise<ProtectedActionResult>;\n workers: {\n claim(actor: ActorContext, input?: { workerId?: string; kinds?: JobRecord['kind'][]; limit?: number }): Promise<JobRecord[]>;\n process(actor: ActorContext, job: JobRecord | { id: string }): Promise<{ processed: boolean; disposition: string }>;\n scheduleReconciliation(actor: ActorContext): Promise<{ enqueued: number }>;\n };\n}\n\nconst CLIENT_OPS = new Set<EngineOperation>([\n 'start', 'resume', 'status', 'retry', 'pause', 'cancel', 'evaluate_protected_action', 'appeal',\n]);\n\nexport function createVerificationPlatform(input: CreateVerificationPlatformInput): VerificationPlatform {\n const runtime: EngineRuntime = input.runtime ?? {};\n const store = input.store;\n const queue = input.queue;\n const policyStore = input.policyStore ?? store;\n const registry = input.registry;\n const now = () => (runtime.now ?? store.now ?? (() => new Date()))();\n const cryptoImpl = runtime.crypto ?? globalThis.crypto;\n const createLocks = new Map<string, Promise<unknown>>();\n const rateBudget = createRateBudget(runtime.rateBudgetPerProvider ?? 25);\n let boot: Promise<void> | null = null;\n\n const ready = () => {\n if (!boot) boot = bootstrap();\n return boot;\n };\n\n async function bootstrap(): Promise<void> {\n if (runtime.seedSandboxExamples !== false) {\n await seedSandboxExamples(store, registry, runtime);\n } else {\n const iso = now().toISOString();\n for (const adapter of registry.list()) {\n await store.upsertProviderDefinition({\n tenantKey: 'default',\n provider: adapter.provider,\n environment: adapter.environment,\n adapterVersion: adapter.manifest.adapterVersion,\n manifestDigest: await digestCanonical(adapter.manifest),\n compiledInRegistry: true,\n productionEligible: false,\n createdAt: iso,\n updatedAt: iso,\n });\n }\n }\n }\n\n async function authorize(actor: ActorContext, operation: EngineOperation, resource: { type: string; id?: string }) {\n const allowed = await input.authorize(actor, operation, resource);\n if (!allowed) throw new AuthorizationError();\n }\n\n async function audit(\n actor: ActorContext,\n operation: string,\n resourceType: string,\n resourceId: string | null,\n reasonCode: string | null,\n safeMetadata: Record<string, string | number | boolean | null> = {},\n ) {\n await store.appendAudit({\n tenantKey: actor.tenantKey,\n id: newId('aud', cryptoImpl),\n actorId: actor.actorId,\n actorType: actor.actorType,\n operation,\n resourceType,\n resourceId,\n reasonCode,\n safeMetadata,\n occurredAt: now().toISOString(),\n });\n }\n\n function adapterFor(provider: string, environment: 'sandbox' | 'production'): VerificationAdapterV1 {\n return registry.get(provider, environment);\n }\n\n async function recordHealth(adapter: VerificationAdapterV1, actorTenant: string, observation: ProviderHealthObservation) {\n await store.recordHealth({\n tenantKey: actorTenant,\n id: newId('hlth', cryptoImpl),\n provider: adapter.provider,\n environment: adapter.environment,\n operation: observation.operation,\n outcome: observation.outcome,\n safeCode: observation.safeCode,\n observedAt: observation.observedAt,\n latencyMs: observation.latencyMs ?? null,\n });\n const circuit = await store.getCircuit(actorTenant, adapter.provider, adapter.environment);\n if (observation.outcome === 'success') {\n await store.saveCircuit({\n ...circuit,\n consecutiveFailures: 0,\n state: circuit.drainedByActorId ? circuit.state : 'closed',\n reasonCode: circuit.drainedByActorId ? circuit.reasonCode : null,\n openUntil: circuit.drainedByActorId ? circuit.openUntil : null,\n updatedAt: now().toISOString(),\n });\n return;\n }\n if (observation.outcome === 'retryable_failure' || observation.outcome === 'terminal_failure') {\n const failures = circuit.consecutiveFailures + 1;\n const open = failures >= 5;\n await store.saveCircuit({\n ...circuit,\n consecutiveFailures: failures,\n state: open ? 'open' : circuit.state,\n reasonCode: observation.safeCode,\n openUntil: open ? new Date(now().getTime() + 300_000).toISOString() : circuit.openUntil,\n updatedAt: now().toISOString(),\n });\n }\n }\n\n async function toView(attempt: AttemptRecord, launch: ProviderLaunchEnvelope | null = null): Promise<SafeAttemptView> {\n return {\n attemptId: attempt.id,\n packageCode: attempt.packageCode,\n status: attempt.canonicalStatus,\n provider: attempt.provider,\n environment: attempt.environment,\n adapterVersion: attempt.adapterVersion,\n manifestDigest: attempt.manifestDigest,\n configurationRevision: attempt.configurationRevision,\n policyVersion: attempt.policyVersion,\n canResume: !isTerminalStatus(attempt.canonicalStatus),\n canRetry: ['declined', 'failed', 'expired', 'canceled', 'provider_unavailable'].includes(attempt.canonicalStatus),\n expiresAt: attempt.expiresAt,\n safeErrorCode: attempt.canonicalStatus === 'provider_unavailable' ? 'provider_unavailable' : null,\n retryAfter: null,\n supportPath: null,\n launch,\n };\n }\n\n async function persistDecision(attempt: AttemptRecord) {\n if (attempt.canonicalStatus !== 'verified') return;\n const existing = await store.getValidDecision(attempt.tenantKey, attempt.subjectHash, attempt.packageCode, now());\n if (existing) return;\n const ttl = (runtime.defaultDecisionTtlSeconds ?? 365 * 24 * 3600) * 1000;\n await store.insertDecision({\n tenantKey: attempt.tenantKey,\n id: newId('dec', cryptoImpl),\n subjectHash: attempt.subjectHash,\n packageCode: attempt.packageCode,\n attemptId: attempt.id,\n status: 'verified',\n source: 'provider',\n policyVersion: attempt.policyVersion,\n reasonCodes: attempt.normalizedReasonCodes,\n effectiveAt: now().toISOString(),\n expiresAt: new Date(now().getTime() + ttl).toISOString(),\n revokedAt: null,\n proposerActorId: null,\n approverActorId: null,\n createdAt: now().toISOString(),\n });\n }\n\n async function bindProviderResult(attempt: AttemptRecord, result: {\n providerResourceId: string;\n providerStatus: string;\n canonicalStatus: VerificationCanonicalStatus;\n linkedResources?: Array<{ resourceType: string; resourceId: string; relationshipCode: string; providerStatus: string; occurredAt: string }>;\n }): Promise<AttemptRecord> {\n const next: AttemptRecord = {\n ...attempt,\n providerResourceId: result.providerResourceId,\n providerStatus: result.providerStatus,\n canonicalStatus: applyMonotonicStatus(attempt.canonicalStatus, result.canonicalStatus),\n statusVersion: attempt.statusVersion + 1,\n createClaimId: null,\n createClaimExpiresAt: null,\n updatedAt: now().toISOString(),\n };\n await store.updateAttempt(next);\n await store.insertLineage({\n tenantKey: attempt.tenantKey,\n id: newId('lin', cryptoImpl),\n attemptId: attempt.id,\n resourceType: 'primary',\n providerResourceId: result.providerResourceId,\n relationshipCode: 'primary',\n providerStatus: result.providerStatus,\n occurredAt: now().toISOString(),\n });\n for (const linked of result.linkedResources ?? []) {\n await store.insertLineage({\n tenantKey: attempt.tenantKey,\n id: newId('lin', cryptoImpl),\n attemptId: attempt.id,\n resourceType: linked.resourceType,\n providerResourceId: linked.resourceId,\n relationshipCode: linked.relationshipCode,\n providerStatus: linked.providerStatus,\n occurredAt: linked.occurredAt,\n });\n }\n await persistDecision(next);\n return next;\n }\n\n function launchCommand(attempt: AttemptRecord, command: StartVerificationCommand): ProviderAttemptCommand {\n return {\n attemptId: attempt.id,\n subjectReference: command.subjectReference,\n organizationReference: command.organization?.legalName ?? null,\n packageCode: attempt.packageCode,\n countryCode: attempt.countryCode,\n idempotencyKey: attempt.idempotencyKey,\n configurationRevision: attempt.configurationRevision,\n legalFirstName: command.legalFirstName,\n legalLastName: command.legalLastName,\n email: command.email,\n organization: command.organization,\n relationship: command.relationship,\n associatedPerson: command.associatedPerson,\n evidenceReferences: command.evidenceReferences,\n requestOrigin: command.requestOrigin,\n metadata: command.metadata,\n };\n }\n\n async function createProviderResource(actor: ActorContext, attempt: AttemptRecord, command: StartVerificationCommand, adapter: VerificationAdapterV1) {\n const budget = rateBudget.consume(adapter.provider, now());\n if (!budget.allowed) {\n throw new EngineError(\n 'PROVIDER_UNAVAILABLE',\n 'The provider rate budget is exhausted.',\n true,\n budget.retryAfterSeconds,\n );\n }\n const started = now();\n try {\n const created = await adapter.createAttempt(launchCommand(attempt, command));\n await recordHealth(adapter, actor.tenantKey, {\n operation: 'create',\n outcome: 'success',\n safeCode: 'ok',\n observedAt: now().toISOString(),\n latencyMs: now().getTime() - started.getTime(),\n });\n return created;\n } catch (error) {\n const safe = toSafeProviderFailure(error);\n await recordHealth(adapter, actor.tenantKey, {\n operation: 'create',\n outcome: safe.retryable ? 'retryable_failure' : 'terminal_failure',\n safeCode: safe.safeCode,\n observedAt: now().toISOString(),\n latencyMs: now().getTime() - started.getTime(),\n });\n throw error;\n }\n }\n\n async function startLocked(actor: ActorContext, command: StartVerificationCommand): Promise<SafeAttemptView> {\n assertNoClientRouting(command);\n assertStartCommand(command);\n await authorize(actor, 'start', { type: 'package', id: command.packageCode });\n const subjectHash = await store.hashSubject(actor.tenantKey, command.subjectReference);\n const reused = await store.getValidDecision(actor.tenantKey, subjectHash, command.packageCode, now());\n if (reused?.attemptId) {\n const prior = await store.getAttempt(actor.tenantKey, reused.attemptId);\n if (prior) {\n await audit(actor, 'start', 'decision', reused.id, 'reused_verified_decision', { attemptId: prior.id });\n return toView(prior);\n }\n }\n const resourceHash = command.resourceReference && command.resourceType\n ? await store.hashResource(actor.tenantKey, command.resourceType, command.resourceReference)\n : null;\n const existing = await store.getAttemptByIdempotencyKey(actor.tenantKey, command.idempotencyKey);\n if (existing?.providerResourceId) {\n return toView(existing);\n }\n if (existing && existing.createClaimExpiresAt && existing.createClaimExpiresAt > now().toISOString()) {\n throw new ProviderOperationPendingError();\n }\n\n const productionPolicy = await store.getActivePolicy(actor.tenantKey, 'production');\n const environment = runtime.productionEnabled\n && productionPolicy?.lifecycle === 'active'\n && twoActorApproved(productionPolicy.proposedByActorId, productionPolicy.approvedByActorId)\n ? 'production' as const\n : 'sandbox' as const;\n const selected = await selectRoute({\n store,\n adapters: registry.list(),\n tenantKey: actor.tenantKey,\n packageCode: command.packageCode,\n countryCode: command.countryCode,\n subjectHash,\n environment: environment === 'production' ? 'production' : 'sandbox',\n runtime,\n });\n const adapter = selected.adapter;\n const manifestDigest = await digestCanonical(adapter.manifest);\n const iso = now().toISOString();\n const attemptId = newId('att', cryptoImpl);\n const claimKey = `start:${command.idempotencyKey}`;\n\n const prepared = await store.transact(async (tx) => {\n const claim = await tx.claimIdempotency({\n tenantKey: actor.tenantKey,\n claimKey,\n operation: 'start',\n attemptId,\n state: 'claimed',\n resultRef: null,\n errorCode: null,\n createdAt: iso,\n completedAt: null,\n });\n if (claim.disposition === 'existing' && claim.claim.resultRef) {\n const prior = await tx.getAttempt(actor.tenantKey, claim.claim.resultRef);\n if (prior) return { kind: 'existing' as const, attempt: prior };\n }\n if (claim.disposition === 'existing' && claim.claim.state === 'claimed') {\n throw new ProviderOperationPendingError();\n }\n const attempt: AttemptRecord = {\n tenantKey: actor.tenantKey,\n id: attemptId,\n subjectHash,\n packageCode: command.packageCode,\n countryCode: command.countryCode,\n provider: adapter.provider,\n environment: adapter.environment,\n adapterVersion: adapter.manifest.adapterVersion,\n manifestDigest,\n configurationRevision: selected.route.configurationRevisionId,\n policyVersion: selected.route.policyVersionId,\n providerResourceId: null,\n providerStatus: null,\n canonicalStatus: 'created',\n statusVersion: 0,\n idempotencyKey: command.idempotencyKey,\n parentAttemptId: null,\n purposeAction: command.action ?? null,\n purposeResourceHash: resourceHash,\n routeId: selected.route.id,\n selectionReason: selected.reason,\n normalizedReasonCodes: [],\n expiresAt: null,\n createClaimId: newId('claim', cryptoImpl),\n createClaimExpiresAt: new Date(now().getTime() + 30_000).toISOString(),\n createdAt: iso,\n updatedAt: iso,\n };\n await tx.insertAttempt(attempt);\n return { kind: 'created' as const, attempt };\n });\n\n if (prepared.kind === 'existing') return toView(prepared.attempt);\n\n try {\n const created = await createProviderResource(actor, prepared.attempt, command, adapter);\n const bound = await store.transact(async (tx) => {\n const latest = await tx.getAttempt(actor.tenantKey, prepared.attempt.id);\n if (!latest) throw new EngineError('ATTEMPT_NOT_FOUND', 'The verification attempt was lost after provider create.');\n const next = await bindProviderResult(latest, created);\n await tx.completeIdempotency(actor.tenantKey, claimKey, next.id);\n return next;\n });\n await audit(actor, 'start', 'attempt', bound.id, selected.reason, { provider: adapter.provider });\n return toView(bound, stripPersistedLaunch(created.launch));\n } catch (error) {\n await store.failIdempotency(actor.tenantKey, claimKey, toSafeProviderFailure(error).safeCode);\n await store.updateAttempt({\n ...prepared.attempt,\n canonicalStatus: 'provider_unavailable',\n createClaimId: null,\n createClaimExpiresAt: null,\n updatedAt: now().toISOString(),\n });\n throw error;\n }\n }\n\n async function start(actor: ActorContext, command: StartVerificationCommand): Promise<SafeAttemptView> {\n await ready();\n const lockKey = `${actor.tenantKey}:${command.idempotencyKey}`;\n const pending = createLocks.get(lockKey);\n const run = (pending ?? Promise.resolve()).then(() => startLocked(actor, command), () => startLocked(actor, command));\n createLocks.set(lockKey, run.then(() => undefined, () => undefined));\n return run;\n }\n\n async function loadAttempt(actor: ActorContext, attemptId: string): Promise<AttemptRecord> {\n const attempt = await store.getAttempt(actor.tenantKey, attemptId);\n if (!attempt) throw new EngineError('ATTEMPT_NOT_FOUND', 'The verification attempt was not found.');\n return attempt;\n }\n\n async function resume(actor: ActorContext, command: ResumeVerificationCommand): Promise<SafeAttemptView> {\n await ready();\n assertNoClientRouting(command);\n await authorize(actor, 'resume', { type: 'attempt', id: command.attemptId });\n const attempt = await loadAttempt(actor, command.attemptId);\n if (isTerminalStatus(attempt.canonicalStatus)) {\n throw new EngineError('ATTEMPT_TERMINAL', 'A terminal verification attempt cannot be resumed.');\n }\n if (!attempt.providerResourceId) {\n throw new EngineError('ATTEMPT_PINNED', 'The pinned verification attempt is not yet bound to a provider resource.');\n }\n const adapter = adapterFor(attempt.provider, attempt.environment);\n const launch = await adapter.resumeAttempt({\n attemptId: attempt.id,\n providerResourceId: attempt.providerResourceId,\n configurationRevision: attempt.configurationRevision,\n requestOrigin: command.requestOrigin,\n });\n await audit(actor, 'resume', 'attempt', attempt.id, 'resumed_pinned', { provider: attempt.provider });\n return toView(attempt, stripPersistedLaunch(launch));\n }\n\n async function status(actor: ActorContext, attemptId: string): Promise<SafeAttemptView> {\n await ready();\n await authorize(actor, 'status', { type: 'attempt', id: attemptId });\n return toView(await loadAttempt(actor, attemptId), null);\n }\n\n async function retry(actor: ActorContext, command: RetryVerificationCommand): Promise<SafeAttemptView> {\n await ready();\n assertNoClientRouting(command);\n await authorize(actor, 'retry', { type: 'attempt', id: command.parentAttemptId });\n const parent = await loadAttempt(actor, command.parentAttemptId);\n const subjectHash = await store.hashSubject(actor.tenantKey, command.subjectReference);\n const selected = await selectRoute({\n store,\n adapters: registry.list(),\n tenantKey: actor.tenantKey,\n packageCode: command.packageCode,\n countryCode: command.countryCode,\n subjectHash,\n environment: parent.environment,\n runtime,\n requiredCapability: 'canRetry',\n });\n const child = await startLocked(actor, command);\n const latest = await store.getAttempt(actor.tenantKey, child.attemptId);\n if (latest) {\n await store.updateAttempt({\n ...latest,\n parentAttemptId: parent.id,\n selectionReason: selected.reason,\n updatedAt: now().toISOString(),\n });\n }\n return child;\n }\n\n async function pause(actor: ActorContext, attemptId: string): Promise<SafeAttemptView> {\n await ready();\n await authorize(actor, 'pause', { type: 'attempt', id: attemptId });\n const attempt = await loadAttempt(actor, attemptId);\n if (isTerminalStatus(attempt.canonicalStatus)) {\n throw new EngineError('ATTEMPT_TERMINAL', 'A terminal verification attempt cannot be paused.');\n }\n const next = { ...attempt, canonicalStatus: applyMonotonicStatus(attempt.canonicalStatus, 'paused'), updatedAt: now().toISOString() };\n await store.updateAttempt(next);\n await audit(actor, 'pause', 'attempt', attemptId, 'paused');\n return toView(next);\n }\n\n async function cancel(actor: ActorContext, attemptId: string): Promise<SafeAttemptView> {\n await ready();\n await authorize(actor, 'cancel', { type: 'attempt', id: attemptId });\n const attempt = await loadAttempt(actor, attemptId);\n if (isTerminalStatus(attempt.canonicalStatus) && attempt.canonicalStatus !== 'canceled') {\n throw new EngineError('ATTEMPT_TERMINAL', 'A terminal verification attempt cannot be canceled.');\n }\n if (attempt.providerResourceId) {\n const adapter = adapterFor(attempt.provider, attempt.environment);\n if (adapter.manifest.capabilities.canCancel) {\n await adapter.cancelAttempt({\n attemptId: attempt.id,\n providerResourceId: attempt.providerResourceId,\n configurationRevision: attempt.configurationRevision,\n });\n }\n }\n const next = {\n ...attempt,\n canonicalStatus: applyMonotonicStatus(attempt.canonicalStatus, 'canceled') as VerificationCanonicalStatus,\n updatedAt: now().toISOString(),\n };\n await store.updateAttempt(next);\n await audit(actor, 'cancel', 'attempt', attemptId, 'canceled');\n return toView(next);\n }\n\n async function redact(actor: ActorContext, command: RedactCommand): Promise<{ jobId: string; status: string }> {\n await ready();\n await authorize(actor, 'redact', { type: 'subject' });\n const subjectHash = await store.hashSubject(actor.tenantKey, command.subjectReference);\n const job: JobRecord = {\n tenantKey: actor.tenantKey,\n id: newId('red', cryptoImpl),\n kind: 'redact',\n attemptId: command.attemptId ?? null,\n eventId: null,\n subjectHash,\n providerResourceId: null,\n state: 'scheduled',\n leaseId: null,\n leaseExpiresAt: null,\n attemptCount: 0,\n nextAttemptAt: now().toISOString(),\n lastErrorCode: null,\n createdAt: now().toISOString(),\n };\n await queue.enqueue(job);\n const targets = command.attemptId\n ? [await loadAttempt(actor, command.attemptId)]\n : (await store.listAttempts(actor.tenantKey)).filter((row) => row.subjectHash === subjectHash);\n if (!targets.length) {\n await store.updateRedactionStatus(actor.tenantKey, job.id, 'not_applicable');\n return { jobId: job.id, status: 'not_applicable' };\n }\n let status = 'scheduled';\n for (const attempt of targets) {\n const adapter = adapterFor(attempt.provider, attempt.environment);\n const result = await adapter.redactSubject({\n subjectReference: command.subjectReference,\n providerResourceId: attempt.providerResourceId,\n requestReference: command.requestReference ?? job.id,\n });\n status = result.disposition ?? (result.completed ? 'redacted' : result.retryable ? 'retryable' : 'dead_letter');\n await store.updateRedactionStatus(actor.tenantKey, job.id, toRedactionStatus(status));\n if (result.completed) {\n await store.updateAttempt({\n ...attempt,\n canonicalStatus: 'redacted',\n updatedAt: now().toISOString(),\n });\n }\n await audit(actor, 'redact', 'attempt', attempt.id, status);\n }\n return { jobId: job.id, status };\n }\n\n async function ingestWebhook(command: IngestWebhookCommand): Promise<IngestWebhookResult> {\n await ready();\n const systemActor: ActorContext = {\n tenantKey: command.tenantKey,\n actorId: 'system:webhook',\n actorType: 'system',\n roles: ['webhook'],\n authorizedSubjectScope: ['*'],\n };\n await authorize(systemActor, 'ingest_webhook', { type: 'provider', id: command.provider });\n const adapter = registry.get(command.provider);\n let verified;\n try {\n verified = await adapter.verifyWebhook(command.request);\n } catch (error) {\n if (error instanceof ProviderError && error.code === 'SIGNATURE_INVALID') {\n throw new EngineError('WEBHOOK_UNAUTHENTICATED', 'The webhook signature is invalid.');\n }\n throw error;\n }\n const normalized = await adapter.normalizeWebhook(verified);\n const claim = await store.claimWebhookEvent({\n tenantKey: command.tenantKey,\n provider: command.provider,\n providerEventKey: normalized.providerEventKey,\n providerResourceId: normalized.providerResourceId,\n eventType: normalized.eventType,\n occurredAt: normalized.occurredAt,\n bodySha256: verified.bodySha256,\n safeMetadata: {\n ...normalized.safeMetadata,\n ...(normalized.canonicalStatus ? { canonicalStatus: normalized.canonicalStatus } : {}),\n },\n });\n if (claim.disposition === 'mismatch') {\n throw new WebhookSecurityIncidentError();\n }\n if (claim.disposition === 'claimed') {\n await queue.enqueue({\n tenantKey: command.tenantKey,\n id: newId('job', cryptoImpl),\n kind: 'webhook',\n attemptId: null,\n eventId: claim.event.id,\n subjectHash: null,\n providerResourceId: normalized.providerResourceId,\n state: 'scheduled',\n leaseId: null,\n leaseExpiresAt: null,\n attemptCount: 0,\n nextAttemptAt: now().toISOString(),\n lastErrorCode: null,\n createdAt: now().toISOString(),\n });\n }\n await audit(systemActor, 'ingest_webhook', 'webhook_event', claim.event.id, claim.disposition, {\n provider: command.provider,\n });\n return { accepted: true, duplicate: claim.disposition === 'duplicate', eventId: claim.event.id };\n }\n\n async function processWebhookJob(tenantKey: string, job: JobRecord): Promise<void> {\n await ready();\n if (!job.eventId) return;\n const event = await store.getWebhookEventById(tenantKey, job.eventId);\n const resourceId = event?.providerResourceId ?? job.providerResourceId;\n let matched = resourceId\n ? await store.findAttemptByProviderResource(tenantKey, event?.provider ?? 'test_fake', resourceId)\n : null;\n if (!matched && resourceId) {\n for (const adapter of registry.list()) {\n matched = await store.findAttemptByProviderResource(tenantKey, adapter.provider, resourceId);\n if (matched) break;\n }\n }\n if (!matched || !event) {\n if (job.leaseId) {\n await queue.retry(tenantKey, job.id, job.leaseId, {\n errorCode: 'ATTEMPT_NOT_BOUND',\n retryAfterSeconds: backoffSeconds(job.attemptCount, undefined, runtime.random),\n });\n }\n return;\n }\n const canonicalFromEvent = event.safeMetadata.canonicalStatus;\n const canonical = (\n typeof canonicalFromEvent === 'string' ? canonicalFromEvent : matched.canonicalStatus\n ) as VerificationCanonicalStatus;\n const updated = {\n ...matched,\n canonicalStatus: applyMonotonicStatus(matched.canonicalStatus, canonical),\n providerStatus: typeof event.safeMetadata.providerStatus === 'string'\n ? event.safeMetadata.providerStatus\n : matched.providerStatus,\n statusVersion: matched.statusVersion + 1,\n updatedAt: now().toISOString(),\n };\n await store.updateAttempt(updated);\n await persistDecision(updated);\n await store.settleWebhookEvent(tenantKey, event.id, 'completed');\n if (job.leaseId) await queue.complete(tenantKey, job.id, job.leaseId);\n }\n\n async function reconcile(actor: ActorContext, attemptId?: string): Promise<{ reconciled: number }> {\n await ready();\n await authorize(actor, 'reconcile', { type: 'attempt', id: attemptId });\n const targets = attemptId\n ? [await loadAttempt(actor, attemptId)]\n : (await store.listAttempts(actor.tenantKey)).filter((row) => !isTerminalStatus(row.canonicalStatus) && row.providerResourceId);\n let reconciled = 0;\n for (const attempt of targets) {\n if (!attempt.providerResourceId) continue;\n const adapter = adapterFor(attempt.provider, attempt.environment);\n const snapshot = await adapter.retrieveAttempt({\n attemptId: attempt.id,\n providerResourceId: attempt.providerResourceId,\n configurationRevision: attempt.configurationRevision,\n });\n const next = {\n ...attempt,\n canonicalStatus: applyMonotonicStatus(attempt.canonicalStatus, snapshot.canonicalStatus),\n providerStatus: snapshot.providerStatus,\n normalizedReasonCodes: snapshot.normalizedReasonCodes,\n statusVersion: attempt.statusVersion + 1,\n updatedAt: now().toISOString(),\n };\n await store.updateAttempt(next);\n await persistDecision(next);\n reconciled += 1;\n }\n await audit(actor, 'reconcile', 'attempt', attemptId ?? null, 'reconciled', { count: reconciled });\n return { reconciled };\n }\n\n async function scheduleReconciliation(actor: ActorContext): Promise<{ enqueued: number }> {\n await ready();\n await authorize(actor, 'reconcile', { type: 'tenant' });\n const live = (await store.listAttempts(actor.tenantKey)).filter((row) => (\n ['processing', 'manual_review_required'].includes(row.canonicalStatus) && row.providerResourceId\n ));\n let enqueued = 0;\n for (const attempt of live) {\n await queue.enqueue({\n tenantKey: actor.tenantKey,\n id: newId('job', cryptoImpl),\n kind: 'reconcile',\n attemptId: attempt.id,\n eventId: null,\n subjectHash: attempt.subjectHash,\n providerResourceId: attempt.providerResourceId,\n state: 'scheduled',\n leaseId: null,\n leaseExpiresAt: null,\n attemptCount: 0,\n nextAttemptAt: now().toISOString(),\n lastErrorCode: null,\n createdAt: now().toISOString(),\n });\n enqueued += 1;\n }\n await audit(actor, 'reconcile.schedule', 'tenant', actor.tenantKey, 'scheduled', { count: enqueued });\n return { enqueued };\n }\n\n async function claimWorkerJobs(actor: ActorContext, input: { workerId?: string; kinds?: JobRecord['kind'][]; limit?: number } = {}) {\n await ready();\n await authorize(actor, 'reconcile', { type: 'tenant' });\n const limit = Math.min(input.limit ?? runtime.workerConcurrency ?? 8, 32);\n return queue.claim({\n tenantKey: actor.tenantKey,\n kinds: input.kinds ?? ['webhook', 'reconcile', 'redact'],\n workerId: input.workerId ?? actor.actorId,\n leaseSeconds: runtime.webhookLeaseSeconds ?? 30,\n limit,\n now: now(),\n });\n }\n\n async function processWorkerJob(actor: ActorContext, jobOrRef: JobRecord | { id: string }): Promise<{ processed: boolean; disposition: string }> {\n await ready();\n const job = 'kind' in jobOrRef ? jobOrRef : await store.getJob(actor.tenantKey, jobOrRef.id);\n if (!job) throw new EngineError('ATTEMPT_NOT_FOUND', 'The worker job was not found.');\n await authorize(actor, 'process_webhook', { type: 'job', id: job.id });\n try {\n if (job.kind === 'webhook') await processWebhookJob(actor.tenantKey, job);\n else if (job.kind === 'reconcile') await reconcile(actor, job.attemptId ?? undefined);\n else if (job.kind === 'redact' && job.attemptId) {\n const attempt = await store.getAttempt(actor.tenantKey, job.attemptId);\n if (attempt) {\n const adapter = adapterFor(attempt.provider, attempt.environment);\n const result = await adapter.redactSubject({\n subjectReference: attempt.subjectHash,\n providerResourceId: attempt.providerResourceId,\n requestReference: job.id,\n });\n const status = result.disposition ?? (result.completed ? 'redacted' : 'retryable');\n await store.updateRedactionStatus(actor.tenantKey, job.id, toRedactionStatus(status));\n if (result.completed) {\n await store.updateAttempt({ ...attempt, canonicalStatus: 'redacted', updatedAt: now().toISOString() });\n }\n }\n }\n if (job.leaseId && job.kind !== 'webhook') await queue.complete(actor.tenantKey, job.id, job.leaseId);\n return { processed: true, disposition: 'completed' };\n } catch (error) {\n const safe = toSafeProviderFailure(error);\n if (job.leaseId) {\n const dead = job.attemptCount >= (runtime.maxWorkerAttempts ?? 8);\n await queue.retry(actor.tenantKey, job.id, job.leaseId, {\n errorCode: safe.safeCode,\n retryAfterSeconds: backoffSeconds(job.attemptCount, safe.retryAfterSeconds, runtime.random),\n deadLetter: dead,\n });\n return { processed: true, disposition: dead ? 'dead_letter' : 'retryable' };\n }\n throw error;\n }\n }\n\n async function submitAppeal(actor: ActorContext, command: AppealSubmitCommand) {\n await ready();\n await authorize(actor, 'appeal', { type: 'attempt', id: command.attemptId });\n const attempt = await loadAttempt(actor, command.attemptId);\n const appeal = {\n tenantKey: actor.tenantKey,\n id: newId('apl', cryptoImpl),\n attemptId: attempt.id,\n subjectHash: attempt.subjectHash,\n status: 'open' as const,\n reason: command.reason,\n policyVersion: attempt.policyVersion,\n proposedByActorId: actor.actorId,\n decidedByActorId: null,\n expiresAt: command.expiresAt ?? null,\n createdAt: now().toISOString(),\n updatedAt: now().toISOString(),\n };\n await store.saveAppeal(appeal);\n if (isApplicationReasonCode(command.reason) && !attempt.normalizedReasonCodes.includes(command.reason)) {\n await store.updateAttempt({\n ...attempt,\n normalizedReasonCodes: [...attempt.normalizedReasonCodes, command.reason],\n updatedAt: now().toISOString(),\n });\n }\n await audit(actor, 'appeal.submit', 'appeal', appeal.id, 'open');\n return { appealId: appeal.id };\n }\n\n function applyGovernanceStatus(current: string, transition: AppealTransitionCommand['transition']): string {\n const map = {\n approve: 'approved',\n deny: 'denied',\n request_more_information: 'more_information_requested',\n revoke: 'revoked',\n expire: 'expired',\n } as const;\n return map[transition] ?? current;\n }\n\n async function transitionAppeal(actor: ActorContext, command: AppealTransitionCommand) {\n await ready();\n await authorize(actor, 'appeal', { type: 'appeal', id: command.appealId });\n const appeal = await store.getAppeal(actor.tenantKey, command.appealId);\n if (!appeal) throw new EngineError('ATTEMPT_NOT_FOUND', 'The appeal was not found.');\n if (command.transition === 'approve' || command.transition === 'deny' || command.transition === 'revoke') {\n if (appeal.proposedByActorId === actor.actorId) {\n throw new EngineError('GOVERNANCE_TWO_ACTOR', 'The proposing actor cannot approve or deny their own appeal.');\n }\n }\n const status = applyGovernanceStatus(appeal.status, command.transition);\n await store.saveAppeal({\n ...appeal,\n status: status as typeof appeal.status,\n reason: command.reason,\n decidedByActorId: actor.actorId,\n updatedAt: now().toISOString(),\n });\n await audit(actor, 'appeal.transition', 'appeal', appeal.id, status);\n return { status };\n }\n\n async function proposeReview(actor: ActorContext, command: ReviewProposeCommand) {\n await ready();\n await authorize(actor, 'review', { type: 'attempt', id: command.attemptId });\n const attempt = await loadAttempt(actor, command.attemptId);\n const reviewCase = {\n tenantKey: actor.tenantKey,\n id: newId('rev', cryptoImpl),\n attemptId: attempt.id,\n subjectHash: attempt.subjectHash,\n status: 'in_review' as const,\n reason: command.reason,\n policyVersion: attempt.policyVersion,\n assignedActorId: actor.actorId,\n createdAt: now().toISOString(),\n updatedAt: now().toISOString(),\n };\n await store.saveReviewCase(reviewCase);\n if (isApplicationReasonCode(command.reason) && !attempt.normalizedReasonCodes.includes(command.reason)) {\n await store.updateAttempt({\n ...attempt,\n normalizedReasonCodes: [...attempt.normalizedReasonCodes, command.reason],\n updatedAt: now().toISOString(),\n });\n }\n const proposal = {\n tenantKey: actor.tenantKey,\n id: newId('prp', cryptoImpl),\n reviewCaseId: reviewCase.id,\n attemptId: attempt.id,\n proposedStatus: command.proposedStatus,\n reason: command.reason,\n policyVersion: attempt.policyVersion,\n expiresAt: command.expiresAt ?? null,\n proposedByActorId: actor.actorId,\n approvedByActorId: null,\n status: 'proposed' as const,\n createdAt: now().toISOString(),\n };\n await store.saveManualDecisionProposal(proposal);\n await audit(actor, 'review.propose', 'manual_decision_proposal', proposal.id, 'proposed');\n return { proposalId: proposal.id, reviewCaseId: reviewCase.id };\n }\n\n async function decideReview(actor: ActorContext, command: ReviewDecideCommand) {\n await ready();\n await authorize(actor, 'review', { type: 'proposal', id: command.proposalId });\n const proposal = await store.getManualDecisionProposal(actor.tenantKey, command.proposalId);\n if (!proposal) throw new EngineError('ATTEMPT_NOT_FOUND', 'The manual decision proposal was not found.');\n if (proposal.proposedByActorId === actor.actorId) {\n throw new EngineError('GOVERNANCE_TWO_ACTOR', 'The proposer cannot approve their own manual decision.');\n }\n if (command.transition === 'deny') {\n await store.saveManualDecisionProposal({ ...proposal, status: 'rejected', approvedByActorId: actor.actorId });\n await audit(actor, 'review.decide', 'manual_decision_proposal', proposal.id, 'rejected');\n return { status: 'rejected' };\n }\n const attempt = await loadAttempt(actor, proposal.attemptId);\n await store.saveManualDecisionProposal({ ...proposal, status: 'approved', approvedByActorId: actor.actorId });\n if (proposal.proposedStatus === 'verified') {\n await store.insertDecision({\n tenantKey: actor.tenantKey,\n id: newId('dec', cryptoImpl),\n subjectHash: attempt.subjectHash,\n packageCode: attempt.packageCode,\n attemptId: attempt.id,\n status: 'verified',\n source: 'manual',\n policyVersion: proposal.policyVersion,\n reasonCodes: [command.reason],\n effectiveAt: now().toISOString(),\n expiresAt: proposal.expiresAt,\n revokedAt: null,\n proposerActorId: proposal.proposedByActorId,\n approverActorId: actor.actorId,\n createdAt: now().toISOString(),\n });\n }\n if (proposal.proposedStatus === 'declined' || proposal.proposedStatus === 'revoked') {\n const nextStatus = proposal.proposedStatus === 'declined' ? 'declined' : attempt.canonicalStatus;\n await store.updateAttempt({\n ...attempt,\n canonicalStatus: applyMonotonicStatus(attempt.canonicalStatus, nextStatus),\n updatedAt: now().toISOString(),\n });\n }\n await audit(actor, 'review.decide', 'manual_decision_proposal', proposal.id, 'approved');\n return { status: 'approved' };\n }\n\n async function transitionCase(actor: ActorContext, command: ReviewCaseTransitionCommand) {\n await ready();\n await authorize(actor, 'review', { type: 'review_case', id: command.reviewCaseId });\n const reviewCase = await store.getReviewCase(actor.tenantKey, command.reviewCaseId);\n if (!reviewCase) throw new EngineError('ATTEMPT_NOT_FOUND', 'The review case was not found.');\n const status = applyGovernanceStatus(reviewCase.status, command.transition);\n await store.saveReviewCase({\n ...reviewCase,\n status: status as typeof reviewCase.status,\n reason: command.reason,\n updatedAt: now().toISOString(),\n });\n await audit(actor, 'review.case', 'review_case', reviewCase.id, status);\n return { status };\n }\n\n async function evaluateProtectedAction(actor: ActorContext, command: ProtectedActionCommand): Promise<ProtectedActionResult> {\n await ready();\n await authorize(actor, 'evaluate_protected_action', { type: 'action', id: command.action });\n const subjectHash = await store.hashSubject(actor.tenantKey, command.subjectReference);\n const resourceHash = await store.hashResource(actor.tenantKey, command.resourceType, command.resourceReference);\n const environment = runtime.productionEnabled ? 'production' : 'sandbox';\n const policy = await policyStore.getActivePolicy(actor.tenantKey, environment === 'production' ? 'production' : 'sandbox')\n ?? await policyStore.getActivePolicy(actor.tenantKey, 'sandbox');\n if (!policy) {\n throw new EngineError('NO_ELIGIBLE_ROUTE', 'No active verification policy is available for protected actions.');\n }\n let requirements = await policyStore.listProtectedActionRequirements(actor.tenantKey, command.action, policy.id);\n if (!requirements.length) {\n requirements = [{\n tenantKey: actor.tenantKey,\n id: 'implicit_human_idv',\n action: command.action,\n packageCode: 'human_idv',\n policyVersionId: policy.id,\n createdAt: now().toISOString(),\n }];\n }\n const missing: string[] = [];\n for (const requirement of requirements) {\n const decision = await store.getValidDecision(actor.tenantKey, subjectHash, requirement.packageCode, now());\n if (!decision) missing.push(requirement.packageCode);\n }\n if (!missing.length) return { allowed: true } satisfies ProtectedActionAllow;\n\n const destinations = await policyStore.getContinuationDestinations(actor.tenantKey);\n const destinationKey = command.destinationKey ?? 'verification.resume';\n if (!destinations.includes(destinationKey)) {\n throw new EngineError('DESTINATION_NOT_ALLOWLISTED', 'The continuation destination is not allowlisted.');\n }\n const token = randomToken(cryptoImpl);\n const key = newId('cont', cryptoImpl);\n const expiresAt = new Date(now().getTime() + (runtime.continuationTtlSeconds ?? 900) * 1000).toISOString();\n await store.saveContinuation({\n tenantKey: actor.tenantKey,\n key,\n tokenHash: await sha256Hex(token),\n action: command.action,\n resourceHash,\n subjectHash,\n destinationKey,\n expiresAt,\n consumedAt: null,\n });\n const denial: ProtectedActionDenial = {\n code: 'VERIFICATION_REQUIRED',\n action: command.action,\n resourceHash,\n requiredPackages: missing,\n continuation: { key, token, expiresAt },\n retryAfter: null,\n supportPath: null,\n };\n return denial;\n }\n\n const admin = {\n async health(actor: ActorContext) {\n await ready();\n await authorize(actor, 'admin.health', { type: 'tenant' });\n return {\n observations: await store.listHealth(actor.tenantKey),\n circuits: await store.listCircuits(actor.tenantKey),\n };\n },\n async routes(actor: ActorContext) {\n await ready();\n await authorize(actor, 'admin.routes', { type: 'tenant' });\n return store.listRoutes(actor.tenantKey);\n },\n async circuits(actor: ActorContext) {\n await ready();\n await authorize(actor, 'admin.circuits', { type: 'tenant' });\n return store.listCircuits(actor.tenantKey);\n },\n async attempts(actor: ActorContext) {\n await ready();\n await authorize(actor, 'admin.attempts', { type: 'tenant' });\n return store.listAttempts(actor.tenantKey);\n },\n async audit(actor: ActorContext) {\n await ready();\n await authorize(actor, 'admin.audit', { type: 'tenant' });\n return store.listAudit(actor.tenantKey);\n },\n async proposeRoute(actor: ActorContext, input: { route: Omit<RouteRecord, 'lifecycle' | 'approvedByActorId' | 'approvedAt' | 'activatedAt'>; reason: string }) {\n await ready();\n await authorize(actor, 'admin.propose_route', { type: 'route' });\n const request = {\n tenantKey: actor.tenantKey,\n id: newId('rcr', cryptoImpl),\n routeId: input.route.id,\n proposedPayload: {\n provider: input.route.provider,\n packageCode: String(input.route.packageCode),\n environment: input.route.environment,\n priority: input.route.priority,\n },\n status: 'proposed' as const,\n reason: input.reason,\n policyVersion: input.route.policyVersionId,\n proposedByActorId: actor.actorId,\n approvedByActorId: null,\n approvedAt: null,\n expiresAt: null,\n createdAt: now().toISOString(),\n };\n await store.saveRouteChangeRequest(request);\n await store.saveRoute({\n ...input.route,\n tenantKey: actor.tenantKey,\n lifecycle: 'draft',\n proposedByActorId: actor.actorId,\n approvedByActorId: null,\n approvedAt: null,\n activatedAt: null,\n createdAt: now().toISOString(),\n updatedAt: now().toISOString(),\n });\n await audit(actor, 'admin.propose_route', 'route', input.route.id, 'proposed');\n return { requestId: request.id };\n },\n async approveRoute(actor: ActorContext, requestId: string, reason: string) {\n await ready();\n await authorize(actor, 'admin.approve_route', { type: 'route_change_request', id: requestId });\n const request = await store.getRouteChangeRequest(actor.tenantKey, requestId);\n if (!request) throw new EngineError('ATTEMPT_NOT_FOUND', 'The route change request was not found.');\n if (request.proposedByActorId === actor.actorId) {\n throw new EngineError('GOVERNANCE_TWO_ACTOR', 'The proposer cannot approve their own route change.');\n }\n const route = request.routeId ? await store.getRoute(actor.tenantKey, request.routeId) : null;\n if (!route) throw new EngineError('NO_ELIGIBLE_ROUTE', 'The proposed route was not found.');\n if (route.environment === 'production' && !runtime.productionEnabled) {\n throw new EngineError('PRODUCTION_NOT_ACTIVATED', 'Production routes cannot be activated without the runtime key.');\n }\n await store.saveRouteChangeRequest({\n ...request,\n status: 'approved',\n reason,\n approvedByActorId: actor.actorId,\n approvedAt: now().toISOString(),\n });\n await store.saveRoute({\n ...route,\n lifecycle: 'active',\n approvedByActorId: actor.actorId,\n approvedAt: now().toISOString(),\n activatedAt: now().toISOString(),\n updatedAt: now().toISOString(),\n });\n await audit(actor, 'admin.approve_route', 'route', route.id, 'approved');\n return { routeId: route.id };\n },\n async proposePolicy(actor: ActorContext, input: {\n version: string;\n environment: 'sandbox' | 'production';\n reason: string;\n expiresAt?: string | null;\n decisionRetentionDays?: number | null;\n providerRedactionDelayDays?: number | null;\n appealHoldDays?: number | null;\n legalHold?: boolean;\n }) {\n await ready();\n await authorize(actor, 'admin.propose_policy', { type: 'policy' });\n const policy = {\n tenantKey: actor.tenantKey,\n id: newId('pol', cryptoImpl),\n version: input.version,\n environment: input.environment,\n lifecycle: 'draft' as const,\n reason: input.reason,\n expiresAt: input.expiresAt ?? null,\n proposedByActorId: actor.actorId,\n approvedByActorId: null,\n approvedAt: null,\n activatedAt: null,\n createdAt: now().toISOString(),\n decisionRetentionDays: input.decisionRetentionDays ?? null,\n providerRedactionDelayDays: input.providerRedactionDelayDays ?? null,\n appealHoldDays: input.appealHoldDays ?? null,\n legalHold: input.legalHold ?? false,\n };\n await store.savePolicyVersion(policy);\n await audit(actor, 'admin.propose_policy', 'policy', policy.id, 'draft');\n return { policyId: policy.id };\n },\n async approvePolicy(actor: ActorContext, policyId: string, reason: string) {\n await ready();\n await authorize(actor, 'admin.approve_policy', { type: 'policy', id: policyId });\n const policy = await store.getPolicyVersion(actor.tenantKey, policyId);\n if (!policy) throw new EngineError('ATTEMPT_NOT_FOUND', 'The policy was not found.');\n if (policy.proposedByActorId === actor.actorId) {\n throw new EngineError('GOVERNANCE_TWO_ACTOR', 'The proposer cannot approve their own policy.');\n }\n await store.savePolicyVersion({\n ...policy,\n lifecycle: 'approved',\n reason,\n approvedByActorId: actor.actorId,\n approvedAt: now().toISOString(),\n });\n await audit(actor, 'admin.approve_policy', 'policy', policy.id, 'approved');\n return { policyId: policy.id };\n },\n async activatePolicy(actor: ActorContext, policyId: string) {\n await ready();\n await authorize(actor, 'admin.activate_policy', { type: 'policy', id: policyId });\n const policy = await store.getPolicyVersion(actor.tenantKey, policyId);\n if (!policy) throw new EngineError('ATTEMPT_NOT_FOUND', 'The policy was not found.');\n if (!twoActorApproved(policy.proposedByActorId, policy.approvedByActorId)) {\n throw new EngineError('GOVERNANCE_TWO_ACTOR', 'An active policy requires distinct proposer and approver.');\n }\n if (policy.environment === 'production' && !runtime.productionEnabled) {\n throw new EngineError('PRODUCTION_NOT_ACTIVATED', 'Production policy activation requires the runtime production key.');\n }\n if (\n policy.environment === 'production'\n && (policy.decisionRetentionDays == null\n || policy.providerRedactionDelayDays == null\n || policy.appealHoldDays == null)\n ) {\n throw new EngineError(\n 'PRODUCTION_NOT_ACTIVATED',\n 'Production policy activation requires explicit retention, redaction, appeal-hold, and legal-hold values.',\n );\n }\n await store.savePolicyVersion({\n ...policy,\n lifecycle: 'active',\n activatedAt: now().toISOString(),\n });\n await audit(actor, 'admin.activate_policy', 'policy', policy.id, 'active');\n return { policyId: policy.id };\n },\n async emergencyDrain(actor: ActorContext, provider: string, environment: 'sandbox' | 'production', reason: string) {\n await ready();\n await authorize(actor, 'admin.emergency_drain', { type: 'provider', id: provider });\n const circuit = await store.getCircuit(actor.tenantKey, provider, environment);\n await store.saveCircuit({\n ...circuit,\n state: 'open',\n reasonCode: reason,\n openUntil: new Date(now().getTime() + 24 * 3600_000).toISOString(),\n drainedByActorId: actor.actorId,\n updatedAt: now().toISOString(),\n });\n await audit(actor, 'admin.emergency_drain', 'circuit', provider, reason);\n return { state: 'open' };\n },\n };\n\n void CLIENT_OPS;\n\n return {\n start,\n resume,\n status,\n retry,\n pause,\n cancel,\n redact,\n ingestWebhook,\n processWebhookJob,\n reconcile,\n appeal: { submit: submitAppeal, transition: transitionAppeal },\n review: { propose: proposeReview, decide: decideReview, transitionCase },\n admin,\n evaluateProtectedAction,\n workers: {\n claim: claimWorkerJobs,\n process: processWorkerJob,\n scheduleReconciliation,\n },\n };\n}\n\nfunction stripPersistedLaunch(launch: ProviderLaunchEnvelope): ProviderLaunchEnvelope {\n return launch;\n}\n\nconst REDACTION_STATUSES: readonly RedactionStatus[] = [\n 'scheduled',\n 'processing',\n 'retryable',\n 'redacted',\n 'not_applicable',\n 'dead_letter',\n];\n\nfunction toRedactionStatus(value: string | undefined): RedactionStatus {\n if (value === 'failed') return 'dead_letter';\n if (value && (REDACTION_STATUSES as readonly string[]).includes(value)) return value as RedactionStatus;\n return 'retryable';\n}\n","export interface RateBudget {\n consume(provider: string, at?: Date): { allowed: boolean; retryAfterSeconds?: number };\n}\n\nexport function createRateBudget(limitPerSecond: number): RateBudget {\n const stamps = new Map<string, number[]>();\n const limit = Math.max(1, Math.floor(limitPerSecond));\n return {\n consume(provider, at = new Date()) {\n const now = at.getTime();\n const recent = (stamps.get(provider) ?? []).filter((stamp) => now - stamp < 1_000);\n if (recent.length >= limit) {\n const oldest = recent[0] ?? now;\n return { allowed: false, retryAfterSeconds: Math.max(1, Math.ceil((oldest + 1_000 - now) / 1_000)) };\n }\n recent.push(now);\n stamps.set(provider, recent);\n return { allowed: true };\n },\n };\n}\n","import type { VerificationAdapterV1 } from '@splitin/verification-adapter-sdk';\n\nimport { EngineError } from './errors.ts';\nimport { cohortBucket } from './hash.ts';\nimport { twoActorApproved } from './guards.ts';\nimport type { VerificationStore } from './store.ts';\nimport type {\n CircuitRecord,\n EngineRuntime,\n RouteRecord,\n VerificationPackageCode,\n VerificationProviderEnvironment,\n} from './types.ts';\n\nexport interface RouteSelection {\n route: RouteRecord;\n adapter: VerificationAdapterV1;\n reason: string;\n usedFailover: boolean;\n}\n\nexport async function selectRoute(input: {\n store: VerificationStore;\n adapters: VerificationAdapterV1[];\n tenantKey: string;\n packageCode: VerificationPackageCode;\n countryCode: string;\n subjectHash: string;\n environment: VerificationProviderEnvironment;\n runtime: EngineRuntime;\n requiredCapability?: 'canResume' | 'canRetry' | 'canCancel' | 'canRedact' | null;\n}): Promise<RouteSelection> {\n const now = (input.runtime.now ?? (() => new Date()))();\n const policy = await input.store.getActivePolicy(input.tenantKey, input.environment);\n if (input.environment === 'production') {\n if (!input.runtime.productionEnabled) {\n throw new EngineError('PRODUCTION_NOT_ACTIVATED', 'Production verification requires the runtime production key.');\n }\n if (!policy || policy.lifecycle !== 'active' || !twoActorApproved(policy.proposedByActorId, policy.approvedByActorId)) {\n throw new EngineError(\n 'PRODUCTION_NOT_ACTIVATED',\n 'Production verification requires an active database policy approved by a different actor.',\n );\n }\n if (policy.expiresAt && policy.expiresAt <= now.toISOString()) {\n throw new EngineError('PRODUCTION_NOT_ACTIVATED', 'The production verification policy has expired.');\n }\n if (\n policy.decisionRetentionDays == null\n || policy.providerRedactionDelayDays == null\n || policy.appealHoldDays == null\n ) {\n throw new EngineError(\n 'PRODUCTION_NOT_ACTIVATED',\n 'Production verification requires explicit decision retention, provider redaction timing, appeal holds, and legal-hold values.',\n );\n }\n } else if (!policy || policy.lifecycle !== 'active') {\n throw new EngineError('NO_ELIGIBLE_ROUTE', 'No active sandbox verification policy is available.');\n }\n\n const cohort = await cohortBucket(input.tenantKey, input.subjectHash);\n const routes = (await input.store.listActiveRoutes(input.tenantKey, input.environment))\n .filter((route) => route.packageCode === input.packageCode)\n .filter((route) => route.countryCode === null || route.countryCode === input.countryCode)\n .filter((route) => cohort >= route.cohortMin && cohort <= route.cohortMax)\n .filter((route) => !route.windowStart || route.windowStart <= now.toISOString())\n .filter((route) => !route.windowEnd || route.windowEnd >= now.toISOString())\n .filter((route) => !route.allowlistRequired || route.allowlistedSubjectHashes.includes(input.subjectHash))\n .sort((left, right) => left.priority - right.priority || left.id.localeCompare(right.id));\n\n let usedFailover = false;\n const eligible: RouteRecord[] = [];\n for (const route of routes) {\n const circuit = await input.store.getCircuit(input.tenantKey, route.provider, route.environment);\n if (circuitIsBlocking(circuit, now)) {\n usedFailover = true;\n continue;\n }\n const adapter = input.adapters.find((candidate) => (\n candidate.provider === route.provider && candidate.environment === route.environment\n ));\n if (!adapter) continue;\n if (!adapter.manifest.supportedPackages.includes(input.packageCode)) continue;\n if (!adapter.manifest.supportedCountries.includes(input.countryCode)) continue;\n if (!adapter.manifest.environments.includes(input.environment)) continue;\n if (input.requiredCapability && !adapter.manifest.capabilities[input.requiredCapability]) continue;\n const routeCapability = route.requiredCapability;\n if (routeCapability && routeCapability in adapter.manifest.capabilities\n && !adapter.manifest.capabilities[routeCapability as keyof typeof adapter.manifest.capabilities]) {\n continue;\n }\n const observations = await input.store.listHealth(input.tenantKey, adapter.provider);\n const recent = observations\n .filter((row) => row.environment === input.environment)\n .sort((left, right) => right.observedAt.localeCompare(left.observedAt))\n .slice(0, 5);\n if (recent.length >= 3 && recent.every((row) => row.outcome !== 'success')) {\n usedFailover = true;\n continue;\n }\n eligible.push(route);\n }\n\n const selected = eligible[0];\n if (!selected) {\n throw new EngineError('NO_ELIGIBLE_ROUTE', 'No eligible verification provider route is available.', true, 30);\n }\n const adapter = input.adapters.find((candidate) => (\n candidate.provider === selected.provider && candidate.environment === selected.environment\n ));\n if (!adapter) {\n throw new EngineError('NO_ELIGIBLE_ROUTE', 'The selected route has no compiled-in adapter.');\n }\n return {\n route: selected,\n adapter,\n reason: usedFailover ? 'new_attempt_failover' : 'primary_route',\n usedFailover,\n };\n}\n\nexport function circuitIsBlocking(circuit: CircuitRecord, now: Date): boolean {\n if (circuit.state === 'closed') return false;\n if (circuit.state === 'open') {\n if (circuit.openUntil && circuit.openUntil <= now.toISOString()) return false;\n return true;\n }\n return circuit.state === 'half_open' && Boolean(circuit.drainedByActorId);\n}\n","import { digestCanonical } from './canonical.ts';\nimport { newId } from './hash.ts';\nimport type { ProviderRegistry } from './registry.ts';\nimport type { VerificationStore } from './store.ts';\nimport type { EngineRuntime, RouteRecord } from './types.ts';\n\nexport async function seedSandboxExamples(\n store: VerificationStore,\n registry: ProviderRegistry,\n runtime: EngineRuntime,\n tenantKey = 'default',\n): Promise<void> {\n const now = (runtime.now ?? (() => new Date()))().toISOString();\n await store.ensureTenant(tenantKey);\n let sandboxPolicy = await store.getActivePolicy(tenantKey, 'sandbox');\n if (!sandboxPolicy) {\n sandboxPolicy = {\n tenantKey,\n id: 'pol_sandbox_example',\n version: 'sandbox-example-1',\n environment: 'sandbox',\n lifecycle: 'active',\n reason: 'Seeded sandbox example policy',\n expiresAt: null,\n proposedByActorId: 'system:seed',\n approvedByActorId: 'system:seed-approver',\n approvedAt: now,\n activatedAt: now,\n createdAt: now,\n decisionRetentionDays: null,\n providerRedactionDelayDays: null,\n appealHoldDays: null,\n legalHold: false,\n };\n await store.savePolicyVersion(sandboxPolicy);\n }\n\n let sandboxPriority = 100;\n for (const adapter of registry.list()) {\n const manifestDigest = await digestCanonical(adapter.manifest);\n await store.upsertProviderDefinition({\n tenantKey,\n provider: adapter.provider,\n environment: adapter.environment,\n adapterVersion: adapter.manifest.adapterVersion,\n manifestDigest,\n compiledInRegistry: true,\n productionEligible: false,\n createdAt: now,\n updatedAt: now,\n });\n const configId = `cfg_sandbox_${adapter.provider}`;\n if (!await store.getConfigurationRevision(tenantKey, configId)) {\n await store.saveConfigurationRevision({\n tenantKey,\n id: configId,\n provider: adapter.provider,\n environment: adapter.environment,\n revision: 1,\n configurationDigest: await digestCanonical({ provider: adapter.provider, environment: adapter.environment }),\n lifecycle: 'approved',\n proposedByActorId: 'system:seed',\n approvedByActorId: 'system:seed-approver',\n approvedAt: now,\n createdAt: now,\n });\n }\n if (adapter.environment !== 'sandbox') continue;\n for (const packageCode of adapter.manifest.supportedPackages) {\n const routeId = `rte_sandbox_${adapter.provider}_${packageCode}`.replace(/[^a-z0-9_]/g, '_');\n if (await store.getRoute(tenantKey, routeId)) continue;\n const route: RouteRecord = {\n tenantKey,\n id: routeId,\n provider: adapter.provider,\n environment: 'sandbox',\n packageCode,\n countryCode: adapter.manifest.supportedCountries[0] ?? 'US',\n requiredCapability: null,\n priority: sandboxPriority++,\n cohortMin: 0,\n cohortMax: 99,\n windowStart: null,\n windowEnd: null,\n allowlistRequired: false,\n allowlistedSubjectHashes: [],\n configurationRevisionId: configId,\n policyVersionId: sandboxPolicy.id,\n lifecycle: 'active',\n proposedByActorId: 'system:seed',\n approvedByActorId: 'system:seed-approver',\n approvedAt: now,\n activatedAt: now,\n createdAt: now,\n updatedAt: now,\n };\n await store.saveRoute(route);\n }\n }\n\n const productionPolicy = (await store.listPolicyVersions(tenantKey)).find((row) => row.environment === 'production');\n if (!productionPolicy) {\n await store.savePolicyVersion({\n tenantKey,\n id: newId('pol'),\n version: 'production-unactivated',\n environment: 'production',\n lifecycle: 'draft',\n reason: 'Seeded production policy is never auto-activated',\n expiresAt: null,\n proposedByActorId: 'system:seed',\n approvedByActorId: null,\n approvedAt: null,\n activatedAt: null,\n createdAt: now,\n decisionRetentionDays: null,\n providerRedactionDelayDays: null,\n appealHoldDays: null,\n legalHold: false,\n });\n }\n}\n","import type {\n AppealRecord,\n AttemptRecord,\n AuditEventRecord,\n CircuitRecord,\n ConfigurationRevisionRecord,\n ContinuationRecord,\n DecisionRecord,\n HealthObservationRecord,\n IdempotencyClaimRecord,\n JobRecord,\n ManualDecisionProposalRecord,\n PolicyVersionRecord,\n ProtectedActionRequirementRecord,\n ProviderDefinitionRecord,\n ProviderResourceLineageRecord,\n QueueJobKind,\n RedactionStatus,\n ReviewCaseRecord,\n RouteChangeRequestRecord,\n RouteRecord,\n TenantRecord,\n VerificationCanonicalStatus,\n VerificationPackageCode,\n VerificationProviderCode,\n VerificationProviderEnvironment,\n WebhookClaimResult,\n WebhookEventRecord,\n} from './types.ts';\n\nexport interface PolicyStore {\n getActivePolicy(\n tenantKey: string,\n environment: VerificationProviderEnvironment,\n ): Promise<PolicyVersionRecord | null>;\n getPolicyVersion(tenantKey: string, id: string): Promise<PolicyVersionRecord | null>;\n listPolicyVersions(tenantKey: string): Promise<PolicyVersionRecord[]>;\n savePolicyVersion(policy: PolicyVersionRecord): Promise<void>;\n listProtectedActionRequirements(\n tenantKey: string,\n action: string,\n policyVersionId: string,\n ): Promise<ProtectedActionRequirementRecord[]>;\n saveProtectedActionRequirement(requirement: ProtectedActionRequirementRecord): Promise<void>;\n getContinuationDestinations(tenantKey: string): Promise<string[]>;\n}\n\nexport interface VerificationStore extends PolicyStore {\n now(): Date;\n hashSubject(tenantKey: string, subjectReference: string): Promise<string>;\n hashResource(tenantKey: string, resourceType: string, resourceReference: string): Promise<string>;\n transact<T>(fn: (store: VerificationStore) => Promise<T>): Promise<T>;\n\n getTenant(tenantKey: string): Promise<TenantRecord | null>;\n ensureTenant(tenantKey: string, displayName?: string): Promise<TenantRecord>;\n\n getConfigurationRevision(tenantKey: string, id: string): Promise<ConfigurationRevisionRecord | null>;\n listConfigurationRevisions(tenantKey: string): Promise<ConfigurationRevisionRecord[]>;\n saveConfigurationRevision(revision: ConfigurationRevisionRecord): Promise<void>;\n\n upsertProviderDefinition(definition: ProviderDefinitionRecord): Promise<void>;\n getProviderDefinition(\n tenantKey: string,\n provider: VerificationProviderCode,\n environment: VerificationProviderEnvironment,\n ): Promise<ProviderDefinitionRecord | null>;\n listProviderDefinitions(tenantKey: string): Promise<ProviderDefinitionRecord[]>;\n\n getRoute(tenantKey: string, routeId: string): Promise<RouteRecord | null>;\n listRoutes(tenantKey: string): Promise<RouteRecord[]>;\n listActiveRoutes(tenantKey: string, environment: VerificationProviderEnvironment): Promise<RouteRecord[]>;\n saveRoute(route: RouteRecord): Promise<void>;\n saveRouteChangeRequest(request: RouteChangeRequestRecord): Promise<void>;\n getRouteChangeRequest(tenantKey: string, id: string): Promise<RouteChangeRequestRecord | null>;\n listRouteChangeRequests(tenantKey: string): Promise<RouteChangeRequestRecord[]>;\n\n getAttempt(tenantKey: string, attemptId: string): Promise<AttemptRecord | null>;\n getAttemptByIdempotencyKey(tenantKey: string, key: string): Promise<AttemptRecord | null>;\n findAttemptByProviderResource(\n tenantKey: string,\n provider: VerificationProviderCode,\n providerResourceId: string,\n ): Promise<AttemptRecord | null>;\n listAttempts(tenantKey: string): Promise<AttemptRecord[]>;\n listLiveAttempts(tenantKey: string, subjectHash: string, packageCode: VerificationPackageCode): Promise<AttemptRecord[]>;\n insertAttempt(attempt: AttemptRecord): Promise<AttemptRecord>;\n updateAttempt(attempt: AttemptRecord): Promise<void>;\n\n insertLineage(row: ProviderResourceLineageRecord): Promise<void>;\n listLineage(tenantKey: string, attemptId: string): Promise<ProviderResourceLineageRecord[]>;\n\n getValidDecision(\n tenantKey: string,\n subjectHash: string,\n packageCode: VerificationPackageCode,\n at: Date,\n ): Promise<DecisionRecord | null>;\n insertDecision(decision: DecisionRecord): Promise<void>;\n listDecisions(tenantKey: string, subjectHash?: string): Promise<DecisionRecord[]>;\n revokeDecision(tenantKey: string, decisionId: string, at: string): Promise<void>;\n\n claimIdempotency(claim: IdempotencyClaimRecord): Promise<{ disposition: 'claimed' | 'existing'; claim: IdempotencyClaimRecord }>;\n completeIdempotency(tenantKey: string, key: string, resultRef: string): Promise<void>;\n failIdempotency(tenantKey: string, key: string, errorCode: string): Promise<void>;\n getIdempotencyClaim(tenantKey: string, key: string): Promise<IdempotencyClaimRecord | null>;\n\n claimWebhookEvent(input: {\n tenantKey: string;\n provider: VerificationProviderCode;\n providerEventKey: string;\n providerResourceId: string;\n eventType: string;\n occurredAt: string;\n bodySha256: string;\n safeMetadata: Record<string, string | boolean | number | null>;\n }): Promise<WebhookClaimResult>;\n getWebhookEvent(tenantKey: string, provider: VerificationProviderCode, eventKey: string): Promise<WebhookEventRecord | null>;\n getWebhookEventById(tenantKey: string, eventId: string): Promise<WebhookEventRecord | null>;\n settleWebhookEvent(\n tenantKey: string,\n eventId: string,\n outcome: 'completed' | 'retryable' | 'dead_letter',\n errorCode?: string,\n ): Promise<void>;\n\n recordHealth(observation: HealthObservationRecord): Promise<void>;\n listHealth(tenantKey: string, provider?: VerificationProviderCode): Promise<HealthObservationRecord[]>;\n\n getCircuit(\n tenantKey: string,\n provider: VerificationProviderCode,\n environment: VerificationProviderEnvironment,\n ): Promise<CircuitRecord>;\n saveCircuit(circuit: CircuitRecord): Promise<void>;\n listCircuits(tenantKey: string): Promise<CircuitRecord[]>;\n\n saveAppeal(appeal: AppealRecord): Promise<void>;\n getAppeal(tenantKey: string, id: string): Promise<AppealRecord | null>;\n listAppeals(tenantKey: string): Promise<AppealRecord[]>;\n saveReviewCase(reviewCase: ReviewCaseRecord): Promise<void>;\n getReviewCase(tenantKey: string, id: string): Promise<ReviewCaseRecord | null>;\n listReviewCases(tenantKey: string): Promise<ReviewCaseRecord[]>;\n saveManualDecisionProposal(proposal: ManualDecisionProposalRecord): Promise<void>;\n getManualDecisionProposal(tenantKey: string, id: string): Promise<ManualDecisionProposalRecord | null>;\n listManualDecisionProposals(tenantKey: string): Promise<ManualDecisionProposalRecord[]>;\n\n saveContinuation(continuation: ContinuationRecord): Promise<void>;\n getContinuation(tenantKey: string, key: string): Promise<ContinuationRecord | null>;\n\n appendAudit(event: AuditEventRecord): Promise<void>;\n listAudit(tenantKey: string): Promise<AuditEventRecord[]>;\n\n saveJob(job: JobRecord): Promise<void>;\n getJob(tenantKey: string, id: string): Promise<JobRecord | null>;\n listJobs(tenantKey: string, kind?: QueueJobKind): Promise<JobRecord[]>;\n claimJobs(input: {\n tenantKey: string;\n kinds: QueueJobKind[];\n workerId: string;\n leaseSeconds: number;\n limit: number;\n now: Date;\n }): Promise<JobRecord[]>;\n updateJob(job: JobRecord): Promise<void>;\n updateRedactionStatus(tenantKey: string, jobId: string, status: RedactionStatus): Promise<void>;\n}\n\nexport const TERMINAL_STATUS_RANK: Record<VerificationCanonicalStatus, number> = {\n created: 10,\n pending_user_input: 20,\n paused: 20,\n processing: 30,\n manual_review_required: 40,\n provider_unavailable: 25,\n verified: 100,\n declined: 100,\n failed: 100,\n expired: 100,\n canceled: 100,\n redacted: 200,\n};\n","import { isTerminalStatus, type VerificationCanonicalStatus } from '@splitin/verification-adapter-sdk';\n\nimport { TERMINAL_STATUS_RANK } from './store.ts';\n\nexport function canTransitionStatus(\n current: VerificationCanonicalStatus,\n next: VerificationCanonicalStatus,\n): boolean {\n if (current === next) return true;\n if (next === 'redacted') return true;\n if (isTerminalStatus(current)) return false;\n if (current === 'provider_unavailable' && !isTerminalStatus(next)) return true;\n return TERMINAL_STATUS_RANK[next] >= TERMINAL_STATUS_RANK[current];\n}\n\nexport function applyMonotonicStatus(\n current: VerificationCanonicalStatus,\n next: VerificationCanonicalStatus,\n): VerificationCanonicalStatus {\n return canTransitionStatus(current, next) ? next : current;\n}\n"]}