Files
PaperClipAI/server/src/__tests__/instance-settings-managed-overlay.test.ts
T
DottaandClaude Opus 5.5 904c01d1a3 feat(mcp): graduate Assistant connections (MCP) out of experimental (#22015)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Assistant connections (MCP) let an outside assistant, or another
Paperclip instance, sign in as a person and use the `/mcp/paperclip`
endpoint
> - The feature was behind the experimental `enablePublicMcp` setting.
The setting was off by default and in practice off on Cloud stacks
> - Instance-to-instance work (one person's agent files a task on a
colleague's instance) fails when the receiving instance has the setting
off
> - This pull request moves the feature out of Experimental. It is now
always on, and a stored or Cloud-managed "off" value is ignored
> - The benefit is that every authenticated instance with a public URL,
including Cloud workspaces, accepts assistant connections with no setup
step

## Linked Issues or Issue Description

**Subsystem affected**
Public MCP (`server/src/services/public-mcp/`), instance settings,
Connectors → Assistant Connection (MCP) setup page, Experimental
settings page.

**Problem or motivation**
A remote MCP connector on one instance cannot use another instance's
`/mcp/paperclip` unless an admin on the other instance finds and turns
on an experimental toggle. On Cloud, the toggle is off and is managed by
the fleet. Instance-to-instance delegation therefore does not work by
default.

**Proposed solution**
Remove the gate. Keep `enablePublicMcp` only as a compatibility key, the
same way `enableApps` was graduated: old stored rows, PATCH bodies and
Cloud managed configs still parse, but the effective value is always
`true`.

**Alternatives considered**
An instance-admin kill switch that defaults ON. I did not keep one. Each
person already controls access: a connection exists only after that
person approves OAuth consent for one company, and the person or an
admin can revoke it. Deployment policy (authenticated mode and a valid
public URL) still decides whether the endpoint exists. A second switch
would add a state that can silently break instance-to-instance work
again. A schema migration was also not needed: the value lives in the
`experimental` JSON column, and the stored key becomes inert.

**Roadmap alignment**
Requested by the maintainer to enable instance-to-instance
communication.

## What Changed

- `packages/shared`: `enablePublicMcp` is a deprecated compatibility
key. The schema default is `true`. The feature catalog entry is
"Assistant connections (compatibility)" with both defaults `true`.
- `server` instance settings: normalization always returns
`enablePublicMcp: true`. The Cloud managed overlay skips the key, so a
fleet value of `false` cannot disable it. Removed the key from the Cloud
staging experimental-key list. Removed the client-mirror policy step
that ran only when the toggle changed.
- `server` public MCP: personal discovery, OAuth, tools, setup and event
delivery no longer read instance settings (`isEnabled()` returns `true`
for the personal endpoint without a DB read). Dot, Grok and Muse agent
connections keep their own experimental settings.
- `server` Cloud paths: the client-mirror sync, the hosted event
authority, the ingress-handoff expiry worker and the idle sleep proof
treat the front door as enabled. The warm-standby `503
workspace_unclaimed` behavior is unchanged.
- `server` Dot/Grok gates: they no longer also require
`enablePublicMcp`. Error messages no longer tell people to enable
Assistant connections.
- `ui`: removed the Experimental toggle, the "Enable assistant
connections / Open Experimental settings" block on the Assistant
Connection page, and the "Enable Assistant connections (MCP)" hint in
Dot setup. Updated the Dot and Grok copy.
- Storybook: deleted the Experimental-setting story and removed the
"enable the experiment" step from the journey and presenter.
- Docs: `doc/public-mcp.md` ("Enable an instance", "Start from
Connections", `GET /api/mcp/setup`), `doc/openai-dot-runner.md`,
`doc/idle-grok-dispatch.md`, and the agent-access map.
- Tests: new red/green tests for "enabled with no setting stored" and "a
stored or managed off value is ignored". Removed the tests for the
"disabled" behavior, which no longer exists.

## Verification

- Red/green: with the old source and the new tests,
`instance-settings-readonly.test.ts`,
`instance-settings-service.test.ts` and `public-mcp.test.ts` fail (4
failures, and the public-MCP suite fails in `beforeAll` because
`isEnabled()` was `false` with no setting stored). With the new source
they pass.
- `server`: `public-mcp.test.ts`, instance-settings (readonly, service,
managed overlay), `managed-config`, `cloud-event-authority`,
`events-work`, `dot-runner`, `dot-oauth-onboarding` and
`agent-runtime-assignments`. 354 passed.
- Cloud client-mirror lifecycle
(`client-mirror-lifecycle.postgres.test.ts`, skipped in CI) passed
against a local Postgres 17 with
`PAPERCLIP_MCP_SLEEP_TEST_DATABASE_URL`. 6/6, plus `events-work` 28/28.
- Idle and sleep: `idle-incoming-wake` (service and route),
`idle-deadline-proof`, `idle-incoming-wake-capability`,
`idle-sleep-proof`, `client-mirror-ack`, `recovery-deadline-acceptance`
and `idle-completed-history` pass. The warm-standby test now also
asserts that discovery after the claim does no SQL read.
- `ui`: `InstanceExperimentalSettings`, `AssistantConnection`,
`NewAgentDialog`, `NewAgent` and `ExternalAgentInviteDialog.muse` pass.
267 passed.
- Typecheck: `packages/shared`, `server` and `ui` pass. `node
scripts/check-maps.mjs` passes.
- `pnpm verify`: see the CI checks on this PR.
- After the deploy: confirm
`/.well-known/oauth-protected-resource/mcp/paperclip` and `/mcp/setup`
return 200 on paperclip.staging without changing any setting.

## Risks

- Behavior change: instances that had the setting off now serve
discovery, OAuth and `/mcp/paperclip`. Security invariants are
unchanged: the endpoint is still mounted only in authenticated mode with
a valid public URL, OAuth still needs a real signed-in user's consent,
local implicit board authority cannot approve, and revocation works the
same way.
- Cloud sleep: on a managed stack, the MCP sleep proof blocks sleep
until the client mirror publishes the tenant front door to Cloud. The
client-mirror sync runs at boot and does this once. Stacks that already
had the flag on use this path today. A stack whose Cloud connector
cannot publish the mirror would stay awake. Watch fleet sleep after the
deploy.
- Personal public-MCP requests now read instance settings one time less.
- Fleet admin: the Cloud fleet catalog can still show and set
`enablePublicMcp`. The value is ignored. Removing it from the fleet
catalog is a separate change in the Cloud repo.
- No migration. The `0354` trigger still compares the stored key. That
causes at most one extra connector-runtime invalidation if an old client
writes the key.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, test execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:42:36 -06:00

374 lines
18 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { Db } from "@paperclipai/db";
import { INSTANCE_FEATURE_CATALOG } from "@paperclipai/shared";
import {
applyManagedExperimentalOverlay,
instanceSettingsService,
normalizeExperimentalSettings,
} from "../services/instance-settings.js";
import { parseManagedConfigEnv } from "../services/managed-config.js";
import { evaluateExecutionAllowlist } from "../services/execution-allowlist.js";
const MANAGED_RAW = JSON.stringify({
v: 1,
mode: "cloud",
catalogVersion: "2026.720.0",
// enableApps is retained only for compatibility and must be ignored;
// enableStatusCards remains a live managed feature.
features: { enableApps: false, enableStatusCards: true },
plugins: { autoInstall: [] },
});
function managedEnv(raw: string | undefined = MANAGED_RAW) {
return { PAPERCLIP_MANAGED_CONFIG: raw };
}
/**
* Minimal stand-in for the drizzle query chains instanceSettingsService uses.
* Captures every `update().set()` payload so tests can assert what would be
* persisted.
*/
function stubDb(row: Record<string, unknown>) {
const persistedSets: Array<Record<string, unknown>> = [];
const db = {
transaction: (fn: (tx: Db) => Promise<unknown>) => fn(db),
select: () => ({ from: () => ({ where: () => Promise.resolve([row]) }) }),
insert: () => {
throw new Error("unexpected insert in test");
},
update: () => ({
set: (values: Record<string, unknown>) => {
persistedSets.push(values);
return { where: () => ({ returning: () => Promise.resolve([{ ...row, ...values }]) }) };
},
}),
} as unknown as Db;
return { db, persistedSets };
}
function settingsRow(experimental: Record<string, unknown>) {
return {
id: "row-1",
singletonKey: "default",
defaultEnvironmentId: null,
general: {},
experimental,
createdAt: new Date("2026-06-20T00:00:00.000Z"),
updatedAt: new Date("2026-06-20T00:00:00.000Z"),
};
}
describe("applyManagedExperimentalOverlay", () => {
it("is the identity with no managed config (self-hosted)", () => {
const experimental = normalizeExperimentalSettings({ enableApps: true });
const result = applyManagedExperimentalOverlay(experimental, null);
expect(result.experimental).toEqual(experimental);
expect(result.managedKeys).toEqual({});
});
it("ignores the retired Apps flag while overlaying live managed values", () => {
const config = parseManagedConfigEnv(managedEnv())!;
const stored = normalizeExperimentalSettings({ enableApps: true });
const { experimental, managedKeys } = applyManagedExperimentalOverlay(stored, config);
expect(experimental.enableApps).toBe(true);
// managed overlay > schema default
expect(experimental.enableStatusCards).toBe(true);
// unmanaged keys keep their stored/default values
expect(experimental.enableCases).toBe(false);
expect(managedKeys).toEqual({
enableStatusCards: { managed: true, managedBy: "paperclip-cloud" },
});
// input is not mutated
expect(stored.enableApps).toBe(true);
});
});
describe("instanceSettingsService managed overlay", () => {
it.each(["team.staging.paperclip.app", "team.paperclip.app"])(
"enables private Notebook through managed config without changing stored opt-out on %s",
async (primaryHost) => {
const row = settingsRow({ enablePaperclipNotebook: false });
const { db, persistedSets } = stubDb(row);
const service = instanceSettingsService(db, { runtimeEnv: {
PAPERCLIP_PRIMARY_HOST: primaryHost,
...managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enablePaperclipNotebook: true }, plugins: { autoInstall: [] },
})),
} });
expect(await service.getExperimental()).toMatchObject({
enablePaperclipNotebook: true,
managedKeys: { enablePaperclipNotebook: { managed: true, managedBy: "paperclip-cloud" } },
});
expect((await service.get()).experimental.enablePaperclipNotebook).toBe(true);
expect(persistedSets).toHaveLength(0);
expect(row.experimental).toEqual({ enablePaperclipNotebook: false });
expect((await instanceSettingsService(db, { runtimeEnv: {} }).getExperimental()).enablePaperclipNotebook).toBe(false);
},
);
it("persists an explicit self-hosted Notebook opt-in and disable across service recreation", async () => {
const row = settingsRow({});
const { db, persistedSets } = stubDb(row);
expect((await instanceSettingsService(db, { runtimeEnv: {} }).getExperimental()).enablePaperclipNotebook).toBe(false);
for (const enabled of [true, false]) {
const service = instanceSettingsService(db, { runtimeEnv: {} });
const updated = await service.updateExperimental({ enablePaperclipNotebook: enabled });
Object.assign(row, persistedSets.at(-1));
expect(updated.experimental.enablePaperclipNotebook).toBe(enabled);
expect((row.experimental as Record<string, unknown>).enablePaperclipNotebook).toBe(enabled);
expect((await instanceSettingsService(db, { runtimeEnv: {} }).getExperimental()).enablePaperclipNotebook).toBe(enabled);
}
});
it.each(["team.staging.paperclip.app", "team.paperclip.app", undefined])(
"enforces every Cloud-enabled flag over old tenant values on %s",
async (primaryHost) => {
const features = Object.fromEntries(Object.entries(INSTANCE_FEATURE_CATALOG)
.filter(([key, entry]) => entry.tier === "managed" && key !== "enableAgentChat")
.map(([key]) => [key, true]));
const stored = Object.fromEntries(Object.keys(features).map((key) => [key, false]));
const { db, persistedSets } = stubDb(settingsRow(stored));
const runtimeEnv = {
PAPERCLIP_PRIMARY_HOST: primaryHost,
...managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features, plugins: { autoInstall: [] },
})),
};
const service = instanceSettingsService(db, { runtimeEnv });
expect(await service.getExperimental()).toMatchObject(features);
expect((await service.get()).experimental).toMatchObject(features);
expect((await service.getExperimental()).managedKeys).toMatchObject(
Object.fromEntries(Object.keys(features)
.filter((key) => key !== "enableApps" && key !== "enableMcpAggregators" && key !== "enablePublicMcp")
.map((key) => [key, { managed: true, managedBy: "paperclip-cloud" }])),
);
for (const key of Object.keys(features).filter((key) => key !== "enablePublicMcp")) {
await expect(service.updateExperimental({ [key]: false })).rejects.toMatchObject({
status: 403,
details: { code: "settings_operator_managed" },
});
}
expect(persistedSets).toHaveLength(0);
expect(await instanceSettingsService(db, { runtimeEnv }).getExperimental()).toMatchObject(features);
},
);
it("accepts an old client's write of the retired assistant connections key while Cloud manages it", async () => {
const { db } = stubDb(settingsRow({}));
const runtimeEnv = managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enablePublicMcp: true, enableStatusCards: true }, plugins: { autoInstall: [] },
}));
const service = instanceSettingsService(db, { runtimeEnv });
const updated = await service.updateExperimental({ enablePublicMcp: false, enablePaperclipNotebook: true });
expect(updated.experimental).toMatchObject({ enablePublicMcp: true, enablePaperclipNotebook: true });
});
it("keeps sandbox policy enforced on staging after a tenant tries to disable it", async () => {
const row = settingsRow({ enableManagedSandboxOnly: false });
const { db, persistedSets } = stubDb(row);
const runtimeEnv = {
PAPERCLIP_PRIMARY_HOST: "team.staging.paperclip.app",
...managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enableManagedSandboxOnly: true }, plugins: { autoInstall: [] },
})),
};
const service = instanceSettingsService(db, { runtimeEnv });
await expect(service.updateExperimental({ enableManagedSandboxOnly: false })).rejects.toMatchObject({ status: 403 });
expect(persistedSets).toHaveLength(0);
const restored = await instanceSettingsService(db, { runtimeEnv }).getExperimental();
for (const experimental of [await service.getExperimental(), restored]) {
expect(experimental).toMatchObject({
enableManagedSandboxOnly: true,
managedKeys: { enableManagedSandboxOnly: { managed: true, managedBy: "paperclip-cloud" } },
});
expect(evaluateExecutionAllowlist(
{ managedSandboxOnly: experimental.enableManagedSandboxOnly },
{ driver: "local", provider: null },
)).toMatchObject({ allowed: false, deniedDriver: "local" });
}
});
it("lets staging override disabled defaults while keeping Cloud-enabled features managed", async () => {
const row = settingsRow({});
const { db, persistedSets } = stubDb(row);
const runtimeEnv = {
...managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enableStatusCards: true, enableChatConnectors: false, enableNativeRunner: true },
plugins: { autoInstall: [] },
})),
PAPERCLIP_PRIMARY_HOST: "team.staging.paperclip.app",
};
const service = instanceSettingsService(db, { runtimeEnv });
const managedKeys = {
enableStatusCards: { managed: true, managedBy: "paperclip-cloud" },
enableNativeRunner: { managed: true, managedBy: "paperclip-cloud" },
};
expect(await service.getExperimental()).toMatchObject({
enableStatusCards: true, enableChatConnectors: false, enableNativeRunner: true, managedKeys,
});
expect(persistedSets).toHaveLength(0);
for (const enabled of [true, false]) {
const updated = await service.updateExperimental({ enableChatConnectors: enabled });
Object.assign(row, persistedSets.at(-1));
const expected = {
enableStatusCards: true, enableChatConnectors: enabled, enableNativeRunner: true, managedKeys,
};
expect(updated.experimental).toMatchObject(expected);
const restored = instanceSettingsService(db, { runtimeEnv });
expect(await restored.getExperimental()).toMatchObject(expected);
expect((await restored.get()).experimental).toMatchObject(expected);
expect(row.experimental).not.toHaveProperty("managedKeys");
expect(row.experimental).not.toHaveProperty("enableStatusCards");
}
expect((await service.updateExperimental({ enableNativeRunner: true })).experimental.enableNativeRunner).toBe(true);
const changedDefaults = instanceSettingsService(db, { runtimeEnv: {
...runtimeEnv,
PAPERCLIP_MANAGED_CONFIG: JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enableStatusCards: false, enableChatConnectors: true, enableNativeRunner: true },
plugins: { autoInstall: [] },
}),
} });
expect(await changedDefaults.getExperimental()).toMatchObject({
enableStatusCards: false, enableChatConnectors: true, enableNativeRunner: true,
});
const production = instanceSettingsService(db, { runtimeEnv: { ...runtimeEnv, PAPERCLIP_PRIMARY_HOST: "team.paperclip.app" } });
expect(await production.getExperimental()).toMatchObject({
enableChatConnectors: false, enableNativeRunner: true,
managedKeys: { enableChatConnectors: { managed: true }, enableNativeRunner: { managed: true } },
});
});
it("preserves Cloud owner access policy on staging", async () => {
const { db } = stubDb(settingsRow({ enableOwnerInstanceAdmin: false }));
const service = instanceSettingsService(db, { runtimeEnv: {
PAPERCLIP_PRIMARY_HOST: "team.staging.paperclip.app",
...managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test",
features: { enableOwnerInstanceAdmin: true }, plugins: { autoInstall: [] },
})),
} });
expect(await service.getExperimental()).toMatchObject({
enableOwnerInstanceAdmin: true,
managedKeys: { enableOwnerInstanceAdmin: { managed: true, managedBy: "paperclip-cloud" } },
});
await expect(service.updateExperimental({ enableOwnerInstanceAdmin: false })).rejects.toMatchObject({ status: 403 });
});
it.each([{}, { enableMcpAggregators: false }])("keeps aggregators on with legacy stored and managed values: %j", async (stored) => {
const { db } = stubDb(settingsRow({ ...stored, enableChatConnectors: true }));
const service = instanceSettingsService(db, { runtimeEnv: managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "legacy", features: { enableMcpAggregators: false }, plugins: { autoInstall: [] },
})) });
expect(await service.getExperimental()).toMatchObject({ enableMcpAggregators: true, enableChatConnectors: true, managedKeys: {} });
expect(await service.updateExperimental({ enableMcpAggregators: false })).toMatchObject({ experimental: { enableMcpAggregators: true, enableChatConnectors: true } });
});
it("persists chat connector opt-in and reads it back after service reconstruction", async () => {
const row = settingsRow({});
const { db, persistedSets } = stubDb(row);
const service = instanceSettingsService(db, { runtimeEnv: {} });
expect((await service.getExperimental()).enableChatConnectors).toBe(false);
for (const enabled of [true, false]) {
const updated = await service.updateExperimental({ enableChatConnectors: enabled });
Object.assign(row, persistedSets.at(-1));
expect(updated.experimental.enableChatConnectors).toBe(enabled);
const restored = await instanceSettingsService(db, { runtimeEnv: {} }).getExperimental();
expect(restored).toMatchObject({ enableApps: true, enableChatConnectors: enabled });
}
});
it("overlays the managed chat connector gate without changing stored data", async () => {
const { db, persistedSets } = stubDb(settingsRow({ enableChatConnectors: true }));
const service = instanceSettingsService(db, { runtimeEnv: managedEnv(JSON.stringify({
v: 1, mode: "cloud", catalogVersion: "test", features: { enableChatConnectors: false }, plugins: { autoInstall: [] },
})) });
expect(await service.getExperimental()).toMatchObject({
enableChatConnectors: false,
managedKeys: { enableChatConnectors: { managed: true, managedBy: "paperclip-cloud" } },
});
expect(persistedSets).toHaveLength(0);
});
it("fails closed at construction on a malformed managed config", () => {
const { db } = stubDb(settingsRow({}));
expect(() => instanceSettingsService(db, { runtimeEnv: managedEnv("{bad") })).toThrow(
/PAPERCLIP_MANAGED_CONFIG is not valid JSON/,
);
});
it("overlays managed values on getExperimental and exposes managedKeys", async () => {
const { db } = stubDb(settingsRow({ enableApps: true }));
const svc = instanceSettingsService(db, { runtimeEnv: managedEnv() });
const experimental = await svc.getExperimental();
expect(experimental.enableApps).toBe(true);
expect(experimental.enableStatusCards).toBe(true);
expect(experimental.managedKeys).toEqual({
enableStatusCards: { managed: true, managedBy: "paperclip-cloud" },
});
});
it("overlays managed values on get()", async () => {
const { db } = stubDb(settingsRow({ enableApps: true }));
const svc = instanceSettingsService(db, { runtimeEnv: managedEnv() });
const settings = await svc.get();
expect(settings.experimental.enableApps).toBe(true);
expect(settings.experimental.managedKeys?.enableApps).toBeUndefined();
});
it("leaves the self-hosted read path unchanged (no managedKeys field)", async () => {
const { db } = stubDb(settingsRow({ enableApps: true }));
const svc = instanceSettingsService(db, { runtimeEnv: {} });
const experimental = await svc.getExperimental();
expect(experimental.enableApps).toBe(true);
expect(Object.prototype.hasOwnProperty.call(experimental, "managedKeys")).toBe(false);
expect(experimental).toEqual(normalizeExperimentalSettings({ enableApps: true }));
const settings = await svc.get();
expect(Object.prototype.hasOwnProperty.call(settings.experimental, "managedKeys")).toBe(false);
});
it("never persists the overlay: updates write stored values, responses show managed ones", async () => {
const { db, persistedSets } = stubDb(settingsRow({ enableApps: true }));
const svc = instanceSettingsService(db, { runtimeEnv: managedEnv() });
const updated = await svc.updateExperimental({ enableCases: true });
expect(persistedSets).toHaveLength(1);
const persisted = persistedSets[0]!.experimental as Record<string, unknown>;
// The retired compatibility key normalizes on, independent of the
// managed document's historical value.
expect(persisted.enableApps).toBe(true);
// The overlay-added value is not written.
expect(persisted.enableStatusCards).toBe(false);
expect(persisted.enableCases).toBe(true);
expect(persisted).not.toHaveProperty("managedKeys");
// The response still reflects the overlay.
expect(updated.experimental.enableApps).toBe(true);
expect(updated.experimental.enableStatusCards).toBe(true);
expect(updated.experimental.managedKeys?.enableApps).toBeUndefined();
});
it("does not let managed metadata leak into self-hosted writes", async () => {
const { db, persistedSets } = stubDb(settingsRow({}));
const svc = instanceSettingsService(db, { runtimeEnv: {} });
const updated = await svc.updateExperimental({ enableCases: true });
expect(persistedSets).toHaveLength(1);
expect(persistedSets[0]!.experimental).not.toHaveProperty("managedKeys");
expect(Object.prototype.hasOwnProperty.call(updated.experimental, "managedKeys")).toBe(false);
});
});