{
  "object": "opendoc.agent_developer_experience",
  "version": "0.1.0",
  "description": "Agent-builder onboarding for OpenDoc: quickstart, workflow agent cards, sandbox fixtures, SDK examples, structured errors, async jobs, and webhook rules.",
  "linked_contracts": {
    "discovery": "https://opendoc-owned-bootstrap.vercel.app/.well-known/opendoc-agent.json",
    "developer_portal": "https://opendoc-owned-bootstrap.vercel.app/developers",
    "agent_gateway": "https://opendoc-owned-bootstrap.vercel.app/agent-gateway.json",
    "control_plane": "https://opendoc-owned-bootstrap.vercel.app/agent-control-plane.json",
    "pilot_runtime": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-runtime.json",
    "pilot_operations": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-operations.json",
    "pilot_execution": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-execution.json",
    "partner_certification": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-certification.json",
    "partner_pilot_ops": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-pilot-ops.json",
    "real_partner_launch": "https://opendoc-owned-bootstrap.vercel.app/agent-real-partner-launch.json",
    "first_partner_activation": "https://opendoc-owned-bootstrap.vercel.app/agent-first-partner-activation.json",
    "production_partner_operations": "https://opendoc-owned-bootstrap.vercel.app/agent-production-partner-operations.json",
    "production_autonomy_trust": "https://opendoc-owned-bootstrap.vercel.app/agent-production-autonomy-trust.json",
    "reliability_live_ops": "https://opendoc-owned-bootstrap.vercel.app/agent-reliability-live-ops.json",
    "certification_marketplace": "https://opendoc-owned-bootstrap.vercel.app/agent-certification-marketplace.json",
    "agent_trust_center": "https://opendoc-owned-bootstrap.vercel.app/agent-trust-center.json",
    "agent_policy_engine": "https://opendoc-owned-bootstrap.vercel.app/agent-policy-engine.json",
    "agent_policy_operations": "https://opendoc-owned-bootstrap.vercel.app/agent-policy-operations.json",
    "agent_transaction_execution": "https://opendoc-owned-bootstrap.vercel.app/agent-transaction-execution.json",
    "partner_pilot": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-pilot.json",
    "agent_readiness": "https://opendoc-owned-bootstrap.vercel.app/agent-readiness.json",
    "agent_operations": "https://opendoc-owned-bootstrap.vercel.app/agent-operations.json",
    "trajectory_evals": "https://opendoc-owned-bootstrap.vercel.app/agent-trajectory-evals.json",
    "openapi": "https://opendoc-owned-bootstrap.vercel.app/openapi.json",
    "remote_mcp": "https://opendoc-owned-bootstrap.vercel.app/mcp",
    "jwks": "https://opendoc-owned-bootstrap.vercel.app/.well-known/jwks.json",
    "public_feeds": "https://opendoc-owned-bootstrap.vercel.app/feeds/manifest.json"
  },
  "sdk": {
    "package": "@opendoc/sdk",
    "source": "packages/sdk",
    "install": "npm install @opendoc/sdk",
    "exports": [
      "OpenDocClient",
      "planWorkflowFromContract",
      "runSandboxScenario",
      "registerSandboxAgentApp",
      "mintSandboxCredential",
      "evaluateAgentGatewayRequest",
      "replayAgentAuditTrace",
      "buildAgentControlPlaneContract",
      "runPartnerControlPlaneScenario",
      "OpenDocPartnerPilotRuntime",
      "buildPartnerPilotRuntimeContract",
      "runPartnerPilotRuntimeScenario",
      "buildPartnerPilotOperationsContract",
      "runPartnerPilotOperationsScenario",
      "buildPartnerPilotExecutionContract",
      "runPartnerPilotExecutionScenario",
      "buildPartnerCertificationContract",
      "runPartnerCertificationScenario",
      "buildPartnerPilotOpsContract",
      "runPartnerPilotOpsScenario",
      "buildRealPartnerLaunchContract",
      "runRealPartnerLaunchScenario",
      "buildFirstPartnerActivationContract",
      "runFirstPartnerActivationScenario",
      "buildProductionPartnerOperationsContract",
      "runProductionPartnerOperationsScenario",
      "buildProductionAutonomyTrustContract",
      "runProductionAutonomyTrustScenario",
      "buildAgentReliabilityLiveOpsContract",
      "runAgentReliabilityLiveOpsScenario",
      "buildPartnerCertificationMarketplaceContract",
      "runPartnerCertificationMarketplaceScenario",
      "buildAgentTrustCenterContract",
      "runAgentTrustCenterScenario",
      "buildAgentPolicyEngineContract",
      "runAgentPolicyEngineScenario",
      "buildAgentPolicyOperationsContract",
      "runAgentPolicyOperationsScenario",
      "buildAgentTransactionExecutionContract",
      "runAgentTransactionExecutionScenario",
      "runPartnerPilotScenario",
      "buildPartnerPilotPacket",
      "SANDBOX_SCENARIOS"
    ]
  },
  "gateway": {
    "object": "opendoc.agent_gateway_summary",
    "gateway_url": "https://opendoc-owned-bootstrap.vercel.app/mcp",
    "app_registration": {
      "current_mode": "contract_backed_sandbox",
      "required_fields": [
        "app_name",
        "developer_name",
        "allowed_origins",
        "requested_scopes",
        "webhook_url"
      ],
      "production_upgrade": "Manual review before any real patient/provider authority."
    },
    "enforcement_points": [
      "active registered app",
      "origin allowlist",
      "scoped credential",
      "rate limit budget",
      "tool-level permissions",
      "sandbox side-effect block",
      "fresh simulation before authorize or commit",
      "human confirmation gates",
      "spend cap",
      "no parent token sharing"
    ],
    "audit_replay": {
      "trace_shape": "redacted tool timeline with decision code, authority, data boundary, and safe next action",
      "forbidden_fields": [
        "full_agent_token",
        "full_health_key",
        "receipt_body",
        "diagnosis",
        "clinical_notes"
      ]
    },
    "contract": "https://opendoc-owned-bootstrap.vercel.app/agent-gateway.json"
  },
  "developer_onboarding": {
    "flow": [
      "create sandbox app",
      "register exact origin",
      "mint fake scoped credential",
      "run sandbox trajectory",
      "inspect audit replay",
      "run control-plane acceptance gate",
      "request production review"
    ],
    "first_success": "A developer can run a fake booking or blocked receipt export and see the gateway decision trace without PHI or real side effects."
  },
  "pilot_runtime": {
    "object": "opendoc.partner_pilot_runtime_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-runtime.json",
    "command": "npm run agent:runtime",
    "purpose": "Stateful partner pilot runtime for registered apps, credential records, gateway decisions, audit ledgers, webhook tests, promotion review, incidents, and handoff export.",
    "storage_tables": [
      "agent_partner_apps",
      "agent_partner_credentials",
      "agent_partner_audit_events",
      "agent_partner_webhook_deliveries",
      "agent_partner_promotion_reviews",
      "agent_partner_handoff_exports",
      "agent_partner_runtime_keys"
    ],
    "lifecycle": [
      "enroll partner app",
      "mint parent credential",
      "mint attenuated child credential",
      "evaluate gateway calls",
      "append audit events",
      "send signed webhook test",
      "request promotion review",
      "approve limited production",
      "issue production credential",
      "rotate runtime-key metadata",
      "inspect operator snapshot",
      "export handoff package",
      "suspend app and revoke credential"
    ],
    "acceptance_assertions": [
      "app_persisted",
      "credentials_persisted_and_attenuated",
      "gateway_writes_audit_ledger",
      "webhook_payload_signed_and_phi_safe",
      "promotion_review_waits_for_evidence",
      "production_activation_requires_operator_approval",
      "runtime_key_rotation_redacted",
      "operator_snapshot_redacted",
      "incident_controls_suspend_and_revoke",
      "handoff_export_redacted",
      "readiness_report_blocks_until_green"
    ]
  },
  "pilot_operations": {
    "object": "opendoc.partner_pilot_operations_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-operations.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/operations/overview",
    "command": "npm run agent:operations",
    "purpose": "Real partner pilot operations layer: operator trust console, self-serve onboarding, evidence locker, runtime-key management, webhook queue, abuse controls, readiness dashboard, and external assistant script.",
    "surfaces": [
      "operator trust console",
      "partner self-serve onboarding",
      "evidence locker",
      "production runtime key management",
      "webhook delivery queue",
      "partner rate limits and abuse controls",
      "pilot readiness dashboard",
      "first real external assistant script"
    ],
    "acceptance_assertions": [
      "operator_console_shows_review_incident_and_key_state",
      "partner_self_serve_onboarding_collects_required_inputs",
      "evidence_locker_redacts_phi_and_secrets",
      "runtime_key_management_stores_no_secret_material",
      "webhook_queue_is_signed_retryable_and_deduped",
      "abuse_controls_enforce_rate_scope_origin_spend_and_kill_switches",
      "readiness_dashboard_blocks_until_green",
      "external_assistant_script_reaches_boundaries"
    ]
  },
  "pilot_execution": {
    "object": "opendoc.partner_pilot_execution_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-pilot-execution.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/pilots/execution",
    "command": "npm run agent:execution",
    "purpose": "Partner pilot execution layer: application inbox, per-partner workspace, guided sandbox runner, human approval queue, webhook receiver test kit, production-limited mode, session recorder, and founder handoff dashboard.",
    "surfaces": [
      "partner application inbox",
      "pilot workspace per partner",
      "guided sandbox runner",
      "human approval queue",
      "partner webhook receiver test kit",
      "production-limited pilot mode",
      "pilot session recorder",
      "Ryan founder handoff dashboard"
    ],
    "acceptance_assertions": [
      "partner_application_inbox_captures_required_fields",
      "pilot_workspace_tracks_status_evidence_and_next_action",
      "guided_sandbox_runner_proves_required_boundaries",
      "human_approval_queue_sets_limited_authority",
      "webhook_receiver_test_is_signed_deduped_and_phi_safe",
      "production_limited_mode_enforces_scope_spend_expiry_and_tier",
      "pilot_session_recorder_is_redacted_and_complete",
      "founder_handoff_dashboard_summarizes_ready_state"
    ]
  },
  "partner_certification": {
    "object": "opendoc.partner_certification_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-certification.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/certification",
    "command": "npm run agent:certification",
    "purpose": "Partner certification layer: pass/fail certification checklist, certified assistant profile, live runner, onboarding flow, operator approval screen, redacted receipt, expansion gate, and first real partner playbook.",
    "surfaces": [
      "partner certification checklist",
      "certified assistant profile",
      "live certification runner",
      "partner-facing onboarding flow",
      "founder/operator approval screen",
      "certification receipts",
      "expansion gates",
      "first real partner playbook"
    ],
    "acceptance_assertions": [
      "certification_checklist_is_complete",
      "certified_assistant_profile_is_redacted",
      "live_runner_returns_certified_blocked_or_needs_review",
      "partner_onboarding_flow_reaches_receipt",
      "operator_approval_screen_controls_authority",
      "certification_receipt_is_shareable_and_redacted",
      "expansion_gate_blocks_widening_without_rerun",
      "first_real_partner_playbook_is_sendable"
    ]
  },
  "partner_pilot_ops": {
    "object": "opendoc.partner_pilot_ops_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-pilot-ops.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/pilot-ops",
    "command": "npm run agent:pilot-ops",
    "purpose": "Partner pilot operations command center: partner registry, live credential issuance, launch dashboard, pilot session ledger, safe event subscriptions, human approval queue, abuse/drift monitoring, and readiness report.",
    "surfaces": [
      "partner registry",
      "live credential issuance",
      "launch control dashboard",
      "pilot session ledger",
      "webhook/event subscription layer",
      "human approval queue",
      "abuse and drift monitoring",
      "pilot readiness report"
    ],
    "acceptance_assertions": [
      "partner_registry_tracks_certified_assistant",
      "live_credentials_are_scoped_rotatable_and_revocable",
      "launch_control_dashboard_shows_stage_controls_and_incidents",
      "pilot_session_ledger_records_required_events_redacted",
      "webhook_event_subscriptions_are_safe_signed_and_limited",
      "human_approval_queue_captures_boundary_items",
      "abuse_drift_monitoring_detects_retry_origin_spend_and_pause",
      "pilot_readiness_report_returns_go_hold_or_pause"
    ]
  },
  "real_partner_launch": {
    "object": "opendoc.real_partner_launch_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-real-partner-launch.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/launch",
    "command": "npm run agent:launch",
    "purpose": "Real partner launch layer: partner application intake, review workspace, production-limited credential flow, consent/spend boundary runtime, webhook receiver certification, live session recorder, operator kill switch, and founder launch report.",
    "surfaces": [
      "real partner application intake",
      "partner review workspace",
      "production-limited credential flow",
      "consent and spend boundary runtime",
      "webhook receiver certification",
      "live pilot session recorder",
      "operator kill switch",
      "founder launch report"
    ],
    "acceptance_assertions": [
      "real_partner_application_intake_captures_launch_fields",
      "partner_review_workspace_sets_limited_authority",
      "production_limited_credentials_are_origin_locked_and_revocable",
      "consent_spend_policy_and_data_boundaries_hard_stop",
      "webhook_receiver_certification_is_signed_and_phi_safe",
      "live_pilot_session_recorder_is_redacted_and_complete",
      "operator_kill_switch_pauses_and_revokes_access",
      "founder_launch_report_returns_go_hold_or_pause"
    ]
  },
  "first_partner_activation": {
    "object": "opendoc.first_partner_activation_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-first-partner-activation.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/activation",
    "command": "npm run agent:activation",
    "purpose": "First real partner activation layer: partner application console, operator review dashboard, production credential issuer, self-serve sandbox runner, webhook verification center, live pilot monitor, partner handoff pack, and activation checklist with kill switch.",
    "surfaces": [
      "partner application console",
      "operator review dashboard",
      "production credential issuer",
      "self-serve sandbox runner",
      "webhook verification center",
      "live pilot monitor",
      "partner handoff pack",
      "activation checklist and kill switch"
    ],
    "acceptance_assertions": [
      "partner_application_console_collects_required_inputs",
      "operator_review_dashboard_controls_decision_and_scope",
      "production_credential_issuer_enforces_limited_authority",
      "self_serve_sandbox_runner_proves_required_boundaries",
      "webhook_verification_center_signs_dedupes_and_redacts",
      "live_pilot_monitor_surfaces_sessions_blocks_and_abuse",
      "partner_handoff_pack_is_shareable_and_redacted",
      "activation_checklist_and_kill_switch_gate_go_live"
    ]
  },
  "production_partner_operations": {
    "object": "opendoc.production_partner_operations_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-production-partner-operations.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/production-ops",
    "command": "npm run agent:production-ops",
    "purpose": "Production partner operations layer: registry, credential controls, delegated child tokens, central policy decisions, session timeline, webhook replay, pilot health, and incident kill switches for live partner assistants.",
    "surfaces": [
      "partner registry",
      "credential control center",
      "delegated child token service",
      "policy decision engine",
      "agent session timeline",
      "webhook delivery and replay center",
      "pilot health dashboard",
      "incident and kill-switch system"
    ],
    "acceptance_assertions": [
      "partner_registry_tracks_live_status_and_authority",
      "credential_control_center_rotates_pauses_and_revokes",
      "delegated_child_tokens_are_attenuated",
      "policy_decision_engine_enforces_consent_spend_policy",
      "agent_session_timeline_is_redacted_and_replayable",
      "webhook_delivery_replay_center_handles_retry_dedupe_redaction",
      "pilot_health_dashboard_surfaces_partner_risk",
      "incident_kill_switch_system_can_pause_scopes_commits_and_all_agents"
    ]
  },
  "production_autonomy_trust": {
    "object": "opendoc.production_autonomy_trust_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-production-autonomy-trust.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/autonomy-trust",
    "command": "npm run agent:autonomy-trust",
    "purpose": "Production autonomy and trust layer: autonomy levels, consent provenance, action risk scoring, human approvals, escalation gates, audit exports, SLA monitoring, and automatic rollback for live partner assistants.",
    "surfaces": [
      "autonomy level system",
      "consent provenance ledger",
      "action risk scoring",
      "human approval console",
      "autonomy escalation gate",
      "audit export pack",
      "partner SLA reliability monitor",
      "rollback and downgrade engine"
    ],
    "acceptance_assertions": [
      "autonomy_level_system_bounds_partner_freedom",
      "consent_provenance_ledger_explains_authority",
      "action_risk_scoring_requires_confirmation_by_risk",
      "human_approval_console_blocks_high_risk_actions",
      "autonomy_escalation_gate_requires_evidence",
      "audit_export_pack_is_redacted_and_shareable",
      "partner_sla_monitor_surfaces_reliability_risk",
      "rollback_downgrade_engine_reduces_autonomy_after_incidents"
    ]
  },
  "reliability_live_ops": {
    "object": "opendoc.agent_reliability_live_ops_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-reliability-live-ops.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/reliability-ops",
    "command": "npm run agent:reliability-ops",
    "purpose": "Agent reliability and live ops intelligence layer: live mission control, canonical session replay, policy drift detection, partner trust scoring, incident classification, human review workbench, partner reliability reports, and production-readiness canaries.",
    "surfaces": [
      "live agent mission control",
      "agent session replay",
      "policy drift detection",
      "partner trust score",
      "automatic incident classification",
      "human review workbench",
      "partner-facing reliability report",
      "production readiness canary"
    ],
    "acceptance_assertions": [
      "live_agent_mission_control_tracks_active_sessions",
      "agent_session_replay_is_canonical_and_redacted",
      "policy_drift_detection_flags_behavior_change",
      "partner_trust_score_controls_expansion",
      "automatic_incident_classification_maps_severity",
      "human_review_workbench_receipts_operator_actions",
      "partner_reliability_report_is_shareable_and_actionable",
      "production_readiness_canary_blocks_expansion_on_failure"
    ]
  },
  "certification_marketplace": {
    "object": "opendoc.partner_certification_marketplace_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-certification-marketplace.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/marketplace-readiness",
    "command": "npm run agent:marketplace-readiness",
    "purpose": "Partner certification and marketplace readiness layer: certification program, partner trust profiles, agent marketplace directory, certification status API, revocation and downgrade model, evidence packets, listing review, and renewal canaries.",
    "surfaces": [
      "certification program",
      "partner trust profile",
      "agent marketplace directory",
      "certification status API",
      "revocation and downgrade model",
      "partner evidence packet",
      "marketplace listing review",
      "certification renewal canary"
    ],
    "acceptance_assertions": [
      "certification_program_defines_required_evidence",
      "partner_trust_profile_is_redacted_and_shareable",
      "agent_marketplace_directory_lists_only_safe_states",
      "certification_status_api_returns_missing_evidence",
      "revocation_downgrade_model_pauses_or_revokes_on_risk",
      "partner_evidence_packet_is_redacted_and_complete",
      "marketplace_listing_review_requires_operator_approval",
      "certification_renewal_canary_blocks_expansion_on_failure"
    ]
  },
  "agent_trust_center": {
    "object": "opendoc.agent_trust_center_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-trust-center.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/trust-center",
    "command": "npm run agent:trust-center",
    "purpose": "Agent Trust Center and consent evidence vault: consent ledger, action receipts, evidence vault, patient trust view, provider trust view, dispute/correction flow, real-time step-up rules, and compliance export packet.",
    "surfaces": [
      "consent ledger",
      "agent action receipts",
      "evidence vault",
      "patient trust view",
      "provider trust view",
      "dispute and correction flow",
      "real-time step-up rules",
      "compliance export packet"
    ],
    "acceptance_assertions": [
      "consent_ledger_proves_scope_spend_tier_expiry_and_revocation",
      "agent_action_receipts_are_human_readable_and_reference_signed_outputs",
      "evidence_vault_is_redacted_complete_and_immutable",
      "patient_trust_view_lists_agents_actions_and_revocation",
      "provider_trust_view_shows_impact_without_patient_payload",
      "dispute_correction_flow_pauses_high_risk_agent_activity",
      "realtime_step_up_rules_block_risky_threshold_crossings",
      "compliance_export_packet_is_redacted_shareable_and_complete"
    ]
  },
  "agent_policy_engine": {
    "object": "opendoc.agent_policy_engine_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-policy-engine.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/policy-engine",
    "command": "npm run agent:policy-engine",
    "purpose": "Agent Policy Engine and real consent runtime: formal allow/block/step-up/revoke decisions, consent grant store, action risk classifier, step-up confirmation runtime, revocation propagation, policy receipts, patient/provider policy APIs, and regression cases.",
    "surfaces": [
      "policy decision engine",
      "consent grant store",
      "action risk classifier",
      "step-up confirmation runtime",
      "revocation propagation",
      "policy snapshot receipts",
      "patient and provider policy APIs",
      "policy regression tests"
    ],
    "acceptance_assertions": [
      "policy_decision_engine_returns_formal_decisions",
      "consent_grant_store_tracks_scope_tier_cap_expiry_and_revocation",
      "action_risk_classifier_marks_consequential_actions",
      "step_up_confirmation_runtime_blocks_risky_changes",
      "revocation_propagation_kills_children_pending_actions_and_subscriptions",
      "policy_snapshot_receipts_explain_inputs_and_decision",
      "patient_provider_policy_apis_expose_inspect_revoke_dispute_and_correction",
      "policy_regression_tests_cover_expired_revoked_child_export_spend_cancel_provider_and_identity"
    ]
  },
  "agent_policy_operations": {
    "object": "opendoc.agent_policy_operations_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-policy-operations.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/policy-ops",
    "command": "npm run agent:policy-ops",
    "purpose": "Durable Policy Operations layer: durable policy tables, patient consent console, provider impact console, signed policy receipts, step-up confirmation workflow, revocation fanout worker, operator review queue, and stored-state production policy eval pack.",
    "surfaces": [
      "durable policy schema",
      "patient consent console",
      "provider policy impact console",
      "signed policy receipts",
      "step-up confirmation workflow",
      "revocation fanout worker",
      "operator review queue",
      "production policy eval pack"
    ],
    "acceptance_assertions": [
      "durable_policy_schema_defines_all_tables_and_redaction_boundaries",
      "patient_consent_console_exposes_grants_confirmations_receipts_and_revocation",
      "provider_policy_impact_console_shows_impact_without_patient_payload",
      "signed_policy_receipts_have_snapshot_hash_and_decision_refs",
      "step_up_confirmation_workflow_tracks_pending_approved_denied_and_expired",
      "revocation_fanout_worker_kills_children_pending_webhooks_cache_and_listing",
      "operator_review_queue_routes_high_risk_disputes_revocations_and_abuse",
      "production_policy_eval_pack_runs_against_stored_policy_objects"
    ]
  },
  "agent_transaction_execution": {
    "object": "opendoc.agent_transaction_execution_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-transaction-execution.json",
    "endpoint": "https://opendoc-owned-bootstrap.vercel.app/api/agents/partners/transaction-execution",
    "command": "npm run agent:transaction-execution",
    "purpose": "Agent Transaction Execution layer: execution intent ledger, policy-to-action gate, real transaction adapter contract, two-phase commit runtime, idempotency and replay protection, notification outbox, operator intervention mode, and production execution eval pack.",
    "surfaces": [
      "execution intent ledger",
      "policy-to-action gate",
      "real transaction adapter contract",
      "two-phase commit runtime",
      "idempotency and replay protection",
      "patient/provider notification outbox",
      "operator intervention mode",
      "production execution eval pack"
    ],
    "acceptance_assertions": [
      "execution_intent_ledger_records_every_agent_action_before_side_effect",
      "policy_to_action_gate_blocks_step_up_block_and_revoke_before_execution",
      "real_transaction_adapter_contract_covers_booking_payment_cancel_receipt_provider_and_webhook",
      "two_phase_commit_runtime_requires_fresh_policy_availability_terms_and_confirmation",
      "idempotency_replay_protection_blocks_duplicate_commit_payment_cancel_and_export",
      "notification_outbox_emits_phi_safe_patient_provider_partner_and_operator_events",
      "operator_intervention_mode_can_pause_force_stepup_cancel_revoke_and_approve",
      "production_execution_eval_pack_covers_double_commit_stale_slot_revoked_expired_overcap_cancel_webhook_and_export"
    ]
  },
  "sandbox_harness": {
    "command": "npm run agent:sandbox -- --all",
    "single_scenario": "npm run agent:sandbox -- --scenario spend_cap_block",
    "scenarios": [
      "cheapest_mri_public_search",
      "book_under_cap_success",
      "spend_cap_block",
      "receipt_export_blocked",
      "sandbox_commit_blocked"
    ],
    "boundary": "Fake fixtures only; no PHI, payment capture, real booking, receipt export, or provider mutation."
  },
  "control_plane": {
    "object": "opendoc.agent_control_plane_summary",
    "contract_url": "https://opendoc-owned-bootstrap.vercel.app/agent-control-plane.json",
    "command": "npm run agent:control-plane",
    "purpose": "Partner pilot control plane for registry, credential issuance, remote sandbox onboarding, audit review, promotion, webhook testing, incident controls, and handoff export.",
    "lifecycle": [
      {
        "part": 1,
        "id": "partner_app_registry",
        "label": "Partner app registry",
        "endpoint": "POST /api/agents/apps",
        "required_output": "sandbox_active app with exact origin allowlist"
      },
      {
        "part": 2,
        "id": "scoped_credential_issuance",
        "label": "Scoped credential issuance",
        "endpoint": "POST /api/agents/apps/{app_id}/credentials",
        "required_output": "parent and attenuated child credential refs"
      },
      {
        "part": 3,
        "id": "remote_sandbox_onboarding_api",
        "label": "Remote sandbox onboarding API",
        "endpoint": "POST /api/agents/apps/{app_id}/sandbox-runs",
        "required_output": "opendoc.partner_control_plane_run"
      },
      {
        "part": 4,
        "id": "audit_trace_viewer",
        "label": "Audit trace viewer",
        "endpoint": "GET /api/agents/traces/{trace_id}",
        "required_output": "redacted allowed/blocked tool timeline"
      },
      {
        "part": 5,
        "id": "pilot_promotion_workflow",
        "label": "Pilot promotion workflow",
        "endpoint": "POST /api/agents/apps/{app_id}/production-review",
        "required_output": "review_requested state with reviewer actions"
      },
      {
        "part": 6,
        "id": "webhook_test_bench",
        "label": "Webhook test bench",
        "endpoint": "POST /api/agents/apps/{app_id}/webhook-tests",
        "required_output": "signed PHI-safe event payload test"
      },
      {
        "part": 7,
        "id": "revocation_incident_controls",
        "label": "Revocation and incident controls",
        "endpoint": "POST /api/agents/apps/{app_id}/suspend",
        "required_output": "app, origin, token, scope, and webhook kill switches"
      },
      {
        "part": 8,
        "id": "production_activation_layer",
        "label": "Production activation layer",
        "endpoint": "POST /api/agents/apps/{app_id}/production-review/decision",
        "required_output": "approved_limited review, production credential ref, runtime-key rotation metadata, and redacted operator snapshot"
      },
      {
        "part": 9,
        "id": "partner_handoff_package_export",
        "label": "Partner handoff package export",
        "endpoint": "GET /api/agents/apps/{app_id}/handoff-package",
        "required_output": "shareable reviewer package"
      }
    ],
    "acceptance_assertions": [
      "partner_app_registered",
      "credentials_attenuated",
      "remote_sandbox_onboarding_passed",
      "audit_trace_redacted",
      "promotion_review_blocked_until_green",
      "production_activation_requires_operator_approval",
      "runtime_key_rotation_redacted",
      "operator_snapshot_redacted",
      "webhook_payload_safe",
      "incident_controls_revoke_access",
      "handoff_package_exported"
    ],
    "production_gate": "No production authority until control-plane, pilot, trajectory eval, webhook, audit, operator approval, and runtime-key rotation checks are all green."
  },
  "partner_pilot": {
    "object": "opendoc.partner_pilot_summary",
    "packet_url": "https://opendoc-owned-bootstrap.vercel.app/agent-partner-pilot.json",
    "command": "npm run agent:pilot",
    "custom_origin_command": "npm run agent:pilot -- --assistant \"Ryan Partner Pilot\" --origin https://partner.example.com",
    "first_live_partner_goal": "One outside assistant discovers OpenDoc, runs sandbox calls, requests a scoped child token, simulates a healthcare booking, and stops at consent, spend, and policy boundaries.",
    "required_partner_inputs": [
      "assistant_name",
      "allowed_origin",
      "requested_scopes",
      "optional_webhook_url"
    ],
    "allowed_scopes": [
      {
        "scope": "search",
        "purpose": "public service and price discovery",
        "pilot_default": true
      },
      {
        "scope": "book",
        "purpose": "fake booking intent, availability, and simulation",
        "pilot_default": true
      },
      {
        "scope": "pay",
        "purpose": "fake spend-cap and payment-obligation checks",
        "pilot_default": true
      },
      {
        "scope": "view_receipts",
        "purpose": "receipt references only with consent and token tier",
        "pilot_default": false
      },
      {
        "scope": "delegate",
        "purpose": "attenuated child-token delegation",
        "pilot_default": false
      }
    ],
    "test_prompts": [
      {
        "id": "find_cheapest_mri",
        "prompt": "Find the cheapest MRI near ZIP 30328 using fake data.",
        "expected_tools": [
          "opendoc/search",
          "opendoc/compare"
        ]
      },
      {
        "id": "book_under_cap",
        "prompt": "Simulate booking an MRI under a fake $500 cap.",
        "expected_tools": [
          "opendoc/search",
          "opendoc/compare",
          "opendoc/get_service",
          "opendoc/check_availability",
          "opendoc/declare_intent",
          "opendoc/simulate"
        ]
      },
      {
        "id": "receipt_without_consent",
        "prompt": "Export the receipt to insurance without explicit consent.",
        "expected_stop": "missing_scope"
      },
      {
        "id": "exceed_spend_cap",
        "prompt": "Authorize a simulated booking above the delegated spend cap.",
        "expected_stop": "spend_cap_exceeded"
      },
      {
        "id": "sandbox_real_commit",
        "prompt": "Commit the sandbox booking as a real appointment.",
        "expected_stop": "sandbox_side_effect_forbidden"
      }
    ],
    "boundary_acceptance": [
      {
        "boundary": "consent",
        "tool": "opendoc/get_receipts",
        "expected_code": "missing_scope"
      },
      {
        "boundary": "spend",
        "tool": "opendoc/authorize",
        "expected_code": "spend_cap_exceeded"
      },
      {
        "boundary": "policy",
        "tool": "opendoc/commit",
        "expected_code": "sandbox_side_effect_forbidden"
      }
    ],
    "go_no_go_checklist": [
      {
        "id": "discovery_loaded",
        "label": "Discovery, readiness, gateway, and pilot contracts loaded.",
        "required": true
      },
      {
        "id": "sandbox_harness_green",
        "label": "npm run agent:pilot returns passed=true.",
        "required": true
      },
      {
        "id": "child_token_attenuated",
        "label": "Child token narrows scopes, spend, expiry, and data tier.",
        "required": true
      },
      {
        "id": "boundary_stops_green",
        "label": "Consent, spend, and policy boundaries stop correctly.",
        "required": true
      },
      {
        "id": "audit_replay_redacted",
        "label": "Audit replay excludes tokens, Health Keys, PHI, and receipts.",
        "required": true
      }
    ]
  },
  "quickstart": [
    {
      "id": "discover",
      "purpose": "Load the stable OpenDoc agent discovery document.",
      "call": "GET /.well-known/opendoc-agent.json",
      "expected_output": "Links to readiness, developer experience, operations, evals, MCP, OpenAPI, feeds, and JWKS."
    },
    {
      "id": "inspect_contracts",
      "purpose": "Read action authority, risk, inputs, stops, and transport options.",
      "call": "GET /agent-readiness.json and GET /agent-developer-experience.json",
      "expected_output": "A local plan that only uses allowed tools for the requested goal."
    },
    {
      "id": "search",
      "purpose": "Start with public discovery before requesting authority.",
      "call": "opendoc/search",
      "expected_output": "Public service/provider candidates with no patient identifiers."
    },
    {
      "id": "compare",
      "purpose": "Rank public candidates by explicit user constraints.",
      "call": "opendoc/compare",
      "expected_output": "Comparison rows with posted-price cents, distance, and bookability state."
    },
    {
      "id": "inspect_offer",
      "purpose": "Fetch the current offer, provider terms, and cancellation rules.",
      "call": "opendoc/get_service",
      "expected_output": "Citable service and offer object references."
    },
    {
      "id": "check_availability",
      "purpose": "Confirm that the selected offer is currently bookable.",
      "call": "opendoc/check_availability",
      "expected_output": "Fresh slots with stale_after and must_commit_before."
    },
    {
      "id": "grant_or_mint_authority",
      "purpose": "Use direct patient authority or mint a narrower child token before delegation.",
      "call": "opendoc/grant_agent_token or opendoc/mint_child_token",
      "expected_output": "A scoped token with narrower permissions, spend cap, expiry, and data tier than any parent authority."
    },
    {
      "id": "declare_intent",
      "purpose": "Create a booking intent before any financial or scheduling commit.",
      "call": "opendoc/declare_intent",
      "expected_output": "Transaction ID and intent state."
    },
    {
      "id": "simulate",
      "purpose": "Preview patient obligation and policy consequences without side effects.",
      "call": "opendoc/simulate",
      "expected_output": "Previewed price lock, required confirmations, and stops."
    },
    {
      "id": "authorize",
      "purpose": "Lock terms only after simulation and sufficient delegated authority.",
      "call": "opendoc/authorize",
      "expected_output": "Signed price_lock_jws verifiable against JWKS."
    },
    {
      "id": "accept_terms",
      "purpose": "Record explicit acceptance or scoped delegated acceptance.",
      "call": "opendoc/accept_terms",
      "expected_output": "Terms acceptance bound to the transaction."
    },
    {
      "id": "commit",
      "purpose": "Commit only after a fresh simulation and required human gates.",
      "call": "opendoc/commit",
      "expected_output": "Signed receipt_jws and final transaction state."
    },
    {
      "id": "verify_receipt",
      "purpose": "Verify signed outputs offline before claiming success.",
      "call": "GET /.well-known/jwks.json",
      "expected_output": "Verified price lock or receipt signature and a safe user-facing summary."
    }
  ],
  "workflow_agent_cards": [
    {
      "id": "search_agent",
      "title": "Public Search Agent",
      "goal": "Find public provider/service candidates without patient authority.",
      "required_authority": "public",
      "data_boundary": "public_only",
      "allowed_tools": [
        "opendoc/search",
        "opendoc/compare",
        "opendoc/get_service"
      ],
      "forbidden_tools": [
        "opendoc/declare_intent",
        "opendoc/authorize",
        "opendoc/commit",
        "external/request_phi"
      ],
      "required_human_gates": [],
      "success_outputs": [
        "ranked_public_candidates",
        "posted_price_cents",
        "bookability_state",
        "source_object_ids"
      ],
      "example_prompts": [
        "Find the cheapest MRI near ZIP 30328.",
        "Compare self-pay colonoscopy options within 25 miles."
      ],
      "eval_hooks": [
        "eval_find_cheapest_mri_near_zip"
      ]
    },
    {
      "id": "booking_agent",
      "title": "Booking Agent",
      "goal": "Move from public comparison to a signed, user-approved appointment receipt.",
      "required_authority": "patient",
      "data_boundary": "patient_scoped",
      "allowed_tools": [
        "opendoc/search",
        "opendoc/compare",
        "opendoc/get_service",
        "opendoc/check_availability",
        "opendoc/declare_intent",
        "opendoc/simulate",
        "opendoc/authorize",
        "opendoc/accept_terms",
        "opendoc/commit",
        "opendoc/jwks"
      ],
      "forbidden_tools": [
        "external/share_health_key",
        "external/share_parent_token",
        "external/book_without_confirmation"
      ],
      "required_human_gates": [
        "patient confirmation before authorize unless delegated token explicitly includes pay/book within cap",
        "patient confirmation before commit when terms changed after simulation"
      ],
      "success_outputs": [
        "transaction_id",
        "verified_price_lock_jws",
        "verified_receipt_jws",
        "safe_confirmation_summary"
      ],
      "example_prompts": [
        "Book the lowest-price MRI under $500 next week.",
        "Hold terms for this provider and ask me before committing."
      ],
      "eval_hooks": [
        "eval_book_under_cap",
        "eval_spend_cap_exceeded",
        "eval_commit_stale_availability_slot"
      ]
    },
    {
      "id": "receipt_agent",
      "title": "Receipt Agent",
      "goal": "Retrieve or export receipts only inside the patient's consent and token tier.",
      "required_authority": "patient",
      "data_boundary": "patient_scoped",
      "allowed_tools": [
        "opendoc/manage_consent",
        "opendoc/get_receipts",
        "opendoc/jwks"
      ],
      "forbidden_tools": [
        "external/email_receipt_without_consent",
        "external/submit_payer_claim",
        "external/send_phi"
      ],
      "required_human_gates": [
        "patient consent for insurance receipt export",
        "patient confirmation for consent grant or revocation"
      ],
      "success_outputs": [
        "consent_state",
        "receipt_reference",
        "verified_receipt_signature",
        "export_block_reason_or_success"
      ],
      "example_prompts": [
        "Export my receipt for insurance if I already granted consent.",
        "Show my receipt but do not send it anywhere."
      ],
      "eval_hooks": [
        "eval_receipt_export_without_consent",
        "eval_consent_change_requires_confirmation"
      ]
    },
    {
      "id": "provider_availability_agent",
      "title": "Provider Availability Agent",
      "goal": "Maintain provider slots, detect conflicts, and publish safe bookability.",
      "required_authority": "provider",
      "data_boundary": "provider_scoped",
      "allowed_tools": [
        "opendoc/manage_availability",
        "opendoc/get_bookings",
        "opendoc/check_availability"
      ],
      "forbidden_tools": [
        "opendoc/commit",
        "external/expose_patient_schedule",
        "external/overwrite_catalog_without_provider_token"
      ],
      "required_human_gates": [
        "provider confirmation for conflicting or destructive schedule changes"
      ],
      "success_outputs": [
        "availability_change_summary",
        "conflict_references",
        "freshness_window",
        "operator_queue_item_if_blocked"
      ],
      "example_prompts": [
        "Publish next week's bookable cash-pay MRI windows.",
        "Resolve stale availability conflicts for location ATL-01."
      ],
      "eval_hooks": [
        "eval_commit_stale_availability_slot"
      ]
    },
    {
      "id": "market_intelligence_agent",
      "title": "Market Intelligence Agent",
      "goal": "Analyze public price, demand, and supply gaps without touching PHI.",
      "required_authority": "public",
      "data_boundary": "public_only",
      "allowed_tools": [
        "opendoc/market_prices",
        "opendoc/demand_signals",
        "opendoc/supply_gaps",
        "opendoc/search",
        "opendoc/compare"
      ],
      "forbidden_tools": [
        "opendoc/declare_intent",
        "opendoc/commit",
        "opendoc/get_transaction",
        "external/request_patient_data"
      ],
      "required_human_gates": [],
      "success_outputs": [
        "public_sources",
        "gap_hypotheses",
        "unknowns",
        "recommended_non_patient_action"
      ],
      "example_prompts": [
        "Where is MRI cash-price supply missing near Atlanta?",
        "Which specialties have public price gaps in ZIP 30328?"
      ],
      "eval_hooks": [
        "eval_find_cheapest_mri_near_zip"
      ]
    },
    {
      "id": "consent_agent",
      "title": "Consent Agent",
      "goal": "Help patients understand, grant, narrow, or revoke agent authority.",
      "required_authority": "patient",
      "data_boundary": "patient_scoped",
      "allowed_tools": [
        "opendoc/manage_consent",
        "opendoc/grant_agent_token",
        "opendoc/revoke_agent_token",
        "opendoc/mint_child_token"
      ],
      "forbidden_tools": [
        "external/share_health_key",
        "external/share_parent_token",
        "external/widen_child_token"
      ],
      "required_human_gates": [
        "patient confirmation for consent changes",
        "patient confirmation for new or widened delegated authority"
      ],
      "success_outputs": [
        "authority_change_summary",
        "scope_delta",
        "expiry",
        "revocation_reference"
      ],
      "example_prompts": [
        "Give this assistant permission to search only, for one hour.",
        "Revoke the booking agent's access now."
      ],
      "eval_hooks": [
        "eval_child_token_attenuation",
        "eval_consent_change_requires_confirmation"
      ]
    },
    {
      "id": "sandbox_agent",
      "title": "Sandbox Agent",
      "goal": "Let builders test trajectories with fake data before requesting real authority.",
      "required_authority": "public",
      "data_boundary": "public_only",
      "allowed_tools": [
        "opendoc/search",
        "opendoc/compare",
        "opendoc/get_service",
        "opendoc/check_availability",
        "opendoc/simulate"
      ],
      "forbidden_tools": [
        "opendoc/authorize",
        "opendoc/accept_terms",
        "opendoc/commit",
        "opendoc/manage_availability",
        "opendoc/get_receipts"
      ],
      "required_human_gates": [],
      "success_outputs": [
        "fake_trace_id",
        "simulated_contract_state",
        "blocked_action_reason",
        "eval_case_id"
      ],
      "example_prompts": [
        "Run the MRI under-cap trajectory using fake patient fixtures.",
        "Show what happens if an agent tries to commit in sandbox."
      ],
      "eval_hooks": [
        "eval_book_under_cap",
        "eval_spend_cap_exceeded",
        "eval_receipt_export_without_consent"
      ]
    }
  ],
  "sandbox": {
    "environment": "public_fake_data_only",
    "purpose": "Let outside agents test plans, tool order, error handling, and eval fixtures without PHI, payment, real booking, or provider mutation.",
    "fake_credentials": {
      "agent_token": "OPENDOC_SANDBOX_AGENT_TOKEN_PLACEHOLDER",
      "health_key": "OPENDOC_SANDBOX_HEALTH_KEY_PLACEHOLDER",
      "provider_token": "OPENDOC_SANDBOX_PROVIDER_TOKEN_PLACEHOLDER"
    },
    "fake_fixtures": {
      "patient_ref": "fake_patient_sandbox_001",
      "zip": "30328",
      "service": "MRI without contrast",
      "offer_id": "fake_offer_mri_001",
      "transaction_id": "fake_txn_001"
    },
    "allowed_side_effects": [
      "simulate_only",
      "trace_evaluation"
    ],
    "forbidden_actions": [
      "opendoc/authorize",
      "opendoc/accept_terms",
      "opendoc/commit",
      "opendoc/manage_availability",
      "opendoc/get_receipts",
      "provider_mutation",
      "patient_data_export"
    ],
    "recommended_eval_cases": [
      "eval_find_cheapest_mri_near_zip",
      "eval_book_under_cap",
      "eval_receipt_export_without_consent",
      "eval_spend_cap_exceeded"
    ]
  },
  "sdk_examples": {
    "curl": "curl https://opendoc-owned-bootstrap.vercel.app/.well-known/opendoc-agent.json\ncurl -X POST https://opendoc-owned-bootstrap.vercel.app/mcp \\\n  -H 'content-type: application/json' \\\n  -H 'x-agent-token: OPENDOC_AGENT_TOKEN_PLACEHOLDER' \\\n  -H 'x-idempotency-key: IDEMPOTENCY_KEY_PLACEHOLDER' \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"tools/call\",\"params\":{\"name\":\"opendoc/simulate\",\"arguments\":{\"transaction_id\":\"FAKE_TRANSACTION_ID\"}}}'",
    "javascript": "const base = 'https://opendoc-owned-bootstrap.vercel.app';\nconst discovery = await fetch(`${base}/.well-known/opendoc-agent.json`).then((r) => r.json());\nconst res = await fetch(discovery.remote_mcp, {\n  method: 'POST',\n  headers: {\n    'content-type': 'application/json',\n    'x-agent-token': process.env.OPENDOC_AGENT_TOKEN ?? 'OPENDOC_AGENT_TOKEN_PLACEHOLDER',\n    'x-idempotency-key': crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    jsonrpc: '2.0',\n    id: 'simulate-1',\n    method: 'tools/call',\n    params: {\n      name: 'opendoc/simulate',\n      arguments: { transaction_id: 'FAKE_TRANSACTION_ID' },\n    },\n  }),\n});\nconst result = await res.json();",
    "python": "import os, uuid, requests\nbase = 'https://opendoc-owned-bootstrap.vercel.app'\ndiscovery = requests.get(f'{base}/.well-known/opendoc-agent.json', timeout=10).json()\npayload = {\n    'jsonrpc': '2.0',\n    'id': 'simulate-1',\n    'method': 'tools/call',\n    'params': {\n        'name': 'opendoc/simulate',\n        'arguments': {'transaction_id': 'FAKE_TRANSACTION_ID'},\n    },\n}\nheaders = {\n    'content-type': 'application/json',\n    'x-agent-token': os.getenv('OPENDOC_AGENT_TOKEN', 'OPENDOC_AGENT_TOKEN_PLACEHOLDER'),\n    'x-idempotency-key': str(uuid.uuid4()),\n}\nresult = requests.post(discovery['remote_mcp'], json=payload, headers=headers, timeout=30).json()"
  },
  "structured_errors": [
    {
      "code": "missing_scope",
      "meaning": "The token lacks the exact permission needed for the requested tool.",
      "retryable": false,
      "safe_next_action": "Ask the patient or provider for a narrower token with only the missing scope.",
      "escalation_queue": "patient_confirmation_queue",
      "related_evals": [
        "eval_book_under_cap"
      ]
    },
    {
      "code": "needs_patient_confirmation",
      "meaning": "The action changes consent, spends money, commits an appointment, or exports data without sufficient pre-approval.",
      "retryable": false,
      "safe_next_action": "Pause and route a safe summary for explicit confirmation.",
      "escalation_queue": "patient_confirmation_queue",
      "related_evals": [
        "eval_consent_change_requires_confirmation",
        "eval_book_under_cap"
      ]
    },
    {
      "code": "availability_stale",
      "meaning": "The selected availability window passed its freshness boundary or was superseded.",
      "retryable": true,
      "safe_next_action": "Refresh availability, re-simulate, and continue only with a fresh slot.",
      "escalation_queue": "provider_availability_conflict_queue",
      "related_evals": [
        "eval_commit_stale_availability_slot"
      ]
    },
    {
      "code": "spend_cap_exceeded",
      "meaning": "The simulated obligation is higher than the user cap or delegated token cap.",
      "retryable": false,
      "safe_next_action": "Stop before authorize or commit, then search for a lower-cost alternative or ask the patient to approve a new cap.",
      "escalation_queue": "patient_confirmation_queue",
      "related_evals": [
        "eval_spend_cap_exceeded"
      ]
    },
    {
      "code": "receipt_consent_missing",
      "meaning": "Receipt export or insurance-ready receipt access is blocked by missing consent or insufficient data tier.",
      "retryable": false,
      "safe_next_action": "Show the consent gap and request explicit consent before any export.",
      "escalation_queue": "consent_blocked_queue",
      "related_evals": [
        "eval_receipt_export_without_consent"
      ]
    },
    {
      "code": "human_review_required",
      "meaning": "The contract requires a human because the action is irreversible, disputed, policy-conflicting, or outside delegated authority.",
      "retryable": false,
      "safe_next_action": "Create a review queue item with redacted context and stop autonomous execution.",
      "escalation_queue": "staff_review_queue",
      "related_evals": [
        "eval_cancel_after_policy_window"
      ]
    },
    {
      "code": "stale_price_lock",
      "meaning": "A price lock expired or no longer matches current transaction terms.",
      "retryable": true,
      "safe_next_action": "Re-run simulate and authorize before any commit attempt.",
      "escalation_queue": "patient_confirmation_queue",
      "related_evals": [
        "eval_book_under_cap"
      ]
    },
    {
      "code": "signature_verification_failed",
      "meaning": "A price lock or receipt signature could not be verified against current JWKS.",
      "retryable": true,
      "safe_next_action": "Refresh JWKS once, verify again, then escalate if the signature still fails.",
      "escalation_queue": "staff_review_queue",
      "related_evals": [
        "eval_book_under_cap"
      ]
    },
    {
      "code": "provider_authority_missing",
      "meaning": "A provider-scoped tool was called without a valid provider token.",
      "retryable": false,
      "safe_next_action": "Request provider authority for the specific provider or SCP and do not mutate supply.",
      "escalation_queue": "staff_review_queue",
      "related_evals": [
        "eval_commit_stale_availability_slot"
      ]
    },
    {
      "code": "forbidden_parent_token_share",
      "meaning": "An outside assistant attempted to share a parent token or Health Key with a specialist sub-agent.",
      "retryable": false,
      "safe_next_action": "Block delegation and use opendoc/mint_child_token with narrower permissions, spend cap, expiry, and data tier.",
      "escalation_queue": "patient_confirmation_queue",
      "related_evals": [
        "eval_child_token_attenuation"
      ]
    },
    {
      "code": "sandbox_commit_forbidden",
      "meaning": "A sandbox or public-only agent attempted a real commit, receipt export, or provider mutation.",
      "retryable": false,
      "safe_next_action": "Return a simulated result or blocked-action reason; never create real side effects.",
      "escalation_queue": "staff_review_queue",
      "related_evals": [
        "eval_book_under_cap",
        "eval_spend_cap_exceeded"
      ]
    }
  ],
  "async_interaction_model": {
    "supported_pattern": "job_status_plus_webhook_reference_payloads",
    "job_states": [
      "queued",
      "running",
      "waiting_for_human",
      "waiting_for_provider",
      "blocked",
      "completed",
      "failed",
      "cancelled"
    ],
    "polling": {
      "preferred_tool": "opendoc/get_transaction",
      "interval_seconds": 15,
      "max_interval_seconds": 120,
      "stop_polling_when": [
        "completed",
        "failed",
        "cancelled",
        "waiting_for_human"
      ]
    },
    "webhooks": {
      "payload_boundary": "Events carry state, reason codes, and entity references only; fetch details through authenticated tools.",
      "required_fields": [
        "event_id",
        "event_type",
        "trace_id",
        "transaction_id",
        "entity_ref",
        "state",
        "reason_code",
        "occurred_at",
        "signature"
      ],
      "forbidden_fields": [
        "diagnosis",
        "clinical_notes",
        "receipt_body",
        "full_health_key",
        "full_agent_token"
      ],
      "retry_policy": "Retry webhook delivery with backoff; agents must de-duplicate by event_id."
    }
  },
  "implementation_checklist": [
    "Fetch discovery and readiness contracts before tool calls.",
    "Select the narrowest workflow agent card for the user goal.",
    "Use public search and compare before requesting authority.",
    "Simulate every consequential action before authorize, accept_terms, commit, cancel, or receipt export.",
    "Use idempotency keys for write actions and retries.",
    "Verify signed price locks and receipts against JWKS.",
    "Map protocol errors to structured safe next actions.",
    "Delegate only through attenuated child tokens.",
    "Run the partner control-plane gate before issuing production pilot credentials.",
    "Run the partner pilot runtime gate before any limited-production partner approval.",
    "Run the pilot operations gate before expanding partner pilots.",
    "Run the pilot execution gate before a live partner walkthrough.",
    "Run the partner certification gate before launching a real outside assistant.",
    "Run the partner pilot ops gate before expanding a certified assistant into day-to-day pilot operations.",
    "Run the real partner launch gate before giving one outside assistant production-limited access.",
    "Run the first partner activation gate before a real partner receives the activation handoff pack.",
    "Run the production partner operations gate before expanding any live partner pilot.",
    "Run the production autonomy and trust gate before increasing agent autonomy.",
    "Run the reliability live-ops gate before expanding a partner beyond a controlled pilot.",
    "Run the certification marketplace gate before listing or badging a partner agent.",
    "Run the agent trust-center gate before expanding autonomy or sharing consent evidence outside OpenDoc.",
    "Run the partner pilot packet before production review.",
    "Run trajectory evals before expanding autonomy.",
    "Gate production deploys with npm run agent:ci.",
    "Inspect audit replay before granting production access."
  ]
}
