Skip to content

Point the develop chat at its deployment's NEMAR hosts - #481

Merged
neuromechanist merged 9 commits into
developfrom
feature/deployment-nemar-hosts
Sep 24, 2026
Merged

neuromechanist merged 9 commits into
developfrom
feature/deployment-nemar-hosts

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Closes #480. On test.nemar.org, the NEMAR chat talked to production NEMAR, which knows none of the datasets staging shows: staging's catalog is the exemplar fleet (xx0999NN). The production MCP answered describe_dataset(xx099906) with "not found in the public catalog", and zarr.nemar.org/xx099906/zarr/index.json is 404.

The develop deployment now reads NEMAR's staging hosts, the way the notebook site's develop build already does (ADR 0011). The decision is recorded as ADR 0013.

Changes

  • src/core/config/deployment.py: current_deployment() returns OSA_DEPLOYMENT when set. Otherwise it returns develop for the container mounted at /osa-dev, which is what deploy/auto-update-dev.sh already runs, and production for anything else. An unknown name is a startup error.
  • extensions.mcp_servers[].url, runtime.python.fetch_allow and runtime.python.prelude take one value or a {production, develop} map. A map must name both deployments, and every deployment's prelude is compiled at load.
  • McpServer.resolved_url is what the MCP client connects to. The public config response carries RuntimeConfig.for_deployment(...), one list and one prelude, so the widget and the runtime bundle are unchanged.
  • NEMAR, for develop: https://mcp-test.nemar.org/mcp and https://zarr-test.nemar.org/, plus a prelude that sets eegprep_lean.index.INDEX_URL_TEMPLATE to the staging host. That is the global read_index reads its URL from, and eegprep-lean has no other setting for it. The execute_code description names "NEMAR's Zarr host" rather than one hostname.
  • deploy/auto-update-dev.sh passes OSA_DEPLOYMENT=develop. The host's copy of the script only changes when someone updates it; until then, the /osa-dev mount decides.
  • ADR 0013, docs/community-browser-runtime.md ("Values per deployment"), and deploy/DEPLOYMENT_ARCHITECTURE.md.

Production is unchanged: every production value is the one it had.

Testing

  • tests/test_core/test_config/test_deployment.py (new):
    • the deployment rule, including /osa-dev/, /osa-dev2, OSA_DEPLOYMENT over the mount, and an unknown name;
    • both field shapes, and the refusals for a missing or unknown deployment;
    • the per-deployment prelude compile and length bound.
  • The config response returns each deployment's runtime from one registered config.
  • The MCP client connects to the develop URL on develop and never to the other deployment's.
  • NEMAR's own values for each deployment.
  • An offline check of the vendored eegprep-lean wheel's source: read_index still reads INDEX_URL_TEMPLATE at call time, so a re-vendored wheel that changed that fails a test instead of quietly sending the develop chat back to production.
  • 10 single-line mutations each fail these tests.
  • Full offline pytest: 2956 passed (test_version_shows_version deselected, the local-only test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434). ruff check and format.
  • After the develop deploy: the xx099906 walk-through on test.nemar.org.

