Import, registry, and plugin surface¶
Import-time behavior¶
Evidence |
Behavior |
Consequence |
|---|---|---|
|
Eagerly imports and re-exports most stable-looking primitives; |
A normal root import has broad dependency and side-effect reach |
|
Extends |
Excluded wrapper can mask package identity and duplicate implementations |
|
Clears the settings cache, reads environment, and publishes globals |
Import order determines configuration snapshots |
|
Read KDF environment overrides at import |
Ciphertext behavior depends on ambient pre-import state |
|
Imports the pyca backend to register it |
Import mutates the backend registry |
|
Emit deprecation/experimental warnings |
Import is observable |
|
Registers a serialized protobuf descriptor |
Generated global descriptor state |
|
Calls Atheris setup/fuzz at module top level |
Harness import starts fuzzing |
|
Mutates |
Documentation import behavior differs from installed-wheel behavior |
Dynamic loading¶
cryptography_suite/keystores/__init__.py:41-50 discovers and imports every
built-in keystore module. Lines 53-69 optionally execute every *.py file from
an explicit directory or from cwd/keystores when
CRYPTOSUITE_LOAD_LOCAL_KEYSTORE_PLUGINS=1. Lines 75-82 load the
cryptosuite.keystores entry-point group. Failures are logged and accumulated
rather than raised.
cryptography_suite/cli.py:1084-1103 uses
spec_from_file_location/exec_module to load the excluded
src/cryptography_suite/cli/migrate_keys.py file. This works only in a
particular source checkout layout and fails from the built wheel.
cryptography_suite/codegen/__init__.py loads Jinja templates through package
resources. Optional modules otherwise use ordinary guarded imports or
import_module, notably the AWS KMS provider.
Registries¶
Registry |
Evidence |
Replacement behavior |
|---|---|---|
Keystore |
|
|
Crypto backend |
|
Decorator and instance selection silently replace the name |
Pipeline module |
|
Rejects a different class with an existing name |
Entry points |
|
Third-party code executes on load |
use_backend() constructs _BackendContext, whose constructor immediately
calls __enter__ (crypto_backends/__init__.py:38-45). Merely creating the
context manager therefore mutates selection. If no selection exists,
get_backend() chooses the first insertion-ordered registered backend
(:107-123).
Global mutable state¶
keystore registry and failed-plugin list;
backend registry plus current-backend/warning
ContextVars;pipeline module registry;
audit logger singleton;
CLI output format;
operational metrics and process cancellation event;
cached settings and import-time configuration constants;
warning-deduplication sets in experimental helpers.
v4 disposition¶
Stable v4 should use explicit provider construction and a sealed registry or allowlist owned by an application context. Local executable discovery from the current working directory is not a stable-core feature. Third-party providers need an explicit enablement and conflict policy. Experimental import aliases, source-path mutation, and the dynamically loaded migration file should be removed during the canonical-layout work, after Phase 2 defines compatibility.