Skip to content

Expose safe effect-graph codec and eliminate cross-module private imports (11.17.0) - #753

Merged
iskandr merged 1 commit into
mainfrom
refactor/public-helpers-and-effect-codec
Nov 20, 2026
Merged

iskandr merged 1 commit into
mainfrom
refactor/public-helpers-and-effect-codec

Conversation

@iskandr

@iskandr iskandr commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #674
Closes #692

1. Public finite class registry, safe typed JSON codec, and annotator listing API (#674)

  • Add effect_serialization_classes() -> Mapping[tuple[str, str], type], returning a read-only allowlist of reviewed classes accepted in native Varcode effect and EffectCollection archives (including backwards-compatible legacy aliases _EffectReference, _AssembledAllele, _ORFTranscript, _ReferenceGenome, _Feature, and _ReferenceTranscript, plus PinnedEnsemblGenome; upstream public export tracked in Export PinnedEnsemblGenome from a public module for finite serialization registries orfdata#210).
  • Add EffectReference, AssembledAllele, effect_to_json, effect_from_json, effect_from_serializable_repr, effect_collection_to_json, effect_collection_from_json, and effect_collection_from_serializable_repr at the package root.
  • Route MutationEffect.from_json(), EffectCollection.from_json(), and EffectCollection.from_csv() effect_json restoration through the finite-allowlist decoders, preserving graph cycles, candidate ordering, germline/haplotype baselines, and orf_effect_schema snapshots while rejecting unreviewed classes and arbitrary function metadata without dynamic module imports.
  • Promote default_effect_sort_key (retaining _default_effect_sort_key for legacy EffectCollection archives).
  • Add registered_annotators(*, include_deprecated: bool = False) -> tuple[str, ...] so callers can inspect registered annotator names without importing private registry state.

2. Eliminate cross-module underscore imports & split effects/structural.py (#692)

  • Promote all cross-module _name helpers to documented public names in their owning modules (contigs, mutant_transcript, orf, orf_serialization, genome_sequence, germline, reference, rna_evidence, structural_variant, sv_allele_parser, transcript_model, vcf, vcf_parsing, effects/classify, effects/effect_prediction), and rename varcode/_sample_vcf.py to varcode/sample_vcf.py.
  • Split varcode/effects/structural.py into structural_models.py, structural_fusions.py, structural_candidates.py, and structural.py, and break the two-way private import cycle between structural and sequence_change via structural_variant.affected_span and mutant_transcript.retained_cds_start.
  • Enforce zero cross-module private symbol/module imports in tests/test_private_imports.py, and cover ordinary, splice, germline/phased, structural, extra-ORF, legacy-alias, and untrusted-class rejection cases in tests/test_safe_effect_codec.py.

Version

  • Bump varcode to 11.17.0 with release notes in CHANGELOG.md, API docs in docs/api_effects.md and docs/api_annotators.md, and static typing checks in tests/typing/api_inputs.py.

…orts (11.17.0)

- Expose a documented read-only finite class registry (`effect_serialization_classes`)
  and safe typed JSON codec (`EffectReference`, `AssembledAllele`, `effect_to_json`,
  `effect_from_json`, `effect_from_serializable_repr`, `effect_collection_to_json`,
  `effect_collection_from_json`, `effect_collection_from_serializable_repr`) for
  native effect and `EffectCollection` graphs, routing `MutationEffect.from_json`,
  `EffectCollection.from_json`, and `EffectCollection.from_csv` `effect_json`
  decoding through the finite allowlist without dynamic module imports.
- Add public `registered_annotators(*, include_deprecated=False)` API.
- Eliminate all cross-module single-underscore imports across `varcode/`, split
  `varcode/effects/structural.py` into `structural_models.py`, `structural_fusions.py`,
  `structural_candidates.py`, and `structural.py`, break the `structural` <->
  `sequence_change` private cycle, and add AST lint and codec regression tests.

Closes #674
Closes #692
@iskandr
iskandr merged commit b5b1c0a into main Nov 20, 2026
6 checks passed
@iskandr
iskandr deleted the refactor/public-helpers-and-effect-codec branch November 20, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant