Overview¶
The models domain is the SDK surface modules use when they need to work with core-managed entities instead of module-owned tables.
This distinction matters.
If the data belongs to your module, module_sdk.database is usually the right tool.
If the data belongs to the application core and already has an official model layer with access rules, filters, table schemas, and form schemas, module_sdk.models is the right entry point.
That means module_sdk.models is not a generic ORM and it is not a raw database escape hatch. It is a proxy layer over the core model registry.
Mental Model¶
When you write:
module_sdk.models.usersyou are not receiving a SQLAlchemy model and you are not receiving a plain repository object.
You are receiving a lazy proxy that will:
- capture the current SDK session context
- build a
CoreModelContext - resolve the named core model through the core registry
- call the selected method on that model
That context contains:
user_idorganization_idaccess_levelmodule_name- the full session payload
- the
bypassflag when bypass policy is allowed
So the normal way to use this domain is not “construct context manually”, but simply “call the model proxy and let the SDK bind the current request identity for you”.
What This Domain Is For¶
Use module_sdk.models when your module needs to work with application-owned entities such as:
- users and roles
- module locks
- engine, extractor, and model registries
- MCP server registrations
- observability data such as background tasks, audit events, and LLM usage
One of the biggest advantages of this domain is that the core model often exposes more than CRUD:
filters_model()for allowed filter definitionstable_model()for table schemasform_model_create()andform_model_update()for form generation- model-specific methods such as
users.verify(...)orroles.form_model_extra(...)
That makes it especially useful when you are building module pages that should stay aligned with the platform’s canonical representation of a core entity.
Current Registered Core Models¶
At the moment, the core registry exposes these model names:
usersrolesmodule_locksengine_registryengine_node_install_registryenvironment_variable_registrymodel_registryavailable_model_registrymodel_capability_priorityobjective_mappingsextractor_registryextractor_mime_type_bindingextractor_node_install_registrymcp_server_registrybackground_tasksaudit_eventsai_model_usageai_model_pipeline_steps
The sidebar breaks these out into dedicated pages so each model can be explained in its own context.
Important Boundary: models vs database¶
Use module_sdk.models when:
- the entity is owned by the core platform
- the model already defines access scope, filters, schemas, and serialization
- you want to stay aligned with the platform contract
Use module_sdk.database when:
- the table belongs to your module
- the schema is module-defined
- the lifecycle is fully under module control
If you ignore this distinction, you usually end up duplicating platform behavior or bypassing access rules the runtime already knows how to enforce.
Subsections¶
- Working With Core Model Proxies
- one page for each registered core model