topos.functors.probes.uast.signature

UAST Signature Module

Cheap, language-agnostic structural fingerprints of a UAST root.

These signatures are designed to summarize a program’s shape across languages so that two implementations of the same algorithm can be compared without depending on language-specific node names.

class topos.functors.probes.uast.signature.StructuralSummary(node_count, depth, declaration_count, expression_count, statement_count)[source]

Bases: object

Aggregate, language-agnostic stats about a UAST.

node_count
depth
declaration_count
expression_count
statement_count
topos.functors.probes.uast.signature.uast_kind_histogram(root, *, include_unknown=True)[source]

Count UAST kind occurrences across the whole tree.

Parameters:
  • root – A UAST root node (duck-typed: must expose kind and children).

  • include_unknown – When False, drops the catch-all Unknown bucket so grammar-coverage gaps don’t dominate the histogram for languages with thinner UAST mapping coverage.

topos.functors.probes.uast.signature.uast_dfs_kind_sequence(root, *, include_unknown=True)[source]

DFS pre-order traversal of UAST kind strings (same order as edit distance).

When include_unknown is False, nodes mapped to Unknown are omitted from the sequence entirely (not counted as a step).

topos.functors.probes.uast.signature.control_flow_profile(root)[source]

Count control-flow-relevant UAST kinds (loops, branches, calls, returns).

topos.functors.probes.uast.signature.structural_summary(root)[source]

Single-pass aggregate stats about the UAST.