Skip to content

refactor(router): move the hash contract to dynamo-kv-hashing - #112

Closed
ishandhanani wants to merge 1 commit into
idhanani/dyn-170-router-protocolfrom
idhanani/dyn-171-kv-hashing-contract
Closed

ishandhanani wants to merge 1 commit into
idhanani/dyn-170-router-protocolfrom
idhanani/dyn-171-kv-hashing-contract

Conversation

@ishandhanani

Copy link
Copy Markdown
Owner

Step 3a of the router split v2 (DYNO-171), stacked on #111. Taken before step 2 because the ZMQ event codec calls these helpers.

Summary

  • dynamo-kv-hashing gains a routing module with the router's block and sequence hash contract, moved verbatim from lib/kv-router/src/protocols.rs: XXH3_SEED, compute_block_hash, BlockHashOptions, the multimodal pad constants and pad_value_for_mm_hash, hash_mm_identifier, compute_block_hash_for_seq and its seeded variants, compute_next_seq_hash, compute_seq_hash_for_block, compute_seq_hash_for_tokens_with_seeds, and TokensWithHashes. The eighteen tests that exercise them move with them. The three seeded helpers that were pub(crate) become pub with their existing docs because the tracking hash in kv-router calls them across the crate boundary.
  • dynamo-router-protocol gains an mm module with the multimodal block and request metadata (BlockMmObjectInfo, BlockExtraInfo, RequestMmObjectInfo, RequestExtraInfo): KV events, the hash contract, and the frontend preprocessor all name it.
  • lib/kv-router keeps pub use shims at the old paths; no other crate's imports change. kv-hashing now depends on protocol and xxhash-rust; protocol does not depend on kv-hashing, and the gate forbids it.
  • Deferred to step 3b: TrackingHashContext, because its from_config reads a key file and is called from lib/llm and the mocker.

Validation

  • cargo test -p dynamo-router-protocol -p dynamo-kv-hashing: protocol 10 passed; kv-hashing 20 + 17 + 3 passed (the 18 moved hashing tests included).
  • cargo check -p dynamo-kv-router: clean.
  • cargo test -p dynamo-kv-router: 1,104 lib + 1 integration passed, 0 failed, 3 ignored (the 22-test drop from refactor(router): add dynamo-router-protocol, the wire vocabulary crate #111 is the 18 hashing tests now in kv-hashing plus the 4 that moved to protocol).
  • cargo check -p dynamo-llm -p dynamo-mocker -p dynamo-bench -p dynamo-custom-policy-builtin --tests: clean.
  • cargo clippy -p dynamo-router-protocol -p dynamo-kv-hashing -p dynamo-kv-router --all-targets -- -D warnings: clean.
  • scripts/router_layering_check.sh: 8 checks, 0 failures (protocol row plus the new kv-hashing row: router deps == {dynamo-router-protocol}; direct deps == {derive_builder, dynamo-router-protocol, dynamo-tokens, serde, serde_json, thiserror, xxhash-rust}; 42-crate closure).
  • scripts/router_move_diff.py ebe3e707db WORKTREE over protocols.rs and kv-hashing/src/lib.rs to the new modules: 1,891 normalized lines in common; 10 new and 13 dropped, all accounted for: pub(crate) to pub on the three seeded helpers, dynamo_kv_hashing:: shortened to the in-crate path on five lines, rustfmt collapsing one signature onto one line, and one mod tests. protocols.rs fraction 0.993.

Move the router's block and sequence hash functions out of
lib/kv-router/src/protocols.rs into dynamo_kv_hashing::routing: the XXH3
seed, compute_block_hash, BlockHashOptions, the multimodal pad constants and
pad_value_for_mm_hash, hash_mm_identifier, compute_block_hash_for_seq and
its seeded variants, compute_next_seq_hash, compute_seq_hash_for_block,
compute_seq_hash_for_tokens_with_seeds, and TokensWithHashes. The eighteen
tests that exercise them move with them. The three seeded helpers that were
pub(crate) become pub with their existing docs, because the tracking hash
in kv-router calls them across the crate boundary.

Move the multimodal block and request metadata (BlockMmObjectInfo,
BlockExtraInfo, RequestMmObjectInfo, RequestExtraInfo) into
dynamo_router_protocol::mm: KV events, the hash contract, and the frontend
preprocessor all name it, so it is shared vocabulary.

dynamo-kv-hashing gains dependencies on dynamo-router-protocol and
xxhash-rust; protocol does not depend on it. lib/kv-router keeps pub use
shims at the old paths, so no other crate changes. The layering gate gains
a dynamo-kv-hashing row and forbids kv-hashing in protocol's tree.

Step 3a of the router split v2 plan, taken before step 2 because the ZMQ
event codec calls these helpers. DYNO-171.

Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
@ishandhanani

Copy link
Copy Markdown
Owner Author

Landed upstream as ai-dynamo#18055 (squash commit 79692cf on main, 2026-11-11). Closing this fork review unit.

This branch had an error being deployed

1 failed deployment
external_collaborator — e28c4d0f Deployed Nov 2, 2026 by ishandhanani via ok-to-test #514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant