Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Fix two config gaps that break a from-scratch Fly deployment (#4)

Joshua Franceefd41489c236
diff --git a/cli/src/config.ts b/cli/src/config.ts
index 38b0027ee..cd3602e91 100644
--- a/cli/src/config.ts
+++ b/cli/src/config.ts
@@ -200,6 +200,8 @@ export function sandboxCoreEnv(
if (violation) throw new CliError(violation.message, { clause: violation.clause });
env.FLY_SANDBOX_APP_NAME = sb.app;
env.FLY_BASE_IMAGE = sb.image;
+ const backend = sb.backend ?? (config.target === "fly" ? "sprites" : undefined);
+ if (backend) env.SANDBOX_BACKEND = backend;
}
for (const [k, v] of Object.entries(sb.env ?? {})) env[`FLY_RESIDENT_ENV_${k}`] = v;
for (const name of sb.secretEnv ?? []) {
diff --git a/cli/src/secrets.ts b/cli/src/secrets.ts
index ddac281cd..84fed6ee4 100644
--- a/cli/src/secrets.ts
+++ b/cli/src/secrets.ts
@@ -250,6 +250,20 @@ export const FIRST_PARTY_SECRET_SPECS: readonly SecretSpec[] = [
description: "Signing key shared with core for portal-bound user identity.",
generate: MINT_LOCALLY,
},
+ {
+ name: "PORTAL_IDENTITY_SECRET",
+ service: "web-ui",
+ required: true,
+ description: "Signing key shared with core for portal-bound user identity.",
+ generate: MINT_LOCALLY,
+ },
+ {
+ name: "PORTAL_IDENTITY_SECRET",
+ service: "admin",
+ required: true,
+ description: "Signing key shared with core for portal-bound user identity.",
+ generate: MINT_LOCALLY,
+ },
{
name: "CORE_SIGNING_SECRET",
service: "auth",
diff --git a/cli/test/secrets.test.ts b/cli/test/secrets.test.ts
index 7185ecbeb..f8b0228fa 100644
--- a/cli/test/secrets.test.ts
+++ b/cli/test/secrets.test.ts
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
-import type { QmConfig } from "../src/config.ts";
+import { sandboxCoreEnv, type QmConfig } from "../src/config.ts";
import {
FLY_TEMPLATE_ENV_DEFAULTS,
computedSecrets,
@@ -288,3 +288,47 @@ test("secretEnv for a service the config does not enable is ignored", () => {
const config = makeConfig({ secretEnv: { portal: { EXTRA_TOKEN: "EXTRA_TOKEN" } } });
assert.ok(!computedSecrets(config).some((s) => s.name === "EXTRA_TOKEN"));
});
+
+test("PORTAL_IDENTITY_SECRET reaches every service that signs or verifies a portal identity", () => {
+ const config = makeConfig({ services: ["core", "web-ui", "admin", "portal"] });
+ const secret = secretByName(config, "PORTAL_IDENTITY_SECRET");
+ assert.deepEqual(
+ [...secretDestinations(secret).keys()].sort(),
+ ["admin", "core", "portal", "web-ui"],
+ "core verifies with PORTAL_IDENTITY_SECRET, so a surface left without it signs with a different key and every request it makes is rejected",
+ );
+});
+
+test("a fly deployment tells core which sandbox substrate to boot", () => {
+ const config = makeConfig({
+ target: "fly",
+ sandbox: {
+ app: "acme-sb",
+ image: "registry.fly.io/acme-sb@sha256:1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a",
+ },
+ });
+ assert.equal(
+ sandboxCoreEnv(config).env.SANDBOX_BACKEND,
+ "sprites",
+ "core refuses to boot in production unless SANDBOX_BACKEND is set explicitly",
+ );
+});
+
+test("an explicit sandbox.backend wins, and non-fly targets keep their own default", () => {
+ const pinned = makeConfig({
+ target: "fly",
+ sandbox: {
+ app: "acme-sb",
+ backend: "sprites",
+ image: "registry.fly.io/acme-sb@sha256:2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b",
+ },
+ });
+ assert.equal(sandboxCoreEnv(pinned).env.SANDBOX_BACKEND, "sprites");
+ const docker = makeConfig({
+ sandbox: {
+ app: "acme-sb",
+ image: "registry.fly.io/acme-sb@sha256:3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c",
+ },
+ });
+ assert.equal(sandboxCoreEnv(docker).env.SANDBOX_BACKEND, undefined);
+});
diff --git a/deploy/core/fly.toml b/deploy/core/fly.toml
index 386a6ec02..d8beef05f 100644
--- a/deploy/core/fly.toml
+++ b/deploy/core/fly.toml
@@ -22,6 +22,7 @@ primary_region = "sjc"
FLY_ORG = "personal"
FLY_DEPLOY_BASE_IMAGE = "registry.fly.io/acme-sandboxes@sha256:1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
FLY_DEPLOY_APP_PREFIX = "qm-d"
+ SANDBOX_BACKEND = "sprites"
[deploy]
strategy = "bluegreen"