topos.functors.profunctors.cpg.topological_coverage

Topological Semantic Test Coverage via Euler Characteristic Transform (ECT).

Evaluates coverage by comparing the V - E ECT of the “test scope” static subgraph of the program under test (PUT) against the ECT of the test execution graph.

Node texts are embedded with fastembed (384-D), reduced to 2-D via PCA fit jointly on PUT ∪ test, and fed into TRAILED’s Rust ECT core through trailed.tabular.compute_ect_from_numpy(..., edge_index=...). Both graphs are computed in one batched call so they share the same directions and filtration grid.

exception topos.functors.profunctors.cpg.topological_coverage.ECTCoverageUnavailableError[source]

Bases: ImportError

Raised when fastembed or trailed are not installed.

topos.functors.profunctors.cpg.topological_coverage.ect_coverage_available()[source]

Return True when optional ECT coverage dependencies are importable.

topos.functors.profunctors.cpg.topological_coverage.require_ect_coverage()[source]

Raise ECTCoverageUnavailableError if optional deps are missing.

topos.functors.profunctors.cpg.topological_coverage.get_embedding_model()[source]

Lazily load and reuse the fastembed TextEmbedding model.

class topos.functors.profunctors.cpg.topological_coverage.TopologicalCoverageReport(topological_distance, topological_coverage_score, tested_functions, untested_functions, put_node_count, test_node_count, scoped_node_count)[source]

Bases: object

Detailed report for topological semantic test coverage.

topological_distance
topological_coverage_score
tested_functions
untested_functions
put_node_count
test_node_count
scoped_node_count
topos.functors.profunctors.cpg.topological_coverage.get_ast_subtree_nodes(start_node, cpg)[source]

Recursively get all CPG nodes in the AST subtree of a given node.

topos.functors.profunctors.cpg.topological_coverage.get_test_scoped_subgraph(put_cpg, test_cpg)[source]

Subset the static CPG of the PUT based on Call Graph Reachability.

topos.functors.profunctors.cpg.topological_coverage.calculate_topological_coverage(put_cpg, test_cpg, *, num_directions=32, num_steps=64)[source]

Calculate the Topological Semantic Test Coverage between PUT and Test CPGs.

  1. Subset PUT CPG to define the “test scope” via Call Graph Reachability.

  2. Embed scoped PUT and test node texts via fastembed.

  3. Jointly PCA-reduce to 2-D so both graphs live in the same low-dim frame.

  4. Compute V - E ECT for both graphs in one batched TRAILED call.

  5. Normalize, take RMSE, and exponentiate into a [0, 1] score.