Spec version: 1.0-alpha
All wrappers and runtimes implement the same deterministic contract:
- deterministic for identical input + config
- bounded output in configured
output_range - explicit failure behavior for invalid ranges and unsupported inputs
- reproducible output by serializing the mapper spec
- no silent coercions, no magic fallback values
- Supported values and ranges are validated before mapping.
NaNand infinity are rejected for numeric contracts unless a language runtime explicitly permits them by policy.- Unknown tokens/symbols/fields/objects fail with explicit typed errors.
- Mapping is never random and never reads global mutable defaults.
mapped = out_min + ((value - in_min) / (in_max - in_min)) * (out_max - out_min)
This formula is the only mapping behavior used unless a wrapper documents a different family policy contract (for example, byte, alphabet, or schema-based mapping).
Alpha focuses on integer support plus explicit extensions for floats, booleans, text, bytes, sequences, and map/object schema contracts.
The default output range is [-1.0, 1.0].
value: one input item to map.input range: an ordered pair[in_min, in_max]declaring valid input bounds.output range: an ordered pair[out_min, out_max]declaring output bounds.mapper: an object or function implementing this contract.mapping spec: serializable metadata needed to reproduce a mapper.transform: the act of mapping one supported value.inverse transform: a future operation for mapping output back to input when safe.clipping: clamping out-of-range input to the nearest input bound before mapping.strict mode: raising an error for out-of-range input.finite numeric value: a number that is not NaN and not positive or negative infinity.
Default bounds apply to all mappers unless explicitly configured:
out_min = -1.0
out_max = 1.0
The output must remain finite and within the configured range when value is finite and contract-valid.
Alpha integer mapping requires:
in_min < in_maxout_min < out_max- input values are integers
- booleans are rejected even in languages where booleans behave like integers
- output is a floating-point value
- no hidden global state
Lower input bound maps to out_min. Upper input bound maps to out_max. Exact midpoints map to 0.0 for the default output range where mathematically exact.
mapper_type:integer_rangeinput_range:[in_min, in_max]output_range:[out_min, out_max]clip: strict (false) or clipping mode (true)name(optional): metadata label for auditing and traceability
Required spec keys are versioned with spec_version.
Mapper specs are serialized as strict JSON: non-finite values such as NaN and Infinity are rejected, and any configured missing_value must itself be JSON-serializable.
Duplicate JSON object keys are rejected during spec recovery so mapper metadata stays deterministic.
If clip is false, values below in_min or above in_max must raise an out-of-range error.
If clip is true, values below in_min map as in_min, and values above in_max map as in_max.
Text and string mappers must document policy explicitly (codepoint, alphabet, or byte).
Unknown characters/symbols must fail, and text mapping must be deterministic and shape-preserving on a per-symbol basis.
- Mappers declare an explicit
vocabularyor token list. - token indices are mapped deterministically by position in the vocabulary.
- vocabulary tokens are JSON-serializable scalar values and are keyed type-aware so booleans do not collapse into numeric tokens.
- unknown token must fail with an explicit error.
- output range is bounded by configured
output_range, and vocabularies are serialized into mapper specs.
Python's byte-family mapper uses the same deterministic model:
- accepted input:
bytes,bytearray,memoryview - explicit empty-policy via
allow_empty - each raw byte
0..255maps through the canonical linear formula - unsupported payload types fail with explicit typed errors
Map mapping is schema-driven and deterministic:
- each schema field must declare its own mapper policy,
- only schema-declared fields are emitted by default,
- unknown keys fail unless explicitly configured,
- missing required fields fail unless
missing_valueis configured, - object inputs are mapped via readable attributes and mapping inputs via dictionary keys.
- property accessor failures are not swallowed; they propagate as explicit runtime errors.
mapper_type:map_rangeschema: ordered field-to-mapper spec mapallow_unknown: boolallow_empty: boolmissing_value(optional): fallback for missing required fieldsname(optional)
Schema order is deterministic because mappings preserve insertion order; runtimes must preserve declared schema order for reproducibility.
Schema mappers used inside maps and sequences must support both map_value() and to_dict() so nested specs remain serializable and reproducible.
mapper_type:text_rangemode:codepoint,alphabet, orbytealphabet(required for alphabet mode): stable symbol list used for indexing, with at least two unique charactersinput_range: derived by modeoutput_range:[out_min, out_max]allow_empty: boolclip: boolname(optional)
Equal or reversed ranges are invalid. NaN and infinity are invalid wherever numeric range values are accepted. Non-integer input values are invalid for the alpha integer mapper.
InvalidRangeError: invalid range shape, order, or zero-length intervalUnsupportedTypeError: unsupported input type, token, or familyOutOfRangeError: valid type in strict mode outside declared input rangeNotFiniteError:NaN/infinity in numeric inputsSerializationError: malformed or incompatible mapper spec
Mapper specs must include enough metadata to reproduce exact behavior in another runtime:
- version (
spec_version) - mapper kind (
mapper_type) - fitted ranges (
input_range,output_range) - control flags (
clip, family policy keys) - optional human metadata (
name, extraction notes)
Mapper specs must use JSON-compatible values.
{
"spec_version": "1.0-alpha",
"implementation_version": "0.1.0-alpha",
"mapper_type": "integer_range",
"input_range": [0, 100],
"output_range": [-1.0, 1.0],
"clip": true,
"name": "optional-name"
}name is optional. Specs must not include raw user datasets.
A conforming alpha implementation must prove:
- lower bound maps to
-1.0 - upper bound maps to
1.0 - midpoint maps to
0.0when exact - positive, negative, mixed, non-zero, and large ranges work
- strict mode raises for out-of-range values
- clipping mode clamps out-of-range values
- invalid ranges fail clearly
- non-integers and booleans are rejected
- mapper specs serialize and reload reproducibly
Future mappers for categories, temporal values, and richer object extractors must declare explicit mapping policies.
Opaque runtime values are not ordinary data-bearing values and must not be mapped implicitly. Examples include file handles, sockets, processes, threads, closures/functions, live database cursors, runtime locks, and raw pointers without metadata.
The default policy is reject without explicit extractor. An extractor contract must declare:
contract_type- source runtime type
- extractor name
- output mapper family
- schema or metadata needed for safe extraction
- deterministic behavior statement
- explicit failure policy
Extractor output must be ordinary data already supported by a mapper family. Raw pointers additionally require size, element type, safe-read bounds, ownership/lifetime, and byte order when relevant. Extractor contracts must not add third-party runtime dependencies to the core SDK.
The machine-readable production boundary is tracked in compliance/opaque_extractor_contract.json.
TemporalRangeMappermaps accepted temporal values through a deterministic conversion policy.- Accepted temporal types are datetime-like values, timedeltas, and explicit numeric timestamps depending on mode.
- Temporal family policies must define mode, epoch/base behavior, and naive datetime handling explicitly.
- Unknown or unsupported temporal values must fail with explicit errors.
Unknown values must not map to arbitrary magic values.
ImageRangeMappersupports explicit modes:grayscale(numeric channels treated as scalar pixel intensities),rgb(3-channel pixels),rgba(4-channel pixels),raw_bytes(bytes / bytearray / memoryview).
- For
rgbandrgba, each deepest-level pixel must be an explicit channel tuple/list with exact channel count. - For
raw_bytes, input must be byte-like; shape is not inferred. - Empty containers are invalid unless
allow_empty=True. - Scalar channel values are mapped through the declared input range (
input_range) using the same canonical formula. - Unknown or malformed structures fail explicitly with typed errors (no implicit coercion of containers).
Beta and production readiness require explicit language-wrapper policies for:
- float and bool families
- nested sequence families
- bytes/buffers
- categories/tokens
- object schemas and map-like data
- image-like structures
- temporal values
- extractor contracts for opaque runtime objects (sockets, threads, file handles, closures, raw pointers without metadata)