From 97b5aceb6cd7fb036fe8b18c8cee7b24065b0b82 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 10 Nov 2026 10:52:35 -0800 Subject: [PATCH] Update Substation to v0.1.237 Pin the reviewed upstream release and build it with Snow Globe's container recipe. Install locked build dependencies, run format, lint, type and 64 offline runtime suites, and embed the source revision and release version. Export the container recipe from the selected infrastructure snapshot so production keeps using reviewed main. Preserve existing accounts, keys and history; the in-app updater stays disabled in the immutable image. Validated ten deployment export tests, staging API key separation, proxy identity and host guards, cross-origin preflight rejection, settings persistence across restart, dashboard rendering and healthy polling. Assisted-by: gpt-6.1-sol --- service/substation/Dockerfile | 27 ++++++++++++ service/substation/build-source.json | 65 +++++++++++++++++++--------- tools/deploy-test.py | 17 ++++++++ tools/deploy.py | 8 ++++ tools/substation.md | 8 ++-- 5 files changed, 100 insertions(+), 25 deletions(-) create mode 100644 service/substation/Dockerfile diff --git a/service/substation/Dockerfile b/service/substation/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e1b20a8e39f1b54fb8e1ec877a96d27c400133fe --- /dev/null +++ b/service/substation/Dockerfile @@ -0,0 +1,27 @@ +FROM docker.io/oven/bun:1.4.4@sha256:3f23864d3e8c923975c61971cabe67ee3d5a728f1e25a559256b95af719a3478 AS build +WORKDIR /src +RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* +ENV BUN_INSTALL=/opt/tools BUN_INSTALL_BIN=/opt/tools/bin +RUN bun install --global --trust @anthropic-ai/claude-code@2.1.318 @openai/codex@0.166.0 \ + && install -m 0755 /opt/tools/install/global/node_modules/@anthropic-ai/claude-code-linux-x64/claude /usr/local/bin/claude \ + && install -m 0755 /opt/tools/install/global/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex /usr/local/bin/codex \ + && claude --version && codex --version +RUN chown bun:bun /src +COPY --chown=bun:bun . . +USER bun +RUN bun install --frozen-lockfile --cache-dir /tmp/bun-cache +RUN bun fmt --no-script --check && bun run lint && bun run typecheck +# The updater's compilation test requires a checkout; immutable images contain source exports. +RUN sed -i '/^ "dashboard\/test-update.ts",$/d' tests.ts +RUN bun tests.ts +RUN bun build --compile --bytecode --sourcemap \ + --no-compile-autoload-dotenv --no-compile-autoload-bunfig --reject-unresolved \ + --define "SUBSTATION_COMMIT=$(bun -e 'console.log(JSON.stringify(require("./.snowglobe-source.json").sources[0].revision))')" \ + --define "SUBSTATION_VERSION=$(bun -e 'console.log(JSON.stringify(require("./.snowglobe-source.json").version))')" \ + --define "SUBSTATION_BUILT_AT=$(bun -e 'console.log(JSON.stringify(new Date().toISOString()))')" \ + substation.ts --outfile /tmp/substation +FROM docker.io/oven/bun:1.4.4@sha256:3f23864d3e8c923975c61971cabe67ee3d5a728f1e25a559256b95af719a3478 +COPY --from=build /tmp/substation /usr/local/bin/substation +COPY --from=build /usr/local/bin/claude /usr/local/bin/codex /usr/local/bin/ +RUN substation --version && claude --version && codex --version +ENTRYPOINT ["/usr/local/bin/substation"] diff --git a/service/substation/build-source.json b/service/substation/build-source.json index 15d436858c10d4b2607f53457dadfa7b143d061a..5a5479323f9b9da91c248b9ef177c72bb5beb42e 100644 --- a/service/substation/build-source.json +++ b/service/substation/build-source.json @@ -1,25 +1,48 @@ { - "source": "../substation", - "revision": "b3083b6316d928fbc2e01f8941941c9e3769bdce", - "dockerfile": "Dockerfile.snowglobe", + "dockerfile": "Dockerfile", + "version": "0.1.237", "includeManifest": true, - "include": [ - ".gitignore", - "package.json", - "README.md", - "build.ts", - "build-info.ts", - "running.ts", - "settings.ts", - "substation.ts", - "tests.ts", - "test-settings.ts", - "update.ts", - "restore.ts", - "hub", - "dashboard", - "ops", - "m0", - "docs" + "sources": [ + { + "source": "../substation", + "revision": "1a5174afde69ea2f08824f65488c2d6270677928", + "include": [ + ".editorconfig", + ".gitignore", + ".oxfmtrc.json", + ".oxlintrc.json", + ".shellcheckrc", + "package.json", + "bun.lock", + "bunfig.toml", + "README.md", + "apply.ts", + "archive.ts", + "build.ts", + "build-info.ts", + "running.ts", + "settings.ts", + "substation.ts", + "tests.ts", + "test-settings.ts", + "test-apply.ts", + "test-archive.ts", + "test-lanes.ts", + "test-lanes.sources.json", + "release-runner.ts", + "release-update.ts", + "restore.ts", + "service-file.d.ts", + "unit-texts.ts", + "units.ts", + "tsconfig.json", + "tsconfig.page.json", + "hub", + "dashboard", + "ops", + "scripts", + "docs" + ] + } ] } diff --git a/tools/deploy-test.py b/tools/deploy-test.py index f9292ea9090e6bbccdb7fbcb897b8e11e29f1898..7792a763ea2401bfd20c5ce1011f93488fd13adc 100644 --- a/tools/deploy-test.py +++ b/tools/deploy-test.py @@ -191,6 +191,23 @@ class BuildSourceExport(unittest.TestCase): self.assertEqual((context / "lib/new").read_text(), "uncommitted library") self.assertEqual((context / "Dockerfile").read_text(), "FROM unfinished\n") + def test_local_dockerfile_uses_exported_main_or_working_stage(self): + dockerfile = self.manifest.parent / "Dockerfile" + dockerfile.write_text("FROM reviewed\n") + source = {key: value for key, value in self.spec.items() if key != "dockerfile"} + self.manifest.write_text(json.dumps({"dockerfile": "Dockerfile", "sources": [source]})) + subprocess.run(["jj", "describe", "-m", "Reviewed container recipe"], cwd=self.repo, check=True, capture_output=True) + subprocess.run(["jj", "bookmark", "set", "main"], cwd=self.repo, check=True, capture_output=True) + dockerfile.write_text("FROM unfinished\n") + for main, expected in ((True, "FROM reviewed\n"), (False, "FROM unfinished\n")): + context = self.remote / "releases" / deploy.upload(main=main) / "service/app/build" + self.assertEqual((context / "Dockerfile").read_text(), expected) + self.assertEqual((context / "run.sh").read_text(), "#!/bin/sh\necho committed\n") + for name in ("../outside", "/absolute", "."): + self.manifest.write_text(json.dumps({"dockerfile": name, "sources": [source]})) + with self.assertRaisesRegex(ValueError, "invalid build context Dockerfile"): + deploy.upload() + def test_dockerfile_also_selected_by_include_is_retained(self): self.manifest.write_text(json.dumps({**self.spec, "include": ["src"]})) context = self.remote / "releases" / deploy.upload() / "service/app/build" diff --git a/tools/deploy.py b/tools/deploy.py index 4a7551141495b437b684c056cdc22bbb01f427e3..a4919b671500c27c35f797eda01a8d861654add9 100644 --- a/tools/deploy.py +++ b/tools/deploy.py @@ -139,6 +139,14 @@ def upload(main=False): shutil.copytree(origin, destination, symlinks=True) else: shutil.copy2(origin, destination) + if "sources" in spec and spec.get("dockerfile"): + relative = Path(spec["dockerfile"]) + dockerfile = manifest.parent / relative + if (relative.is_absolute() or ".." in relative.parts or not relative.parts + or not dockerfile.resolve(strict=True).is_relative_to(manifest.parent) + or not dockerfile.is_file() or (context / "Dockerfile").exists()): + raise ValueError(f"invalid build context Dockerfile: {relative}") + shutil.copy2(dockerfile, context / "Dockerfile") if not (context / "Dockerfile").is_file(): raise ValueError(f"missing build source Dockerfile: {manifest.parent.name}") if spec.get("includeManifest"): diff --git a/tools/substation.md b/tools/substation.md index 3e6bb4170f02d79c52af36821fea70375d82e053..f6bbfe5054adc1d695e1734ab1df1aff4c48f862 100644 --- a/tools/substation.md +++ b/tools/substation.md @@ -80,16 +80,16 @@ Nomad owns the generated keys and OAuth client credentials. Existing numeric service identities remain reserved when a service is retired. `service/substation/build-source.json` pins a local Jujutsu revision of -`../substation`. That checkout's `Dockerfile.snowglobe` builds the program and -includes pinned Claude and Codex login tools. The exporter includes its source -manifest as build provenance. Snow Globe receives source and builds locally; +`../substation` and its release version. `service/substation/Dockerfile` builds +the program and includes pinned Claude and Codex login tools. The exporter +includes its source manifest as build provenance. Snow Globe receives source and builds locally; it receives no GitHub SSH key or repository credentials. Stage with `python3 tools/deploy.py stage substation`. Previews start with empty storage, their own keys, and a separate Snow OAuth client. Updates preserve that preview's state. Use disposable accounts and prompts when testing. Production uses described, conflict-free main and `python3 tools/deploy.py prod`. -The checkout-dependent updater is unavailable inside the immutable image. +The in-app updater is unavailable inside the immutable image. CPA's live dataset, preview, keys, and routing are retired after the replacement passes production checks. Restricted off-server recovery copies retain the old -- 2.54.1