topos_compare_code
Computes AST tree-edit distance between two code snippets to detect clones or measure refactor impact. Returns normalized distance and similarity scores.
Instructions
Compute the AST (tree-edit) distance between two source-code
strings.
Read-only and idempotent; parses both snippets in memory, never
writes or scores. Use for clone detection or to measure refactor
impact; the topos_assess_* tools already fold this in as an
anti-gaming check, so call it directly only for the raw number.
Returns a ComparisonResult: normalized_distance in [0, 1],
similarity (= 1 - it), raw_distance, an operations edit-count
map, and source_valid/target_valid (error set if either fails
to parse).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | python, rust, javascript, typescript, cpp, or go. | python |
| source_code | Yes | Baseline code. | |
| target_code | Yes | Proposed/target code. |