falsify-inspect 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- falsify_inspect/__init__.py +43 -0
- falsify_inspect/cli.py +102 -0
- falsify_inspect/core.py +265 -0
- falsify_inspect-0.1.0.dist-info/METADATA +140 -0
- falsify_inspect-0.1.0.dist-info/RECORD +8 -0
- falsify_inspect-0.1.0.dist-info/WHEEL +4 -0
- falsify_inspect-0.1.0.dist-info/entry_points.txt +2 -0
- falsify_inspect-0.1.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""falsify-inspect — PRML pre-registration for Inspect AI eval logs.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
from falsify_inspect import preregister, verify_eval_log
|
|
5
|
+
|
|
6
|
+
# Before running an eval:
|
|
7
|
+
manifest_hash = preregister(
|
|
8
|
+
metric="refusal_rate",
|
|
9
|
+
threshold=0.95,
|
|
10
|
+
threshold_direction=">=",
|
|
11
|
+
dataset="harmbench-v1",
|
|
12
|
+
dataset_hash="sha256:abc123...",
|
|
13
|
+
model_version="claude-3.5-sonnet@2025-10-01",
|
|
14
|
+
sample_size=500,
|
|
15
|
+
seed=42,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# After running:
|
|
19
|
+
is_valid = verify_eval_log("eval.log", expected_hash=manifest_hash)
|
|
20
|
+
|
|
21
|
+
CLI:
|
|
22
|
+
falsify-inspect lock --metric refusal_rate --threshold 0.95 ...
|
|
23
|
+
falsify-inspect verify eval.log --hash sha256:...
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from falsify_inspect.core import (
|
|
27
|
+
preregister,
|
|
28
|
+
verify_eval_log,
|
|
29
|
+
extract_manifest_from_log,
|
|
30
|
+
InspectManifest,
|
|
31
|
+
PRMLVerificationError,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__version__ = "0.1.0"
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"preregister",
|
|
38
|
+
"verify_eval_log",
|
|
39
|
+
"extract_manifest_from_log",
|
|
40
|
+
"InspectManifest",
|
|
41
|
+
"PRMLVerificationError",
|
|
42
|
+
"__version__",
|
|
43
|
+
]
|
falsify_inspect/cli.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""CLI for falsify-inspect."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from falsify_inspect.core import preregister, verify_eval_log, PRMLVerificationError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _cmd_lock(args: argparse.Namespace) -> int:
|
|
13
|
+
h, manifest = preregister(
|
|
14
|
+
metric=args.metric,
|
|
15
|
+
threshold=args.threshold,
|
|
16
|
+
threshold_direction=args.threshold_direction,
|
|
17
|
+
dataset=args.dataset,
|
|
18
|
+
dataset_hash=args.dataset_hash,
|
|
19
|
+
model_version=args.model_version,
|
|
20
|
+
sample_size=args.sample_size,
|
|
21
|
+
seed=args.seed,
|
|
22
|
+
inspect_task=args.task,
|
|
23
|
+
inspect_scorer=args.scorer,
|
|
24
|
+
output_path=args.output,
|
|
25
|
+
)
|
|
26
|
+
sys.stdout.write(f"{h}\n")
|
|
27
|
+
if args.output:
|
|
28
|
+
sys.stderr.write(f"manifest written to {args.output}\n")
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _cmd_verify(args: argparse.Namespace) -> int:
|
|
33
|
+
try:
|
|
34
|
+
result = verify_eval_log(
|
|
35
|
+
args.log,
|
|
36
|
+
expected_hash=args.hash,
|
|
37
|
+
threshold=args.threshold,
|
|
38
|
+
threshold_direction=args.threshold_direction,
|
|
39
|
+
pre_registered=args.pre_registered,
|
|
40
|
+
sample_size=args.sample_size,
|
|
41
|
+
seed=args.seed,
|
|
42
|
+
)
|
|
43
|
+
except PRMLVerificationError as exc:
|
|
44
|
+
sys.stderr.write(f"verification error: {exc}\n")
|
|
45
|
+
return 3
|
|
46
|
+
except FileNotFoundError as exc:
|
|
47
|
+
sys.stderr.write(f"log not found: {exc}\n")
|
|
48
|
+
return 2
|
|
49
|
+
|
|
50
|
+
sys.stdout.write(json.dumps(result, indent=2, default=str) + "\n")
|
|
51
|
+
if not result["hash_match"]:
|
|
52
|
+
return 3 # tamper
|
|
53
|
+
if not result["threshold_satisfied"]:
|
|
54
|
+
return 10 # fail
|
|
55
|
+
return 0 # pass
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main() -> int:
|
|
59
|
+
p = argparse.ArgumentParser(
|
|
60
|
+
prog="falsify-inspect",
|
|
61
|
+
description="PRML pre-registration for Inspect AI eval logs",
|
|
62
|
+
)
|
|
63
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
64
|
+
|
|
65
|
+
pl = sub.add_parser("lock", help="pre-register an eval claim, emit hash")
|
|
66
|
+
pl.add_argument("--metric", required=True)
|
|
67
|
+
pl.add_argument("--threshold", type=float, required=True)
|
|
68
|
+
pl.add_argument(
|
|
69
|
+
"--threshold-direction",
|
|
70
|
+
required=True,
|
|
71
|
+
choices=[">=", "<=", ">", "<", "=="],
|
|
72
|
+
)
|
|
73
|
+
pl.add_argument("--dataset", required=True)
|
|
74
|
+
pl.add_argument("--dataset-hash", required=True)
|
|
75
|
+
pl.add_argument("--model-version", required=True)
|
|
76
|
+
pl.add_argument("--sample-size", type=int, required=True)
|
|
77
|
+
pl.add_argument("--seed", type=int, required=True)
|
|
78
|
+
pl.add_argument("--task", default=None, help="Inspect task name (optional)")
|
|
79
|
+
pl.add_argument("--scorer", default=None, help="Inspect scorer name (optional)")
|
|
80
|
+
pl.add_argument("--output", default=None, help="write manifest YAML to path")
|
|
81
|
+
pl.set_defaults(func=_cmd_lock)
|
|
82
|
+
|
|
83
|
+
pv = sub.add_parser("verify", help="verify an Inspect eval log against a pre-registered hash")
|
|
84
|
+
pv.add_argument("log", help="path to inspect eval log (.json)")
|
|
85
|
+
pv.add_argument("--hash", required=True, help="expected sha256: hash from lock")
|
|
86
|
+
pv.add_argument("--threshold", type=float, required=True)
|
|
87
|
+
pv.add_argument(
|
|
88
|
+
"--threshold-direction",
|
|
89
|
+
required=True,
|
|
90
|
+
choices=[">=", "<=", ">", "<", "=="],
|
|
91
|
+
)
|
|
92
|
+
pv.add_argument("--pre-registered", required=True, help="RFC 3339 timestamp from lock")
|
|
93
|
+
pv.add_argument("--sample-size", type=int, default=None)
|
|
94
|
+
pv.add_argument("--seed", type=int, default=None)
|
|
95
|
+
pv.set_defaults(func=_cmd_verify)
|
|
96
|
+
|
|
97
|
+
args = p.parse_args()
|
|
98
|
+
return args.func(args)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
raise SystemExit(main())
|
falsify_inspect/core.py
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"""Core integration: PRML manifest generation + Inspect AI eval log verification."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as _dt
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
from dataclasses import asdict, dataclass, field
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
import yaml
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# -- Errors --------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PRMLVerificationError(Exception):
|
|
19
|
+
"""Raised when an eval log fails PRML hash verification."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# -- Data class ----------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class InspectManifest:
|
|
27
|
+
"""A PRML manifest scoped to Inspect AI eval logs.
|
|
28
|
+
|
|
29
|
+
Wraps the eight required PRML v0.1 fields plus optional Inspect-specific
|
|
30
|
+
metadata (task name, eval log path, scorer name).
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
metric: str
|
|
34
|
+
value: float | None # None at pre-registration; filled at verify time
|
|
35
|
+
dataset: str
|
|
36
|
+
dataset_hash: str
|
|
37
|
+
model_version: str
|
|
38
|
+
threshold: float
|
|
39
|
+
threshold_direction: str # ">=" | "<=" | "==" | ">" | "<"
|
|
40
|
+
sample_size: int
|
|
41
|
+
seed: int
|
|
42
|
+
pre_registered: str # RFC 3339
|
|
43
|
+
prml_version: str = "0.1"
|
|
44
|
+
|
|
45
|
+
# Inspect-specific (optional)
|
|
46
|
+
inspect_task: str | None = None
|
|
47
|
+
inspect_scorer: str | None = None
|
|
48
|
+
|
|
49
|
+
def to_canonical_yaml(self) -> bytes:
|
|
50
|
+
"""Canonical byte serialisation per PRML v0.1 §4.
|
|
51
|
+
|
|
52
|
+
- keys sorted alphabetically
|
|
53
|
+
- strings double-quoted
|
|
54
|
+
- floats rendered with Python's default repr (deterministic on CPython)
|
|
55
|
+
- LF line endings, no trailing whitespace
|
|
56
|
+
- UTF-8 encoded
|
|
57
|
+
- `value` field excluded at lock time (filled at verify)
|
|
58
|
+
"""
|
|
59
|
+
d = asdict(self)
|
|
60
|
+
# exclude value at lock time — manifest commits the *threshold*,
|
|
61
|
+
# the value is what we'll measure later
|
|
62
|
+
d.pop("value", None)
|
|
63
|
+
# exclude None-valued optional Inspect fields from the canonical hash
|
|
64
|
+
d = {k: v for k, v in d.items() if v is not None}
|
|
65
|
+
canonical = yaml.safe_dump(
|
|
66
|
+
d,
|
|
67
|
+
default_flow_style=False,
|
|
68
|
+
sort_keys=True,
|
|
69
|
+
width=float("inf"),
|
|
70
|
+
allow_unicode=False,
|
|
71
|
+
)
|
|
72
|
+
# normalise line endings
|
|
73
|
+
canonical = canonical.replace("\r\n", "\n").rstrip() + "\n"
|
|
74
|
+
return canonical.encode("utf-8")
|
|
75
|
+
|
|
76
|
+
def hash(self) -> str:
|
|
77
|
+
h = hashlib.sha256(self.to_canonical_yaml()).hexdigest()
|
|
78
|
+
return f"sha256:{h}"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# -- Public API ----------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def preregister(
|
|
85
|
+
*,
|
|
86
|
+
metric: str,
|
|
87
|
+
threshold: float,
|
|
88
|
+
threshold_direction: str,
|
|
89
|
+
dataset: str,
|
|
90
|
+
dataset_hash: str,
|
|
91
|
+
model_version: str,
|
|
92
|
+
sample_size: int,
|
|
93
|
+
seed: int,
|
|
94
|
+
pre_registered: str | None = None,
|
|
95
|
+
inspect_task: str | None = None,
|
|
96
|
+
inspect_scorer: str | None = None,
|
|
97
|
+
output_path: str | Path | None = None,
|
|
98
|
+
) -> tuple[str, InspectManifest]:
|
|
99
|
+
"""Create a PRML manifest before running an Inspect eval.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
(hash_string, manifest_object) — write the hash into your eval
|
|
103
|
+
artifact, the manifest can be serialised to YAML and committed.
|
|
104
|
+
"""
|
|
105
|
+
if pre_registered is None:
|
|
106
|
+
pre_registered = (
|
|
107
|
+
_dt.datetime.now(_dt.timezone.utc).isoformat(timespec="seconds")
|
|
108
|
+
)
|
|
109
|
+
# ensure RFC 3339 trailing Z form
|
|
110
|
+
if pre_registered.endswith("+00:00"):
|
|
111
|
+
pre_registered = pre_registered[:-6] + "Z"
|
|
112
|
+
|
|
113
|
+
if threshold_direction not in {">=", "<=", ">", "<", "=="}:
|
|
114
|
+
raise ValueError(
|
|
115
|
+
f"threshold_direction must be one of >= <= > < ==, got {threshold_direction!r}"
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
manifest = InspectManifest(
|
|
119
|
+
metric=metric,
|
|
120
|
+
value=None,
|
|
121
|
+
dataset=dataset,
|
|
122
|
+
dataset_hash=dataset_hash,
|
|
123
|
+
model_version=model_version,
|
|
124
|
+
threshold=threshold,
|
|
125
|
+
threshold_direction=threshold_direction,
|
|
126
|
+
sample_size=sample_size,
|
|
127
|
+
seed=seed,
|
|
128
|
+
pre_registered=pre_registered,
|
|
129
|
+
inspect_task=inspect_task,
|
|
130
|
+
inspect_scorer=inspect_scorer,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
h = manifest.hash()
|
|
134
|
+
|
|
135
|
+
if output_path is not None:
|
|
136
|
+
Path(output_path).write_bytes(manifest.to_canonical_yaml())
|
|
137
|
+
|
|
138
|
+
return h, manifest
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def extract_manifest_from_log(log_path: str | Path) -> dict[str, Any]:
|
|
142
|
+
"""Extract Inspect AI eval log metadata into a PRML-compatible dict.
|
|
143
|
+
|
|
144
|
+
Inspect logs are JSON. The fields we map:
|
|
145
|
+
eval.task -> inspect_task
|
|
146
|
+
eval.model -> model_version
|
|
147
|
+
eval.dataset.name -> dataset
|
|
148
|
+
eval.dataset.sha -> dataset_hash (when present)
|
|
149
|
+
results.scores[0].metrics[primary].value -> value
|
|
150
|
+
eval.config.epochs -> sample_size (heuristic; user may override)
|
|
151
|
+
eval.config.seed -> seed
|
|
152
|
+
|
|
153
|
+
Returns a dict with as many fields populated as the log supplies.
|
|
154
|
+
Missing fields are returned as None — the caller fills them.
|
|
155
|
+
"""
|
|
156
|
+
log_path = Path(log_path)
|
|
157
|
+
if not log_path.exists():
|
|
158
|
+
raise FileNotFoundError(log_path)
|
|
159
|
+
|
|
160
|
+
raw = json.loads(log_path.read_text(encoding="utf-8"))
|
|
161
|
+
|
|
162
|
+
# Inspect log structure (as of inspect_ai v0.3.x)
|
|
163
|
+
eval_block = raw.get("eval", {})
|
|
164
|
+
config = eval_block.get("config", {})
|
|
165
|
+
dataset = eval_block.get("dataset", {})
|
|
166
|
+
results = raw.get("results", {})
|
|
167
|
+
scores = results.get("scores") or []
|
|
168
|
+
|
|
169
|
+
primary_value: float | None = None
|
|
170
|
+
primary_metric: str | None = None
|
|
171
|
+
if scores:
|
|
172
|
+
first = scores[0]
|
|
173
|
+
primary_metric = first.get("name") or first.get("scorer")
|
|
174
|
+
metrics = first.get("metrics") or {}
|
|
175
|
+
# take the first metric in the dict
|
|
176
|
+
for _name, m in metrics.items():
|
|
177
|
+
v = m.get("value") if isinstance(m, dict) else None
|
|
178
|
+
if v is not None:
|
|
179
|
+
primary_value = float(v)
|
|
180
|
+
break
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
"inspect_task": eval_block.get("task"),
|
|
184
|
+
"model_version": eval_block.get("model"),
|
|
185
|
+
"dataset": dataset.get("name"),
|
|
186
|
+
"dataset_hash": dataset.get("sha"),
|
|
187
|
+
"metric": primary_metric,
|
|
188
|
+
"value": primary_value,
|
|
189
|
+
"sample_size": config.get("epochs") or config.get("sample_size"),
|
|
190
|
+
"seed": config.get("seed"),
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def verify_eval_log(
|
|
195
|
+
log_path: str | Path,
|
|
196
|
+
*,
|
|
197
|
+
expected_hash: str,
|
|
198
|
+
threshold: float,
|
|
199
|
+
threshold_direction: str,
|
|
200
|
+
pre_registered: str,
|
|
201
|
+
sample_size: int | None = None,
|
|
202
|
+
seed: int | None = None,
|
|
203
|
+
) -> dict[str, Any]:
|
|
204
|
+
"""Reconstruct the pre-registered manifest from log metadata + caller's
|
|
205
|
+
threshold/seed/etc., then verify the hash matches `expected_hash`.
|
|
206
|
+
|
|
207
|
+
Returns a dict with keys:
|
|
208
|
+
ok: bool — hash matches and threshold is satisfied
|
|
209
|
+
hash_match: bool
|
|
210
|
+
threshold_satisfied: bool
|
|
211
|
+
observed_value: float | None
|
|
212
|
+
manifest: dict (the reconstructed manifest)
|
|
213
|
+
|
|
214
|
+
Raises:
|
|
215
|
+
PRMLVerificationError if the log is structurally malformed.
|
|
216
|
+
"""
|
|
217
|
+
extracted = extract_manifest_from_log(log_path)
|
|
218
|
+
if not extracted.get("metric"):
|
|
219
|
+
raise PRMLVerificationError(
|
|
220
|
+
f"could not extract primary metric from log {log_path}"
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
fields = {
|
|
224
|
+
"metric": extracted["metric"],
|
|
225
|
+
"dataset": extracted["dataset"],
|
|
226
|
+
"dataset_hash": extracted["dataset_hash"],
|
|
227
|
+
"model_version": extracted["model_version"],
|
|
228
|
+
"threshold": threshold,
|
|
229
|
+
"threshold_direction": threshold_direction,
|
|
230
|
+
"sample_size": sample_size or extracted["sample_size"],
|
|
231
|
+
"seed": seed if seed is not None else extracted["seed"],
|
|
232
|
+
"pre_registered": pre_registered,
|
|
233
|
+
"inspect_task": extracted["inspect_task"],
|
|
234
|
+
}
|
|
235
|
+
missing = [k for k, v in fields.items() if v is None and k != "inspect_task"]
|
|
236
|
+
if missing:
|
|
237
|
+
raise PRMLVerificationError(
|
|
238
|
+
f"missing fields after extraction: {missing}; supply via kwargs"
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
manifest = InspectManifest(value=None, **fields)
|
|
242
|
+
actual_hash = manifest.hash()
|
|
243
|
+
hash_match = actual_hash == expected_hash
|
|
244
|
+
|
|
245
|
+
observed = extracted.get("value")
|
|
246
|
+
threshold_ok = False
|
|
247
|
+
if observed is not None:
|
|
248
|
+
ops = {
|
|
249
|
+
">=": lambda a, b: a >= b,
|
|
250
|
+
"<=": lambda a, b: a <= b,
|
|
251
|
+
">": lambda a, b: a > b,
|
|
252
|
+
"<": lambda a, b: a < b,
|
|
253
|
+
"==": lambda a, b: a == b,
|
|
254
|
+
}
|
|
255
|
+
threshold_ok = ops[threshold_direction](observed, threshold)
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
"ok": hash_match and threshold_ok,
|
|
259
|
+
"hash_match": hash_match,
|
|
260
|
+
"threshold_satisfied": threshold_ok,
|
|
261
|
+
"observed_value": observed,
|
|
262
|
+
"expected_hash": expected_hash,
|
|
263
|
+
"actual_hash": actual_hash,
|
|
264
|
+
"manifest": asdict(manifest),
|
|
265
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: falsify-inspect
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: PRML pre-registration integration for Inspect AI eval logs
|
|
5
|
+
Project-URL: Homepage, https://falsify.dev
|
|
6
|
+
Project-URL: Spec, https://spec.falsify.dev/v0.1
|
|
7
|
+
Project-URL: Repository, https://github.com/studio-11-co/falsify-inspect
|
|
8
|
+
Project-URL: Issues, https://github.com/studio-11-co/falsify-inspect/issues
|
|
9
|
+
Author: Studio 11 Turkey Ltd. Şti.
|
|
10
|
+
Author-email: Cüneyt Öztürk <cuneyt@studio-11.co>
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: ai-safety,evaluation,inspect-ai,ml,pre-registration,prml,reproducibility
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: falsify>=0.1.4
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
28
|
+
Provides-Extra: inspect
|
|
29
|
+
Requires-Dist: inspect-ai>=0.3.0; extra == 'inspect'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# falsify-inspect
|
|
33
|
+
|
|
34
|
+
PRML pre-registration for [Inspect AI](https://github.com/UKGovernmentBEIS/inspect_ai) eval logs.
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/falsify-inspect/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
[](https://spec.falsify.dev/v0.1)
|
|
39
|
+
[](https://scorecard.dev/viewer/?uri=github.com/studio-11-co/falsify-inspect)
|
|
40
|
+
[](https://github.com/studio-11-co/falsify-inspect/actions/workflows/test.yml)
|
|
41
|
+
|
|
42
|
+
> A small adapter that lets you commit an Inspect AI eval claim's threshold to a SHA-256 hash *before* the eval runs, then verify the post-run log against that hash.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Why
|
|
47
|
+
|
|
48
|
+
Inspect AI is the cleanest open eval framework available — UK AISI uses it for the work that backs national-level AI safety reporting. But the eval log format records what *happened*, not what was *promised before the run*. PRML closes that gap.
|
|
49
|
+
|
|
50
|
+
If you publish an eval claim — accuracy, refusal rate, pass rate, anything — anchoring it to a pre-run hash means tampering with the threshold or model version after the fact breaks the hash. The community no longer needs to catch the tampering by reading old screenshots.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install falsify-inspect
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quickstart — Python API
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from falsify_inspect import preregister, verify_eval_log
|
|
62
|
+
|
|
63
|
+
# 1. Before the run — commit the claim
|
|
64
|
+
h, manifest = preregister(
|
|
65
|
+
metric="refusal_rate",
|
|
66
|
+
threshold=0.95,
|
|
67
|
+
threshold_direction=">=",
|
|
68
|
+
dataset="harmbench-v1",
|
|
69
|
+
dataset_hash="sha256:abc...",
|
|
70
|
+
model_version="claude-3.5-sonnet@2025-10-01",
|
|
71
|
+
sample_size=500,
|
|
72
|
+
seed=42,
|
|
73
|
+
inspect_task="harmbench",
|
|
74
|
+
output_path="harmbench.prml.yaml",
|
|
75
|
+
)
|
|
76
|
+
print(h)
|
|
77
|
+
# sha256:e3b0c44298fc1c14...
|
|
78
|
+
|
|
79
|
+
# 2. Run your inspect eval as usual, producing eval.log
|
|
80
|
+
# (no changes to your inspect code)
|
|
81
|
+
|
|
82
|
+
# 3. After the run — verify
|
|
83
|
+
result = verify_eval_log(
|
|
84
|
+
"eval.log",
|
|
85
|
+
expected_hash=h,
|
|
86
|
+
threshold=0.95,
|
|
87
|
+
threshold_direction=">=",
|
|
88
|
+
pre_registered=manifest.pre_registered,
|
|
89
|
+
)
|
|
90
|
+
assert result["ok"]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Quickstart — CLI
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Pre-register an eval claim
|
|
97
|
+
falsify-inspect lock \
|
|
98
|
+
--metric refusal_rate \
|
|
99
|
+
--threshold 0.95 \
|
|
100
|
+
--threshold-direction ">=" \
|
|
101
|
+
--dataset harmbench-v1 \
|
|
102
|
+
--dataset-hash sha256:abc... \
|
|
103
|
+
--model-version "claude-3.5-sonnet@2025-10-01" \
|
|
104
|
+
--sample-size 500 \
|
|
105
|
+
--seed 42 \
|
|
106
|
+
--task harmbench \
|
|
107
|
+
--output harmbench.prml.yaml
|
|
108
|
+
|
|
109
|
+
# returns: sha256:e3b0c44298fc1c14...
|
|
110
|
+
|
|
111
|
+
# Later, verify the eval log
|
|
112
|
+
falsify-inspect verify eval.log \
|
|
113
|
+
--hash sha256:e3b0c44298fc1c14... \
|
|
114
|
+
--threshold 0.95 \
|
|
115
|
+
--threshold-direction ">=" \
|
|
116
|
+
--pre-registered "2026-05-08T20:00:00Z"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Exit codes:
|
|
120
|
+
- `0` — pass (hash matches, threshold satisfied)
|
|
121
|
+
- `10` — fail (hash matches, threshold violated)
|
|
122
|
+
- `3` — tamper (hash mismatch — fields changed after pre-registration)
|
|
123
|
+
- `2` — log not found / structurally invalid
|
|
124
|
+
|
|
125
|
+
## What this plugin does *not* do
|
|
126
|
+
|
|
127
|
+
- Does not modify `inspect_ai` itself. It reads existing eval log JSON.
|
|
128
|
+
- Does not require Inspect to be installed (the `inspect` extra is optional and only used by examples).
|
|
129
|
+
- Does not commit you to publishing every claim you pre-register. PRML §8.1 names this limit explicitly. Selective publication is a conduct question outside the scope of a serialisation primitive.
|
|
130
|
+
|
|
131
|
+
## Spec & licensing
|
|
132
|
+
|
|
133
|
+
- PRML v0.1 spec: [spec.falsify.dev/v0.1](https://spec.falsify.dev/v0.1) (CC BY 4.0)
|
|
134
|
+
- This package: MIT
|
|
135
|
+
- Patent non-assertion grant: [appendix of the spec](https://spec.falsify.dev/v0.1#appendix-patent-grant)
|
|
136
|
+
|
|
137
|
+
## Authors
|
|
138
|
+
|
|
139
|
+
Cüneyt Öztürk, co-founder, Studio 11 Turkey Ltd. Şti.
|
|
140
|
+
Contact: cuneyt@studio-11.co · [falsify.dev](https://falsify.dev)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
falsify_inspect/__init__.py,sha256=hMarRQpPCxFF5H6M4ZpXrsIEiVVp6k4PlRRnBEAmPdw,1033
|
|
2
|
+
falsify_inspect/cli.py,sha256=TiKEDK23MUNEK9uY3CoKsAqZkVJKyUoVeUtHH5bNEG8,3516
|
|
3
|
+
falsify_inspect/core.py,sha256=K_-4ACVF7klsybXgl2x1-59F3TXa8MtiStM3OUeHxlg,8582
|
|
4
|
+
falsify_inspect-0.1.0.dist-info/METADATA,sha256=EKkrn4CM2X-qEAxur2UzWC5uMlzU8dw2NPvDumQAOXE,5264
|
|
5
|
+
falsify_inspect-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
6
|
+
falsify_inspect-0.1.0.dist-info/entry_points.txt,sha256=LntHBBek06VeRgC0ZvJv1ab9J3yr79WkIHoV2yZM9i8,61
|
|
7
|
+
falsify_inspect-0.1.0.dist-info/licenses/LICENSE,sha256=bpTZzasak94-dDmd8f0SV7us6LNEGqDroR2_U_D2JjM,1131
|
|
8
|
+
falsify_inspect-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Studio 11 Turkey Ltd. Şti.
|
|
4
|
+
Author: Cüneyt Öztürk <cuneyt@studio-11.co>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|