Skip to content

feat(sketch_db): Phase 5 M2 — derive sketch sid from content hash - #150

Merged
zzylol merged 1 commit into
mainfrom
feat/sid-from-hash
May 13, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/sid-from-hash

Conversation

@zzylol

@zzylol zzylol commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds compute_sketch_sid(metric_name, attrs_fingerprint, sketch_kind, sketch_config) -> u64 in data_plane::stores::sketch_db::index, a deterministic xxh64 over the four DataPoint inputs the backend has at sketch-ingest time.
  • Rewires the sketch ingest path in otel.rs to compute the sid by hash instead of going through SeriesIdResolver. Same four inputs always yield the same sid across restarts and across hosts; the controller no longer needs to emit aggregationId.
  • SketchIndex.instance(sid).is_some() replaces SeriesIdResolver::is_known(sid) as the "have we seen this sid before?" check for the (sid!=0, no-attrs) wire case. (sid!=0, attrs) recomputes the hash and signals stale on disagreement. (sid=0, attrs) always derives the hash. (sid=0, no-attrs) still drops.
  • Raw-sample ResolveSeriesIDs RPC and non-sketch paths keep the existing counter-based resolver — no agent-side coordination change needed for this PR.

Scope this PR does NOT cover (follow-ups)

  • Controller AggregationConfig.aggregation_id field removal from YAML wire format.
  • SchemaRegistry / SketchStore agg_id → sid migration (M2 finish).
  • Arc<dyn AggregateCore> retirement (M3).

Test plan

  • 5 new unit tests in sketch_db::index::tests cover determinism + distinguishing each of the 4 hash inputs (metric, attrs values, sketch_kind, container_config).
  • 3 existing sid_resolution_tests updated to assert on SketchIndex registration state instead of resolver state.
  • cargo test -p data_plane --lib — 792 passed; 2 failed (pre-existing schema_timeline_dispatch_tests regressions, unrelated to this change); 6 ignored.
  • cargo check --workspace clean.

🤖 Generated with Claude Code

The backend now computes `series_id` for a sketch DataPoint as
xxh64(metric_name, attrs_fingerprint, sketch_kind, sketch_config)
instead of minting a monotonic counter value through SeriesIdResolver.
Same four inputs → same sid across restarts and across hosts, so the
controller no longer needs to emit `aggregationId` for each (metric,
agg-type, params) tuple — backend derives it.

`SketchIndex.instance(sid).is_some()` replaces
`SeriesIdResolver::is_known(sid)` as the "have we seen this sid before?"
check for the (sid!=0, no-attrs) wire case; the (sid!=0, attrs) case
recomputes the hash and signals stale on disagreement. Raw-sample
ResolveSeriesIDs RPC and non-sketch paths keep the existing
counter-based resolver (no agent-side coordination change needed yet).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit a3e4f79 into main May 13, 2026
@zzylol
zzylol deleted the feat/sid-from-hash branch July 17, 2026 20:05
zzylol added a commit that referenced this pull request Jul 27, 2026
…eal Cms sketch

Bumps the ASAPController rev pin to feat/extension-realization-hook
(ASAPController#162, not yet merged) to pick up
CostModel::{realize_extension, readout_extension} (ASAPController#150).

ControlPlaneCostModel now implements both for ext_kind == "frequency":
realize_extension parses the accuracy out of payload and returns
Implementation::Sketch{kind: Cms, params: Cms{width,depth}} -- matching
capability_matching::pick_family's own Frequency -> Cms mapping (NOT the
older sketch_catalog::sketch_type_for_op's SketchType::CountSketch,
which is a genuinely different sketch algorithm under a similar name and
predates/disagrees with capability_matching -- kept the newer, tested
mapping). readout_extension builds SketchQuery::PointCount, falling back
to {key: SampleValue, value: None} until the filter value is threaded
through payload (a separate, later change) -- correct as the bare
bucket total in the meantime.

ForcedFamilyCostModel (used by optimizer::rules::bind_workload_typed)
delegates both new methods to its inner ControlPlaneCostModel, so the
`endpoint_request_freq` contract row -- previously a documented, accepted
regression declining to Logical pending #150 -- now commits like every
other row. Flipped the tests that pinned the old decline behavior to
assert the new Cms binding instead.

Also updates emit::stage_config's SketchQuery::PointCount wire JSON for
the new `value` field (ASAPController#162).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jul 27, 2026
…ding

Caught in review: the section header above frequency_extension_binds_cms
still described Frequency as declining to bind (pre-#150 behavior) and
pointed at the old, renamed test name. Corrected to describe current
behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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