推导基础设施 API¶
基础设施分离三个关注点:
- schema authoring 创建 immutable、codec-visible 的 record 与封闭 ADT;
- pass authoring 从 annotation 提取静态 contract,不包装执行语义;
- transaction runner 在 commit 前验证输入、输出、lineage rule、deterministic replay、analysis 与 checkpoint。
Schema authoring¶
Expert authoring surface for canonical records and closed algebraic data.
Application users do not need these helpers. They are intentionally grouped
here for core schema and trusted dialect authors; registry and manifest
implementation details remain in :mod:blueprinting.schema.deriving.
record ¶
Derive an immutable canonical record from an annotated class declaration.
Source code in src/blueprinting/schema/deriving.py
adt ¶
Declare the shared semantic wire namespace for a closed sum type.
Source code in src/blueprinting/schema/deriving.py
variant ¶
Derive and register one explicitly named constructor of an ADT family.
Source code in src/blueprinting/schema/deriving.py
adt_manifest ¶
Return a deterministic documentation/schema manifest for one ADT family.
Source code in src/blueprinting/schema/deriving.py
Pass authoring¶
Stable authoring surface for verified derivation passes.
Application code should execute passes through :class:PassManager. This
module is for trusted pass and target-extension authors and deliberately omits
transaction-runner and registry implementation details.
derivation ¶
derivation(name: str, *, revision: str, bindings: Iterable[BindingAxis] = (), requires: Iterable[AnalysisKey] = (), preserves: Iterable[AnalysisKey] = (), produces: Iterable[AnalysisKey] = (), rules: Iterable[PassRule] = (), mutation: MutationModel = MutationModel.IMMUTABLE, verification: VerificationPolicy = VerificationPolicy.BOTH, deterministic: bool = True, uses_session_seed: bool = False, normalizer: PassNormalizer | None = None) -> Callable[[PassType], PassType]
Attach a complete exact-schema contract to a typed pass class.
Source code in src/blueprinting/synthesizer/passes/deriving.py
relation ¶
relation(transform: str, rewrite: str, *, source: type[Any] | str, target: type[Any] | str, verifier: Callable[[Any, Any, RelationCheckContext], None], preserves: Iterable[RuleClaim] = (), introduces: Iterable[str] = (), forbids: Iterable[str] = ()) -> PassRule
Declare a lineage shape plus an independent executable relation invariant.
Source code in src/blueprinting/synthesizer/passes/deriving.py
claim ¶
Declare one preservation property and the predicate that proves it.
事务与验证类型¶
Declarative, immutable derivation-pass infrastructure.
The pass manager treats lowering as a sequence of typed snapshot transitions. It validates schemas, bindings, analyses, mutation behavior, verification policy, and provenance around every pass. Analysis publication is committed only after the produced IR has passed its contract, avoiding half-written caches after a failed lowering.
PassRule
dataclass
¶
PassRule(transform: str, source_entity: str, target_entity: str, rewrite: str, preserves: tuple[RuleClaim, ...] = (), introduces: tuple[str, ...] = (), forbids: tuple[str, ...] = (), verifier: RuleVerifier | None = None)
Declarative semantic contract for one named lineage transform.
TransitionRelation
dataclass
¶
TransitionRelation(rule_id: str, transform: str, source_entity: str, target_entity: str, source_ids: tuple[str, ...], target_id: str, lineage_kind: LineageKind, evidence: tuple[ClaimEvidence, ...] = ())
TransitionReport
dataclass
¶
TransitionReport(source_digest: str, target_digest: str, relations: tuple[TransitionRelation, ...] = (), status: TransitionVerificationStatus = TransitionVerificationStatus.STRUCTURAL_ONLY, canonical_conformance: ClaimEvidence | None = None)
TransitionVerifier ¶
Verify typed entity lineage and executable derivation laws.
PassContract
dataclass
¶
PassContract(name: str, revision: str, input_type: type[CanonicalIRMixin], input_schema: SchemaRange, output_type: type[CanonicalIRMixin], output_schema: SchemaVersion, required_bindings: frozenset[BindingAxis] = frozenset(), required_analyses: frozenset[AnalysisKey] = frozenset(), preserved_analyses: frozenset[AnalysisKey] = frozenset(), produced_analyses: frozenset[AnalysisKey] = frozenset(), mutation_model: MutationModel = MutationModel.IMMUTABLE, verification: VerificationPolicy = VerificationPolicy.BOTH, deterministic: bool = True, uses_session_seed: bool = False, rules: tuple[PassRule, ...] = (), normalizer: PassNormalizer | None = None)
Complete static contract for one canonical IR transition.
normalizer_identity
property
¶
Stable diagnostic identity of the canonical derivation law.
digest
property
¶
Content identity of the contract and its declared callable identities.
create
classmethod
¶
create(name: str, input_type: type[CanonicalIRMixin], output_type: type[CanonicalIRMixin], *, revision: str = '1', **options: Any) -> PassContract
Build the common exact-schema contract without hiding its resolved values.
Source code in src/blueprinting/synthesizer/passes/base.py
PassResult
dataclass
¶
Bases: Generic[OutputIR]
DerivationPass ¶
Bases: ABC, Generic[InputIR, OutputIR]
Base class for one declaratively contracted lowering or analysis pass.
PassPipeline
dataclass
¶
Immutable, type-checked pass composition.
PassRecord
dataclass
¶
PassRecord(pass_name: str, contract_revision: str, contract_digest: str, input_digest: str, output_digest: str, session_fingerprint: str, duration_ns: int, mutation_model: MutationModel, produced_analyses: tuple[AnalysisKey, ...], transition_report: TransitionReport)
PassCheckpoint
dataclass
¶
PassCheckpoint(record: PassRecord, ir: CanonicalIRMixin, analysis_products: tuple[AnalysisProduct, ...])
One inspectable lowering boundary for profilers and validation hooks.
PassManager ¶
PassManager(analyses: AnalysisStore | None = None, *, observers: Iterable[PassObserver] = (), determinism: DeterminismPolicy = DeterminismPolicy.OFF)
Executes pipelines while enforcing all pass contracts at the boundary.
Source code in src/blueprinting/synthesizer/passes/base.py
run ¶
run(pipeline: PassPipeline, ir: InputIR, *, session: SynthesisSession) -> Checked[PipelineResult[Any]]
Execute a pipeline and return expected contract failures as diagnostics.
Source code in src/blueprinting/synthesizer/passes/base.py
require_run ¶
require_run(pipeline: PassPipeline, ir: InputIR, *, session: SynthesisSession) -> PipelineResult[Any]
Explicit exception adapter for application and legacy boundaries.