Commit 742a6a5
* fix(objectql): resync the fallback autonumber counter (adopt + collision re-seed) (#6806)
The engine fallback autonumber path seeded `object.field.<scope>` once and then
incremented purely in memory, so it drifted below the store's real max in two
ways it could never recover from.
- Adopt an exempt writer's supplied record number into the counter (isSystem
seed replay / preserveAudit import / beforeInsert hook stamp). Free: one
string parse, no extra query. Read by #6468's anchoring rules, now shared
with the seeding scan as `readAutonumberCounter` so the two cannot drift.
- Re-seed and re-issue on a unique violation attributable to an autonumber the
engine issued, bounded to 3 attempts, then refuse with
`code: 'ERR_AUTONUMBER_COLLISION'` carrying the driver error as `cause`.
The predicates come from `@objectstack/types` (#6250 / #6544), never a
dialect word-list of the engine's own.
Batch inserts drop the stale counter but are never re-issued (bulkCreate may be
partially applied). #6114's read-failure discrimination is unchanged and now
also covers the re-seed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QW3F6hGmFkf1RpwGBthDo
* test(objectql): pin the storage-dependence of the collision half and the batch outcome (#6806)
driver-memory enforces no uniqueness at all (its create is a table.push(),
#4065), so the collision branch is unreachable there and a duplicate lands
silently. Named and pinned rather than left implied (PD #10); adoption is the
half that covers that driver. Also pins what an author gets on a batch
collision: the driver's own error, never ERR_AUTONUMBER_COLLISION, with the
counter dropped so the caller's retry converges.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QW3F6hGmFkf1RpwGBthDo
* docs(objectql): name the drivers behind the storage-dependent collision half (#6806)
Measured `supports.autonumber` across all five in-repo drivers rather than
asserting "the storage layer": only driver-memory (`supports = {}`) and
driver-mongodb (bit absent) take the engine fallback path; driver-sql declares
`autonumber: true` and driver-sqlite-wasm / driver-turso inherit it via
`extends SqlDriver`. Of the two, only driver-mongodb can raise a unique
violation, so the collision retry protects essentially one backend.
Anchored to the reading the repo already ruled and gates —
scripts/driver-memory-census.ledger.json's `ruled-permanent` disposition for
autonumber-seed-cross-side-parity.integration.test.ts ("InMemoryDriver declares
`supports = {}`, so the ENGINE's autonumber seeding owns the counter") — rather
than authoring a second answer to who owns the counter (#6832's shape).
The test rig is a hand-rolled fake driver and imports no driver package, so
check:driver-memory-census sees no unledgered arrival; re-run to confirm.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QW3F6hGmFkf1RpwGBthDo
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 183b4c4 commit 742a6a5
3 files changed
Lines changed: 1252 additions & 33 deletions
File tree
- .changeset
- packages/objectql/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments