{"service":"scrimed-execution-attempt-durable-store","route":"/workflows/execution-attempts","apiRoute":"/api/workflows/execution-attempts/durable-store","briefRoute":"/api/workflows/execution-attempts/durable-store/brief","recordRoute":"/api/workflows/execution-attempts/durable-store/record","replayRoute":"/api/workflows/execution-attempts/durable-store/replay","reviewDispositionRoute":"/api/workflows/execution-attempts/durable-store/review-disposition","status":"execution-attempt-durable-store-contract-active-no-phi","briefStatus":"execution-attempt-durable-store-brief-ready-no-phi","contractVersion":"scrimed-execution-attempt-durable-store-v1","boundary":"SCRIMED Execution Attempt Durable Store v1 is a tenant-scoped, no-PHI, metadata-only persistence contract for execution-attempt envelopes, idempotency, replay lookup, review dispositions, immutable audit events, regional retention, Compute Fabric routing evidence, and fail-closed protected route access. It does not authorize PHI processing, live patient data use, production model routing, autonomous diagnosis, autonomous treatment, prescribing, payer submission, claim submission, EHR writeback, patient outreach, production connector use, or clinical production approval.","readinessAssessment":"GO for migration-ready, tenant-scoped, no-PHI durable execution-attempt metadata, idempotency, replay lookup, and human review disposition APIs. NO-GO for live clinical production, PHI, autonomous workflow execution, production connectors, patient outreach, payer submission, EHR writeback, final billing, or production model routing.","dataBoundary":"synthetic-and-metadata-only","phiAuthority":"not-authorized-production-phi","clinicalCareAuthority":"not-authorized-live-care","workflowExecutionAuthority":"durable-attempt-store-no-protected-execution","replayAuthority":"metadata-replay-only","modelRoutingAuthority":"telemetry-only-not-production-routing","protectedWritesEnabled":true,"envelopeCount":5,"recordableEnvelopeCount":5,"acceptedEnvelopeCount":5,"replayReadyCount":5,"scorecardCount":10,"passingScorecardCount":10,"architectureSectionCount":49,"healthcareAIPriorityCount":16,"validation":{"status":"pass","checks":[{"check":"durable-store-wraps-all-known-envelopes","passed":true,"detail":"5 envelopes are available for metadata-only durable persistence."},{"check":"protected-writes-require-human-review","passed":true,"detail":"Every server-known envelope carries a required human review gate."},{"check":"no-phi-boundary-retained","passed":true,"detail":"All durable-store candidate envelopes deny production PHI authority."},{"check":"idempotency-ttl-locking-replay-defined","passed":true,"detail":"Contract defines idempotency keys, lock TTLs, retention, and metadata-only replay."},{"check":"mcp-gateway-permissioning-defined","passed":true,"detail":"MCP-compatible tool access remains blocked without explicit AAL2, tenant, and tool permissions."},{"check":"clinical-robustness-lab-covered","passed":true,"detail":"Clinical robustness coverage is bound to durable attempt metadata, scorecards, reviewer queues, and the current required adversarial perturbation families."},{"check":"model-router-observability-covered","passed":true,"detail":"Every durable-store candidate carries cost, latency, confidence, fallback, and routing rationale."},{"check":"compute-fabric-evidence-binding-covered","passed":true,"detail":"Every durable-store candidate binds SCRIMED Compute Fabric selected model, tier, PHI policy, human review flag, and audit hash."},{"check":"progressive-delivery-rollout-defined","passed":true,"detail":"Migration, canary, authenticated smoke, and rollback-aware rollout stages are defined."}]},"architecture":{"systemArchitecture":["Agent Runtime builds deterministic no-PHI envelopes before any workflow worker can run.","Durable Store records envelope metadata, idempotency state, replay tokens, review dispositions, and immutable events in tenant-scoped storage.","Compute Fabric metadata is projected into first-class durable-store columns for selected model, tier, provider, deployment mode, PHI policy, human-review flag, fallback model path, and audit hash.","Governance routes require Supabase Auth verification, AAL2 session freshness, workspace membership, and a server runtime token before any write RPC is reachable.","Workflow Engine remains blocked from protected external side effects until review disposition, connector approval, PHI authorization, and production rollout gates are separately approved.","Evaluation Engine binds each attempt to clinical readiness scorecards, adversarial scenarios, missing-data checks, and evidence-quality gates."],"moduleBoundaries":["executionAttemptEnvelope owns deterministic envelope construction and no-PHI synthetic scorecards.","scrimedComputeFabric owns model-routing metadata, confidence/correctness boundaries, private/edge deployment policy, and synthetic benchmarking scaffolds.","executionAttemptDurableStore owns the storage contract, request validators, public evidence summary, and Supabase RPC helpers.","protectedPilotStore continues to own authentication context and tenant workspace lookup.","Route handlers own HTTP concerns, rate limits, fail-closed errors, and boundary headers.","Supabase migration owns tenant isolation, direct table denial, function grants, idempotency, replay lookup, review disposition, and append-only event storage."],"interfaces":["GET durable-store summary for public architecture evidence.","GET durable-store brief as Markdown for diligence packets.","POST record accepts a workspace slug plus a known synthetic attempt reference and persists the server-side envelope.","POST replay accepts a workspace slug plus idempotency key or replay token and returns metadata-only retained state.","POST review-disposition records human review outcome with fixed no-PHI, no-clinical-authority attestation."],"dataModels":["private.execution_attempts: one row per tenant workspace and idempotency key with envelope JSON, replay token, trace, region, lock TTL, retention, risk, and no-PHI flags.","private.execution_attempts Compute Fabric columns: compute_fabric_telemetry, compute_fabric_audit_hash, compute_fabric_selected_model, compute_fabric_model_tier, compute_fabric_provider, compute_fabric_deployment_mode, compute_fabric_phi_policy, compute_fabric_human_review_required, and compute_fabric_fallback_models.","private.execution_attempt_events: append-only audit events for record, replay, idempotency reuse, quarantine, and review actions.","private.execution_attempt_review_dispositions: immutable human review outcomes with reviewer role, reason code, attestation, and retained boundary.","No raw prompt text, PHI, connector payload, credential, payer member data, or production record content is accepted."],"threatModel":["PHI injection through request bodies is blocked by known-envelope reference recording and SQL content guards.","Cross-tenant replay is blocked by tenant membership, workspace slug lookup, and workspace-scoped idempotency uniqueness.","Unauthorized tool access is blocked because no durable route grants connector execution, and every write requires AAL2 governance context.","Idempotency collision returns conflict unless the retained digest, context fingerprint, attempt id, and replay token match.","Prompt injection and missing citations trigger quarantine-ready metadata and do not obtain tool permissions.","Cost runaway is controlled by model-route telemetry, budget guard placeholders, and replay metadata without re-executing models.","Unsafe model escalation is controlled by Compute Fabric PHI policy, no-live-model-call audit tags, confidence-is-not-correctness boundaries, and high-risk human review enforcement.","Stale reviewer authority is blocked by Supabase session freshness and immutable review dispositions."],"testPlan":["Public smoke validates summary status, boundary headers, architecture sections, clinical robustness coverage, MCP gateway contract, and no-PHI hard stops.","Public smoke validates Markdown brief content and durable-store evidence counts.","Public smoke verifies protected record, replay, and review-disposition endpoints fail closed without bearer tokens.","Typecheck, lint, and build gate all TypeScript route and library changes.","Authenticated AAL2 smoke must be run after the migration is applied before pilot use.","Compute Fabric migration smoke must verify trigger extraction, JSON projection, audit-hash parity, and high-risk human-review enforcement.","Supabase advisors and RLS tests should run in the target environment before tenant canary."],"migrationPlan":["Apply the Supabase migration in a non-production project first.","Apply execution_attempt_compute_fabric_evidence_binding after the durable-store base and hardening migrations so new records project Compute Fabric evidence columns.","Run RLS/advisor checks and verify direct table access remains denied to anon and authenticated roles.","Run authenticated AAL2 record, replay, idempotency-reuse, idempotency-conflict, and review-disposition smoke.","Apply to production only after rollback and retention/residency owners approve.","Keep protected workflow execution disabled after migration until customer authorization and connector approvals exist."],"rolloutPlan":["Stage 0: code and public architecture evidence deployed with protected writes fail-closed.","Stage 1: migration applied in staging and authenticated AAL2 smoke passes.","Stage 1b: Compute Fabric evidence projection verified against record, replay, and review-disposition responses.","Stage 2: one synthetic pilot workspace canary records known attempts only.","Stage 3: reviewer dispositions enabled for tenant-admin, pilot-lead, and reviewer roles.","Stage 4: production connector, PHI, and model routing remain separate approval tracks with rollback gates."]},"clinicalAIOperatingSystemFoundation":[{"priority":"Clinical Robustness Lab","implementedBy":"Adversarial, missing-data, hallucination, evidence-quality, prompt-injection, regression, and clinical-safety scorecards bound to every durable attempt.","productionGate":"Add persisted evaluation datasets and reviewer-calibrated clinical readiness scores before clinical production use."},{"priority":"Agent Orchestration Layer","implementedBy":"Agent runtime identity, permission lists, denied capabilities, human approval gates, trace ids, and immutable event hooks on every envelope.","productionGate":"Specialty agents remain review-gated until scoped tools, memory hooks, and supervisor policies are approved per tenant."},{"priority":"Enterprise MCP Gateway","implementedBy":"Tool registry metadata, no connector access, route-level authorization, AAL2 governance session, and immutable audit events before tool use.","productionGate":"OAuth, scoped tokens, revocation endpoints, and tool-level allowlists must be live before MCP tools can operate."},{"priority":"Dynamic Model Routing","implementedBy":"Provider class, model version placeholder, cost, latency, confidence, fallback provider, and routing rationale are retained for every attempt.","productionGate":"Approved model registry, provider contracts, privacy review, budget limits, and routing observability must be activated."},{"priority":"Lazy Capability Loading","implementedBy":"Attempt records retain only task-relevant context refs, evidence refs, policy refs, allowed tools, and blocked tools.","productionGate":"Capability loader must enforce retrieval source, memory, model, and tool activation per task before live workflow workers run."},{"priority":"Dynamic Few-Shot Engine","implementedBy":"Validated example references are treated as evidence-bound retrieval inputs, not generic chain-of-thought prompts.","productionGate":"Persist reviewed examples with outcome, reviewer, specialty, risk level, and source before model execution."},{"priority":"Live Steering Engine","implementedBy":"Quarantine triggers, human approval gates, failure recovery, and protected-action denial are durable before execution.","productionGate":"Mid-run drift, cost, tool misuse, missing citations, and unsafe conclusion monitors must pause or terminate workers."},{"priority":"ReferralOS","implementedBy":"Referral queue summary attempts can be persisted as no-outreach metadata and routed to reviewer-held operations handoff.","productionGate":"Provider matching, insurance verification, scheduling, leakage analytics, and closed-loop feedback require approved connectors."},{"priority":"Ambient Clinical Workflow","implementedBy":"Documentation draft attempts carry clinician-review gates, no chart writeback, no orders, no patient instructions, and no PHI authority.","productionGate":"Conversation capture, note drafting, coding, prior auth, education, follow-up, referral, and medication workflows require human signoff."},{"priority":"Research Pipeline Engine","implementedBy":"Evidence refs, policy refs, source attribution, confidence, and human review state are preserved for research-like synthesis attempts.","productionGate":"Literature retrieval, contradiction detection, guideline comparison, trial matching, and recommendation review need validated sources."},{"priority":"Scientific Agent Toolkit","implementedBy":"Specialty-ready metadata lanes can bind oncology, imaging, genomics, trials, public health, and population health evidence cards.","productionGate":"Each scientific agent needs retrieval verification, citation checks, evidence grading, and accountable human review."},{"priority":"Edge / Private AI Architecture","implementedBy":"No-PHI and no-connector authority headers keep private deployment and local inference lanes distinct from public metadata evidence.","productionGate":"Local inference, speech, vision, imaging, FHIR gateway, knowledge graph, offline mode, and data-residency controls must be tenant approved."},{"priority":"MLOps / AIOps Foundation","implementedBy":"Attempt contract version, model route telemetry, scorecards, trace ids, replay tokens, and review dispositions create a registry-ready spine.","productionGate":"Prompt registry, model registry, evaluation datasets, reviewer queues, CI evals, regression detection, and rollback support must be connected."},{"priority":"Security and Compliance","implementedBy":"Least privilege, RLS deny-all tables, PHI guards, immutable events, no secrets, retention, regional tags, and fail-closed protected routes.","productionGate":"HIPAA program artifacts, BAAs/DPAs, secret scanning, SBOM, exploitability review, consent, and residency controls require external review."},{"priority":"Progressive Delivery","implementedBy":"Migration-ready store, canary rollout plan, protected fail-closed routes, health checks, and rollback-oriented hard stops.","productionGate":"Feature flags, staged tenant rollout, blast-radius controls, dashboards, and rollback drills must pass before broader activation."},{"priority":"Observability","implementedBy":"Model, prompt boundary, tool plan, latency budget, token/cost placeholders, confidence, reviewer outcome, clinical risk, and PHI risk are retained.","productionGate":"Live telemetry streams and dashboards must connect costs, latency, token use, hallucination risk, reviewer outcome, and escalation events."}],"hardStops":["No live patient data, PHI, member identifiers, raw chart text, secrets, credentials, or production connector payloads in durable attempt records.","No autonomous clinical authority, diagnosis, treatment, prescribing, clinical triage replacement, patient messaging, EHR writeback, payer submission, claim submission, or final billing action.","No tool access without explicit tenant membership, AAL2 governance session, scoped server runtime token, and route-level permission check.","No replay of protected side effects; replay can return retained metadata only.","No review disposition can create live-care, PHI, connector, payer, billing, certification, or go-live authority.","No production activation until the migration is applied, authenticated AAL2 smoke passes, retention/residency is approved, and customer-specific authorization exists."],"supportedReviewDispositions":["approved-for-synthetic-release","changes-requested","rejected","escalated"],"supportedRegions":["us","eu","uk","ca","apac","customer-private-region"],"activationControls":[{"gate":"live-migration-structural-verification","owner":"SCRIMED platform reliability + database owner","requiredEvidence":"Supabase migration history contains execution_attempt_durable_store, execution_attempt_durable_store_rpc_hardening, and execution_attempt_durable_store_advisor_alignment; live structural SQL verifies private tables, public wrappers, RLS, deny policies, restricted table grants, and foreign-key index coverage.","rollback":"Keep SCRIMED_EXECUTION_ATTEMPT_DURABLE_STORE_ENABLED=false or flip it back to false before any app release rollback."},{"gate":"rpc-least-privilege-hardening","owner":"SCRIMED security lead","requiredEvidence":"Public durable-store RPC wrappers stay SECURITY INVOKER with empty search_path; private implementation RPCs retain explicit authenticated execute only because wrappers delegate to them and each private RPC enforces AAL2 governance, tenant membership, server runtime token, and no-PHI guards.","rollback":"Revoke public wrapper execute from authenticated while retaining private tables for forensic review; keep the feature flag disabled until a new smoke passes."},{"gate":"authenticated-aal2-smoke","owner":"SCRIMED governance operator","requiredEvidence":"Run npm run smoke:execution-attempt-durable-store:authenticated with SCRIMED_BEARER_TOKEN, SCRIMED_REQUIRE_AUTHENTICATED_SMOKE=true, and a tenant workspace slug.","rollback":"Disable the feature flag and preserve retained audit events; do not delete durable evidence during incident review."},{"gate":"supabase-auth-password-posture","owner":"SCRIMED security lead + identity owner","requiredEvidence":"Supabase security advisor is clean for leaked-password protection when password sign-in is enabled, or product routes remain passkey/magic-link first with password auth excluded from protected durable-store operation.","rollback":"Keep password sign-in disabled for product routes or keep durable-store protected writes off in environments that rely on passwords without leaked-password protection."},{"gate":"tenant-canary-only","owner":"SCRIMED pilot operations","requiredEvidence":"One named no-PHI synthetic workspace records, replays, idempotently retries, and captures review disposition before broader tenant access.","rollback":"Remove tenant access to the route, keep protected workflow execution blocked, and retain no-PHI durable records until retention review."}],"sampleRecordableAttempts":[{"attemptId":"att_a1b4a5d1b714","idempotencyKey":"idem_a1b4a5d1b7141182c03dd057","replayToken":"replay_c1552eead2ab4068b6e0c3dc","workflowSlug":"prior-auth-evidence-packet","clinicalRiskLevel":"high","humanReviewRequired":true,"modelRoute":"route_fb15bb40cb","computeFabricSelectedModel":"retrieval-embedding-synthetic-slot","computeFabricModelTier":"EMBEDDING_MODEL","computeFabricPhiPolicy":"metadata-only-no-public-phi","computeFabricAuditHash":"scrimed-intel-0b93e75e","clinicalRobustnessScenarioRefs":["perfect-chart-conflict-unit-completeness","clinical-copilot-unit-abbreviation-citation"],"boundary":"This envelope is a metadata-only, no-PHI, replayable contract. It is not live workflow execution, not production persistence, not model routing approval, and not clinical or payer authority."},{"attemptId":"att_49ff8508346b","idempotencyKey":"idem_49ff8508346b6770c3dd43ed","replayToken":"replay_54b10f0d1ea07e11625de8e7","workflowSlug":"clinical-documentation-draft-review","clinicalRiskLevel":"high","humanReviewRequired":true,"modelRoute":"route_fb21f84068","computeFabricSelectedModel":"gpt-class-frontier-synthetic-slot","computeFabricModelTier":"FRONTIER_MODEL","computeFabricPhiPolicy":"metadata-only-no-public-phi","computeFabricAuditHash":"scrimed-intel-6a209b65","clinicalRobustnessScenarioRefs":["docutwin-noisy-incomplete-draft","ambient-scribe-noise-multilingual-injection"],"boundary":"This envelope is a metadata-only, no-PHI, replayable contract. It is not live workflow execution, not production persistence, not model routing approval, and not clinical or payer authority."},{"attemptId":"att_6158a14f1292","idempotencyKey":"idem_6158a14f1292a091335537c7","replayToken":"replay_ab1d10a31eb91039d9944159","workflowSlug":"referral-queue-administrative-summary","clinicalRiskLevel":"moderate","humanReviewRequired":true,"modelRoute":"route_d5408bccf0","computeFabricSelectedModel":"private-sglang-compact-runtime-slot","computeFabricModelTier":"COMPACT_REASONING_MODEL","computeFabricPhiPolicy":"metadata-only-no-public-phi","computeFabricAuditHash":"scrimed-intel-16825452","clinicalRobustnessScenarioRefs":["sanar-conflict-temporal-escalation","careexplain-multilingual-education-boundary"],"boundary":"This envelope is a metadata-only, no-PHI, replayable contract. It is not live workflow execution, not production persistence, not model routing approval, and not clinical or payer authority."},{"attemptId":"att_1b0731ae0518","idempotencyKey":"idem_1b0731ae05183c88be751df5","replayToken":"replay_5baa3594a4f08a86eb1a00e7","workflowSlug":"organization-policy-route-check","clinicalRiskLevel":"moderate","humanReviewRequired":true,"modelRoute":"route_fdb60aeb43","computeFabricSelectedModel":"private-sglang-compact-runtime-slot","computeFabricModelTier":"COMPACT_REASONING_MODEL","computeFabricPhiPolicy":"metadata-only-no-public-phi","computeFabricAuditHash":"scrimed-intel-b1c053f5","clinicalRobustnessScenarioRefs":["trialcore-eligibility-temporal-evidence","oncoid-abbreviation-guideline-conflict"],"boundary":"This envelope is a metadata-only, no-PHI, replayable contract. It is not live workflow execution, not production persistence, not model routing approval, and not clinical or payer authority."},{"attemptId":"att_c457962a73ff","idempotencyKey":"idem_c457962a73ff77a59c0f5b5f","replayToken":"replay_b8c7009f50d041cc33d9967c","workflowSlug":"trustops-signal-remediation-review","clinicalRiskLevel":"moderate","humanReviewRequired":true,"modelRoute":"route_cfb561cfa2","computeFabricSelectedModel":"private-sglang-compact-runtime-slot","computeFabricModelTier":"COMPACT_REASONING_MODEL","computeFabricPhiPolicy":"metadata-only-no-public-phi","computeFabricAuditHash":"scrimed-intel-9abbb131","clinicalRobustnessScenarioRefs":["sanar-conflict-temporal-escalation","clinical-copilot-unit-abbreviation-citation"],"boundary":"This envelope is a metadata-only, no-PHI, replayable contract. It is not live workflow execution, not production persistence, not model routing approval, and not clinical or payer authority."}],"remainingProductionGates":["Retain live Supabase structural verification evidence for migration history, private tables, RLS, deny policies, and RPC grants.","Run authenticated AAL2 record/replay/review smoke with server runtime token configured.","Connect model registry, prompt registry, cost budgets, and evaluation datasets to the durable record.","Implement OAuth scoped token issuance and revocation for a production MCP gateway.","Activate feature flags, canary dashboard, rollback runbook, and tenant-specific retention/residency policy."],"updated":"2026-06-28"}