Publish verification pack files (cookie commit)
Browse files- README.md +0 -57
- VERIFICATION-DOSSIER-PUBLIC.md +61 -0
- environment/src/binary_reasoning_v1/grading.py +114 -0
- verification_kit/README.md +52 -0
- verification_kit/do_nothing.py +54 -0
- verification_kit/gold.py +88 -0
- verification_kit/grader_tamper.py +127 -0
- verification_kit/leak_check.py +71 -0
- verification_kit/random_wrong.py +103 -0
README.md
CHANGED
|
@@ -53,60 +53,3 @@ request access; access is reviewed on request. Commercial licensing and custom t
|
|
| 53 |
|
| 54 |
## License
|
| 55 |
All rights reserved pending commercial license; research evaluation use granted for the free sample.
|
| 56 |
-
|
| 57 |
-
<!-- hf-api-probe -->
|
| 58 |
-
---
|
| 59 |
-
license: "other"
|
| 60 |
-
tags:
|
| 61 |
-
- reinforcement-learning
|
| 62 |
-
- evaluation
|
| 63 |
-
- reverse-engineering
|
| 64 |
-
- binaries
|
| 65 |
-
- elf
|
| 66 |
-
- pe
|
| 67 |
-
- cross-architecture
|
| 68 |
-
- taskset
|
| 69 |
-
- harbor-framework
|
| 70 |
-
- rl-environments
|
| 71 |
-
size_categories:
|
| 72 |
-
- 10K<n<100K
|
| 73 |
-
pretty_name: binary-reasoning-v1
|
| 74 |
-
---
|
| 75 |
-
|
| 76 |
-
# binary-reasoning-v1
|
| 77 |
-
|
| 78 |
-
**Verified reverse-engineering tasks over real production binaries** — an RL / eval environment
|
| 79 |
-
pack where every answer is derived from the artifact itself and machine-checked.
|
| 80 |
-
|
| 81 |
-
- **10,251 items · 10 families · 7 ISAs** (x86-64, i686, AArch64, ARM32, RISC-V, MIPS o32/n64, PPC64LE)
|
| 82 |
-
- Sources: 649 distinct third-party file names referenced in shipped provenance (system libs incl.
|
| 83 |
-
libcrypto/zstd/sqlite3/libxml2, Mesa DRI drivers, QEMU device models, systemd internals), Debian production
|
| 84 |
-
cross-toolchain glibc, Android/Termux production aarch64 libs, curated Windows PEs, labeled cross-compiles
|
| 85 |
-
- Provenance per item: binary name and sha256_16 on every item; function address/size and architecture where applicable
|
| 86 |
-
- **Verification:** automated REA re-verification (answers re-verified against the binaries); 10,172
|
| 87 |
-
deterministic items score 1.0 on gold / 0.0 on abstention; automated answer-leak scan found 0/10,251 hits; all tasks load
|
| 88 |
-
against the real `verifiers` v1 framework; 29 agentic challenges ship Harbor-format task packages,
|
| 89 |
-
built + scored in real Docker containers with reward-chain gold and wrong-answer tests passing; each binary was also checked with 24 single-character mutations that scored zero
|
| 90 |
-
- **Baseline:** a small local open-weight model mini-eval scored `5/23` (22%) on selected static deterministic items; see `EVAL_RESULTS.md` for conditions. Headroom is the feature — per-buyer calibration is part of the paid pilot path.
|
| 91 |
-
|
| 92 |
-
## Contents of this repo (free sample)
|
| 93 |
-
| file | what |
|
| 94 |
-
|---|---|
|
| 95 |
-
| `DATASHEET.md` | full composition table, guarantees, known limits, positioning vs existing work |
|
| 96 |
-
| `sample_free.jsonl` | 9 items — one per family |
|
| 97 |
-
| `EVAL_RESULTS.md` | baseline eval methodology + results (incl. measured frontier reference: Opus 5.5 single-shot ~58% on ID items; agentic flag-hunts pass@1 3/3 with tools — reward reachable, not free) |
|
| 98 |
-
| `VERIFICATION-DOSSIER-PUBLIC.md` | public proof summary with measured checks and known caveats |
|
| 99 |
-
| `verification_kit/` | sample-level grader, wrong-answer, key-sensitivity, and leak-check scripts; see `verification_kit/README.md` for limitations |
|
| 100 |
-
| `environment/src/binary_reasoning_v1/grading.py` | minimal grader module used by the verification kit (full runnable environment is on the Prime Hub package) |
|
| 101 |
-
| `harbor_pilot_29.zip` | all 29 agentic Harbor task packages (task.toml + instruction + Dockerfile + verifier), ready for `harbor run` or a free HUD import ([direct download](https://huggingface.co/datasets/S3RL4/binary-reasoning-v1/resolve/main/harbor_pilot_29.zip)) |
|
| 102 |
-
|
| 103 |
-
Also live on the Prime Intellect Environments Hub: `s3rl4/binary-reasoning-v1`
|
| 104 |
-
(`prime env install s3rl4/binary-reasoning-v1`).
|
| 105 |
-
|
| 106 |
-
The **full pack** (10,251 items + runnable verifiers v1 environment + Harbor packages + agentic
|
| 107 |
-
binaries & sources) lives in the gated companion repo:
|
| 108 |
-
[S3RL4/binary-reasoning-v1-full](https://huggingface.co/datasets/S3RL4/binary-reasoning-v1-full) —
|
| 109 |
-
request access; access is reviewed on request. Commercial licensing and custom taskset builds: samueljanttila@gmail.com.
|
| 110 |
-
|
| 111 |
-
## License
|
| 112 |
-
All rights reserved pending commercial license; research evaluation use granted for the free sample.
|
|
|
|
| 53 |
|
| 54 |
## License
|
| 55 |
All rights reserved pending commercial license; research evaluation use granted for the free sample.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VERIFICATION-DOSSIER-PUBLIC.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Verification dossier — public summary
|
| 2 |
+
|
| 3 |
+
This is the public part of RE-Lab's verification dossier for `binary-reasoning-v1`. The full buyer-ready version adds procurement, provenance tables, calibration plans, and delivery details. Contact: samueljanttila@gmail.com.
|
| 4 |
+
|
| 5 |
+
**Dataset:** https://huggingface.co/datasets/S3RL4/binary-reasoning-v1
|
| 6 |
+
**Self-serve sample kit:** `verification_kit/README.md` in this dataset repo
|
| 7 |
+
**Canary for contamination checks:** `RE-Lab-brv-2026-10-29-8c1e4f7a`
|
| 8 |
+
|
| 9 |
+
## What is verified now
|
| 10 |
+
|
| 11 |
+
### 1. Pack counts and grader split
|
| 12 |
+
The full pack contains `10,251` items:
|
| 13 |
+
- `10,172` deterministic-graded items.
|
| 14 |
+
- `79` rubric-judged open-ended items, disclosed rather than sold as deterministic.
|
| 15 |
+
|
| 16 |
+
The public sample includes 9 free items and a 100-item open sample in the Prime environment package. The sample kit skips rubric-judged items instead of pretending they are deterministic.
|
| 17 |
+
|
| 18 |
+
### 2. Grader sanity checks
|
| 19 |
+
On the 100-item open sample, the public sample kit reports:
|
| 20 |
+
- `gold.py`: deterministic gold replies pass `84/84`; `16` judge items skipped.
|
| 21 |
+
- `do_nothing.py`: empty answers score `0` on all `84` deterministic items.
|
| 22 |
+
- `random_wrong.py`: deterministic mutated wrong answers score `0` on all `84` deterministic items.
|
| 23 |
+
- `grader_tamper.py`: mutating the answer key makes the original gold reply fail on all `84` deterministic items.
|
| 24 |
+
- `leak_check.py`: `items=100 unique_ids=100 checked_rows=73 leaks=0`.
|
| 25 |
+
|
| 26 |
+
On the 9-item free sample:
|
| 27 |
+
- deterministic sanity checks pass `4/4`; `5` judge items skipped.
|
| 28 |
+
- `leak_check.py`: `items=9 unique_ids=9 checked_rows=3 leaks=0`.
|
| 29 |
+
|
| 30 |
+
### 3. Answer-leak audit
|
| 31 |
+
The existing full-pack answer-token audit reports `0/10,251` exact-token leaks. The public sample script is a smaller reproduction tool and reports checked-row coverage (`73/100` checkable rows on the open sample; `3/9` on the free sample). It does not replace the full-pack audit.
|
| 32 |
+
|
| 33 |
+
### 4. Agentic environments
|
| 34 |
+
The public agentic tier has `29` Harbor-format flag-hunt environments. The Docker reward chain was tested with gold answers and wrong-answer tests, and each binary was checked with 24 single-character mutations that scored zero. In the JSONL/verifiers path, the deterministic grader checks whether the stored flag appears in the reply as a substring; that is weaker than the Harbor oracle.
|
| 35 |
+
|
| 36 |
+
### 5. Hard-trial reproduction evidence
|
| 37 |
+
The 99-item hard trial pack has 19 family-level reproduction scripts in RE-Lab's pinned Ubuntu 24.04/WSL2 and Windows test environment. They reproduce `99/99` gold answers without reading the `answer` field. About `77` rows are command/binary re-execution (reproducibility, not an independent solve); about `22` rows use static ELF/PE/argv-derived reasoning. No human solved these tasks.
|
| 38 |
+
|
| 39 |
+
### 6. Calibration evidence so far
|
| 40 |
+
The public agentic tier is intentionally warm-up level for a frontier agent: Claude Opus 5.5 solved `29/29` environments and `145/145` attempts in a non-isolated host run with Bash/Read tools, graded by the binary oracle.
|
| 41 |
+
|
| 42 |
+
A separate local open-weight calibration run on the 99-item hard trial pack scored `14/99` at pass@8:
|
| 43 |
+
- model: `qwen3.8-flash-next-iq3_s`, 3-bit quantized;
|
| 44 |
+
- single-turn, no tools;
|
| 45 |
+
- temperature `0.7`, `max_tokens=600`, with a `reasoning_content` fallback;
|
| 46 |
+
- whole-reply normalized matching rather than each item's verifier rule.
|
| 47 |
+
|
| 48 |
+
That is headroom evidence, not a published band table or proof that each task sits in the RL mid-band. Per-buyer model calibration is part of the paid pilot path.
|
| 49 |
+
|
| 50 |
+
## Known limitations and caveats
|
| 51 |
+
- Current deterministic graders can accept some "shotgun" replies that contain the correct token among many distractors. A dedicated `shotgun.py` probe is a planned kit addition.
|
| 52 |
+
- Some hard-trial reproduction scripts are environment-bound: they depend on local paths, WSL/Windows tools, pinned package digests, or host-specific loader behavior. They are evidence, not yet a portable buyer-runnable solver suite.
|
| 53 |
+
- Some shipped artifact sets include grader-side metadata or unstripped twins that could reveal an answer if mounted to the model. A model-visible vs grader-only manifest is needed before selling sealed evaluation as fully isolated.
|
| 54 |
+
- The full-pack public exposure window was 2026-10-28 22:02 → 2026-10-29 17:08 UTC, then older public versions were deleted. Deletion reduces future access but does not prove no copies exist.
|
| 55 |
+
- The full pack uses production distro binaries with per-item provenance (`binary` path + `sha256_16`, plus address/size/architecture where applicable). A source-offer manifest lists `649` distinct third-party file names; upstream package/source mapping is a procurement follow-up for any redistribution-heavy order.
|
| 56 |
+
|
| 57 |
+
## What this does not claim
|
| 58 |
+
- It does not claim human or expert hand-checking of every task.
|
| 59 |
+
- It does not claim every task is model-solvable without tools.
|
| 60 |
+
- It does not claim the deterministic graders reject all low-effort answers.
|
| 61 |
+
- It does not claim the hard trial pack has a published pass-rate band for every task yet.
|
environment/src/binary_reasoning_v1/grading.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Deterministic grading for binary-reasoning-v1 items. Pure functions, no framework deps."""
|
| 2 |
+
import json
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
JUDGE_FAMILIES = {"func_summary", "arch_semantics_qa", "isa_semantics_qa", "pe_import_reasoning", "pe_structure_qa"}
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def norm_symbol(s: str) -> str:
|
| 9 |
+
s = s.strip().lower()
|
| 10 |
+
s = re.sub(r"^[*&]+", "", s)
|
| 11 |
+
s = re.sub(r"\(.*\)$", "", s).strip()
|
| 12 |
+
s = re.sub(r"\.+$", "", s) # sentence-final dot captured by token regex
|
| 13 |
+
return s
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _answer_symbol(answer) -> str:
|
| 17 |
+
if isinstance(answer, dict):
|
| 18 |
+
return answer.get("symbol", "")
|
| 19 |
+
return str(answer)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def grade_func_id_exact(reply: str, answer) -> float:
|
| 23 |
+
sym = norm_symbol(_answer_symbol(answer))
|
| 24 |
+
if not sym:
|
| 25 |
+
return 0.0
|
| 26 |
+
accepted = {sym}
|
| 27 |
+
if isinstance(answer, dict):
|
| 28 |
+
accepted |= {norm_symbol(a) for a in answer.get("aliases", []) if a}
|
| 29 |
+
toks = [norm_symbol(t) for t in re.findall(r"[A-Za-z_][A-Za-z0-9_.]+", reply)]
|
| 30 |
+
return 1.0 if accepted & set(toks) else 0.0
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def grade_func_id_mc(reply: str, answer: dict) -> float:
|
| 34 |
+
correct = answer.get("correct", "")
|
| 35 |
+
opts = answer.get("options", [])
|
| 36 |
+
r = reply.strip()
|
| 37 |
+
m = re.search(r"\b([A-D])\b", r[:80], re.IGNORECASE)
|
| 38 |
+
if m:
|
| 39 |
+
idx = ord(m.group(1).upper()) - 65
|
| 40 |
+
if 0 <= idx < len(opts):
|
| 41 |
+
return float(norm_symbol(opts[idx]) == norm_symbol(correct))
|
| 42 |
+
names = [norm_symbol(o) for o in re.findall(r"[A-Za-z_][A-Za-z0-9_.]{3,}", r.lower())]
|
| 43 |
+
return 1.0 if norm_symbol(correct) in names else 0.0
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def grade_tcfp(reply: str, answer: dict) -> float:
|
| 47 |
+
strs = answer.get("toolchain_strings", [])
|
| 48 |
+
if not strs:
|
| 49 |
+
return 0.0
|
| 50 |
+
hits = sum(1 for s in strs if s.lower() in reply.lower())
|
| 51 |
+
return hits / len(strs)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def needs_judge(family: str, answer) -> bool:
|
| 55 |
+
if family in JUDGE_FAMILIES:
|
| 56 |
+
return True
|
| 57 |
+
if family == "func_id_exact":
|
| 58 |
+
sym = _answer_symbol(answer)
|
| 59 |
+
# descriptive/inferred answers (contain prose) cannot be string-matched
|
| 60 |
+
return (" " in sym.strip()) or ("inferred" in sym.lower())
|
| 61 |
+
return False
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def grade_agentic(reply: str, answer) -> float:
|
| 65 |
+
flag = _answer_symbol(answer)
|
| 66 |
+
return 1.0 if flag and flag in reply else 0.0
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def grade_crossarch(reply: str, answer) -> float:
|
| 70 |
+
if isinstance(answer, str):
|
| 71 |
+
try:
|
| 72 |
+
answer = json.loads(answer)
|
| 73 |
+
except Exception:
|
| 74 |
+
answer = {"same": "true" in answer.lower(),
|
| 75 |
+
"symbol": re.sub(r'.*?"symbol"\s*:\s*"([^"]+)".*', r"\1", answer) if '"symbol"' in answer else ""}
|
| 76 |
+
want = bool(answer.get("same"))
|
| 77 |
+
r = reply.lower()
|
| 78 |
+
neg = bool(re.search(r"\bnot\s+(the\s+)?same\b|\bdifferent\b|\bno\b", r))
|
| 79 |
+
pos = not neg and bool(re.search(r"\bsame\b|\byes\b|\btrue\b|match", r))
|
| 80 |
+
if not (neg or pos):
|
| 81 |
+
return 0.0 # abstention / no clear stance
|
| 82 |
+
if pos != want:
|
| 83 |
+
return 0.0
|
| 84 |
+
if want:
|
| 85 |
+
sym = norm_symbol(answer.get("symbol", ""))
|
| 86 |
+
toks = [norm_symbol(t) for t in re.findall(r"[A-Za-z_][A-Za-z0-9_.]+", reply)]
|
| 87 |
+
if sym not in toks:
|
| 88 |
+
return 0.0
|
| 89 |
+
return 1.0
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def grade_library_ident(reply: str, answer) -> float:
|
| 93 |
+
ans = _answer_symbol(answer)
|
| 94 |
+
toks = [t for t in re.split(r"\s+", ans) if len(t) >= 2]
|
| 95 |
+
r = reply.lower()
|
| 96 |
+
return 1.0 if all(t.lower() in r for t in toks) else 0.0
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def grade_item(family: str, reply: str, answer) -> float:
|
| 100 |
+
if needs_judge(family, answer):
|
| 101 |
+
return 0.0 # handled by rubric judge in taskset.py
|
| 102 |
+
if family == "library_ident":
|
| 103 |
+
return grade_library_ident(reply, answer)
|
| 104 |
+
if family == "crossarch_equivalence":
|
| 105 |
+
return grade_crossarch(reply, answer)
|
| 106 |
+
if family == "agentic_flag_hunt":
|
| 107 |
+
return grade_agentic(reply, answer)
|
| 108 |
+
if family == "func_id_exact":
|
| 109 |
+
return grade_func_id_exact(reply, answer)
|
| 110 |
+
if family == "func_id_mc":
|
| 111 |
+
return grade_func_id_mc(reply, answer)
|
| 112 |
+
if family == "toolchain_fp":
|
| 113 |
+
return grade_tcfp(reply, answer)
|
| 114 |
+
return 0.0
|
verification_kit/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Verification kit — sample-level checks
|
| 2 |
+
|
| 3 |
+
This small kit lets a buyer's researcher sanity-check the grader and answer hygiene without trusting RE-Lab. It runs on the public sample JSONL files; it does not require the paid full pack. The grader scripts import `binary_reasoning_v1.grading` from `environment/src/binary_reasoning_v1/grading.py` (`leak_check.py` does not), so include that file (or the Prime environment package) when downloading just the free sample.
|
| 4 |
+
|
| 5 |
+
## Run it
|
| 6 |
+
|
| 7 |
+
From the dataset root:
|
| 8 |
+
|
| 9 |
+
```bash
|
| 10 |
+
python verification_kit/gold.py sample_free.jsonl
|
| 11 |
+
python verification_kit/do_nothing.py sample_free.jsonl
|
| 12 |
+
python verification_kit/random_wrong.py sample_free.jsonl
|
| 13 |
+
python verification_kit/leak_check.py sample_free.jsonl
|
| 14 |
+
python verification_kit/grader_tamper.py sample_free.jsonl
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
If the 100-item open sample is present locally, point the same scripts at it:
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
python verification_kit/gold.py environment/src/binary_reasoning_v1/items.jsonl
|
| 21 |
+
python verification_kit/do_nothing.py environment/src/binary_reasoning_v1/items.jsonl
|
| 22 |
+
python verification_kit/random_wrong.py environment/src/binary_reasoning_v1/items.jsonl
|
| 23 |
+
python verification_kit/leak_check.py environment/src/binary_reasoning_v1/items.jsonl
|
| 24 |
+
python verification_kit/grader_tamper.py environment/src/binary_reasoning_v1/items.jsonl
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
## What each script checks
|
| 28 |
+
|
| 29 |
+
| Script | What it does | Expected result |
|
| 30 |
+
|---|---|---|
|
| 31 |
+
| `gold.py` | Builds a reply from the stored answer and grades it. | Deterministic items score `1.0`; rubric-judged items are skipped, not silently graded. |
|
| 32 |
+
| `do_nothing.py` | Grades an empty reply. | Deterministic items score `0`. |
|
| 33 |
+
| `random_wrong.py` | Builds a deterministic mutated wrong reply and grades it. | Deterministic items score `0`. It is not stochastic random guessing. |
|
| 34 |
+
| `leak_check.py` | Extracts exact hidden answer tokens where possible and searches the model-facing `input` field. | Reports checked-row coverage; no exact-token leaks on the public samples. |
|
| 35 |
+
| `grader_tamper.py` | Mutates the stored answer key and grades the original gold reply against it. | The original gold reply no longer scores, showing that grading depends on the answer key. |
|
| 36 |
+
|
| 37 |
+
## Measured results on this workspace (2026-10-30)
|
| 38 |
+
|
| 39 |
+
On `sample_free.jsonl`:
|
| 40 |
+
- `gold.py`, `do_nothing.py`, `random_wrong.py`, and `grader_tamper.py`: `4/4` deterministic items pass; `5` rubric-judged items are skipped.
|
| 41 |
+
- `leak_check.py`: `items=9 unique_ids=9 checked_rows=3 leaks=0`.
|
| 42 |
+
|
| 43 |
+
On the 100-item open sample at `environment/src/binary_reasoning_v1/items.jsonl`:
|
| 44 |
+
- `gold.py`, `do_nothing.py`, `random_wrong.py`, and `grader_tamper.py`: `84/84` deterministic items pass; `16` rubric-judged items are skipped.
|
| 45 |
+
- `leak_check.py`: `items=100 unique_ids=100 checked_rows=73 leaks=0`.
|
| 46 |
+
|
| 47 |
+
## Known limitations
|
| 48 |
+
|
| 49 |
+
- The current deterministic graders can accept some "shotgun" replies that contain the correct token among many distractors. This kit does not yet include a dedicated `shotgun.py` probe.
|
| 50 |
+
- `leak_check.py` scans the raw JSONL `input` field, not every rendered prompt variant. Rows with no extractable exact answer token are reported as unchecked.
|
| 51 |
+
- The full-pack answer-leak figure (`0/10,251`) comes from the existing full-pack audit, not from this public sample script.
|
| 52 |
+
- The `solvers/` directory contains RE-Lab-run reproduction scripts for internal hard-trial families. Several depend on local paths, WSL/Windows tools, pinned package digests, or host-specific loader behavior, so they are evidence rather than a portable buyer-runnable kit yet.
|
verification_kit/do_nothing.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Do-nothing sanity check: an empty answer should score 0 on deterministic tasks."""
|
| 3 |
+
import json
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 8 |
+
sys.path.insert(0, str(ROOT / "environment" / "src"))
|
| 9 |
+
from binary_reasoning_v1.grading import grade_item, needs_judge # noqa: E402
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def resolve_path():
|
| 13 |
+
if len(sys.argv) > 1:
|
| 14 |
+
return Path(sys.argv[1])
|
| 15 |
+
for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
|
| 16 |
+
if p.exists():
|
| 17 |
+
return p
|
| 18 |
+
raise SystemExit("no sample JSONL found; pass one as argv[1]")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def load_rows(path):
|
| 22 |
+
rows = []
|
| 23 |
+
for line in path.read_text(encoding="utf-8").splitlines():
|
| 24 |
+
if line.strip():
|
| 25 |
+
rows.append(json.loads(line))
|
| 26 |
+
return rows
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def main():
|
| 30 |
+
path = resolve_path()
|
| 31 |
+
rows = load_rows(path)
|
| 32 |
+
passed = failed = skipped = 0
|
| 33 |
+
fails = []
|
| 34 |
+
for row in rows:
|
| 35 |
+
fam = row.get("family", "")
|
| 36 |
+
ans = row.get("answer")
|
| 37 |
+
if needs_judge(fam, ans):
|
| 38 |
+
skipped += 1
|
| 39 |
+
continue
|
| 40 |
+
score = grade_item(fam, "", ans)
|
| 41 |
+
if score == 0.0:
|
| 42 |
+
passed += 1
|
| 43 |
+
else:
|
| 44 |
+
failed += 1
|
| 45 |
+
fails.append((row.get("id"), fam, score))
|
| 46 |
+
print(f"file={path}")
|
| 47 |
+
print(f"summary: do_nothing pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
|
| 48 |
+
for f in fails[:10]:
|
| 49 |
+
print("FAIL", *f)
|
| 50 |
+
return 0 if failed == 0 else 1
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
raise SystemExit(main())
|
verification_kit/gold.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Gold-answer sanity check: built-in gold replies should score 1 on deterministic tasks."""
|
| 3 |
+
import json
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 8 |
+
sys.path.insert(0, str(ROOT / "environment" / "src"))
|
| 9 |
+
from binary_reasoning_v1.grading import _answer_symbol, grade_item, needs_judge, norm_symbol # noqa: E402
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def resolve_path():
|
| 13 |
+
if len(sys.argv) > 1:
|
| 14 |
+
return Path(sys.argv[1])
|
| 15 |
+
for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
|
| 16 |
+
if p.exists():
|
| 17 |
+
return p
|
| 18 |
+
raise SystemExit("no sample JSONL found; pass one as argv[1]")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def load_rows(path):
|
| 22 |
+
rows = []
|
| 23 |
+
for line in path.read_text(encoding="utf-8").splitlines():
|
| 24 |
+
if line.strip():
|
| 25 |
+
rows.append(json.loads(line))
|
| 26 |
+
return rows
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def parse_json_answer(ans):
|
| 30 |
+
if isinstance(ans, dict):
|
| 31 |
+
return ans
|
| 32 |
+
if isinstance(ans, str):
|
| 33 |
+
try:
|
| 34 |
+
obj = json.loads(ans)
|
| 35 |
+
if isinstance(obj, dict):
|
| 36 |
+
return obj
|
| 37 |
+
except Exception:
|
| 38 |
+
pass
|
| 39 |
+
return {}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def gold_reply(row):
|
| 43 |
+
fam = row.get("family", "")
|
| 44 |
+
ans = row.get("answer")
|
| 45 |
+
if fam == "func_id_mc" and isinstance(ans, dict):
|
| 46 |
+
opts = ans.get("options", [])
|
| 47 |
+
correct = norm_symbol(ans.get("correct", ""))
|
| 48 |
+
for i, opt in enumerate(opts[:4]):
|
| 49 |
+
if norm_symbol(opt) == correct:
|
| 50 |
+
return "ABCD"[i]
|
| 51 |
+
return str(ans.get("correct", ""))
|
| 52 |
+
if fam == "toolchain_fp" and isinstance(ans, dict):
|
| 53 |
+
return "\n".join(str(s) for s in ans.get("toolchain_strings", []))
|
| 54 |
+
if fam == "crossarch_equivalence":
|
| 55 |
+
obj = parse_json_answer(ans)
|
| 56 |
+
if bool(obj.get("same")):
|
| 57 |
+
return f"Same function: {obj.get('symbol', '')}"
|
| 58 |
+
return "Not the same."
|
| 59 |
+
sym = _answer_symbol(ans)
|
| 60 |
+
return str(sym or ans or "")
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def main():
|
| 64 |
+
path = resolve_path()
|
| 65 |
+
rows = load_rows(path)
|
| 66 |
+
passed = failed = skipped = 0
|
| 67 |
+
fails = []
|
| 68 |
+
for row in rows:
|
| 69 |
+
fam = row.get("family", "")
|
| 70 |
+
ans = row.get("answer")
|
| 71 |
+
if needs_judge(fam, ans):
|
| 72 |
+
skipped += 1
|
| 73 |
+
continue
|
| 74 |
+
score = grade_item(fam, gold_reply(row), ans)
|
| 75 |
+
if score == 1.0:
|
| 76 |
+
passed += 1
|
| 77 |
+
else:
|
| 78 |
+
failed += 1
|
| 79 |
+
fails.append((row.get("id"), fam, score))
|
| 80 |
+
print(f"file={path}")
|
| 81 |
+
print(f"summary: gold pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
|
| 82 |
+
for f in fails[:10]:
|
| 83 |
+
print("FAIL", *f)
|
| 84 |
+
return 0 if failed == 0 else 1
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
if __name__ == "__main__":
|
| 88 |
+
raise SystemExit(main())
|
verification_kit/grader_tamper.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Grader tamper check: gold replies must fail when the answer key is deliberately mutated."""
|
| 3 |
+
import copy
|
| 4 |
+
import json
|
| 5 |
+
import sys
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 9 |
+
sys.path.insert(0, str(ROOT / "environment" / "src"))
|
| 10 |
+
from binary_reasoning_v1.grading import _answer_symbol, grade_item, needs_judge, norm_symbol # noqa: E402
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def resolve_path():
|
| 14 |
+
if len(sys.argv) > 1:
|
| 15 |
+
return Path(sys.argv[1])
|
| 16 |
+
for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
|
| 17 |
+
if p.exists():
|
| 18 |
+
return p
|
| 19 |
+
raise SystemExit("no sample JSONL found; pass one as argv[1]")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def load_rows(path):
|
| 23 |
+
rows = []
|
| 24 |
+
for line in path.read_text(encoding="utf-8").splitlines():
|
| 25 |
+
if line.strip():
|
| 26 |
+
rows.append(json.loads(line))
|
| 27 |
+
return rows
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def parse_json_answer(ans):
|
| 31 |
+
if isinstance(ans, dict):
|
| 32 |
+
return ans
|
| 33 |
+
if isinstance(ans, str):
|
| 34 |
+
try:
|
| 35 |
+
obj = json.loads(ans)
|
| 36 |
+
if isinstance(obj, dict):
|
| 37 |
+
return obj
|
| 38 |
+
except Exception:
|
| 39 |
+
pass
|
| 40 |
+
return {}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def mutate_token(s):
|
| 44 |
+
s = str(s)
|
| 45 |
+
if not s:
|
| 46 |
+
return "RELAB_TAMPER"
|
| 47 |
+
mid = len(s) // 2
|
| 48 |
+
return f"{s[:mid]}_RELAB_TAMPER_{s[mid:]}"
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def gold_reply(row):
|
| 52 |
+
fam = row.get("family", "")
|
| 53 |
+
ans = row.get("answer")
|
| 54 |
+
if fam == "func_id_mc" and isinstance(ans, dict):
|
| 55 |
+
opts = ans.get("options", [])
|
| 56 |
+
correct = norm_symbol(ans.get("correct", ""))
|
| 57 |
+
for i, opt in enumerate(opts[:4]):
|
| 58 |
+
if norm_symbol(opt) == correct:
|
| 59 |
+
return "ABCD"[i]
|
| 60 |
+
return str(ans.get("correct", ""))
|
| 61 |
+
if fam == "toolchain_fp" and isinstance(ans, dict):
|
| 62 |
+
return "\n".join(str(s) for s in ans.get("toolchain_strings", []))
|
| 63 |
+
if fam == "crossarch_equivalence":
|
| 64 |
+
obj = parse_json_answer(ans)
|
| 65 |
+
if bool(obj.get("same")):
|
| 66 |
+
return f"Same function: {obj.get('symbol', '')}"
|
| 67 |
+
return "Not the same."
|
| 68 |
+
sym = _answer_symbol(ans)
|
| 69 |
+
return str(sym or ans or "")
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def tamper_answer(row):
|
| 73 |
+
fam = row.get("family", "")
|
| 74 |
+
ans = copy.deepcopy(row.get("answer"))
|
| 75 |
+
if fam == "func_id_mc" and isinstance(ans, dict):
|
| 76 |
+
opts = ans.get("options", [])
|
| 77 |
+
correct = norm_symbol(ans.get("correct", ""))
|
| 78 |
+
for opt in opts:
|
| 79 |
+
if norm_symbol(opt) != correct:
|
| 80 |
+
ans["correct"] = opt
|
| 81 |
+
return ans
|
| 82 |
+
ans["correct"] = f"{ans.get('correct', '')}_RELAB_TAMPER"
|
| 83 |
+
return ans
|
| 84 |
+
if fam == "toolchain_fp" and isinstance(ans, dict):
|
| 85 |
+
ans["toolchain_strings"] = [mutate_token(s) for s in ans.get("toolchain_strings", [])]
|
| 86 |
+
return ans
|
| 87 |
+
if fam == "library_ident":
|
| 88 |
+
return f"{ans}_RELAB_TAMPER"
|
| 89 |
+
if fam == "crossarch_equivalence":
|
| 90 |
+
obj = parse_json_answer(ans)
|
| 91 |
+
obj["same"] = not bool(obj.get("same"))
|
| 92 |
+
if isinstance(ans, str):
|
| 93 |
+
return json.dumps(obj)
|
| 94 |
+
return obj
|
| 95 |
+
if isinstance(ans, dict):
|
| 96 |
+
ans["symbol"] = f"{ans.get('symbol', '')}_RELAB_TAMPER"
|
| 97 |
+
ans["aliases"] = [f"{a}_RELAB_TAMPER" for a in ans.get("aliases", [])]
|
| 98 |
+
return ans
|
| 99 |
+
return f"{ans}_RELAB_TAMPER"
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def main():
|
| 103 |
+
path = resolve_path()
|
| 104 |
+
rows = load_rows(path)
|
| 105 |
+
passed = failed = skipped = 0
|
| 106 |
+
fails = []
|
| 107 |
+
for row in rows:
|
| 108 |
+
fam = row.get("family", "")
|
| 109 |
+
ans = row.get("answer")
|
| 110 |
+
if needs_judge(fam, ans):
|
| 111 |
+
skipped += 1
|
| 112 |
+
continue
|
| 113 |
+
score = grade_item(fam, gold_reply(row), tamper_answer(row))
|
| 114 |
+
if score < 1.0:
|
| 115 |
+
passed += 1
|
| 116 |
+
else:
|
| 117 |
+
failed += 1
|
| 118 |
+
fails.append((row.get("id"), fam, score))
|
| 119 |
+
print(f"file={path}")
|
| 120 |
+
print(f"summary: grader_tamper pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
|
| 121 |
+
for f in fails[:10]:
|
| 122 |
+
print("FAIL", *f)
|
| 123 |
+
return 0 if failed == 0 else 1
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
if __name__ == "__main__":
|
| 127 |
+
raise SystemExit(main())
|
verification_kit/leak_check.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Answer-leak audit: hidden answer labels/tokens should not appear in the model-facing input."""
|
| 3 |
+
import json
|
| 4 |
+
import re
|
| 5 |
+
import sys
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def resolve_path():
|
| 12 |
+
if len(sys.argv) > 1:
|
| 13 |
+
return Path(sys.argv[1])
|
| 14 |
+
for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
|
| 15 |
+
if p.exists():
|
| 16 |
+
return p
|
| 17 |
+
raise SystemExit("no sample JSONL found; pass one as argv[1]")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def load_rows(path):
|
| 21 |
+
rows = []
|
| 22 |
+
for line in path.read_text(encoding="utf-8").splitlines():
|
| 23 |
+
if line.strip():
|
| 24 |
+
rows.append(json.loads(line))
|
| 25 |
+
return rows
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def candidate_names(row):
|
| 29 |
+
ans = row.get("answer")
|
| 30 |
+
names = []
|
| 31 |
+
if isinstance(ans, dict):
|
| 32 |
+
if isinstance(ans.get("symbol"), str):
|
| 33 |
+
names.append(ans["symbol"])
|
| 34 |
+
if isinstance(ans.get("correct"), str):
|
| 35 |
+
names.append(ans["correct"])
|
| 36 |
+
for alias in ans.get("aliases", []):
|
| 37 |
+
if isinstance(alias, str):
|
| 38 |
+
names.append(alias)
|
| 39 |
+
for s in ans.get("toolchain_strings", []):
|
| 40 |
+
if isinstance(s, str):
|
| 41 |
+
names.append(s)
|
| 42 |
+
elif isinstance(ans, str) and re.fullmatch(r"[A-Za-z_][A-Za-z0-9_.]{4,}", ans):
|
| 43 |
+
# Exact-symbol / flag-style answers. Prose and JSON answers are handled by rubric/judge paths.
|
| 44 |
+
names.append(ans)
|
| 45 |
+
return [n for n in names if len(n) >= 4]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def main():
|
| 49 |
+
path = resolve_path()
|
| 50 |
+
rows = load_rows(path)
|
| 51 |
+
leaks = []
|
| 52 |
+
checked_rows = 0
|
| 53 |
+
ids = [row.get("id") for row in rows]
|
| 54 |
+
for row in rows:
|
| 55 |
+
candidates = candidate_names(row)
|
| 56 |
+
if candidates:
|
| 57 |
+
checked_rows += 1
|
| 58 |
+
surface = row.get("input", "")
|
| 59 |
+
for name in candidates:
|
| 60 |
+
if re.search(r"(?<![A-Za-z0-9_.])" + re.escape(name) + r"(?![A-Za-z0-9_])", surface):
|
| 61 |
+
leaks.append((row.get("id"), row.get("family"), name))
|
| 62 |
+
break
|
| 63 |
+
print(f"file={path}")
|
| 64 |
+
print(f"summary: leak_check items={len(rows)} unique_ids={len(set(ids))} checked_rows={checked_rows} leaks={len(leaks)}")
|
| 65 |
+
for l in leaks[:10]:
|
| 66 |
+
print("LEAK", *l)
|
| 67 |
+
return 0 if not leaks else 1
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
raise SystemExit(main())
|
verification_kit/random_wrong.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Random-wrong sanity check: a deliberately wrong deterministic reply should score 0."""
|
| 3 |
+
import json
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 8 |
+
sys.path.insert(0, str(ROOT / "environment" / "src"))
|
| 9 |
+
from binary_reasoning_v1.grading import _answer_symbol, grade_item, needs_judge, norm_symbol # noqa: E402
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def resolve_path():
|
| 13 |
+
if len(sys.argv) > 1:
|
| 14 |
+
return Path(sys.argv[1])
|
| 15 |
+
for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
|
| 16 |
+
if p.exists():
|
| 17 |
+
return p
|
| 18 |
+
raise SystemExit("no sample JSONL found; pass one as argv[1]")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def load_rows(path):
|
| 22 |
+
rows = []
|
| 23 |
+
for line in path.read_text(encoding="utf-8").splitlines():
|
| 24 |
+
if line.strip():
|
| 25 |
+
rows.append(json.loads(line))
|
| 26 |
+
return rows
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def parse_json_answer(ans):
|
| 30 |
+
if isinstance(ans, dict):
|
| 31 |
+
return ans
|
| 32 |
+
if isinstance(ans, str):
|
| 33 |
+
try:
|
| 34 |
+
obj = json.loads(ans)
|
| 35 |
+
if isinstance(obj, dict):
|
| 36 |
+
return obj
|
| 37 |
+
except Exception:
|
| 38 |
+
pass
|
| 39 |
+
return {}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def mutate_token(s):
|
| 43 |
+
s = str(s)
|
| 44 |
+
if not s:
|
| 45 |
+
return "RELAB_WRONG"
|
| 46 |
+
mid = len(s) // 2
|
| 47 |
+
return f"{s[:mid]}_RELAB_WRONG_{s[mid:]}"
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def wrong_reply(row):
|
| 51 |
+
fam = row.get("family", "")
|
| 52 |
+
ans = row.get("answer")
|
| 53 |
+
if fam == "func_id_mc" and isinstance(ans, dict):
|
| 54 |
+
opts = ans.get("options", [])
|
| 55 |
+
correct = norm_symbol(ans.get("correct", ""))
|
| 56 |
+
for i, opt in enumerate(opts[:4]):
|
| 57 |
+
if norm_symbol(opt) != correct:
|
| 58 |
+
return "ABCD"[i]
|
| 59 |
+
return "RELAB_WRONG"
|
| 60 |
+
if fam == "toolchain_fp" and isinstance(ans, dict):
|
| 61 |
+
parts = [mutate_token(s) for s in ans.get("toolchain_strings", []) if str(s)]
|
| 62 |
+
return "\n".join(parts) if parts else "RELAB_WRONG"
|
| 63 |
+
if fam == "library_ident":
|
| 64 |
+
ans_str = str(_answer_symbol(ans) or ans or "")
|
| 65 |
+
toks = [t for t in ans_str.split() if len(t) >= 2]
|
| 66 |
+
return " ".join(mutate_token(t) for t in toks) if toks else "RELAB_WRONG"
|
| 67 |
+
if fam == "crossarch_equivalence":
|
| 68 |
+
obj = parse_json_answer(ans)
|
| 69 |
+
if bool(obj.get("same")):
|
| 70 |
+
return "Not the same."
|
| 71 |
+
return "Same function: RELAB_WRONG"
|
| 72 |
+
sym = _answer_symbol(ans) or ans or ""
|
| 73 |
+
if row.get("family") == "agentic_flag_hunt":
|
| 74 |
+
return mutate_token(sym)
|
| 75 |
+
return f"{sym}_RELAB_WRONG"
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def main():
|
| 79 |
+
path = resolve_path()
|
| 80 |
+
rows = load_rows(path)
|
| 81 |
+
passed = failed = skipped = 0
|
| 82 |
+
fails = []
|
| 83 |
+
for row in rows:
|
| 84 |
+
fam = row.get("family", "")
|
| 85 |
+
ans = row.get("answer")
|
| 86 |
+
if needs_judge(fam, ans):
|
| 87 |
+
skipped += 1
|
| 88 |
+
continue
|
| 89 |
+
score = grade_item(fam, wrong_reply(row), ans)
|
| 90 |
+
if score == 0.0:
|
| 91 |
+
passed += 1
|
| 92 |
+
else:
|
| 93 |
+
failed += 1
|
| 94 |
+
fails.append((row.get("id"), fam, score))
|
| 95 |
+
print(f"file={path}")
|
| 96 |
+
print(f"summary: random_wrong pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
|
| 97 |
+
for f in fails[:10]:
|
| 98 |
+
print("FAIL", *f)
|
| 99 |
+
return 0 if failed == 0 else 1
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
if __name__ == "__main__":
|
| 103 |
+
raise SystemExit(main())
|