docs(adr): equal displays in a scope are shown with a gapless " #2" suffix in id order (improvise-cq1q.1)

Replaces the "one permitted exception" to display uniqueness for a
formula beside a stored measure of the same name: Profit and Profit #2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Claude (adr007-steward)
2026-10-09 09:50:15 -07:00
committed by Edward Langley
parent 38058ec73f
commit 1df5f99e35
@@ -17,6 +17,7 @@ behaviour, the accepted rule binds until the amendment is approved:
| 1 | `_index`, `_dim`, `_measure` are the only ids beginning with `_` | a leading `_` is reserved for virtual ids in general, including the virtual views `_records` and `_drill` |
| 1 | the virtual categories are declared and named in the file (`## Category: _Measure`, `_Measure: column`) | they are defined by criteria with hardcoded ids and displays, never declared, and referred to by id (`_measure`) |
| 1 | `measure_item_names` merges a formula into a stored measure of the same name | a formula never merges: it gets its own id, `profit-<n>` beside a stored `profit` |
| 2 | a display already in use in a scope is refused | equal displays in a scope are shown with a gapless ` #2`, ` #3`, … suffix in id order |
| 2 | `CellKey` pairs are `(CategoryId, ItemId)` | `(CategoryId, ItemHandle)` |
| 2, 5 | a collapsed entry and a group reference name a group by name | by its id |
| 4 | casefold; a run of U+0020 spaces becomes one `_`; strip characters outside `a`–`z`, `0`–`9`, `-`, `_`; remove a leading `_` | casefold; every character outside `a`–`z`, `0`–`9` and `-` becomes `_`; runs of `_` collapse; leading and trailing `_` and `-` are removed; `n` is prepended before a leading digit |
@@ -77,10 +78,8 @@ cost`); a dimension target is rare, for a derived dimension.
`Profit`), adding `Profit = Revenue - Cost` creates a second measure with a fresh id,
`profit-<n>`, by the ordinary collision rule. The stored measure keeps `profit` and
its data; removing the formula removes only `profit-<n>`.
- **Conflict with display uniqueness:** both are displayed `Profit` in `_measure`'s
scope. This is the one permitted case; the two are told apart by id (the formula
panel shows ids where a display is ambiguous, and a typed `Profit` matching both is
refused with both ids listed, clause 12).
- Both are named `Profit` in `_measure`'s scope, so they are shown as `Profit` and
`Profit #2` (clause 2's suffix rule).
- **A target outside `_Measure` is a real item** with its own `ItemId`, and its formula
has a separate `FormulaId`: a formula `Tax` in `CustomCat` gets item id `tax`, then
formula id `tax-<n>`.
@@ -96,6 +95,27 @@ cost`); a dimension target is rare, for a derived dimension.
hold.
- **A collapsed entry names its group by the group's id**, and `Group` gains a
`display`.
- **Displays stay unique within a scope by suffixing.** The accepted text refuses a
display already in use in the scope; a formula's measure beside a stored measure of
the same name (clause 1) cannot be refused. So when several things in one scope have
the same display, they are shown with a suffix: the first keeps the bare display, and
the rest get ` #2`, ` #3`, … (a space, then `#` and the number) as a gapless
sequence in the order their ids sort.
- The order is the ids' string order, the order `CellKey` already sorts ids in. So
`profit`, `profit-1` and `profit-2` show as `Profit`, `Profit #2` and `Profit #3`,
and `profit-10` sorts before `profit-2`.
- Gapless: if the thing shown as `Profit #2` is removed, `Profit #3` becomes
`Profit #2`.
- The suffix is computed when a display is shown, from the things that share it, and
is never stored or written to a file.
- A suffixed display is a display like any other: interactive input that types
`Profit #2` picks that thing (clause 6), and the ids stay the unambiguous name.
- Old files cannot hold two things with one name in a scope, so loading one adds no
suffix.
- A display can also be literally `Profit #2`. Beside two things displayed `Profit`,
it shows the same text as the suffixed one; the two stay distinct by id, and typing
`Profit #2` then matches both, so the pick is ambiguous and is refused with both ids
listed (clause 12).
### 4. How an id is made
@@ -271,7 +291,7 @@ therefore shows B as `east-1`, never as a bare `east`.
## Consequences
- Scripts that name things by display break and must be rewritten over ids.
- Two measures can share a display; every place that shows displays falls back to ids.
- Two measures can share a display, and are shown as `Profit` and `Profit #2`.
- Old files' `_Measure` declarations and hyphen- or digit-led names change on first save.
- `id.rs` and its tests need the follow-up in clause 4.