{
  "schema_version": "0.1.0",
  "name": "K-Work Trust",
  "description": "Agent Trust Contract Kit for AI agents that need to decide whether an external API is safe, ready, and precise enough to call. K-Work Trust is the first live verification pack for Korean vendor, invoice, payment, CRM, ecommerce, and technical assurance workflows.",
  "product_family": "Agent Trust Contract Kit",
  "trust_contract_checker": {
    "endpoint": "https://k-work-trust-api.fly.dev/v1/agent-trust/check",
    "sample_report_url": "https://k-work-trust-api.fly.dev/v1/agent-trust/sample-report",
    "auth_required": true,
    "purpose": "Score another service's agent-facing discovery contract across health, manifest, readiness, OpenAPI, skill, failure modes, auth, onboarding, and first-safe-call guidance.",
    "remote_fetch_policy": "Fetches only fixed public discovery paths, blocks localhost/private addresses by default, uses short timeouts, and never sends caller credentials to the target service."
  },
  "audience": [
    "autonomous agents",
    "agent builders",
    "bot operators",
    "workflow automation systems"
  ],
  "base_url": "https://k-work-trust-api.fly.dev",
  "status_url": "https://k-work-trust-api.fly.dev/health",
  "preferred_discovery_url": "https://k-work-trust-api.fly.dev/.well-known/service.json",
  "canonical_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/k-work-trust-agent.json",
  "service_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/service.json",
  "generic_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/service.json",
  "agent_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/agent.json",
  "agent_trust_contract_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/agent-trust-contract.json",
  "agent_trust_contract_markdown_url": "https://k-work-trust-api.fly.dev/agent-trust-contract.md",
  "directory_listing_url": "https://k-work-trust-api.fly.dev/.well-known/agent-directory.json",
  "ai_plugin_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/ai-plugin.json",
  "mcp_manifest_url": "https://k-work-trust-api.fly.dev/.well-known/mcp.json",
  "readiness_url": "https://k-work-trust-api.fly.dev/v1/agent/readiness",
  "runtime_errors_url": "https://k-work-trust-api.fly.dev/v1/agent/runtime/errors",
  "openapi_url": "https://k-work-trust-api.fly.dev/openapi.json",
  "skill_url": "https://k-work-trust-api.fly.dev/skill.md",
  "llms_txt_url": "https://k-work-trust-api.fly.dev/llms.txt",
  "discovery_urls": {
    "preferred_manifest": "https://k-work-trust-api.fly.dev/.well-known/service.json",
    "service_manifest": "https://k-work-trust-api.fly.dev/.well-known/service.json",
    "agent_manifest": "https://k-work-trust-api.fly.dev/.well-known/agent.json",
    "trust_contract_manifest": "https://k-work-trust-api.fly.dev/.well-known/agent-trust-contract.json",
    "canonical_kwt_manifest": "https://k-work-trust-api.fly.dev/.well-known/k-work-trust-agent.json",
    "legacy_agent_manifest": "https://k-work-trust-api.fly.dev/agent.json",
    "api_manifest": "https://k-work-trust-api.fly.dev/v1/agent/discovery",
    "directory_listing": "https://k-work-trust-api.fly.dev/.well-known/agent-directory.json",
    "directory_json": "https://k-work-trust-api.fly.dev/directory.json",
    "directory_markdown": "https://k-work-trust-api.fly.dev/directory.md",
    "ai_plugin_manifest": "https://k-work-trust-api.fly.dev/.well-known/ai-plugin.json",
    "mcp_manifest": "https://k-work-trust-api.fly.dev/.well-known/mcp.json",
    "openapi": "https://k-work-trust-api.fly.dev/openapi.json",
    "well_known_openapi": "https://k-work-trust-api.fly.dev/.well-known/openapi.json",
    "trust_contract_markdown": "https://k-work-trust-api.fly.dev/agent-trust-contract.md",
    "llms_txt": "https://k-work-trust-api.fly.dev/llms.txt",
    "well_known_llms_txt": "https://k-work-trust-api.fly.dev/.well-known/llms.txt",
    "skill": "https://k-work-trust-api.fly.dev/skill.md",
    "readiness": "https://k-work-trust-api.fly.dev/v1/agent/readiness",
    "runtime_errors": "https://k-work-trust-api.fly.dev/v1/agent/runtime/errors",
    "sample_report": "https://k-work-trust-api.fly.dev/v1/agent-trust/sample-report",
    "signup_status": "https://k-work-trust-api.fly.dev/v1/agent/signup/status",
    "mcp": "https://k-work-trust-api.fly.dev/mcp",
    "robots_txt": "https://k-work-trust-api.fly.dev/robots.txt",
    "sitemap_xml": "https://k-work-trust-api.fly.dev/sitemap.xml",
    "canonical_manifest": "https://k-work-trust-api.fly.dev/.well-known/k-work-trust-agent.json",
    "generic_manifest": "https://k-work-trust-api.fly.dev/.well-known/service.json",
    "agent_manifest_alias": "https://k-work-trust-api.fly.dev/.well-known/agent.json"
  },
  "mcp_url": "https://k-work-trust-api.fly.dev/mcp",
  "mcp": {
    "transport": "streamable-http",
    "url": "https://k-work-trust-api.fly.dev/mcp",
    "auth": {
      "type": "bearer",
      "header": "Authorization: Bearer <kwt_api_key>",
      "required_for": [
        "tools/call"
      ],
      "not_required_for": [
        "initialize",
        "tools/list"
      ]
    },
    "supports": [
      "initialize",
      "tools/list",
      "tools/call"
    ],
    "sse_streams_enabled": false,
    "quota_policy": "tools/call consumes monthly request quota; initialize and tools/list do not."
  },
  "authenticated_session_url": "https://k-work-trust-api.fly.dev/v1/auth/whoami",
  "auth": {
    "type": "bearer",
    "header": "Authorization: Bearer <kwt_api_key>",
    "key_prefix": "kwt_"
  },
  "self_serve_signup": {
    "enabled": true,
    "mode": "provisional_key_or_email_verification_with_sha256_proof_of_work",
    "status_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/status",
    "proof_of_work": {
      "algorithm": "sha256",
      "digest_encoding": "hex",
      "input_template": "${nonce}:${subject}:${solution}",
      "difficulty_rule": "The hex digest must start with '0' repeated difficulty_hex_prefix_zeros times.",
      "solution_field": "proof.solution",
      "challenge_field": "proof.challenge",
      "max_solution_length": 160,
      "challenge_ttl_seconds": 300,
      "email_signup_difficulty_hex_prefix_zeros": 4,
      "provisional_signup_difficulty_hex_prefix_zeros": 4
    },
    "provisional": {
      "description": "For agents without an inbox. Issues an ultra-low-quota key after proof-of-work only.",
      "challenge_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/provisional/challenge?agent_label=<agent-label>",
      "issue_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/provisional",
      "proof_subject": "The returned subject from the challenge response, derived from agent_label, agent_id, or agent_url.",
      "default_quota": {
        "rate_limit_rpm": 1,
        "monthly_request_quota": 20
      },
      "official_sources": "disabled_by_default_until_email_verified_or_human_approved",
      "upgrade_request_code_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/provisional/upgrade/request-code",
      "upgrade_verify_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/provisional/upgrade/verify"
    },
    "email_verified": {
      "description": "For agents or operators with an inbox. Issues or upgrades to a higher low-quota key.",
      "challenge_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/challenge?email=<agent-or-operator-email>",
      "request_code_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/request-code",
      "verify_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/verify",
      "proof_subject": "The normalized email returned from the challenge response."
    },
    "challenge_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/challenge?email=<agent-or-operator-email>",
    "request_code_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/request-code",
    "verify_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/signup/verify",
    "key_visibility": "The plaintext API key is returned once after verification."
  },
  "recommended_first_call": {
    "method": "POST",
    "path": "/v1/vendor-onboarding/validate",
    "description": "Use before an agent registers a Korean vendor or customer, updates CRM, prepares invoice data, or touches ecommerce business records.",
    "body_example": {
      "company_name": "Test Company",
      "registration_number": "1234567891",
      "phone_number": "01012345678"
    },
    "response_contract": {
      "profile_id": "agent-trust-contract-kit.discovery.v1",
      "success_fields": [
        "request_id",
        "tool",
        "result.status",
        "result.decision",
        "result.blocking_issues",
        "result.warnings",
        "result.evidence",
        "result.agent_next_action"
      ],
      "decision_meanings": {
        "register_vendor": "Proceed only with normalized_record and retained evidence.",
        "request_human_review": "Pause downstream writes and route warnings/evidence to a human reviewer.",
        "do_not_proceed": "Abort downstream workflow until blocking_issues are corrected."
      },
      "failure_mode_field": "failure_modes",
      "runtime_contract_field": "runtime_contract",
      "escalation_contract": "Use failure_modes to choose retry, abort, or human/operator escalation without guessing from HTTP status alone.",
      "portable_fields": [
        "request_id",
        "status",
        "decision",
        "warnings",
        "blocking_issues",
        "evidence",
        "agent_next_action",
        "failure_modes"
      ],
      "domain_extensions": [
        "normalized_record",
        "official_business_status",
        "official_address",
        "official_ftc_ecommerce_registration",
        "official_dart_disclosures",
        "official_opensanctions_screening",
        "human_review_packet"
      ]
    }
  },
  "trust_contract_profiles": [
    {
      "id": "agent-trust-contract-kit.discovery.v1",
      "status": "implemented",
      "scope": "portable",
      "purpose": "A small machine-readable profile that lets agents decide whether an API is discoverable, authenticated, quota-aware, and safe to call before parsing domain-specific fields.",
      "required_public_surfaces": [
        "/health",
        "/.well-known/k-work-trust-agent.json",
        "/v1/agent/readiness",
        "/openapi.json",
        "/skill.md"
      ],
      "required_contract_fields": [
        "base_url",
        "auth",
        "response_contract",
        "failure_modes",
        "runtime_contract",
        "max_payload_size",
        "recommended_first_call",
        "safe_test_payloads"
      ],
      "caller_decisions_supported": [
        "discovery_only",
        "verify_key",
        "make_first_safe_call",
        "retry_after_limit",
        "abort_invalid_auth",
        "escalate_for_human_review",
        "stop_when_payload_exceeds_declared_limit",
        "continue_local_only_when_source_unavailable"
      ],
      "extension_rule": "Portable fields describe how an agent should call and recover. Domain extensions may add business-specific evidence, but must not change the meaning of portable fields."
    },
    {
      "id": "k-work-trust.kyb-workflow.v1",
      "status": "implemented",
      "scope": "domain_extension",
      "extends": "agent-trust-contract-kit.discovery.v1",
      "purpose": "Korean vendor, invoice, payment, CRM, ecommerce, agent-action, technical-due-diligence, advanced technical-assurance, and Agent Trust Compiler gates layered on top of the portable agent discovery contract.",
      "domain_evidence_fields": [
        "normalized_record",
        "official_business_status",
        "official_address",
        "official_ftc_ecommerce_registration",
        "official_dart_disclosures",
        "official_opensanctions_screening",
        "official_companies_house_company",
        "document_cross_check",
        "technical_due_diligence_ready",
        "supply_chain_ready",
        "secret_flow_safe",
        "contract_drift_safe",
        "policy_invariants_ready",
        "fuzzing_ready",
        "trust_compiler_ready",
        "open_world_certificate_ready",
        "safe_use_boundary",
        "asset_profile",
        "provenance_profile",
        "flow_profile",
        "contract_profile",
        "policy_profile",
        "fuzz_profile",
        "mathematical_model",
        "action_graph",
        "temporal_model_check",
        "risk_bound",
        "tail_risk",
        "evidence_quality_ready",
        "quality_score",
        "autonomy_budget",
        "trust_certificate",
        "assumption_ledger",
        "open_world_unknowns",
        "monitors",
        "counterexamples",
        "human_review_packet"
      ],
      "compatibility_rule": "Agents that do not understand this domain profile can still use the portable discovery profile to stop, retry, or escalate safely."
    }
  ],
  "response_contract": {
    "profile_id": "agent-trust-contract-kit.discovery.v1",
    "success_fields": [
      "request_id",
      "tool",
      "result.status",
      "result.decision",
      "result.blocking_issues",
      "result.warnings",
      "result.evidence",
      "result.agent_next_action"
    ],
    "decision_meanings": {
      "register_vendor": "Proceed only with normalized_record and retained evidence.",
      "request_human_review": "Pause downstream writes and route warnings/evidence to a human reviewer.",
      "do_not_proceed": "Abort downstream workflow until blocking_issues are corrected."
    },
    "failure_mode_field": "failure_modes",
    "runtime_contract_field": "runtime_contract",
    "escalation_contract": "Use failure_modes to choose retry, abort, or human/operator escalation without guessing from HTTP status alone.",
    "portable_fields": [
      "request_id",
      "status",
      "decision",
      "warnings",
      "blocking_issues",
      "evidence",
      "agent_next_action",
      "failure_modes"
    ],
    "domain_extensions": [
      "normalized_record",
      "official_business_status",
      "official_address",
      "official_ftc_ecommerce_registration",
      "official_dart_disclosures",
      "official_opensanctions_screening",
      "human_review_packet"
    ]
  },
  "runtime_contract": {
    "schema_version": "agent-runtime-contract/v1",
    "errors_endpoint": "https://k-work-trust-api.fly.dev/v1/agent/runtime/errors",
    "max_payload_size": {
      "request_body_bytes": 1000000,
      "response_body_bytes": 1000000,
      "tool_result_bytes": 1000000,
      "agent_trust_fetch_bytes": 200000,
      "unit": "bytes"
    },
    "payload_size_policy": "Before the first mutating or high-volume call, compare expected request, response, and tool-result size against max_payload_size. If the payload may exceed the ceiling, request a smaller projection/page, use a narrower endpoint, or abort and escalate with request_id.",
    "http_status_routing": {
      "401": "abort_and_verify_key",
      "403": "abort_or_correct_policy_violation",
      "410": "remove_capability_until_manifest_refresh",
      "422": "correct_input_before_retry",
      "429": "backoff_or_stop_until_quota_reset",
      "500": "escalate_with_request_id",
      "503": "retry_with_backoff_then_escalate"
    },
    "required_public_error_fields": [
      "request_id",
      "error.code",
      "error.message",
      "error.failure_mode",
      "error.retry",
      "error.agent_next_action",
      "error.escalation"
    ],
    "failure_modes": [
      {
        "code": "UNAUTHORIZED",
        "applies_to": [
          "authenticated_api",
          "whoami"
        ],
        "http_status": 401,
        "category": "auth_failure",
        "retry": "do_not_retry_same_key",
        "agent_next_action": "Abort the protected call, verify the key with /v1/auth/whoami, and obtain a valid key through self-serve signup or the operator.",
        "escalation": "human_or_operator_if_the_agent_expected_this_key_to_be_active",
        "safe_to_log": [
          "request_id",
          "error.code"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "RATE_LIMITED",
        "applies_to": [
          "authenticated_api",
          "signup"
        ],
        "http_status": 429,
        "category": "temporary_limit",
        "retry": "retry_after_retry_after_seconds",
        "agent_next_action": "Wait for retry_after_seconds before retrying. If the workflow is urgent or repeated rate limits occur, escalate instead of looping.",
        "escalation": "human_review_or_alternative_route_for_time_sensitive_workflows",
        "safe_to_log": [
          "request_id",
          "error.code",
          "retry_after_seconds"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "QUOTA_EXCEEDED",
        "applies_to": [
          "authenticated_api"
        ],
        "http_status": 429,
        "category": "quota_exhausted",
        "retry": "do_not_retry_until_resets_at",
        "agent_next_action": "Stop automated calls for this key until resets_at or ask an operator for review. Do not request a manual key in public channels.",
        "escalation": "operator_review_required_for_quota_change",
        "safe_to_log": [
          "request_id",
          "error.code",
          "quota.limit",
          "quota.used",
          "quota.resets_at"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "VALIDATION_BLOCKED",
        "applies_to": [
          "workflow_response"
        ],
        "http_status": 200,
        "category": "business_rule_block",
        "retry": "retry_only_after_correcting_input",
        "agent_next_action": "Do not proceed with the workflow action. Preserve blocking_issues and evidence, then collect corrected fields or ask a human reviewer.",
        "escalation": "human_review_if_the_record_is_business_critical",
        "safe_to_log": [
          "request_id",
          "status",
          "decision",
          "blocking_issues",
          "warnings"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "MANUAL_REVIEW",
        "applies_to": [
          "workflow_response"
        ],
        "http_status": 200,
        "category": "needs_human_judgment",
        "retry": "do_not_auto_retry_without_new_information",
        "agent_next_action": "Route the normalized record, warnings, and evidence to a human reviewer before creating or updating downstream records.",
        "escalation": "human_review_required_before_downstream_write",
        "safe_to_log": [
          "request_id",
          "status",
          "decision",
          "warnings",
          "evidence"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "SOURCE_UNAVAILABLE",
        "applies_to": [
          "workflow_response",
          "official_sources"
        ],
        "http_status": 200,
        "category": "external_source_unavailable",
        "retry": "retry_later_or_continue_local_only_if_policy_allows",
        "agent_next_action": "Use local validation only when acceptable. If official-source evidence is required, pause the workflow and escalate with request_id and evidence.",
        "escalation": "human_or_operator_if_official_source_evidence_is_required",
        "safe_to_log": [
          "request_id",
          "external_status",
          "warnings",
          "evidence"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "PROOF_OF_WORK_FAILED",
        "applies_to": [
          "signup"
        ],
        "http_status": 403,
        "category": "signup_challenge_failure",
        "retry": "request_fresh_challenge_and_solve_contract",
        "agent_next_action": "Request a fresh challenge, solve sha256(nonce + ':' + subject + ':' + solution), and avoid repeated blind retries.",
        "escalation": "only_if_repeated_failures_indicate_onboarding_blocker",
        "safe_to_log": [
          "request_id",
          "error.code"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "SIGNUP_RATE_LIMITED",
        "applies_to": [
          "signup"
        ],
        "http_status": 429,
        "category": "signup_limit",
        "retry": "wait_before_requesting_another_challenge_or_mutation",
        "agent_next_action": "Wait before continuing signup. Do not ask for a pasted plaintext key; use the self-serve flow after the limit resets.",
        "escalation": "operator_review_only_for_repeated_legitimate_tester_blockers",
        "safe_to_log": [
          "request_id",
          "error.code"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      },
      {
        "code": "ABUSE_GUARD_BLOCKED",
        "applies_to": [
          "authenticated_api",
          "workflow_request"
        ],
        "http_status": 403,
        "category": "misuse_or_sensitive_input_guard",
        "retry": "do_not_retry_same_payload",
        "agent_next_action": "Stop the request. Remove secrets, sensitive personal identifiers, bulk records, or enumeration-like input before retrying with one synthetic or authorized business record.",
        "escalation": "operator_review_if_the_agent_believes_the_block_is_false_positive",
        "safe_to_log": [
          "request_id",
          "error.code",
          "abuse.reason"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets",
          "personal_identifiers"
        ]
      },
      {
        "code": "CAPABILITY_REMOVED",
        "applies_to": [
          "discovery",
          "agent_routing",
          "authenticated_api"
        ],
        "http_status": 410,
        "category": "capability_no_longer_available",
        "retry": "remove_capability_until_manifest_refresh",
        "agent_next_action": "Remove this capability from the routing cache, refresh the manifest/readiness/runtime contract, and do not call the removed path again unless a newer contract advertises it.",
        "escalation": "human_or_operator_if_a_live_workflow_depends_on_the_removed_capability",
        "safe_to_log": [
          "request_id",
          "error.code",
          "path",
          "replacement_endpoint"
        ],
        "do_not_log": [
          "plaintext_api_key",
          "private_records",
          "secrets"
        ]
      }
    ]
  },
  "failure_modes": [
    {
      "code": "UNAUTHORIZED",
      "applies_to": [
        "authenticated_api",
        "whoami"
      ],
      "http_status": 401,
      "category": "auth_failure",
      "retry": "do_not_retry_same_key",
      "agent_next_action": "Abort the protected call, verify the key with /v1/auth/whoami, and obtain a valid key through self-serve signup or the operator.",
      "escalation": "human_or_operator_if_the_agent_expected_this_key_to_be_active",
      "safe_to_log": [
        "request_id",
        "error.code"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "RATE_LIMITED",
      "applies_to": [
        "authenticated_api",
        "signup"
      ],
      "http_status": 429,
      "category": "temporary_limit",
      "retry": "retry_after_retry_after_seconds",
      "agent_next_action": "Wait for retry_after_seconds before retrying. If the workflow is urgent or repeated rate limits occur, escalate instead of looping.",
      "escalation": "human_review_or_alternative_route_for_time_sensitive_workflows",
      "safe_to_log": [
        "request_id",
        "error.code",
        "retry_after_seconds"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "QUOTA_EXCEEDED",
      "applies_to": [
        "authenticated_api"
      ],
      "http_status": 429,
      "category": "quota_exhausted",
      "retry": "do_not_retry_until_resets_at",
      "agent_next_action": "Stop automated calls for this key until resets_at or ask an operator for review. Do not request a manual key in public channels.",
      "escalation": "operator_review_required_for_quota_change",
      "safe_to_log": [
        "request_id",
        "error.code",
        "quota.limit",
        "quota.used",
        "quota.resets_at"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "VALIDATION_BLOCKED",
      "applies_to": [
        "workflow_response"
      ],
      "http_status": 200,
      "category": "business_rule_block",
      "retry": "retry_only_after_correcting_input",
      "agent_next_action": "Do not proceed with the workflow action. Preserve blocking_issues and evidence, then collect corrected fields or ask a human reviewer.",
      "escalation": "human_review_if_the_record_is_business_critical",
      "safe_to_log": [
        "request_id",
        "status",
        "decision",
        "blocking_issues",
        "warnings"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "MANUAL_REVIEW",
      "applies_to": [
        "workflow_response"
      ],
      "http_status": 200,
      "category": "needs_human_judgment",
      "retry": "do_not_auto_retry_without_new_information",
      "agent_next_action": "Route the normalized record, warnings, and evidence to a human reviewer before creating or updating downstream records.",
      "escalation": "human_review_required_before_downstream_write",
      "safe_to_log": [
        "request_id",
        "status",
        "decision",
        "warnings",
        "evidence"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "SOURCE_UNAVAILABLE",
      "applies_to": [
        "workflow_response",
        "official_sources"
      ],
      "http_status": 200,
      "category": "external_source_unavailable",
      "retry": "retry_later_or_continue_local_only_if_policy_allows",
      "agent_next_action": "Use local validation only when acceptable. If official-source evidence is required, pause the workflow and escalate with request_id and evidence.",
      "escalation": "human_or_operator_if_official_source_evidence_is_required",
      "safe_to_log": [
        "request_id",
        "external_status",
        "warnings",
        "evidence"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "PROOF_OF_WORK_FAILED",
      "applies_to": [
        "signup"
      ],
      "http_status": 403,
      "category": "signup_challenge_failure",
      "retry": "request_fresh_challenge_and_solve_contract",
      "agent_next_action": "Request a fresh challenge, solve sha256(nonce + ':' + subject + ':' + solution), and avoid repeated blind retries.",
      "escalation": "only_if_repeated_failures_indicate_onboarding_blocker",
      "safe_to_log": [
        "request_id",
        "error.code"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "SIGNUP_RATE_LIMITED",
      "applies_to": [
        "signup"
      ],
      "http_status": 429,
      "category": "signup_limit",
      "retry": "wait_before_requesting_another_challenge_or_mutation",
      "agent_next_action": "Wait before continuing signup. Do not ask for a pasted plaintext key; use the self-serve flow after the limit resets.",
      "escalation": "operator_review_only_for_repeated_legitimate_tester_blockers",
      "safe_to_log": [
        "request_id",
        "error.code"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    },
    {
      "code": "ABUSE_GUARD_BLOCKED",
      "applies_to": [
        "authenticated_api",
        "workflow_request"
      ],
      "http_status": 403,
      "category": "misuse_or_sensitive_input_guard",
      "retry": "do_not_retry_same_payload",
      "agent_next_action": "Stop the request. Remove secrets, sensitive personal identifiers, bulk records, or enumeration-like input before retrying with one synthetic or authorized business record.",
      "escalation": "operator_review_if_the_agent_believes_the_block_is_false_positive",
      "safe_to_log": [
        "request_id",
        "error.code",
        "abuse.reason"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets",
        "personal_identifiers"
      ]
    },
    {
      "code": "CAPABILITY_REMOVED",
      "applies_to": [
        "discovery",
        "agent_routing",
        "authenticated_api"
      ],
      "http_status": 410,
      "category": "capability_no_longer_available",
      "retry": "remove_capability_until_manifest_refresh",
      "agent_next_action": "Remove this capability from the routing cache, refresh the manifest/readiness/runtime contract, and do not call the removed path again unless a newer contract advertises it.",
      "escalation": "human_or_operator_if_a_live_workflow_depends_on_the_removed_capability",
      "safe_to_log": [
        "request_id",
        "error.code",
        "path",
        "replacement_endpoint"
      ],
      "do_not_log": [
        "plaintext_api_key",
        "private_records",
        "secrets"
      ]
    }
  ],
  "abuse_guard": {
    "enabled": true,
    "behavior_based": true,
    "does_not_infer_nationality": true,
    "low_trust_max_records_per_request": 1,
    "low_trust_max_business_number_like_identifiers": 4,
    "blocks": [
      "plaintext API keys or bearer tokens in request bodies",
      "personal identifier patterns such as resident registration or passport fields",
      "bulk or batch payloads from low-trust/provisional keys",
      "many distinct business-number-like identifiers from low-trust/provisional keys"
    ],
    "operator_controls": [
      "KWT_ABUSE_GUARD_ENABLED=false disables the guard temporarily",
      "KWT_REJECT_PROVISIONAL_KEYS=true rejects existing provisional keys",
      "KWT_PROVISIONAL_ALLOW_OFFICIAL_SOURCES=false keeps provisional keys local-only"
    ]
  },
  "safe_test_payloads": {
    "vendor_onboarding": {
      "company_name": "Test Company",
      "registration_number": "1234567891",
      "phone_number": "01012345678"
    },
    "agent_action_firewall": {
      "action_type": "local_docs_update",
      "action_summary": "Update public onboarding docs after tests pass.",
      "environment": "local",
      "data_sensitivity": "public",
      "tests_passed": true,
      "risk_flags": []
    }
  },
  "endpoints": [
    {
      "method": "GET",
      "path": "/.well-known/service.json",
      "auth_required": false,
      "purpose": "Preferred generic service manifest for agents, registries, and crawlers that do not know a product-specific path."
    },
    {
      "method": "GET",
      "path": "/.well-known/agent.json",
      "auth_required": false,
      "purpose": "Agent-specific discovery manifest alias kept for compatibility."
    },
    {
      "method": "GET",
      "path": "/.well-known/agent-trust-contract.json",
      "auth_required": false,
      "purpose": "Agent Trust Contract Kit manifest alias for trust-contract scanners and registries."
    },
    {
      "method": "GET",
      "path": "/.well-known/agent-directory.json",
      "auth_required": false,
      "purpose": "Directory-optimized listing metadata for external agent/API/MCP catalogs."
    },
    {
      "method": "GET",
      "path": "/.well-known/mcp.json",
      "auth_required": false,
      "purpose": "Remote MCP server discovery metadata for catalogs that index MCP endpoints."
    },
    {
      "method": "GET",
      "path": "/.well-known/ai-plugin.json",
      "auth_required": false,
      "purpose": "AI-plugin-style compatibility manifest that points to OpenAPI and safe auth rules."
    },
    {
      "method": "GET",
      "path": "/agent-trust-contract.md",
      "auth_required": false,
      "purpose": "Human-readable contract summary that points agents to manifest, readiness, runtime errors, OpenAPI, skill, and MCP surfaces."
    },
    {
      "method": "GET",
      "path": "/llms.txt",
      "auth_required": false,
      "purpose": "LLM-readable service index with safe-use rules and public discovery links."
    },
    {
      "method": "GET",
      "path": "/robots.txt",
      "auth_required": false,
      "purpose": "Crawler hint that advertises the sitemap for public discovery endpoints."
    },
    {
      "method": "GET",
      "path": "/sitemap.xml",
      "auth_required": false,
      "purpose": "Machine-readable URL inventory for external directories and search crawlers."
    },
    {
      "method": "GET",
      "path": "/v1/agent/runtime/errors",
      "auth_required": false,
      "purpose": "Read retry, abort, escalation, and payload-size limits before an agent retries or sends a large request."
    },
    {
      "method": "GET",
      "path": "/v1/agent-trust/sample-report",
      "auth_required": false,
      "purpose": "Preview a complete agent trust contract report against K-Work Trust's own public discovery contract."
    },
    {
      "method": "GET",
      "path": "/v1/agent/readiness",
      "auth_required": false,
      "purpose": "Check whether the deployment is ready for autonomous or invited agent use."
    },
    {
      "method": "POST",
      "path": "/v1/agent-trust/check",
      "auth_required": true,
      "purpose": "Run a pre-flight trust check against an agent-facing API contract before an agent uses it."
    },
    {
      "method": "GET",
      "path": "/v1/auth/whoami",
      "auth_required": true,
      "purpose": "Verify a key and inspect trust level, quotas, and official-source policy without consuming monthly quota."
    },
    {
      "method": "GET",
      "path": "/v1/tools",
      "auth_required": true,
      "purpose": "List callable tools."
    },
    {
      "method": "POST",
      "path": "/mcp",
      "auth_required": "tools/call only",
      "purpose": "Remote MCP Streamable HTTP endpoint. initialize and tools/list are public; tools/call requires a bearer key."
    },
    {
      "method": "POST",
      "path": "/v1/tools/call",
      "auth_required": true,
      "purpose": "Call a tool dynamically by name."
    },
    {
      "method": "POST",
      "path": "/v1/vendor-onboarding/validate",
      "auth_required": true,
      "purpose": "Return a workflow decision, normalized record, issues, warnings, evidence, and next action."
    },
    {
      "method": "POST",
      "path": "/v1/payment-or-invoice-release/validate",
      "auth_required": true,
      "purpose": "Gate payment, invoice, settlement, or purchase release with amount policy, required fixes, and a human review packet."
    },
    {
      "method": "POST",
      "path": "/v1/document-cross-check/validate",
      "auth_required": true,
      "purpose": "Cross-check vendor, invoice, contract, and bank document fields before downstream workflow writes."
    },
    {
      "method": "POST",
      "path": "/v1/vendor-reverification/validate",
      "auth_required": true,
      "purpose": "Check whether an existing vendor is fresh enough for continued autonomous use or must be reverified."
    },
    {
      "method": "POST",
      "path": "/v1/agent-action-firewall/validate",
      "auth_required": true,
      "purpose": "Check whether a proposed agent action is allowed, needs approval, or must be blocked before execution."
    },
    {
      "method": "POST",
      "path": "/v1/technical-due-diligence/validate",
      "auth_required": true,
      "purpose": "Preflight a repo, API, MCP server, package, SDK, or technical service before an agent uses it."
    },
    {
      "method": "POST",
      "path": "/v1/supply-chain-provenance/validate",
      "auth_required": true,
      "purpose": "Validate provenance, signatures, SBOM, pins, builder trust, and dependency evidence before an agent trusts an artifact."
    },
    {
      "method": "POST",
      "path": "/v1/secret-flow/validate",
      "auth_required": true,
      "purpose": "Validate secret-scan, taint-flow, redaction, secret-manager, prompt, log, and sink evidence before handling credentials."
    },
    {
      "method": "POST",
      "path": "/v1/api-contract-drift/validate",
      "auth_required": true,
      "purpose": "Validate OpenAPI or MCP contract drift, breaking changes, versioning, migration, and client-test evidence before integration."
    },
    {
      "method": "POST",
      "path": "/v1/policy-invariants/validate",
      "auth_required": true,
      "purpose": "Validate policy-as-code or model-check invariants for approval, quota, secrets, paid actions, and safety gates."
    },
    {
      "method": "POST",
      "path": "/v1/agent-endpoint-fuzzing/validate",
      "auth_required": true,
      "purpose": "Validate fuzz and property-test evidence before exposing an agent-facing endpoint to autonomous callers."
    },
    {
      "method": "POST",
      "path": "/v1/agent-plan/compile",
      "auth_required": true,
      "purpose": "Compile an agent plan into a bounded transition model with action graph and normalized actions."
    },
    {
      "method": "POST",
      "path": "/v1/agent-policy-invariants/prove",
      "auth_required": true,
      "purpose": "Check whether policy invariants hold for an agent plan and return failed invariants with counterexamples."
    },
    {
      "method": "POST",
      "path": "/v1/agent-counterexample/find",
      "auth_required": true,
      "purpose": "Find a short unsafe execution trace for an agent plan when a supplied invariant fails."
    },
    {
      "method": "POST",
      "path": "/v1/agent-risk-bound/estimate",
      "auth_required": true,
      "purpose": "Estimate a conservative upper risk bound for an agent plan."
    },
    {
      "method": "POST",
      "path": "/v1/agent-tail-risk/estimate",
      "auth_required": true,
      "purpose": "Estimate dependency-adjusted loss distribution, VaR, and CVaR tail risk for an agent plan."
    },
    {
      "method": "POST",
      "path": "/v1/agent-evidence-quality/score",
      "auth_required": true,
      "purpose": "Score evidence packets with claim coverage, source entropy, freshness, provenance, and contradiction penalties before an agent relies on them."
    },
    {
      "method": "POST",
      "path": "/v1/agent-trust-contracts/compose",
      "auth_required": true,
      "purpose": "Compose multiple service trust contracts into one workflow graph certificate and surface weak services, incompatible edges, and missing first-safe-call boundaries."
    },
    {
      "method": "POST",
      "path": "/v1/autonomy-budget/optimize",
      "auth_required": true,
      "purpose": "Choose allowed, gated, and blocked actions under risk and money budgets."
    },
    {
      "method": "POST",
      "path": "/v1/agent-temporal-safety/model-check",
      "auth_required": true,
      "purpose": "Model-check dependency-respecting execution orders and return temporal counterexamples plus minimal interventions."
    },
    {
      "method": "POST",
      "path": "/v1/agent-trust-certificate/issue",
      "auth_required": true,
      "purpose": "Issue an Agent Trust Compiler certificate with model, proof, counterexamples, risk bound, and autonomy budget."
    },
    {
      "method": "POST",
      "path": "/v1/open-world-trust-certificate/issue",
      "auth_required": true,
      "purpose": "Issue a bounded open-world certificate that composes proof packets, argument provenance, adversarial checks, assumptions, unknowns, and monitors."
    },
    {
      "method": "POST",
      "path": "/v1/open-world-proof-carrying-autonomy/authorize",
      "auth_required": true,
      "purpose": "Authorize end-to-end open-world proof-carrying autonomy with lifecycle phases, runtime monitors, renewal deadlines, revocation triggers, and audit boundaries."
    }
  ],
  "agent_policy": [
    "Use synthetic data, public test data, or records the agent is authorized to process.",
    "Do not treat responses as legal, tax, accounting, or official endorsement advice.",
    "Preserve blocking issues and evidence when escalating to a human.",
    "Do not expose the API key in public prompts, posts, logs, or tool outputs."
  ]
}