From 033b5f415353f90b44a64c5eb3a8561bf8cf6207 Mon Sep 17 00:00:00 2001 From: Andrew Peris Date: Sat, 24 Oct 2026 11:32:22 -0400 Subject: [PATCH 1/2] Propose stable record ID contract with synthetic conformance cases --- CHANGELOG.md | 4 + CONSTITUTION_CONFORMANCE.md | 15 ++ rfcs/0009-stable-record-ids.md | 187 +++++++++++++++++++++ rfcs/0009-stable-record-ids/cases.json | 39 +++++ rfcs/0009-stable-record-ids/id.schema.json | 10 ++ specs/ids/README.md | 4 + tests/stable-record-ids.test.cjs | 62 +++++++ 7 files changed, 321 insertions(+) create mode 100644 rfcs/0009-stable-record-ids.md create mode 100644 rfcs/0009-stable-record-ids/cases.json create mode 100644 rfcs/0009-stable-record-ids/id.schema.json create mode 100644 tests/stable-record-ids.test.cjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 99e9b0f..0272d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ compatible, or editorial. ## Unreleased +- Propose stable record IDs 0.1.0 in Draft RFC 0009 (new additive family), + with synthetic syntax and inventory/reference conformance evidence. No + existing or released contract semantics change; adoption remains undecided. + - Clarified the unreleased Comic Manifest 1.0.0 candidate's (#95 prerequisite) detached approval time bounds: decision time is inclusive, expiry is exclusive at both action and scoped publication time. The test-only oracle preserves diff --git a/CONSTITUTION_CONFORMANCE.md b/CONSTITUTION_CONFORMANCE.md index 92cf7c7..2f1b017 100644 --- a/CONSTITUTION_CONFORMANCE.md +++ b/CONSTITUTION_CONFORMANCE.md @@ -1,5 +1,20 @@ # Constitution conformance record +## Stable record ID proposal — 2026-10-24 + +Owner and required decision reviewer: @andrewperis. Constitution 1.0.0 at +`a9cc8a503aa30e17820edc62ac95f7cbe10e0564`; assessed base +`ba64020042a8a7e4d4abaf3abc4e5fdfd489fea0` plus the RFC 0009 proposal diff. +Profile: ADR/RFC/stable specification. Status: proposed, pending owner and +affected consumer review; no acceptance or broader conformance completion claim. +Evidence: RFC 0009, proposal-local ID schema, synthetic inventory/reference cases +and `tests/stable-record-ids.test.cjs`. Scope: technical record identity only; +released contracts, source provenance semantics and immutable artifacts unchanged. +No exception requested. Inventory ownership, reservation workflow and any legacy +scheme compatibility must be decided before adoption. Review on format, identity, +classification, issuance, reference or consumer changes and before acceptance. +Private allocation, creative content, production validation and release are excluded. + ## Studio #86 release preparation — 2026-09-16 Owner: @andrewperis. Constitution 1.0.0 at diff --git a/rfcs/0009-stable-record-ids.md b/rfcs/0009-stable-record-ids.md new file mode 100644 index 0000000..4bc0c7f --- /dev/null +++ b/rfcs/0009-stable-record-ids.md @@ -0,0 +1,187 @@ +# RFC 0009: Stable record IDs + +- Status: Draft — proposal only; merge does not itself accept this contract +- Authors: @andrewperis +- Created: 2026-10-24 +- Contract families: identifiers +- Compatibility: New additive proposed contract, version 0.1.0; no stable predecessor +- Supersedes: None +- Superseded by: None +- Constitution version: 1.0.0 +- Constitution tag: `constitution/v1.0.0` +- Constitution commit: `a9cc8a503aa30e17820edc62ac95f7cbe10e0564` +- Applicable checklist profile: ADR, RFC, and stable specification +- Conformance evidence: [synthetic cases](0009-stable-record-ids/cases.json), [tests](../tests/stable-record-ids.test.cjs) +- Decision owner and required A4 reviewers: @andrewperis; Codex and affected consumer maintainers + +## Summary + +Propose persistent identity for character, location, and relationship records. +An ID names the same logical record across edits, display-name changes, and +repository moves. It does not identify exact content bytes or confer authority. +The requirements below describe the proposed 0.1.0 contract, not an accepted +standard, production allocation, or publication approval. + +## Motivation and existing-contract inventory + +[Identifiers](../specs/ids/README.md) and [taxonomies](../specs/taxonomies/README.md) +currently reserve subject areas without defining a record scheme. +[Context Package v1 sources](../specs/context-packages/context-package-v1.md#sources) +use `source_id`, opaque `version`, classification and evidence for prepared +provenance. Its schema's `safeId` permits 1–200 ASCII characters, beginning with +an alphanumeric and continuing with alphanumerics, dot, underscore, colon or +hyphen. [Context Builder](../specs/context-builder/context-builder-v1.md) adds +source-selection semantics, not a character/location/relationship registry. +Existing prompt, package, schema, production and artifact identities retain +their own meanings and namespaces. + +Reuse that safe ASCII repertoire, exact string comparison, and independent +version/content identity rather than add a resolver protocol. Those existing +schemes do not specify persistent record issuance, collision or rename rules; +therefore a small separate proposal is necessary. No source ID is converted, +reserved, replaced or reinterpreted by this RFC. + +## Specification (proposed) + +### Format and scope + +A record ID MUST match exactly: + +```text +^record\.(character|location|relationship)\.[0-9a-f]{32}$ +``` + +The suffix is 16 random bytes encoded as 32 lowercase hexadecimal characters. +The prefix `record` and three kind tokens are proposed only. This RFC neither +reserves nor changes an existing released namespace. IDs are opaque: names, +slugs, file paths, chronology, ownership and classification MUST NOT be encoded. +Consumers MUST reject malformed IDs rather than trim, case-fold, normalize or +repair them. Equality is exact ASCII string equality. The kind is immutable; +the three tokens are record categories, not a world-building taxonomy. + +The full string MUST be unique across the Studio record inventory, including +retired IDs and copies in every repository. A copied record retains its ID; +a genuinely distinct record receives a new ID. A foreign inventory import MUST +be checked for collisions before attachment, not silently treated as the same +record because its ID matches. Uniqueness is a semantic requirement; JSON Schema +alone cannot establish it. + +### Issuance and collisions + +Only an authorized record owner MAY issue an ID. The issuer MUST use a +cryptographically secure random generator, check the complete candidate against +the authoritative inventory of issued and retired IDs, and atomically reserve +it with its kind before committing a new record. A reservation collision MUST +cause fresh generation and another reservation attempt. If the inventory or +atomic reservation is unavailable, issuance MUST fail without publishing a +record. Offline candidates are unissued until reservation succeeds. Consumers +MUST NOT mint IDs merely because they encounter a missing reference. + +The inventory may be maintained by an existing transactional store or serialized +owner-reviewed allocation process; no new service or framework is prescribed. +The accountable inventory owner and cross-repository reservation workflow must +be selected before adoption. Randomness reduces collision probability; it does +not replace a uniqueness check. Retired IDs remain reserved forever. + +A conflict discovered after issuance MUST stop import/update and be escalated +to the accountable owner. Do not silently overwrite, merge or renumber an +already referenced record. An approved remediation must preserve an explicit +old-to-new mapping scoped to the conflicting origin and update affected +references together; an ambiguous old ID MUST NOT resolve automatically. + +### Immutability, names and references + +An issued ID MUST NOT change when display name, alias, content, path, repository, +visibility or revision changes. Names and aliases are mutable metadata, never +identity or implicit redirects. An ID MUST NOT be reassigned after deletion, +retirement, split or merge. A change of record kind creates a new record with +an explicit migration mapping; split/merge decisions similarly retain retired +IDs and explicit mappings rather than reuse identity. Mappings are owner +reviewed and do not make historical references name a different entity. + +A record reference carries the full ID. Relationships have their own persistent +ID and explicit endpoint IDs; they MUST NOT derive identity from endpoint order, +names or a hash of the current relationship text. Endpoints in the minimal +examples are characters or locations. This proposal does not define predicates, +cardinality, directionality or a relationship payload schema. + +An authorized validator MUST check references against its complete permitted +inventory, including record kind and retirement state. Missing, conflicting, +wrong-kind or retired references MUST fail current-use validation; a validator +with an incomplete inventory MUST report unresolved and MUST NOT claim success. +Historical references MAY retain retired IDs as historical facts. A bare ID +never pins a revision: workflows needing exact content MUST also use their +existing version/artifact digest contract. Access checks precede resolution; +IDs do not grant retrieval, publication, approval, truth or canon status. + +Context `source_id` remains provenance identity. An authorized integration MAY +maintain a separate explicit mapping between a source ID/version and record +ID/revision. It MUST NOT assume equality, one-to-one cardinality or automatic +conversion. Do not add record fields to existing closed context schemas. + +## Conformance examples + +All values in the [cases](0009-stable-record-ids/cases.json) are fabricated. +The [proposal-local schema](0009-stable-record-ids/id.schema.json) validates only +ID strings; it intentionally has no canonical `$id` and is not a released schema. +The cases exercise syntax, inventory collisions, rename continuity, relationship +references and retirement. The test oracle is conformance evidence, not a +production issuer or a claim that authorization/randomness were verified. +Run `node --test tests/stable-record-ids.test.cjs` or `npm test`. + +## Compatibility and migration + +This introduces proposed 0.1.0 semantics only. Released schemas, bundles, tags, +source IDs and artifact namespaces remain unchanged. No consumer adopts it by +merging this proposal. Candidate consumers are record storage/validation and +reference-producing tools; Context Builder/Prompt SDK would require a separately +reviewed integration only if they consume persistent record references. +@andrewperis owns the decision; affected consumer maintainers must confirm the +inventory and reservation process before acceptance. + +Before adoption: inventory existing schemes and references without disclosing +protected records; prefer preserving compatible issued identities over blanket +renumbering; document explicit mappings for incompatible legacy IDs; validate +references and collisions; obtain owner/consumer review; then publish the +accepted specification, canonical versioned schema and immutable release under +[versioning policy](../docs/versioning.md). No existing consumer migration or +dated support window is activated by this proposal. Adoption must set a dated +rollout/rollback window and preserve old references during that window. A rollback +must retain reservations and mappings so issued IDs are never recycled. + +## Security and privacy + +Even random IDs can correlate private activity. Public material MUST use wholly +synthetic IDs and examples; do not copy private IDs, names, paths, links, excerpts +or mappings into public fixtures or logs. Inventory access and error detail must +respect classification. An ID's shape proves neither ownership nor permission. +No private record allocation or private validator work is part of this proposal. + +## Rights, provenance, accessibility, and portability + +Examples and tests are original synthetic technical material under the repository +license. ASCII IDs and JSON work without a provider, network resolver or vendor +runtime. Interfaces should present readable labels alongside IDs; labels do not +replace exact references. Existing provenance, rights and publication reviews +remain required. No capability extension or constitutional exception is proposed. +This RFC does not assess private content or complete a broader conformance item. + +## Alternatives considered + +- Reuse context source IDs: preserves syntax but conflates prepared provenance + with a persistent record and leaves issuance/rename semantics unspecified. +- Derive IDs from names, paths or content hashes: exposes information and changes + identity on ordinary edits or moves. +- Sequential IDs: require coordinated enumeration and reveal allocation order; + random suffixes keep the same explicit uniqueness check without that leakage. +- Introduce a resolver/registry service or full record taxonomy: unnecessary for + this narrow contract; implementation and payload semantics remain separate. + +## Implementation plan and decisions needed + +Review format, uniqueness scope, retirement/reference rules and inventory owner. +Confirm whether any existing issued scheme must be retained before accepting. +Only after explicit acceptance should maintainers promote the proposal, choose +its stable version, implement issuance in the owning consumer, and plan release. +The PR should be ready for review while the RFC remains Draft. Do not merge, +release, tag, allocate real IDs or change public canon as part of this task. diff --git a/rfcs/0009-stable-record-ids/cases.json b/rfcs/0009-stable-record-ids/cases.json new file mode 100644 index 0000000..f164d8f --- /dev/null +++ b/rfcs/0009-stable-record-ids/cases.json @@ -0,0 +1,39 @@ +{ + "valid": [ + "record.character.11111111111111111111111111111111", + "record.location.22222222222222222222222222222222", + "record.relationship.33333333333333333333333333333333" + ], + "invalid": [ + "source.synthetic-1", + "RECORD.CHARACTER.11111111111111111111111111111111", + "record.character.11111111111111111111111111111111\n", + " record.character.11111111111111111111111111111111", + "record.character.1111111111111111111111111111111", + "record.character.111111111111111111111111111111110", + "record.asset.11111111111111111111111111111111", + "record.character.gggg1111111111111111111111111111" + ], + "records": [ + { + "id": "record.character.11111111111111111111111111111111", + "name": "Example Character" + }, + { + "id": "record.location.22222222222222222222222222222222", + "name": "Example Location" + }, + { + "id": "record.relationship.33333333333333333333333333333333", + "endpoints": [ + "record.character.11111111111111111111111111111111", + "record.location.22222222222222222222222222222222" + ] + } + ], + "rename": { + "id": "record.character.11111111111111111111111111111111", + "name": "Renamed Character" + }, + "missing": "record.character.44444444444444444444444444444444" +} diff --git a/rfcs/0009-stable-record-ids/id.schema.json b/rfcs/0009-stable-record-ids/id.schema.json new file mode 100644 index 0000000..9cd8bbd --- /dev/null +++ b/rfcs/0009-stable-record-ids/id.schema.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Proposed stable record ID 0.1.0 (RFC 0009 only)", + "type": "string", + "pattern": "^record\\.(character|location|relationship)\\.[0-9a-f]{32}$", + "maxLength": 52, + "not": { + "pattern": "[^a-z0-9.]" + } +} diff --git a/specs/ids/README.md b/specs/ids/README.md index e02437a..76226e0 100644 --- a/specs/ids/README.md +++ b/specs/ids/README.md @@ -2,3 +2,7 @@ Stable identifier formats, namespaces, uniqueness rules, normalization, and human-readable naming conventions belong here. + +[RFC 0009](../../rfcs/0009-stable-record-ids.md) proposes stable record IDs +for characters, locations and relationships. It is Draft, not an accepted +contract or authority to allocate production IDs. diff --git a/tests/stable-record-ids.test.cjs b/tests/stable-record-ids.test.cjs new file mode 100644 index 0000000..f0ba15a --- /dev/null +++ b/tests/stable-record-ids.test.cjs @@ -0,0 +1,62 @@ +const { readFileSync } = require('node:fs'); +const { resolve } = require('node:path'); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const Ajv = require('ajv/dist/2020'); +const read = p => JSON.parse(readFileSync(resolve(__dirname, '..', p))); +const schema = read('rfcs/0009-stable-record-ids/id.schema.json'); +const cases = read('rfcs/0009-stable-record-ids/cases.json'); +const validate = new Ajv({ strict: true }).compile(schema); +// Test-only inventory oracle; no allocation, storage, access or randomness implementation. +function inventory(records, retired = []) { + const ids = new Map(); + for (const record of records) { + assert.ok(validate(record.id), 'malformed ID'); + assert.ok(!ids.has(record.id), 'duplicate ID'); + ids.set(record.id, record); + } + for (const record of records) { + assert.ok(!retired.includes(record.id), 'retired record in current use'); + if (record.id.startsWith('record.relationship.')) { + for (const id of record.endpoints) { + assert.ok(validate(id), 'malformed endpoint'); + assert.ok(!id.startsWith('record.relationship.'), 'wrong endpoint kind'); + assert.ok(ids.has(id), 'unresolved endpoint'); + assert.ok(!retired.includes(id), 'retired endpoint'); + } + } + } + return ids; +} +test('proposed ID schema accepts only exact canonical strings', () => { + for (const id of cases.valid) assert.equal(validate(id), true, id); + for (const id of cases.invalid) assert.equal(validate(id), false, JSON.stringify(id)); +}); +test('proposed IDs fit existing context safeId syntax without equating identities', () => { + const context = read('schemas/json/context-packages/v1/context-package.schema.json'); + const safe = new Ajv({ strict: true }).compile(context.$defs.safeId); + for (const id of cases.valid) assert.equal(safe(id), true); + assert.equal(validate('source.synthetic-1'), false); +}); +test('synthetic inventory and relationship references resolve', () => { + assert.equal(inventory(cases.records).size, 3); +}); +test('duplicate imports and retired reservations cannot be used as new records', () => { + assert.throws(() => inventory([...cases.records, { ...cases.records[0] }]), /duplicate/); + assert.throws(() => inventory(cases.records, [cases.records[0].id]), /retired/); +}); +test('renaming preserves ID and references', () => { + const records = structuredClone(cases.records); + records[0] = cases.rename; + const ids = inventory(records); + assert.equal(ids.get(records[2].endpoints[0]).name, 'Renamed Character'); + assert.equal(ids.get(cases.records[0].id).id, cases.records[0].id); +}); +test('missing and wrong-kind endpoints fail; incomplete inventories cannot pass', () => { + for (const endpoint of [cases.missing, cases.records[2].id, 'Example Character']) { + const records = structuredClone(cases.records); + records[2].endpoints[0] = endpoint; + assert.throws(() => inventory(records), /endpoint/); + } + assert.throws(() => inventory(cases.records.slice(1)), /unresolved/); +}); From 964a7c772d8f7c26586861748bc1307231ddbfd5 Mon Sep 17 00:00:00 2001 From: Andrew Peris Date: Sat, 24 Oct 2026 12:07:37 -0400 Subject: [PATCH 2/2] Base proposed record identity profile on RFC 9562 UUIDv4 --- CHANGELOG.md | 4 +- CONSTITUTION_CONFORMANCE.md | 3 +- rfcs/0009-stable-record-ids.md | 72 ++++++-- rfcs/0009-stable-record-ids/cases.json | 200 +++++++++++++++++++-- rfcs/0009-stable-record-ids/id.schema.json | 8 +- specs/ids/README.md | 4 +- tests/stable-record-ids.test.cjs | 24 ++- 7 files changed, 274 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0272d4f..7b1b249 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ compatible, or editorial. ## Unreleased - Propose stable record IDs 0.1.0 in Draft RFC 0009 (new additive family), - with synthetic syntax and inventory/reference conformance evidence. No + built on RFC 9562 UUIDv4 with standard hyphenated lowercase suffixes, pinpoint + standards references, and synthetic syntax/version/variant and inventory/reference + conformance evidence. Prefix and identity lifecycle rules remain application policy. No existing or released contract semantics change; adoption remains undecided. - Clarified the unreleased Comic Manifest 1.0.0 candidate's (#95 prerequisite) diff --git a/CONSTITUTION_CONFORMANCE.md b/CONSTITUTION_CONFORMANCE.md index 2f1b017..41c1301 100644 --- a/CONSTITUTION_CONFORMANCE.md +++ b/CONSTITUTION_CONFORMANCE.md @@ -8,7 +8,8 @@ Owner and required decision reviewer: @andrewperis. Constitution 1.0.0 at Profile: ADR/RFC/stable specification. Status: proposed, pending owner and affected consumer review; no acceptance or broader conformance completion claim. Evidence: RFC 0009, proposal-local ID schema, synthetic inventory/reference cases -and `tests/stable-record-ids.test.cjs`. Scope: technical record identity only; +and `tests/stable-record-ids.test.cjs`. Scope: technical record identity +application profile over RFC 9562 UUIDv4 only; released contracts, source provenance semantics and immutable artifacts unchanged. No exception requested. Inventory ownership, reservation workflow and any legacy scheme compatibility must be decided before adoption. Review on format, identity, diff --git a/rfcs/0009-stable-record-ids.md b/rfcs/0009-stable-record-ids.md index 4bc0c7f..995dd34 100644 --- a/rfcs/0009-stable-record-ids.md +++ b/rfcs/0009-stable-record-ids.md @@ -16,11 +16,16 @@ ## Summary -Propose persistent identity for character, location, and relationship records. +Propose a reusable application-level naming and identity profile built on +[RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.html), using UUIDv4 for +character, location, and relationship records. An ID names the same logical record across edits, display-name changes, and repository moves. It does not identify exact content bytes or confer authority. The requirements below describe the proposed 0.1.0 contract, not an accepted -standard, production allocation, or publication approval. +standard, production allocation, or publication approval. This repository RFC +is a local proposal, not an IETF submission, endorsement or standards-track +document. A broader proposal could be considered later through a separate +review and submission decision; no external submission is part of this work. ## Motivation and existing-contract inventory @@ -30,8 +35,13 @@ currently reserve subject areas without defining a record scheme. use `source_id`, opaque `version`, classification and evidence for prepared provenance. Its schema's `safeId` permits 1–200 ASCII characters, beginning with an alphanumeric and continuing with alphanumerics, dot, underscore, colon or -hyphen. [Context Builder](../specs/context-builder/context-builder-v1.md) adds -source-selection semantics, not a character/location/relationship registry. +hyphen. [Context Builder](../specs/context-builder/context-builder-v1.md#explicit-build-request) +already requires opaque UUIDv4 URNs (`urn:uuid:...`) for source and other +preparation identities. Its schema enforces a lowercase, hyphenated v4 layout. +That existing scheme is viable for UUID generation and opacity, but its +source-selection/provenance semantics do not establish persistent record +ownership, rename or retirement rules. This profile reuses UUIDv4 rather than +invent a random-number encoding; it does not alter those URNs or their meanings. Existing prompt, package, schema, production and artifact identities retain their own meanings and namespaces. @@ -43,20 +53,48 @@ reserved, replaced or reinterpreted by this RFC. ## Specification (proposed) +### Standards basis and application rules + +The UUID suffix follows these pinpoint references to the official RFC: + +| Basis | Rule used by this profile | +| --- | --- | +| [RFC 9562 section 4](https://www.rfc-editor.org/rfc/rfc9562.html#section-4) | UUID text uses hexadecimal groups of 8-4-4-4-12 digits separated by hyphens; the RFC permits upper, lower or mixed case. | +| [Section 4.1](https://www.rfc-editor.org/rfc/rfc9562.html#section-4.1) | Variant bits are `10`, giving the fourth group's initial digit `8`, `9`, `a` or `b` in lowercase text. | +| [Section 5.4](https://www.rfc-editor.org/rfc/rfc9562.html#section-5.4) | UUIDv4 has 122 random bits plus four version bits set to `0100` and two variant bits set to `10`; the third group begins with `4`. | +| [Section 6.9](https://www.rfc-editor.org/rfc/rfc9562.html#section-6.9) | Recommends a cryptographically secure pseudorandom generator and suitable generator-state handling, including reseeding on process forks. This profile requires a suitable CSPRNG and fails issuance if unavailable. | + +These references define the UUID building block. The typed prefix, lowercase-only +wire convention, exact comparison/no input repair, inventory ownership and atomic +reservation, permanence, reference and record-version rules below are **our +application requirements**, not additional requirements imposed by RFC 9562. +UUID generation itself needs no central registry; our reservation requirement +serves the application inventory. This is not a new UUID version or UUID URN. + ### Format and scope A record ID MUST match exactly: ```text -^record\.(character|location|relationship)\.[0-9a-f]{32}$ +^record\.(character|location|relationship)\.[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ ``` -The suffix is 16 random bytes encoded as 32 lowercase hexadecimal characters. +The suffix MUST be a properly generated RFC 9562 UUIDv4 in the standard +hyphenated text form, emitted in lowercase by our application convention. +Producers MUST use conforming UUIDv4 generation per section 5.4, including the +required version/variant bits. Merely inserting hyphens into arbitrary random +bytes is insufficient; a name/content hash with overwritten version bits is +not UUIDv4 generation. Schema validation can check syntax, version and variant, +but cannot establish random generation. The prefix `record` and three kind tokens are proposed only. This RFC neither reserves nor changes an existing released namespace. IDs are opaque: names, slugs, file paths, chronology, ownership and classification MUST NOT be encoded. -Consumers MUST reject malformed IDs rather than trim, case-fold, normalize or -repair them. Equality is exact ASCII string equality. The kind is immutable; +Consumers MUST reject malformed or noncanonical profile IDs rather than trim, +case-fold, normalize or repair them. Lowercase is the producer's serialization +policy, not permission for consumers to rewrite incoming IDs. Uppercase UUIDs +are allowed by RFC 9562 but rejected by this narrower profile. Bare UUIDs, +`urn:uuid:` forms, braces, unhyphenated text and non-v4 values are also outside +this profile. Equality is exact ASCII string equality. The kind is immutable; the three tokens are record categories, not a world-building taxonomy. The full string MUST be unique across the Studio record inventory, including @@ -69,8 +107,8 @@ alone cannot establish it. ### Issuance and collisions Only an authorized record owner MAY issue an ID. The issuer MUST use a -cryptographically secure random generator, check the complete candidate against -the authoritative inventory of issued and retired IDs, and atomically reserve +UUIDv4 generator backed by a CSPRNG as required by this profile, check the +complete candidate against the authoritative inventory of issued and retired IDs, and atomically reserve it with its kind before committing a new record. A reservation collision MUST cause fresh generation and another reservation attempt. If the inventory or atomic reservation is unavailable, issuance MUST fail without publishing a @@ -124,8 +162,10 @@ conversion. Do not add record fields to existing closed context schemas. All values in the [cases](0009-stable-record-ids/cases.json) are fabricated. The [proposal-local schema](0009-stable-record-ids/id.schema.json) validates only ID strings; it intentionally has no canonical `$id` and is not a released schema. -The cases exercise syntax, inventory collisions, rename continuity, relationship -references and retirement. The test oracle is conformance evidence, not a +The UUIDv4 fixtures were generated solely for synthetic tests with Python +`uuid.uuid4()`; they are not issued or reserved record IDs. The cases exercise +text syntax, version/variant rejection, inventory collisions, rename continuity, +relationship references and retirement. The test oracle is conformance evidence, not a production issuer or a claim that authorization/randomness were verified. Run `node --test tests/stable-record-ids.test.cjs` or `npm test`. @@ -173,13 +213,17 @@ This RFC does not assess private content or complete a broader conformance item. - Derive IDs from names, paths or content hashes: exposes information and changes identity on ordinary edits or moves. - Sequential IDs: require coordinated enumeration and reveal allocation order; - random suffixes keep the same explicit uniqueness check without that leakage. + UUIDv4 suffixes keep the same explicit uniqueness check without that leakage. +- A custom 32-hex random suffix: superseded in this proposal by standard + hyphenated UUIDv4 with explicit version and variant, for interoperability. - Introduce a resolver/registry service or full record taxonomy: unnecessary for this narrow contract; implementation and payload semantics remain separate. ## Implementation plan and decisions needed -Review format, uniqueness scope, retirement/reference rules and inventory owner. +Review the application profile, uniqueness scope, retirement/reference rules +and inventory owner. UUIDv4 is the proposed standard building block; application +adoption and any future broader RFC remain separate decisions. Confirm whether any existing issued scheme must be retained before accepting. Only after explicit acceptance should maintainers promote the proposal, choose its stable version, implement issuance in the owning consumer, and plan release. diff --git a/rfcs/0009-stable-record-ids/cases.json b/rfcs/0009-stable-record-ids/cases.json index f164d8f..9634902 100644 --- a/rfcs/0009-stable-record-ids/cases.json +++ b/rfcs/0009-stable-record-ids/cases.json @@ -1,39 +1,203 @@ { "valid": [ - "record.character.11111111111111111111111111111111", - "record.location.22222222222222222222222222222222", - "record.relationship.33333333333333333333333333333333" + "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b", + "record.location.c7b9fa21-6342-4701-ae20-d0e299231239", + "record.relationship.7f157e6c-8056-4ca4-87d6-72aeca26ad8e" ], "invalid": [ - "source.synthetic-1", - "RECORD.CHARACTER.11111111111111111111111111111111", - "record.character.11111111111111111111111111111111\n", - " record.character.11111111111111111111111111111111", - "record.character.1111111111111111111111111111111", - "record.character.111111111111111111111111111111110", - "record.asset.11111111111111111111111111111111", - "record.character.gggg1111111111111111111111111111" + { + "name": "context source identity is not a record ID", + "id": "urn:uuid:811bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "bare UUID lacks typed prefix", + "id": "811bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "uppercase suffix is RFC-valid but outside this profile", + "id": "record.character.811BF47E-B3D6-4815-A3A3-B6C39C886F9B" + }, + { + "name": "mixed case suffix is outside this profile", + "id": "record.character.811bf47e-b3d6-4815-A3A3-B6C39C886F9B" + }, + { + "name": "trailing newline", + "id": "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b\n" + }, + { + "name": "leading whitespace", + "id": " record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "truncated suffix", + "id": "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9" + }, + { + "name": "extra digit", + "id": "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b0" + }, + { + "name": "unknown record kind", + "id": "record.asset.811bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "nonhex suffix", + "id": "record.character.g11bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "legacy unhyphenated encoding", + "id": "record.character.811bf47eb3d64815a3a3b6c39c886f9b" + }, + { + "name": "colon separators", + "id": "record.character.811bf47e:b3d6:4815:a3a3:b6c39c886f9b" + }, + { + "name": "braced suffix", + "id": "record.character.{811bf47e-b3d6-4815-a3a3-b6c39c886f9b}" + }, + { + "name": "URN suffix under typed prefix", + "id": "record.character.urn:uuid:811bf47e-b3d6-4815-a3a3-b6c39c886f9b" + }, + { + "name": "nil UUID", + "id": "record.character.00000000-0000-0000-0000-000000000000" + }, + { + "name": "max UUID", + "id": "record.character.ffffffff-ffff-ffff-ffff-ffffffffffff" + }, + { + "name": "version nibble 0 is not v4", + "id": "record.character.811bf47e-b3d6-0815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 1 is not v4", + "id": "record.character.811bf47e-b3d6-1815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 2 is not v4", + "id": "record.character.811bf47e-b3d6-2815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 3 is not v4", + "id": "record.character.811bf47e-b3d6-3815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 5 is not v4", + "id": "record.character.811bf47e-b3d6-5815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 6 is not v4", + "id": "record.character.811bf47e-b3d6-6815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 7 is not v4", + "id": "record.character.811bf47e-b3d6-7815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 8 is not v4", + "id": "record.character.811bf47e-b3d6-8815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble 9 is not v4", + "id": "record.character.811bf47e-b3d6-9815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble a is not v4", + "id": "record.character.811bf47e-b3d6-a815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble b is not v4", + "id": "record.character.811bf47e-b3d6-b815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble c is not v4", + "id": "record.character.811bf47e-b3d6-c815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble d is not v4", + "id": "record.character.811bf47e-b3d6-d815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble e is not v4", + "id": "record.character.811bf47e-b3d6-e815-a3a3-b6c39c886f9b" + }, + { + "name": "version nibble f is not v4", + "id": "record.character.811bf47e-b3d6-f815-a3a3-b6c39c886f9b" + }, + { + "name": "variant nibble 0 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-03a3-b6c39c886f9b" + }, + { + "name": "variant nibble 1 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-13a3-b6c39c886f9b" + }, + { + "name": "variant nibble 2 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-23a3-b6c39c886f9b" + }, + { + "name": "variant nibble 3 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-33a3-b6c39c886f9b" + }, + { + "name": "variant nibble 4 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-43a3-b6c39c886f9b" + }, + { + "name": "variant nibble 5 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-53a3-b6c39c886f9b" + }, + { + "name": "variant nibble 6 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-63a3-b6c39c886f9b" + }, + { + "name": "variant nibble 7 is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-73a3-b6c39c886f9b" + }, + { + "name": "variant nibble c is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-c3a3-b6c39c886f9b" + }, + { + "name": "variant nibble d is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-d3a3-b6c39c886f9b" + }, + { + "name": "variant nibble e is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-e3a3-b6c39c886f9b" + }, + { + "name": "variant nibble f is not 10xx", + "id": "record.character.811bf47e-b3d6-4815-f3a3-b6c39c886f9b" + } ], "records": [ { - "id": "record.character.11111111111111111111111111111111", + "id": "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b", "name": "Example Character" }, { - "id": "record.location.22222222222222222222222222222222", + "id": "record.location.c7b9fa21-6342-4701-ae20-d0e299231239", "name": "Example Location" }, { - "id": "record.relationship.33333333333333333333333333333333", + "id": "record.relationship.7f157e6c-8056-4ca4-87d6-72aeca26ad8e", "endpoints": [ - "record.character.11111111111111111111111111111111", - "record.location.22222222222222222222222222222222" + "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b", + "record.location.c7b9fa21-6342-4701-ae20-d0e299231239" ] } ], "rename": { - "id": "record.character.11111111111111111111111111111111", + "id": "record.character.811bf47e-b3d6-4815-a3a3-b6c39c886f9b", "name": "Renamed Character" }, - "missing": "record.character.44444444444444444444444444444444" + "missing": "record.character.bd89b679-d865-4645-bdb1-5bbc7509dfcb" } diff --git a/rfcs/0009-stable-record-ids/id.schema.json b/rfcs/0009-stable-record-ids/id.schema.json index 9cd8bbd..dfe6a93 100644 --- a/rfcs/0009-stable-record-ids/id.schema.json +++ b/rfcs/0009-stable-record-ids/id.schema.json @@ -1,10 +1,10 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Proposed stable record ID 0.1.0 (RFC 0009 only)", + "title": "Proposed UUIDv4 record identity profile 0.1.0 (RFC 0009 only)", "type": "string", - "pattern": "^record\\.(character|location|relationship)\\.[0-9a-f]{32}$", - "maxLength": 52, + "pattern": "^record\\.(character|location|relationship)\\.[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", + "maxLength": 56, "not": { - "pattern": "[^a-z0-9.]" + "pattern": "[^a-z0-9.\\-]" } } diff --git a/specs/ids/README.md b/specs/ids/README.md index 76226e0..c28c911 100644 --- a/specs/ids/README.md +++ b/specs/ids/README.md @@ -3,6 +3,6 @@ Stable identifier formats, namespaces, uniqueness rules, normalization, and human-readable naming conventions belong here. -[RFC 0009](../../rfcs/0009-stable-record-ids.md) proposes stable record IDs -for characters, locations and relationships. It is Draft, not an accepted +[RFC 0009](../../rfcs/0009-stable-record-ids.md) proposes a UUIDv4 application profile for +stable record IDs for characters, locations and relationships. It is Draft, not an accepted contract or authority to allocate production IDs. diff --git a/tests/stable-record-ids.test.cjs b/tests/stable-record-ids.test.cjs index f0ba15a..c6fde53 100644 --- a/tests/stable-record-ids.test.cjs +++ b/tests/stable-record-ids.test.cjs @@ -30,7 +30,7 @@ function inventory(records, retired = []) { } test('proposed ID schema accepts only exact canonical strings', () => { for (const id of cases.valid) assert.equal(validate(id), true, id); - for (const id of cases.invalid) assert.equal(validate(id), false, JSON.stringify(id)); + for (const { name, id } of cases.invalid) assert.equal(validate(id), false, name); }); test('proposed IDs fit existing context safeId syntax without equating identities', () => { const context = read('schemas/json/context-packages/v1/context-package.schema.json'); @@ -60,3 +60,25 @@ test('missing and wrong-kind endpoints fail; incomplete inventories cannot pass' } assert.throws(() => inventory(cases.records.slice(1)), /unresolved/); }); + +test('all RFC 9562 variant 10xx nibbles pass the lowercase v4 profile', () => { + const [prefix, kind, uuid] = cases.valid[0].split('.'); + for (const variant of '89ab') { + assert.equal(validate(`${prefix}.${kind}.${uuid.slice(0, 19)}${variant}${uuid.slice(20)}`), true); + } +}); +test('synthetic UUIDv4 suffixes have the standard layout without changing context URNs', () => { + const { randomUUID } = require('node:crypto'); + // Ephemeral synthetic sample only: validates generator/profile integration, not entropy quality. + assert.equal(validate(`record.character.${randomUUID()}`), true); + const context = read('schemas/json/context-builder/v1/context-builder.schema.json'); + const validateContextId = new Ajv({ strict: true }).compile(context.$defs.opaque); + for (const id of cases.valid) { + const uuid = id.split('.').at(-1); + assert.equal(uuid.length, 36); + assert.equal(uuid[14], '4'); + assert.ok('89ab'.includes(uuid[19])); + assert.equal(validateContextId(`urn:uuid:${uuid}`), true); + assert.equal(validateContextId(id), false); + } +});