# MAPO-CORE Agent Instructions ## Core Context - **Primary Goal**: Optimization and refactoring of the `MP-SPEC.sln` solution, focusing on migrating legacy Redis/DB caching to `FusionCache` (Memory + Redis + DB) in `MP.SPEC\Data\MpDataService.cs`. - **Language**: C# (primary), PowerShell (scripts). - **Documentation/Comments**: MUST be in **Italiano**. - **Code Style**: Maintain existing region organization (`#region Public Methods`, etc.). - **Reference Docs**: See `Refactor_Plan.md` for the current migration status and detailed strategy. ## Development Workflow - **Build & Verification**: - Use `./build_all_par.ps1 --agent` to build all solutions silently. - Always verify that changes do not leave partial traces of old classes that break compilation. - **Refactoring Strategy (`MpDataService.cs`)**: - Use `GetOrFetchAsync(string operationName, string cacheKey, Func> fetchFunc, TimeSpan expiration, params string[] tags)` as the standard for all data access. - Target methods currently using manual `redisDb.StringGetAsync` / `StringSetAsync` patterns. - **Testing**: - Check the codebase for existing testing patterns before proposing new ones. ## Architecture Notes - **Multi-Layer Caching**: The system is transitioning from a dual-layer (Redis + DB) to a triple-layer approach via `IFusionCache`. - **Service Responsibility**: `MpDataService` is the central hub for data access, interacting with `MpSpecController` (EFCore) and `MpMongoController` (MongoDB). - **Key Management**: Cache keys are heavily managed via `Utils.redis...` constants. Use these to prevent key mismatches.