Conversation
Method import strategies (Brightway's term for imperative CF-mutation functions applied at import time) are stateful and non-idempotent: they mutate a persisted store, so re-running an import re-applies the mutation. VoLCA parses methods fresh from source on every load, so the same adjustment can be expressed as data instead: a `[[methods.patches]]` TOML block that rescales or overrides matched characterization factors, applied as a pure transform right after parsing. A patch selector (category, flow name/prefix, CAS, subcompartment substring) is a product type with conjunctive matching; the decoder rejects an empty selector and requires exactly one of `scale` or `set-value`, so invalid patches are unrepresentable rather than silently ambiguous. A patch that matches zero characterization factors logs a warning at load time instead of failing silently. Config.mcPatches defaults to `[]`, so existing configs are unaffected.
The per-activity /impacts endpoint already let a caller drop delayed
long-term emissions before scoring; the bulk multi-activity endpoint
(POST /db/{db}/impacts/{collection}) didn't, forcing scripts that need
both a full panel and long-term exclusion onto the much slower
per-activity path. Threads the same LongTermMode through
batchImpactsH/runBatchImpacts, applied to each solved inventory before
characterization. Also exposed on the score_activities MCP tool, which
had the same gap relative to score_activity.
mapAccumL instead of a foldl with quadratic list append, maybeToList instead of a local reimplementation, and a total factorValues helper in the spec instead of irrefutable let patterns that would crash rather than fail cleanly.
Also record the bulk exclude-long-term extension in the changelog.
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.
Summary
[[methods.patches]]: a declarative, idempotent way to rescale or override matched characterization factors at method-load time — the data-driven equivalent of a Brightway import strategy, without its statefulness (re-loading never compounds a patch, since it's re-derived from the untouched source file every time).exclude-long-termto the bulkPOST /impactsendpoint and thescore_activitiesMCP tool, which previously only supported it per-activity.Test plan
cabal build lib:volca— clean, no warningscabal test lca-tests— 1543 examples, 0 failures[[methods.patches]]block loads without a "touched 0 CFs" warning; a deliberately wrong selector does trigger the warning