Skip to content

Drop --scope from BrokerCli method signatures. - #1243

Open
floitsch wants to merge 2 commits into
floitsch/build-artemis-service.s-new.070from
floitsch/build-artemis-service.s-new.080
Open

Drop --scope from BrokerCli method signatures.#1243
floitsch wants to merge 2 commits into
floitsch/build-artemis-service.s-new.070from
floitsch/build-artemis-service.s-new.080

Conversation

@floitsch

Copy link
Copy Markdown
Member

Each BrokerCli instance is constructed with a server-config that carries its own scope (PR #1241). The data-plane methods now read it off server-config_.scope internally instead of taking it per call.

  • BrokerCli interface: 9 methods lose --scope/Scope.
  • BrokerCliHttp impl: each method resolves organization-id via server-config_.scope.as-uuid.
  • BrokerCliSupabase: when the broker-cli wraps a Supabase config, the inner http-config is now built with the same scope.
  • Broker class: drops --scope=server-config.scope from every BrokerCli call (cleaner; the broker connection already knows its scope).
  • upload-image previously passed --scope=(Scope.from-organization-id device.organization-id) — collapses to the broker's scope. device.organization-id is always equal to the broker's scope today (each device in this fleet belongs to this fleet's org), so the distinction was theoretical. Documented why we dropped it.
  • Tests: tests/broker.toit attaches TEST-SCOPE to the test ServerConfigs (HTTP construction; Supabase via 'with --scope'); tests/{broker,pod-registry}-test drop --scope=TEST-SCOPE from each BrokerCli call.

Each BrokerCli instance is constructed with a server-config that carries
its own scope (PR #1241). The data-plane methods now read it off
server-config_.scope internally instead of taking it per call.

- BrokerCli interface: 9 methods lose --scope/Scope.
- BrokerCliHttp impl: each method resolves organization-id via
  server-config_.scope.as-uuid.
- BrokerCliSupabase: when the broker-cli wraps a Supabase config, the
  inner http-config is now built with the same scope.
- Broker class: drops --scope=server-config.scope from every BrokerCli
  call (cleaner; the broker connection already knows its scope).
- upload-image previously passed --scope=(Scope.from-organization-id
  device.organization-id) — collapses to the broker's scope.
  device.organization-id is always equal to the broker's scope today
  (each device in this fleet belongs to this fleet's org), so the
  distinction was theoretical. Documented why we dropped it.
- Tests: tests/broker.toit attaches TEST-SCOPE to the test
  ServerConfigs (HTTP construction; Supabase via 'with --scope');
  tests/{broker,pod-registry}-test drop --scope=TEST-SCOPE from each
  BrokerCli call.
@floitsch
floitsch force-pushed the floitsch/build-artemis-service.s-new.080 branch from 7210530 to 1f386ba Compare May 23, 2026 13:09
Scope no longer exposes 'as-uuid'. Instead it wraps any
JSON-encodable value (string, Map, etc.) and exposes only:
- Scope.from-json: build a scope from a JSON-encodable value.
- Scope.from-organization-id: convenience for today's UUID case (the
  UUID is stored as a string internally).
- scope.to-json: read back the wrapped JSON value.

Each backend that consumes a scope knows the shape its auth provider
issues and interprets to-json accordingly. There is no shared
'to-key' or 'to-string' indirection — backends derive whatever stable
representation they need (URL segment, cache key, ...) from the JSON
form directly.

Callers updated:
- HTTP broker impl: uses scope.to-json directly as a URL path segment;
  variable renamed from 'organization-id' to 'scope'.
- cache.toit: cache keys interpolate scope.to-json.
- ServerConfig.{from,to}-json: serializes/parses scope as an arbitrary
  JSON value rather than a UUID string.
- fleet.toit: FleetFile/Fleet.organization-id getter parses
  broker-scope.to-json as a Uuid (the auth-call sites are still
  org-id concrete).
@floitsch
floitsch force-pushed the floitsch/build-artemis-service.s-new.080 branch from 4d99838 to b64d085 Compare May 23, 2026 13:31
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