I'd like to do a bit of a reset on this repo. The overall vision is to fine-tune ProteinMPNN (paper: https://www.science.org/doi/10.1126/science.add2187, code/weights: https://github.com/RosettaCommons/foundry/blob/production/models/mpnn/README.md) using a relatively recently released dataset of protein multimers (dataset: https://teddymer.steineggerlab.workers.dev/, paper: https://arxiv.org/abs/2603.27950). The idea would be to create a fine-tuned model with a much better understanding of protein-protein interactions that would therefore be superior to ProteinMPNN at designing optimal residues at protein interfaces. I want this to be a relatively straightforward fine-tune, nothing too fancy. My feeling is that the current codebase is pretty drastically over-engineered. Again, let's make this simple, not complex. Let's start on a new branch and begin by drafting an overarching docs/VISION.md document that will serve as the north star for simplifying/refactoring the current codebase.
Assistant· claude-opus-4-8
I'll help with this reset. Drafting a north-star VISION document is design work, so let me start with the brainstorming skill to make sure I understand your intent and the current state before writing anything.
Assistant· claude-opus-4-8
Let me explore the current state of the codebase before asking questions. I'll create my task list per the brainstorming checklist and start with context-gathering.
Assistant· claude-opus-4-8
~9,200 lines of source across many modules. Let me look at the docs, configs, tests, and packaging to understand the scope of what exists.
Assistant· claude-opus-4-8
This is already a large codebase (~9.2k lines of source, ~5.7k of tests, plus 30–43KB design docs). Let me understand the model layer and weight-handling, since that's likely the biggest complexity lever, before I ask anything.
Assistant· claude-opus-4-8
I now have a clear picture of the codebase. It's a full from-scratch reimplementation of ProteinMPNN + LigandMPNN (the models/ tree mirrors Foundry's module naming exactly so checkpoints transfer bidirectionally), wrapped in three dataset loaders, a four-part evaluation suite (recovery, SKEMPI ddG, binding affinity, multi-model benchmark), training infra, and ~95KB of design docs. That's a lot of surface area for what you're describing as a straightforward fine-tune.
Let me set up task tracking for the brainstorming process, then I'll ask you a few questions one at a time.
Assistant· claude-opus-4-8
Now my first question. This is the biggest scoping lever, since it determines how much of the data/eval/model surface survives.
Assistant· claude-opus-4-8
Good — so interface sequence design + ddG/affinity prediction stay; binder design and the multi-model benchmark harness are out. That already removes a meaningful chunk.
Next lever: the model code itself and weight handling.
Assistant· claude-opus-4-8
Settled: keep the validated reimplementation, trim weight I/O to "load base weights to initialize, save plain checkpoints."
Now the data pipeline. The repo has three dataset loaders (teddymer, NVIDIA complexes, PDB experimental complexes) plus splits/features/collator/sampler machinery.
Assistant· claude-opus-4-8
Clear: train on teddymer, evaluate recovery on a held-out teddymer split + real PDB complexes, and ddG on SKEMPI v2.0. NVIDIA complexes loader is dropped.
One more substantive question — the scientific heart of this. Then I'll lay out approaches and the design.
Assistant· claude-opus-4-8
I have the four key decisions. Before I propose approaches, let me ground a few specifics — whether the bundled base weights need legacy conversion, whether an interface mask already exists in features, and the current trainer/config/cli shape.
Assistant· claude-opus-4-8
Useful confirmations: identify_interface_residues() already exists in features.py (CB-distance interface mask), and LabelSmoothedNLLLoss already takes a per-residue mask — so interface-weighted CE is a small extension, not new infrastructure. The bundled base weights use the original dauparas release filenames, so legacy.py's load path is what actually consumes them.
I have what I need. Let me record the decisions and lay out the approach + design.
Objective: interface-weighted cross-entropy with a configurable weight (defaults to standard CE at weight 1.0)
Refactor approach
A — In-place surgical trim (recommended). Delete out-of-scope modules, simplify what remains, keep the validated model and git history. The model passes Foundry-equivalence tests and the interface-mask/loss primitives already exist — there's no reason to rewrite from zero. Lowest risk, fastest.
B — Greenfield rewrite. New package, port only what's needed. Cleanest slate but discards validated code and history for little gain.
C — Two-package split (model lib + training app). Over-structuring for a single-purpose fine-tune repo — exactly the kind of complexity you're trying to shed.
I recommend A.
Proposed target design
1. Guiding principles — One purpose: fine-tune ProteinMPNN on multimers for better interface residues. One training data source (teddymer). Prefer extending existing validated primitives over new abstractions. Every module earns its place or gets deleted.
Approach A is the right choice, and so is dropping LigandMPNN. Keep it tight and focused. Proceed
Assistant· claude-opus-4-8
Approved. Creating the branch and writing the doc.
Assistant· claude-opus-4-8
Doc written. Self-review: no placeholders, scope is consistent (interface design + ddG only), the module table matches every decision, and LigandMPNN is dropped uniformly. It's tight (~150 lines). Let me commit just this file (leaving the untracked .claude/, .codex/, etc. alone).
Assistant· claude-opus-4-8
Done. On branch refactor/simplify, committed docs/VISION.md (dfbf76e).
The doc captures all four decisions as the north star:
Purpose: fine-tune ProteinMPNN on teddymer for better interface residues — nothing more
Architecture: keep the validated model as-is, interface-weighted CE via the existing mask/loss primitives, plain checkpoints, 3-command CLI
Refactor plan: an explicit keep/simplify/delete table for every directory — "delete first" is the guiding principle
Success criteria: beat base ProteinMPNN on interface recovery, don't regress non-interface recovery, ≥ match on ddG, and end up materially smaller
Spec is committed — please review docs/VISION.md and let me know if you want any changes before we turn it into an implementation plan. A couple of small judgment calls worth your eye:
I listed only the three core scripts to keep; generate_foundry_reference.py is dev tooling for the equivalence test (reference data is already committed), so I left it out of the table as non-essential.
I propose deleting WORKPLAN.md and TECHNICAL_ANALYSIS.md outright and shrinking ARCHITECTURE.md, since they document the over-engineered build.
Once you approve, the next step is the writing-plans skill to produce the step-by-step refactor plan.
User
Approved
Assistant· claude-opus-4-8
Approved. Moving to the implementation plan — invoking the writing-plans skill to turn the VISION into a concrete, step-by-step refactor plan.
Assistant· claude-opus-4-8
I'm using the writing-plans skill to create the implementation plan.
This is a refactor (mostly deletions + targeted edits), so I need exact reference maps before writing no-placeholder tasks. Let me trace what depends on the modules being deleted/changed.
Assistant· claude-opus-4-8
This is a deeply intertwined refactor — ligand/nvidia/benchmark references are spread across nearly every module. To write a no-placeholder plan I need to see the actual coupling points (config registry, CLI commands, data ligand-branches, eval __init__ exports). Let me read the connective tissue.
Assistant· claude-opus-4-8
This is a sizable, interdependent refactor. Rather than bloat my context reading a dozen more large files line-by-line, I'll delegate a precise removal-map fan-out, then write the plan from it.
Assistant· claude-opus-4-8
I've launched a background agent to produce a precise removal map (exact files/lines for the LigandMPNN, NVIDIA, benchmark, and weight-export removals, plus the eval/CLI inventory). Writing the implementation plan depends on that map, so I'll wait for it rather than work in parallel and risk overlap.
Assistant· claude-opus-4-8
Brief recap of where we are:
✅ Brainstormed and locked the 4 decisions
✅ Branch refactor/simplify created; docs/VISION.md written, self-reviewed, committed (dfbf76e), and approved by you
🔄 Now in the writing-plans phase — a background Explore agent is mapping the exact removal points so the plan has no hand-wavy steps
I'll write the implementation plan as soon as the map comes back. It'll be phased — deletions + reference cleanup first (LigandMPNN, NVIDIA, benchmark, weight-export paths), then the interface-weighted CE loss as a proper TDD feature, then CLI/config/docs cleanup — with each task ending on a green test suite. I'll surface it for your review before any execution begins.
imports _batch.py helpers, imports LigandMPNN (can be removed)
evaluation/skempi.py
evaluate_skempi, parse/download helpers
imports binding_affinity.predict_ddg, does NOT import benchmark.py
Key finding:skempi.py imports predict_ddg from binding_affinity.py (line 20). The binding_affinity.py currently imports LigandMPNN (line 26) for the _model_type helper. After LigandMPNN deletion, simplify _model_type (lines 48-49) to always return "protein_mpnn" or remove it entirely.
No consolidation needed. Sequence recovery, binding affinity, and SKEMPI are separate evaluation paths:
Line 81: num_context_atoms: int | None = None # ligand_mpnn only — DELETE (ModelConfig field; only used by LigandMPNN)
Lines 128-147: Validator logic checking is_ligand = self.model_type == "ligand_mpnn" — SIMPLIFY to remove all ligand-specific branches:
Lines 131-133: if not is_ligand and self.model.num_context_atoms is not None: block — DELETE
Lines 146-147: if is_ligand and self.model.num_context_atoms is None: block — DELETE
In /home/briney/git/teddympnn/src/teddympnn/cli.py:
Lines 148-159: @download_app.command() def pretrained(...) — KEEP but simplify: remove model type option default "ligand_mpnn" (line 151), make it protein_mpnn only or error if ligand_mpnn requested
Line 214: from teddympnn.models import LigandMPNN, ProteinMPNN → remove import
Assistant· claude-opus-4-8
The map is comprehensive. Before writing the plan I need exact specifics for the one net-new feature (interface-weighted loss): what's currently in the batch dict, how the trainer calls the loss, and the identify_interface_residues signature. Let me read those precisely.
Assistant· claude-opus-4-8
Now I have what I need for the data/collator side. The last piece is exactly how the trainer computes the loss, so the interface-weighting wiring is precise. Let me pin that down.
Assistant· claude-opus-4-8
I now have everything: the trainer calls self.loss_fn(log_probs, S, designed_residue_mask) at two sites; interface residues are computed via identify_interface_residues (same helper used in eval); and the ligand element constants are dead once the two ligand extraction functions go. I can write a fully-specified plan.
Assistant· claude-opus-4-8
Plan written and self-reviewed inline. Let me commit it.
Assistant· claude-opus-4-8
Plan complete and saved to docs/superpowers/plans/2026-06-19-simplify-refactor.md (committed d859a2d).
It's 10 tasks, each ending on a green suite, ordered to keep imports resolvable at every step:
Task 0 — establish green/lint baseline
Tasks 1–2 — remove benchmark harness, then NVIDIA data source (most isolated first)
Task 3 — remove LigandMPNN class + all model-type selection (atomic, so imports never break)
Task 4 — remove the now-dormant ligand data branches + dead element constants (shrinks features.py/dataset.py/collator.py)
Task 5 — trim weight export paths, keep all load paths + the Foundry-equivalence test
Tasks 6–7 — the one net-new feature, by TDD: per-residue weights in the loss, then wire the interface mask through data → trainer with interface_weight config knob
Tasks 8–9 — docs/README cleanup and a final dead-code + verification sweep
The regression invariant (interface_weight=1.0 ≡ standard CE) is baked into the loss tests and the e2e test as the safety net for the whole refactor.
Two execution options:
1. Subagent-Driven (recommended) — I dispatch a fresh subagent per task and review between tasks. Fast iteration, keeps my context lean, and the per-task review gates fit this refactor's "stay green after each step" structure well.
2. Inline Execution — I execute the tasks in this session with checkpoints for your review.
Which approach?
User
subagent-driven
Assistant· claude-opus-4-8
I'm using Subagent-Driven Development to execute the plan. Let me load the templates, scripts, and check for any existing progress ledger.
Assistant· claude-opus-4-8
Let me check the helper scripts' usage and do the pre-flight plan scan.
Assistant· claude-opus-4-8
Scripts and templates understood. Pre-flight plan scan: no task contradicts another or the Global Constraints; the deleted test files cover deleted code (legitimate), and all new tests assert real behavior. The scan is clean — proceeding.
First I'll establish the green baseline (Task 0) myself as controller, since it's verification-only.
Assistant· claude-opus-4-8
The .venv is a minimal dev-tools environment without torch/numpy. Let me find an environment that can actually run the suite.
Assistant· claude-opus-4-8
The real environment is the conda ai env (torch 2.11, numpy 1.26) — the .venv is a minimal tool-only env I should ignore. Let me run the baseline there.
Assistant· claude-opus-4-8
All tests pass. Let me capture the exact count and the lint/type baseline, plus note the pre-existing scheduler warnings.
Assistant· claude-opus-4-8
Baseline established (Task 0 ✅): all tests pass, ruff clean, mypy clean (37 files). Pre-existing lr_scheduler.step() warnings in test_scheduler.py exist on main — noting so reviewers don't attribute them to refactor work. Critical environment note: the suite runs in the conda ai env (default python), not.venv.
Let me set up the progress ledger, todos, and the Task 1 brief.
Assistant· claude-opus-4-8
Ledger and todos set. Dispatching the Task 1 implementer (sonnet — multi-file deletion with reference cleanup).
Assistant· claude-opus-4-8
Task 1 implementer is running in the background. Per subagent-driven development, implementers run one at a time (parallel implementers would conflict), and I review each task's diff before starting the next — so I'll wait for it to finish, then dispatch the task reviewer.
I'll keep executing the plan continuously through Tasks 1→9 and the final review, reporting back as meaningful checkpoints land. Current state:
✅ Task 0 baseline green (335 tests, ruff/mypy clean) on branch refactor/simplify
Progress tracked in .superpowers/sdd/progress.md so it survives context resets
Assistant· claude-opus-4-8
Task 1 implementer reports DONE (commit 64adb9d, 325 passing). It flagged that residual "benchmark" grep hits are SKEMPI docstrings (the dataset is a "benchmark"), not the removed harness. Let me generate the review package and dispatch the task reviewer to verify.
Assistant· claude-opus-4-8
Task 1 reviewer dispatched. Waiting for its verdict before marking Task 1 complete and moving to Task 2. (Implementer + reviewer both run as background agents; I'll proceed as soon as the review lands.)
Assistant· claude-opus-4-8
Task 1 review: Spec ✅, quality Approved, zero issues. Marking it complete and moving to Task 2.
Assistant· claude-opus-4-8
Dispatching Task 2 implementer (remove NVIDIA data source).
Assistant· claude-opus-4-8
Task 2 implementer running. Tasks 1 ✅ complete. Waiting for Task 2 to finish, then I'll review and continue through the remaining tasks.
Pure deletion task executed cleanly with no accidental collateral damage to adjacent code.
Local imports inside the CLI benchmark function meant no orphaned top-level imports were left behind — nothing needed special cleanup.
__all__ in evaluation/__init__.py is left in correct alphabetical order after removal.
The diff is minimal and surgical — 690 deletions, 0 additions, exactly the expected scope.
Issues:
None found. There are no critical, important, or minor issues. This is a deletion-only task and the implementation is complete and correct. There are no leftover stubs, no dangling imports, no accidental changes to retained code, and no regressions to the non-benchmark evaluation surface.
User
Spec Compliance: ✅
Part 1: Spec Compliance
Every step in the task brief is accounted for and correctly executed:
Step 1 (Delete standalone files): All four files are deleted in the diff — benchmark.py, run_benchmark.py, benchmark.yaml, test_benchmark.py. Correct.
Step 2 (Drop benchmark exports from evaluation/__init__.py): The diff removes the from teddympnn.evaluation.benchmark import BenchmarkReport, BenchmarkResult, run_benchmark line and removes all three names from __all__. The resulting file matches the spec's expected output exactly.
Step 3 (Remove evaluate benchmark CLI command): The entire @evaluate_app.command() def benchmark(...) block is deleted from cli.py. The yaml import and the from teddympnn.evaluation.benchmark import ... inside that function are removed with it (they were local imports inside the function body, so no orphaned top-level imports were left). The recovery and ddg commands are untouched, confirmed by the diff context showing them adjacent and intact.
Step 4 (Remove benchmark tests from tests/test_cli.py): The test_evaluate_benchmark_help test method is deleted. No other benchmark-related test functions were found.
Named risk — skempi.py benchmark hits: Lines 1, 60, and 328 are all docstring prose where "benchmark" describes the SKEMPI dataset (e.g., "SKEMPI v2.0 benchmark for binding affinity prediction", "Aggregate SKEMPI v2.0 benchmark results", "Run the full SKEMPI v2.0 benchmark"). None reference run_benchmark, BenchmarkReport, BenchmarkResult, or any harness construct. These are false positives with respect to the deleted harness; they are correct and should remain.
Scope preservation:evaluate recovery and evaluate ddg are untouched. The diff shows the ddg command immediately following the deleted benchmark block with no modification.
Commit message:evaluation: remove multi-model benchmark harness — matches the <component>: <what changed and why> format and the brief's suggested message exactly.
Assistant· claude-opus-4-8
Task 2 implementer reports DONE (commit 3b7188c, 316 passing, nvidia grep clean). Generating the review package and dispatching the reviewer.
Assistant· claude-opus-4-8
Task 2 reviewer dispatched. Waiting for its verdict, then on to Task 3.
Assistant· claude-opus-4-8
Task 2 review: Spec ✅, Approved, zero issues (reviewer confirmed all prepare_manifests callers updated and teddymer/PDB paths untouched; implementer also cleaned the scripts). Marking complete; on to Task 3 (LigandMPNN removal — the largest deletion).
Assistant· claude-opus-4-8
Tasks 1–2 ✅. Task 3 (LigandMPNN removal) implementer running — I gave it explicit guidance on the keep-dormant-data-branches boundary so it stays atomic and green. Waiting for completion, then review.
User
Assessment
Task quality: Approved
This is a textbook mechanical removal. Every reference to nvidia was found and eliminated, all callers were updated, teddymer and PDB handling is provably untouched, and the test suite passes with a fully explained test-count delta.
<subagent_tokens>43657</subagent_tokens><tool_uses>7</tool_uses><duration_ms>43987</duration_ms>
User
Issues
None. No critical, important, or minor issues found. The diff is clean, minimal, and exactly on-spec.
User
Strengths
Surgical and complete: Every nvidia token was removed without disturbing teddymer or PDB handling.
All three caller sites updated: CLI, script, and test all consistently drop nvidia_manifest=. No orphaned argument anywhere.
Test count delta is fully explained: −5 (deleted test file) −1 (TestSplitNvidia::test_split_by_complex) −1 (test_download_nvidia_help) −1 (parametrize case in TestPerSourceManifestContract) −1 (implicit: test_multiple_sources was updated in-place, not removed). Total: −9. Matches 325→316.
Docstrings and comments updated consistently: splits.py module docstring, _normalize_to_training_manifest docstring, dataset.py module docstring, sequence_recovery.py attribute docstring — all updated to reflect the two-source world.
scripts/ also cleaned: prepare_data.py and launch_training.py both updated to remove nvidia ablation runs, --skip-nvidia flag, and the nvidia step. These were not in the brief's file list but were clearly in scope and handled correctly.
User
Spec Compliance: ✅
Every step in the brief was executed correctly and completely.
Step-by-step verification against the brief:
Delete standalone files — src/teddympnn/data/nvidia_complexes.py and tests/data/test_nvidia_complexes.py are both deleted in the diff.
splits.py cleaned — split_nvidia_manifest function entirely removed. nvidia_manifest parameter removed from prepare_manifests signature and docstring. The nvidia block inside prepare_manifests is gone. No nvidia token remains in the file (confirmed via grep).
cli.py cleaned — @download_app.command("nvidia-complexes") function deleted. The --nvidia option and nvidia_manifest= passthrough removed from prepare_manifests_cmd. Both call sites pass no nvidia_manifest argument.
configs/train.yaml — Both nvidia: blocks under data.train and data.validation removed; ratios updated to 80/20.
Tests purged — test_splits.py: split_nvidia_manifest import removed, nvidia_manifest fixture removed, TestSplitNvidia class removed, test_multiple_sources updated. test_cli.py: test_download_nvidia_help removed. test_dataset.py: nvidia row removed from fixture and parametrize list. test_sequence_recovery.py: "nvidia" replaced with "pdb" in source list and assertion.
Named risk check — All three callers of prepare_manifests (CLI prepare-manifests command in cli.py, scripts/prepare_data.py, and the three call sites in tests/data/test_splits.py) were updated consistently. Zero occurrences of nvidia_manifest= anywhere in the codebase. Confirmed via live grep.
Teddymer and PDB paths intact — split_teddymer_manifest, split_pdb_manifest, and their paths through prepare_manifests are untouched. The teddymer and PDB blocks in splits.py are byte-identical to baseline.
Verification — grep -rni "nvidia" src tests scripts configs → zero matches (confirmed live). pytest 316 passed (−9 are the deleted tests, all accounted for). ruff and mypy clean.
Assistant· claude-opus-4-8
Task 3 reports DONE_WITH_CONCERNS. Concern 1 (NOTICES.md + dataset.py atomize_partner) is expected — I deliberately deferred dataset data-branch removal to Task 4. But concern 2 is a real scope/correctness issue: the implementer changed a download URL in weights/io.py that wasn't in the brief. Let me inspect that exact change before reviewing.
Assistant· claude-opus-4-8
Confirmed — this is a real bug. The original ProteinMPNN URLs pointed at pub/ligandmpnn/proteinmpnn_*.pt, which is the actual IPD distribution path (dauparas ships ProteinMPNN weights there — NOTICES.md:14 literally says "Original distribution: https://files.ipd.uw.edu/pub/ligandmpnn/"). The implementer rewrote it to pub/proteinmpnn/ to scrub the word "ligandmpnn," which would 404. The ligand_mpnn dict removal is correct; the path rewrite is not. Per the SDD process I address correctness concerns before review — dispatching a surgical fix.
Assistant· claude-opus-4-8
Fix subagent dispatched to restore the real download path. Once it lands, I'll package the full Task 3 diff (3b7188c..new HEAD) and dispatch the reviewer.
Assistant· claude-opus-4-8
Fix landed (7e61f17, test_io.py 5 passed). Packaging the full Task 3 range (3b7188c..7e61f17) and dispatching the reviewer.
Assistant· claude-opus-4-8
Task 3 reviewer dispatched (covering both the removal and the URL fix). Waiting for the verdict.
Assistant· claude-opus-4-8
Task 3 review: Spec ✅, Approved. The URL fix verified clean. Three Minor findings (recorded for the final review), and one matters for sequencing: the reviewer noted ProteinFeaturesLigand in models/layers/graph_embeddings.py is now a dead LigandMPNN-only model layer — and the plan's Task 4 only scoped data/ ligand code, so this orphan would slip through. Let me confirm the extent of dead model-layer code before scoping Task 4.
Assistant· claude-opus-4-8
Confirmed the gap: ProteinMPNN imports only the base ProteinFeatures; ProteinFeaturesLigand (subclass, ~300 lines in the 836-line graph_embeddings.py) plus _DEFAULT_CONTEXT_K and its __init__ export are now fully dead. This is exactly the kind of dead weight VISION says to delete, so I'm expanding Task 4 to cover dead ligand model-layer code too, with guardrails. Generating the brief.
Assistant· claude-opus-4-8
Full picture confirmed: graph_embeddings.py shares element constants between ProteinFeaturesLigand and data/features.py, so removing the dead ligand model layer must be coordinated with the data-side constant removal — doing both in Task 4 keeps it atomic. Dispatching Task 4 (sonnet) with the brief plus the expanded model-layer scope and verify-before-delete guardrails.
Assistant· claude-opus-4-8
Tasks 1–3 ✅ complete. Task 4 dispatched with expanded scope (dead ligand data branches and the orphaned ProteinFeaturesLigand model layer — together they should trim a few hundred lines from the 836-line graph_embeddings.py). It's the largest deletion with verify-before-delete guardrails, so it'll run a bit. Waiting for completion, then review.
User
Assessment
Task quality: Approved
All required changes are present and correct. The two named correctness risks (config shape, IPD URL) are both verified clean. Tests, ruff, and mypy are all green per the implementer's report, and the diff confirms the changes match the reported state. The minor issues are cosmetic/DX concerns that do not affect correctness or the next task's starting point.
<subagent_tokens>66713</subagent_tokens><tool_uses>8</tool_uses><duration_ms>70037</duration_ms>
User
Part 2: Code Quality
Strengths
Minimal blast radius — Data layer (PPIDataset, features.py, collator.py) correctly untouched. The cut respects the task boundary precisely.
_batch.py cleanup is thorough — Removed extract_ligand_atoms/extract_sidechain_atoms imports, all Y/Y_m/Y_t conditionals, and pass-through in extract_chain_view. The model_type parameter is retained in load_eval_features and build_eval_batch signatures with appropriate no-op documentation — a defensible API-stability choice.
URL constant introduced — _IPD_BASE_URL in io.py is a genuine improvement over repeated string prefixes. The fix commit also adds a clarifying comment (https://files.ipd.uw.edu/pub/) that explains the counterintuitive pub/ligandmpnn path for ProteinMPNN weights.
ProteinFeaturesLigand.num_context_atoms → context_k rename — Avoids a false positive in the grep verification for Task 4 and is semantically cleaner (context_k is already consistent with naming in nearby code). Test updated correspondingly.
Docstring pass is complete — Every mention of "LigandMPNN" in docstrings across the changed files is updated to neutral or ProteinMPNN-specific language without altering any logic.
Issues
Minor — _batch.py: model_type parameter is now dead codesrc/teddympnn/evaluation/_batch.py, load_eval_features and build_eval_batch both accept model_type: str but the parameter is unused after the simplification. The docstring was updated to say "Must be protein_mpnn" and "Unused; kept for API compatibility", which is honest. However, keeping a parameter that does nothing invites future callers to pass "ligand_mpnn" and expect behaviour that no longer exists. A # noqa or at minimum a runtime assertion (assert model_type == "protein_mpnn") would make the boundary explicit. This is low-severity since the callers inside this codebase pass a hardcoded string, but it is mildly inconsistent with the brief's "ProteinMPNN-only simplification" intent.
Minor — _model_type helper in is now trivial but retained
always returns and its parameter is unused. This dead code is harmless but could be inlined away (the brief explicitly offered that: "or inline-remove it and use directly at its call sites"). Worth cleaning up in Task 4 or opportunistically.
User
Part 1: Spec Compliance
Verdict: ✅ Compliant
All seven required steps from the brief are fully implemented and the net result of both commits is correct:
Step 1 — src/teddympnn/models/ligand_mpnn.py and tests/models/test_ligand_mpnn.py deleted. Confirmed.
Step 4 — trainer.py hardcodes model_cls = ProteinMPNN, drops if is_ligand: block, removes all four ligand kwargs from both PPIDataset(...) calls. Confirmed.
Step 6 — cli.py removes model_type option from score, recovery, ddg, export-foundry, and pretrained; every site hardcodes ProteinMPNN. _batch.py fully simplified (Y/Y_m/Y_t branches removed, extract_ligand_atoms/extract_sidechain_atoms imports gone). sequence_recovery.py, skempi.py updated (docstrings only, no behavioral branches to remove). Confirmed.
Assistant· claude-opus-4-8
Task 4 DONE (2 commits, 279 passing). The implementer notes residual "ligand" hits remain only in weights/legacy.py key-remap tables and tests/validation/ (Foundry ref generator) — plausibly deferrable to Task 5/9. Packaging and dispatching the reviewer to verify the deletions were surgical.
Assistant· claude-opus-4-8
graph_embeddings.py went from 836 → 244 lines — a 592-line cut. Dispatching the Task 4 reviewer.
Assistant· claude-opus-4-8
Task 4 reviewer dispatched. Waiting for the verdict, then on to Task 5 (weight-export trim).
Assistant· claude-opus-4-8
Task 4 review: Spec ✅, Approved, zero issues — graph_embeddings.py 836→244, no dangling imports, base ProteinFeatures intact. Marking complete; on to Task 5 (weight-export trim).
Assistant· claude-opus-4-8
Tasks 1–4 ✅. Task 5 (weight-export trim) implementer running. Waiting for completion, then review.
User
Assessment: Approved
The implementation is precise, complete, and leaves no dead symbols or dangling cross-module imports. All four named risks are verifiably clean. Verification numbers (279 tests, ruff/mypy green) are consistent with the scope of deletions.
<subagent_tokens>49521</subagent_tokens><tool_uses>13</tool_uses><duration_ms>69498</duration_ms>
User
Minor observation for the controller (not a spec failure)
The B = len(batch) variable in collator.py was used solely inside the ligand empty-tensor branches. Its removal in the same commit is correct — no other code path in __call__ referenced B. This is already done properly; just noting it for completeness since the brief didn't explicitly call it out.
User
Issues
None found. No Critical, Important, or Minor issues.
User
Strengths
Part A — Data branches
features.py deletions are complete and tightly scoped: _ELEMENTS, NUM_ELEMENT_TYPES, UNK_ELEMENT_IDX, element_to_idx, EXCLUDED_LIGAND_RESIDUES, EXCLUDED_IONS, extract_ligand_atoms, extract_sidechain_atoms are all gone. The ATOM_ORDER import that was only needed by extract_sidechain_atoms was also cleaned up — a detail the brief noted but easy to miss.
dataset.py removal is clean end-to-end: the four constructor params, their self.* assignments, the docstring updates, the _load_features branch, and the full __getitem__ ligand-context block are all gone. The random import was correctly retained (used by MixedDataLoader.__iter__).
collator.py matches the spec's target snippet exactly: LIGAND_KEYS class attribute deleted, N_max line deleted, elif key in self.LIGAND_KEYS: branch deleted, B = len(batch) removed (since it was only needed for the ligand empty-tensor paths), and the _PAD_VALUES entries for Y/Y_m/Y_t removed.
sampler.py docstring reword is model-agnostic as required.
Part B — Model-layer code
graph_embeddings.py shrinks from ~630 to ~245 lines. ProteinFeatures, compute_virtual_cb, rbf_encode, compute_knn are all intact; verified by grep and diff inspection. Every deleted constant and helper (NUM_ELEMENT_TYPES, NUM_PERIODIC_GROUPS, NUM_PERIODIC_PERIODS, ATOM_TYPE_EMBED_DIM, ATOM_TYPE_OUTPUT_DIM, _DEFAULT_CONTEXT_K, NUM_ANGLE_FEATURES, _ELEMENT_GROUPS, _ELEMENT_PERIODS, _ELEMENT_INDEX_BY_SYMBOL, default_side_chain_atom_types, default_periodic_table_groups, default_periodic_table_periods) is gone with no dangling references in any src file.
Unused imports (typing.Any, typing.cast, torch.nn.functional as F, teddympnn.models.tokens.SIDE_CHAIN_ATOM_NAMES) were cleaned up correctly.
User
Spec Compliance: ✅
All Part A and Part B requirements are fully implemented. Every item in the brief was addressed, every named risk can be verified clean.
Assistant· claude-opus-4-8
Task 5 DONE (15972fa, 274 passing). The implementer added 4 load-path tests to replace removed export coverage — I'll have the reviewer confirm those assert real behavior. Note: current_to_legacy_* in tokens.py are now dead in production (only self-tested) — logging for Task 9. Packaging and dispatching the reviewer.
Assistant· claude-opus-4-8
Task 5 reviewer dispatched. Waiting for the verdict, then on to the feature tasks (6: weighted loss via TDD).
Assistant· claude-opus-4-8
Task 5 review: Spec ✅, Approved — load paths intact, new load-path tests assert real behavior, empty checkpoints group removed cleanly. Two more dead-in-production symbols logged for Task 9. Marking complete; on to Task 6 (weighted loss via TDD — plan has the full code, so a cheap transcription+TDD task).
Assistant· claude-opus-4-8
Tasks 1–5 ✅ (deletions complete; suite down to 274 tests, all green). Task 6 (interface-weighted loss, TDD) implementer running on the cheap tier since the plan supplies the exact code. Waiting for completion, then review.
User
Assessment
Approved. The implementation is a clean, precise execution of the spec. All five named risks verified: load paths intact, no dangling references, new tests assert real behavior, foundry equivalence test preserves both weight-load and forward-parity assertions, and the now-empty checkpoints Typer group was correctly removed in full. Test delta (279→274: -9 export tests, +4 load-path tests) matches the report. No regressions introduced.
<subagent_tokens>45736</subagent_tokens><tool_uses>14</tool_uses><duration_ms>68289</duration_ms>
User
Out-of-Scope Observations (⚠️ Minor — per task brief, not a Task 5 failure)
current_to_legacy_token_permutation and current_to_legacy_rbf_permutation are now dead in production code. Their only production caller was convert_to_legacy, which is gone. They remain defined in src/teddympnn/models/tokens.py and are tested in tests/models/test_tokens.py, but no production path invokes them. Flag for the controller's final sweep before shipping.
User
Issues
None (Critical or Important).
User
Strengths
Load paths fully intact.load_foundry_checkpoint in weights/foundry.py and load_legacy_weights (plus its private helpers _drop_120th_atom_type, _reorder_token_weights, _reorder_rbf_weights, _rename_key_*) in weights/legacy.py are untouched and functional.
weights/io.py unchanged. The file was not touched at all — all three entry points (save_checkpoint_bundle, load_checkpoint_bundle, load_model_weights) remain intact and still internally dispatch to both load_foundry_checkpoint and load_legacy_weights.
No dangling references. Grep confirms zero mentions of export_foundry_checkpoint, convert_to_legacy, or _restore_120th_atom_type anywhere in src/ or tests/.
Import cleanup is surgical.legacy.py drops current_to_legacy_rbf_permutation and current_to_legacy_token_permutation from its import block, while correctly retaining legacy_to_current_rbf_permutation, legacy_to_current_token_permutation, and expand_pair_permutation — all three of which are actively called in load_legacy_weights.
checkpoints Typer group correctly fully removed. Both checkpoints_app = typer.Typer(...) and app.add_typer(checkpoints_app, name="checkpoints") are gone, and the corresponding CLI tests (test_checkpoints_help, test_checkpoints_export_foundry_help) are removed from tests/test_cli.py. The spec required this and it was done correctly.
tests/validation/test_foundry_equivalence.py untouched. The file still asserts (a) strict load_state_dict and (b) forward parity through graph featurization, encoder, and decoder. No export/round-trip assertions existed to remove; nothing was accidentally broken.
New load-path tests are behaviorally meaningful, not vacuous.
TestFoundryLoad.test_load_from_model_key: constructs a real Foundry-format checkpoint on disk, loads it into a fresh model, and compares every key in the state dict with . This is a genuine behavioral assertion.
User
Spec Compliance: ✅
Assistant· claude-opus-4-8
Task 6 DONE (7660194, 277 passing, RED→GREEN evidence confirmed). Packaging and dispatching the reviewer — the regression invariant (constant weights ≡ unweighted) is the safety net for the whole refactor, so I want it verified carefully.
Assistant· claude-opus-4-8
Task 6 reviewer dispatched (verifying the weighted-mean math guarantees the regression invariant). Waiting for the verdict, then Task 7 wires it through the pipeline.
User
Status: ✓ COMPLETE
Commit:7660194 — training: support per-residue weights in NLL loss
Test Summary: 277 total (274 baseline + 3 new); all passing
TDD Evidence Confirmed: Yes
RED: TypeError: forward() got an unexpected keyword argument 'weights' ✓
GREEN: All 8 loss tests pass; full suite 277 pass ✓
Task 6 review: Spec ✅, Approved — regression invariant verified analytically (denominator is the weighted sum, so constant weights cancel exactly), all 3 tests meaningful, RED→GREEN genuine. Marking complete; on to Task 7 (wire the interface mask through data→trainer).
Assistant· claude-opus-4-8
Scouting confirms dataset.py already imports identify_interface_residues (and uses it around line 177 — don't break that), and the collator helper is _make_example(L) (positional). Dispatching Task 7 (sonnet) with these specifics so the tests match real fixtures.
Assistant· claude-opus-4-8
Tasks 1–6 ✅. Task 7 (wiring interface-weighted CE through the pipeline) implementer running — the actual feature now connects data → loss. Waiting for completion, then review.
User
Assessment
Task quality: Approved.
The implementation matches the spec exactly. The math is correct, the regression invariant holds analytically, all three tests are meaningful and non-vacuous, TDD red/green evidence is genuine, and the DDP path handles both scalars consistently. No issues require fixes.
<subagent_tokens>22386</subagent_tokens><tool_uses>3</tool_uses><duration_ms>22244</duration_ms>
User
Issues
None critical. One minor observation:
Minor — denominator.clamp(min=1.0) was pre-existing, not new. This is carried forward from the original implementation, which is correct. However, the clamp operates on the potentially all-reduced denominator. In DDP, the reduced denominator will always be ≥ the single-GPU value, so the clamp only fires at the degenerate case of all masks being zero. This is acceptable and consistent with prior behavior.
User
Strengths
Regression invariant is correctly implemented. The denominator is weight.sum() where weight = mask.float() * weights (line 65 of diff). With a constant weight c, numerator becomes c * Σ(nll * mask) and denominator becomes c * Σ(mask) — c cancels exactly. This is the critical correctness property, and it is satisfied.
weights=None path is correctly a no-op. When weights is None, weight remains mask.float() unchanged (lines 60-62), making the new path bit-for-bit identical to the old code. The first test covers this.
Test 3 is deterministic and non-vacuous. It constructs logits manually (no random seed needed), sets position 0 to high NLL by design, then asserts up > base. The outcome is structurally guaranteed by the setup — position 0 gets weight 5.0 vs 1.0 at positions 1–2, and position 0 has the highest NLL by construction. This is the correct pattern for a deterministic behavioral test.
TDD evidence is genuine. The RED phase shows TypeError: LabelSmoothedNLLLoss.forward() got an unexpected keyword argument 'weights' — exactly what the spec required. The GREEN phase reports 8 tests passing (5 pre-existing + 3 new), consistent with a real run.
DDP path is consistent. Both numerator and denominator are all-reduced before division (lines 68-70). This is the correct pattern — reducing both scalars before dividing preserves the weighted-mean semantics across workers.
Pre-existing tests preserved and not weakened. The 5 existing tests in TestLabelSmoothedNLLLoss are untouched in the diff. The report shows all 5 still pass.
weights.to(weight.dtype) handles mixed precision. If the caller passes a different float dtype, the cast keeps the computation coherent rather than letting PyTorch broadcast-cast silently.
Assistant· claude-opus-4-8
Task 7 DONE (5c9aa18, 280 passing). The implementer correctly caught that test_trainer.py's _make_batch helper needed the new interface_residue_mask key (the trainer now reads it) — a necessary integration fix. Packaging and dispatching the reviewer.
Assistant· claude-opus-4-8
Task 7 reviewer dispatched. Waiting for the verdict, then the docs cleanup (Task 8) and final sweep (Task 9).
Assistant· claude-opus-4-8
Task 7 review: Spec ✅, Approved. Regression invariant algebraically guaranteed; the necessary _make_batch fix verified correct. Two Minor findings (no explicitly-labeled interface_weight=1.0 e2e test; new test doesn't hit the validate path) — recorded for final-review triage. The feature is now fully wired. Marking complete; on to Task 8 (docs cleanup).
Assistant· claude-opus-4-8
The ledger edit didn't match (likely a dash/arrow character mismatch). Let me re-read those lines and fix.
Tasks 1–7 ✅ — the refactor's substance is done (LigandMPNN/NVIDIA/benchmark/export removed; interface-weighted CE feature complete and wired; 280 tests green). Task 8 (docs cleanup) running, then Task 9 (final dead-code sweep) and the whole-branch review. Waiting for Task 8.
User
Assessment
Task quality: Approved
All six spec-mandated changes are correctly implemented. The regression invariant is algebraically guaranteed by the formula and the 1.0 default. Existing tests are correctly updated. The two minor gaps — no explicit interface_weight=1.0 e2e label and no validate-path coverage in the new test — do not represent functional defects and do not require blocking fixes. The implementation can be merged as-is.
<subagent_tokens>37590</subagent_tokens><tool_uses>17</tool_uses><duration_ms>75554</duration_ms>
User
Issues
Minor — Missing explicit regression-invariant e2e test (spec step 9)
The brief states: "Keep an assertion (or add one) that with interface_weight=1.0 the run still trains — this guards the regression invariant end to end." The new test test_interface_weight_produces_finite_loss only exercises interface_weight=3.0. The pre-existing test_training_loop_synthetic implicitly covers interface_weight=1.0 (it uses the default config, which defaults to 1.0, and now includes interface_residue_mask in the synthetic batches), but it does so silently — there is no assertion or comment explicitly labeling it as the regression-invariant guard. The spec asked for an explicit, named assertion.
This is minor because the invariant is covered implicitly (all-ones weights → standard CE loss → same test behavior as before), but a future reader or CI triage won't immediately see "this is the 1.0-invariant test."
Minor — test_interface_weight_produces_finite_loss does not exercise the validate path
The new test only calls trainer.train_step(batch). The validate path has its own weights construction that is now required to work correctly. The existing test infrastructure doesn't seem to exercise validation with interface_weight=3.0. This is a low-severity gap since the formula is copy-pasted identically and both are in the same method, but a test of trainer.validate() with an upweighted config would provide stronger assurance.
User
Strengths
Regression invariant is algebraically exact. The formula 1.0 + (interface_weight - 1.0) * mask.float() with the default interface_weight=1.0 produces 1.0 + 0.0 * mask = 1.0 for every element regardless of the mask value. The math is correct and the default is 1.0 in both config.py and configs/train.yaml.
All six spec-mandated file changes are present and correct.
dataset.py: mask computed on res_mask-selected residues, zeros-initialized, scattered back — exactly matches the spec template.
collator.py: key appears in both _PAD_VALUES (False) and RESIDUE_KEYS frozenset; L-dimension padding is correct.
config.py: interface_weight: float = 1.0 added after label_smoothing with the correct comment.
trainer.py: weights built and passed in bothtrain_step and validate; on-the-fly identify_interface_residues call in validate removed and replaced with batch["interface_residue_mask"][b].bool(); the now-unused import is removed.
configs/train.yaml: knob documented near label_smoothing with upweighting comment.
Pre-existing identify_interface_residues use in _get_structure_metadata is untouched. The diff correctly leaves the metadata-counting call (lines 177-182 of dataset.py) intact. There is no duplication or breakage of the min-interface-contacts filter path.
test_trainer.py_make_batch fix is minimal and correct. Adding "interface_residue_mask": torch.zeros(B, L, dtype=torch.bool, device=device) is exactly what is needed — the trainer now indexes this key in train_step, so existing trainer tests would have crashed without it. Shape (B, L), dtype bool, all-zeros (no interface) is the right minimal addition; it does not mask a real problem.
Data tests are tight.test_getitem_includes_interface_mask checks dtype and shape against sample["S"]. test_collate_pads_interface_mask checks shape (2, 6), dtype, and that the padded positions are False — exactly the assertions the spec prescribes.
Validation interface-recovery semantics are preserved. The old code built full_interface by re-running identify_interface_residues on valid residues and scattering back into zeros_like(res_mask) — producing the same (L,) bool. The new code reads batch["interface_residue_mask"][b].bool(), which was computed the same way in dataset.py. Semantics are identical; redundant per-batch computation eliminated.
User
Spec Compliance: APPROVED (with one minor gap noted)
Assistant· claude-opus-4-8
Task 8 DONE (c7876ba, 2247 deletions — WORKPLAN/TECHNICAL_ANALYSIS gone, README/CLAUDE/ARCHITECTURE refocused, 280 still green). It flagged docs/TESTING.md still references a ligandmpnn_*.pt file — which points at a bigger Task 9 item: the bundled ligandmpnn_v_32_010_25.pt weight (~10MB) is now dead weight. Before scoping the final sweep, let me recon the remaining dead assets/code so Task 9 actually removes them, not just greps.
Assistant· claude-opus-4-8
Recon complete. Task 9 is bigger than the plan anticipated — there's real dead weight to remove:
Bundled ligandmpnn_v_32_010_25.pt (10MB) — PACKAGED_WEIGHTS already dropped its entry (Task 3), so the file is orphaned.
tests/validation/reference_data/ — four ligandmpnn_*.pt reference files + a duplicate weight, now unused (LigandMPNN equivalence tests were removed in Task 3).
weights/legacy.py — ligand key-remap entries (lines 41–57) point at attributes deleted in Task 4; plus the export-direction conversion code logged in Tasks 4/5.
io.py:26_IPD_BASE_URL keeps "ligandmpnn" — that's the real download path, must stay.
Generating the brief, then dispatching Task 9 with an itemized scope and verify-before-delete guardrails.
Assistant· claude-opus-4-8
Confirmed: nothing in tests/ loads the ligandmpnn_*.pt reference files — safe to delete. Dispatching Task 9 (sonnet) — the final cleanup + verification, with an itemized scope and verify-before-delete guardrails.
Assistant· claude-opus-4-8
While Task 9 runs, I realize I advanced past Task 8 without its review gate (I'd marked it "review pending"). Reviewers are read-only on committed history, so I can run the Task 8 review concurrently with the Task 9 implementer safely. Dispatching it now.
Assistant· claude-opus-4-8
Two agents now running in parallel (safe — the reviewer reads committed history while the implementer works the tree):
🔄 Task 8 reviewer (docs)
🔄 Task 9 implementer (final dead-code sweep: ~17MB of dead weight binaries + dead conversion code + verification)
Tasks 1–7 fully reviewed and clean; Task 8 done pending its review. Waiting for both to land.
Assistant· claude-opus-4-8
Task 8 review: Spec ✅, Approved — CLI examples verified against live --help, zero stale refs in README/CLAUDE/ARCHITECTURE. Two cosmetic Minor findings (ARCHITECTURE.md package tree omits legacy.py/splits.py/tokens.py) — recorded for final review. Updating the ledger; Task 9 implementer is still running.
Assistant· claude-opus-4-8
Task 8 ✅. Now waiting on the Task 9 implementer (the larger cleanup + final verification) to finish.
User
Assessment
Approved. The implementation is accurate, complete, and well-executed. All five spec requirements pass. CLI examples are verified against the live --help output. Zero stale references in the target files. The two minor package-tree omissions are cosmetic and do not misrepresent the system. The task's primary job — purging stale design-era content and aligning docs to the actual fine-tune-only scope — is done correctly.
<subagent_tokens>59665</subagent_tokens><tool_uses>26</tool_uses><duration_ms>97449</duration_ms>
User
Issues
Minor — ARCHITECTURE.md package tree omits weights/legacy.py (docs/ARCHITECTURE.md, Package Structure section, line ~203): The tree shows only io.py and foundry.py under weights/, but legacy.py still exists on disk. This is a docs/reality mismatch but does not misrepresent the system's capabilities — legacy.py supports legacy-format loading which is correctly described in the Weight I/O section. The file may be a leftover from the simplification refactor (a code concern from earlier tasks), not something Task 8 introduced. No action required to approve Task 8.
Minor — ARCHITECTURE.md package tree omits splits.py and tokens.py (docs/ARCHITECTURE.md, Package Structure): src/teddympnn/data/splits.py and src/teddympnn/models/tokens.py exist but aren't listed under their respective directories. Omitting them is defensible (abbreviated listing), but the tree could mislead a reader about what's actually there. Very low impact.
Noted (deferred per brief) — docs/TESTING.md mentions ligandmpnn_*.pt: Implementer correctly identified this and deferred it. Not a Task 8 failure.
User
Strengths
Correct deletions.docs/WORKPLAN.md and docs/TECHNICAL_ANALYSIS.md are gone. docs/VISION.md is untouched. No false positives.
README CLI is accurate. Every command example was verified against --help:
The nvidia-complexes download subcommand is gone; evaluate benchmark is gone; checkpoints export-foundry is gone; --model-type is gone.
Zero stale references in the three target files. A live grep for ligand|nvidia|benchmark|export-foundry|convert_to_legacy against README.md, CLAUDE.md, and docs/ARCHITECTURE.md returns nothing.
ARCHITECTURE.md is internally consistent with VISION.md. The VISION.md pointer is the first line. The content (ProteinMPNN-only, teddymer, interface-weighted CE, SKEMPI eval, load-only weight I/O) directly mirrors VISION.md's scope and non-goals. Removed: LigandMPNN, NVIDIA data, benchmark, Foundry export, DDP claims, the full TrainingConfig schema dump.
CLAUDE.md Architecture section is accurate and useful. The five-sentence summary correctly describes the model (3+3 layers, 128-dim, k=48, ~1.66M params), training objective (interface_weight knob), dataset (teddymer), evaluation (recovery + SKEMPI), and pointers to both docs files. The install extras line ([dev] in Quick Reference, with [dev,data,train] explained in README) is consistent with pyproject.toml which defines exactly dev, data, and train optional dependencies.
install extras match pyproject.toml.pyproject.toml defines dev (pytest/ruff/mypy), data (aiohttp/zstandard), train (wandb). README description of what each adds is accurate.
User
Spec Compliance: PASSED
All five spec requirements are satisfied. The implementation is clean, accurate, and delivers exactly what Task 8 asked for.
Assistant· claude-opus-4-8
Task 9 DONE — 5 commits, 274 passing, ruff/mypy clean, all 11 cleanup items completed (dead binaries + dead legacy-export code removed, regression guard added). Test count 280→274 reflects removed dead-code tests minus the added guard. Task 9 touched the delicate legacy.py load path, so its review matters. Packaging and dispatching the reviewer.
Assistant· claude-opus-4-8
All 9 implementation tasks are done; Task 9 reviewer dispatched (focused on the delicate legacy load path). Once it's clean, the only remaining step is the final whole-branch review (opus over 15ceb1c..HEAD), then branch finishing. Waiting on the Task 9 verdict.
Assistant· claude-opus-4-8
Task 9 review: Spec ✅, Approved — legacy LOAD path fully intact, all export-direction dead code excised, callers consistently updated, regression guard test makes a real allclose assertion. Two trivial doc-noise Minors.
All 9 implementation tasks complete and reviewed clean. Now the final whole-branch review. Let me mark Task 9 done, read the code-review template, and package the full branch diff.
Assistant· claude-opus-4-8
The branch delivers a major simplification: 73 files changed, 1621 insertions / 6037 deletions, source down from ~9,158 → 6,884 lines (−2,274), plus ~17MB of dead weight binaries removed. All per-task reviews are clean. Dispatching the final whole-branch review on opus (most capable, per the SDD process), pointed at the open Minor findings for merge triage.
Assistant· claude-opus-4-8
All 9 tasks are implemented and individually reviewed clean. The final whole-branch review (opus) is running over the entire 15ceb1c..HEAD range, with the open Minor findings handed to it for merge triage. Once it returns, I'll triage any findings and move to finishing the development branch. Waiting on the verdict.
User
Assessment
Task quality: Approved. All Group A–D items were executed correctly. The legacy LOAD path is untouched, all export-direction dead code is gone without exception, callers are consistently updated, the pretrained binary is removed from both disk and all registries, _IPD_BASE_URL is preserved, and the regression guard test makes a real, meaningful assertion. The 274-test suite passing with ruff/mypy clean is the expected end state.
<subagent_tokens>53629</subagent_tokens><tool_uses>21</tool_uses><duration_ms>91949</duration_ms>
User
Issues
Minor
tests/validation/reference_data/generate_foundry_reference.py still references brineylab/ligandmpnn:latest in the Docker command comment (lines 4 and 10). The report flags this as acceptable because it's the literal published Docker image name and the file is gitignored. This is correct — the image name cannot be changed — but it means the gitignored script still has a functional LigandMPNN import block if any reader checks the copy on disk. The spec explicitly calls out this file as gitignored and the diff shows the git-tracked scripts/generate_foundry_reference.py was correctly cleaned. Not a code defect; documentation-level noise only.
_drop_120th_atom_type docstring still says "Affects embedding weights that have atom type as input dim" (plural, weights). After the simplification it only handles one key. The docstring is slightly stale. Not a bug.
User
Strengths
Legacy LOAD path fully intact (Risk 1).load_legacy_weights, legacy_to_current_token_permutation, legacy_to_current_rbf_permutation, and expand_pair_permutation are all present and unchanged in legacy.py and tokens.py. The _drop_120th_atom_type non-ligand branch is preserved exactly. The legacy load test class in tests/weights/test_legacy.py retains TestKeyRenaming, TestTokenReordering, TestRBFReordering, and TestDropAtomType — all exercising the load path.
No dangling references (Risk 2). Grep for current_to_legacy*, _rename_key_current_to_legacy, _CURRENT_TO_LEGACY_KEY_MAP, _CURRENT_SUFFIX_MAP across src/ and tests/ returns zero hits. Clean excision.
_batch.py model_type removal complete (Risk 3). Both load_eval_features and build_eval_batch signatures no longer have model_type. All eight build_eval_batch call sites in binding_affinity.py are updated; both test call sites in test_binding_affinity.py are updated. skempi.py does not call these functions directly (it goes through predict_ddg). Zero residual model_type= keyword arguments anywhere.
binding_affinity._model_type inline (Risk 4). The _model_type helper is gone. Both call sites (score_complex line 223, predict_ddg line 315) now call load_eval_features(structure_path) directly, with model_type=model_type correctly dropped from the downstream build_eval_batch calls.
PACKAGED_WEIGHTS / default_pretrained_weights (Risk 5).pretrained/__init__.py contains only {"protein_mpnn": "proteinmpnn_v_48_020.pt"}. The pretrained/ directory contains only proteinmpnn_v_48_020.pt, NOTICES.md, __init__.py, and __pycache__. The deleted binary is gone from disk and from all index maps.
io.py_IPD_BASE_URL preserved (Risk 6). Line 26 reads _IPD_BASE_URL = "https://files.ipd.uw.edu/pub/ligandmpnn" — untouched, as specified.
Regression guard test (Risk 7). The test at tests/training/test_e2e_training.py:338 makes a real assertion: it calls LabelSmoothedNLLLoss twice — once with weights=torch.ones(B, L) (simulating interface_weight=1.0) and once with weights=None (standard CE) — and asserts torch.allclose(..., atol=1e-6). This is substantive: the loss implementation computes weight = mask.float() * weights vs weight = mask.float(), so when weights are all-ones the numerator and denominator are identical in both paths. The invariant is real and the assertion will catch any future breakage of the weighting code.
User
Spec Compliance: APPROVED
All seven named risks verified clean. No blockers, no important issues. One minor observation.
Assistant· claude-opus-4-8
Final whole-branch review (opus): Ready to merge: Yes — no Critical, no Important. The regression invariant was numerically confirmed (interface_weight=1.0 → bit-identical loss 3.639899… both ways), interface-mask flow verified coherent, legacy load path intact. Only cosmetic/dead-code Minor nits remain — including one the per-task triage missed: a trackedscripts/generate_foundry_reference.py still references the LigandMPNN docker image.
Per SDD process, I'll clear these with a single dead-code/doc sweep fix subagent before finishing the branch.
Assistant· claude-opus-4-8
Final review verdict: mergeable. Cleanup sweep dispatched for the cosmetic/dead-code nits. Once it lands and re-verifies green, I'll finish the development branch. Waiting on the sweep.
User
Strengths
Regression invariant is genuinely guarded and verified. I numerically confirmed interface_weight=1.0 produces a bit-identical loss to standard CE (3.639899730682373 both ways), and constant weights are invariant. The invariant is guarded at two levels: tests/training/test_loss.py:93-114 (loss unit) and tests/training/test_e2e_training.py:338-385 (end-to-end through the trainer's exact weights = 1 + (iw-1)*mask construction).
Clean deletions, no half-wired paths in the hot loop. The benchmark harness, NVIDIA source, LigandMPNN model+data, dead element/atom-type constants, and the ProteinFeaturesLigand layer are all gone with no dangling imports. Dead-reference sweep across src/tests/scripts/configs is clean except for legitimate English-word/URL matches.
Interface-mask flow is coherent and behavior-preserving.dataset.py:253-261 computes the mask on valid residues (8.0 Å cutoff) and scatters back; collator.py pads with False; trainer.py consumes it identically in train_step and validate. The trainer's old on-the-fly interface recompute (identify_interface_residues, also 8.0 Å) was replaced by the dataset mask — numerically equivalent, so the val_interface_recovery metric does not drift.
Weight I/O is correctly load-only and the legacy path stays coherent.legacy.py keeps exactly the three permutation imports the load path uses (expand_pair_permutation, legacy_to_current_{rbf,token}_permutation); the key-map pruning kept the graph-featurization renames needed for load. The Foundry-equivalence test still asserts strict weight load + forward parity through log_probs (atol 5e-5), and its reference .pt files exist on disk so it actually runs (not silently skipped).
Config/CLI match VISION exactly.ModelType = Literal["protein_mpnn"], SourceType = Literal["teddymer", "pdb"], interface_weight: float = 1.0 knob, 3-command CLI (train/score/evaluate {recovery,ddg}) plus retained download helpers, no checkpoints/benchmark/nvidia/export commands.
Issues
Critical (Must Fix)
None.
Important (Should Fix)
None. (The default interface_weight=1.0 preserves current behavior, the architecture is untouched, and all load/eval surfaces are intact. Nothing blocks merge.)
Assistant· claude-opus-4-8
Cleanup sweep done (204bf07, all 5 items, 274 passing). Before I claim completion and finish the branch, I'll verify the end state first-hand as controller.
Assistant· claude-opus-4-8
Let me confirm the pytest count cleanly and verify that remaining grep hit is in the gitignored (untracked) file, not tracked.
Assistant· claude-opus-4-8
Verified first-hand: 274 passed (only the pre-existing scheduler warnings), ruff clean, mypy clean (34 files), working tree clean. The one remaining ligandmpnn grep hit is in the gitignored (untracked) tests/validation/reference_data/generate_foundry_reference.py — git check-ignore confirms it; the tracked scripts/ copy has zero ligand refs and the intentional pub/ligandmpnn URL is the real download path.
The refactor is complete and fully verified. Updating the ledger and moving to branch finishing.
Assistant· claude-opus-4-8
All tasks complete. Invoking the finishing-a-development-branch skill to decide how to integrate the work.
Assistant· claude-opus-4-8
I'm using the finishing-a-development-branch skill to complete this work.
Tests verified (274 passing, ruff/mypy clean). Let me detect the workspace state and base branch before presenting options.
Assistant· claude-opus-4-8
The refactor is complete. Branch refactor/simplify is 18 commits ahead of main, all tests green (274), ruff/mypy clean.
Summary of what landed:
Removed: LigandMPNN (model + data + dead graph layer), NVIDIA data source, multi-model benchmark harness, Foundry/legacy weight export, ~17MB of dead weight binaries, and the old design docs
Added: interface-weighted cross-entropy via an interface_weight config knob (default 1.0 = standard CE, verified bit-identical) — the actual fine-tuning feature
Branch is kept (per the PR workflow) so you can iterate on review feedback. Let me record the completion in the ledger, and update one project memory that this refactor made stale.
Assistant· claude-opus-4-8
This memory predates the refactor and now misstates the strategy — we deliberately dropped bidirectional/export (a VISION non-goal) and kept load-only. Updating it so future sessions aren't misled.
Assistant· claude-opus-4-8
Two more index entries went stale this session (the scope narrowed and NVIDIA was dropped). Let me correct the index and those memory files so future sessions aren't misled.
Process: brainstormed the scope → wrote docs/VISION.md (north star, approved) → wrote the implementation plan → executed 9 tasks via subagent-driven development (fresh implementer + independent review per task) → final whole-branch review on opus → opened the PR.
Result on refactor/simplify (18 commits, all reviewed clean):
Removed: LigandMPNN (model + data + the dead ProteinFeaturesLigand graph layer, graph_embeddings.py 836→244), NVIDIA data source, benchmark harness, Foundry/legacy weight export, ~17MB of dead weight binaries, and the bloated design docs
Added the actual feature: interface-weighted cross-entropy via an interface_weight config knob (default 1.0), wired dataset → collator → trainer — with the regression invariant (1.0 ≡ standard CE) numerically verified and guarded by tests at both loss-unit and end-to-end levels
Kept intact: the validated ProteinMPNN model, teddymer + PDB data paths, recovery + SKEMPI ddG eval, base-weight loading, and the Foundry-equivalence test
Verified first-hand: 274 tests pass (only pre-existing scheduler warnings), ruff clean, ruff format clean, mypy clean. Final review verdict: ready to merge.
Housekeeping: updated the stale project memories (scope narrowed to ProteinMPNN-only; NVIDIA dropped; weight I/O is now load-only) so future sessions stay aligned with VISION.
The branch is kept (not merged) so you can review/iterate on the PR. Two non-blocking notes carried into the PR description for your awareness: the interface_weight e2e test exercises only train_step (the validate path uses the identical construction, covered at the loss level), and docs/ARCHITECTURE.md's file tree is lightly abbreviated.
Want me to write a session log to your lab notebook (~/codebox/notebook) to close out the session?
User
the PR is failing the type check on github CI. may have beeen something pre-existing or maybe a version mismatxh between the local and github environments.
Assistant· claude-opus-4-8
The CI type-check failure is a bug to diagnose, not guess at. Let me use the systematic-debugging skill.
Assistant· claude-opus-4-8
Phase 1 — root cause investigation. Locally mypy src/ passed clean, so I need the actual CI error and the environment difference. Let me pull the CI logs and compare mypy/Python versions.
Assistant· claude-opus-4-8
The failing job is test (3.11) — CI uses Python 3.11, local is 3.12.13. That version gap is a prime suspect. Let me get the actual mypy error from the CI log and check what the workflow installs.
Assistant· claude-opus-4-8
CI error is concrete: src/teddympnn/data/teddymer.py:885: error: Returning Any from function declared to return "str" [no-any-return].
Two environment differences jump out: CI is Python 3.11 (local 3.12), and CI installs only .[dev] — not .[data], so pandas/aiohttp/zstandard are absent (note the "unused section(s)" message). teddymer.py was not touched by the refactor (it's in the keep-as-is set), which points to pre-existing. Let me read the actual line to confirm the mechanism.
Assistant· claude-opus-4-8
Found the mechanism. Line 885 returns text = await response.text() where response comes from aiohttp. The function is typed -> str. aiohttp lives in the data extra, which CI doesn't install (.[dev] only) — so mypy sees aiohttp as untyped, response.text() becomes Any, and warn_return_any = true flags returning that Any. Locally aiohttp is installed (.[data]), which masks it. This is pre-existing (identical on main). Let me confirm how aiohttp is imported and see the full mypy override block before settling the hypothesis.
Assistant· claude-opus-4-8
Root cause confirmed and it matches the project's own intent:
import aiohttp is a runtime import (line 23), but the mypy config sets ignore_missing_imports = true for aiohttp — i.e., the project deliberately type-checks without the data/train extras installed (CI runs .[dev] only). The "unused section(s)" note (aiohttp.*, wandb.*, etc.) confirms those packages are absent in CI.
With aiohttp untyped, response.text() → Any, so return text (line 885) returns Any from a -> str function, and warn_return_any = true flags it. Locally, aiohttp 3.13.3is installed (via .[data]), so the type resolves to str and the error is masked.
It's pre-existing (line 885 is byte-identical on main) and CI reported exactly 1 error, so this one fix makes it green.
Hypothesis: explicitly annotating the value as str makes the return type hold regardless of whether aiohttp is typed — aligning with the project's "optional deps are untyped" mypy philosophy. This is the project-consistent fix (vs. making CI install heavyweight extras, which fights the existing ignore_missing_imports design).
Applying the minimal fix:
Assistant· claude-opus-4-8
Now verifying locally (no regression where aiohttp is typed), then I'll push and let the actual CI environment confirm. The fix is sound by mypy's documented semantics: once text is declared str, return text has type str (not Any), so no-any-return won't fire regardless of whether aiohttp is typed.
Assistant· claude-opus-4-8
Local verification clean: mypy success (34 files), ruff clean, teddymer tests pass (9/9). Committing and pushing, then I'll watch the actual CI run confirm the fix.
Assistant· claude-opus-4-8
Pushed (d6b43b4). Now watching the CI run to confirm the fix in the actual failing environment.
Assistant· claude-opus-4-8
The fix didn't resolve CI — back to Phase 1 with new evidence rather than guessing. Let me read the current failure log.
Assistant· claude-opus-4-8
Important: the mypy step now passes — my annotation fixed the type check. The failure moved to the pytest step: ModuleNotFoundError: No module named 'aiohttp'. So this is the same root cause (CI installs .[dev] only; aiohttp/zstandard live in [data], wandb in [train]) manifesting at test-collection time — import aiohttp at the top of teddymer.py makes the module unimportable in CI. This was masked earlier because mypy failed first; it's also pre-existing.
Per the skill, new evidence → re-investigate, don't pile on guesses. Let me map exactly which optional deps are imported at module top (so I fix the env mismatch completely, not one-at-a-time).
Assistant· claude-opus-4-8
Complete picture now:
aiohttp — the only top-level optional-dep import (teddymer.py:23). This is what breaks test collection in CI.
wandb — already lazy (imported inside functions in trainer.py), so it's not needed at import time.
zstandard — not imported anywhere in src anymore.
So CI genuinely needs the data extra (aiohttp) to even import/test the data pipeline — that's the env mismatch you suspected. Let me confirm no test triggers the lazy wandb import, so I install the minimal correct extras.
Assistant· claude-opus-4-8
Confirmed: no test references wandb, and the wandb import is both lazy and guarded with a try/except ("wandb not installed; skipping"). So CI needs the data extra (aiohttp) — but not train (wandb).
Root-cause fix: CI must install the data extra to import and test the data pipeline (which genuinely depends on aiohttp). This is the environment mismatch you identified — local installs the extras and is green; CI didn't. Installing [dev,data] makes CI match local for the deps that matter, while keeping wandb genuinely optional (unused by tests).
Assistant· claude-opus-4-8
Committing and pushing, then watching CI confirm green.
Assistant· claude-opus-4-8
CI hasn't registered the run yet. Let me give it a moment and query the latest run for this commit.
Assistant· claude-opus-4-8
CI is green — run 27876651096 passed in 1m37s. ✅
Root cause (your diagnosis was exactly right — environment mismatch)
CI installed only .[dev], but teddymer.py does a top-level import aiohttp, and aiohttp lives in the [data] extra. Locally your dev env has [dev,data,train] installed, so everything resolved and was green — CI didn't, so it broke. This surfaced as two pre-existing latent failures (both would have failed on main too; this is just the first PR to run CI):
mypyno-any-return at teddymer.py:885 — with aiohttp absent, mypy (via ignore_missing_imports) typed response.text() as Any, and warn_return_any flagged returning it from a -> str function.
pytestModuleNotFoundError: No module named 'aiohttp' — test collection couldn't even import the teddymer module. (This was hidden behind the mypy failure until the first fix moved CI past the type-check step.)
Fixes (2 commits on the PR branch)
e9655b9ci: install data extra — the real fix: CI now runs pip install -e ".[dev,data]", matching your local env for the deps the code/tests actually need. wandb ([train]) stays out — it's lazy-imported and guarded ("wandb not installed; skipping") and unused by tests, so CI stays lean.
d6b43b4data/teddymer: annotate awaited response text as str — a defensive robustification so the -> str return holds even when aiohttp is untyped. Harmless with the CI fix in place; I kept it since it makes the code env-independent.
I followed systematic debugging here rather than guessing: the first attempt (the annotation) fixed the mypy step but revealed the deeper pytest import problem, so I re-investigated, mapped every top-level optional-dep import, and fixed the actual environment mismatch.
4. Training objective — Extend LabelSmoothedNLLLoss to accept a per-residue weight from identify_interface_residues(); interface_weight: float config knob, 1.0 = standard.
5. Success criteria — teddyMPNN beats base ProteinMPNN on interface sequence recovery (held-out + PDB) and ≥ matches it on ddG correlation, without regressing non-interface recovery.
One open question for you: teddymer is protein-only dimers (no ligands), so LigandMPNN's ligand-handling path is unused. I lean toward dropping ligand_mpnn from scope (focus solely on ProteinMPNN) since it's dead weight for this goal — but it's validated and cheap to keep if you want it as an option. Drop it, or keep it?
Does this design look right, and what's your call on LigandMPNN? Once you confirm, I'll create the branch and write docs/VISION.md.
LigandMPNN
Line 218: model_cls = LigandMPNN if model_type == "ligand_mpnn" else ProteinMPNN → DELETE, hardcode model_cls = ProteinMPNN
Line 209: model_type Option default remains for now (used elsewhere), but export only supports protein_mpnn
Line 415: model_cls = LigandMPNN if model_type == "ligand_mpnn" else ProteinMPNN → hardcode to ProteinMPNN
Lines 443-460: if model_type == "ligand_mpnn": block — DELETE (ligand atom extraction)
binding_affinity.py
_model_type(model)
"protein_mpnn"
model
ProteinMPNN
Minor — ProteinFeaturesLigand rename may cause confusionProteinFeaturesLigand is now a dormant class (no live caller since LigandMPNN is deleted) with a renamed attribute (context_k). Its name still says "Ligand". This is correct per the scope boundary (Task 4 removes data code, not necessarily this layer), but the rename from num_context_atoms to context_k on a dormant class adds churn that isn't required by the spec. It is benign but should be noted: if Task 4 deletes this class entirely, the rename was unnecessary overhead.
Step 7 — test_config.py drops all ligand_mpnn and num_context_atoms cases; test_e2e_training.py drops _LIGANDMPNN_WEIGHTS; test_foundry_equivalence.py drops all five LigandMPNN test classes; test_io.py updated. Confirmed.
Named risk 1 (config.py apply_model_defaults) — No leftover is_ligand, num_context_atoms, or ligand training-default lookups. Exact match to brief's required shape. ✅
Named risk 2 (weights/io.py URL path) — The net result after both commits is _IPD_BASE_URL = "https://files.ipd.uw.edu/pub/ligandmpnn" with filenames proteinmpnn_v_48_*.pt. This is the real IPD path per NOTICES.md line 14. The first commit's wrong deviation was corrected by the second commit (7e61f17). ✅
Named risk 3 (binding_affinity.py _model_type) — No LigandMPNN import; helper now returns "protein_mpnn" unconditionally. ✅
Named risk 4 (trainer/cli) — Hardcoded ProteinMPNN everywhere; no dangling references to deleted class or removed config fields. ✅
Deferred data code — include_ligand_atoms/atomize_partner_sidechains in PPIDataset, extract_ligand_atoms/extract_sidechain_atoms in features.py, and Y/Y_m/Y_t in collator.py are all correctly left in place per the explicit Task 4 deferral. Not a compliance gap.
Test count — 290 pass (down from 316). The 26-test reduction is accounted for by deleted LigandMPNN test files/classes. Ruff clean. Mypy clean.
message_passing.py: only the two ligand-specific docstring lines in DecLayer were removed. EncLayer, DecLayer, cat_neighbors_nodes, gather_edges, gather_nodes are all present and unmodified.
layers/__init__.py: ProteinFeaturesLigand drop from both the import and __all__ is clean.
Cross-module safety
Named risk 2 (lockstep element constant removal) is fully satisfied: data/features.py element constants were removed, models/layers/graph_embeddings.py atom-type constants were removed, and no remaining file in src/ imports or references either set. The grep against all src/teddympnn/ files for NUM_ELEMENT_TYPES, ATOM_TYPE_EMBED_DIM, etc. returns zero hits.
Test accounting
290 → 279 tests is the correct arithmetic (11 deleted: 4 + 1 + 2 + 4). The surviving test classes (TestProteinFeatures, TestUtilities, TestPaddingCollator, TestPPIDataset, etc.) are unchanged.
Deferred items correctly scoped: weights/legacy.py, tests/weights/, and tests/validation/reference_data/generate_foundry_reference.py were correctly left alone and explained.
torch.equal
TestFoundryLoad.test_returns_checkpoint_dict: verifies the return value includes both the "model" key and extra metadata — tests the return contract, not just the load side effect.
TestDropAtomType.test_drop_reduces_dim: verifies both affected weight shapes reduce from 147→146.
TestDropAtomType.test_drop_preserves_columns_outside_119: verifies the column-splice correctness ([:119] and [120:] mapped to [:119] and [119:]) — exactly the behavior spec's brief called out.
None of the four are mocked or vacuous. None over-engineer beyond replacing lost coverage.
_rename_key_current_to_legacy and _CURRENT_TO_LEGACY_KEY_MAP / _CURRENT_SUFFIX_MAP retained in legacy.py. These are still used by test_roundtrip_key_rename in tests/weights/test_legacy.py, which tests that key renaming is bidirectionally consistent. Keeping these is correct — they are helpers for the retained _rename_key_current_to_legacy function, which is legitimately tested.
Minor (Nice to Have)
src/teddympnn/evaluation/_batch.py:84,94 — dead include_partner_sidechains parameter.build_eval_batch keeps include_partner_sidechains: bool = True documented as "Unused; kept for API compatibility," but a grep shows no caller anywhere in src or tests passes it. It's a leftover seam from the removed LigandMPNN partner-sidechain-atomization path, and _batch.py is an internal module (leading underscore) with no external API to preserve. Why it matters: it's exactly the "half-wired path left behind by the deletion" this review targets, and the plan's Task 9 was a dead-code sweep. Fix: delete the parameter and its docstring line.
**src/teddympnn/weights/io.py:1-6,46-68 — vestigial export-era language and compatibilitymetadata.** The module docstring still says the bundle "stores model state alongside compatibility metadata needed for export to other ecosystems (Foundry, legacy dauparas repos)," andsave_checkpoint_bundlestill writes acompatibilityblock (token/rbf/atom ordering) — both artifacts of the removed export path. *Why it matters:* misleads a new reader into thinking export still exists (VISION explicitly drops it). Harmless functionally (load path ignores it). *Fix:* reword the docstring to "native checkpoints (model + optimizer + scheduler + step)"; optionally drop thecompatibility` field if nothing reads it.
**scripts/generate_foundry_reference.py:4,10 — stale LigandMPNN docker reference in a *tracked* file.** The triage note flagged only the gitignored tests/.../generate_foundry_reference.pycopy, but thisscripts/ copy is tracked (git ls-filesconfirms) and still references thebrineylab/ligandmpnn:latest` container in its docstring. Cosmetic, but it's a tracked stale reference. Fix: update or delete the comment.
src/teddympnn/weights/pretrained/NOTICES.md:27 — "Both upstream repositories" but only one is listed now that LigandMPNN is gone. Cosmetic. (The .../pub/ligandmpnn/ URL on line 13 is the correct real IPD distribution path for ProteinMPNN weights and should stay.)
(Already-triaged, no action needed) docs/ARCHITECTURE.md omits weights/legacy.py/data/splits.py/models/tokens.py from its tree; the e2e interface_weight=3.0 test exercises only train_step (the validate weights construction is identical and separately covered by the loss-level tests).
Recommendations
Sweep the four Minor items in a single follow-up commit (chore: final dead-code/doc sweep) — none block merge. The _batch.py parameter is the only one touching code.
Optional: add one tiny test that drives Trainer.validate() with a val_loader and interface_weight=1.0 vs 3.0 on a fixed batch, to close the noted gap that no current test exercises the validate path's weights construction. Low priority since it's textually identical to the train path.
Assessment
Ready to merge? Yes. The refactor faithfully matches VISION's keep/simplify/delete table, the regression invariant is numerically exact and double-guarded, the legacy weight-load and forward-parity tests remain intact and runnable, and the interface mask flows correctly dataset → collator → trainer. The only findings are cosmetic/dead-code nits (chief among them an unused include_partner_sidechains parameter in the internal _batch.py) that can be cleaned up in a trivial follow-up and do not affect correctness or the 274-test green suite.
<subagent_tokens>115710</subagent_tokens><tool_uses>34</tool_uses><duration_ms>197675</duration_ms>