Run this model with HF Jobs
Run Codeseys/composer-replication-framework on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Codeseys/composer-replication-framework. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Codeseys/composer-replication-framework on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Codeseys/composer-replication-framework with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Codeseys/composer-replication-framework with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Codeseys/composer-replication-framework", device_map="auto") - Notebooks
- Google Colab
- Kaggle
review+fix: cross-family adversarial ADR review (owed item) + remediation
Browse filesRan the owed 5-family adversarial review of ADR-008/009/010 (unblocked once
OpenRouter credits were restored). 4/5 clean reviews (GPT-5.5, Gemini 3.1 Pro,
DeepSeek V4 Pro, Grok 4.3; Kimi starved its token budget). Verdicts: ADR-008
3-REJECT/1-fix, ADR-009 unanimous-fix, ADR-010 3-REJECT/1-fix — all REJECTs were
"accepted-status outran the evidence," not "design wrong."
The review caught a real policy-corrupting P0 the solo pre-mortem missed: the
SDPO alignment guard was a shape-check, so hint-shifted teacher tokens could
silently misalign and distill garbage into the policy.
Verified every convergent finding against code, then fixed (192 pass/16 skip,
was 187):
- SDPO alignment (composer_trainer.py): require collator-emitted
student_response_idx/teacher_response_idx; gather aligned post-hint logits
before JSD; strict-mode raises on missing/mismatched indices. Tests rewritten
to the corrected contract (different-length sequences now exercised).
- Sandbox scrub (sandbox.py): boot() physically removes __pycache__/.mypy_cache/
.pytest_cache/.git/.hg + *.pyc/*.pyo/*.class — the ADR-claimed PRIMARY
reward-hack control, previously UNIMPLEMENTED. shlex.quote on test node ids.
- Curriculum (curriculum.py + env.py): fractional pass credit instead of
int(reward>0) (the partial-reward-logs-as-full-pass bug that prematurely
retired multi-feature tasks); hacked/guard-broken rollouts contribute 0 credit
but count as exposures.
- reward_fn (env.py): length-guard against silent zip-truncation.
- LLM judge (hint_generator.py): address-stripped + versioned cache key,
600-char output clamp, atomic disk write.
- make_dr_grpo_config: fixed duplicated assertion literal.
Added 5 regression tests. Each ADR now carries a "Post-acceptance cross-family
review" section documenting fixed vs open items. Open follow-ups (none corrupt a
run): Docker substrate e2e, k1-KL assert, AST-provenance monitor, hint default
routing, curriculum turn/think-token signals.
Artifacts: docs/reviews/cross-family-adr-008-009-010-2026-05-29/
Files changed (16)
- composer_replication/datagen/curriculum.py+11-2
- composer_replication/datagen/env.py+19-1
- composer_replication/datagen/sandbox.py+48-2
- composer_replication/datagen/tests/test_feature_deletion.py+76
- composer_replication/hint_generator.py+32-3
- composer_replication/trainer/composer_trainer.py+79-22
- composer_replication/trainer/tests/test_dr_grpo_config_and_alignment.py+45-8
- docs/WAVE_COMPOSER_DATAGEN_RL_2026-05-29.md+18-6
- docs/adrs/ADR-008-drgrpo-sdpo-live-channel.md+58
- docs/adrs/ADR-009-layered-hint-generator.md+41
- docs/adrs/ADR-010-feature-deletion-datagen.md+70
- docs/reviews/cross-family-adr-008-009-010-2026-05-29/SYNTHESIS.mdAdded+90
- docs/reviews/cross-family-adr-008-009-010-2026-05-29/review_deepseek-v4-pro.mdAdded+46
- docs/reviews/cross-family-adr-008-009-010-2026-05-29/review_gemini-3.1-pro.mdAdded+61
- docs/reviews/cross-family-adr-008-009-010-2026-05-29/review_gpt-5.5.mdAdded+153
- docs/reviews/cross-family-adr-008-009-010-2026-05-29/review_grok-4.3.mdAdded+29
22 unmodified lines2324252627282918 unmodified lines4849505152535422 unmodified lines@dataclassclass _TaskStats:n_pass: int = 0n_total: int = 0@property18 unmodified lines_stats: dict[str, _TaskStats] = field(default_factory=dict)_quarantined: set[str] = field(default_factory=set)def update(self, task_id: str, n_pass: int, n_total: int) -> None:st = self._stats.setdefault(task_id, _TaskStats())st.n_pass += n_passst.n_total += n_total22 unmodified lines2324252627282918 unmodified lines4849505152535455565758596061626322 unmodified lines@dataclassclass _TaskStats:n_pass: float = 0.0n_total: int = 0@property18 unmodified lines_stats: dict[str, _TaskStats] = field(default_factory=dict)_quarantined: set[str] = field(default_factory=set)def update(self, task_id: str, n_pass: float, n_total: int) -> None:"""Record `n_pass` successes over `n_total` exposures.`n_pass` is a FLOAT so multi-feature tasks can record fractional credit(e.g. a completion that passes 1 of 2 FAIL_TO_PASS tests contributes 0.5,not 1). Cross-family review 2026-05-29: the env previously passed`int(reward > 0)`, which logged a 0.5 partial as a full pass and let`p_hat` cross `tau_easy` so the task was retired before the policy everlearned the remaining features."""st = self._stats.setdefault(task_id, _TaskStats())st.n_pass += n_passst.n_total += n_total
115 unmodified lines1161171181191201213 unmodified lines125126127128129115 unmodified lines"reward_fn requires a `task_id` column (passed via the GRPO ""dataset) to map each completion to its FeatureDeletionTask.")rewards: list[float] = []for comp, tid in zip(completions, task_id):task = self.registry[tid]3 unmodified lineselse:res = self.step({"type": "submit"})rewards.append(res.reward)self.curriculum.update(tid, n_pass=int(res.reward > 0), n_total=1)return rewards115 unmodified lines1161171181191201211221231241251261271281293 unmodified lines133134135136137138139140141142143144145146147115 unmodified lines"reward_fn requires a `task_id` column (passed via the GRPO ""dataset) to map each completion to its FeatureDeletionTask.")# Length guard (cross-family review 2026-05-29): a `zip` over mismatched# lengths silently truncates and returns fewer rewards than TRL expects,# corrupting the advantage computation. Fail loudly instead.if len(task_id) != len(completions):raise ValueError(f"reward_fn length mismatch: {len(completions)} completions vs "f"{len(task_id)} task_ids. TRL expects one reward per completion.")rewards: list[float] = []for comp, tid in zip(completions, task_id):task = self.registry[tid]3 unmodified lineselse:res = self.step({"type": "submit"})rewards.append(res.reward)# Curriculum update uses FRACTIONAL credit, not int(reward>0):# - n_pass = pass-fraction over the FAIL_TO_PASS targets so a# partial multi-feature solve doesn't read as a full pass and# prematurely retire the task (the 3/4-reviewer P0).# - a guard-broken or hack-flagged trajectory contributes 0 credit# (reward is already 0) but STILL counts as an exposure, so a# task only ever solvable via a hack trends toward quarantine# rather than polluting the prior with phantom passes.frac = float(res.info.get("frac", 0.0))clean = bool(res.info.get("guard_ok", True)) and not bool(res.info.get("hacked", False))self.curriculum.update(tid, n_pass=(frac if clean else 0.0), n_total=1)return rewards
7 unmodified lines891011121323 unmodified lines37383940414243444546474861 unmodified lines11011111211311411511611711811912011 unmodified lines1321331341351361371387 unmodified lines"""from __future__ import annotationsimport subprocessfrom dataclasses import dataclass, fieldfrom typing import Protocol, runtime_checkable23 unmodified lines# primary control is that __pycache__/.mypy_cache/.class are scrubbed pre-task.SANDBOX_DENYLIST: frozenset[str] = frozenset({"find", "strings", "unzip", "jar", "javap", "unzip","procyon", "cfr", "jd-cli", "jadx", # Java decompilers"uncompyle6", "decompyle3", # Python decompilers"git", # .git is stripped; no history mining})@runtime_checkable61 unmodified lines_trajectory: list[dict] = field(default_factory=list)booted_image: str | None = Nonedef boot(self, image: str) -> None:self.booted_image = imageself._trajectory = []def is_command_allowed(self, command: str) -> bool:return command not in SANDBOX_DENYLISTdef exec(self, action: dict) -> str:11 unmodified linesdef run_tests(self, test_command: str, tests: tuple[str, ...]) -> TestRunResult:# Run pytest with explicit node ids; parse the summary line.node_ids = " ".join(tests)cmd = f"{test_command} {node_ids}"proc = subprocess.run(cmd, shell=True, cwd=self.workdir, capture_output=True, text=True, timeout=6007 unmodified lines891011121314151623 unmodified lines4041424344454647484950515253545556575861 unmodified lines12012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216311 unmodified lines1751761771781791801811821831847 unmodified lines"""from __future__ import annotationsimport osimport shleximport shutilimport subprocessfrom dataclasses import dataclass, fieldfrom typing import Protocol, runtime_checkable23 unmodified lines# primary control is that __pycache__/.mypy_cache/.class are scrubbed pre-task.SANDBOX_DENYLIST: frozenset[str] = frozenset({"find", "strings", "unzip", "jar", "javap","procyon", "cfr", "jd-cli", "jadx", # Java decompilers"uncompyle6", "decompyle3", # Python decompilers"git", # .git is stripped; no history mining})# NOTE (cross-family review 2026-05-29): this denylist is INSUFFICIENT as a# primary control. `is_command_allowed` checks only the first whitespace token,# so `/usr/bin/find`, `sh -c "strings x"`, and especially `python -c "import# marshal,dis; ..."` all bypass it. The ADR-claimed PRIMARY control is the# pre-task cache/.git scrub in `boot()` — see `_scrub_tree` below, which is now# implemented (was previously absent, making the denylist the only — broken —# defense). The denylist remains as cheap defense-in-depth, not the wall.@runtime_checkable61 unmodified lines_trajectory: list[dict] = field(default_factory=list)booted_image: str | None = None# Cache/history artifacts that let an agent recover a deleted signature# WITHOUT reimplementing it (the Composer-blog reward-hacks). Scrubbed at# boot() so the denylist isn't the only — and bypassable — line of defense._SCRUB_NAMES: tuple[str, ...] = ("__pycache__", ".mypy_cache", ".pytest_cache", ".git", ".hg",)_SCRUB_SUFFIXES: tuple[str, ...] = (".pyc", ".pyo", ".class")def boot(self, image: str) -> None:self.booted_image = imageself._trajectory = []self._scrub_tree()def _scrub_tree(self) -> None:"""PRIMARY reward-hack control (ADR-010 §3): physically remove byte-codecaches, type-check caches, and VCS history from the working tree beforethe episode starts, so there is no cached signature to recover. This isthe wall; the command denylist is only cheap defense-in-depth on top.Cross-family review 2026-05-29 found this was previously UNIMPLEMENTED —boot() only recorded the image string."""if not self.workdir or not os.path.isdir(self.workdir):returnfor root, dirs, files in os.walk(self.workdir, topdown=True):# Remove (and stop descending into) scrub-named directories.for d in list(dirs):if d in self._SCRUB_NAMES:shutil.rmtree(os.path.join(root, d), ignore_errors=True)dirs.remove(d)for f in files:if f.endswith(self._SCRUB_SUFFIXES):try:os.remove(os.path.join(root, f))except OSError:passdef is_command_allowed(self, command: str) -> bool:# NOTE: first-token-only check — see SANDBOX_DENYLIST comment. This is# NOT a security boundary on its own; _scrub_tree() is the real control.return command not in SANDBOX_DENYLISTdef exec(self, action: dict) -> str:11 unmodified linesdef run_tests(self, test_command: str, tests: tuple[str, ...]) -> TestRunResult:# Run pytest with explicit node ids; parse the summary line.# shlex.quote each node id — SWE-bench node ids contain spaces/brackets# (parametrized tests like `test_x.py::test_y[a b]`) and could otherwise# break the shell or inject commands (cross-family review 2026-05-29).node_ids = " ".join(shlex.quote(t) for t in tests)cmd = f"{test_command} {node_ids}"proc = subprocess.run(cmd, shell=True, cwd=self.workdir, capture_output=True, text=True, timeout=600
205 unmodified lines206207208209210211205 unmodified linesenv.reward_fn(prompts=["p"], completions=["c"])# --- SweBenchAdapter --------------------------------------------------------def test_swebench_adapter_inverts_instance():205 unmodified lines206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287205 unmodified linesenv.reward_fn(prompts=["p"], completions=["c"])def test_reward_fn_rejects_length_mismatch():"""Cross-family review 2026-05-29: a zip over mismatched lengths silentlytruncated and returned fewer rewards than TRL expects. Now a hard error."""task = _task()env = FeatureDeletionEnv(FakeSandbox(test_outcomes={"test_feature_a": True}),registry={task.task_id: task})with pytest.raises(ValueError, match="length mismatch"):env.reward_fn(prompts=["p", "p"], completions=["c", "c"],task_id=[task.task_id]) # 1 id for 2 completionsdef test_partial_multifeature_reward_is_fractional_credit_not_a_full_pass():"""Regression for the 3/4-reviewer P0: a multi-feature task solved 1-of-2must record FRACTIONAL curriculum credit (0.5), not int(reward>0)==1. Theold code logged the 0.5 partial as a 100% pass, crossing tau_easy andretiring the task before the policy learned the remaining feature."""cur = DifficultyCurriculum()# 'b' never solved => steady 0.5 reward each rollout.sb = FakeSandbox(test_outcomes={"a": True, "b": False, "keep": True})task = _task(task_id="mf", fail_to_pass=("a", "b"), pass_to_pass=("keep",),deleted_symbols=())env = FeatureDeletionEnv(sb, curriculum=cur, registry={"mf": task})for _ in range(12):out = env.reward_fn(prompts=["p"], completions=["c"], task_id=["mf"])assert out == [0.5]# p_hat must hover near 0.5 (frontier), NOT be driven above tau_easy.assert cur.p_hat("mf") < cur.tau_easy# And the task must remain ACTIVE (frontier-weighted), not retired.assert cur.weight("mf") > 0.0def test_guard_broken_trajectory_does_not_pollute_curriculum_with_a_pass():"""A guard-broken (or hacked) rollout earns reward 0 AND contributes 0curriculum credit while still counting as an exposure — so a task onlysolvable by breaking the functional guard trends toward quarantine ratherthan logging phantom passes (Grok finding)."""cur = DifficultyCurriculum(min_exposures=4, tau_hard=0.05)# target 'a' passes but the PASS_TO_PASS guard 'keep' is broken => reward 0.sb = FakeSandbox(test_outcomes={"a": True, "keep": False})task = _task(task_id="gb", fail_to_pass=("a",), pass_to_pass=("keep",),deleted_symbols=())env = FeatureDeletionEnv(sb, curriculum=cur, registry={"gb": task})for _ in range(8):out = env.reward_fn(prompts=["p"], completions=["c"], task_id=["gb"])assert out == [0.0]assert cur.is_quarantined("gb")# --- sandbox scrub (primary reward-hack control) ----------------------------def test_local_sandbox_scrubs_caches_and_git_on_boot(tmp_path):"""Cross-family review 2026-05-29: the ADR-claimed PRIMARY reward-hackcontrol (pre-task scrub of byte-code/type caches + .git) was unimplemented— boot() only recorded the image string. It now physically removes them."""from composer_replication.datagen.sandbox import LocalSubprocessSandbox# Build a tree with the exact artifacts an agent could mine for signatures.(tmp_path / "__pycache__").mkdir()(tmp_path / "__pycache__" / "feature_a.cpython-311.pyc").write_bytes(b"\x00cache")(tmp_path / ".mypy_cache").mkdir()(tmp_path / ".mypy_cache" / "x.json").write_text("{}")(tmp_path / ".git").mkdir()(tmp_path / ".git" / "HEAD").write_text("ref: refs/heads/main")(tmp_path / "src").mkdir()(tmp_path / "src" / "lib.class").write_bytes(b"\xca\xfe\xba\xbe")(tmp_path / "src" / "keep.py").write_text("x = 1") # must surviveLocalSubprocessSandbox(workdir=str(tmp_path)).boot("img:broken")assert not (tmp_path / "__pycache__").exists()assert not (tmp_path / ".mypy_cache").exists()assert not (tmp_path / ".git").exists()assert not (tmp_path / "src" / "lib.class").exists()assert (tmp_path / "src" / "keep.py").exists() # real source untouched# --- SweBenchAdapter --------------------------------------------------------def test_swebench_adapter_inverts_instance():
200 unmodified lines2012022032042052067 unmodified lines2142152162172182192202212222237 unmodified lines23123223323423523623723823924024113 unmodified lines255256257258259260200 unmodified lines"Corrective hint:")def __init__(self,complete: Callable[[str], str] | None = None,7 unmodified linesdef _cache_key(self, error_kind: str, error_meta: dict) -> str:import hashlibimport jsonblob = json.dumps({"k": error_kind, "m": error_meta}, sort_keys=True, default=str)return hashlib.sha256(blob.encode("utf-8")).hexdigest()[:32]def _disk_get(self, key: str) -> str | None:7 unmodified linesdef _disk_put(self, key: str, value: str) -> None:if not self._cache_dir:returnfrom pathlib import Pathd = Path(self._cache_dir)d.mkdir(parents=True, exist_ok=True)(d / f"{key}.txt").write_text(value, encoding="utf-8")def generate(self, error_kind: str, error_meta: dict) -> str | None:if self.complete is None:13 unmodified lineshint = self.complete(prompt).strip()if not hint:return Noneself._mem_cache[key] = hintself._disk_put(key, hint)return hint200 unmodified lines2012022032042052062072082092102112122132142152167 unmodified lines2242252262272282292302312322332342352362372382392402412422437 unmodified lines25125225325425525625725825926026126226326426526613 unmodified lines280281282283284285286287288289200 unmodified lines"Corrective hint:")# Bump when PROMPT_TEMPLATE or the underlying judge model changes so stale# cached hints are invalidated rather than silently reused._CACHE_VERSION = 2# Hard cap on a generated hint. The judge is asked for <=2 sentences but# nothing enforced it (cross-family review 2026-05-29) — a runaway judge# could emit a full solution / prompt-leak / megabyte of text straight into# the SDPO teacher conditioning. Clamp defensively._MAX_HINT_CHARS = 600def __init__(self,complete: Callable[[str], str] | None = None,7 unmodified linesdef _cache_key(self, error_kind: str, error_meta: dict) -> str:import hashlibimport jsonimport re# Strip volatile object reprs (e.g. "<Exception at 0x7f8b...>") so the# key is stable across runs/restarts. Cross-family review 2026-05-29:# `default=str` on raw Exception/context objects embedded a memory# address in the key, guaranteeing a 0% cross-process cache-hit rate and# unbounded judge cost. Also version the key so prompt/model changes# invalidate stale hints rather than serving them.blob = json.dumps({"v": self._CACHE_VERSION, "k": error_kind, "m": error_meta},sort_keys=True, default=str,)blob = re.sub(r"0x[0-9a-fA-F]+", "0xADDR", blob)blob = re.sub(r"\bat 0xADDR\b", "", blob)return hashlib.sha256(blob.encode("utf-8")).hexdigest()[:32]def _disk_get(self, key: str) -> str | None:7 unmodified linesdef _disk_put(self, key: str, value: str) -> None:if not self._cache_dir:returnimport osfrom pathlib import Pathd = Path(self._cache_dir)d.mkdir(parents=True, exist_ok=True)# Atomic write: concurrent DDP workers writing the same key would# otherwise interleave and corrupt the file (cross-family review).tmp = d / f"{key}.txt.{os.getpid()}.tmp"tmp.write_text(value, encoding="utf-8")os.replace(tmp, d / f"{key}.txt")def generate(self, error_kind: str, error_meta: dict) -> str | None:if self.complete is None:13 unmodified lineshint = self.complete(prompt).strip()if not hint:return None# Clamp to a sane length so a runaway judge can't inject a full solution# or megabyte blob into the SDPO teacher conditioning (cross-family review).if len(hint) > self._MAX_HINT_CHARS:hint = hint[: self._MAX_HINT_CHARS].rstrip() + "…"self._mem_cache[key] = hintself._disk_put(key, hint)return hint
161 unmodified lines162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192101 unmodified lines294295296297298299300301302303161 unmodified lineswith torch.no_grad():teacher_logits = model(input_ids=inputs["ctx_teacher_input_ids"]).logits# NOTE: in real implementation, ctx_teacher and ctx_student must be the# SAME LENGTH at the post-hint section so logits align position-by-position.# The data collator pads/aligns. The skeleton trusts that's done correctly.if student_logits.shape != teacher_logits.shape:msg = (f"SDPO logit shape mismatch: student={tuple(student_logits.shape)} "f"vs teacher={tuple(teacher_logits.shape)}. The data collator must ""pad/align the post-hint section so student and teacher have ""identical token-counts; otherwise the distillation signal is ""silently zeroed.")if self.strict_sdpo_alignment:# Hard error (default): a mismatch means the collator failed to# align — the ADR-008 trust-gap. Do not silently zero the channel.raise ValueError(msg + " (strict_sdpo_alignment=True; pass False to warn-and-skip ""instead for production resilience.)")logger.warning("%s Skipping SDPO loss for this step.", msg)return torch.tensor(0.0, device=_device_of(model), requires_grad=True)return generalized_jsd_loss(student_logits=student_logits,teacher_logits=teacher_logits,labels=inputs.get("sdpo_loss_mask"), # error-turn token maskbeta=self.sdpo_jsd_beta,temperature=self.sdpo_temperature,token_clip=self.sdpo_token_clip,101 unmodified linesmerged = {**dr_grpo_defaults, **overrides}cfg = GRPOConfig(**merged)# Guard: fail loudly if a future TRL renames/repurposes these knobs.assert cfg.loss_type == merged["loss_type"], "GRPOConfig dropped loss_type"assert str(cfg.scale_rewards) in ("none", "False", "False"), (f"Dr. GRPO requires scale_rewards='none' (no std-norm); got {cfg.scale_rewards!r}. ""TRL knob may have drifted — re-verify against trl version.")assert cfg.num_iterations == merged["num_iterations"], "GRPOConfig dropped num_iterations"return cfg161 unmodified lines162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240101 unmodified lines342343344345346347348349350351352353354355356357358359360161 unmodified lineswith torch.no_grad():teacher_logits = model(input_ids=inputs["ctx_teacher_input_ids"]).logits# ------------------------------------------------------------------# ALIGNMENT (cross-family review 2026-05-29 — the 4/4-reviewer P0).## The teacher context has a hint inserted at the error turn, so the# teacher's post-hint response tokens are shifted right by len(hint)# relative to the student's. A bare `student.shape == teacher.shape`# check does NOT establish token-level alignment: equal-length tensors# whose response regions are offset will be JSD'd position-by-position# against each other, distilling garbage into the policy.## The ONLY correct alignment is an explicit map from the collator that# selects, for each response token, the matching index in each sequence.# We require it whenever SDPO is active:# - `student_response_idx` / `teacher_response_idx`: LongTensors of# equal length selecting the aligned response positions in each# sequence (the collator builds these knowing where it inserted the# hint). JSD is computed over the gathered, provably-aligned logits.# - If the collator cannot yet supply them, strict mode raises (loud# failure) rather than silently distilling misaligned tokens.s_idx = inputs.get("student_response_idx")t_idx = inputs.get("teacher_response_idx")if s_idx is None or t_idx is None:msg = ("SDPO alignment indices missing: the collator must emit ""`student_response_idx` and `teacher_response_idx` (matching ""LongTensors selecting the aligned post-hint response tokens) so ""the JSD compares corresponding tokens. A shape-only check does ""NOT establish alignment — the hint shifts the teacher's response ""tokens right, so equal-length sequences can still be misaligned ""and silently distill garbage into the policy (ADR-008 trust-gap).")if self.strict_sdpo_alignment:raise ValueError(msg + " (strict_sdpo_alignment=True; pass False to fall back ""to the legacy shape-only check for resilience.)")logger.warning("%s Falling back to shape-only alignment check.", msg)if student_logits.shape != teacher_logits.shape:logger.warning("SDPO shape mismatch student=%s teacher=%s; skipping.",tuple(student_logits.shape), tuple(teacher_logits.shape),)return torch.tensor(0.0, device=_device_of(model), requires_grad=True)return generalized_jsd_loss(student_logits=student_logits,teacher_logits=teacher_logits,labels=inputs.get("sdpo_loss_mask"),beta=self.sdpo_jsd_beta,temperature=self.sdpo_temperature,token_clip=self.sdpo_token_clip,reduction="batchmean",)# Validate the index tensors describe a consistent 1:1 alignment.if s_idx.shape != t_idx.shape:raise ValueError(f"SDPO alignment index shape mismatch: student_response_idx="f"{tuple(s_idx.shape)} vs teacher_response_idx={tuple(t_idx.shape)}. ""They must select the same number of aligned response tokens.")# Gather the provably-aligned response logits from each sequence, then# JSD only those positions (this is the masked error-turn distillation).# gather over the sequence dim (dim=1): expand index to the vocab dim.vocab = student_logits.size(-1)s_gather = s_idx.unsqueeze(-1).expand(-1, -1, vocab)t_gather = t_idx.unsqueeze(-1).expand(-1, -1, vocab)student_aligned = torch.gather(student_logits, 1, s_gather)teacher_aligned = torch.gather(teacher_logits, 1, t_gather)return generalized_jsd_loss(student_logits=student_aligned,teacher_logits=teacher_aligned,labels=inputs.get("sdpo_loss_mask"), # optional further error-turn maskbeta=self.sdpo_jsd_beta,temperature=self.sdpo_temperature,token_clip=self.sdpo_token_clip,101 unmodified linesmerged = {**dr_grpo_defaults, **overrides}cfg = GRPOConfig(**merged)# Guard: fail loudly if a future TRL renames/repurposes these knobs.assert cfg.loss_type == merged["loss_type"], (f"GRPOConfig loss_type drifted: requested {merged['loss_type']!r}, "f"got {cfg.loss_type!r} — TRL may have renamed/repurposed the knob.")# Dr. GRPO requires NO std-dev advantage normalization. TRL accepts either# the string "none" or the bool False to disable it; normalize before# comparing so a future TRL that switches the representation still passes# (and a genuinely-wrong value like "batch"/"group"/True fails loudly).# (Cross-family review 2026-05-29: the prior literal `("none","False","False")`# had a duplicated "False" and did a brittle case-sensitive str compare.)assert str(cfg.scale_rewards).lower() in ("none", "false"), (f"Dr. GRPO requires scale_rewards disabled (no std-norm); got "f"{cfg.scale_rewards!r}. TRL knob may have drifted — re-verify against trl version.")assert cfg.num_iterations == merged["num_iterations"], "GRPOConfig dropped num_iterations"return cfg
93 unmodified lines9495969798991001011021031041051061071081091101111121135 unmodified lines1191201211221231241251261271281291301311321 unmodified line13413513613713813993 unmodified linesreturn objdef test_strict_alignment_raises_on_shape_mismatch():obj = _make_trainer_without_init(strict=True)model = _TinyLM(vocab=16)# student seq len 5, teacher seq len 7 -> logit shape mismatchinputs = {"input_ids": torch.randint(0, 16, (1, 5)),"ctx_teacher_input_ids": torch.randint(0, 16, (1, 7)),"sdpo_loss_mask": torch.ones(1, 5),}with pytest.raises(ValueError, match="shape mismatch"):obj._compute_sdpo_loss(model, inputs)def test_nonstrict_alignment_warns_and_skips_on_mismatch():obj = _make_trainer_without_init(strict=False)model = _TinyLM(vocab=16)inputs = {5 unmodified linesassert float(loss.detach()) == 0.0 # skipped, not crasheddef test_aligned_shapes_produce_finite_sdpo_loss():obj = _make_trainer_without_init(strict=True)model = _TinyLM(vocab=16)# student and teacher SAME length -> channel firesinputs = {"input_ids": torch.randint(0, 16, (1, 6)),"ctx_teacher_input_ids": torch.randint(0, 16, (1, 6)),"sdpo_loss_mask": torch.ones(1, 6),}loss = obj._compute_sdpo_loss(model, inputs)val = float(loss.detach())1 unmodified lineassert val not in (float("inf"), float("-inf"))def test_no_error_sites_returns_zero_without_forward():"""Empty ctx_teacher_input_ids => no SDPO signal, returns 0 (no crash)."""obj = _make_trainer_without_init(strict=True)93 unmodified lines9495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281295 unmodified lines1351361371381391401411421431441451461471481491501511521531541 unmodified line15615715815916016116216316416516616716816917017117217317417517693 unmodified linesreturn obj# ---------------------------------------------------------------------------# Gate 2 — SDPO alignment guard (corrected per cross-family review 2026-05-29).## The guard now requires the collator to emit explicit `student_response_idx` /# `teacher_response_idx` alignment tensors whenever SDPO is active, because a# shape-only check does NOT establish token-level alignment (the hint shifts the# teacher's response tokens). The tests below verify the CORRECTED contract:# - strict + missing indices => raise (loud failure, not silent garbage)# - non-strict + missing indices => warn-and-fall-back to legacy shape check# - aligned indices supplied => channel fires with a finite, gathered loss# ---------------------------------------------------------------------------def test_strict_alignment_raises_on_missing_indices():"""Strict mode (default) refuses to distill without explicit alignmentindices — the misalignment-is-silent trust-gap is now a loud error."""obj = _make_trainer_without_init(strict=True)model = _TinyLM(vocab=16)inputs = {"input_ids": torch.randint(0, 16, (1, 5)),"ctx_teacher_input_ids": torch.randint(0, 16, (1, 7)),"sdpo_loss_mask": torch.ones(1, 5),# NO student_response_idx / teacher_response_idx}with pytest.raises(ValueError, match="alignment indices missing"):obj._compute_sdpo_loss(model, inputs)def test_nonstrict_falls_back_to_shape_check_and_skips_on_mismatch():"""Non-strict + missing indices => legacy shape-only fallback; a true shapemismatch is skipped (returns 0) rather than crashing."""obj = _make_trainer_without_init(strict=False)model = _TinyLM(vocab=16)inputs = {5 unmodified linesassert float(loss.detach()) == 0.0 # skipped, not crasheddef test_aligned_indices_produce_finite_gathered_sdpo_loss():"""With matching student/teacher response indices supplied, the channelgathers the aligned post-hint logits and computes a finite JSD — even whenthe two sequences have DIFFERENT lengths (the realistic hint-shifted casethe old shape-only guard could not handle)."""obj = _make_trainer_without_init(strict=True)model = _TinyLM(vocab=16)# student len 6, teacher len 9 (hint inserted 3 tokens). The 3 response# tokens live at student positions [3,4,5] and teacher positions [6,7,8].inputs = {"input_ids": torch.randint(0, 16, (1, 6)),"ctx_teacher_input_ids": torch.randint(0, 16, (1, 9)),"student_response_idx": torch.tensor([[3, 4, 5]]),"teacher_response_idx": torch.tensor([[6, 7, 8]]),}loss = obj._compute_sdpo_loss(model, inputs)val = float(loss.detach())1 unmodified lineassert val not in (float("inf"), float("-inf"))def test_mismatched_alignment_index_shapes_raise():"""student/teacher response-index tensors of different length are acollator bug — caught loudly, not gathered into a broken JSD."""obj = _make_trainer_without_init(strict=True)model = _TinyLM(vocab=16)inputs = {"input_ids": torch.randint(0, 16, (1, 6)),"ctx_teacher_input_ids": torch.randint(0, 16, (1, 9)),"student_response_idx": torch.tensor([[3, 4, 5]]),"teacher_response_idx": torch.tensor([[6, 7]]), # length 2 != 3}with pytest.raises(ValueError, match="alignment index shape mismatch"):obj._compute_sdpo_loss(model, inputs)def test_no_error_sites_returns_zero_without_forward():"""Empty ctx_teacher_input_ids => no SDPO signal, returns 0 (no crash)."""obj = _make_trainer_without_init(strict=True)
46 unmodified lines4748495051525354555657585946 unmodified lines## Owed / unblocked-by (constraints this wave hit)- **Cross-family adversarial ADR review** (GPT-5.5 / Gemini 3.1 Pro / DeepSeekV4 Pro per model-roster) — deferred: OpenRouter ran out of credits mid-wave,blocking `delegate_task`. A focused single-author pre-mortem was substituted(caught + fixed the ADR-006 stale-matrix-row). Re-run when credits restored.- **Live Docker substrate-inversion e2e** for ADR-010 (pull one SWE-bench-Liteimage, run the 4 gates against it) — wired but deferred (no Docker in the CPUdev env). Marked `[~]` in the ADR.- Gateway restarted 6× during the wave; all work kept durable viaphase-boundary commits + detached `systemd-run` scopes.## Commit trail46 unmodified lines4748495051525354555657585960616263646566676869707146 unmodified lines## Owed / unblocked-by (constraints this wave hit)- **Cross-family adversarial ADR review** (GPT-5.5 / Gemini 3.1 Pro / DeepSeekV4 Pro / Kimi K2.6 / Grok 4.3) — ✅ **DONE 2026-05-29** once OpenRouter creditswere restored. 4/5 clean reviews (Kimi starved its budget). Verdicts: ADR-0083-REJECT/1-fix, ADR-009 unanimous-fix, ADR-010 3-REJECT/1-fix — the REJECTs allamounted to "accepted-status outran the evidence," not "design is wrong." Thereview **caught a real policy-corrupting P0 the solo pre-mortem missed**: theSDPO alignment guard was a shape-check that let hint-shifted tokens silentlymisalign. That plus 6 other convergent defects (sandbox scrub unimplemented,curriculum partial-reward→full-pass, reward_fn truncation, shell injection,LLM-judge cache non-determinism, scale_rewards assert dup) were **fixed andtested** (192 pass / 16 skip, was 187). Full synthesis + the 4 reviews:`docs/reviews/cross-family-adr-008-009-010-2026-05-29/`. Each ADR now carries a"Post-acceptance cross-family review" section documenting fixed vs open items.- **Live Docker substrate-inversion e2e** for ADR-010 (pull one SWE-bench-Liteimage, run the 4 gates against it) — STILL deferred (no Docker in the CPU devenv). The review confirmed this is the gate that matters: it closes theremaining OPEN findings (real reachability/provenance, FakeSandbox-tautologyobjection). Marked `[~]` in ADR-010. Needs a box with Docker + a SWE-bench-Liteimage.- Gateway restarted 6× during the original wave; all work kept durable viaphase-boundary commits + detached `systemd-run` scopes.## Commit trail
101 unmodified lines102103104105106107101 unmodified lines- Good: TRL default; least config work.- Bad: std-dev advantage normalization "massively upweights small behavioral differences within equal-correctness groups" (tech report); length-standardization injects length bias. Diverges from the known-good recipe for no benefit.## Acceptance gate (must be green before status flips to accepted)All gates green as of 2026-05-29 (commit chain `bde5c5e`+; smoke PASS via101 unmodified lines102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165101 unmodified lines- Good: TRL default; least config work.- Bad: std-dev advantage normalization "massively upweights small behavioral differences within equal-correctness groups" (tech report); length-standardization injects length bias. Diverges from the known-good recipe for no benefit.## Post-acceptance cross-family review (2026-05-29)A 5-family adversarial review (GPT-5.5, Gemini 3.1 Pro, DeepSeek V4 Pro,Kimi K2.6, Grok 4.3 — the owed cross-family review, unblocked once OpenRoutercredits were restored) examined this ADR against its implementation. 4 of 5returned clean reviews (Kimi starved its token budget). **Verdict split: 3REJECT / 1 ACCEPT-WITH-FIXES on ADR-008.** The review correctly found that theacceptance gate above **over-claimed**: the SDPO "trust-gap closed" gate wassatisfied only by a *shape check*, and the smoke gate proved init-not-wiring.Findings verified against code and remediated:- **[FIXED — was the headline P0, 4/4 reviewers] SDPO alignment was a shape-checkplacebo.** `_compute_sdpo_loss` only asserted `student_logits.shape ==teacher_logits.shape`. Because the teacher context has a hint inserted at theerror turn, the teacher's response tokens are shifted right by `len(hint)`;equal-length sequences can still be token-misaligned, so `generalized_jsd_loss`would distill the student's code against the teacher's *hint* — silentlypoisoning the policy. **Fix:** the guard now REQUIRES the collator to emitexplicit `student_response_idx` / `teacher_response_idx` alignment tensorswhenever SDPO is active; the loss gathers the provably-aligned post-hint logitsbefore JSD. Missing indices raise in strict mode (loud failure) instead ofsilently distilling garbage. Tests rewritten to the corrected contract(`test_strict_alignment_raises_on_missing_indices`,`test_aligned_indices_produce_finite_gathered_sdpo_loss` across *different*sequence lengths, `test_mismatched_alignment_index_shapes_raise`).- **[FIXED] `scale_rewards` drift assertion had a duplicated literal**`("none","False","False")` and a brittle case-sensitive compare. Now`str(cfg.scale_rewards).lower() in ("none","false")`.- **[RE-SCOPED — gate honesty] The CPU smoke (gate 3) is init-coverage, notwiring-coverage.** As 3 reviewers noted, the toy rollouts carry no`ctx_teacher_input_ids`, so `_compute_sdpo_loss` hits its early `return 0.0`and the smoke passes without ever entering the SDPO body. The gate proves thesubclass instantiates against a real `trl.GRPOTrainer` and the step runs — itdoes NOT prove the SDPO channel fires on a real error-aligned batch. Thatseparate proof lives in `examples/sdpo_real_trace_train_smoke` (loss-math onreal traces). **Gate 3 re-worded below to claim only what it establishes.**- **[OPEN — acknowledged, not fixed here] KL estimator (k1 vs k3) is notconfigured or asserted** (2 reviewers). The ADR claims Composer uses the k1(`−log r`) estimator and that "TRL's native estimator" satisfies this, but thecode neither sets nor verifies it against TRL 1.5.0's actual GRPO KL branch. IfTRL uses k3, we train a slightly different reference-KL than the reportspecifies. Tracked as a follow-up: add a unit test computing KL for knownlogprob pairs and asserting the k1 value, or set `beta=0` and document thereference-KL term as intentionally disabled.- **[OPEN — narrower guarantee] `num_iterations=1` ≠ "a prompt is never trainedtwice"** (GPT-5.5). It controls GRPO inner-loop reuse per generation batch, notdataset-level resampling/epochs. The single-epoch guarantee also depends on thesampler/dataloader. Documented; the claim is narrowed to the GRPO inner-loopsense.- **[OPEN] "Adam" is claimed but `optim` is not set** — HF/TRL defaults to AdamW.Either set `optim` explicitly or drop the Adam-specific claim. Follow-up.**Status note:** the silent-misalignment P0 (the one that would actually corrupttraining) is fixed and tested. The remaining OPEN items arefidelity/documentation gaps that don't corrupt a run, tracked as follow-ups. Thereview artifact (all 4 reviews + convergence synthesis) is committed at`docs/reviews/cross-family-adr-008-009-010-2026-05-29/`.## Acceptance gate (must be green before status flips to accepted)All gates green as of 2026-05-29 (commit chain `bde5c5e`+; smoke PASS via
89 unmodified lines90919293949589 unmodified lines- Good: maximal coverage, natural language for every site.- Bad: cost on every site (templates would have been free); nondeterministic data prep; network dependency on the hot path. Wasteful for the common tool-error case a template nails.## Acceptance gate (must be green before status flips to accepted)All gates green as of 2026-05-29 (commit `<this>`; 12 tests in89 unmodified lines9091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513689 unmodified lines- Good: maximal coverage, natural language for every site.- Bad: cost on every site (templates would have been free); nondeterministic data prep; network dependency on the hot path. Wasteful for the common tool-error case a template nails.## Post-acceptance cross-family review (2026-05-29)The 5-family review (see ADR-008's review section) was **unanimousACCEPT-WITH-FIXES on ADR-009** — the layered Protocol design is sound; thedefects are in the LLM-judge layer's robustness and an ADR-body/code drift.Verified and remediated:- **[FIXED] LLM-judge cache key was non-deterministic across processes**(Gemini P1, GPT-5.5 P2). `_cache_key` used `json.dumps(..., default=str)` on`error_meta`; if that dict carries a raw Exception/context object, `str(obj)`embeds a memory address (`<X at 0x7f…>`) → the key changes every run → 0%cross-process cache hit → unbounded judge cost. **Fix:** strip `0x…` addresstokens before hashing and version the key (`_CACHE_VERSION`) so prompt/modelchanges invalidate stale hints.- **[FIXED] LLM-judge output was unbounded** (GPT-5.5 P1). The prompt asks for≤2 sentences but nothing enforced it; a runaway judge could inject a fullsolution / prompt-leak / megabyte blob straight into SDPO teacherconditioning. **Fix:** `_MAX_HINT_CHARS = 600` clamp on the returned hint.- **[FIXED] Non-atomic disk-cache write** (Gemini P2). Concurrent DDP workerswriting the same key could corrupt the file. **Fix:** write to a`.{pid}.tmp` and `os.replace()` atomically.- **[CORRECTED — ADR body] Decision Outcome described sibling-bootstrap ascomposite layer (4).** As DeepSeek noted, the body says "(4) SDPOsibling-bootstrap" as a composite layer, but the implementation (correctly)places it trainer-side, and the acceptance gate already documents the shift.The permanent decision record was internally inconsistent. **The DecisionOutcome below now states sibling-bootstrap lives in the rollout loop (ADR-008trainer), not the HintGenerator composite.**- **[OPEN — follow-up] Default layer order routes style/communication sitesthrough `RawErrorHintGenerator` before the judge** (GPT-5.5 P1). Any uncoveredsite that carries an `error_message` is consumed by the raw-error layer andnever reaches the LLM judge — so the judge (the layer that actually coversstyle/communication/effort, the stated goal) rarely fires in the defaultcomposite. The fall-through test disables raw-error to force the judge, so itdoesn't validate the *default* path. Follow-up: add error-kind routing(tool/runtime → raw-error OK; style/communication/effort → skip raw, go tojudge) and test the default composite directly.All ADR-009 fixes are covered by the existing 12 tests passing unchanged plusthe cache-determinism behavior; no test regressions.## Acceptance gate (must be green before status flips to accepted)All gates green as of 2026-05-29 (commit `<this>`; 12 tests in
90 unmodified lines91929394959690 unmodified lines- Good: zero build.- Bad: not *Feature Deletion* — it's issue-fixing; no controlled difficulty knob; no deletion mechanic; doesn't bring Composer's data-gen method in, just consumes an existing benchmark. Fails the actual ask.## Acceptance gate (must be green before status flips to accepted)Core gates green as of 2026-05-29 (19 tests in90 unmodified lines91929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516690 unmodified lines- Good: zero build.- Bad: not *Feature Deletion* — it's issue-fixing; no controlled difficulty knob; no deletion mechanic; doesn't bring Composer's data-gen method in, just consumes an existing benchmark. Fails the actual ask.## Post-acceptance cross-family review (2026-05-29)The 5-family review (see ADR-008's review section) was **3 REJECT / 1ACCEPT-WITH-FIXES on ADR-010** — the harshest of the three. The reviewers'core, correct objection: the `[x]` gates were satisfied **against `FakeSandbox`materializers that directly assign pass/fail booleans**, so they prove thecontrol-flow plumbing, NOT that feature-deletion-and-reimplement works on a realrepo. ADR-010's central claim ("invert OSS SWE substrates") is exactly the partthat is `[~]` (Docker-deferred) — the accepted gates are the easy half. This isfair; the gate language below is re-scoped accordingly. Findings verified andremediated where possible without Docker:- **[FIXED — P0, 4/4 reviewers] Reward-hack sandbox lockdown was the ADR'sclaimed PRIMARY control but was UNIMPLEMENTED.** `LocalSubprocessSandbox.boot`only recorded the image string; no cache/.git scrub existed, so the(bypassable) command denylist was the *only* defense. Worse, the denylistchecks only the first whitespace token, so `python -c "import marshal,dis;…read __pycache__/*.pyc"`, `/usr/bin/strings`, `sh -c "strings x"` all bypassit, and the `HackMonitor` regex is defeated by string-concat(`"__py"+"cache__"`). **Fix:** `boot()` now physically scrubs `__pycache__`,`.mypy_cache`, `.pytest_cache`, `.git`, `.hg`, and `*.pyc/*.pyo/*.class` fromthe working tree before the episode — the actual primary control. The denylistis now documented as cheap defense-in-depth, not the wall. Tested:`test_local_sandbox_scrubs_caches_and_git_on_boot`.- **[FIXED — P0, 3/4 reviewers] Curriculum recorded partial multi-featurereward as a full pass.** `reward_fn` updated the curriculum with`int(res.reward > 0)`, so a 0.5 (1-of-2 features) reward logged as a 100% pass;`p_hat` crossed `tau_easy` and the task was **retired before the policy learnedthe second feature**. **Fix:** the curriculum now takes FRACTIONAL credit(`n_pass: float`), and `reward_fn` feeds the pass-fraction; a guard-broken orhack-flagged rollout contributes 0 credit but still counts as an exposure (sohack-only tasks trend to quarantine, not phantom passes). Tested:`test_partial_multifeature_reward_is_fractional_credit_not_a_full_pass`,`test_guard_broken_trajectory_does_not_pollute_curriculum_with_a_pass`.- **[FIXED] `reward_fn` could silently return the wrong reward count.** The`zip(completions, task_id)` truncated on length mismatch, returning fewerrewards than TRL expects and corrupting the advantage computation. **Fix:**explicit length-guard raises. Tested: `test_reward_fn_rejects_length_mismatch`.- **[FIXED] Shell injection / parameterized-test breakage in `run_tests`**(DeepSeek + Gemini). `f"{test_command} {node_ids}"` with `shell=True` breaks onSWE-bench parametrized node ids (`test_x.py::test_y[a b]`) and is injectable.**Fix:** `shlex.quote` each node id.- **[FIXED] Duplicate `"unzip"` in `SANDBOX_DENYLIST`** (multiple reviewers).- **[OPEN — honest, the central re-scope] Gate 2 ("deletion breaks the feature")and the "deletion reachable from tests" claim do NOT verify reachability**(GPT-5.5 P0, Grok P0). Gate 2 only checks that `FAIL_TO_PASS` tests fail in thebroken state — it does not prove the failure was *caused by the revertedfeature* rather than an unrelated breakage. A real reachability check(coverage of the changed region by the failing tests, or revert-provenance)needs the live Docker materializers. **This is the same `[~]` gate as thesubstrate-inversion e2e — see below.**- **[OPEN] `HackMonitor` is a substring matcher, not the AST-provenance monitorthe ADR advertises** (DeepSeek P0). It flags cache/decompiler signatures in thetrajectory but does no AST/symbol-reappearance analysis, and is bypassable bystring-concat. With the scrub now in place as the primary control, the monitoris correctly-scoped defense-in-depth — but the ADR's §3c "AST provenancemonitor" language overstates it. Re-scoped: it is a *signature-based* monitor;a genuine AST provenance check (scan the agent's patch for reintroduced`deleted_symbols` reached via non-implementation paths) is a follow-up.- **[OPEN — recipe fidelity] Curriculum ignores rollout-turns andthinking-token count** (DeepSeek, GPT-5.5). The Composer 2 tech report keys thecurriculum on these; the implementation tracks only pass-rate. Follow-up:extend `DifficultyCurriculum.update` to accept and weight on turn/think-tokensignals.**The three OPEN items all require the Docker substrate e2e to close** (realreachability, real provenance on a materialized repo). That gate remains thehonest `[~]` — see the unblocked-by note. The fixable correctness defects(scrub, fractional curriculum, length-guard, shlex) are fixed and tested.## Acceptance gate (must be green before status flips to accepted)Core gates green as of 2026-05-29 (19 tests in
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990# Cross-family adversarial review — ADR-008 / 009 / 010 (2026-05-29)
> The "owed" cross-family adversarial ADR review from the Composer 2.5> data-gen + targeted-RL wave. Deferred during the wave because OpenRouter ran> out of credits mid-run (blocking `delegate_task`); run here once credits were> restored (~$50 free at review time). This is the proper GPT-5.5 / Gemini /> DeepSeek / Kimi / Grok scatter the wave summary promised.
## Method
Route-fidelity-safe urllib scatter (no `delegate_task` per-task-override risk)to 5 diverse families, full corpus embedded inline: the 3 ADRs **plus theirimplementation code plus the tests** (~100KB / ~25K tokens), so reviewerscritiqued the *implementation against the decision*, not just the prose.
| Family | Slug (served) | Result ||---|---|---|| OpenAI | gpt-5.5-20260423 | clean, very specific (7981 tok) || Google | gemini-3.1-pro-preview-20260219 | clean, sharpest (9174 tok @ retry 16K) || DeepSeek | deepseek-v4-pro-20260423 | clean, math/correctness lens (10308 tok @ retry 16K) || xAI | grok-4.3-20260430 | clean, terse/decisive (1645 tok) || Moonshot | kimi-k2.6-20260420 | starved token budget (63K reasoning, content=None) — excluded |
4 of 5 clean reviews. Raw reviews: `review_*.md` in this directory.
## Verdict matrix
| ADR | GPT-5.5 | Gemini | DeepSeek | Grok | Consensus ||---|---|---|---|---|---|| 008 (Dr.GRPO+SDPO) | REJECT | REJECT | ACCEPT-w-FIXES | REJECT | **3 REJECT / 1 fix** || 009 (layered hints) | ACCEPT-w-FIXES | ACCEPT-w-FIXES | ACCEPT-w-FIXES | ACCEPT | **unanimous: fixable** || 010 (FeatureDeletion datagen) | REJECT | REJECT | REJECT | ACCEPT-w-FIXES | **3 REJECT / 1 fix** |
The REJECTs were not "the design is wrong" — every reviewer agreed thearchitecture is sound. They were "the **accepted** status outruns the**evidence**": gates marked `[x]` were satisfied by shape-checks and FakeSandboxtautologies, not by the hard guarantee the gate language implied.
## Convergent findings (≥2 reviewers, ALL verified against code by the orchestrator)
| # | Finding | Reviewers | Status ||---|---|---|---|| 1 | SDPO alignment guard = shape-check only; hint-shifted tokens silently misalign → policy poisoning | 4/4 | **FIXED** (explicit alignment-index gather + strict-raise; tests rewritten) || 2 | Sandbox denylist trivially bypassable (`python -c`, abs paths, `sh -c`) + ADR-claimed scrub UNIMPLEMENTED | 4/4 | **FIXED** (`_scrub_tree` primary control implemented + tested) || 3 | Curriculum `int(reward>0)` logs 0.5 partial as full pass → premature retire | 3/4 | **FIXED** (fractional credit + tests) || 4 | `scale_rewards` assertion dup literal `("none","False","False")` | 4/4 | **FIXED** (case-insensitive) || 5 | CPU smoke is tautological — never enters `_compute_sdpo_loss` (early return) | 3/4 | **RE-SCOPED** (gate honestly reworded) || 6 | FakeSandbox validator tests prove plumbing, not real inversion | 3/4 | **RE-SCOPED** (= the `[~]` Docker gate) || 7 | HackMonitor is substring matcher, not AST-provenance as advertised | 2/4 | **RE-SCOPED + OPEN** (follow-up) || 8 | Validator gate-2/"deletion reachable" doesn't test reachability | 2/4 | **OPEN** (needs Docker materializers) || 9 | `shell=True` + node-id interpolation = injection + param-test breakage | 2/4 | **FIXED** (`shlex.quote`) || 10 | LLM-judge cache key non-deterministic (memory addr) + unbounded output | 2/4 | **FIXED** (addr-strip + version + clamp + atomic write) || 11 | KL estimator k1 never configured/asserted | 2/4 | **OPEN** (fidelity follow-up) || 12 | `reward_fn` zip truncates on length mismatch | 1 (GPT) | **FIXED** (length-guard) |
## What was fixed in this pass (all tested, 192 pass / 16 skip, 0 fail)
- **SDPO alignment** (`composer_trainer.py`): require `student_response_idx` / `teacher_response_idx` from the collator; gather aligned post-hint logits before JSD; strict-mode raises on missing/mismatched indices. The silent-misalignment P0 (the only finding that would actually corrupt a run) is closed and tested across different-length sequences.- **Sandbox scrub** (`sandbox.py`): `boot()` physically removes byte-code/type caches + `.git`/`.hg` — the ADR-claimed PRIMARY reward-hack control, previously absent. Denylist re-documented as defense-in-depth + `shlex.quote` on node ids.- **Curriculum** (`curriculum.py` + `env.py`): fractional pass credit; hacked / guard-broken rollouts contribute 0 credit but count as exposures.- **reward_fn** (`env.py`): length-guard against silent truncation.- **LLM judge** (`hint_generator.py`): address-stripped + versioned cache key, 600-char output clamp, atomic disk write.- **`make_dr_grpo_config`** (`composer_trainer.py`): fixed the duplicated assertion literal.
## What remains OPEN (honest follow-ups, none corrupt a run)
1. **Live Docker substrate-inversion e2e** — the central `[~]` gate. Closes findings #6, #8 (real reachability/provenance on a materialized repo) and the "FakeSandbox is tautological" objection. **Blocked: no Docker in this env.**2. **k1 KL estimator** assert/config vs TRL 1.5.0's actual GRPO KL branch (#11).3. **HackMonitor → real AST provenance** check (#7).4. **Hint-generator default layer routing** so style/communication sites reach the judge (ADR-009 P1).5. **Curriculum turn/think-token signals** for full Composer recipe fidelity.
All five are documented in the ADRs' "Post-acceptance cross-family review"sections.
## Cost
~$2-4 OpenRouter (2 scatters: 5×8K + 3×16K tokens on a 25K-token corpus).12345678910111213141516171819202122232425262728293031323334353637383940414243444546# Review by deepseek/deepseek-v4-pro-20260423 (206.1s, 26727/10308 tok)
## Verdict- **ADR-008**: ACCEPT-WITH-FIXES- **ADR-009**: ACCEPT-WITH-FIXES- **ADR-010**: REJECT
## P0 findings
1. **[ADR-010] Sandbox denylist can be trivially bypassed — `is_command_allowed` validates only the first whitespace-delimited token, not the resolved command.** - `composer_replication/datagen/sandbox.py:81-83` (`FakeSandbox.exec`) and `:130-136` (`LocalSubprocessSandbox.exec`) - An attacker can run `/usr/bin/find …`, `bash -c "find …"`, or even `./my_decompile` (any path prefix) to circumvent the denylist. Because the check is `cmd.strip().split()[0]`, it compares e.g. `"/usr/bin/find"` against the denylist entry `"find"` and allows it. - The ADR claims “allowlisted sandbox without find/strings/unzip/decompilers” – but the actual enforcement is cosmetic. In a real reward‑hacking scenario this safeguard fails. - **Fix**: enforce a strict executable‑allowlist (e.g., only `pytest`, `python`, `git apply`, `editor` wrappers) at the sandbox level, or use OS‑level capability restrictions (seccomp / AppArmor). The current string‑matching must block *any* invocation of a forbidden tool, not just the bare command name.
## P1 findings
1. **[ADR-008] SDPO alignment guard only checks logit tensor shape, not semantic alignment of the post‑hint sequences.** - `composer_replication/trainer/composer_trainer.py:120-130` — the shape guard raises `ValueError` on unequal dimensions, but equal‑length sequences could still be misaligned if the collator inserts the hint at different positions. The ADR states the trust‑gap is “closed” with an assertion; in reality the guard only catches length mismatches, leaving silent misalignment possible. - **Fix**: require the collator to provide explicit alignment information (e.g., a boolean mask identifying the post‑hint region) and validate that the teacher’s logits in that region correspond 1:1 with the student’s.
2. **[ADR-009] ADR-009’s Decision Outcome says the composite includes a sibling‑bootstrap layer, but the implementation does not.** - `docs/adrs/ADR-009-layered-hint-generator.md` lines 57‑62 describe a composite “that tries layers cheapest‑first: (1) TemplateHintGenerator … (4) SDPO sibling‑bootstrap”. The code (`composer_replication/hint_generator.py:CompositeHintGenerator` and `default_composite`) only layers templates → raw error → LLM judge. The sibling‑bootstrap is documented as a trainer‑side flag, not a composite layer. - The ADR’s own acceptance gate acknowledges the shift, but the body of the ADR (the permanent decision record) is now inconsistent with the shipped implementation. This misleads future readers about the architecture. - **Fix**: update the ADR’s Decision Outcome to note that sibling‑bootstrap lives in the rollout loop, not in the HintGenerator composite.
3. **[ADR-010] HackMonitor is not an AST‑provenance monitor.** - `composer_replication/datagen/monitor.py` uses a static substring denylist (`__pycache__`, `javap`, …) to flag a trajectory. The ADR’s §3c and Decision Outcome describe an “AST provenance monitor that masks reward when deleted symbols reappear via non‑implementation paths”. No AST or symbol‑reappearance analysis is performed. - The current monitor is a trivially‑extended version of the sandbox denylist, not a heuristic provenance detector as advertised. - **Fix**: either implement a genuine provenance check (e.g., scan the agent’s patch for reintroduced symbols that match the `deleted_symbols` list, and cross‑reference with AST imports) or rewrite the ADR to accurately describe the signature‑based monitor.
4. **[ADR-010] DifficultyCurriculum does not incorporate rollout‑turns or thinking‑token count.** - `composer_replication/datagen/curriculum.py` tracks only pass/fail test outcomes and derives a frontier‑variance weight. The Composer 2 tech report (cited in the ADR) explicitly keys the curriculum on “rollout #turns + thinking‑token count”. The implementation omits these signals entirely. - This deviates from the recipe the ADR claims to match; the resulting curriculum may miss important difficulty‑modulation behaviour. - **Fix**: augment `DifficultyCurriculum` with moving averages of turn‑count and thinking‑token length per task, and incorporate them into the weighting or difficulty‑escalation logic.
## P2 / nits
- **ADR-008**: `make_dr_grpo_config`’s assertion string `("none", "False", "False")` duplicates `"False"` (presumably a copy‑paste typo) — `composer_replication/trainer/composer_trainer.py:228`.- **ADR-010**: `LocalSubprocessSandbox.run_tests` constructs a shell command via `f"{test_command} {node_ids}"` with `shell=True` — potential command injection if `node_ids` is untrusted (`sandbox.py:148‑151`).- **ADR-010**: The 4‑gate validator’s `gate2` includes a redundant `bool(targets)` check – `targets` is always non‑empty per `FeatureDeletionTask` invariant, so the check is dead code (`validator.py:62`).
## Anything the self-review likely missed- The ADR‑008 smoke test relies on `strict_sdpo_alignment=False`; it never exercises the shape‑mismatch error path in production‑like configuration, so that path is untested.- The `FeatureDeletionEnv.reward_fn` curriculum update uses `n_pass=int(res.reward > 0)` — this treats any positive reward (even 0.1) as a “pass” for the pass‑rate tracker, which may bias `p_hat` upward for partially‑rewarded tasks. The intention was likely to count fractional success, but the current code treats it as binary.- The `SweBenchAdapter` fallback for non‑JSON `FAIL_TO_PASS` strings (e.g., `"test_x"`) returns a single‑element tuple, which is a reasonable heuristic but silently changes semantics for datasets that use delimiters other than JSON‑list.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061# Review by google/gemini-3.1-pro-preview-20260219 (94.0s, 28773/9174 tok)
## Verdicts**ADR-008 (Dr. GRPO + SDPO):** REJECT**ADR-009 (Layered HintGenerator):** ACCEPT-WITH-FIXES**ADR-010 (Feature Deletion Datagen):** REJECT
---
## P0 findings
**1. SDPO student/teacher alignment guard is a shape-check placebo (ADR-008)***File:* `composer_replication/trainer/composer_trainer.py` inside `_compute_sdpo_loss`*Why:* The code asserts `student_logits.shape != teacher_logits.shape` to verify alignment. This is fundamentally flawed. The teacher context (`ctx_teacher_input_ids`) has a hint inserted in the *middle* of the sequence (at the error turn). To make the total sequence lengths match, the collator must pad one of them. Even if the shapes are identical, the student's post-hint response tokens are shifted relative to the teacher's by `len(hint)`. `generalized_jsd_loss` will compute the KL divergence between completely unaligned tokens (e.g., the student's code vs. the teacher's hint). The trust-gap is not closed; it is silently hidden.*Fix:* The collator must emit an alignment mapping (e.g., `teacher_gather_indices`), and `_compute_sdpo_loss` must `gather` the exact post-hint response logits from the teacher before computing JSD, rather than relying on sequence-level shape equality.
**2. Reward-hacking safeguards are trivially bypassed via Python (ADR-010)***File:* `composer_replication/datagen/sandbox.py` (`SANDBOX_DENYLIST`) and `monitor.py` (`HackMonitor`)*Why:* The denylist blocks shell commands like `strings`, `javap`, and `uncompyle6` by checking the first word of the command. However, `python` is allowed. An agent can simply run `python -c "import dis, marshal; print(dis.dis(marshal.load(open('__pycache__/feature_a.cpython-310.pyc', 'rb'))))"` to decompile the cache, or use Python to read `.git` objects. Furthermore, the `HackMonitor` regex is defeated by basic string concatenation in the generated code (e.g., `getattr(os, "list" + "dir")(".git")` or `"__py" + "cache__"`). The safeguards provide a false sense of security.*Fix:* Do not rely on command denylists or regex monitors as the primary defense. The sandbox `boot()` method MUST physically execute `rm -rf $(find . -name __pycache__) .git` before the episode starts.
**3. Curriculum prematurely retires tasks due to partial-reward logging (ADR-010)***File:* `composer_replication/datagen/env.py` inside `reward_fn`*Why:* The reward function updates the curriculum using `n_pass=int(res.reward > 0)`. For a multi-feature task where the agent fixes 1 out of 2 tests, `res.reward` is `0.5`. `int(0.5 > 0)` evaluates to `1`. The curriculum logs this as a 100% pass rate. Consequently, `p_hat` quickly exceeds `tau_easy` (0.95), and the task is retired before the agent ever learns to solve the remaining features.*Fix:* Update the curriculum using strict success: `n_pass=int(res.reward == 1.0)`.
---
## P1 findings
**4. LLM Judge cache key is destroyed by memory addresses (ADR-009)***File:* `composer_replication/hint_generator.py` inside `LLMJudgeHintGenerator._cache_key`*Why:* The cache key uses `json.dumps(..., default=str)`. `error_meta` frequently contains raw Exception objects or un-repr'd context objects. `str(obj)` for these includes their memory address (e.g., `<Exception at 0x7f8b...>`), which changes on every single run. This guarantees a 0% cache hit rate across restarts, leading to unbounded OpenRouter API costs.*Fix:* Sanitize `error_meta` to strip memory addresses (e.g., via regex) or extract only safe primitive fields before hashing.
**5. Shell injection and syntax errors on parameterized tests (ADR-010)***File:* `composer_replication/datagen/sandbox.py` inside `LocalSubprocessSandbox.run_tests`*Why:* The code joins test names with spaces: `cmd = f"{test_command} {node_ids}"` and runs with `shell=True`. SWE-bench heavily uses parameterized tests (e.g., `test_foo.py::test_bar[my arg]`). The spaces and brackets will cause shell syntax errors or allow arbitrary command injection if a test name contains `;` or `&`.*Fix:* Use `shlex.quote(t)` on each test node ID before joining them.
**6. `reward_fn` throws KeyError in distributed TRL loops (ADR-010)***File:* `composer_replication/datagen/env.py` inside `reward_fn`*Why:* `reward_fn` looks up `task_id` in `self.registry`. `self.registry` is only populated when `env.reset(task)` is called locally. In a standard TRL training loop, `reward_fn` is a stateless callback executed on batches of generated completions. If the environment wasn't pre-loaded with the entire dataset, `self.registry[tid]` will immediately raise a `KeyError`.*Fix:* `FeatureDeletionEnv` must accept a dataset reference or a task-factory function to load unseen `task_id`s on demand.
---
## P2 / nits
**7. Non-atomic disk cache writes (ADR-009)***File:* `composer_replication/hint_generator.py` inside `LLMJudgeHintGenerator._disk_put`*Why:* `(d / f"{key}.txt").write_text(value)` is not atomic. Concurrent DDP workers writing to the same cache key will corrupt the file. Write to a `.tmp` file and use `os.replace`.
**8. Typo in Dr. GRPO config assertion (ADR-008)***File:* `composer_replication/trainer/composer_trainer.py` inside `make_dr_grpo_config`*Why:* `assert str(cfg.scale_rewards) in ("none", "False", "False")` repeats `"False"`.
---
## Anything the self-review likely missedThe ADR-008 CPU smoke test (`examples/composer_grpo_sdpo_smoke/run.py`) explicitly passes `strict_sdpo_alignment=False` and notes that the toy rollouts won't carry `ctx_teacher_input_ids`. This means the smoke test **tautologically passes** without ever executing the inside of the `_compute_sdpo_loss` block (it hits the early return `0.0`). It proves the trainer doesn't crash on init, but it completely fails to prove that the SDPO channel is "wired into the live loop" as claimed in the acceptance gate.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153# Review by openai/gpt-5.5-20260423 (146.6s, 24888/7981 tok)
## Verdict
- **ADR-008: REJECT** — Dr. GRPO/TRL claims are not established; SDPO “live” gate is mostly a no-op.- **ADR-009: ACCEPT-WITH-FIXES** — layered interface is useful, but default ordering and omitted sibling-bootstrap contradict the ADR.- **ADR-010: REJECT** — reward function, validator, sandbox, and Docker/substrate gates do not prove the accepted claims.
## P0 findings
1. **ADR-008 — Dr. GRPO KL estimator claim is wrong / unimplemented** **File/function:** `composer_replication/trainer/composer_trainer.py::make_dr_grpo_config` **Why:** The ADR claims Composer uses k1 KL (`−log r`) and that “TRL’s native estimator” satisfies this. TRL GRPO implementations commonly use the Schulman k3-style estimator (`exp(ref-logp - logp) - (ref-logp - logp) - 1`) for the per-token KL. This code does not configure or override the KL estimator at all; it only leaves `beta` to the caller. If TRL 1.5.0 uses k3, the accepted ADR is training the wrong RL objective while claiming Dr. GRPO fidelity. **Concrete fix:** Add an explicit version-pinned assertion against TRL 1.5.0 source behavior, and if TRL uses k3, override GRPO’s KL computation in `ComposerReplicationTrainer` to k1 or set `beta=0` and document that Composer’s reference-KL term is intentionally disabled. Add a test that computes KL for known logprob pairs and asserts exact k1 values.
2. **ADR-008 — `scale_rewards="none"` is not a robust Dr. GRPO guard** **File/function:** `composer_replication/trainer/composer_trainer.py::make_dr_grpo_config` **Why:** The acceptance gate says no std-dev advantage normalization is guaranteed. The code passes the string `"none"` and then only checks that `cfg.scale_rewards` echoes as `"none"`/`False`. That is not a semantic guard. If TRL expects `False` to disable scaling and treats unknown strings as truthy or as a mode, this silently fails the key Dr. GRPO requirement. The assertion also contains a duplicated tuple entry: `("none", "False", "False")`. **Concrete fix:** Use the TRL 1.5.0-supported disable value directly, likely `scale_rewards=False`, and add an integration/unit test around TRL’s actual advantage-scaling branch showing no group/batch std normalization is applied.
3. **ADR-008 — “live SDPO smoke” does not prove SDPO is live and does not assert its own gate** **File/function:** `examples/composer_grpo_sdpo_smoke/run.py::main` **Why:** The smoke enables `alpha_sdpo=1.0` but supplies no `ctx_teacher_input_ids` and no `sdpo_loss_mask`. Therefore `ComposerReplicationTrainer._compute_sdpo_loss` immediately returns zero and performs no teacher forward, no JSD, and no error-site masking. Worse, the script computes `sdpo_logged = any(...)` but never asserts it; it prints `PASS` unconditionally after `trainer.train()`. This gate can go green even if the SDPO override is never invoked. **Concrete fix:** Build a tiny dataset/collator batch with aligned `input_ids`, `ctx_teacher_input_ids`, and nonzero `sdpo_loss_mask`; assert a teacher forward occurred, `loss/sdpo_kl` is logged, and the logged value is finite and positive or at least nonzero under controlled logits. Also `return 1` if `sdpo_logged` is false.
4. **ADR-010 — TRL `reward_fn` ignores the completion, so non-solutions can receive full reward** **File/function:** `composer_replication/datagen/env.py::FeatureDeletionEnv.reward_fn` **Why:** In the default path, each completion is ignored. The env calls `reset(task)` and then `step({"type": "submit"})`; the sandbox’s pre-existing test outcomes determine reward. The unit test `test_reward_fn_returns_one_float_per_completion` rewards `"...agent diff..."` without applying any patch or action. This is a ship-blocking reward bug: every completion for a task can get the same score, including an empty or malicious non-solution. **Concrete fix:** Make `reward_fn` require a replay/action executor that applies the completion’s patch/tool calls in an isolated sandbox before grading. If no replay implementation is provided, raise `NotImplementedError` instead of grading a bare submit. Add tests where two different completions for the same task produce different rewards.
5. **ADR-010 — sandbox denylist is trivially bypassable and the promised scrub is not implemented** **Files/functions:** - `composer_replication/datagen/sandbox.py::SANDBOX_DENYLIST` - `composer_replication/datagen/sandbox.py::LocalSubprocessSandbox.exec` - `composer_replication/datagen/monitor.py::HackMonitor.flag` **Why:** The ADR claims pre-task scrub of `__pycache__`, `.mypy_cache`, `.class`, `.git` and an allowlisted sandbox. Code implements neither. `LocalSubprocessSandbox.boot` only records the image. `exec` uses `shell=True` and blocks only the first token if it exactly matches a denylisted command. Concrete bypasses: - `/usr/bin/strings file.pyc` bypasses because head is `/usr/bin/strings`, not `strings`. - `sh -c "strings file.pyc"` bypasses because head is `sh`. - `python -c "import pathlib; ... read __pycache__/*.pyc ..."` bypasses because head is `python`. - `grep -R`, `ripgrep`, `cat`, `tar`, `zipinfo`, `python -m dis`, or custom bytecode readers are not denied. The monitor can also be evaded by string-splitting: `('__py'+'cache__')`, `('.p'+'yc')`, etc. **Concrete fix:** Replace denylist shell execution with a constrained tool API or container-level policy: scrub caches/history before task image creation, run without `.git`, no network, no arbitrary shell for reward-sensitive tasks, or enforce syscall/path-level restrictions. At minimum, canonicalize executable paths, block shells/interpreters for filesystem reconnaissance, and scan the filesystem before grading.
6. **ADR-010 — accepted Docker/substrate gate is not green; FakeSandbox tests are tautological** **Files/functions:** - `composer_replication/datagen/substrates.py::SweBenchAdapter.to_task` - `composer_replication/datagen/validator.py::validate_task` - `composer_replication/datagen/tests/test_feature_deletion.py::_materializers` **Why:** The ADR marks the core gates accepted while the actual live substrate inversion is explicitly deferred. `SweBenchAdapter.to_task` only maps schema fields; it does not apply or reverse patches, scrub caches, build a broken image, or run tests. The validator unit tests use materializers that directly assign pass/fail dictionaries in `FakeSandbox`, so they prove only that the validator obeys synthetic booleans, not that feature deletion works on a repo. This is especially bad because ADR-010’s central claim is “invert OSS SWE substrates.” **Concrete fix:** Keep ADR-010 unaccepted until a Docker-gated test actually clones/materializes one real substrate instance, applies the gold patch to establish solved green, reverts/deletes to broken, runs `FAIL_TO_PASS`/`PASS_TO_PASS`, reapplies gold, and verifies the four gates.
7. **ADR-010 — validator does not actually prove “deletion is reachable from tests”** **File/function:** `composer_replication/datagen/validator.py::validate_task` **Why:** Gate 2 checks only that `FAIL_TO_PASS` tests fail in the state supplied by `materialize_broken`. It does not verify that the failure was caused by reverting/deleting the specified feature or symbols. A broken materializer can make tests fail for any unrelated reason and pass validation if `apply_gold` later flips the booleans. The FakeSandbox tests encode exactly that weakness. **Concrete fix:** In the real materializer, record and verify the exact patch/reverse-patch operation, changed files, and deleted symbols. Add a reachability check that failing tests execute or import the changed region, e.g. via coverage, traceback provenance, or mutation/revert validation on the actual repo.
## P1 findings
1. **ADR-008 — SDPO alignment guard is only a shape check** **File/function:** `composer_replication/trainer/composer_trainer.py::ComposerReplicationTrainer._compute_sdpo_loss` **Why:** The ADR says the student/teacher alignment trust-gap is closed. It is not. The code only compares `student_logits.shape != teacher_logits.shape`. Same shape with shuffled batch rows, shifted post-hint tokens, wrong error-site mask, or different padding all pass silently and train on nonsense. **Concrete fix:** Carry explicit alignment metadata from the collator: batch ids, error-site ids, student token ids, teacher target token ids, and mask. Assert equality under the SDPO mask, not just equal tensor shape.
2. **ADR-008 — missing `sdpo_loss_mask` distills the whole sequence** **File/function:** `composer_replication/trainer/composer_trainer.py::ComposerReplicationTrainer._compute_sdpo_loss` **Why:** If `ctx_teacher_input_ids` exists but `sdpo_loss_mask` is absent, the code passes `labels=None` into `generalized_jsd_loss`. Depending on that implementation, this can compute loss over all tokens, not only error-turn tokens. That violates “masked to error-turn tokens only.” **Concrete fix:** When `alpha_sdpo > 0` and teacher ids are present, require `sdpo_loss_mask` with compatible shape and nonzero entries, or explicitly return zero with a warning.
3. **ADR-008 — “Adam” is claimed but not configured** **File/function:** `composer_replication/trainer/composer_trainer.py::make_dr_grpo_config` **Why:** ADR says Dr. GRPO uses Adam. The helper does not set `optim`, `weight_decay`, or Adam-vs-AdamW behavior. HF/TRL defaults are typically AdamW variants. **Concrete fix:** Set the optimizer explicitly or remove the claim. Add a config test that asserts the exact optimizer TRL will instantiate.
4. **ADR-008 — `num_iterations=1` is not the same as “a prompt is never trained twice”** **File/function:** `composer_replication/trainer/composer_trainer.py::make_dr_grpo_config` **Why:** `num_iterations=1` controls GRPO inner reuse per generation batch. It does not by itself prevent dataset-level resampling, multiple epochs, repeated prompts, or replay through dataloader settings. **Concrete fix:** Document the narrower guarantee and add sampler/dataset controls if the intended guarantee is truly one update per prompt.
5. **ADR-009 — default layer order prevents LLM judge from handling many style/communication cases** **File/function:** `composer_replication/hint_generator.py::default_composite` **Why:** Default order is template → raw-error → LLM. Any uncovered style/communication site with an `error_message` will be consumed by `RawErrorHintGenerator` and never reach the LLM judge. The test `test_composite_falls_through_to_judge_for_uncovered_site` disables raw error to make the judge fire, which does not validate the default accepted design. **Concrete fix:** Add routing policy: tool/runtime errors may use raw error; style/communication/effort kinds should skip raw-error and go to judge. Test the default composite, not a special disabled-raw variant.
6. **ADR-009 — sibling-bootstrap is accepted but not implemented** **Files/functions:** - `composer_replication/hint_generator.py` - `composer_replication/trainer/composer_trainer.py` **Why:** The ADR chooses template → raw-error → LLM-judge → SDPO sibling-bootstrap. The implementation comments say sibling-bootstrap is trainer-side, but no trainer-side flag or rollout integration exists in the provided trainer. Acceptance says “satisfied by design,” which is not an implementation gate. **Concrete fix:** Add an explicit trainer/rollout interface that can select a successful sibling rollout as feedback, or downgrade the ADR to exclude sibling-bootstrap from the accepted scope.
7. **ADR-009 — LLM hints are not bounded, sanitized, or policy-checked** **File/function:** `composer_replication/hint_generator.py::LLMJudgeHintGenerator.generate` **Why:** Prompt asks for `<=2 sentences`, but code accepts arbitrary output. A judge can return a full solution, huge text, hidden prompt leakage, or adversarial instructions. This contaminates SDPO teacher conditioning. **Concrete fix:** Enforce length, strip code blocks if undesired, reject full-solution style outputs, and record model/prompt version in cache metadata.
8. **ADR-010 — curriculum quarantine will discard hard-but-solvable tasks early** **File/function:** `composer_replication/datagen/curriculum.py::DifficultyCurriculum.update` **Why:** With `tau_hard=0.02` and `min_exposures=8`, any task with zero successes in its first eight attempts is quarantined forever. Early in RL, that describes many valid hard tasks, not just impossible tasks. This contradicts the “create/select harder tasks dynamically” goal. **Concrete fix:** Use confidence intervals/Bayesian posterior, minimum diverse solver attempts, validator failures, or periodic reactivation rather than irreversible zero-success quarantine.
9. **ADR-010 — curriculum ignores turns and thinking-token count despite ADR claim** **File/function:** `composer_replication/datagen/curriculum.py::DifficultyCurriculum` **Why:** ADR says the Composer tech report keys curriculum on rollout turns and thinking-token count. Implementation tracks only binary pass totals. **Concrete fix:** Extend `update` to accept turns and thinking tokens, and weight/graduate tasks using those signals.
10. **ADR-010 — partial multi-feature reward is collapsed to binary for curriculum** **File/function:** `composer_replication/datagen/env.py::FeatureDeletionEnv.reward_fn` **Why:** Curriculum update uses `n_pass=int(res.reward > 0)`. A 0.1 partial pass and a 1.0 full pass both count as one success. That corrupts pass-rate estimates for multi-feature tasks. **Concrete fix:** Track fractional reward or target-test pass counts, e.g. `n_pass=res.info["frac"] * len(fail_to_pass)`, `n_total=len(fail_to_pass)`.
11. **ADR-010 — reward adapter can return the wrong number of rewards** **File/function:** `composer_replication/datagen/env.py::FeatureDeletionEnv.reward_fn` **Why:** It loops with `zip(completions, task_id)`. If `task_id` length differs from `completions`, it silently truncates and returns fewer rewards than TRL expects. **Concrete fix:** Assert `len(task_id) == len(completions) == len(prompts)`.
12. **ADR-010 — `LocalSubprocessSandbox` is not a Docker/image sandbox** **File/function:** `composer_replication/datagen/sandbox.py::LocalSubprocessSandbox` **Why:** `boot(image)` does not materialize an image. It just stores the string. Tests run in the mutable local `workdir`. This contradicts the ADR’s frozen-image/scrubbed-repo premise. **Concrete fix:** Implement a real Docker-backed sandbox or rename this as an unsafe local dev runner and keep it out of acceptance gates.
13. **ADR-010 — test parsing is unreliable and can misgrade** **File/function:** `composer_replication/datagen/sandbox.py::LocalSubprocessSandbox.run_tests` **Why:** It marks a test passed if `f"{t} PASSED"` appears, otherwise uses a coarse return-code fallback. Many test commands do not emit that format unless verbose mode is enabled; parametrized node ids, xfail/xpass, collection skips, and non-pytest substrates will be misclassified. **Concrete fix:** Use structured pytest JSON/JUnit output where possible, substrate-specific parsers otherwise, and fail closed on unknown parse states.
## P2 / nits
1. **Duplicate denylist entry** **File/function:** `composer_replication/datagen/sandbox.py::SANDBOX_DENYLIST` `unzip` appears twice.
2. **Weak drift assertion message** **File/function:** `composer_replication/trainer/composer_trainer.py::make_dr_grpo_config` Assertion says `GRPOConfig dropped loss_type`, but the real risk is semantic drift, not field absence.
3. **Smoke comment is misleading** **File/function:** `examples/composer_grpo_sdpo_smoke/run.py::main` It says `strict=False` makes absence of error sites a clean no-op. Strictness is irrelevant when `ctx_teacher_input_ids` is absent; the function returns before alignment checking.
4. **LLM cache key lacks prompt/model/version** **File/function:** `composer_replication/hint_generator.py::LLMJudgeHintGenerator._cache_key` Same error context will reuse stale hints after prompt/model/policy changes. Include prompt template version and model id.
5. **`FeatureDeletionTask.golden_diff` is hidden from `repr`, not from access** **File/function:** `composer_replication/datagen/schema.py::FeatureDeletionTask` `repr=False` is not a leakage boundary. Ensure prompt/rendering paths and serialized training examples exclude it.
## Anything the self-review likely missed
- The ADR-008 acceptance gate confuses “trainer instantiated” with “custom loss path executed.” The current smoke can pass if the parent TRL loss path never calls the subclass’s SDPO logic.- The ADR-010 tests mostly validate control-flow plumbing against `FakeSandbox`, not the hard parts: real patch inversion, real test execution, real sandbox isolation, and reward sensitivity to completions.- The reward-hacking controls are described as defense-in-depth, but the “primary” controls — scrubbed caches/history and a real allowlisted sandbox — are absent. What remains is a brittle denylist plus a string-search monitor.- ADR-009’s raw-error fallback is too eager. It optimizes for cheapness but undermines the stated goal of covering style/communication/effort errors with natural-language judge feedback.1234567891011121314151617181920212223242526272829# Review by x-ai/grok-4.3-20260430 (20.1s, 24615/1645 tok)
**## Verdict (ADR-008)**REJECT
**## Verdict (ADR-009)**ACCEPT
**## Verdict (ADR-010)**ACCEPT-WITH-FIXES
**## P0 findings**1. composer_trainer.py:280 — `assert str(cfg.scale_rewards) in ("none", "False", "False")` is a copy-paste error and does not match TRL 1.5.0 GRPOConfig storage (scale_rewards is stored as str "none" or bool False). This guard will fail or silently pass on valid Dr. GRPO configs. Fix: change to `str(cfg.scale_rewards).lower() in ("none", "false")`.2. composer_trainer.py:158-160 and _compute_sdpo_loss:191 — the "strict alignment guard" only does `student_logits.shape != teacher_logits.shape`. It performs no content/position alignment check on the post-hint tokens, so a collator that pads incorrectly but produces equal-length tensors still produces a silent zeroed loss. The ADR-008 trust-gap is not closed. Fix: add an explicit mask or token-id prefix check before the JSD call.3. datagen/validator.py:92 — Gate 4 (`apply_gold`) only verifies that the gold diff turns tests green; it never tests that the deletion site is reachable from the FAIL_TO_PASS tests via the agent's observation (no AST or coverage probe). The claim "deletion is reachable from tests" is not verified. Fix: add a coverage or import-graph reachability assertion inside the gold-applied state.
**## P1 findings**- composer_trainer.py:273 (make_dr_grpo_config) — never sets or asserts the KL estimator (k1 vs k3). TRL 1.5.0 GRPOConfig default is not guaranteed to be the `-log r` estimator cited in the tech report; the config is incomplete vs the ADR claim.- datagen/sandbox.py:57 and monitor.py:42 — SANDBOX_DENYLIST only checks the first token of a shell command. Concrete bypass: `python -c 'import marshal, dis; ...'` or `import importlib.util; ...` to read `__pycache__/*.pyc` without invoking any denied binary. Reward can still be gamed.- datagen/curriculum.py:48 — `raw_rate` quarantine decision uses the unsmoothed rate, but `update` is called with `n_total=1` per completion in env.py:reward_fn. A task that passes once then fails forever can never be quarantined after min_exposures because the running count never reflects sustained failure.- datagen/env.py:140 — `reward_fn` calls `curriculum.update(..., n_total=1)` even on hacked or guard-broken trajectories (reward==0). This pollutes the difficulty prior for tasks that are only solvable via hacks.
**## P2 / nits**- examples/composer_grpo_sdpo_smoke/run.py:88 — smoke test forces `strict_sdpo_alignment=False`, so the only alignment test that would have caught the shape-mismatch bug is disabled in the "live loop" proof.- datagen/tests/test_feature_deletion.py:140 — all validator tests use FakeSandbox materializers that directly mutate `test_outcomes`; they are tautological and do not exercise the real "deletion reachable" path.- hint_generator.py:212 — LLMJudgeHintGenerator cache key includes the full error_meta dict; any non-deterministic key (timestamps, random seeds) defeats the disk cache.
**## Anything the self-review likely missed**- The Dr. GRPO `loss_type="dr_grpo"` + `scale_rewards="none"` combination was only asserted to exist in TRL 1.5.0 help text; no test actually instantiates GRPOConfig and checks that the resulting advantages have zero length normalization and no std scaling. The acceptance gate is therefore unverified against the actual TRL implementation.