topos.functors.profunctors.cpg.compare

CPG Comparison — profunctor D : E × E^op restricted to the Code Property Graph. ====================================================================

Pairwise comparison of two CodePropertyGraph instances. The CPG fuses AST ∪ CFG ∪ DDG ∪ CDG into a single labeled multigraph; comparing two CPGs gives a single end-to-end signal for “did this refactor change the program’s semantic structure?”.

Signals:

family_jaccards   : Jaccard similarity per edge family
                    ({AST, CFG, DDG, CDG} → float in [0, 1])
node_jaccard      : Jaccard similarity over CPG node ids
dangerous_delta   : signed change in count of dangerous-API call sites
taint_delta       : signed change in count of source → sink taint paths
class topos.functors.profunctors.cpg.compare.CPGComparison(family_jaccards, node_jaccard, dangerous_delta, taint_delta, source_metrics=<factory>, target_metrics=<factory>)[source]

Bases: object

Pairwise comparison summary for two code-property graphs.

family_jaccards
node_jaccard
dangerous_delta
taint_delta
source_metrics
target_metrics
property changed
topos.functors.profunctors.cpg.compare.node_jaccard(source, target)[source]

Jaccard similarity over CPG node ids (stable UAST node hashes).

topos.functors.profunctors.cpg.compare.family_jaccards(source, target)[source]

Jaccard similarity per edge family over edge identities.

Each edge is identified by the triple (source, target, label) so that, e.g., two DDG edges over the same variable count as the same edge and two CFG edges with different branch labels (true vs false) count as distinct. Result keys are the CPGEdgeKind enum values (ast, cfg, ddg, cdg).

topos.functors.profunctors.cpg.compare.dangerous_delta(source, target)[source]

Signed change in dangerous-API call-site count (target − source).

topos.functors.profunctors.cpg.compare.taint_delta(source, target)[source]

Signed change in source → sink taint-path count (target − source).

topos.functors.profunctors.cpg.compare.compare_cpg(source, target)[source]

Run the full CPG comparison suite for a single pair of graphs.