feat: wire ElementId into Counter/Register/Map + Map<Element> with recursive merge#14
Merged
Conversation
…cursive merge - Counter/Register/Map opaque, carry an ElementId set at create. - Map slot value is Element (was Scalar). map_set/get/delete/merge updated. - map_merge same-key path: same composite kind + same id -> element_merge (recursive). Otherwise LWW on slot stamp. - LWW with composite displacement host_aborts (cross-arena pointer would dangle). Deterministic id derivation in PR 5 keeps the path unreachable in normal use. - element.h breaks the map.h cycle via forward decl typedef struct Map. - elementid.h header guard fixed (#define was missing). - Death test test_map_abort.c exercises the abort; Makefile inverts exit.
There was a problem hiding this comment.
3 issues found across 16 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… LWW when src wins - Recursive same-id merge now sets dst slot stamp to max(dst, src). Without this, a later slot-level op on dst could flip the slot using a stamp src has already moved past, and replicas diverge. - LWW fallthrough no longer aborts on composite src that LOSES the stamp comparison. The abort guard is for the cross-arena displacement hazard (src wins); when src loses, dst keeps its slot and nothing dangles. - Tombstone branch in the fallthrough takes its own continue to keep the remaining LWW-vs-abort flow flat.
Hitting LWW with a composite means id derivation is broken or types diverged at this key. That is a programmer error regardless of which side's stamp wins; skipping the abort when src loses by stamp made the crash stamp-dependent, which would let the same broken state crash one replica and silently pass on another. Restore unconditional abort; drop the now-misleading "src loses does not abort" regression test.
Member
Author
|
@cubic-dev-ai review |
@vieiralucas I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 16 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Counter/Register/Mapnow opaque; carry anElementIdset at*_create. New accessors:counter_id,register_id,map_id.Mapslot value isElement(wasScalar).map_set/map_get/map_delete/map_mergeupdated.map_mergeper-slot rule:element_merge(recursive, in-place).scalar_dup'd into dst arena.host_aborts (cross-arena pointer would dangle). Deterministic id derivation in PR 5 keeps this path unreachable in normal use.element.hbreaks themap.hinclude cycle viatypedef struct Map Map;forward decl.elementid.hheader guard fix —#definewas missing.test_map_abort.cexercises the abort; Makefile target inverts the exit (! ./test_map_abort).Summary by cubic
Switch Map to store Element values and wire ElementId through Counter/Register/Map to enable recursive merges of same-id composites. Recursive merges advance the slot stamp; any LWW path that hits a composite aborts to avoid cross-arena pointers and stamp-dependent divergence.
New Features
Counter/Register/Mapare opaque and carry anElementIdset at create; addedcounter_id,register_id,map_id.MapstoresElement;map_set/map_get/map_delete/map_mergeupdated. Scalars are duped into the dst arena; composites are pointers.map_merge: same composite kind + same id → recursiveelement_merge, then set slot stamp tomax(dst, src); otherwise LWW on the slot. Any LWW path with a composite nowhost_aborts.element.h↔map.hinclude cycle via forward decl; fixedelementid.hheader guard; updated header docs (incl.map_getreturnsElement). Added death testtest_map_abortand a Makefile target.Migration
counter_create(arena, id),register_create(arena, id, value, stamp),map_create(arena, id).Element: wrap scalars withelement_scalar(...)when callingmap_set;map_getreturnsElement.ElementIds per slot so replicas share ids and merges recurse.Written for commit 8f1672b. Summary will update on new commits.