Source:
__
Local role: Orchestrates the full generation workflow: rule application → builder dispatch → optional registration → optional validation → structured result.
Big-picture role:
Top-level entry point for the generation architecture (F-16 to F-22). Accepts a GenerationContext, applies the configured GenerationRuleSet, delegates to the appropriate builder, and returns a GenerationResult carrying the generated object, applied rule names, validation outcome, and repair suggestions.
Parameters and fields (ContextualGenerationPipeline):
rules: GenerationRuleSet— rule set applied before building; defaults tocombined_generation_rules()validation_pipeline: ValidationPipeline | None— optional validation pipeline; only runs whencontext.validate=True
Methods (ContextualGenerationPipeline):
generate(context, *, world=None) -> GenerationResult— full pipeline: rules → build → register → validategenerate_from_text_response(context, *, raw_response, ...)— parses an LLM text response into context overrides then delegates togenerate
Parameters and fields (GenerationResult, dataclass):
generated: Any— the model object produced by the builderapplied_rule_names: list[str]— names of rules that were part of the active rule set (in order)validation: ValidationResult | None— validation outcome;Noneif validation was not requesteddiagnostics: list[str]— ordered human-readable pipeline stage messagesuncertainty_zones: list[str]— uncertainty zones declared in the contextrepair_suggestions: list[str]— suggested fixes when validation fails
Notes:
- Supported
context.operationvalues:"create","partial_update","corrective_update". - Supported
context.registration_policyvalues:"none","if_available","require". applied_rule_namesreflects the rule set configuration, not which predicates fired.- Validation only runs when
context.validate=Trueand avalidation_pipelineis provided. - The pipeline does not call
LLMGenerationAdapterautomatically; callers must chain it explicitly.
See also:
Example:
from ometeotl_core.generation.pipeline import ContextualGenerationPipeline
from ometeotl_core.generation.context import GenerationContext
ctx = GenerationContext(
kind="actor",
id="actor-1",
label="Scout",
attributes={"mobility": True},
validate=True,
validation_mode="lenient",
)
pipeline = ContextualGenerationPipeline()
result = pipeline.generate(ctx, world=world)
actor = result.generated
print(type(actor).__name__) # "Actor"
print(result.applied_rule_names) # rules that ran in the rule set
if result.validation:
print(result.validation.valid)
Generation flow
GenerationContext
→ GenerationRuleSet.apply() # constraint propagation and normalization
→ build_from_context() # kind dispatch → builder
→ registration_policy check # optional world registry update
→ ValidationPipeline.validate() # optional; only when context.validate=True
→ GenerationResult
