Skip to content

refactor: split MAAValue into MAAValue and ResolvedMAAValue#485

Open
wangl-cc wants to merge 7 commits intomainfrom
refactor/resolved_maa_value
Open

refactor: split MAAValue into MAAValue and ResolvedMAAValue#485
wangl-cc wants to merge 7 commits intomainfrom
refactor/resolved_maa_value

Conversation

@wangl-cc
Copy link
Member

Refactors the maa-value crate to distinguish between configuration templates (which may contain user inputs and conditional logic) and fully resolved values.

Key changes:

  • Split MAAValue into MAAValue (unresolved) and ResolvedMAAValue (resolved) to enforce type safety.
  • Rename init() method to resolve() to better reflect the transformation process.
  • Modularize maa-value source code by extracting logic into array, convert, map, value, and error modules.
  • Introduce MapOps, ArrayOps, AsPrimitive, and TryAs traits to standardize operations and improve ergonomics.
  • Add maa_value::prelude for convenient imports.
  • Update maa-cli and maa-value-macro to adapt to the API changes and new type definitions.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @wangl-cc, your pull request is larger than the review limit of 150000 diff characters

@wangl-cc
Copy link
Member Author

@copilot review

Copy link

Copilot AI commented Jan 15, 2026

@wangl-cc I've opened a new pull request, #486, to work on those changes. Once the pull request is ready, I'll request review from you.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.14%. Comparing base (e1a837f) to head (3e4febe).
⚠️ Report is 2 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (e1a837f) and HEAD (3e4febe). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (e1a837f) HEAD (3e4febe)
6 2
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #485       +/-   ##
===========================================
- Coverage   70.48%   17.14%   -53.35%     
===========================================
  Files          61        2       -59     
  Lines        5825      175     -5650     
  Branches     5825      175     -5650     
===========================================
- Hits         4106       30     -4076     
+ Misses       1408      144     -1264     
+ Partials      311        1      -310     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the maa-value crate to introduce a type-safe distinction between unresolved configuration templates and fully resolved values. The refactoring improves API clarity by splitting MAAValue into two distinct types and reorganizes the codebase into a more modular structure.

Changes:

  • Split MAAValue into MAAValue (unresolved) and ResolvedMAAValue (resolved) types to enforce type safety
  • Rename init() method to resolve() to better reflect the transformation from unresolved to resolved state
  • Modularize codebase by extracting functionality into dedicated modules (array, convert, map, value, error) and introduce traits (MapOps, ArrayOps, AsPrimitive, TryAs) for improved ergonomics
  • Add maa_value::prelude module for convenient imports
  • Update all dependent crates (maa-cli, maa-value-macro) to adapt to the new API

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/maa-value/src/value.rs Defines MAAValue and ResolvedMAAValue enums with resolve() method and conversion implementations
crates/maa-value/src/map.rs Introduces MapOps trait with map-like operations (get, insert, merge, join) for both value types
crates/maa-value/src/convert.rs Defines AsPrimitive and TryAs traits with conversion macros for primitive types
crates/maa-value/src/array.rs Introduces ArrayOps trait for array-like operations
crates/maa-value/src/primitive.rs Updates MAAPrimitive type with simplified implementation using conversion traits
crates/maa-value/src/lib.rs Refactors to export modules and adds prelude with common imports
crates/maa-value/src/input.rs Updates import paths to use new module structure
crates/maa-value/src/userinput/*.rs Updates import paths for error module
crates/maa-value-macro/src/*.rs Updates codegen to use fully qualified paths for new module structure
crates/maa-value-macro/tests/*.rs Updates all tests to use resolve() instead of init() and import from prelude
crates/maa-cli/src/**/*.rs Updates to use ResolvedMAAValue type and call resolve() on unresolved values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…AValue`

Refactors the `maa-value` crate to distinguish between configuration templates
(which may contain user inputs and conditional logic) and fully resolved values.

Key changes:
- Split `MAAValue` into `MAAValue` (unresolved) and `ResolvedMAAValue`
  (resolved) to enforce type safety.
- Rename `init()` method to `resolve()` to better reflect the transformation
  process.
- Modularize `maa-value` source code by extracting logic into `array`,
  `convert`, `map`, `value`, and `error` modules.
- Introduce `MapOps`, `ArrayOps`, `AsPrimitive`, and `TryAs` traits to
  standardize operations and improve ergonomics.
- Add `maa_value::prelude` for convenient imports.
- Update `maa-cli` and `maa-value-macro` to adapt to the API changes and new
  type definitions.
WIP
@wangl-cc wangl-cc force-pushed the refactor/resolved_maa_value branch from 02f6f8d to 3e4febe Compare January 18, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants