Port mining extraction semantics into the source node #20

Closed
opened 2026-07-21 02:41:48 +00:00 by coilyco-ops · 1 comment
Owner

Build the next core simulation step after #19. This is core Rust logic, not Bevy/viewer/deploy work.

Current state on main:

  • The source node is a pre-filled stockpile (source_stockpile: 9). After three hauls the scenario runs dry and the sim idles.
  • The Unity-era MiningComponentCore semantics have not been ported: finite deposit extraction per tick, and the manifest (create-from-nothing) path.
  • The advisor plan on #12 called out preserving the difference between finite resource sources and recipe-based production.

Goal:

Port Assets/Scripts/Components/MiningComponent.cs semantics into the Rust kernel so the source node extracts ore from a finite deposit at a fixed per-tick speed, with the manifest path represented for items flagged create-from-nothing. Energy/battery stays out of scope.

Implementation guidance:

  • Add a mining module to factory_sim with a typed extractor: target item, mining speed, and a deposit state that is either finite-remaining or manifest.
  • Finite deposits move at most mining_speed per tick from deposit to the source stockpile, bounded by stockpile capacity, and stop at zero.
  • Manifest items create mining_speed per tick into the stockpile, capacity-bounded, mirroring the C# CreateFromNothing branch.
  • factory_content::ItemDefinition gains create_from_nothing. Scenario definitions gain deposit size and mining speed in place of the pre-filled stockpile.
  • Mining advances at the start of each tick so freshly mined ore is dispatchable the same tick.
  • Snapshots expose deposit/mining state. JSONL stays deterministic.

Acceptance criteria:

  • cargo test --workspace passes.
  • The iron-bars scenario still produces iron bars deterministically.
  • At least one test proves a finite deposit depletes to zero and extraction stops.
  • At least one test covers the manifest (create-from-nothing) path.
  • Snapshot includes deposit remaining and mining configuration.
  • docs/factory-sim.md and docs/FEATURES.md updated where terminology changes.

Out of scope:

  • Power/battery/energy cost.
  • Multiple miners, miner placement, or grid co-location rules.
  • More recipes/content breadth beyond what the manifest test needs.
  • Bevy, Wasm, viewer, or deploy work.
Build the next core simulation step after #19. This is core Rust logic, not Bevy/viewer/deploy work. Current state on `main`: * The source node is a pre-filled stockpile (`source_stockpile: 9`). After three hauls the scenario runs dry and the sim idles. * The Unity-era `MiningComponentCore` semantics have not been ported: finite deposit extraction per tick, and the manifest (create-from-nothing) path. * The advisor plan on #12 called out preserving the difference between finite resource sources and recipe-based production. Goal: Port `Assets/Scripts/Components/MiningComponent.cs` semantics into the Rust kernel so the source node extracts ore from a finite deposit at a fixed per-tick speed, with the manifest path represented for items flagged create-from-nothing. Energy/battery stays out of scope. Implementation guidance: * Add a `mining` module to `factory_sim` with a typed extractor: target item, mining speed, and a deposit state that is either finite-remaining or manifest. * Finite deposits move at most `mining_speed` per tick from deposit to the source stockpile, bounded by stockpile capacity, and stop at zero. * Manifest items create `mining_speed` per tick into the stockpile, capacity-bounded, mirroring the C# `CreateFromNothing` branch. * `factory_content::ItemDefinition` gains `create_from_nothing`. Scenario definitions gain deposit size and mining speed in place of the pre-filled stockpile. * Mining advances at the start of each tick so freshly mined ore is dispatchable the same tick. * Snapshots expose deposit/mining state. JSONL stays deterministic. Acceptance criteria: * `cargo test --workspace` passes. * The iron-bars scenario still produces iron bars deterministically. * At least one test proves a finite deposit depletes to zero and extraction stops. * At least one test covers the manifest (create-from-nothing) path. * Snapshot includes deposit remaining and mining configuration. * `docs/factory-sim.md` and `docs/FEATURES.md` updated where terminology changes. Out of scope: * Power/battery/energy cost. * Multiple miners, miner placement, or grid co-location rules. * More recipes/content breadth beyond what the manifest test needs. * Bevy, Wasm, viewer, or deploy work.
Author
Owner

Landed on main in 115bf2d (feat: port mining extraction into the source node).

What shipped:

  • New factory_sim::mining module with a typed MiningExtractor (target item, speed, Deposit::Finite(remaining) or Deposit::Manifest), ported from MiningComponentCore minus the energy cost, which stays out of scope.
  • factory_content::ItemDefinition gains create_from_nothing (with a stone starter item exercising the manifest path). ScenarioDefinition replaces source_stockpile with source_deposit + mining_speed (iron-bars: deposit 9, speed 3).
  • Mining advances first in each tick, so freshly mined ore is dispatchable the same tick. The source snapshot now exposes the extractor state, and mine events carry the remaining deposit.

Verification:

  • cargo test --workspace passes - 8 tests, including finite-deposit depletion-to-zero, capacity-bounded manifest creation, and scenario-level deposit depletion. The pre-existing dispatch/route/determinism tests pass unchanged because mining-before-intents preserves the prior tick timeline.
  • ward exec test and pre-commit run --all-files both green.
  • A 6-tick CLI run shows the deposit draining 9 -> 0 over ticks 1-3, hauling continuing from the stockpile, and 10 iron bars produced at tick 5.

WARD-OUTCOME: done

Landed on `main` in `115bf2d` (`feat: port mining extraction into the source node`). What shipped: * New `factory_sim::mining` module with a typed `MiningExtractor` (target item, speed, `Deposit::Finite(remaining)` or `Deposit::Manifest`), ported from `MiningComponentCore` minus the energy cost, which stays out of scope. * `factory_content::ItemDefinition` gains `create_from_nothing` (with a `stone` starter item exercising the manifest path). `ScenarioDefinition` replaces `source_stockpile` with `source_deposit` + `mining_speed` (iron-bars: deposit 9, speed 3). * Mining advances first in each tick, so freshly mined ore is dispatchable the same tick. The source snapshot now exposes the extractor state, and mine events carry the remaining deposit. Verification: * `cargo test --workspace` passes - 8 tests, including finite-deposit depletion-to-zero, capacity-bounded manifest creation, and scenario-level deposit depletion. The pre-existing dispatch/route/determinism tests pass unchanged because mining-before-intents preserves the prior tick timeline. * `ward exec test` and `pre-commit run --all-files` both green. * A 6-tick CLI run shows the deposit draining 9 -> 0 over ticks 1-3, hauling continuing from the stockpile, and 10 iron bars produced at tick 5. `WARD-OUTCOME: done`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-gaming/factory-game-v3#20
No description provided.