refactor(ecospold): extract shared cut-off strategy into EcoSpold.Cutoff#99
Merged
Conversation
The cut-off post-processing — reduce a multi-output dataset to a single reference product so the engine sees a single-output process — was duplicated verbatim between the EcoSpold1 and EcoSpold2 parsers. Move the eight-function chain into one EcoSpold.Cutoff module both parsers import. Tests that exercise these helpers now import them from EcoSpold.Cutoff instead of the EcoSpold.Parser1 re-export.
The waste-flow comments explaining why waste outputs aren't production and can't be promoted to reference product didn't survive the move into EcoSpold.Cutoff. Restore them in the now-single source of truth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The cut-off post-processing — reducing a multi-output dataset to a single reference product so the engine sees a single-output process — was duplicated verbatim between the EcoSpold1 and EcoSpold2 parsers (~70 lines, the same eight-function chain in each). This moves that block into one shared
EcoSpold.Cutoffmodule that both parsers import.This is the last remaining piece of the EcoSpold refactor series (after the Parser2 split #97 and the Parser1 fold dedup #94), which left the cut-off block still copy-pasted in both files.
Changes
src/EcoSpold/Cutoff.hs— holdsapplyCutoffStrategy,hasReferenceProduct,removeZeroAmountCoproducts,assignSingleProductAsReference,isProductionExchange(exported) plus the internalupdateReferenceProduct/markAsReference/unmarkAsReference.Parser1.hs/Parser2.hs— delete the duplicated block,import EcoSpold.Cutoff (applyCutoffStrategy). Parser1 drops its "exported for testing" cut-off helpers.EcoSpold1Spec.hs— imports the cut-off helpers fromEcoSpold.Cutoffinstead of the oldEcoSpold.Parser1re-export.volca.cabal— registers the new library module.Pure post-fold logic, runs once per activity (not in the SAX loop), so no behaviour or throughput change. Net: ~154 duplicated lines removed across the two parsers, replaced by one ~95-line module.
Verification
cabal build lib:volca+exe:volca: clean (only pre-existing unrelated MCP warnings).cabal test lca-tests: 1107 examples, 0 failures, 1 pending — including the EcoSpold1 cut-off-helper tests now resolving against the new module.