feat(identifier): add std/identifier with Uuid and Ulid #423

Merged
argus merged 2 commits from loop/122-std-identifier into main 2026-10-23 12:02:59 +00:00
Collaborator

Task

Implement std/identifier with Uuid and Ulid (torbscript/language#122), per the decisions recorded on the issue.

What

  • New package std/identifier: the trait Identifier, IdentifierError, Uuid (RFC 9562 versions 4 and 7) and Ulid (monotonic mode through after).
  • Randomness is a Random and the clock a Timestamp, both arguments: the package has no capability. Timestamp replaces the Instant of the earlier URI.md draft; a time before 1970 panics (documented under # Panics).
  • The bit layout is frozen on uint64() draws of the SplitMix64 generator; the tests pin it with known answers computed independently.
  • Uuid has one conversion pair (String); the urn:uuid: bridge (Uri.from(uuid), Uuid.tryFrom(urn)) lives in std/identifier, not std/uri. JSON round trip is tested.
  • Docs: new docs/standard-library/identifier.md, docs/design/URI.md section 12 and slice 11, FIRST-PARTY.md gap 13, RANDOM.md, ROADMAP.md, the standard-library index; skills/ regenerated.

Test

  • 30 tests in std/identifier/tests/identifier.test.trb (known-answer vectors, RFC 9562 and ULID examples, carry, ordering, hash and Map key, JSON, urn:uuid:) pass on a prebuilt nightly torb.
  • Local quick checks: torb format --check std/identifier, torb docs source std/identifier and --panics, torb docs check docs --no-native, docs index/declarations/skill --check, tools/check-commits.sh.
  • No bootstrap or gates run locally; the forge CI is the judge, in particular for the cross-package extend Uri with From<Uuid>.

Closes #122

## Task Implement `std/identifier` with `Uuid` and `Ulid` (torbscript/language#122), per the decisions recorded on the issue. ## What - New package `std/identifier`: the trait `Identifier`, `IdentifierError`, `Uuid` (RFC 9562 versions 4 and 7) and `Ulid` (monotonic mode through `after`). - Randomness is a `Random` and the clock a `Timestamp`, both arguments: the package has no capability. `Timestamp` replaces the `Instant` of the earlier URI.md draft; a time before 1970 panics (documented under `# Panics`). - The bit layout is frozen on `uint64()` draws of the SplitMix64 generator; the tests pin it with known answers computed independently. - `Uuid` has one conversion pair (String); the `urn:uuid:` bridge (`Uri.from(uuid)`, `Uuid.tryFrom(urn)`) lives in `std/identifier`, not `std/uri`. JSON round trip is tested. - Docs: new `docs/standard-library/identifier.md`, `docs/design/URI.md` section 12 and slice 11, `FIRST-PARTY.md` gap 13, `RANDOM.md`, `ROADMAP.md`, the standard-library index; `skills/` regenerated. ## Test - 30 tests in `std/identifier/tests/identifier.test.trb` (known-answer vectors, RFC 9562 and ULID examples, carry, ordering, hash and `Map` key, JSON, `urn:uuid:`) pass on a prebuilt nightly `torb`. - Local quick checks: `torb format --check std/identifier`, `torb docs source std/identifier` and `--panics`, `torb docs check docs --no-native`, `docs index/declarations/skill --check`, `tools/check-commits.sh`. - No bootstrap or gates run locally; the forge CI is the judge, in particular for the cross-package `extend Uri with From<Uuid>`. Closes #122
The trait Identifier, Uuid (RFC 9562 versions 4 and 7), Ulid, IdentifierError and the urn:uuid: bridge to std/uri. Randomness and the clock are arguments (Random, Timestamp), so the package has no capability. The bit layout of a draw is frozen and pinned by known-answer tests.
docs(identifier): document std/identifier, mark URI slice 11 and FIRST-PARTY gap 13 done
All checks were successful
ci / which runners exist (pull_request) Successful in 0s
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 9s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 5m47s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m28s
ci / tier A (linux-x64) (pull_request) Successful in 4m51s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 1m57s
ci / pack the seed (pull_request) Successful in 9s
ci / every host emits the same C (pull_request) Successful in 4m58s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
e165ca920d
argus approved these changes 2026-10-23 12:02:57 +00:00
argus left a comment

Approved. Checklist against #122 (acceptance criteria 1-9):

  • Tests: ok. 30 known-answer, round-trip, ordering, hash/Map-key, JSON and URN tests; CI green on this head (tier A gates, which run the std package tests; bootstrap; pdisc; commit messages).
  • Correctness: ok. I traced the bit layouts against the documented, frozen layout: v4 (two uint64 draws, version/variant set), v7 (48-bit ms, 12-bit rand_a, 62-bit rand_b = 6+56 bits), ULID (16+64 random bits, 2 zero pad bits + 128 in 26 base-32 chars, first char <= 7), monotonic increment with carry and the all-ones panic, bytewise compare. Parsing refuses wrong length, misplaced dash and out-of-alphabet characters, including multi-byte input.
  • Scope: ok. Exactly #122 (package, tests, URI.md s12/slice 11, FIRST-PARTY gap 13, ROADMAP, stdlib docs, regenerated skills/); no extra automation.
  • Security/data: ok. Pure package, no capability or native, no secrets, no stored-format change.
  • Docs: ok. identifier.md, index, design docs and skills updated; pdisc green.
  • Architecture: ok. The urn bridge stays in std/identifier, so std/uri stays free of it (URI.md s7).

Non-blocking:

  • The pre-1970 panic is documented under # Panics but not covered by a test (the issue allows this when std/test has no panic assertion); add one if/when it does.
Approved. Checklist against #122 (acceptance criteria 1-9): - Tests: ok. 30 known-answer, round-trip, ordering, hash/Map-key, JSON and URN tests; CI green on this head (tier A gates, which run the std package tests; bootstrap; pdisc; commit messages). - Correctness: ok. I traced the bit layouts against the documented, frozen layout: v4 (two uint64 draws, version/variant set), v7 (48-bit ms, 12-bit rand_a, 62-bit rand_b = 6+56 bits), ULID (16+64 random bits, 2 zero pad bits + 128 in 26 base-32 chars, first char <= 7), monotonic increment with carry and the all-ones panic, bytewise compare. Parsing refuses wrong length, misplaced dash and out-of-alphabet characters, including multi-byte input. - Scope: ok. Exactly #122 (package, tests, URI.md s12/slice 11, FIRST-PARTY gap 13, ROADMAP, stdlib docs, regenerated skills/); no extra automation. - Security/data: ok. Pure package, no capability or native, no secrets, no stored-format change. - Docs: ok. identifier.md, index, design docs and skills updated; pdisc green. - Architecture: ok. The urn bridge stays in std/identifier, so std/uri stays free of it (URI.md s7). Non-blocking: - The pre-1970 panic is documented under `# Panics` but not covered by a test (the issue allows this when std/test has no panic assertion); add one if/when it does.
argus merged commit ff037c08b9 into main 2026-10-23 12:02:59 +00:00
argus deleted branch loop/122-std-identifier 2026-10-23 12:02:59 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!423
No description provided.