feat(plugin): every provider write surface carries the real committed generation

The provider contract (metadata addToIndex/removeFromIndex, vector
addItem/removeItem, id-mapper getOrAssign/remove) gains an optional
trailing generation — evaluated lazily at operation execute time (the
graph surface's thunk pattern, generalized), threaded from all 17
construction sites: undefined during generation-0 bootstrap, the real
committed generation everywhere else. Optional = additive: no existing
provider or caller breaks; native delta logs that stamped literal zero
start hearing truth. JS twins accept the parameter with parity notes.
Pins: provider doubles capture and assert nonzero monotonic generations
across add/update/remove on both surfaces.
This commit is contained in:
David Snelling 2026-08-10 09:29:06 -07:00
parent 3484107462
commit 2d532684b4
7 changed files with 583 additions and 63 deletions

View file

@ -164,8 +164,15 @@ export class EntityIdMapper implements EntityIdMapperProvider {
* would exceed that, throws {@link EntityIdSpaceExceeded} so the caller
* loudly migrates to cor's binary mapper with `idSpace: 'u64'`
* rather than silently truncating entity ids.
*
* @param generation - Brainy's commit generation current at mint time
* (contract parity with the `EntityIdMapperProvider` surface). This JS
* mapper keeps a snapshot file, not a per-record delta log, so there is
* no natural slot to store it accepted and ignored; a native mapper
* stamps its assignment records with it.
*/
getOrAssign(uuid: string): number {
getOrAssign(uuid: string, generation?: bigint): number {
void generation // Contract parity — no per-record log in the JS mapper.
const existing = this.uuidToInt.get(uuid)
if (existing !== undefined) {
return existing
@ -226,8 +233,14 @@ export class EntityIdMapper implements EntityIdMapperProvider {
/**
* Remove mapping for UUID
*
* @param generation - Brainy's commit generation for this removal (contract
* parity with the `EntityIdMapperProvider` surface). Accepted and ignored
* this JS mapper removes immediately; a native mapper tombstones the
* mapping at this generation in its version chain.
*/
remove(uuid: string): boolean {
remove(uuid: string, generation?: bigint): boolean {
void generation // Contract parity — no per-key version chain in the JS mapper.
const intId = this.uuidToInt.get(uuid)
if (intId === undefined) {
return false