11. Type and Units
11.1 Scope
Type checking is contract-driven per operation argument:
- Expected arg dimensions come from operation catalog contracts.
- Checking is applied to IR step arguments.
- Unknown-step handling belongs to semantic validation, not typecheck.
- Constructor/content descriptor checks are split across semantic and type stages.
11.2 Quantity Requirement Model
For args that require dimensions:
- Value must be quantity-like (
IRQuantityor unary-negated quantity) unless deferred via identifier. - Unit must be known to the typechecker unit table.
- Unit dimension must match one of allowed dimensions for the arg.
11.3 Supported Dimensions and Unit Families
Supported dimensions:
- Time:
ms,s,min,h,day - Temperature:
C,K - Volume:
uL,mL,L - Mass:
ug,mg,g,kg - Electric potential:
V,mV - Electric current:
A,mA,uA - Rotation rate:
rpm - Count:
cells
Notes:
with env(co2=...)andwith env(rh=...)are checked against thepercentdimension and accept%.- Unknown units still fail before any dimension-specific acceptance can succeed.
11.4 Type Failure Surface
Type checking rejects:
- unknown or disallowed units
- quantity/unit dimension mismatches
- environment argument dimension mismatches
- mutation/load quantity unit or dimension mismatches
- constructor/content field type mismatches
- assignment target or value type mismatches
- program-field kind or dimension mismatches
Common diagnostics include TYPE_UNKNOWN_UNIT, TYPE_UNIT_NOT_ALLOWED, TYPE_DIMENSION_MISMATCH, and program-field TYPE_* diagnostics. The complete diagnostic list and stage placement are specified in Chapter 8.
11.5 Identifier Deferral
Identifier argument values:
- Identifier-based quantity values are deferred by typecheck (no full symbol/type environment).
- This allows valid patterns using
let-bound quantities while keeping checker conservative.
11.6 Boundary with Semantic Validation
Division of responsibilities:
- Semantic validation checks step existence and arg shape.
- Typecheck checks quantity/dimension compatibility.
- Runtime/material checks state-dependent numeric feasibility.
For content constructors:
- Semantic stage checks whitelist membership and required fields (for example
content_kind). - Type stage checks descriptor value types (for example
attrsshould be record-like). - Runtime stage checks state existence and conflict constraints (for example content identity lookup).
11.7 Conformance Boundary
Type checkers, call-contract validators, and conformance tests must conform to the type and unit rules in this chapter. Module layout and test file names are not part of the type contract.
11.8 Variable Type Catalog
Basic language-level type catalog:
Operation-specific result types are defined in Chapter 6.
Basic types:
Boolean:true/falseString: quoted text literalQuantity: numeric with unit suffix (for example10uL,37C,5%)Number: unitless numeric scalar (Quantitywithout unit in semantic usage)Identifier: symbolic name resolved by binding/type/runtime stagesList[T]: list valueRecord: structured payload valueVoid: no value / no required return object
Signed quantity note:
- A leading
-is expression syntax, not part of the quantity token. -20Ctherefore remains a quantity-like temperature expression for type and unit checking.
Domain reference type (used by operation contracts in Chapter 6):
Container: logical container identity reference; runtime may map it to physical labware (typically tube or plate well) through metadata.Content: logical content identity reference independent of container position.
11.9 Content Descriptor Type Contracts
Chapter 6 defines which content descriptor fields are required or optional. Value-level type constraints for those fields:
content_kind: Textcontent_type: Textcontent_code: Text(optional)content_name: Text(optional)attrs: Record(optional)
Type failures for these fields are commonly reported as TYPE_CONTENT_KIND_NOT_TEXT, TYPE_CONTENT_TYPE_NOT_TEXT, TYPE_CONTENT_CODE_NOT_TEXT, or TYPE_CONTENT_ATTRS_NOT_RECORD. The complete diagnostic list and stage placement are specified in Chapter 8.
11.10 Quantity Axis Rules for Content Loading
For LoadContent(container, content, amount, ...) style operations:
amountmust beQ[Volume|Mass|Count].- Unit family determines load axis (volume, mass, or count).
- Missing unit or wrong quantity dimension is rejected at type stage, commonly as
TYPE_LOAD_QUANTITY_UNIT_REQUIREDorTYPE_LOAD_QUANTITY_DIMENSION_MISMATCH. - Incompatible existing runtime axis should surface as a material-stage error, commonly as
MAT_CONTENT_LOAD_AXIS_MISMATCH, not a late semantic/type-stage error. - Diagnostic code definitions and stage placement are specified in Chapter 8.
cellsrequires cellular content when the content contract is statically known.- Direct authored and transferred
cellsquantities must be non-negative integers; runtime partition results may be fractional estimates. - Count is an authoritative component quantity axis, not a volume unit. A count-quantified transfer may nevertheless require runtime concentration to resolve the physical carrier volume moved with the cells.
11.11 Program, Stream, and Data Types
Program/value type families:
thermal_program: programmatic thermal-control descriptor/callable value used byenv(thermal=...)and other thermal-control flows.sep program: mechanism descriptor/callable value family forsep.frac program: mechanism descriptor/callable value family forfrac.data_schema_ref: declared open result-structure contract used byschema_ref.- Program descriptor values may be bound with
let; a let-bound program descriptor is not a container, content value, or executable statement. - Program descriptor values do not emit runtime steps by themselves. They become executable only when consumed by a compatible owner such as
sep,frac, orenv(thermal=...).
Program parameter value types:
CentrifugalSettingisQ[RelativeCentrifugalForce] | Q[RotationRate].- Relative centrifugal force is written with
g, for example8000g; rotation rate is written withrpm, for example12000rpm. - The unit
gdenotes mass in an ordinary mass-quantity position and relative centrifugal force in aCentrifugalSettingposition. - Conversion between relative centrifugal force and rotation rate requires rotor geometry and is not implicit.
field_programrequires exactly one ofvoltage: Q[ElectricPotential],current: Q[ElectricCurrent], orfield: Q[ElectricPotential].fieldis an alias forvoltage; electric potential and electric current are not implicitly interchangeable.
Stream/reference types:
unit_stream_ref: stream handle returned bystream(sample=..., unit=...).unit_ref: temporary unit reference valid only insiderepeat x in unit_stream.sep_container_group: fixed-length tuple-like group with stable slotsgroup[0]/group[1].fraction_group: ordered container sequence with stable index semantics.- These stream/group values are typed frontend/runtime references; they are not material-state scalar values.
Data/reference types:
data_ref: structured information result payload forimg/ecp/phyand decomposed analytical readout paths.data_group_ref: flat, ordered group ofdata_ref, aligned with grouped readout input order and supporting stablegroup[index]access.artifact_ref: minimal raw-artifact handle containing artifact identity/profile metadata.export_ref: minimal external/profile export handle containing export kind/profile/format identity metadata.
Result scalar/value types:
BoolResult: boolean predicate/result field.IntResult: integer count-like field.NumberResult: unitless numeric field.TextResult: text/label field.QuantityResult: quantity-valued field with unit.
11.12 Type Constraints for Atomic/Readout Contracts
env(thermal=...)accepts union type:Q[Temperature] | thermal_program.- Mechanism program records used by
sepandfracmust satisfy their declared field type and dimension constraints. fracbinsmust be integer-like.- Readout returns use
data_reffor single inputs anddata_group_reffor grouped inputs; they are not container-typed values. - Complex or profile-specific readout result shapes use
schema_refto constrain accessible fields.
Operator-specific accepted program families, source forms, and return contracts are defined in Chapter 6.
