Proposal: Emit PropMutations for all final graph derived values (ratings, benchmarks)
## Summary We propose that all final computed values in the `final_graph` should also be available as `PropMutation` entries in the mutation log. Currently, the mutation log contains "raw" property values, but the `final_graph` contains additional **derived values** that are computed post-processing and not captured in any mutation. This is blocking the ability to reconstruct the complete calculation graph from mutations alone. ## Problem When reconstructing a calculation graph from the mutation log, the following derived values are **missing**: ### High Priority - Ratings & Benchmarks | Property | Example Mutation Value | Example Final Graph Value | |----------|------------------------|---------------------------| | `impact_assessment.co2_rating` | `"E"` | `"A"` | | `impact_assessment.co2_value_improvement_percentage` | `null` | `83.99` | | `impact_assessment.co2_award` | `false` | `true` | | `impact_assessment.co2_value_reduction_value` | `null` | `0.108...` | | `scarce_water_consumption_rating` | `""` | `"A"` | | `scarce_water_consumption_improvement_percentage` | _(missing)_ | `100` | | `vitascore_rating` | `"E"` | `"A"` | | `vitascore_improvement_percentage` | `0` | `33.08` | | `animal_welfare_rating` | `"E"` | `"A"` | | `rainforest_rating` | `"E"` | `"A"` | **Note:** Core calculation values (e.g., `amount_for_activity_production_amount`) **match exactly** between mutations and final_graph. Only the derived ratings/benchmarks are missing. ### Medium Priority - Serialization Metadata | Property | Description | |----------|-------------| | `sub_node_uids` | Array of direct child node UIDs | | `tree_index` | Position in tree hierarchy | ### Low Priority - Clarification Needed Two node types appear in mutations but not in `final_graph`: - `ModeledActivityNode` (external inventory references) - `ElementaryResourceEmissionNode` (emission nodes) Are these intentionally excluded from `final_graph`? ## Proposed Solution **Option A (Preferred):** Add additional `PropMutation` entries to the mutation log that set the final computed values for ratings, improvement percentages, and awards. These should be emitted after the calculation is complete. **Option B:** Include benchmark reference values in the mutation log so clients can compute ratings themselves using the same algorithm. ## Full List of Properties Needing Mutations ``` impact_assessment.co2_rating impact_assessment.co2_value_improvement_percentage impact_assessment.co2_award impact_assessment.co2_value_reduction_value scarce_water_consumption_rating scarce_water_consumption_improvement_percentage scarce_water_consumption_award scarce_water_consumption_reduction_value vitascore_rating vitascore_improvement_percentage animal_welfare_rating rainforest_rating ``` ## Test Data Analysis performed on `salt-only-response.json` with 185 mutations. Full protocol documented in `firefly-pro/lca-extension/docs/MUTATION_LOG_GAPS_PROTOCOL.md`. ## Impact Without these mutations, clients cannot: - Display A-E ratings - Show improvement percentages vs benchmarks - Determine award status - Fully reconstruct the final graph without relying on `final_graph` response
issue