Skip to content

Place a SimaPro activity by a stated location, not a guessed one - #263

Merged
ccomb merged 2 commits into
mainfrom
simapro_location_provenance
Jul 27, 2026
Merged

Place a SimaPro activity by a stated location, not a guessed one#263
ccomb merged 2 commits into
mainfrom
simapro_location_provenance

Conversation

@ccomb

@ccomb ccomb commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Why

A handful of Agribalyse activities were filed under "locations" that name no place: F-Organic, F-Org(Farrrowin, Mid-western. Following it back, the cause is not a bad list of geographies but a reading that outranks a fact.

SimaPro caps its Process name field at 80 characters — 8096 Agribalyse names sit exactly at the limit. On a long name that cut takes the trailing {FR} tag away and leaves only a slash the name has for its own reasons. The parser then read the tail after the last slash as a geography code:

Bresaola, processed in FR | Chilled | Already packed - PP/PE | No preparation |
                                                        ^^ read as Peru

PE is polyethylene. Two arithmetic twins make the truncation plain — a stray dot in the source shifts the cut by one character and the "location" shortens by one character with it:

process name (80 chars) location it produced
…mulched floor for PW/F-Org(Farrrowin F-Org(Farrrowin
…mulched floor for PW/F-Org(Far-mate (with Build.ing) F-Org(Far-mate

In every one of these cases the product name is not truncated and still states {FR}. The parser consulted it only when the process name yielded nothing, so a guess beat a statement.

What changed

extractLocation now says how it found a location — a tag ({FR}, //[FR]) or a slash suffix — and returns Maybe instead of a name paired with a blank. The Geography field still outranks both; between the two names, a tag wins wherever it sits and a slash suffix only wins when no tag is on offer.

The name follows that same decision: it loses its tail only when the tail is what named the place. That is what stops names being cut short, which matters beyond the label — a shortened name merges activities, since the activity UUID is a hash of name and location.

No shape heuristic was added, deliberately: F-Organic and the real WFLDB code UN-SEASIA have the same shape, so no test on the string can separate them. Provenance can.

Measured

Reproduced over every SimaPro export at hand, before and after:

export activities placed by the slash reading changed by this PR
Agribalyse 3.2 81 73, all to a tag the product already stated
WFLDB 1876 0 — 80 distinct locations, identical
ginko 2025.2 0 0
pastoeco 1 0

On Agribalyse the four junk locations are retired, the 68 bogus PE become FR (39 genuine {PE} activities in Peru stay), and distinct (name, location) pairs go from 15163 to 15202 — 39 pairs of activities that shared one identity are now told apart.

WFLDB was re-parsed with the patched engine and produces the same 80 locations as before, which is the point: the slash reading is the WFLDB convention and had to keep working.

Engine suite: 1904 examples, 0 failures.

ccomb added 2 commits July 27, 2026 00:50
SimaPro caps its "Process name" field at 80 characters. On a long name that
cut takes the "{FR}" tag off the end and leaves only a slash the name has for
its own reasons, so "Already packed - PP/PE | No preparation" was read as
Peru — PE is the plastic. Same mechanism gave "F-Organic", "F-Org(Farrrowin"
and "Mid-western" (the last from a region whose own name contains a slash).

The slash reading is how WFLDB states a location and has to keep working, so
it is not the reading that is wrong, only its rank: extractLocation now says
which of the two forms it found, and a tag beats a suffix wherever each sits.
The name follows the same decision — it only loses its tail when that tail is
what named the place — which is what stops names being cut short.

Measured over every SimaPro export at hand: 73 activities move on Agribalyse
3.2 and 39 pairs stop sharing one identity; WFLDB, which relies on the slash
reading 1876 times, is bit-for-bit unchanged, as are ginko and pastoeco.

extractLocation returns Maybe rather than a name paired with a blank, so a
caller can no longer mistake "no location" for one.
A coproduct whose own name states no location took whatever the process
name yielded — including a slash guess off a truncated name — while the
reference product's tag placed its sibling elsewhere, splitting a block
that must collapse onto one activityUUID.

The reference product's reading now closes the priority list. Sitting
last, it only speaks when neither the process name nor the coproduct's
own name settles the place, so every measured behaviour (WFLDB ties
included) is unchanged; the block just stays on one location.
@ccomb
ccomb merged commit 7314169 into main Jul 27, 2026
9 checks passed
@ccomb
ccomb deleted the simapro_location_provenance branch July 27, 2026 08:31
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