mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-10-14 05:20:46 +02:00
The Content Seal manifest named the production GPU worker in its provenance column and in two row keys, several docstrings described their sources as user uploads from the private corpus, and that corpus was called by the storage product holding it. Each is now what a public reader can check: a pipeline and strength, material that is not publication-cleared, and a private corpus. The corpus test follows the renamed rows. Deployment and tier detail goes the same way, since which backend each hosting tier can afford is a product decision, not a library fact. Twelve harnesses that need a cloud GPU account leave scripts/. The research pages that cite their findings name them as harnesses kept outside this repository and stop implying a reader can rerun them; the tracked inputs and recorded verdicts remain the durable record, and the offline analysis step stays here with its test. A development invariant states the rule so the next harness is not added back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
"""Tests for the Content Seal oracle corpus layout.
|
|
|
|
Mirrors the synthid corpus guard: the manifest is the source of truth for
|
|
which binaries exist, and every recorded hash must match the file it names.
|
|
Derived rows are recipes, not stored files, so only originals are checked
|
|
against disk.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import csv
|
|
import hashlib
|
|
import re
|
|
from pathlib import Path
|
|
|
|
CORPUS_DIR = Path(__file__).resolve().parent.parent / "data" / "contentseal"
|
|
MANIFEST = CORPUS_DIR / "manifest.csv"
|
|
ORIGINALS = CORPUS_DIR / "originals"
|
|
|
|
_SHA256 = re.compile(r"^[0-9a-f]{64}$")
|
|
_VALID_VERDICTS = {"detected", "not_detected", ""}
|
|
_VALID_ORIGINS = {"meta-model-api", "derived", "meta-blog-cdn", "synthetic-local"}
|
|
|
|
|
|
def _manifest_rows() -> list[dict[str, str]]:
|
|
with open(MANIFEST, newline="") as f:
|
|
return list(csv.DictReader(f))
|
|
|
|
|
|
def test_manifest_original_rows_match_binaries_and_hashes() -> None:
|
|
rows = [r for r in _manifest_rows() if r["file"]]
|
|
stored = {path.name for path in ORIGINALS.iterdir() if path.is_file()}
|
|
assert {r["file"].removeprefix("originals/") for r in rows} == stored
|
|
|
|
for row in rows:
|
|
digest = hashlib.sha256((CORPUS_DIR / row["file"]).read_bytes()).hexdigest()
|
|
assert digest == row["sha256"], row["file"]
|
|
|
|
|
|
def test_manifest_rows_are_well_formed() -> None:
|
|
rows = _manifest_rows()
|
|
assert len({row["sha256"] for row in rows}) == len(rows), "duplicate sha256"
|
|
|
|
for row in rows:
|
|
assert _SHA256.match(row["sha256"]), row["name"]
|
|
assert row["origin"].split(":")[0] in _VALID_ORIGINS, row["name"]
|
|
assert row["oracle_verdict"] in _VALID_VERDICTS, row["name"]
|
|
# Every oracle verdict must carry its check timestamp.
|
|
if row["oracle_verdict"]:
|
|
assert row["checked_at_utc"], row["name"]
|
|
# Detection rows must name the oracle attribution.
|
|
if row["oracle_verdict"] == "detected":
|
|
assert "Muse Image 1" in row["oracle_attribution"], row["name"]
|
|
|
|
|
|
def test_default_pipeline_clearance_is_recorded() -> None:
|
|
"""The verified claim that the default profile clears Content Seal must stay."""
|
|
rows = {row["name"]: row for row in _manifest_rows()}
|
|
for name in ("fox_default_invisible", "text_default_invisible"):
|
|
assert rows[name]["oracle_verdict"] == "not_detected", name
|
|
|
|
|
|
def test_deterministic_transforms_reproduce_recorded_hashes(tmp_path: Path) -> None:
|
|
from scripts.contentseal_transforms import reproduce_transforms
|
|
|
|
outputs = reproduce_transforms(tmp_path)
|
|
|
|
assert len(outputs) == 8
|
|
assert all(path.is_file() for path in outputs)
|