Units, money, time and coordinate reference systems
2,390 words7 subsections5 tables1 listingPlan version 0.1
On this page7
25.1 Why this is a section and not a utility module
Many material reconciliation failures in mining are not modelling failures but basis failures (HYPOTHESIS, tested by the M2 parity reproduction and GB-34):
- wet tonnes treated as dry;
%Cu averaged by truck count;- ounces per short ton read as grams per tonne;
- a mine grid read as UTM;
- a month-end cut at midnight UTC instead of at the site's production-day boundary.
Each produces a believable number that is wrong by a few percent. That is exactly the size of the signal §20 tries to detect. FrankenMining therefore makes basis part of the type, and refuses at the boundary rather than converting silently (INV-014).
25.2 fmine-units (S0, std-only, stable Rust)
Lineage. It is modelled on frankensim fs-qty, but not lifted: fs-qty needs generic_const_exprs on
nightly-2026-07-06 (E001, B4 §4.3). fmine-units uses ordinary const generics and marker types on the suite
toolchain, with no nightly features.
Type shape (DESIGN).
#![forbid(unsafe_code)]
/// A quantity is a value + a dimension + a basis. Basis is not a unit; it is what the number is *of*.
pub struct Qty<D: Dim, B: Basis, R: Repr = f64> { v: R, _p: PhantomData<(D, B)> }
pub enum MassBasis { Wet, Dry } // tonnes of what moisture state
pub enum MaterialOf { Ore, Waste, Concentrate(ConcId), Dore, Cathode, Bullion, Reagent(ReagentId),
HazardousByproduct(HazardId) /* e.g. Hg from retorts; custody records, §17.7 */ }
pub enum MetalStage { InSitu, Mined, Contained, Recoverable { card: CardRef }, Recovered, Payable, Sold }
// §21: each is a distinct type
pub enum ChemBasis { AsN, AsNO3, AsCaCO3, AsElement, Dissolved, Total } // what a concentration is "of"
pub type DryTonnes = Qty<Mass, Dry>;
pub type WetTonnes = Qty<Mass, Wet>;
pub type MetalMass<S> = Qty<Mass, Metal<S>>; // grams internally; oz_t and lb are views
pub type Grade = Qty<MassFraction, DryBasis>; // g/t ≡ ppm; % Cu; never Add
pub type Recovery = Qty<Fraction, ProcessStep>; // 0..1; a change is PercentagePoints
pub type PercentagePoints = Qty<FractionDelta, ()>; // "recovery up 2 pp", not "up 2%"
pub type SpecificEnergy = Qty<EnergyPerMass, Dry>; // kWh/t (BWi, SAG specific energy)
pub type BankVolume = Qty<Volume, InSitu>; // bcm; loose volume (lcm) is a different basis
pub type Density = Qty<MassPerVolume, DryInSitu>; // a Claim with method; §13
Arithmetic laws compiled into the types.
| Law | Type-level rule | Runtime refusal (when data arrives untyped) |
|---|---|---|
| Grade is intensive | Grade has no Add. The only average is mass_weighted_mean(&[(Grade, DryTonnes)]). |
FMINE-REF-103 (non-additive average) |
| Metal is extensive | MetalMass<S> adds only with the same stage S. Contained + Recovered does not compile. |
FMINE-REF-105 (basis mismatch) |
| Contained metal | Grade × DryTonnes → MetalMass<Contained>. Grade × WetTonnes does not compile. |
FMINE-REF-105 |
| Wet to dry | No law exists. WetTonnes → DryTonnes requires a MoistureClaim for that lot (§25.3). |
FMINE-REF-105; FMINE-REF-403 for shipments |
| Volume to mass | BankVolume × Density → DryTonnes, where the density Claim carries method and support. Loose volume needs a swell Claim. |
FMINE-REF-102 (support mismatch) |
| Recovery | MetalMass<Contained> × Recovery → MetalMass<Recovered>. Recovery applies at processing support only. |
FMINE-REF-102 (G-CRUC-2) |
| Recoverable inventory | MetalMass<Contained> × card → MetalMass<Recoverable{card}>. A ProcessInventory row declares Contained or Recoverable (heap books are usually recoverable-basis; E275, E276). Recoverable never adds to Contained. |
FMINE-REF-105 |
| Chemical basis | Qty<MassConc, AsN> meets a limit typed AsNO3 only through a registered stoichiometric law (× 4.427); likewise as-CaCO3 and dissolved vs total. Water, effluent and assay limits are typed the same way. |
FMINE-REF-105. Fixture: nitrate reported as N against a limit stated as NO3 (E322–E324) |
| Mass fraction | An analyte mass fraction lies in [0, 1] on import (Porgera's database held S > 100%; C4 P12). | Refuse the row; discrepancy entry |
| Payable | Payable is produced only by contract terms in fmine-acctpack (payable %, minimum deductions, penalties). |
— |
| Percent | % used as a ratio and percentage points used as a delta are different types. |
— |
| Non-additive geomet attributes (BWi, recovery, Ai) | Mixing needs a registered MixRule (§13.6, §17.4), or the mix is refused. |
FMINE-REF-103 |
Exact constants. Conversion factors that are exact by definition are stored as rationals, and a conversion rounds once, with a declared rounding rule:
- 1 troy ounce = 31.1034768 g;
- 1 lb = 0.45359237 kg;
- 1 short ton = 2,000 lb = 0.90718474 t;
- 1 oz/st = 240/7 g/t (≈ 34.2857). A historical US resource quoted in opt is converted exactly, not with "34.29".
Representations.
- Engines compute in
f64(Repr = f64), under the determinism classes of §29. - Accountable values crossing into the ledger or FA use
ExactQty: an i128 scaled decimal with a declared scale per dimension (milligrams for metal mass, grams for tonnage, 10⁻⁹ for fractions). - The conversion
f64 → ExactQtyis an explicit, logged rounding step and never implicit.
Money.
Money { ccy: Currency, minor: i128 }is a boundary type only. FrankenMining never computes authoritative balances; FA does (§21).- FX is always a Claim with source, date and rate type (spot, average, closing). There is no implicit conversion, and two currencies never add.
- Prices (
$/oz,$/lb) areMoney-per-MetalMassand come from a versioned price deck (INV-013). - At the bridge,
Moneymaps one-to-one onto FA's amount type. FA'sunits.tomlhas no metals (B4 S6), so metal quantities travel as Statistical-account rows (§21.4) until the FA unit ask lands (Appendix F).
Import boundary.
- Untyped numbers enter only through
Portal(§32), where a dialect row must declare unit, basis and support for every column. - An undeclared unit is stored as
UNREGISTERED_UNIT, is viewable, and cannot be combined (FMINE-REF-107).
25.3 The wet/dry rule and moisture as a per-lot measurement
- A lot is the unit of moisture measurement: a truck-load group, a stockpile reclaim campaign, a concentrate parcel, a shipment or a filter-cake batch. Moisture is a Claim per lot, with a sampling method, a drying method and a time.
- Moisture is never a site constant. When only a planning moisture exists, the dry tonnes are a Claim of evidence
class
Assumed, with the UU term priced by the moisture variance observed in reconciled history (§9.3). - Concentrate. Wet-to-dry conversion for sale uses the contract's moisture determination. For shipment release, FMINE-REF-403 (moisture vs TML) applies (§17.6).
- Why this matters (GB-34). A constant moisture assumption is a hidden bias that §20 would attribute to the wrong node (mill vs mine).
25.4 fmine-time (S0)
§6.3 fixes the quad-temporal semantics (QuadTemporalStamp, anchors, as_of_decision vs for_physical_period). This crate supplies the types.
| Type | Meaning | Rule |
|---|---|---|
RecordTime |
(cell, seq) plus TimeEvidence for the wall clock |
Ordering across cells is never by wall clock, only by anchors and cross-cell references (INV-012) |
ValidTime |
Interval [from, to) in UTC nanoseconds (i64) with a granularity tag |
An instant is a zero-width interval at its granularity; used for physical_valid_time |
CollectionTime |
UTC nanoseconds (i64) plus TimeEvidence |
Physical acquisition instant of sample, core interval, survey pickup, or sensor frame (collection_time >= physical_valid_time.from) |
AvailabilityTime |
UTC nanoseconds (i64) plus TimeEvidence |
Instant when lab assay certificate, QA/QC disposition, or processed reading became operationally observable (availability_time >= collection_time) |
QuadTemporalStamp |
{physical_valid_time: ValidTime, collection_time: CollectionTime, availability_time: AvailabilityTime, record_time: RecordTime} |
Mandatory on observations and Claims (§6.3, §8.1). Operational hindcasts and short-term decision backtests filter on availability_time <= t_dec (INV-016, G-TIME-2); physical period closes group by physical_valid_time. |
TimeEvidence |
{source: Gnss | Ptp | Ntp | DeviceRtc | Manual, offset_bound, sync_status, observed_at} |
Clock uncertainty is explicit. A manual time carries a ≥ 60 s bound by default. |
SiteCalendar |
IANA zone id, production-day boundary (e.g. 06:00 local), shift pattern, month-end cut rule | A registry row per site (registries/calendars.toml). DST rules are data. Leap seconds are not represented; the ≤ 1 s ambiguity is recorded in TimeEvidence. |
FiscalCalendar |
Issuer fiscal periods and close calendars | Matches FA periods exactly (FA-ACC rows, §21.3) |
Roster |
FIFO and residential rotation patterns (14/7, 8/6, 4×4 …) | Hours rules are hard constraints (§19, GB-23) |
Clock<'cx> |
Time read through Cx capability TIME only |
K and E crates have no TIME capability (§26.6). Engines receive times as inputs, so replay is deterministic. |
No chrono or time crates in FrankenMining code. Both are banned as direct dependencies and in public APIs (§28.5, L-5); they appear only transitively inside foundations, on an explicit allow-list. The few calendar algorithms needed (civil-from-days, zone offsets from a registry snapshot, ISO weeks) are std-only, with known-answer tests against a pinned oracle table.
25.5 fmine-crs (S0)
| Concern | Design |
|---|---|
| Scope | An EPSG subset, not a PROJ port: geographic WGS 84, WGS 84 / UTM zones, the national datums actually used at operating sites (for example Arc 1950/1960 in East and Southern Africa, NAD83 in Nevada, PSAD56 legacy data in South America), and their registered Helmert transforms with stated accuracy |
| Mine grids | A local grid is a fitted transform (2-D similarity or affine plus vertical offset) from surveyed control points. The transform is a Claim: RMS residual, control-point hull as its validity domain, surveyor attestation. Use outside the hull is flagged (G-CRS-2). |
| Vertical | Ellipsoidal vs orthometric heights are distinct types. Mine RL = orthometric + registered offset. Geoid grids are CAS objects with provenance. |
| Unregistered | Data imported without a declared CRS keeps raw coordinates tagged UNREGISTERED. It is viewable in its own frame. Any combination with registered data is refused (FMINE-REF-106). |
| Canonical encoding | f64 metres in a declared CRS; for hashing, canonical bit patterns (no −0.0, no NaN) |
| Oracle | PROJ in the lab lane only (§33.2), with known-answer transforms at ≤ 1 mm for projection math; datum transforms checked against the EPSG-stated accuracy |
| Units in coordinates | Feet-based legacy grids (US survey foot vs international foot) are distinct units. The difference is 2 ppm, which is 2 cm over 10 km. |
25.6 Guards and refusal codes added by this section
The §8.4 code table gains four domain-law refusals:
- FMINE-REF-105: basis mismatch (wet/dry, metal stage, material).
- FMINE-REF-106: unregistered or incompatible CRS/datum combined.
- FMINE-REF-107: undeclared unit, basis or time zone on import.
- FMINE-REF-108: assay-availability lookahead (
AssayLagLookahead,availability_time > t_dec; §6.3, G-TIME-2).
| Guard | Trigger | Action |
|---|---|---|
| G-UNIT-1 | Grade averaged by count, volume or wet mass | FMINE-REF-103 |
| G-UNIT-2 | Wet tonnes reach a contained-metal calculation without a lot moisture Claim | FMINE-REF-105 |
| G-UNIT-3 | A conversion factor typed by a user (not a registered exact constant) | Refuse; the constant must be registered |
| G-UNIT-4 | An imported CorrelationCard mixes input units (g/t and oz/st), or its output scale (fraction vs %) is unparsed, or its formula fails parse_check |
Refuse the card (§17.3; E171) |
| G-UNIT-5 | A document quantity with a stated derivation fails replay on import: a dimension mismatch, or an input that conflicts with the same document | Discrepancy entry. Fixtures: a stated area that is a volume in m³ (E347); fuel and GHG on hours that conflict with the same document (E346) |
| G-CRS-1 | UNREGISTERED coordinates joined to registered data |
FMINE-REF-106 |
| G-CRS-2 | A mine-grid transform used outside its control hull | Claim colour Estimated plus a UU term; a decision-grade use refuses |
| G-CRS-3 | Coordinates with no stated CRS | A CRS recovered by fit is a Claim with its residual, never silently assigned (E314) |
| G-TIME-1 | A period aggregate built on a UTC midnight boundary for a site with a different production-day boundary | Refuse; use SiteCalendar |
| G-TIME-2 | An operational hindcast, forecast registration, or short-term dig-line backtest (as_of_decision(t_dec)) conditions on an assay or observation with availability_time > t_dec |
Refuse (FMINE-REF-108: AssayLagLookahead; INV-016) |
| PO | Statement | Verification |
|---|---|---|
| PO-UNIT-1 | Every exact conversion round-trips to within one unit of the declared scale | Property tests over random quantities |
| PO-UNIT-2 | No public function in K/E crates takes a bare f64 for a physical quantity |
xtask check-claims lint (INV-001) |
| PO-UNIT-3 | Mass-weighted means are invariant to splitting and merging lots | Metamorphic tests (§33) |
| PO-CRS-1 | Registered transforms agree with the PROJ oracle within stated accuracy over a 10⁴-point corpus per site CRS | Lab fixtures |
| PO-TIME-1 | Calendar algorithms agree with the pinned oracle table over 1900–2200 | Known-answer tests |
| PO-TIME-2 | as_of_decision(t_dec) excludes every record with availability_time > t_dec even when physical_valid_time <= t_dec |
Property test with synthetic 1–21 day lab-turnaround delays |
25.7 Galaxy-brain card
GB-34 · A constant moisture assumption manufactures a "mill problem".
- Equation. dry = wet × (1 − m). The contained-metal error is Δdry × grade, and the revenue error is Δdry × grade × recovery × price.
- Substituted.
- One month of 1,000,000 wmt of ROM ore at 1.2 g/t.
- Planning moisture 6% gives 940,000 dmt. The measured lot moisture is 9%, giving 910,000 dmt.
- Δ = 30,000 dmt → 36,000 g = 1,157 oz contained, and 1,042 oz recovered at 90%. At $3,000/oz that is $3.1M per month (≈ $37.5M per year).
- In §20 this appears as a 3.2% gap between the mine-side tonnes claim and the mill feed.
- Intuition. An unmeasured moisture difference looks exactly like a mill under-recovery or a weightometer bias. If moisture is a constant, the reconciliation posterior will attribute it to the wrong node, and it may refuse attribution altogether (FMINE-REF-104), because the moisture and weightometer biases are not separately identifiable without lot moisture data.
- Assumptions. A single blended moisture; no weightometer bias; a constant grade.
- Flip. Per-lot moisture sampling makes the two biases identifiable. Its VOI is a §22 card, and is usually large relative to sampling cost.