cgcardona / muse public
feat main #50 / 100

feat: supercharge .museattributes — base/union strategies, priority, comment, code domain wiring

* feat: supercharge .museattributes — new strategies, priority, comment, code plugin wiring

## muse/core/attributes.py - Add `base` strategy: revert to the common merge-base version, discarding changes from both branches. Useful for generated files, lock files, or any path that must stay at a known-good state during a merge. - `union` strategy now fully documented: include all additions from both sides; honour deletions only when both agree; prefer left for binary blobs. - Add `comment` field to AttributeRule (documentation, zero runtime cost). - Add `priority` field to AttributeRule (int, default 0); load_attributes now stable-sorts rules by priority descending so higher-priority rules are always evaluated before lower-priority ones, regardless of file order. - VALID_STRATEGIES: 5 → 6 (base added). - AttributesRuleDict updated to total=False to accommodate optional fields. - Full module docstring rewrite covering all six strategies and all five fields.

## muse/plugins/code/plugin.py - CodePlugin.merge() now loads and respects .museattributes (was a documented gap — repo_root was accepted but never consulted). - All six strategies implemented at file level: ours, theirs, base, union, manual, auto. manual also fires on one-sided auto-resolved paths. - applied_strategies dict populated and returned in MergeResult. - CodePlugin.merge_ops() now applies attribute resolution at the symbol-level conflict_addresses set: extracts the file path from "file::symbol" addresses and checks rules, so "src/**/*.py" / strategy = "ours" suppresses symbol conflicts in those files, not just file-level manifest conflicts. - applied_strategies from both file-level and op-level resolution merged.

## muse/cli/commands/init.py - _museattributes_template completely rewritten with: - All six strategies with plain-English descriptions - All five rule fields documented inline - Domain-specific commented examples for MIDI, code, and generic repos - priority and comment fields demonstrated

## tests/test_core_attributes.py (+30 tests) - TestNewStrategies: base and union in VALID_STRATEGIES, parsed, resolved. - TestCommentField: parsed, defaults to empty, ignored at runtime. - TestPriorityField: parsed, defaults to 0, higher overrides lower, equal preserves order, negatives allowed, affects all strategies. - TestFullRuleComposition: round-trip of all new fields together, MIDI and code priority sort scenarios.

## tests/test_code_plugin_attributes.py (NEW, 14 tests) - Integration tests for CodePlugin.merge() × .museattributes: one test class per strategy (ours, theirs, base, union, manual, auto) plus priority ordering, no-repo-root degradation, and applied_strategies propagation through merge_ops().

mypy: 0 errors · typing_audit: 0 violations · 1747 tests green

* docs: rewrite muse-attributes.md for v0.1.2

- Documents all six strategies including new base and union semantics - Documents comment and priority fields with usage guidance - Explains priority-based rule evaluation order with examples - Adds MIDI dimension reference (all 21 dims + aliases) - Adds code domain section (file-level and symbol-level wiring) - Four complete annotated examples: MIDI, code, genomics, any-domain - Documents applied_strategies in MergeResult and its CLI output - Links to related docs and type-contracts

---------

Co-authored-by: Gabriel Cardona <gabriel@tellurstori.com>

G Gabriel Cardona <cgcardona@gmail.com> · 1d ago Mar 19, 2026 · 12559ad7 · parent fa688757
oldest
newest 51%

Comments

0

No comments yet. Be the first to start the discussion.