Pipeline¶
The detection pipeline transforms rule definitions into detector configurations and executes them.
Pipeline configuration¶
mcp_zen_of_languages.analyzers.pipeline.PipelineConfig
¶
Bases: BaseModel
Typed container for the detector configs that drive a language pipeline.
A PipelineConfig holds an ordered list of
DetectorConfig instances
ready for execution by
DetectionPipeline.
Configs are either projected from zen principles via from_rules
or loaded from zen-config.yaml and validated through the registry's
discriminated-union :pyclass:TypeAdapter.
| ATTRIBUTE | DESCRIPTION |
|---|---|
language |
ISO-style language identifier (e.g.
TYPE:
|
detectors |
Ordered detector configs; validated on assignment via
TYPE:
|
Functions¶
from_rules
classmethod
¶
Build a complete pipeline by projecting a language's zen principles.
Loads the LanguageZenPrinciples
for language, then delegates to
configs_from_rules
to project each principle's metrics onto the matching detector configs.
| PARAMETER | DESCRIPTION |
|---|---|
language
|
Language key recognised by
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PipelineConfig
|
A fully populated
TYPE:
|
PipelineConfig
|
all zen principles defined for the language. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no zen rules exist for language. |
Examples:
Source code in src/mcp_zen_of_languages/analyzers/pipeline.py
Pipeline utilities¶
mcp_zen_of_languages.analyzers.pipeline.project_rules_to_configs
¶
Convert zen principle metric thresholds into typed detector configs.
For every ZenPrinciple
in lang_zen, the function resolves which detectors are registered for
that rule and maps the principle's metrics dict onto each detector's
config fields. Keys that don't match any registered config field raise
immediately so typos in rule definitions are caught at startup.
| PARAMETER | DESCRIPTION |
|---|---|
lang_zen
|
The complete set of zen principles for a single language, including metric thresholds and violation specs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DetectorConfig]
|
list[DetectorConfig]: Ordered detector configs with thresholds populated from the rules. |
See Also
DetectorRegistry.configs_from_rules
— the registry method this function delegates to.
Source code in src/mcp_zen_of_languages/analyzers/pipeline.py
mcp_zen_of_languages.analyzers.pipeline.merge_pipeline_overrides
¶
Layer user overrides from zen-config.yaml onto rule-derived defaults.
Override entries are matched to base entries by DetectorConfig.type.
When a match is found, only the fields explicitly set in the override are
applied (via model_dump(exclude_unset=True)), preserving every
rule-derived default that the user didn't touch. Overrides whose type
doesn't appear in the base are appended as new detector entries.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
Pipeline produced by
TYPE:
|
overrides
|
Pipeline section from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PipelineConfig
|
A new
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If overrides.language doesn't match base.language. |
Source code in src/mcp_zen_of_languages/analyzers/pipeline.py
Mapping models¶
mcp_zen_of_languages.analyzers.mapping_models.RuleBinding
¶
Bases: BaseModel
Explicit binding between one rule id and its dogma/violation bounds.
Functions¶
model_post_init
¶
Default empty violation selectors to the wildcard selector.
Source code in src/mcp_zen_of_languages/analyzers/mapping_models.py
mcp_zen_of_languages.analyzers.mapping_models.RuleDetectorBinding
¶
Bases: BaseBinding
Declares which detector class enforces one or more zen rules.
Each binding is authored in a language's mapping.py and consumed by
registry bootstrap during startup.
| ATTRIBUTE | DESCRIPTION |
|---|---|
detector_id |
Unique key that doubles as the
TYPE:
|
detector_class |
Concrete
TYPE:
|
config_model |
Pydantic model used to validate threshold values projected from zen principle metrics.
TYPE:
|
rules |
Explicit per-rule bounds for this detector. Each bound rule carries its own violation selectors and dogma ids.
TYPE:
|
default_order |
Pipeline execution order; lower values run first.
TYPE:
|
enabled_by_default |
If
TYPE:
|
Attributes¶
rule_verified_dogma_map
property
¶
Return explicitly authored verified dogma ids grouped by rule id.
rule_verified_testing_map
property
¶
Return explicitly authored verified testing ids grouped by rule id.
rule_projection_map
property
¶
Return explicit projection family ids grouped by rule id.
rule_verified_projection_map
property
¶
Return explicitly authored verified projection ids grouped by rule id.
Functions¶
build_bundle
¶
Build the rule-perspective bundle for a rule detector binding.
Source code in src/mcp_zen_of_languages/analyzers/mapping_models.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
mcp_zen_of_languages.analyzers.mapping_models.NonRuleDetectorBinding
¶
Bases: BaseBinding
Binding for generic detectors that do not map to explicit rules.
Functions¶
build_bundle
¶
Build the rule-perspective bundle for a non-rule detector binding.
Source code in src/mcp_zen_of_languages/analyzers/mapping_models.py
mcp_zen_of_languages.analyzers.mapping_models.LanguageDetectorMap
¶
Bases: BaseModel
All current detector bindings for one language, exported as DETECTOR_MAP.
Each language's mapping.py module constructs a single instance of
this model and assigns it to the module-level DETECTOR_MAP constant,
which DetectorRegistry.bootstrap_from_mappings
reads during startup.
| ATTRIBUTE | DESCRIPTION |
|---|---|
language |
Language identifier matching
TYPE:
|
bindings |
Ordered list of detector bindings for this language.
TYPE:
|
mcp_zen_of_languages.analyzers.mapping_models.FullDetectorMap
¶
Bases: BaseModel
Aggregate view of detector bindings across every supported language.
Primarily useful for tooling and introspection; the registry itself
iterates individual LanguageDetectorMap instances during bootstrap.
| ATTRIBUTE | DESCRIPTION |
|---|---|
languages |
Mapping from language identifier to its
TYPE:
|