Skip to content

cockpit-server: serve tile shapes from Lance instead of the eager singleton - #139

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-chains-books-lancedb
Aug 17, 2026
Merged

cockpit-server: serve tile shapes from Lance instead of the eager singleton#139
AdaWorldAPI merged 1 commit into
mainfrom
claude/q2-osm-chains-books-lancedb

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

Follow-up to #138 (merged): wires the Lance datasets built by the boot-time conversion into the two highest-volume request handlers, removing the permanent Vec/String residency on the actual tile-serving hot path.

  • osm_chains_books_lance.rs: RequestChains/RequestBooks (request-scoped, dropped at the end of each request) + gather_chains/gather_books (one batched Lance take_rows per table, cached Dataset handles via tokio::sync::OnceCell — metadata only, not row data). 2 new tests proving a gather returns exactly the requested ordinals and nothing else.
  • osm_features.rs:
    • sample_tile_rows — the tile-row sampling factored out of query_tile_shapes, so the async gather phase and the sync resolve phase share one sampling implementation (this file's own module doc names the exact failure mode of two implementations of one projection drifting — osm_tiles' old V1/V3 key split).
    • ChainsHandle/BooksHandle — plain enums dispatching between the Lance-gathered source and the eager resident singleton (fallback only, when the Lance dataset isn't available).
    • tile_sources — the async gather-then-serve orchestration, called by osm_tile_geometry_bin_handler and osm_tile_geometry_handler before the existing sync query_tile_shapes/query_tile_geometry.

Deliberately deferred (not silently dropped)

Three call sites still use the eager open_chains()/open_books() singletons directly:

  • query_feature/osm_feature_handler and query_geometry/osm_geometry_handler — single-row lookups; migrating needs a two-phase split (read row identity → gather → resolve), lower priority since they fire on a click, not every pan.
  • osm_health_handler — its styling_verdict needs digest validation (distinguishing "codebook present but pinned to a different slab" from "valid"), which needs the same check open_books()'s read_books does internally. No cheap header-only reader exists yet to check just the digest. This is a genuine residual trigger.

Full details in claude-notes/plans/2026-08-16-chains-books-lancedb-blob.md.

Test plan

  • cargo check -p cockpit-server --tests — clean.
  • cargo nextest run -p cockpit-server --bin q2-cockpit osm_features — 20/20 passing.
  • cargo nextest run -p cockpit-server --bin q2-cockpit osm_chains_books_lance — 7/7 passing.
  • cargo fmt --check -p cockpit-server — flags pre-existing, crate-wide formatting drift unrelated to this change (spans ~20 files never touched this session); not chased here.
  • Full workspace verification (cargo build --workspace / cargo nextest run --workspace / cargo xtask verify) not run — deferred given this session's disk constraints (see plan file).
  • Not yet exercised against a real running deployment — the fallback-on-any-failure design means a broken Lance path degrades to today's exact (memory-heavy but correct) behavior rather than an error, but this hasn't been observed live yet.

Generated by Claude Code

…er singleton

Wires the Lance datasets built by the boot-time conversion (previous
commit) into the two highest-volume request handlers, removing the
permanent Vec/String residency on the hot path.

osm_chains_books_lance.rs: RequestChains/RequestBooks (request-scoped,
dropped at the end of each request) + gather_chains/gather_books (one
batched Lance take_rows per table, cached Dataset handles via
tokio::sync::OnceCell — metadata only, not row data). 2 new tests
proving a gather returns exactly the requested ordinals and nothing
else (a leaked non-requested ordinal would pass a weaker assertion).

osm_features.rs:
- sample_tile_rows: the tile-row sampling factored out of
  query_tile_shapes, so the async gather phase and the sync resolve
  phase share one sampling implementation (never two that can drift,
  per this file's own documented lesson about osm_tiles' old V1/V3
  key split).
- ChainsHandle/BooksHandle: enums dispatching between the Lance-gathered
  source and the eager resident singleton (fallback only). Plain enums
  rather than traits, since both arms already share the same inherent
  method shape.
- tile_sources: the async gather-then-serve orchestration, called by
  osm_tile_geometry_bin_handler and osm_tile_geometry_handler before
  the existing sync query_tile_shapes/query_tile_geometry.

Deliberately deferred (documented in the plan file, not silently
dropped): query_feature/query_geometry (single-row endpoints) and
osm_health_handler (needs a cheap header-only digest check that
doesn't exist yet) still use the eager singletons. The tile handlers
are the highest-volume path — every map pan/zoom hits one of them.

Verified: cargo check -p cockpit-server --tests (clean), cargo nextest
run -p cockpit-server --bin q2-cockpit osm_features (20/20) and
osm_chains_books_lance (7/7). Full workspace verification deferred per
this session's disk constraints (see plan file).
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f5781e57-fca0-45b8-8901-83ac6f12a102


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_211dcbc9-2f3c-4a0a-bd43-404500ce97a2)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review August 17, 2026 20:56
@AdaWorldAPI
AdaWorldAPI merged commit 4c6365a into main Aug 17, 2026
5 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

2 participants