Skip to content

refactor(ecospold): extract shared cut-off strategy into EcoSpold.Cutoff#99

Merged
ccomb merged 2 commits into
advanced_haskellfrom
ecospold-cutoff-dedup
May 28, 2026
Merged

refactor(ecospold): extract shared cut-off strategy into EcoSpold.Cutoff#99
ccomb merged 2 commits into
advanced_haskellfrom
ecospold-cutoff-dedup

Conversation

@ccomb
Copy link
Copy Markdown
Owner

@ccomb ccomb commented May 28, 2026

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.Cutoff module 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

  • New src/EcoSpold/Cutoff.hs — holds applyCutoffStrategy, hasReferenceProduct, removeZeroAmountCoproducts, assignSingleProductAsReference, isProductionExchange (exported) plus the internal updateReferenceProduct / 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 from EcoSpold.Cutoff instead of the old EcoSpold.Parser1 re-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.

ccomb added 2 commits May 28, 2026 20:03
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.
@ccomb ccomb merged commit b76fbac into advanced_haskell May 28, 2026
@ccomb ccomb deleted the ecospold-cutoff-dedup branch May 28, 2026 19:11
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.

1 participant