topos.evaluation.characteristic_morphism¶
Characteristic Morphism χ_S : P → Ω¶
This module implements the characteristic morphism of the program
topos. Per the math spec §3, for every program P ∈ E and every
subprogram S ↪ P there exists a unique natural transformation
χ_S : P → Ω
mapping each structural component to an element of Ω. This file
contains the map; the codomain Ω itself lives in
topos.core.omega.
Categorical / Pythonic correspondence:
Math Python
------------------ -----------------------------------------
Ω Omega (topos.core.omega)
elements of Ω EvaluationValue (topos.core.omega)
χ_S : P → Ω CharacteristicMorphism (this module)
image of χ_S(P) ClassificationResult (this module)
The characteristic morphism:
Builds every available Representation (AST + CFG + ModuleDependencyGraph + CPG) for the morphism.
Groups them by generator (each Representation declares its
dimension∈ {“simple”, “composable”, “secure”}).Runs the matching policy translator Φᵢ on the collected metrics (
simple→ Φ_SIMPLE, etc.).Combines the three Boolean truth values via
topos.core.omega.verdict_from_generators()into the final Ω element.
Priority is recorded on results and steers agent guidance; it does
not change per-metric pass/fail thresholds inside each Φᵢ.
- class topos.evaluation.characteristic_morphism.ClassificationResult(is_parseable, dimensions=<factory>, scores=<factory>, lattice_element=EvaluationValue.SLOP, priority=Priority.SECURE, raw_metrics=<factory>, interpretation=<factory>)[source]
Bases:
objectThe image of one program morphism under χ_S : P → Ω.
- is_parseable
Whether the code parsed successfully.
- Type:
- dimensions
Per-generator value in Ω: the singleton generator (SIMPLE/COMPOSABLE/SECURE) when satisfied, SLOP otherwise.
- lattice_element
Overall Ω element — the join of the satisfied generators, encoded via
verdict_from_generators.- Type:
topos.core.omega.EvaluationValue
- priority
Generator emphasis label (metadata / guidance).
- Type:
topos.evaluation.policies.base.Priority
- is_parseable
- dimensions
- scores
- lattice_element = 0
- priority = 'secure'
- raw_metrics
- interpretation
- summary()[source]
The overall Ω element χ_S(P).
- class topos.evaluation.characteristic_morphism.CharacteristicMorphism(omega=<factory>)[source]
Bases:
objectχ_S : P → Ω — the characteristic morphism of the program topos.
For every program morphism
P(and the canonical subprogramS = Pitself, in the absence of a finer subobject) this object computes the natural-transformation imageχ_S(P)as anEvaluationValuein Ω.Each generator
gᵢis fed by the Representation theory says is the correct lens for that quality:SIMPLE ← CFG cyclomatic complexity COMPOSABLE ← ModuleDependencyGraph coupling / instability SECURE ← Code Property Graph taint / danger probes
- omega
The subobject classifier Ω (the value Heyting algebra).
- Type:
topos.core.omega.Omega
- omega
- classify(morphism)[source]
Return
classify_detailed(...).summary()— the overall Ω element.
- classify_detailed(morphism, representations=None, priority=Priority.SECURE)[source]
Compute χ_S : P → Ω in full detail.
An
ASTRepresentationis always built from the morphism (it carriesast.entropyinto the SIMPLE generator). Any additional representations (CFG, ModuleDependencyGraph, PDG, CPG) are grouped by theirdimensionand scored independently.Parse failures collapse to ⊥ = SLOP.
- combine(*values)[source]
Combine multiple Ω values via meet (∧).
- combine_dimensions(results, thresholds=None)[source]
Pointwise multi-file meet ⋀_f χ_S(f).
A generator is satisfied across the codebase iff it is satisfied for every file (minimum score across files ≥ its calibrated threshold). Parse failures inject a zero score on the SIMPLE generator (since the program failed even to compile, no other generator is reachable).