{
  "version": 4,
  "vectors": [
    {
      "name": "timestamp_extract_running_example",
      "category": "codec:timestamp",
      "operation": "extract",
      "input": "usr_06f80z92d2dbsqqg28t5cy4tqg",
      "expected": 1780272145000
    },
    {
      "name": "timestamp_generate_running_example",
      "category": "codec:timestamp",
      "operation": "generate",
      "input": { "timestamp": 1780272145000, "rng": "9abcdef0123456789abc" },
      "expected": "usr_06f80z92d2dbsqqg28t5cy4tqg"
    },
    {
      "name": "timestamp_generate_ms_min_rng_min",
      "description": "boundary: ms = 0, all-0x00 rng — the minimum 16-byte payload",
      "category": "codec:timestamp",
      "operation": "generate",
      "input": { "timestamp": 0, "rng": "00000000000000000000" },
      "expected": "usr_00000000000000000000000000"
    },
    {
      "name": "timestamp_extract_ms_min_rng_min",
      "category": "codec:timestamp",
      "operation": "extract",
      "input": "usr_00000000000000000000000000",
      "expected": 0
    },
    {
      "name": "timestamp_generate_ms_min_rng_max",
      "description": "boundary: ms = 0, all-0xff rng",
      "category": "codec:timestamp",
      "operation": "generate",
      "input": { "timestamp": 0, "rng": "ffffffffffffffffffff" },
      "expected": "usr_0000000003zzzzzzzzzzzzzzzw"
    },
    {
      "name": "timestamp_extract_ms_min_rng_max",
      "category": "codec:timestamp",
      "operation": "extract",
      "input": "usr_0000000003zzzzzzzzzzzzzzzw",
      "expected": 0
    },
    {
      "name": "timestamp_generate_ms_max_rng_min",
      "description": "boundary: ms = 2^48 - 1 (281474976710655), all-0x00 rng",
      "category": "codec:timestamp",
      "operation": "generate",
      "input": { "timestamp": 281474976710655, "rng": "00000000000000000000" },
      "expected": "usr_zzzzzzzzzw0000000000000000"
    },
    {
      "name": "timestamp_extract_ms_max_rng_min",
      "category": "codec:timestamp",
      "operation": "extract",
      "input": "usr_zzzzzzzzzw0000000000000000",
      "expected": 281474976710655
    },
    {
      "name": "timestamp_generate_ms_max_rng_max",
      "description": "boundary: ms = 2^48 - 1 (281474976710655), all-0xff rng — the maximum 16-byte payload",
      "category": "codec:timestamp",
      "operation": "generate",
      "input": { "timestamp": 281474976710655, "rng": "ffffffffffffffffffff" },
      "expected": "usr_zzzzzzzzzzzzzzzzzzzzzzzzzw"
    },
    {
      "name": "timestamp_extract_ms_max_rng_max",
      "category": "codec:timestamp",
      "operation": "extract",
      "input": "usr_zzzzzzzzzzzzzzzzzzzzzzzzzw",
      "expected": 281474976710655
    },
    {
      "name": "reverse_extract_running_example",
      "description": "the 6 timestamp bytes are bitwise-inverted before encoding; extract re-inverts them",
      "category": "codec:reverse",
      "operation": "extract",
      "input": "usr_zsgqz0pxjydbsqqg28t5cy4tqg",
      "expected": 1780272145000
    },
    {
      "name": "reverse_generate_running_example",
      "category": "codec:reverse",
      "operation": "generate",
      "input": { "timestamp": 1780272145000, "rng": "9abcdef0123456789abc" },
      "expected": "usr_zsgqz0pxjydbsqqg28t5cy4tqg"
    },
    {
      "name": "reverse_generate_ms_min_rng_min",
      "description": "boundary: ms = 0, all-0x00 rng — inverted ts bytes (0xff) sort the epoch last",
      "category": "codec:reverse",
      "operation": "generate",
      "input": { "timestamp": 0, "rng": "00000000000000000000" },
      "expected": "usr_zzzzzzzzzw0000000000000000"
    },
    {
      "name": "reverse_extract_ms_min_rng_min",
      "description": "re-inverts the 0xff ts bytes back to ms = 0",
      "category": "codec:reverse",
      "operation": "extract",
      "input": "usr_zzzzzzzzzw0000000000000000",
      "expected": 0
    },
    {
      "name": "reverse_generate_ms_min_rng_max",
      "description": "boundary: ms = 0, all-0xff rng",
      "category": "codec:reverse",
      "operation": "generate",
      "input": { "timestamp": 0, "rng": "ffffffffffffffffffff" },
      "expected": "usr_zzzzzzzzzzzzzzzzzzzzzzzzzw"
    },
    {
      "name": "reverse_extract_ms_min_rng_max",
      "category": "codec:reverse",
      "operation": "extract",
      "input": "usr_zzzzzzzzzzzzzzzzzzzzzzzzzw",
      "expected": 0
    },
    {
      "name": "reverse_generate_ms_max_rng_min",
      "description": "boundary: ms = 2^48 - 1 (281474976710655), all-0x00 rng — inverted ts bytes (0x00) sort newest first",
      "category": "codec:reverse",
      "operation": "generate",
      "input": { "timestamp": 281474976710655, "rng": "00000000000000000000" },
      "expected": "usr_00000000000000000000000000"
    },
    {
      "name": "reverse_extract_ms_max_rng_min",
      "description": "re-inverts the 0x00 ts bytes back to ms = 2^48 - 1",
      "category": "codec:reverse",
      "operation": "extract",
      "input": "usr_00000000000000000000000000",
      "expected": 281474976710655
    },
    {
      "name": "reverse_generate_ms_max_rng_max",
      "description": "boundary: ms = 2^48 - 1 (281474976710655), all-0xff rng",
      "category": "codec:reverse",
      "operation": "generate",
      "input": { "timestamp": 281474976710655, "rng": "ffffffffffffffffffff" },
      "expected": "usr_0000000003zzzzzzzzzzzzzzzw"
    },
    {
      "name": "reverse_extract_ms_max_rng_max",
      "category": "codec:reverse",
      "operation": "extract",
      "input": "usr_0000000003zzzzzzzzzzzzzzzw",
      "expected": 281474976710655
    },
    {
      "name": "to_uuid_running_example",
      "description": "the 16 payload bytes written verbatim as an RFC 9562 lowercase hyphenated UUID",
      "category": "wire",
      "operation": "to_uuid",
      "input": "usr_06f80z92d2dbsqqg28t5cy4tqg",
      "expected": "019e807d-2268-9abc-def0-123456789abc"
    },
    {
      "name": "from_uuid_running_example",
      "category": "wire",
      "operation": "from_uuid",
      "input": "019e807d-2268-9abc-def0-123456789abc",
      "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
    },
    {
      "name": "from_uuid_uppercase_accept",
      "description": "RFC 9562 parsers accept uppercase hex; output is the same canonical id",
      "category": "wire",
      "operation": "from_uuid",
      "input": "019E807D-2268-9ABC-DEF0-123456789ABC",
      "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
    },
    {
      "name": "from_uuid_reject_braces",
      "description": "braced {…} form is rejected; only the hyphenated 8-4-4-4-12 form is accepted",
      "category": "wire",
      "operation": "from_uuid",
      "input": "{019e807d-2268-9abc-def0-123456789abc}",
      "expected": { "ok": false, "layer": "uuid" }
    },
    {
      "name": "canonicalize_uppercase",
      "description": "ASCII A-Z folds to lowercase",
      "category": "wire",
      "operation": "canonicalize",
      "input": "USR_06F80Z92D2DBSQQG28T5CY4TQG",
      "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
    },
    {
      "name": "canonicalize_alias_o_to_zero",
      "description": "Crockford visual alias o/O resolves to 0 before validation",
      "category": "wire",
      "operation": "canonicalize",
      "input": "usr_o6f8oz92d2dbsqqg28t5cy4tqg",
      "expected": { "ok": true, "id": "usr_06f80z92d2dbsqqg28t5cy4tqg" }
    },
    {
      "name": "canonicalize_reject_padding_bit",
      "description": "final base32 char '1' has non-zero low 2 bits (not in [048cgmrw])",
      "category": "wire",
      "operation": "canonicalize",
      "input": "usr_00000000000000000000000001",
      "expected": { "ok": false, "layer": "base32" }
    },
    {
      "name": "canonicalize_reject_wrong_prefix",
      "description": "a well-formed id of a different brand is rejected at the prefix layer (vectors are authored against brand usr)",
      "category": "wire",
      "operation": "canonicalize",
      "input": "org_06f80z92d2dbsqqg28t5cy4tqg",
      "expected": { "ok": false, "layer": "prefix" }
    },
    {
      "name": "from_uuid_reject_not_string",
      "description": "non-string input (null) is rejected at the not_a_string layer before any UUID shape check",
      "category": "wire",
      "operation": "from_uuid",
      "input": null,
      "expected": { "ok": false, "layer": "not_a_string" }
    },
    {
      "name": "canonicalize_reject_not_string",
      "description": "non-string input (a number) is rejected at the not_a_string layer before any prefix/base32 check",
      "category": "wire",
      "operation": "canonicalize",
      "input": 42,
      "expected": { "ok": false, "layer": "not_a_string" }
    },
    {
      "name": "canonicalize_reject_unicode_kelvin",
      "description": "U+212A KELVIN SIGN is not ASCII; SPEC case folding is ASCII-only, so it is not folded to 'k' and the payload is rejected at the base32 layer (guards against String.prototype.toLowerCase() Unicode aliasing)",
      "category": "wire",
      "operation": "canonicalize",
      "input": "usr_\u212akkkkkkkkkkkkkkkkkkkkkkkk0",
      "expected": { "ok": false, "layer": "base32" }
    },
    {
      "name": "canonicalize_reject_overlong_wrong_prefix",
      "description": "overlong input (31 chars) whose leading slice is not the codec prefix is rejected at the prefix layer, not base32 — first-failing-layer rule applies even when the input also trips the length guard",
      "category": "wire",
      "operation": "canonicalize",
      "input": "org_000000000000000000000000000",
      "expected": { "ok": false, "layer": "prefix" }
    },
    {
      "name": "canonicalize_reject_overlong_right_prefix",
      "description": "overlong input (31 chars) whose leading slice IS the codec prefix still reports base32 — the prefix passed, so the oversized payload is the first failure",
      "category": "wire",
      "operation": "canonicalize",
      "input": "usr_000000000000000000000000000",
      "expected": { "ok": false, "layer": "base32" }
    },
    {
      "name": "canonicalize_alias_i_l_to_one",
      "description": "Crockford visual aliases i/I/l/L resolve to 1 before validation; scattered at payload positions 1, 9, 17, 25 so partial alias coverage (e.g. timestamp region only) fails",
      "category": "wire",
      "operation": "canonicalize",
      "input": "usr_i0000000I0000000l0000000L0",
      "expected": { "ok": true, "id": "usr_10000000100000001000000010" }
    }
  ]
}
