Skip to content

refactor(hydra)!: ASAPv1 only — drop proto and portable HydraKLL, add goldens - #171

Closed
GordonYuanyc wants to merge 2 commits into
mainfrom
asapv1-only/hydra
Closed

GordonYuanyc wants to merge 2 commits into
mainfrom
asapv1-only/hydra

Conversation

@GordonYuanyc

Copy link
Copy Markdown
Collaborator

Part of the ASAPv1-only series: one PR per sketch group, each off main. This one removes Hydra's protobuf format and the portable HydraKllSketch; ASAPv1 (0x07 0x00–0x07 0x04) is the only Hydra format left, and all five counter variants get goldens.

Draft because of the downstream question below.

Removed

  • proto/hydra/hydra.proto (HydraState, HydraCounterType, HydraCell); SketchEnvelope.hydra (16) is now reserved 16; reserved "hydra";. KLLState, CountSketchState, CountMinState, HyperLogLogState, UnivMonState stay (other sketches on main still use them).
  • message_pack_format::portable::hydra_kll: HydraKllSketch (incl. update, quantile, merge_refs, aggregate_hydrakll, MessagePackCodec), HydraKllSketchWire; crate-root re-export HydraKllSketch.

Added

  • Goldens for every Hydra counter, built from fixed state (pushed to sketchlib-golden-bytes; submodule bumped): hydra_kll_2x2_k200, hydra_cm_2x2_counter_2x2, hydra_cs_2x2_counter_2x2, hydra_hll_1x2_p14 (registers set via crafted hashes, asserted), hydra_univmon_1x2 (cells, heaps, total weight and an incomplete layer set through public setters). Each is checked in both directions. The reviewer hand-decoded all five against spec §3.9.
  • A property law round-tripping a compacting Hydra-KLL grid through ASAPv1 (mutation-checked).
  • The ASAPv1 docs no longer state a fixture count; they defer to the golden README.

Open question

HydraKllSketch is a production type: ASAPQuery uses it in memory and ASAPQuery-backend writes it with portable to_msgpack. Its nearest replacement, native Hydra with a one-column schema over HydraCounter::KLL, routes label:value subkeys through the matrix hash at HYDRA_SEED instead of xxh32(key, row) % cols. Stored HydraKLL data therefore cannot be mapped cell for cell; the backend and ASAPQuery must switch together and old data becomes unreadable. The CHANGELOG says so.

Verification (rustc 1.99)

cargo fmt --check; clippy -D warnings for all four CI feature sets; RUSTDOCFLAGS="-D warnings" cargo doc; gen-proto drift clean; filtered tests (asapv1_golden, pbt -- hydra::, --lib -- hydra, msgpack_compat, xtest_consumer, e2e -- quantiles). Implemented and reviewed by separate agents; review findings are addressed in the second commit.

🤖 Generated with Claude Code

GordonYuanyc and others added 2 commits October 2, 2026 00:57
Hydra serializes as ASAPv1 only. Remove the portable HydraKllSketch and
HydraKllSketchWire, hydra/hydra.proto (HydraState, HydraCell,
HydraCounterType) and SketchEnvelope's hydra field (16, now reserved), with
the tests, example section and docs that used them. The two portable
property laws give way to a KLL-counter ASAPv1 round-trip law on the
native Hydra.

Add ASAPv1 golden fixtures for all five Hydra counter variants
(0x07 0x00-0x07 0x04), bumping asapv1_golden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
State no fixture count; point at asapv1_golden/README.md's Coverage
section. The cross-language proto test reads eight envelope files. The
CHANGELOG entry notes that native Hydra routes subkeys differently from
HydraKllSketch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GordonYuanyc

Copy link
Copy Markdown
Collaborator Author

Outdated. ASAPv1 encodings and goldens landed in #232 and #235 against the current spec; removing the legacy formats is redone on current main in #206 and #207.

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.

1 participant