Skip to content

world-graph: deferred building-meter effects mark 'applied' before system 14 composes the total #349

Description

@The-Running-Dev

Raised during review of #348 (W83 — Buildings Get Dirty, Wear Out, and Break).

applyWorldEffects's deferred building-meter branch (src/engine/src/kinds/world-graph/tick/effects.ts, the buildingMeters loop's context.deferBuildingMeters branch) marks applied[index] = true as soon as the local group.delta is nonzero — before system 14 (cleanliness-wear) has composed/clamped the total across all deferred sources for that building/meter. The non-deferred branch just below, and the guestMeters branch above, only mark applied once the final clamped value actually differs from previous.

Concrete failure scenario: a scenario/policy building_meter_delta effect that nets to zero once system 14 sums it with same-tick service/staff/litter deltas for the same building/meter still fires kind.world-graph.scenario.effect.applied, even though the meter never moved. Low severity today — debug-level, and scenario is the only caller reading .applied — but a real semantic drift.

Why not fixed inline: a true fix needs to know the post-composition outcome before applyWorldEffects returns, which conflicts with the whole point of deferring. The existing test in pipeline.test.ts ("applies every effect family, groups/clamps meters once...") already locks in "every staged effect counts as applied" for the single-source case, so a fix would need to update that assertion's intent, not just the implementation.

Reference: PR #348 review thread on src/engine/src/kinds/world-graph/tick/effects.ts:283.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions