Skip to content

refactor(transparency): resolve method families via own algorithm_registry; drop framework hardcoding#355

Merged
stanlrt merged 5 commits into
mainfrom
318-transparency-registry-driven-semantics
Jul 7, 2026
Merged

refactor(transparency): resolve method families via own algorithm_registry; drop framework hardcoding#355
stanlrt merged 5 commits into
mainfrom
318-transparency-registry-driven-semantics

Conversation

@stanlrt

@stanlrt stanlrt commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Removes bootstrap-era hardcoded ShapExplainer/CaptumExplainer knowledge from the framework-agnostic transparency layer (issue #318), so third-party plugin adapters are handled correctly instead of silently mishandled.

Investigation showed the fix is a pure simplification, not a new abstraction: every real explainer — in-tree or plugin — is a decorated adapter carrying its own algorithm_registry ClassVar (mandated by @adapters.transparency), so it always resolves via the own-registry lookup. The framework-label path and the cross-framework algorithm-string scan were dead in production (only test stubs reached them), and the factory's "shap"/"captum" name-sniffing gate actively skipped the visualiser semantic-compat check for plugins named neither.

Changes:

  • transparency/semantics.py: method_families_for_explainer / _hints_for_explainer now resolve solely via type(explainer).algorithm_registry (same shape as robustness/semantics.py). Deleted the dead helpers _adapter_class_for_framework, _explainer_framework, _normalise_framework, _method_families_for_algorithm, and the unused AbstractSet import.
  • transparency/factory.py: deleted _requires_registry_semantics (the name-sniff gate) and the two hardcoded explainer imports; check_explainer_visualiser_semantic_compat now always runs and dropped its unused explainer_target param.
  • Tests: stubs rewritten to use real adapter instances / real algorithm_registry; deleted tests that only exercised the removed fallback paths.

Net: 25 insertions / 225 deletions. No behavior change for shap/captum; the only intended behavior change is that the visualiser semantic-compat check now also runs for adapters named neither (i.e. future plugins).

API note (reviewers): removed the algorithm= keyword param from the public infer_output_space and the explainer_target param from check_explainer_visualiser_semantic_compat. Both were dead — no in-tree production caller passed them (only tests did). Pre-1.0, treated as a clean removal, not a breaking change.

Closes #318.

Checklist

  • CI — Required checks are green
  • Breaking changes — Not a breaking change: the only removed surface (infer_output_space(algorithm=...), check_explainer_visualiser_semantic_compat(explainer_target=...)) had no production callers. No ! in the title.
  • Contributor guide — I’ve read Pull requests and commit messages before requesting review.

Optional

@stanlrt stanlrt changed the title refactor(transparency): resolve method families via own algorithm_registry; drop framework hardcoding (refs #318) refactor(transparency): resolve method families via own algorithm_registry; drop framework hardcoding Jul 7, 2026
@stanlrt stanlrt force-pushed the 318-transparency-registry-driven-semantics branch from 172a3e5 to 9cc2a6a Compare July 7, 2026 22:14
@stanlrt

stanlrt commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Folded in two de-hardcode follow-ups surfaced by a parallel dead-code audit (same #318 smell family), commit 9cc2a6ae:

  • utils/diagnostics.py: replaced the hardcoded ("raitap.transparency", "raitap.robustness") provider tuple with a register_configs() call — now aggregates third-party libs across all families + discovered plugins (drift-proof, plugin-inclusive), instead of a hand-maintained 2-family subset.
  • robustness/_ci_router.py: derive the ci_method value set from get_args(CIMethod) instead of re-declaring the ("wilson", "clopper_pearson") literal (no-duplicated-Literals rule). Error wording unchanged.

Both verified locally (test_diagnostics 16, test_ci 6 green).

@stanlrt stanlrt merged commit b799371 into main Jul 7, 2026
18 checks passed
@stanlrt stanlrt deleted the 318-transparency-registry-driven-semantics branch July 7, 2026 22:23
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.

Transparency semantics/factory hardcode SHAP/Captum adapter classes (silently breaks plugin adapters)

1 participant