Portable Entity ID Range
This page defines the cross-stack TeaQL contract for persistence identities and the foreign keys that reference them. It does not define business-facing numbers such as order numbers, account codes, or external partner identifiers.
Evidence status: provisional. The range is the adopted design contract and
matches Java Long, signed SQL BIGINT, and the checked signed bindings in
current Rust provider paths. A complete audit proving that every generator,
provider, import, and serialization entry point enforces the contract has not
yet been recorded. Applications must validate custom and external ID sources.
Normative Range
The portable numeric domain is:
PORTABLE_ID_MAX = 9,223,372,036,854,775,807 = 2^63 - 1
The following rules apply:
- Persisted entity IDs and foreign keys MUST be in
1..=PORTABLE_ID_MAX. - Zero is reserved for unassigned/sentinel use and MUST NOT be generated or persisted as an entity identity.
- Negative values are invalid.
- Values greater than
PORTABLE_ID_MAXare invalid even when a language or database type can represent them. - An invalid value MUST be rejected before mutation; it MUST NOT be wrapped, truncated, clamped, or reinterpreted as signed bits.
- Primary-key and foreign-key columns SHOULD use a signed 64-bit integer type.
- Business identifiers MUST use a separate field and lifecycle contract.
Null or an option type represents absence. Code must not silently translate between null and zero.
Language and Storage Mapping
| Boundary | Required representation | Validation |
|---|---|---|
| Rust domain/runtime | u64 is permitted | Require 1 <= id && id <= i64::MAX as u64 before persistence or interchange |
| Java domain/runtime | long / Long | Require a positive value; never use negative long values as unsigned IDs |
| Go service | int64 preferred; checked uint64 permitted internally | Reject zero and values greater than math.MaxInt64 |
| Python service/tooling | int | Explicitly require 1 <= id <= 2**63 - 1 |
| SQL schema | signed BIGINT or exact equivalent | Add application validation; use a database check constraint where operationally compatible |
| Protobuf | int64 | Reject zero/negative values for persisted IDs |
| JSON/HTTP | canonical decimal string | Parse digits, reject non-canonical forms, then check the range |
Do not choose a SQL unsigned column merely because one provider offers it. The portable contract is defined by the shared range, not the widest capability of one provider.
JSON Contract
IDs exposed through JSON MUST be decimal strings:
{
"id": "481923487123456789",
"ownerId": "7234567890123456789"
}
This rule avoids precision loss in JavaScript, whose Number type represents
integers exactly only through 2^53 - 1.
The canonical persisted-ID form:
- contains ASCII digits only;
- has no sign, whitespace, decimal point, or exponent;
- has no leading zero;
- parses to a value in
1..=PORTABLE_ID_MAX.
An endpoint that needs an explicit unassigned value may accept null. It
SHOULD NOT publish "0" as an entity identity.