Add $schema versioning to fleet.json; carry scope per server entry.#1240
Open
floitsch wants to merge 3 commits into
Open
Add $schema versioning to fleet.json; carry scope per server entry.#1240floitsch wants to merge 3 commits into
floitsch wants to merge 3 commits into
Conversation
Adopts the pod-specification pattern (a $schema URL string identifies
the format) for the fleet file. The new on-disk shape:
{
"$schema": "https://toit.io/schemas/artemis/fleet/v2.json",
"id": ...,
"broker": { "ref": <broker-name>, "scope": <uuid> },
...
}
Replaces the legacy top-level "organization" UUID and bare-string
"broker" with a single "broker" object that nests its ref alongside
its scope. The scope is opaque to the fleet schema; for the current
Toit-hosted setup it happens to be the organization-id UUID stringified.
Future per-service backends (pod-store, fleet-store) get the same
nested shape with their own scopes.
Reader accepts both shapes:
- Files with "$schema" use the new layout.
- Files without it fall back to the legacy fields.
Writer always emits the new layout — any edit to an old fleet.json
upgrades it in place on next write.
In-memory model is unchanged: FleetFile still exposes
'organization-id' as a Uuid. Renaming that to a Scope-typed field is a
follow-up.
Tests:
- cmd-fleet-init-test and cmd-fleet-create-reference-test now read
fleet-json["broker"]["ref"] when looking up the broker name.
- fleet-root-test gains a back-compat case that downgrades the new
format to the legacy shape and exercises the reader.
Restructures the new fleet.json shape: the broker reference is again a
plain string referring to a server name, and each server entry carries
its own scope alongside its connection info:
{
"$schema": "...",
"broker": "<name>",
"servers": {
"<name>": { "type": ..., "host": ..., "scope": "<blob>" }
}
}
Migration-from servers automatically carry their own scope without
needing a parallel scope map at the top level. Picking a different
broker is just changing the 'broker' string.
The reader pulls the scope field out of each server entry before
handing the rest to ServerConfig.from-json, so ServerConfig stays
scope-free in memory. For now only the broker's scope is actually used
(it populates organization-id); scopes on other entries are read but
ignored. They become load-bearing once we track per-server scope in
memory.
The writer emits the new shape with the fleet's single organization-id
copied into every server entry. The in-memory FleetFile is unchanged.
Tests reverted to reading fleet-json["broker"] as a string and the
back-compat downgrade in fleet-root-test now strips the scope field
from server entries (and moves the broker's scope back to a top-level
'organization').
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopts the pod-specification
$schemapattern for the fleet file, andintroduces the per-service
scopeconcept by attaching it to eachserver entry. This is the on-disk half of the org-agnostic data-plane
work; the in-memory model still exposes a single
organization-idandgets a follow-up.
New on-disk shape
{ "$schema": "https://toit.io/schemas/artemis/fleet/v2.json", "id": "<uuid>", "broker": "<server-name>", "groups": { ... }, "migrating-from": [...], "servers": { "<server-name>": { "type": "supabase", "host": "...", "scope": "<blob>" } }, "recovery-urls": [...] }The legacy top-level
"organization"UUID is gone. The brokerreference stays a plain string. Each server entry carries its own
opaque
scopealongside its connection info — the scope is unread byServerConfig.from-json(the reader pre-strips it).For the current Toit-hosted setup,
scopeis the organization-id UUIDstringified. Future per-service backends (pod-store, fleet-store) will
get their own scope under their own server entry without any schema
churn.
Why scope-on-server (rather than nested under
broker)Migrating-from servers automatically carry their own scope without
needing a parallel scope map at the top level. Picking a different
broker is just changing the
brokerstring. Adding new services(
pod-store: "<name>", etc.) doesn't require restructuring thebroker block. The cost is conceptual: connection info and authorization
info now live in the same object — see the discussion in REFACTOR.md.
Compatibility
$schemause the newlayout (scope is read from
servers[broker-name].scope); fileswithout it fall back to the legacy top-level
organization.organization-idinto every server entry'sscopefield for now.Any edit to an old fleet.json upgrades it in place on next write.
FleetFile.organization-idis unchanged in shape andtype; renaming it to a
Scope-typed field is a follow-up. Scopes onnon-broker server entries are read but ignored — they become
load-bearing once the in-memory model tracks per-server scope.
Tests
fleet-root-testgains a back-compat case that downgrades the newfile to the legacy shape (strips
$schemaandscopefields, movesthe broker's scope back to a top-level
organization) and exercisesthe reader.
cmd-fleet-init-testandcmd-fleet-create-reference-testkeepreading
fleet-json[\"broker\"]as a string.make test— 82/82 passedmake test-supabase— 32/32 passed (rerun pending after this PR'sscope-on-server amendment)
The schema URL is a placeholder; it goes live when we publish the
schema JSON to
public/schemas/fleet/alongside the pod-spec schemas.