@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 63 lines 2.76 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import type { ProviderService } from "alchemy/Provider";
5 import * as Effect from "effect/Effect";
6
7 const { test } = Test.make({ providers: AWS.providers() });
8
9 /**
10 * Dual-mode AWS providers whose LOCAL variant is a process on this machine
11 * (a dev server), not the floci emulator. They have no emulator API for a
12 * binding client to route to, so `resolveLocalDataPlane` deliberately falls
13 * back to the real cloud for them (see Provider.ts). Every other AWS dual
14 * runs on floci and must say so.
15 */
16 const PROCESS_HOSTED = new Set(["Command.Dev", "AWS.Website.Server", "Website.Server"]);
17
18 /**
19 * Every floci-backed dual provider must declare the emulator as its
20 * {@link ProviderService.localDataPlane}. A dual that doesn't is a silent
21 * hole in `alchemy dev`: a deploy-time binding client bound to it (an
22 * Action body, a plan-time `execute`) is left unrouted — a single-resource
23 * binding such as `InvokeFunction(fn)` then targets the real cloud, and a
24 * binding spanning a declaring sibling (`RunTask(cluster, task)`) dies with
25 * "Binding client spans mixed data planes" (the reported bug; its e2e is
26 * test/AWS/Local/Actions.local.test.ts).
27 *
28 * `flociDual` declares it for you; the hand-written floci providers
29 * (`ProviderLayer.dual` with a `Floci*Provider` local) have to say so
30 * explicitly — this walks the registry and pins that they all do.
31 */
32 test.provider(
33 "every floci-backed dual AWS provider declares its local data plane",
34 () =>
35 Effect.gen(function* () {
36 const context = yield* Effect.context<never>();
37 const missing: string[] = [];
38 let duals = 0;
39 for (const [key, value] of context.mapUnsafe) {
40 const entry = value as Partial<ProviderService> & {
41 kind?: string;
42 providers?: Record<string, ProviderService>;
43 };
44 // Providers live in context either as individual `Provider` tags or
45 // inside a `ProviderCollection` keyed by resource type.
46 const candidates: [string, Partial<ProviderService>][] =
47 entry.kind === "ProviderCollection" && entry.providers
48 ? Object.entries(entry.providers)
49 : typeof entry.reconcile === "function"
50 ? [[String(key), entry]]
51 : [];
52 for (const [type, service] of candidates) {
53 if (service.modes === undefined || PROCESS_HOSTED.has(type)) continue;
54 duals += 1;
55 if (service.localDataPlane === undefined) missing.push(type);
56 }
57 }
58 // Sanity: the registry was actually walked (hundreds of duals).
59 expect(duals).toBeGreaterThan(100);
60 expect(missing).toEqual([]);
61 }),
62 { tags: ["provider:aws", "local"] },
63 );