cockpit-server: bucket-read multi-region OSM catalogue + /api/osm/regions - #142
Conversation
…ions Closes the "adding/selecting a region needs an env-var change + redeploy" friction: OSM_BAKE_REGION previously selected the single servable region, and switching regions meant a Railway env-var edit (which triggers a redeploy) even though the bake itself already lives in S3 with no code change needed. - New osm_region_catalogue.rs: reads .config/q2/config.yaml from the bucket via lance_graph::soa_config's shared schema/parser (the same boot-config pattern every other AdaWorldAPI deployment uses for its own bake catalogue) and projects it onto (name, hydrate). table/classid are validated but unused here — this deployment's OSM bakes are still raw .soa/.books/.chains file triplets, not Lance tables; reusing the shared, already-hardened parser (unknown-key rejection, duplicate-name rejection) beats hand-rolling a near-identical one. - osm_slab_hydrate::ensure_slab_local now: loads the catalogue (falling back to a single synthetic entry from OSM_BAKE_REGION/DEFAULT_REGION when no config.yaml exists — zero behavior change for deploys that never opt in), hydrates every hydrate:true entry (hydrate:false stays declared-but-not-pulled, never fetched), and publishes the resolved catalogue for the new endpoint. OSM_BAKE_REGION, when set, still wins outright as the active region even if absent from the catalogue or declared hydrate:false there — the pre-existing escape hatch is unchanged, including bake_region()'s validate-or-fall-back-to-default behavior on an invalid value. - Region-name validation ([a-z0-9-], <=64 bytes — guards the S3 key/path join against traversal) now applies to every catalogue-sourced name too, not only the env-var path. - New GET /api/osm/regions: the map-menu data source (name, hydrated, active per region). Read-only discovery — this deployment still serves exactly one active region at a time (open_slab()'s mmap is process-global); switching which one is active still needs the operator to flip hydrate:true (or set OSM_BAKE_REGION) and restart. That is a narrower claim than "hot-swap without restart," which this change does not attempt. Test plan: - 12 new unit tests in osm_region_catalogue.rs (TDD): parse_catalogue_yaml projects name/hydrate correctly, keeps hydrate:false entries (does not drop or promote them), rejects malformed YAML, propagates the shared parser's own duplicate-name validation; pick_active prefers the env override even when absent from the catalogue or over a hydrate:true entry, falls back to the first hydrate:true entry, returns None on an all-false catalogue with no override (paired negative case); the publish/snapshot OnceLock round-trips and a second publish is a silent no-op rather than a panic. - cargo check -p cockpit-server --bin q2-cockpit --tests: clean, 0 errors, 0 new warnings (34 pre-existing baseline warnings unchanged). - cargo test/nextest for this crate could not be run to completion in this session: the q2-cockpit test binary transitively links nearly the entire q2 workspace (lance/arrow/datafusion/geo/aws-sdk/opendal/ tree-sitter/wasmtime/mlua/...), and the final link step exceeded this container's disk allowance on repeated attempts (ENOSPC, then a linker SIGBUS), even immediately after a full target/ clean. This is the same environment limitation documented on q2#141 for the same binary, unrelated to this change. Reported honestly: type/borrow-check-verified, not executed-test-verified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NMeiLmtDKhomJNSo2ecbJw
Bugbot couldn't run - usage limit reachedBugbot 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_0a0f2d0a-3ee9-4233-860c-8841fff1b287) |
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Closes the "adding/selecting a region needs an env-var change + redeploy" friction:
OSM_BAKE_REGIONpreviously selected the single servable region, and switching regions meant a Railway env-var edit (which triggers a redeploy) even though the bake itself already lives in S3 (q2/bakes/<region>-v1) with no code change needed.osm_region_catalogue.rs: reads.config/q2/config.yamlfrom the bucket vialance_graph::soa_config's shared schema/parser — the same boot-config pattern every other AdaWorldAPI deployment reads its own bake catalogue from — and projects it onto(name, hydrate).table/classidare validated but unused here: this deployment's OSM bakes are still raw.soa/.books/.chainsfile triplets, not Lance tables; reusing the shared, already-hardened parser (unknown-key rejection, duplicate-name rejection,deny_unknown_fields) beats hand-rolling a near-identical one.osm_slab_hydrate::ensure_slab_localnow: loads the catalogue (falling back to a single synthetic entry fromOSM_BAKE_REGION/DEFAULT_REGIONwhen noconfig.yamlexists — zero behavior change for deploys that never opt in), hydrates everyhydrate: trueentry (hydrate: falsestays declared-but-not-pulled, never fetched), and publishes the resolved catalogue for the new endpoint.OSM_BAKE_REGION, when set, still wins outright as the active region even if absent from the catalogue or declaredhydrate: falsethere — the pre-existing escape hatch is unchanged, includingbake_region()'s validate-or-fall-back-to-default behavior on an invalid value.[a-z0-9-], ≤64 bytes — guards the S3 key/path join against traversal) now applies to every catalogue-sourced name too, not only the env-var path.GET /api/osm/regions: the map-menu data source (name, hydrated, active per region). Read-only discovery — this deployment still serves exactly one active region at a time (open_slab()'s mmap is process-global); switching which one is active still needs the operator to fliphydrate: true(or setOSM_BAKE_REGION) and restart. That is a narrower claim than "hot-swap without restart," which this change does not attempt.Test plan
osm_region_catalogue.rs(TDD):parse_catalogue_yamlprojects name/hydrate correctly, keepshydrate: falseentries (does not drop or promote them), rejects malformed YAML, propagates the shared parser's own duplicate-name validation;pick_activeprefers the env override even when absent from the catalogue or over ahydrate: trueentry, falls back to the firsthydrate: trueentry, returnsNoneon an all-falsecatalogue with no override (paired negative case); the publish/snapshotOnceLockround-trips and a second publish is a silent no-op rather than a panic.cargo check -p cockpit-server --bin q2-cockpit --tests: clean, 0 errors, 0 new warnings (34 pre-existing baseline warnings unchanged).cargo test/nextestfor this crate could not be run to completion in this session: theq2-cockpittest binary transitively links nearly the entire q2 workspace (lance/arrow/datafusion/geo/aws-sdk/opendal/tree-sitter/wasmtime/mlua/…), and the final link step exceeded this container's disk allowance on repeated attempts (ENOSPC, then a linker SIGBUS), even immediately after a fulltarget/clean. This is the same environment limitation documented on q2#141 for the same binary, unrelated to this change. Reported honestly: type/borrow-check-verified, not executed-test-verified.🤖 Generated with Claude Code
Generated by Claude Code