Extending DRTML
DRTML extension is a vertical change. A YAML field is not a feature until it has a model/parser, validation, a compiled representation, a runtime consumer, tests, and documentation.
Choose the owning layer first
Section titled “Choose the owning layer first”- Manifest syntax/model/validation →
framework/drtml/. - Runtime data I/O →
framework/storage/orframework/db/<engine>/. - Execution lifecycle →
framework/processing/<mode>/. - Pure math →
framework/algorithms/. - UI/Airflow/Ray connection →
framework/integration/. - Metric emit/dashboard codegen →
framework/telemetry/. - Shared DTO across those layers →
framework/contracts/.
Do not put runtime behavior in the parser and do not teach domain steps to interpret framework sections.
Add a field to an existing typed section
Section titled “Add a field to an existing typed section”Example: a new feed.read option.
- Add it to the smallest Pydantic model under
drtml/models/<section>/. - Use
extra="forbid"unless the block is an explicit plugin envelope. - Add field-level and cross-field validators.
- Propagate it into the frozen compiled plan.
- Consume it in the owning runtime module.
- Add parse/validation, compile, and runtime tests.
- Add a DRTML example and update the relevant reference page.
Never read raw manifest __pydantic_extra__ in unrelated runtime code when a typed plan is appropriate.
Add a new section
Section titled “Add a new section”- Create a model package under
drtml/models/<section>/(or a dedicateddrtml/<section>/parser for storage-style sections). - Add the root field to
StepManifestif it is universally typed; use versioned validation for compatibility. - Add
parse_<section>_planand an immutable plan model. - Wire it once in
compile_step_manifest. - Pass the plan to runtime; runtime must not reload or reparse YAML.
- Add it to
FILES.mdand docs.
Do not create import-only shims such as drtml/new_section.py that only re-export models.new_section.
Add a new param namespace
Section titled “Add a new param namespace”- Add the namespace to
ALLOWED_PARAM_NAMESPACES. - Decide and document who may read it.
- Add
params_defaultsto manifests that require it. - If exposed in UI, ensure a runtime/domain reader consumes it.
- Never use
domain.*for framework orchestration.
Add a dataset backend
Section titled “Add a dataset backend”- Add the backend literal/whitelist in DRTML storage parsing and
StoragePlan. - Add backend-specific inline block model/parser and compatibility validation.
- Implement transport in
db/<engine>/when an external system is involved. - Implement
DatasetWriteBackend/DatasetReadBackendadapters. - Register adapters in
backend_builtinsor plugin initialization. - Keep
StorageSessionfree ofif backend ==branches. - Add fake contract tests and integration tests.
See New dataset backend.
Add a new execution pattern or mode
Section titled “Add a new execution pattern or mode”- Define its typed DRTML block and plan.
- Implement a thin orchestration runner under
processing/<mode>/. - Put algorithms and I/O in their owning packages.
- Register with
register_pattern_runnerorregister_mode_runner. - Prefer
execution.entryfor product-specific execution that does not deserve a framework-wide pattern.
Do not add another branch to run_from_manifest.
Add a metric source or method
Section titled “Add a metric source or method”A metric method computes a dataset value: add MetricMethod through register_method, plus backend capabilities/SQL when needed.
A metric source maps runtime state to Prometheus: extend the metrics model source catalog, emit plan, source emitter, tests, and dashboard behavior if applicable.
Keep computation in algorithms/DB, orchestration in processing, and Prometheus emission in telemetry.
Compatibility policy
Section titled “Compatibility policy”- Additive optional fields are safe within a DRTML version.
- Renames/removals need explicit validation errors and migration text (not silent aliases forever).
- Defaults that change run behavior belong in each step’s DRTML, not hidden in generic framework code.
- A parser accepting a field that runtime ignores is a bug.