Skip to content

Commit d16ebc4

Browse files
committed
docs: keep scoped resource IDs string-valued
## Summary ### Why? Resource identity should stay flexible at storage and API boundaries even when the current allocator produces sequential numbers. ### What? Define generated IDs as canonical decimal strings, keep resource and reference columns as VARCHAR, and limit integer storage to counter high-water marks.
1 parent 9a95b6e commit d16ebc4

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎doc/rfc/scoped-resource-ids.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ Proposed.
66

77
## Decision
88

9-
A generated resource ID is the positive `int64` returned by a durable counter scoped to `(owner domain, queue, resource kind)`.
9+
A generated resource ID is the canonical decimal string for a positive value returned by a durable counter scoped to `(owner domain, queue, resource kind)`.
1010

1111
| Resource | Current ID | Proposed ID | Complete identity |
1212
|---|---:|---:|---|
13-
| SubmitQueue request | `demo-queue/42` | `42` | `(submitqueue, demo-queue, request, 42)` |
14-
| SubmitQueue batch | `demo-queue/batch/7` | `7` | `(submitqueue, demo-queue, batch, 7)` |
15-
| Stovepipe request | `request/monorepo/main/42` | `42` | `(stovepipe, monorepo/main, request, 42)` |
13+
| SubmitQueue request | `demo-queue/42` | `"42"` | `(submitqueue, demo-queue, request, "42")` |
14+
| SubmitQueue batch | `demo-queue/batch/7` | `"7"` | `(submitqueue, demo-queue, batch, "7")` |
15+
| Stovepipe request | `request/monorepo/main/42` | `"42"` | `(stovepipe, monorepo/main, request, "42")` |
1616

17-
The numeric ID is unique only within its scope. The same value may appear in another queue, resource kind, or domain. APIs and messages therefore carry the queue separately; their typed field or message type supplies the resource kind.
17+
The decimal ID is unique only within its scope. The same value may appear in another queue, resource kind, or domain. APIs and messages therefore carry the queue separately; their typed field or message type supplies the resource kind.
1818

1919
Do not embed scope into the ID. Forms such as `demo-queue/42`, `demo-queue/batch/7`, `request.42`, and ARN-like resource names are not stored or accepted as IDs.
2020

@@ -40,14 +40,14 @@ The counter contract requires an atomic durable increment, not MySQL specificall
4040

4141
## Storage and contracts
4242

43-
Resource tables store the numeric value directly. Queue remains the leading key:
43+
Resource tables keep IDs as strings. Queue remains the leading key:
4444

4545
```text
46-
request(queue, id BIGINT, ...) PRIMARY KEY (queue, id)
47-
batch(queue, id BIGINT, ...) PRIMARY KEY (queue, id)
46+
request(queue, id VARCHAR(...), ...) PRIMARY KEY (queue, id)
47+
batch(queue, id VARCHAR(...), ...) PRIMARY KEY (queue, id)
4848
```
4949

50-
Reference columns use the same numeric type. Domain entities use distinct named types such as `RequestID` and `BatchID`, and protobuf resource fields use `int64`.
50+
Reference columns use the same string type. Domain entities may use distinct named string types such as `RequestID` and `BatchID`; protobuf resource fields remain `string`. The counter backend may store its high-water marks as integers, and controllers convert allocated values to canonical decimal strings before creating resources.
5151

5252
This proposal applies only to counter-generated resources. Provider build IDs, message and hook IDs, change URIs, and content hashes keep their existing contracts.
5353

@@ -69,5 +69,6 @@ A UI may display `request.42`, `batch.7`, or `#42`, but those are derived labels
6969
- **Queue or kind prefixes:** duplicate explicit context, lengthen keys, require parsing, and introduce URL separators.
7070
- **ARN-like names:** solve global lookup, which current APIs neither provide nor require.
7171
- **UUIDs or a global counter:** provide global uniqueness at the cost of unnecessary encoding or coordination.
72+
- **Integer resource fields:** couple the persisted and wire contracts to the current counter representation without adding identity semantics.
7273
- **SQL auto-increment or `MAX(id) + 1`:** move allocation into one storage implementation or fail under concurrency.
7374
- **Process-local counters:** reuse IDs after restart and collide across replicas.

0 commit comments

Comments
 (0)