|
| 1 | +--- |
| 2 | +"@objectstack/cli": minor |
| 3 | +--- |
| 4 | + |
| 5 | +feat(cli): `os migrate duplicates` — an operator-facing inventory of the business identifiers the tenancy split already minted twice (#8928) |
| 6 | + |
| 7 | +Two producers of untenanted rows have been closed (#8686's seed loader plus its |
| 8 | +one-shot backfill, and #8844's runtime system-context write). Neither touches |
| 9 | +the **damage already done**, and both rulings say the same thing about it: a |
| 10 | +business identifier that has already been handed out — on an invoice, in a |
| 11 | +notification, in another system's idempotence key — is not the platform's to |
| 12 | +rewrite. What an operator needs instead is to know **which ones they are**. |
| 13 | + |
| 14 | +```bash |
| 15 | +os migrate duplicates # the whole report, JSON on stdout |
| 16 | +os migrate duplicates > duplicates-2026-08-17.json |
| 17 | +os migrate duplicates --object crm_case # narrowed (and the report says so) |
| 18 | +``` |
| 19 | + |
| 20 | +**Run it BEFORE the #8686 backfill is applied.** The evidence is perishable: |
| 21 | +`organization_id = NULL` is the marker that says "this row came from the |
| 22 | +untenanted side", and it is exactly what that repair overwrites. The repair also |
| 23 | +merges and deletes the `__global__` counter, which is the report's only |
| 24 | +forward-looking line — an install that repairs before reporting can never |
| 25 | +produce it again. The command itself applies nothing: it boots read-only (no |
| 26 | +DDL, no seed, no database file brought into existence) and issues SELECTs only. |
| 27 | + |
| 28 | +What the report contains, per the 2026-08-16 maintainer ruling on all five of |
| 29 | +the card's decision points: |
| 30 | + |
| 31 | +- **one row per duplicated value, with its holders** — id, organization, |
| 32 | + partition and creation timestamp per row, so the operator can decide case by |
| 33 | + case rather than per value. JSON on stdout, no persistence and no new schema: |
| 34 | + the operator archives it; |
| 35 | +- **the narrow definition of duplicate** — a value held by rows in more than one |
| 36 | + of the partitions `COALESCE(organization_id, '__global__')` separates |
| 37 | + (ADR-0120 D3). A value repeated *inside* one partition is refused by the |
| 38 | + partitioned unique index and is not reported; |
| 39 | +- **the live condition too** — an object still running a `__global__` counter |
| 40 | + beside an organization-scoped one is about to mint more duplicates; |
| 41 | +- **a data-side probe** — `GROUP BY <field> HAVING COUNT(*) > 1` over the |
| 42 | + object's own table, never an enumeration of `_objectstack_sequences`, so a |
| 43 | + duplicate whose counter was since merged is still found. The counter table is |
| 44 | + read for the live condition alone, because that fact lives nowhere else. |
| 45 | + |
| 46 | +Scope is every registered object that is organization-scoped, and on it every |
| 47 | +`autonumber` or `unique` field. `sys_` / `cloud_` / `ai_` objects are **not** |
| 48 | +filtered out — that filter is correct for a repair (platform seeds stay global |
| 49 | +by design) and wrong for a report, which must not silently omit a real |
| 50 | +duplicate. Anything that could not be probed is listed in `skipped` with the |
| 51 | +driver's own message, so a target the command could not read never reads as a |
| 52 | +target with no findings; a driver with no raw-SQL seam refuses loudly and exits |
| 53 | +non-zero rather than reporting zero duplicates. |
| 54 | + |
| 55 | +⛔ Reporting is all it does. Renumbering, deduplicating or otherwise rewriting an |
| 56 | +already-minted identifier stays out of scope per both rulings. |
0 commit comments