{
  "contract_id": "d15-extraction-evidence-contract",
  "version": "2026-09-10.1",
  "status": "verified_on_fixtures",
  "implementation_started": false,
  "purpose": "Normalize one permitted article read into ArticleSnapshot and immutable EvidenceEnvelope.",
  "boundaries": {
    "public_read_only": true,
    "captcha_bypass": false,
    "paywall_bypass": false,
    "credentials_in_evidence": false,
    "binary_media_saved": false,
    "mass_collection": false,
    "production_worker_changed": false
  },
  "pipeline": ["can_handle", "canonicalize", "scope_robots_rate_gate", "fetch", "extract", "extract_media", "normalize", "emit_evidence"],
  "adapters": {
    "primary_text_meta": "Trafilatura",
    "bounded_discovery": "Scrapy",
    "public_js_fallback": "Playwright",
    "mathcast_owned": ["scope", "rate_gate", "provenance", "unknown_semantics", "sanitization", "evidence", "registry_handoff"]
  },
  "snapshot_fields": {
    "identity": ["snapshot_id", "run_id", "resource_id", "article_id", "revision_id"],
    "urls": ["origin_url", "final_url", "canonical_url"],
    "capture": ["fetched_at", "status", "http_status", "content_type", "bytes", "encoding", "raw_hash", "rendered_hash"],
    "article": ["title", "author", "published_at", "body_text", "body_html", "headings", "links", "images", "public_signals", "language", "warnings"]
  },
  "value_states": ["observed", "unknown", "no_access", "not_tested", "not_applicable"],
  "statuses": ["COMPLETE", "PARTIAL", "UNKNOWN", "NO_ACCESS", "BLOCKED", "UNSUPPORTED"],
  "evidence_required": ["evidence_id", "run_id", "article_id", "revision_id", "resource_id", "origin_url", "final_url", "method", "status", "content_type", "bytes", "captured_at", "raw_storage_ref", "raw_hash", "adapter", "adapter_version", "parser", "parser_version", "warnings"],
  "derived_data": ["body_html", "body_text", "normalized_metadata", "headings", "links", "image_manifest"],
  "immutable_data": ["raw_response", "raw_hash", "capture_context", "evidence_envelope"],
  "sanitization": {
    "remove": ["script", "style", "form", "event_handlers", "javascript_urls", "unsafe_attributes"],
    "raw_html_is_executable": false,
    "derived_html_can_be_edited": false,
    "edit_creates_new_revision": true
  },
  "fixtures": [
    {"name": "static_html", "source": "https://example.com/", "expected": ["decode", "title", "canonical"]},
    {"name": "makezine_js_article", "expected": ["public_render_fallback", "body", "metadata"]},
    {"name": "hackaday_article", "expected": ["template", "metadata_fallback"]},
    {"name": "short_missing_fields", "expected": ["PARTIAL", "UNKNOWN", "no_invention"]},
    {"name": "malformed_encoding", "expected": ["warning", "explicit_encoding_state"]},
    {"name": "truncated_or_oversized", "expected": ["controlled_partial_or_blocked"]},
    {"name": "redirect_private_target", "expected": ["scope_denial", "no_ssrf"]},
    {"name": "hostile_html", "expected": ["sanitization", "no_executable_payload"]}
  ],
  "checks": ["schema_validation", "content_hash", "encoding", "canonicalization", "field_provenance", "warning_completeness", "sanitization", "partial_semantics", "immutable_raw_reference", "credential_absence"],
  "rollback": "Use previous approved adapter version; never overwrite snapshots/evidence; retry under a new run_id and revision_id.",
  "verification_note": "D11 spike evidence: Trafilatura 6/6, Scrapy parser mapping 3/3, Playwright 6/6; rendered JS hash may vary and capture context must be retained.",
  "links": ["/docs/d15-writter-plan.html", "/docs/d11-pilot-adapters.md", "/docs/d11-data-contract.md", "/docs/d11-finalists-spike.md", "/docs/d15-github-reuse-review.html"]
}