mcp_servers[].url, runtime.python.fetch_allow and runtime.python.prelude
each take one value or a {production, develop} map (#480). The backend
is develop when OSA_DEPLOYMENT says so, or, unset, when mounted at
/osa-dev; the MCP client connects to the resolved URL and the public
config response carries the resolved runtime.

Tested: test_deployment.py (new), the router and MCP client tests; 10
single-line mutations each fail them; full offline pytest, 2956 passed.
test.nemar.org embeds the develop widget and shows only the exemplar
fleet, which production's MCP and Zarr host do not know. Develop now
reads mcp-test.nemar.org and zarr-test.nemar.org, and its prelude points
eegprep-lean's read_index at the staging host (#480).

Tested: test_nemar_runtime.py, test_nemar_mcp_wiring.py, and an offline
check of the vendored wheel that read_index reads the template global
at call time.
auto-update-dev.sh passes OSA_DEPLOYMENT=develop, which takes effect
when the host's copy is next updated; until then the /osa-dev mount
decides (#480).

Tested: shell change only; the fallback is covered by test_deployment.py.
Why per-deployment maps, how the backend knows its deployment, and the
eegprep-lean global the develop prelude relies on (#480).

Tested: docs only.
auto-update.sh and deploy.sh pass OSA_DEPLOYMENT for whichever deployment
ENVIRONMENT selects, and docker-compose.yml sets production. Production no
longer relies on the ROOT_PATH fallback, since both containers read one
shared .env and a stray ROOT_PATH=/osa-dev there would have sent production
readers to staging hosts. Review finding on #481.

Tested: pytest tests/test_deploy (runs each script's own selection block
under bash for dev and prod) and the offline suite.
CommunityConfigResponse rejects a runtime whose fetch_allow or prelude is
still a per-deployment map, so a caller that skips for_deployment fails on
the server instead of handing the widget a value it reads as no egress and
no prelude. Review finding on #481.

Tested: pytest tests/test_api/test_community_router.py; the validator
mutated off fails both new cases.
A map that both misses a deployment and names an unknown one now says both,
since {production, staging} is a typo for develop. A blank OSA_DEPLOYMENT
counts as unset, now pinned by a test. Both deployments' preludes are
tested for compilation, not only develop's. for_deployment's signature and
NOTEBOOK_ENVIRONMENTS are typed with the Deployment literal, clearing two
mypy errors in the new code. Review findings on #481.

Tested: pytest tests/test_core/test_config (a prelude check limited to
develop now fails a test).
The config comment and the module docstring named mcp.nemar.org as the
server for every deployment; develop now reads the staging one. Adds the
#480 changelog entry. Review findings on #481.

Tested: docs only; pytest tests/test_assistants passes.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review response

Two Sonnet reviews: code and error handling, and tests with documentation. Every finding is addressed.

Code and error handling

  • Production relied on the ROOT_PATH fallback, with a .env it shares with develop. deploy/auto-update.sh and deploy/deploy.sh now pass OSA_DEPLOYMENT for whichever deployment ENVIRONMENT selects, and deploy/docker-compose.yml sets production (c12519f). A new test runs each script's own selection block under bash for dev and prod. ADR 0013 and DEPLOYMENT_ARCHITECTURE.md say why production is named.
  • for_deployment was typed dict[str, T] against fields keyed by Deployment, and NOTEBOOK_ENVIRONMENTS was untyped: two mypy errors in the new code. Both are typed with the Deployment literal (44d2bf2). The five mypy errors left in those modules predate this PR.
  • The public response's runtime type allowed a map through. CommunityConfigResponse now refuses a runtime whose fetch_allow or prelude is still a map, so a caller that skips for_deployment fails on the server instead of handing the widget a value it reads as no egress (10521fd). Tested by validating a served payload with a map put back in; the validator mutated off fails both cases.

Tests and documentation

  • Only develop's prelude was tested for compilation; a check limited to develop survived. The test now runs for both deployments, and that mutant fails (44d2bf2).
  • A blank OSA_DEPLOYMENT counted as unset, but no test said so. Now pinned, and the docstring says why: an env file that references an unset host variable passes it blank.
  • A map with an unknown key and a missing one, {production, staging}, reported only the unknown key. The message now names both.
  • config.yaml's MCP comment and src/assistants/nemar/__init__.py named mcp.nemar.org for every deployment; both now say production (da2b164).
  • The CHANGELOG.md entry was missing; added under [Unreleased].

One reviewer ran git stash and popped another worktree's stash by mistake, then reset. I checked afterward: all four stash entries are still there, and the PR's worktree had lost nothing.

Gates: offline pytest 2968 passed. The one failure, tests/test_cli/test_main.py::TestVersionCommand::test_version_shows_version, is Rich color codes in this shell; it also fails on origin/develop and this PR does not touch it. ruff is clean.

test-data-lane.js and the browser harness read config.yaml directly and
handed the widget code a per-deployment map, which it reads as no prelude.
Both now resolve production's values, as the server does for a local run.
The data lane also boots the develop prelude in real Pyodide, which nothing
had run before: it checks that FetchTransport is the default and that
read_index points at zarr-test.nemar.org.

Tested: every Bun suite in test.yml's Frontend Tests job, the runtime
bundle check, and bun frontend/browser-harness/chrome.js (exit 0); removing
the develop prelude's INDEX_URL_TEMPLATE line fails the new check.
@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-deployment-nemar-hos-demo.osc.earth
Branch feature/deployment-nemar-hosts
Commit fb0db0f

This preview will be updated automatically when you push new commits.

@neuromechanist

Copy link
Copy Markdown
Member Author

Follow-up: the first CI run failed Frontend Tests, and the failure was mine. frontend/test-data-lane.js and frontend/browser-harness/serve.js read NEMAR's config.yaml directly, so they handed the widget code a per-deployment map, which it reads as no prelude. Both now resolve production's values, as the server does for a local run (9a12ac0). The data lane also boots the develop prelude in real Pyodide, which nothing had run before: it checks that FetchTransport is the default and that read_index points at zarr-test.nemar.org. Removing that prelude's staging line fails the new check. Every Bun suite in the Frontend Tests job and chrome.js pass locally, and CI is green at 9a12ac0.

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