feat(code): Phase 4 — metadata_id, canonical_key, composite refactor classification (#65)
SymbolRecord gains two new fields (backward-compatible: "" for pre-v2 records):
metadata_id SHA-256 of symbol metadata that wraps the body without being part of it: decorators + async flag for Python functions, decorator list + bases for Python classes. Stubbed ("") for tree-sitter adapters — future adapters can enrich this by reading modifier/annotation nodes.
canonical_key Stable machine handle: {file}#{scope}#{kind}#{name}#{lineno}. Disambiguates overloads and nested scopes. Unique within a snapshot. Enables agent-to-agent symbol handoff without re-querying.
New classification helpers:
muse/plugins/code/_refactor_classify.py classify_exact() hash-based exact classification: rename | move | rename+move | signature_only | impl_only | metadata_only | full_rewrite classify_composite() batch heuristic classification across a set of added/removed symbols — detects extract, inline, split, merge with confidence scores and evidence RefactorClassification full typed result (to_dict() → JSON-ready)
muse detect-refactor --json now emits schema_version:2 with total count.
Python _make_*_record() helpers thread file_path and class_prefix for accurate canonical_key computation. tree-sitter TreeSitterAdapter uses scope prefix extracted from the qualified_name.
mypy: 0 errors · typing_audit: 0 violations · pytest: 797 passed.
Co-authored-by: Gabriel Cardona <gabriel@tellurstori.com>
Comments
0No comments yet. Be the first to start the discussion.