Skip to content

refactor: remove dead code and duplication left by the resolution consolidation (#853) - #863

Merged
TomKaltofen merged 5 commits into
mainfrom
chore/853-remove-dead-code-resolution-consolidation
Jul 20, 2026
Merged

refactor: remove dead code and duplication left by the resolution consolidation (#853)#863
TomKaltofen merged 5 commits into
mainfrom
chore/853-remove-dead-code-resolution-consolidation

Conversation

@TKaltofen

Copy link
Copy Markdown
Collaborator

Closes the #853 cleanup: removes dead surface and collapses duplicated logic left by the FeatureGroup-resolution consolidation. No production behavior change is intended.

Dead surface removed

  • Engine.copy_compute_frameworks (assigned, never read).
  • The raising-constructor surface of IdentifyFeatureGroupClass (__init__ that raised, get(), .result, feature_group_compute_framework_mapping). The engine and resolve_feature already resolve through evaluate(); removing the wrapper also drops the cls.__new__(cls) contortion inside evaluate() (now a plain __init__ builds the per-attempt instance).
  • The unreachable empty-environment render branch and its now-dead environment_empty fact. PreFilterPlugins raises EnvironmentPreconditionError("No feature groups are loaded. Did you call PluginLoader.all()?") before an empty mapping can reach the renderer, so the render-layer duplicate was unreachable in production.
  • The constant ResolvedFeature.environment (always "standalone-default").

Duplications collapsed to a single owner

  • _as_str moved next to safe_field as components/utils.as_str (was defined twice).
  • PARTIAL_RECORDS_CAP is now applied in one place: FeatureResolutionError.__init__ caps and snapshots (deep-copies) the records; the engine passes them raw.
  • resolve_feature reads the winner's supported/unsupported framework split from the seam's captured result.candidate_frameworks instead of recomputing it.
  • The three near-identical strict-mode "warn about unregistered plugins" blocks (FeatureGroups, ComputeFrameworks, Extenders) now call one _warn_once_unregistered helper.

Tests

Migrated ~15 test files off the removed raising constructor to IdentifyFeatureGroupClass.evaluate(...), via a shared engine-seam helper tests/test_core/test_prepare/identify_seam.py (evaluate_or_raise / identify_winner) that mirrors how the engine renders and raises a resolution failure. Added a positive assertion for the nothing-loaded PluginLoader.all() precondition (now owned by PreFilterPlugins).

Breaking change

ResolvedFeature.environment (a public dataclass field added in #757) is removed. It was a constant, the four-positional-argument constructor is unchanged, and #853 states backwards compatibility is not required, but external consumers reading result.environment are affected.

Validation

tox green: 7115 passed, 170 skipped, ruff format/ruff check clean, license allowlist OK, mypy --strict no issues in 880 files, bandit OK. Two independent deep reviews (a fresh Claude Opus agent and codex) found no correctness regressions; the one actionable finding (the missing positive assertion above) is addressed in this PR.

…ns (#853)

- delete unread Engine.copy_compute_frameworks
- make PARTIAL_RECORDS_CAP a single owner: FeatureResolutionError caps and
  snapshots the records, the engine passes them raw
- collapse resolve_feature's winner framework-split to the seam's captured
  result.candidate_frameworks
- move _as_str to components/utils.as_str, deduplicating the two copies
…le empty-environment render branch (#853)

- remove ResolvedFeature.environment, which was always "standalone-default"
- remove the empty-environment render branch and the now-dead environment_empty
  fact; PreFilterPlugins already owns the no-plugins-loaded message in production
- migrate the tests and docs that pinned the removed surface
…rface (#853)

The engine and resolve_feature resolve through evaluate(); the raising
constructor, get(), .result and feature_group_compute_framework_mapping had no
production caller and forced a cls.__new__ contortion inside evaluate().

- replace __init__ with a plain per-attempt memo initializer and build the
  instance in evaluate() with cls(...) instead of cls.__new__(cls)
- drop get(), the .result attribute and feature_group_compute_framework_mapping
- migrate the tests off the constructor to evaluate(), via a shared engine-seam
  helper (evaluate_or_raise / identify_winner) that mirrors how the engine
  renders and raises a resolution failure
FeatureGroups, ComputeFrameworks and Extenders each repeated the same
"warn once per unregistered plugin" logic. Extract _warn_once_unregistered and
call it from all three strict-mode filters.
#853)

Restores positive coverage for the "No feature groups are loaded. Did you call
PluginLoader.all()?" precondition, which PreFilterPlugins owns after the
duplicate render-layer branch was deleted.
@TKaltofen
TKaltofen requested a review from TomKaltofen as a code owner July 20, 2026 07:14
@TomKaltofen
TomKaltofen merged commit e829544 into main Jul 20, 2026
18 checks passed
@TomKaltofen
TomKaltofen deleted the chore/853-remove-dead-code-resolution-consolidation branch July 20, 2026 14:16
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.

2 participants