axm-echo
Neural similarity & echo detection over code corpora (MiniLM + scikit-learn).
Installation
Bash
# echo is neural by default — the install ships torch + sentence-transformers
# (MiniLM) alongside numpy + scikit-learn.
uv add axm-echo
The neural st backend is the in-process default. The tfidf backend stays
pure-CPU and never loads torch, for callers that want to skip the model.
Quick Start
Python
from axm_echo import embed, extract_monorepo, neighbors
# 1. Build a corpus of public symbols across the configured workspaces
# (driven by ~/axm/echo.toml, falling back to the current dir).
symbols = extract_monorepo()
texts = [s["embed_text"] for s in symbols]
# 2. Embed it. "st" (MiniLM) is the neural default; "tfidf" stays pure-CPU.
matrix = embed(texts, backend="tfidf")
# 3. Find the nearest neighbours of a symbol (exact cosine top-k).
for idx, score in neighbors(matrix[0], matrix, k=5):
print(f"{score:.3f} {symbols[idx]['qualname']}")
Features
- ✅
echo_codecross-package echo detection — theaxm echo_codetool (MCP + CLI + DAG node) clusters intent-equivalent duplicate symbols across packages, with the v7 anti-signals (trivial-accessor filter, parallel-API demotion, boilerplate-frequency demotion) applied - ✅ Liveable
echo_codereport — bounded--top-ndisplay (the neural pass still finds them all, only the output is capped; the total stays visible),--max-cluster-sizerejection of union-find over-merges, and an acknowledged-cluster waiver workflow ([[tool.axm-echo.acknowledged]]in the scan-rootpyproject.toml) that excludes intended echoes and reports stale waivers to retire - ✅
echo_checkintent retrieval — theaxm echo_checktool (MCP + CLI + DAG node) embeds a free-form intention and returns the top-k nearest monorepo symbols with their docstrings, each tagged with a location verdict (reuse canonical / reuse in place / promotable); it does the retrieval, leaving the use / extend / nothing decision to the caller - ✅ Structural similarity —
statement_set/jaccard_similarity(withflatten_body/normalize_dump) compare twoast.FunctionDefbodies by Jaccard over constant/identifier-normalized statement-sets; 100% structural, pure stdlib, never loads torch - ✅ Two embedding backends —
st(MiniLMall-MiniLM-L6-v2, the neural default) andtfidf(code, scikit-learn), selected by a registry - ✅ Exact neighbour search — brute-force cosine matmul, no ANN
- ✅ Lazy torch import —
torch+sentence-transformersship in the base install (neural-by-default), but torch is imported only inside thestbackend, so thetfidfpath never loads it at runtime - ✅ axm-ast corpus extractor — public symbols with signature +
docstring,
embed_textfalling back to code when undocumented - ✅ Scope loader —
~/axm/echo.toml, graceful degradation to the current workspace - ✅ Modern Python — 3.12+ with strict typing