Physical profile
How a product's size and weight are held. This page summarises
ADR 0002; the ADR is
the authority and internal/domain/product/physical.go is the implementation.
Two sources that disagree
| Part | Who supplies it | Type | Set by |
|---|---|---|---|
| Declared | vendor or master-data steward (catalogue, packaging spec), before the first unit arrives | UnitDimensions | PUT /products/{sku}/dimensions/declared → DeclareDimensions |
| Measured | a dimensioning device (cubiscan) or a person, on a real unit | Measurement = UnitDimensions + measuredAt + optional deviceId | PUT /products/{sku}/dimensions/measured → RecordMeasurement |
Rules
- Integer units. Length, width and height in whole millimetres, weight in
whole grams (
int64), so two services never disagree on rounding. - Bounds. Each dimension 1..20000 mm (
MaxDimensionMm), weight 1..2000000 g (MaxWeightG). They catch unit mistakes, not real limits. - Orientation is not normalised. Sides are stored as given;
VolumeMm3() = length x width x heightis orientation-free. - Effective values.
Effective()is the measurement if present, else the declared dimensions, else absent;EffectiveSource()ismeasured,declaredornone. Consumers act on the effective values only. - Latest measurement wins, by
measuredAt. An older reading than the current one isErrStaleMeasurement(409 stale-measurement); ameasuredAtafter the service clock isErrMeasuredAtInFuture(400 measured-at-in-future). A different reading with the samemeasuredAtreplaces the current one (a correction); the identical reading is no change.measuredAtis normalised to UTC and truncated to microseconds, the precision Postgres stores. - Discrepancy. When both parts exist,
Discrepancy()is true if the measured volume or the measured weight differs from the declared one by more than 10 % of the declared value (|m - d| * 10 > d, integer arithmetic). It is information for stewards, not a rejection. - Classification is independent.
Oversizedstays a steward decision; nothing derives or validates handling tags from dimensions.
Worked example
| Step | Declared (mm, g) | Measured (mm, g) | Effective | effectiveSource | discrepancy | version |
|---|---|---|---|---|---|---|
Register SKU-1 | none | none | none | none | false | 1 |
| Declare 100 x 100 x 100, 1000 g | 100 x 100 x 100, 1000 | none | declared | declared | false | 2 |
| Measure 100 x 100 x 105, 1050 g at 10:00 | same | 100 x 100 x 105, 1050 | measured | measured | false (5 % volume, 5 % weight) | 3 |
| Measure 100 x 100 x 120, 1000 g at 11:00 | same | 100 x 100 x 120, 1000 | measured | measured | true (20 % volume) | 4 |
| Measure again, dated 09:00 | same | unchanged | measured | measured | true | 4, rejected 409 stale-measurement |
Each accepted step publishes either ProductDimensionsDeclared or
ProductMeasured, both carrying the full profile (declared, measured,
effective, effective source, discrepancy, version), so a consumer overwrites
its copy instead of merging.
Not kept in v1
- A measurement history: only the latest measurement is stored
(
measured_*columns onproducts). ADR 0002 makes history an additive table with its own ADR if audit becomes a need. - A per-category tolerance: the 10 % threshold is fixed.