Skip to content

Collapse BRA/ARG/USA producers into one PDL-derived producer archetype #33

Description

@Hackatro

Raised in #31 (topology.py ID_OVERRIDES / FARMER* fragments).

After #31 the three producer archetypes (bra_farmers, arg_farmers, usa_farmers) are behaviorally identical — all ROLE_PRODUCER, one unified _step_producer. They survive as three hand-maintained entries (two ID_OVERRIDES + one KIND_ARCHETYPES default) purely for data/wiring identity, not behavior. Adding a new producing region still needs a hand-written override + param fragment + per-region scenario knobs.

Fix: collapse them into a single generic producer archetype differentiated only by PDL entity id, so a new (region, agriculture) entity dropped into the PDL wires itself with no topology.py edit. (build_roster already has the per-entity split machinery — its outputs just don't match today's schema yet.)

Three blockers, each must become PDL/scenario-derived:

  1. Producer list names ARE the output schema — bra_farmers → CSV/DB tables + FLOW_ADJACENCY keys. Collapsing → entity-id-based names → schema change. (Generalize port routing with origin allow-list #19 frees the wholesaler volume columns but not the producer table names.)

  2. Fertilizer is a universal producer input, not a BRA special-case. Today _FARMER_BRA alone binds fertilizer → ("fertilizer_supply","price"); ARG/USA don't. Decision (per Unify Farmer & Trader into region-agnostic capability supersets (roles without regions) #31 follow-up): every producer depends on fertilizer, so the binding moves into the shared producer archetype and applies to all producers by default. This removes the need to derive it per-entity — it's a shared default, not a component to special-case. (Behavior change: ARG/USA fixed costs will now respond to fertilizer_supply price shocks — e.g. the ammonia_halt → fertilizer_supply events in the energy/compound cascades — so those scenarios need a re-baseline, same pattern as USA's unification in Unify Farmer & Trader into region-agnostic capability supersets (roles without regions) #31. brazil_drought is unaffected: it doesn't shock fertilizer.)

  3. Per-region cost knobs are separate scenario fields (fixed_costs_bra_farmer, …). Needs an entity-id convention (fixed_costs_<entity_id>) + resolver.

Acceptance:

  • No per-producer entries in ID_OVERRIDES (brazil_farms/us_farms removed); one generic producer archetype

  • A new (region, agriculture) PDL entity becomes its own producer list with no topology.py edit

  • Fertilizer binding lives on the shared producer archetype (all producers bind it), not on any single region

  • Producer params sourced by entity-id convention, not per-region scenario fields

  • Existing scenarios reproduce current producer values byte-for-byte (pure refactor — behavior unchanged; only table names may move)

Depends on: #19 (schema thaw for the volume columns)
Ref: topology.py ID_OVERRIDES, _FARMER_BRA/_FARMER_ARG/_FARMER_USA, build_roster producer-split.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementFor everything that improves an already existing feature.simulation logicFor everything related to the internal simulation logic

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions