Skip to content

identifier

@fungi.computer/cairn


@fungi.computer/cairn / identifier

Bounded error thrown when a trusted family declaration violates Cairn’s version 1 definition invariants.

This error retains no rejected definition, family, kind, cause, or detail.

  • Error

new CairnDefinitionError(): CairnDefinitionError

Creates a fresh bounded family-definition error.

CairnDefinitionError

Error.constructor

readonly name: "CairnDefinitionError" = "CairnDefinitionError"

Stable public error name.

Error.name

readonly code: "invalid_definition" = "invalid_definition"

Stable machine-readable error discriminator.


Bounded error thrown when secure entropy is unavailable during codec generation.

This error retains only validated family and kind metadata and never exposes a foreign cause, detail, or random bytes.

  • Error

new CairnGenerationError(input): CairnGenerationError

Creates a fresh bounded generation error.

Readonly<{ family: string; kind: string; }>

Validated family and kind metadata for the failing codec.

CairnGenerationError

Error.constructor

readonly name: "CairnGenerationError" = "CairnGenerationError"

Stable public error name.

Error.name

readonly code: "entropy_unavailable" = "entropy_unavailable"

Stable machine-readable error discriminator.

readonly family: string

Validated family whose codec could not generate an identifier.

readonly kind: string

Validated kind whose codec could not generate an identifier.

readonly version: 1 = 1

Wire grammar version used by the codec.

Generator and canonical parser for one declared identifier family and kind.

F extends string

Declaring identifier family.

K extends string

Identifier kind within the family.

V extends 1 = 1

Retained wire grammar version; currently version 1.

readonly family: F

Declared identifier family; it is not serialized into metadata.

readonly kind: K

Declared identifier kind; it is not serialized into metadata.

readonly version: V

Wire grammar version implemented by this codec.

generate(): CairnId<F, K, V>>

Generates one canonical identifier with a 21-character base36 suffix.

CairnId<F, K, V>

A fresh canonical identifier branded for this codec.

CairnGenerationError When secure entropy is unavailable.

parse(value): IdParseResult<CairnId<F, K, V>>, F, K>>

Parses an untrusted value without trimming, decoding, or normalization.

unknown

Untrusted candidate value.

IdParseResult<CairnId<F, K, V>, F, K>

The original branded value or one bounded parse error.

is(value): value is CairnId<F, K, V>

Reports whether an untrusted value is canonical for this codec.

unknown

Untrusted candidate value.

value is CairnId<F, K, V>

Whether the value is accepted by IdCodec.parse.

CairnId<F, K, V> > = string & object

Canonical opaque identifier branded by its declaring family, kind, and wire grammar version.

readonly [cairnIdBrand]: readonly [F, K, V]

Compile-time identity metadata that is never serialized.

F extends string

Declaring identifier family.

K extends string

Identifier kind within the family.

V extends 1 = 1

Retained wire grammar version; currently version 1.


IdOf<C> > = C extends IdCodec<infer F, infer K, infer V> ? CairnId<F, K, V> > : never

Extracts the distinctly branded identifier produced by an ID codec.

C

Codec whose identifier type is required.


IdParseError<F, K> > = Readonly<{ code: "invalid_id"; family: F; kind: K; version: 1; reason: "type" | "bounds" | "grammar" | "non_canonical"; }>

Bounded public description of a rejected identifier value.

The error deliberately retains neither the rejected value nor a foreign cause.

F extends string

Declaring identifier family.

K extends string

Identifier kind within the family.


IdParseResult<I, F, K> > = Readonly<{ ok: true; value: I; }> | Readonly<{ ok: false; error: IdParseError<F, K>>; }>

Successful canonical parsing or one bounded parse error.

I

Branded identifier returned after successful parsing.

F extends string

Declaring identifier family.

K extends string

Identifier kind within the family.


IdKindDefinition = Readonly<{ prefix: string; acceptedSuffixLength?: readonly [number, number]; }>

Trusted declaration for one identifier kind within a family.


IdFamily<F, D> > = Readonly<{ readonly [K in keyof D]: IdCodec<F, K & string, 1> }>>

Readonly family whose every own kind key maps to one distinctly branded version 1 codec.

F extends string

Declaring identifier family.

D extends Readonly<Record<string, IdKindDefinition>>

Own identifier-kind declarations for the family.

defineIdFamily<F, D>>(definition): IdFamily<F, D>>

Validates one trusted version 1 family declaration and creates its readonly family-scoped codecs.

Family and kind names, prefixes, compatibility ranges, own-key counts, and prefix uniqueness must satisfy the accepted Cairn invariants before any codec is returned.

F extends string

Literal identifier-family name.

D extends Readonly<Record<string, Readonly<{ prefix: string; acceptedSuffixLength?: readonly [number, number]; }>>>

Literal own kind declarations for the family.

Readonly<{ family: F; version: 1; kinds: D; }>

Trusted version 1 family declaration to validate.

IdFamily<F, D>

One readonly codec property for every own kind key.

CairnDefinitionError When any declaration invariant or property access fails.