Definition Time Guide¶
Guide Maps¶
graph LR
prepare["__prepare__"] --> body["Class body executes"]
body --> setname["Descriptors receive __set_name__"]
setname --> new["PluginMeta.__new__"]
new --> registry["Registry and signature become visible"]
flowchart LR
question["What happens before any plugin instance exists?"] --> step["Trace the definition-time steps"]
step --> owner["Name the owning file or hook"]
owner --> proof["Choose the matching test or inspection route"]
Use this guide when the capstone's runtime seems clear but the class-definition behavior still feels like hidden magic. The goal is to make the definition-time sequence explicit before you reason about invocation.
Definition-time sequence¶
PluginMeta.__prepare__returnsDefinitionNamespace.- The class body executes and places fields and wrapped actions into that namespace.
- Descriptors receive
__set_name__and learn their storage keys. PluginMeta.__new__gathers inherited and local fields and action specs.- A constructor signature is generated from the collected fields.
- Concrete plugins receive their group and public plugin name.
- Concrete plugins are registered in the deterministic runtime registry.
Why this matters¶
- duplicate tracked members are rejected during class-body execution
- descriptors become meaningful before instance creation because names and storage keys are fixed
- generated constructor signatures make field declarations visible to tooling
- manifest and registry output depend on definition-time work staying deterministic
Best proof surfaces¶
tests/test_registry.pyfor constructor signatures, duplicate protection, and wrapped metadatamanifestandregistryoutput for the public consequences of definition-time workframework.pyandfields.pyfor the owning implementation path
Best companion guides¶
- read PLUGIN_RUNTIME_GUIDE.md when the terms are still fuzzy
- read CONSTRUCTOR_GUIDE.md when generated
__init__and signature behavior needs its own explanation - read PACKAGE_GUIDE.md when you want the file route for the same sequence
- read PROOF_GUIDE.md when you want the command route after the sequence is clear