Skip to content

Remove the dead facades and give the rollback tail an owner - #187

Merged
dhsohn merged 1 commit into
mainfrom
fix/dead-facades-and-misplaced-code
Aug 30, 2026
Merged

Remove the dead facades and give the rollback tail an owner#187
dhsohn merged 1 commit into
mainfrom
fix/dead-facades-and-misplaced-code

Conversation

@dhsohn

@dhsohn dhsohn commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Motivation

Three kinds of code that reads like it does something and does not: forwarding
methods whose only callers are the tests that verify the forwarding, a helper
that calls itself through two hops of adapter indirection, and one eight-line
rollback tail copy-pasted five times because nothing owned it. Plus 49 lines of
scene-rect code living in the wrong module of its own package.

Changes

Twenty-three dead facade methods removed, net −488 lines. Each candidate was
re-measured on the current tree rather than taken from the survey: forwarding
methods collected by AST, then production callers counted unfiltered from two
angles — call sites and bare-word occurrences, because six candidates turned out
to be alive only as bound-method references (kwarg=self.method) that a
call-site grep alone would have missed, and those six stay. Removals cascade:
deleting a forwarder often left its target at zero production callers too, so
the unit is the chain, not the method — bond_merge_seed through two layers
down to the module function that has a real internal caller and survives,
get_name_from_smiles down to the 18-entry _name_map dict that existed only
to serve it. Tests that verified only the deleted wiring were deleted with it —
one asserted against a bare mock.Mock() and could never have failed for a real
reason — and tests that verified behavior through a facade were re-aimed at the
real path.

The set_text_align name stays in the boundary file's re-introduction ban list,
which is the ban working as intended, not a leftover.

The scene-rect snapshot trio moved home. capture/release/ restore_scene_rect_snapshot lived in scene_runtime.py — the package's largest
module — while scene_rect.py is the declared owner of everything scene-rect.
Same names, same package, both files already inside the rollback-kernel checks'
glob.

Two adapter round trips flattened. RDKitConversionHelper called two of its
own methods as self.adapter.X(...), which the adapter forwards straight back
to the helper. Read before flattening: those two adapter methods are pure
forwarding with no last_error reset and no RDKitResult wrapping, and no test
patches them on the adapter. The _embed_3d_molecule hops that look similar are
not flattened — the adapter's own comment calls them a seam, and tests
really do patch that seam.

The rollback tail got an owner. Re-measured after the note-consolidation
series, the eight-line "restore the absolute scene/runtime snapshots" tail was
still copied verbatim in five places across history_commands and
scene_runtime. It is now restore_absolute_snapshots() in scene_runtime,
next to the restore machinery it drives; the raise decisions stay at the call
sites.

One thing found and deliberately not done: with its controller forwarder gone,
InsertSmilesService.load_smiles — the whole document-replacing SMILES load
with its exact-rollback machinery — now has zero production callers. That is a
feature removal, not a cleanup, so it is recorded here and left for a separate
decision rather than folded into this diff.

Verification

bash scripts/check.sh — exit 0: ruff clean, formatted, mypy clean, all 300
test files passing in their own processes. The nineteen affected test files pass
directly — 694 tests — including test_core_rdkit_adapter under a real RDKit
install, which covers the flattened calls.

Every "zero consumers" claim in this diff is backed by an unfiltered two-angle
search recorded before the removal, and the survivors list shows the method that
each angle saved. No file mode changed.

…roundtrips

Batch 10 of the dead-facade / misplaced-code cleanup (L2-04 partial, L2-07,
L2-08, L2-11).

L2-07 dead forwarders (production consumers 0, evidence: unfiltered git grep
two angles - attribute-call sites and word occurrences):
- InsertController: load_smiles, template_point_resolvers,
  resolve_ring_points_for_template,
  resolve_regular_ring_points_for_template_bond,
  resolve_chair_points_for_template, resolve_boat_points_for_template,
  resolve_template_points_for_template_bond, bond_merge_seed
- MainWindowTextStyleService.set_text_align (+ now-orphaned _TEXT_ALIGNMENTS)
- StructureBuildService: ensure_ring_fills_for_model, add_linear_chain
- RDKitAdapter.get_name_from_smiles
Second-order ripple (targets whose only production caller was a removed
forwarder): the six InsertTemplateService resolver forwarders,
InsertCommitService.bond_merge_seed (module-level owner in
insert_template_commit_service stays), CanvasStyleController.set_text_alignment
(production alignment flows through the note controller),
StructureBuildCommitter.ensure_ring_fills_for_model / add_linear_chain,
RDKitImportHelper.get_name_from_smiles (+ orphaned RDKitAdapter._name_map).
Wiring-only tests deleted (including one that exercised a bare mock.Mock());
real-behavior tests retargeted to the real paths (smiles_service.load_smiles,
template_geometry resolvers, module-level bond_merge_seed).

L2-11: capture/release/restore_scene_rect_snapshot moved from
ui/transactions/scene_runtime.py to their owner ui/transactions/scene_rect.py,
names unchanged; consumers (scene_runtime, history_commands, tests) now import
from scene_rect. Both modules stay in the rollback-kernel list and the
history-transaction acyclic cluster; scene_rect does not import scene_runtime.

L2-08: the absolute-restore rollback tail (restore scene/runtime snapshot,
then scene rect) was still copied verbatim at 5 sites (3 in
history_commands.py, 2 in scene_runtime.py); consolidated into
scene_runtime.restore_absolute_snapshots, `raise` stays at call sites.

L2-04 partial: flattened two conversion-helper roundtrips that went
helper -> adapter -> same helper with no side effect on the adapter hop
(model_to_rdkit_with_map_tolerant in _suggest_atom_correspondence,
model_to_rdkit_with_map_strict_labels in model_to_rdkit_strict_labels).
The _embed_3d_molecule/_build_conversion_rdkit_mol pair is untouched: it is
a documented test seam (tests patch those names on the adapter).

Left for a separate decision: InsertSmilesService.load_smiles (plus its
transaction-builder/rollback machinery) is now production-caller-0 but is a
coherent feature with characterization tests; not removed in this batch.

Verification: scripts/check.sh GATE EXIT=0 (300 test files); affected suites
run directly, including test_core_rdkit_adapter under real RDKit;
git diff --summary shows no mode changes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T06:28:18.772910Z 7f6e749 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dhsohn
dhsohn merged commit 357bb63 into main Aug 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant