Skip to content

Collector view states: ingest OTLP states of the views a collector builds, staged and committed as the view's windows - #890

Draft
zzylol wants to merge 12 commits into
feat/late-merge-committed-windowsfrom
feat/collector-state-ingest
Draft

zzylol wants to merge 12 commits into
feat/late-merge-committed-windowsfrom
feat/collector-state-ingest

Conversation

@zzylol

@zzylol zzylol commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: a collector (ASAPCollector-public) can build a leaf sketch view (for example a DDSketch per series per 5 s window) before the network, but the backend has no way to take its states in: every view is built here from raw samples. The design is in draft docs(design): plan sub-DAGs precomputed in the collector (v1: leaf sketch views) #885 (docs/design/collector-sketch-ingest.md, §4 and §6).
  • Change: the collector-state ingest path, steps 3 of that design's plan.
    • common::ViewStateBatch: a request's collector states, nested as the OTAP tiers (view → series → records).
    • otlp: one walk, branching at the metric. A metric whose metadata carries the view identity (asap.plan_id, asap.node_id, asap.view_state_key) and whose name is <metric>.asap_view.<node_id> gives states: labels from the raw path's label function (resource attributes as Prometheus does, from fix(otlp): OTLP/HTTP replies, Prometheus resource-attribute labels, DELTA sums rejected, in-place decoder #887), window (start, time], ASAPv1 bytes from sketch.envelope, count. Every other metric gives samples, as before.
    • precompute: views listed in PrecomputeOptions::collector are collector views. Each is a refresh group of its own that no run computes. A state is checked, decoded into the view's kernel with storage's ASAPv1 codec, staged per (view, series, window), and committed through the precompute committer when the request ends (no commit grace); the request answers once its windows are committed. A later state of a committed window merges into it through feat(precompute): merge late samples into committed windows within retention #892's late merge.
  • Effect: with the collector building view n1, the backend answers the view's queries from the collector's states exactly as from its own windows, and stores no raw samples of a metric only collector views read. With no collector view configured, nothing changes: the parity dump is byte-identical to the base, the decode and ingest benchmarks are unchanged.

Restack (2026-11-30, 2nd) onto #892 5da5b6c, at b7b9312

Restack (2026-11-30) onto #892 0867ce6, at 742e799

Fix 2b (2026-11-30), at 8411b5b

  • Problem (e2e on c49bc44): collector windows closed only when states arrived. While a collector stream was idle, no collector window closed (0 wall-clock closes vs 6 on the ASAPQuery-backend-only arm). Queries over the idle period got HTTP 422 "has no rows tiling", for good if the stream never resumed.
  • Fix: a collector view's group gets an idle watermark on the monotonic clock, as feat(precompute): close an idle stream's last windows by wall-clock time #889 has for samples. It is the newest state's window end (capped at the wall-clock time it arrived), plus the monotonic time since it arrived, less CollectorViewOptions::idle_close_ms (default 8 s: the collector's 6 s close delay plus a 2 s skew allowance).
  • Test first: windows_of_a_stopped_collector_close_by_the_clock. With a manual clock, the collector stops 30 s before the query time.
    • Before: the query over the stop got 422.
    • After: once the clock passes the stop's last window end by 8 s, the query answers and equals ASAPQuery-backend alone on the same samples.
  • Gate:
    • clippy (workspace) clean;
    • collector_views 11, ingest_shards 17, ingest_protocols 6, precompute lib 12.

Follow-ups (2026-11-30), at cd13693, on #892 3b3eaac

  • Feed gap fix (priority, from the e2e on e7b33b7).
    • Problem: a collector window that closed with no state was counted empty and not stored. Every range over a feed gap then failed with "materialized view 1 has no rows tiling" (HTTP 422), while the ASAPQuery-backend-only arm stores its idle windows empty and answers.
    • Fix: such a window is now committed empty (still counted empty). States or corrections that come later merge into it.
    • Test first: a_feed_gap_is_stored_empty_and_answered. A 30 s gap (six 5 s windows) failed with 422; now q01 over the gap equals the answer of a data plane that built the view from the same samples.
    • With this, the lagging-collector window is stored empty first, and its late states merge into it. That test now also checks the answer meanwhile.
    • bad_states_…_is_missing becomes bad_states_…_is_counted.
  • Collector corrections:
    • a_correction_state_merges_into_its_emitted_window: a state of a window's late samples alone, sent after the window was emitted, merges (late_merged), and the answer equals on-time arrival. Sent again, it is a duplicate.
    • The per-(window, series) hash set already gave this, so the test passes without a code change.

Review guide

Commit on arrival (this restack)

  • Close: a collector view's windows close through the newest window a request staged, when the request's coordinator pass ends (Ingestion::collector_arrived, close_windows). ingest_collector_states returns once those windows, and the late merges queued before them, are committed: the coordinator queues a committer barrier per request.
  • Later states: a state for a window at or before the group's closed-through goes one of three ways:
  • Dedup: Staging::committed keeps the hash set per (window, series) of every committed window while it is kept. A resent state or request merges nothing twice, and a new series or partial merges.
  • Removed:
    • CollectorViewOptions::commit_grace_ms and the clock start of a collector group: a group starts at the oldest window of its first states.
    • close(now_ms) → close().
  • Order (approved follow-up, 2026-11-29): a window whose first states arrive after a later window of its view committed is stored behind the newest, within retention. Its states go to the late path with insert set (feat(precompute): merge late samples into committed windows within retention #892's ViewStore::merge_late / replace_window). The wider windows read from it that closed meanwhile are computed again from the views as they then stand; if their first run failed on the missing window, they are inserted. Its states count as late_merged; only a window past retention is late_dropped.

Behavior: before → after

One series data{job="a"}, plan quantile_over_time(0.99, data[5m]) with a DDSketch α 0.05 chain n1 (10 s windows), the collector building n1; POST /v1/metrics with metric data.asap_view.1, metadata (plan id, 1, n1's key), one summary point per window with sketch.envelope:

Before After
The view metric's points ingested as samples data.asap_view.1_sum / _count (a metric no Scan reads) staged as n1's states, series {__name__="data", job="a"}
n1's window (T−10 s, T] built here from raw samples committed when the request carrying its states ends; the request answers after the commit
Query at T answered from n1 built here the same answer, byte for byte (test below)
Raw data samples (n1 is their only reader) stored not stored (samples_unrouted)
A second state of one window (collector restart) — merged; a repeat of either is a duplicate
A state after its window committed (another series, a new partial) — merged into the window within retention (late_merged); a repeat is a duplicate; past retention or never stored: late_dropped
A window with no state at commit — stored empty (counted empty); later states merge into it
Another plan's / unknown node's / other key's / off-grid window's / undecodable state — rejected (other_plan, unknown_view, key_mismatch, window, decode), counted in the reply's partial_success
Identity metadata missing in part, bad key JSON, name not <metric>.asap_view.<node_id>, sketch.envelope under a plain metric samples 400

/metrics gains, per view, asap_collector_states_total{outcome=staged|duplicate|merged|late_merged|late_dropped|expired}, asap_collector_states_rejected_total{reason}, asap_collector_states_windows_total{outcome=committed|empty} and the histogram asap_collector_states_arrival_delay_seconds; none is rendered before a state arrives.

Design scope

  • Where the skip lives: the engine option PrecomputeOptions::collector (CollectorViewOptions { views }) already makes precompute skip the listed views and the Scans only they read, because the ingest path cannot be tested without it. The next PR adds the file, the control plane rule and --collector-views that set it.
  • One group per collector view: a collector view leaves its planner refresh group and becomes a group of its own (Ingestion::split_collector_views), compiled only for its output schema. Its windows close through the newest window a request staged, instead of by the raw watermark; a group reading it (a wider chain level) closes a window only once the collector group closed it, and one no metric starts starts with it. Plan order is kept (collector groups first within their planner group), so RefreshTaskGraph orders readers after them.
  • The commit path is the committer's: a closed collector window goes to the committer as PrecomputeJob::Collector with its staged states, takes a precompute slot and counts in the backlog like any window, and is committed by commit_window (readers, persistence, memory budget, missing_only for windows loaded from files). The view files' plan hash mixes in the collector views, since they change the group layout.
  • Decoding: the view's kernel is the executor's own (create_planner_accumulator for the view's summary type, θ and input); Asapv1Decoder::of_state finds the stored-form kernel of that empty state, and decode is the existing decode_sketch. No sketch table is written here.
  • Where staging runs: checks and decoding on the HTTP thread; staging (late check, hash set, merge) on the ingest coordinator, which owns the window clock, behind one command per request; rows are built on the committer, not the coordinator.
  • Readers of a collector view (directly or through other groups, reads_collector) close a window only behind every group they read; one no metric starts starts with the collector view, and one started earlier (by its metric or a stream start) skips to the collector view's first window, whichever starts first. A reader that also scans a metric holds that metric's raw samples until the collector's first state arrives.
  • /v1/metrics stages states before ingesting samples: a request refused (503) for either is retried whole, its states are then duplicates (ignored), and no sample is ingested twice.
  • No new trait. ingest_collector_states is a method on InstalledPrecompute, next to try_ingest (the design names PrecomputeEngine; the HTTP side holds InstalledPrecompute).

Deviations from the design document (to fold into #885)

  • ViewStateRecord carries window_start_ms too: a state whose start is not end − width is rejected (window).
  • Rejection reasons add key_mismatch (key differs from the node's; the design folds it into unknown_view), name (a series' __name__ is not the view's Scan metric) and merge (a state that does not merge with the staged one). A name without the .asap_view.<node_id> suffix of its identity is refused by the adapter (400) with the other identity errors.
  • A view's group starts at its first states' oldest window.
  • ingest_collector_states is Busy (503) while the precompute backlog is full, as samples get 503 once the queues fill.
  • Rejections of a node id the plan has no collector view for are counted under view="unknown".
  • Staged states of a window skipped as past the view's retention are counted as expired, not late_dropped.

Interfaces

crates/common/src/view_states.rs

+pub struct ViewStateBatch { pub views: Vec<CollectorViewStates> }
+pub struct CollectorViewStates { pub plan_id: String, pub node_id: PhysicalASAPNodeId, pub key: ViewStateKey, pub series: Vec<CollectorSeriesStates> }
+pub struct CollectorSeriesStates { pub labels: LabelSet, pub records: Vec<ViewStateRecord> }
+pub struct ViewStateRecord { pub window_start_ms: i64, pub window_end_ms: i64, pub asapv1: Vec<u8>, pub sample_count: u64 }
+pub mod view_identity { PLAN_ID, NODE_ID, VIEW_STATE_KEY, NAME_INFIX, ENVELOPE_ATTRIBUTE }
+pub use asap_types::plan::materialized_view::ViewStateKey;

crates/adapters/ingest/otlp/src/lib.rs

 pub struct Decoded<S> {
     pub samples: Vec<S>,
     pub rejected_points: u64,
     pub dropped_no_value_points: u64,
+    pub view_states: ViewStateBatch,
 }
 pub enum OtlpError {
+    ViewIdentity { metric: String, reason: String },
 }

crates/precompute/src/collector.rs, engine.rs

+pub struct CollectorViewOptions { pub views: BTreeSet<PhysicalASAPNodeId> }  // default: none
+pub struct CollectorStateIngestReport { pub staged: u64, pub duplicate: u64, pub merged: u64, pub late_merged: u64, pub late_dropped: u64, pub rejected: BTreeMap<&'static str, u64> }
+pub mod reject { OTHER_PLAN, UNKNOWN_VIEW, KEY_MISMATCH, NAME, WINDOW, DECODE, MERGE }
+pub mod outcome { STAGED, DUPLICATE, MERGED, LATE_DROPPED, EXPIRED, COMMITTED, EMPTY }
 pub struct PrecomputeOptions {
+    pub collector: CollectorViewOptions,
 }
 impl InstalledPrecompute {
+    pub async fn ingest_collector_states(&self, batch: ViewStateBatch) -> Result<CollectorStateIngestReport, IngestError>;
 }

crates/storage/src/segment.rs

+pub fn with_view_layout_states(batch: Batch) -> Result<Batch, Error>;
 impl WindowLocation {
-    pub fn read(&self, schema: &SchemaRef, how: ViewRead) -> Result<(Batch, usize), Error>;
+    pub fn read(&self, schema: &SchemaRef, how: ViewRead) -> Result<Batch, Error>;
 }

The view store's window charge is now Batch::stored_bytes (every state column in full) less shared texts, for appended and read-back windows alike; the separate state-byte count read returned is gone.

crates/storage/src/persist.rs

+pub struct Asapv1Decoder(SketchKernel);
+impl Asapv1Decoder {
+    pub fn of_state(template: &dyn AggregateCore) -> Option<Self>;
+    pub fn decode(&self, asapv1: &[u8]) -> Option<Arc<dyn AggregateCore>>;
+}

crates/data-plane/src/engine.rs

 pub struct EngineOptions {
+    pub collector: CollectorViewOptions,
 }
 impl EngineHandle {
+    pub async fn ingest_collector_states(&self, batch: ViewStateBatch) -> Result<CollectorStateIngestReport, IngestError>;
 }

internal_metrics::Metrics gains collector_states: CollectorStateMetrics.

Usage

crates/data-plane/tests/collector_views.rs::collector_states_answer_as_the_view_built_here, run at this commit:

// A data plane whose collector builds the chain n1, committing each window as it ends.
let options = EngineOptions {
    precompute_mode: PrecomputeMode::Push,
    collector: CollectorViewOptions { views: BTreeSet::from([node]) },
    ..no_forward(0)
};
// One DDSketch (α of the view) per job per window of (T − 5 m, T], fed that window's samples,
// sent as the collector's OTLP summary points (identity in the metric's metadata).
assert_eq!(post(&app, body(&plan, node, width_ms, &states)).await, 0); // 0 rejected points
wait_for(&state, "asap_collector_states_windows_total{view=\"1\",outcome=\"committed\"}", 30.0).await;
let (status, _, answer) = common::get(&app, &common::instant_uri(QUERY, time_ms / 1000)).await;
assert_eq!(answer, expected); // the answer of a data plane that built n1 from the same samples

Tests

Test bodies were written from the design before running, and failed first on two real gaps: the chain's window_end column, and a wider level reading a collector view never starting. Test data: the OTLP bodies are built as the collector's OTAP codec (asap-precompute-rs/src/otap/codec.rs) writes a summary point, with the identity in metric metadata as the design specifies (the collector's metadata and window-boundary changes are its own steps 7–8, not merged yet, so no captured body has this format), and the states are asap_sketchlib DdSketch ASAPv1 bytes at the backend's pinned revision.

  • otlp (unit): a view metric's points become states labeled as raw samples (and a raw gauge in the same request stays a sample); states group by view then series; bad identity, name or envelope refuse the request.

  • precompute::collector (unit) windows_close_through_the_newest_staged_and_later_states_merge: a request's windows close in any order through its newest; later states of a committed window merge unless repeated; a window closed without states takes none later (late_dropped).

  • precompute::collector (unit) a_collector_window_is_charged_as_the_computed_window_of_its_samples: a collector window and the window the view's run seals from the same samples (50 series × 60 samples, DDSketch) take equal view-store bytes. Before the fix (decoded states kept as kernel objects) 30,840 B vs 10,348 B, the 2.8× of the collector e2e run; after, equal (states in the view layout, storage::segment::with_view_layout_states).

  • data-plane/tests/collector_views.rs (end to end, /v1/metrics):

    • states answer exactly as the view built here from the same samples (push mode here, window mode for the reference), and data's raw samples are not stored;
    • a wider chain level built here from the collector's windows answers as the levels built from samples;
    • two partials of one window merge to the whole window's answer; repeats, before and after commit, are duplicates; a state past retention is late_dropped;
    • commit on arrival, written first and failing on the old code:
      • (a) states_of_one_window_in_two_requests_answer_as_one_request: job a's states, then job b's in a second request. The answer read right after the second request equals the one-request answer, with late_merged equal to job b's states.
      • (b) a_request_sent_twice_counts_once: every state of the second request is a duplicate, and the answer is unchanged.
      • (c) a_window_answers_once_its_request_returns: windows that ended under 10 s ago are queryable right after the request returns.
    • Lagging collector (follow-up, test-first): a_window_whose_first_states_come_after_a_later_windows_is_stored. All windows but one three windows back are sent first; that window's states come in a later request. On the leveled plan, the window is stored behind the newest and the wider level is rebuilt. The answer equals one data plane's that got every state on time, with no late_dropped.
    • each rejection reason, and a window with no state left unstored (query not answered).
  • Gate (base chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888 b192642 before the restack onto feat(precompute): close an idle stream's last windows by wall-clock time #889; rerun on feat(precompute): close an idle stream's last windows by wall-clock time #889 below): cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace (ulimit -n 65536): 256 passed, 0 failed, 3 ignored (the base plus 8 new).

  • On feat(precompute): close an idle stream's last windows by wall-clock time #889: gate 259 passed, 0 failed, 3 ignored (feat(precompute): close an idle stream's last windows by wall-clock time #889 plus 8 new), fmt and clippy clean; parity dump vs feat(precompute): close an idle stream's last windows by wall-clock time #889 byte-identical (70,736 B). The last commit (OTLP raw-path trim, after a 3 % decode_bench slowdown showed on feat(precompute): close an idle stream's last windows by wall-clock time #889) is covered by cargo test -p otlp, data_plane --test ingest_protocols --test collector_views, clippy and a final parity run (identical).

  • decode_bench vs feat(precompute): close an idle stream's last windows by wall-clock time #889 at this head, 6 alternating rounds, pinned core: OTLP 0.109–0.112 vs 0.113–0.116 µs/sample (one series per sample), 0.080–0.081 vs 0.081–0.082 (100 per series); Remote Write 0.104 vs 0.104–0.105. ingest_bench on feat(precompute): close an idle stream's last windows by wall-clock time #889: windows refreshed after 0.88–0.89 s on both (first cold runs excepted).

  • Parity dump vs the base with no collector input (raw RW/OTLP, sum and DDSketch quantile, forward and no-forward, /metrics): byte-identical, 69,468 B.

  • Benchmarks vs the base, alternating, 3 rounds: decode_bench (pinned core): Remote Write 0.104–0.107 vs 0.104–0.105 µs/sample, OTLP 0.112 vs 0.111 µs/sample (one series per sample), OTLP 0.080 vs 0.080 (100 samples per series): unchanged. ingest_bench 1000 120 views: every window refreshed after 0.88–0.89 s vs 0.89–0.90 s (one cold first run of the new tree at 4.03 s; the same cold outlier showed on the base tree in an earlier round), writes acknowledged in 0.03 s on both: no regression without collector input.

  • Restack gate (2026-11-29, tests of changed code only):

    • cargo fmt --all --check and cargo clippy --workspace --all-targets --locked -D warnings: clean.
    • Unit tests: precompute lib 12, storage lib 45, otlp 17.
    • data_plane integration: collector_views 7 (3 runs), ingest_shards 15, ingest_protocols 6, server 10.
    • The parity dump and benchmarks were not rerun.
  • Follow-up gate (2026-11-29, at 6d57168, on feat(precompute): merge late samples into committed windows within retention #892 8f5588f):

Open questions

  1. Resolved: out-of-order first states are stored (above).
  2. Previous: none blocking. Collector-side steps (metadata identity, (e − w, e] windows, raw-forward filter) are ASAPCollector-public's; the end-to-end comparison with a real collector (design step 5) follows them.

@zzylol zzylol added enhancement New feature or request area: data plane Runtime ingestion, storage, and query-serving data paths area: summary execution Warm-summary binding, readout, composition, and result decoding test: end-to-end Process-boundary, differential, conformance, and full-stack tests labels Nov 28, 2026
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 8c6f738 to 4d1070d Compare November 29, 2026 00:55
@zzylol
zzylol changed the base branch from feat/idle-wall-clock-close to feat/late-merge-committed-windows November 29, 2026 00:55
zzylol added a commit that referenced this pull request Nov 29, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol added a commit that referenced this pull request Nov 29, 2026
… insert missing windows; shards wait for a pass's routing

- A group whose states depend on the order of their samples (Counter for
  rate/increase, IRate) keeps its raw samples for its views' retention.
  A late sample of it is stored as raw data too, and its window is
  computed again from the raw data whole and replaces the stored one;
  the windows built from it are computed again from the views. Such a
  group is not built by push. KLL and float sums keep the merge.
- A pane's raw rows stay in time order: an out-of-order append (a late
  sample) rebuilds the pane as one chunk sorted by time.
- ViewStore::replace_window replaces a window, or inserts one missing
  behind the newest within retention (for a collector view's window
  whose first states come late, #890); merge_late can insert likewise.
- After answering a flush, a shard holds its samples until the routing
  of that pass (the Maintain the coordinator now sends after every
  flushed pass), so no sample is routed by windows a pass has closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 4d1070d to 6d57168 Compare November 29, 2026 18:01
zzylol added a commit that referenced this pull request Nov 29, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 6d57168 to cd13693 Compare November 30, 2026 02:33
zzylol added a commit that referenced this pull request Nov 30, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol added a commit that referenced this pull request Nov 30, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol added a commit that referenced this pull request Nov 30, 2026
…close

CollectorViewOptions gained idle_close_ms (#890); the collector-views
file does not carry the collector's close delay (a new field would be
refused by readers that deny unknown fields), so the options it gives
take the default 6 s + 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 8411b5b to 742e799 Compare November 30, 2026 06:21
zzylol added a commit that referenced this pull request Nov 30, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol added a commit that referenced this pull request Nov 30, 2026
…close

CollectorViewOptions gained idle_close_ms (#890); the collector-views
file does not carry the collector's close delay (a new field would be
refused by readers that deny unknown fields), so the options it gives
take the default 6 s + 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol and others added 10 commits November 30, 2026 06:43
…s the view's windows

A view of the installed plan that a collector builds (docs/design/collector-sketch-ingest.md)
arrives on /v1/metrics as OTLP summary points under `<metric>.asap_view.<node_id>`,
with the view identity (plan id, node id, view state key) in the metric's metadata
and each series' window state as ASAPv1 bytes in `sketch.envelope`.

- common: ViewStateBatch (view -> series -> records), the identity keys.
- otlp: one walk; a metric naming a view gives states (labels from the raw
  path's label function), every other metric samples, as before.
- precompute: each collector view (PrecomputeOptions::collector) is a refresh
  group of its own that no run computes. States are checked (plan, view, key,
  name, window), decoded into the view's kernel with storage's ASAPv1 codec,
  staged per (view, series, window) with a set of envelope hashes (repeat:
  duplicate; new: merged), and committed through the committer when the wall
  clock passes the window's end by the commit grace; later states are dropped
  as late, a window with no state is not stored. A group reading a collector
  view waits for its windows; Scans only collector views read keep no samples.
- metrics: asap_collector_states_{total,rejected_total,windows_total,
  arrival_delay_seconds}, per view.

Rebased onto the late-merge PR as one commit (the six commits of
8c6f738, resolved once against it):
- fix(collector views): hold a collector window's states in the view layout, as a computed window
- perf(otlp): keep the raw path's per-point and per-metric work as before
- fix(collector views): stage and close collector windows by the engine's clock
- fix(collector views): align a collector view's readers on every start; stage states before samples
- fix(collector views): review fixes: readers of collector groups, open-window start, rows on the committer
- feat(ingest): collector view states over OTLP, staged and committed as the view's windows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…t request counts once (failing first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…within retention

A collector request's staged windows close when the request ends, and
the request is answered once they are committed: no commit grace (the
8 s grace cost every window about 6 s of freshness, while states arrive
within half a second of the window's end). A state that comes later for
a committed window still kept merges into it through the late merge of
window past retention, or closed without states, is dropped as late.

The hashes of each committed window's states are kept while the window
is, per series, so a resent state or request merges nothing twice.

CollectorViewOptions::commit_grace_ms is removed; the report and
asap_collector_states_total gain late_merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…:read's batch; one collector test helper

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… window's is stored, its wider level rebuilt (failing first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… window's is stored

Collector states of a closed window still kept that was never stored
(its first states came after a later window committed, e.g. from a
collector lagging more than a window) go to the late path with insert
set: the window is stored behind the newest (#892's replace_window /
merge_late), and the wider windows read from it that closed meanwhile
are computed again (inserted when their first run failed on the
missing window). They count as late_merged; only a window past
retention is late_dropped. Collector windows also count in the
committer's closed-through, which decides which readers take a change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… its emitted window

A collector that got late samples of a window it already emitted sends a
state of the late samples alone for that window and series. Its bytes
differ, so it merges (late_merged) and the window answers as if every
sample had come on time; sent again, it is a duplicate. The existing
per-(window, series) hash set already gives this; the test pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…ng first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
A collector view's window that closed with no state (a feed gap) was
counted empty and not stored, so every range over it failed ("has no
rows tiling", HTTP 422), while the backend-only path stores its idle
windows empty and answers. It is now committed empty (still counted
empty), and states or corrections coming later merge into it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol and others added 2 commits November 30, 2026 06:43
…ck (failing first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…k and are stored empty

Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
@zzylol
zzylol force-pushed the feat/collector-state-ingest branch from 742e799 to b7b9312 Compare November 30, 2026 07:30
zzylol added a commit that referenced this pull request Nov 30, 2026
…ws file and CLI

Collector windows now commit when their states arrive (#890), so the
grace has no reader: CommitGrace, CollectorViewsFile::commit_grace_ms
and --collector-export-interval-ms / --collector-clock-skew-allowance-ms
go. The collector's window_close_delay_ms capability stays as it
declares it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol added a commit that referenced this pull request Nov 30, 2026
…close

CollectorViewOptions gained idle_close_ms (#890); the collector-views
file does not carry the collector's close delay (a new field would be
refused by readers that deny unknown fields), so the options it gives
take the default 6 s + 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths area: summary execution Warm-summary binding, readout, composition, and result decoding enhancement New feature or request test: end-to-end Process-boundary, differential, conformance, and full-stack tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant