Skip to content

docs(design): repository layout and engine boundaries - #874

Draft
zzylol wants to merge 18 commits into
mainfrom
docs/repo-layout
Draft

zzylol wants to merge 18 commits into
mainfrom
docs/repo-layout

Conversation

@zzylol

@zzylol zzylol commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: the data plane is one 17,000-line crate. Nothing enforces which part uses which; for example, query code can reach into store internals. Measurement code is spread over bench/demo, data_plane/examples and scripts, and ASAPQuery's protocol adapters have no place to land.
  • Change: a design doc, docs/design/repo-layout.md. It defines:
    • the target layout: crates/{common, control-plane, precompute, storage, query, internal-metrics, data-plane, adapters/*}, benchmarks/, eval/ and deployment/;
    • the engine boundaries, taken from ASAPQuery's engine-boundaries design (docs(query-engine): design engine boundaries for ASAPPlanner plans ASAPQuery#935) under the same names: the boundary types in common, FallbackClient as its one trait, and the engines and stores as concrete types (a trait is added with its second implementation);
    • the routes data-plane serves, and how /metrics stays out of internal-metrics;
    • where every current file goes;
    • a 9-step migration order.
  • Effect: none; this is documentation. The stack refactor: move folders to the layout in docs/design/repo-layout.md (layout step 2) #876 → refactor: eval/scripts, eval/baselines and deployment Dockerfile (layout step 9) #884 is based on this branch and implements it: steps 2–6 keep behavior and tests unchanged, steps 7–9 only add routes, flags and an image.
  • Status: accepted; the doc was synced with the code after a whole-stack review (dependency graph as built, no engine or store traits, install order, routes, tests and benchmarks as moved).

Review guide

  • Read the "Boundaries" section first: the dependency graph, the control plane → data plane contract (InstallablePlan → PlanInstaller::install), the common types, and the routes.
  • Then read "Where the backend differs from #935". It covers the query engine, the ingest engine, view state, view id, raw data, sketch kernels, the adapters' dependency and SQL/Query DSL queries.
  • Decisions recorded at the end:
    1. common lives in this repository; ASAPPlanner and ASAPQuery are not changed.
    2. The workload tracker lives in control-plane.
    3. The binary is not renamed.
    4. A trait is added with its second implementation: FallbackClient has three; #935's IngestEngine, QueryEngine, ViewStore and RawDataStore wait for a second engine or store.

Migration order

  1. This doc
  2. Folder moves only
  3. internal-metrics and storage crates
  4. common types and FallbackClient
  5. precompute and query crates, PlanInstaller, QueryDispatcher
  6. Existing adapters into crates/adapters
  7. Ingest adapters from ASAPQuery
  8. Query adapters and fallback clients from ASAPQuery
  9. eval/ baselines and deployment/

Folded in from #826 (commit 30a464d)

#826 ("design ASAPQuery-backend on ASAPPlanner's physical DAG") is closed; its still-valid parts move here, rewritten to today's types and code (checked at the layout stack top 659d53b0):

  • Boundaries → "Planner and backend responsibilities": the concern table on InstallablePlan { wire_version, dag, query_texts }, materialized_views() / ingestion_refresh_groups() / raw_data_retention(), asap-executor's compile/instantiate/DataStore (RunStore), DeploymentCapabilities/CostInputs; and the rules (backend never changes a plan, one executor implementation, install fails before anything runs).
  • "Ingestion rules": one watermark (newest sample capped at the wall clock less --allowed-lateness-ms, or a barrier; idle shards never hold it), future drop (--max-future-ms), late drop and samples_late_for_views, first window skipped unless --stream-start-ms, 503 past --max-queued-samples, the event-time barrier.
  • "Query forwarding": forwarded with x-asap-execution / x-asap-forward-reason; --no-forward refuses at install and answers 422.
  • "Alternatives considered" and "Open questions" (idle stream: closing windows by wall-clock time without a barrier).

The doc change is a new commit on docs/repo-layout only. The stack above (#876 → …) is not rebased now; it picks the commit up at its next restack.

@zzylol zzylol added documentation Improvements or additions to documentation area: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths labels Nov 26, 2026
…s; verbatim forward

Lists Answer and ResultSample in common's block, the dependency rule for
ingest adapters (common, nothing, or the adapter whose wire format they
extend), why ingest adapters do not build RawDataBatch, the verbatim
forward and FallbackClient as the seam for the next fallback clients, and
the VictoriaMetrics Remote Write and OTLP adapter crates.
- Status accepted; the two-crate table is the starting point.
- Dependency graph as built: control-plane on asap-planner only,
  storage on asap_sketchlib and not common, data-plane's real list,
  control-plane as a dev-dependency.
- No engine or store traits: each has one implementation, and a trait
  is added with its second (decision 4). common lists what it holds:
  QueryResult::Table(Table), the re-exports, MAX_TIME_MS.
- Install order: query, ingest, dispatcher; queries see the plan only
  after every engine accepts it.
- Routes, including the forward-mode-only and the forward-mode-off ones;
  /metrics is rendered in data-plane, so internal-metrics stays a leaf.
- Tests that start the engine stay in data-plane; eight micro benchmarks
  moved and the load generator stayed; benchmarks/scripts listed.
- persist-N and view-cache code in storage, started by precompute.
- Folders use hyphens, packages underscores.
- Steps 2-6 keep behavior; steps 7-9 only add.
zzylol added a commit that referenced this pull request Nov 28, 2026
Step 2 of the repository layout design (#874): folder moves only, with
every path reference updated. No code or behavior change.

- control_plane -> crates/control-plane, data_plane -> crates/data-plane
  (package names unchanged)
- data_plane/examples/*_bench.rs -> benchmarks/micro/ ([[example]] entries
  of data_plane)
- bench/demo/{campaign,harness,workloads,profile} -> eval/;
  {live,run_live_demo.sh} -> eval/demo/; monitoring -> deployment/monitoring;
  build.sh, fetch_binaries.sh, run_vm_demo.sh, README.md, .gitignore -> eval/
- scripts/{profile.sh,tiered_views_cgroup.sh} -> benchmarks/scripts/
- examples/*.json -> docs/examples/
- eval/results/ is git-ignored
…e layout doc

Adds the Planner/backend responsibility table (current InstallablePlan,
materialized_views, raw_data_retention, DataStore), the ingestion rules
(watermark, future and late samples, first window, 503 back-pressure,
event-time barrier), query forwarding and --no-forward, the rejected
alternatives, and the idle-stream open question, each checked against the
code.
The open idle-stream question becomes decision 5: an idle watermark that
advances the newest sample time by the wall-clock time since a sample last
arrived, less the allowed lateness and a 1 s grace, so the last windows of
a stopped stream close and a lagging stream closes nothing early.
A sample of a committed window still within its views' retention is
merged into it (store and file replaced, cached results made stale);
beyond retention it is dropped and counted.

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 29, 2026 17:18
… wait for a pass's routing after a flush

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… as long as wider levels computed again read them

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: control plane Planning, configuration, routing, and control-plane orchestration area: data plane Runtime ingestion, storage, and query-serving data paths documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant