Repository navigation
serve --adapter fastly should reconcile local provisioning and typed config before starting Viceroy #390
Description
Problem
A generated typed app CLI currently needs this manual sequence for Fastly local development:
ts config push --adapter fastly --local --yes
ts serve --adapter fastlyThe first command is easy to miss. It also has to be repeated after trusted-server.toml changes. Without it, fastly.toml has missing or stale [local_server.config_stores.<store>.contents] data, so Viceroy starts without the current typed app config.
This makes serve unreliable on a fresh checkout and lets developers test stale configuration without realizing it.
The current code paths explain the gap:
run_servedispatchesAdapterAction::Serveimmediately.- Fastly
serveshells out tofastly compute serve. config push --localis the code that writes the typed blob into Fastly's local-server config-store tables.- The typed push already compares the blob-envelope SHA and skips an equal value, so we do not need a second timestamp or cache file to detect changes.
Desired behavior
For a generated typed CLI, this should be enough:
ts serve --adapter fastlyBefore starting Viceroy, serve should reconcile the local state needed by that adapter:
- Ensure local adapter resources and generated manifests exist and match
edgezero.toml. - Validate and push the typed app config to the local emulator state when its content differs.
- Start the adapter's local server only after reconciliation succeeds.
The operation must stay local. It must not create or update Fastly account resources or require Fastly authentication.
Suggested shape
- Add a typed serve path such as
run_serve_typed::<C>, since the bundled untypededgezerobinary cannot serialize an application'sAppConfig<C>. - Update generated downstream CLIs to dispatch
servethrough that typed path. - Reuse the existing local config readback and envelope SHA comparison. Run reconciliation on every serve invocation and let the existing idempotency check decide whether a write is needed.
- Compose with
provision --localfrom feat: provision --local + gitignored adapter manifests + hardened path safety #287 once available, rather than adding separate Fastly-only bootstrap logic toserve. - Keep
run_serveusable for untyped callers. If it cannot reconcile typed config, its behavior and limitation should be explicit. - Treat local reconciliation as a preflight. If validation, provisioning, or config writeback fails, do not start Viceroy.
This can start with Fastly, but the boundary should allow other adapters to declare local prerequisites without putting provider-specific branching into the generated CLI.
Acceptance criteria
- On a freshly provisioned checkout,
ts serve --adapter fastlydoes not require a separatets config push --adapter fastly --localcommand. - Changing
trusted-server.tomland restartingserveupdates the Fastly local config-store entry before Viceroy starts. - Starting
servewith unchanged config uses the existing SHA equality check and does not rewrite the entry unnecessarily. - The preflight performs no Fastly management API operations and needs no Fastly login.
- A config validation or local writeback error exits before
fastly compute serveruns. - Generated typed CLIs use the typed serve path.
- Tests cover first run, changed config, unchanged config, and preflight failure.
- Local-development docs show
serveas the single command after initial project setup.
Related work
- feat: provision --local + gitignored adapter manifests + hardened path safety #287 adds
provision --localand generated local adapter manifests. - Epic: provision --local implementation #288 tracks that local-provisioning workstream.
- Section 7 — Scaffold + gitignore + run_serve (Tasks 32–35) #295 covers existing
run_serveenvironment-file loading, but not typed config reconciliation.
Activity