Skip to content

warren-core: IdMap<K: IdKeys> with FixedKeys (M10 step 2) - #56

Merged
wfaithfull merged 3 commits into
mainfrom
m10-idkeys
Oct 23, 2026
Merged

wfaithfull merged 3 commits into
mainfrom
m10-idkeys

Conversation

@wfaithfull

Copy link
Copy Markdown
Contributor

This is M10 step 2 (DESIGN.md §5.7). It makes the id map generic over how it stores ids, with no change in behaviour, so step 3 can add TextKeys without touching callers again.

Shape

  • IdMap<K: IdKeys> holds keys: K and the tombstones. The rebuild's merge walk (tombstone, keep or append) stays in IdMap::merge, so a new key storage only has to supply its storage.
  • trait IdKeys:
    • associated types: Key: ?Sized + Ord, Ids: NodeIds, Rebuild: KeysRebuild<Self>;
    • lookups in both directions: dense_id and key, with external_id returning a reference;
    • in_order, renumber, compacted, and a rebuild that reserves exactly.
  • FixedKeys<E> holds today's pairs and inverse unchanged. The parts that only apply to fixed ids stay on IdMap<FixedKeys<E>>: segments, shared views and from_parts.
  • Now generic over K: EdgeIntake, GraphVersion, compaction, diff, the degree counts and distance alignment.
  • pg_warren only changes to IdMap<FixedKeys<E>>. Splitting IdDatum is left to step 4.
  • Small changes:
    • IdMap::renumber builds the new tombstones first, so a failed memory charge changes nothing.
    • GraphVersion gets hand-written Clone/Copy, because a derive would require K: Copy.
    • The fuzz target decode_id_map is updated.

§5.7 records the trait as built.

Checked locally

  • warren-core: 651 unit tests and 5 integration tests pass, the same counts as before.
  • Miri, with CI's flags and the pinned nightly: passed.
  • fmt, both clippy runs with -D warnings, rustdoc with -D warnings, and the core-isolation check.
  • cargo pgrx test pg16: 636 passed, before main (with set_owner) was merged in. CI covers the merged tree.

Generated by Claude Code

The id map becomes generic over its key storage (DESIGN.md §5.7):
IdMap<K> holds the keys and the tombstones, and IdKeys has what the
shared logic needs of a key storage: lookups both ways, in_order,
renumber, compacted and rebuild. The rebuild's merge walk stays in
IdMap, feeding a KeysRebuild in key order, so TextKeys can reuse it.
FixedKeys<E> is today's pairs and inverse, unchanged; segment encoding
and from_segments stay on IdMap<FixedKeys<E>>.

EdgeIntake, GraphVersion, compact, diff, shared_dense_ids and
align_ids/align_graph are generic over K. external_id returns a
reference. pg_warren names IdMap<FixedKeys<E>> where it named IdMap<E>.
No behaviour change: tests change only where the types did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Rxfe2L3iVjSwSBPdUu1Ke
# Conflicts:
#	DESIGN.md
@wfaithfull
wfaithfull merged commit 88dfbb8 into main Oct 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants