Datasets:
File size: 6,371 Bytes
77e5321 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | #!/usr/bin/env python3
"""Self-check for src/verify_paper_claims.py against a synthetic mini-repo."""
import json
import shutil
import sys
import tempfile
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import verify_paper_claims as vpc # noqa: E402
TEX = r"""
\begin{figure}
\addplot[thick] coordinates {(v0.1.0,1.00)(v0.1.1,3.00)};
\caption{grew from 1.00 billion tokens and 1 sources (v0.1.0).}
\end{figure}
\begin{abstract}
Release v0.1.1 comprises \num{300} documents and \num{3.00}~billion tokens
from 2 sources.
\end{abstract}
\begin{table}
\begin{tabular}{lrr}
Version & Tokens (billions) & Sources \\
v0.1.0 & 1.00 & 1 \\
v0.1.1 & 3.00 & 2 \\
\end{tabular}
\label{tab:s04-wersje}
\end{table}
\begin{table}
\label{tab:s05-zrodla}
\begin{tabular}{llr}
Source & License & Tokens [M] \\
\texttt{alpha} & CC0 & 2000.0 \\
\texttt{beta\_two} & CC-BY-SA-4.0 & 1000.0 \\
\textbf{Total} & CC-BY-SA-4.0 & \textbf{$\approx$3000} \\
\end{tabular}
\end{table}
\begin{table}
\label{tab:s10-licencje}
\begin{tabular}{llr}
License family & Representative sources & Tokens [billions] \\
CC0 & alpha & $2.00$ \\
CC-BY-SA & beta two & $1.00$ \\
Total & & $3.00$ \\
\end{tabular}
\end{table}
This work is pinned to commit \texttt{deadbeef}.
"""
CHANGELOG = """# Changelog
## v0.1.1 (2026-01-02)
- Added `beta_two`.
- Totals: 2 sources, 300 docs, 3.00B tokens.
"""
README = "| `v0.1.0` | previous stable | 100 | 1.00B | Baseline from 1 open/official sources. |\n"
GROWTH = """VERSIONS = ["v0.1.0", "v0.1.1"]
DOCUMENTS = [100, 300]
TOKENS = [1_000_000_000, 3_000_000_000]
"""
STATS = {"alpha": (200, 2_000_000_000), "beta_two": (100, 1_000_000_000)}
SOURCES = """SOURCES = {
"alpha": {"license": "CC0-1.0", "license_spdx": "CC0-1.0", "release": "0.1.0"},
"beta_two": {"license": "CC-BY-SA-4.0", "license_spdx": "CC-BY-SA-4.0", "release": "0.1.1"},
}
"""
def registry(root: Path) -> dict:
return vpc.load_registry(root)
def edit(path: Path, old: str, new: str) -> None:
text = path.read_text()
assert old in text, f"fixture no longer contains {old!r}"
path.write_text(text.replace(old, new))
def build(root: Path) -> None:
(root / "src").mkdir(parents=True)
(root / "CHANGELOG.md").write_text(CHANGELOG)
(root / "README.md").write_text(README)
(root / "src" / "plot_version_growth.py").write_text(GROWTH)
(root / "src" / "sources.py").write_text(SOURCES)
for name, (docs, tokens) in STATS.items():
directory = root / "data" / name
directory.mkdir(parents=True)
(directory / f"{name}.stats.json").write_text(
json.dumps({"kept": docs, "tokens": tokens, "license": "CC0"})
)
(directory / f"{name}.md").write_text(
f"# {name}\n- **License:** `{registry(root)[name]['license']}`\n"
)
(root / "paper.tex").write_text(TEX)
def run(root: Path) -> int:
return vpc.main(["--tex", str(root / "paper.tex"), "--root", str(root), "--ref", "worktree"])
def scenario(mutate=None) -> int:
root = Path(tempfile.mkdtemp())
try:
build(root)
if mutate:
mutate(root)
return run(root)
finally:
shutil.rmtree(root)
def drop_token_digit(root: Path) -> None:
path = root / "paper.tex"
path.write_text(path.read_text().replace("2000.0", "2500.0"))
def wrong_source_count(root: Path) -> None:
path = root / "paper.tex"
path.write_text(path.read_text().replace("v0.1.1 & 3.00 & 2", "v0.1.1 & 3.00 & ---"))
def add_source(root: Path, release: str | None) -> None:
directory = root / "data" / "gamma"
directory.mkdir(parents=True)
(directory / "gamma.stats.json").write_text(json.dumps({"kept": 1, "tokens": 1, "license": "CC0"}))
(directory / "gamma.md").write_text("# gamma\n- **License:** `CC0-1.0`\n")
edit(root / "src" / "sources.py", "}\n",
f' "gamma": {{"license": "CC0-1.0", "release": {release!r}}},\n}}\n')
def unlisted_source(root: Path) -> None:
add_source(root, "0.1.1")
def unreleased_source(root: Path) -> None:
add_source(root, None)
def wrong_license(root: Path) -> None:
edit(root / "paper.tex", "CC-BY-SA-4.0 & 1000.0", "CC-BY-4.0 & 1000.0")
def datasheet_license_drift(root: Path) -> None:
edit(root / "data" / "alpha" / "alpha.md", "CC0-1.0", "CC-BY-4.0")
def undefined_footnote(root: Path) -> None:
edit(root / "paper.tex", "& CC0 &", r"& CC0$^{\dagger}$ &")
def family_value_drift(root: Path) -> None:
edit(root / "paper.tex", "& beta two & $1.00$", "& beta two & $1.50$")
def incomplete_partition(root: Path) -> None:
edit(root / "paper.tex", "CC-BY-SA & beta two & $1.00$ \\\\\n", "")
def unfootnoted_dual_license(root: Path) -> None:
"""alpha's content is CC0 but its platform redistributes under CC-BY-4.0."""
edit(root / "src" / "sources.py",
'"alpha": {"license": "CC0-1.0", "license_spdx": "CC0-1.0"',
'"alpha": {"license": "CC0-1.0", "license_spdx": "CC-BY-4.0"')
def stale_growth_series(root: Path) -> None:
path = root / "src" / "plot_version_growth.py"
path.write_text(path.read_text().replace("3_000_000_000", "3_100_000_000"))
if __name__ == "__main__":
assert scenario() == 0, "consistent fixture must pass"
assert scenario(drop_token_digit) == 1, "per-source token drift must fail"
assert scenario(wrong_source_count) == 1, "carried-over '---' source count must fail"
assert scenario(unlisted_source) == 1, "source present in repo but not in Table 3 must fail"
assert scenario(stale_growth_series) == 1, "growth series vs composition drift must fail"
assert scenario(unreleased_source) == 0, "a source with release=None is not part of the release"
assert scenario(wrong_license) == 1, "license in Table 3 vs registry must fail"
assert scenario(datasheet_license_drift) == 1, "datasheet vs registry license drift must fail"
assert scenario(undefined_footnote) == 1, "a footnote marker with no definition must fail"
assert scenario(unfootnoted_dual_license) == 1, "an unfootnoted dual license must fail"
assert scenario(family_value_drift) == 1, "a wrong license-family subtotal must fail"
assert scenario(incomplete_partition) == 1, "a license family with no row must fail"
print("ok")
|