---
id: w5/m10/t001
title: Fix `local-bex` stub — multi-service store, per-id resolvers, unknown id → null
worker: worker5
status: done
estimate: 45m
depends_on: []
---

## Objective

Replace the stub's single hardcoded `SERVICE` (echoed for any requested id — `server(id: "nightly-report")` returns `eden-cms-v2`'s whole object with only the id swapped, `local-bex.mjs:194`) with a small keyed store of 2–3 distinct services, per-id resolution in every resolver that takes an id, and `null` for unknown ids — so the stub can never again fabricate a service.

## Context

- `dashboard/scripts/local-bex.mjs` — the offending resolver: `return { server: { ...SERVICE, id: variables.id ?? SERVICE.id } }`. The same single-service assumption leaks into `customDomains`, `envVarKeys`, logs (`INSTANCES`, `resource` label), and the SSE tail.
- Root cause of the 2026-07-09 phantom-service report: `/services/nightly-report` rendered `www.eden-cms.com` custom domains.
- Keep the stub dependency-free and tiny (it's a dev tool, per its header comment); a plain `SERVICES = { id: {...} }` map suffices. Give the second service a different shape (e.g. no custom domains, 1 replica) so cross-service bleed is visually obvious.

## Steps

1. Convert `SERVICE`/`CUSTOM_DOMAINS`/`INSTANCES` into a per-service keyed store (2–3 services with distinct names/urls/domains/instances).
2. Make `server`, `service`, `customDomains`, env, and log resolvers look up by `variables.id` and return `null` (or empty) for unknown ids.
3. Scope the SSE tail's synthetic lines to the requested resource.

## Files

- `dashboard/scripts/local-bex.mjs`

## Acceptance criteria

- [ ] `server(id: "eden-cms-v2")` and `server(id: <second-service>)` return distinct objects; each service's domains/logs are its own.
- [ ] `server(id: "nightly-report")` (unknown) returns `null` — no field borrowed from another service.
- [ ] Stub stays zero-dependency and starts via `node scripts/local-bex.mjs`.

## Out of scope

- Dashboard handling of the `null` (t002).
- Any real-backend change.
