refactor: layer variables are named layer or layerXyz (#16282)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-10-05 18:39:51 -07:00
1 parent 4df84a7d03
commit ecfdda5fa8
401 files changed
+7338 -7418

No files matched your search

@@ -54,7 +54,7 @@ const newerServerStream = Effect.gen(function* () {
];
});
const serving = (events: ReadonlyArray<unknown>) =>
const layerServing = (events: ReadonlyArray<unknown>) =>
Layer.succeed(
HttpClient.HttpClient,
HttpClient.make((request) =>
@@ -75,7 +75,7 @@ const connect = Effect.gen(function* () {
});
/** Sends `events`, then keeps the connection open without another byte, like a frozen server. */
const servingThenSilent = (events: ReadonlyArray<unknown>) =>
const layerServingThenSilent = (events: ReadonlyArray<unknown>) =>
Layer.succeed(
HttpClient.HttpClient,
HttpClient.make((request) =>
@@ -103,7 +103,9 @@ describe("OpenCode2Client events", () => {
const { events } = yield* connect.pipe(
Effect.provide(
OpenCode2Client.layer.pipe(
Layer.provide(servingThenSilent([{ id: "evt_1", type: "server.connected", data: {} }])),
Layer.provide(
layerServingThenSilent([{ id: "evt_1", type: "server.connected", data: {} }]),
),
),
),
);
@@ -124,7 +126,7 @@ describe("OpenCode2Client events", () => {
Effect.provide(
OpenCode2Client.layer.pipe(
Layer.provide(
serving([
layerServing([
{
id: "evt_1",
created: 1,
@@ -167,7 +169,7 @@ describe("OpenCode2Client events", () => {
Effect.gen(function* () {
const events = yield* newerServerStream;
const { events: subscribe } = yield* connect.pipe(
Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(serving(events)))),
Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(layerServing(events)))),
);
const types = yield* (yield* subscribe).pipe(
Stream.map((event) => event.type),
@@ -185,7 +187,7 @@ describe("OpenCode2Client events", () => {
Effect.gen(function* () {
const events = yield* newerServerStream;
const { client } = yield* connect.pipe(
Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(serving(events)))),
Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(layerServing(events)))),
);
const failure = yield* client.event.subscribe().pipe(Stream.runDrain, Effect.flip);
assert.strictEqual(failure._tag, "ClientError");
@@ -12,7 +12,7 @@ const INFO_BODY = '{"version":"2.0.18","pid":4242,"urls":[],"paths":{"tmp":"/tmp
/** Sends one request through the client and returns the Authorization header it carried. */
const authorizationFor = (password: string | Redacted.Redacted) => {
const seen: Array<string | undefined> = [];
const capturing = Layer.succeed(
const layerCapturing = Layer.succeed(
HttpClient.HttpClient,
HttpClient.make((request) =>
Effect.sync(() => {
@@ -29,7 +29,7 @@ const authorizationFor = (password: string | Redacted.Redacted) => {
const { client } = yield* opencode.connect({ baseUrl: "http://127.0.0.1:4096", password });
yield* client.server.info();
return seen[0];
}).pipe(Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(capturing))));
}).pipe(Effect.provide(OpenCode2Client.layer.pipe(Layer.provide(layerCapturing))));
};
const utf8Basic = (password: string) =>
@@ -229,7 +229,7 @@ describe.runIf(binaryPath !== undefined)("OpenCode2Server live", () => {
Effect.provide(
Layer.mergeAll(
OpenCode2Client.layer,
OpenCodeRuntime.OpenCodeRuntimeLive.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
OpenCodeRuntime.layer.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer))),
),
),
@@ -27,7 +27,7 @@ const INFO_BODY =
const UNAUTHORIZED_BODY = '{"_tag":"UnauthorizedError","message":"Authentication required"}';
const SPA_BODY = "<!doctype html><html><head><title>OpenCode</title></head></html>";
const serverReplying = (reply: {
const layerServerReplying = (reply: {
readonly status: number;
readonly contentType?: string;
readonly body: string;
@@ -58,7 +58,7 @@ describe("OpenCode2Server.verifyServer", () => {
it.effect("returns the version of an authenticated OpenCode 2 server", () =>
Effect.gen(function* () {
const version = yield* verify(
serverReplying({ status: 200, contentType: "application/json", body: INFO_BODY }),
layerServerReplying({ status: 200, contentType: "application/json", body: INFO_BODY }),
);
assert.strictEqual(version, "2.0.18");
}),
@@ -67,7 +67,11 @@ describe("OpenCode2Server.verifyServer", () => {
it.effect("reports a rejected password, not a wrong server", () =>
Effect.gen(function* () {
const error = yield* verify(
serverReplying({ status: 401, contentType: "application/json", body: UNAUTHORIZED_BODY }),
layerServerReplying({
status: 401,
contentType: "application/json",
body: UNAUTHORIZED_BODY,
}),
).pipe(Effect.flip);
assert.include(error.detail, "rejected the server password");
}),
@@ -76,7 +80,7 @@ describe("OpenCode2Server.verifyServer", () => {
// 1.x rejects a wrong password with an empty 401, which the client cannot decode.
it.effect("reports an empty-body 401 as a rejected password", () =>
Effect.gen(function* () {
const error = yield* verify(serverReplying({ status: 401, body: "" })).pipe(Effect.flip);
const error = yield* verify(layerServerReplying({ status: 401, body: "" })).pipe(Effect.flip);
assert.include(error.detail, "rejected the server password");
}),
);
@@ -85,7 +89,7 @@ describe("OpenCode2Server.verifyServer", () => {
Effect.gen(function* () {
for (const status of [500, 502]) {
const error = yield* verify(
serverReplying({ status, contentType: "text/plain", body: "upstream failed" }),
layerServerReplying({ status, contentType: "text/plain", body: "upstream failed" }),
).pipe(Effect.flip);
assert.include(error.detail, `returned HTTP ${status}`);
}
@@ -96,7 +100,7 @@ describe("OpenCode2Server.verifyServer", () => {
it.effect("rejects a server that answers with the web UI's HTML", () =>
Effect.gen(function* () {
const error = yield* verify(
serverReplying({ status: 200, contentType: "text/html", body: SPA_BODY }),
layerServerReplying({ status: 200, contentType: "text/html", body: SPA_BODY }),
).pipe(Effect.flip);
assert.include(error.detail, "is not an OpenCode 2 server");
}),
@@ -129,24 +133,26 @@ describe("OpenCode2Server error details", () => {
Effect.provide(
Layer.mergeAll(
OpenCode2Client.layer.pipe(Layer.provide(httpClient)),
OpenCodeRuntime.OpenCodeRuntimeLive.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
OpenCodeRuntime.layer.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
).pipe(Layer.provideMerge(NodeServices.layer)),
),
);
it.effect("never include the server URL", () =>
Effect.gen(function* () {
const hanging = Layer.succeed(
const layerHanging = Layer.succeed(
HttpClient.HttpClient,
HttpClient.make(() => Effect.never),
);
const timedOut = yield* detailFor(hanging).pipe(Effect.forkChild);
const timedOut = yield* detailFor(layerHanging).pipe(Effect.forkChild);
yield* TestClock.adjust("10 seconds");
const details = [
yield* detailFor(FetchHttpClient.layer),
yield* detailFor(serverReplying({ status: 401, body: "" })),
yield* detailFor(serverReplying({ status: 502, contentType: "text/plain", body: "" })),
yield* detailFor(serverReplying({ status: 200, contentType: "text/html", body: SPA_BODY })),
yield* detailFor(layerServerReplying({ status: 401, body: "" })),
yield* detailFor(layerServerReplying({ status: 502, contentType: "text/plain", body: "" })),
yield* detailFor(
layerServerReplying({ status: 200, contentType: "text/html", body: SPA_BODY }),
),
yield* Fiber.join(timedOut),
];
assert.deepStrictEqual(details, [
@@ -244,7 +250,7 @@ describe("OpenCode2Server spawned server", () => {
Effect.provide(
Layer.mergeAll(
OpenCode2Client.layer,
OpenCodeRuntime.OpenCodeRuntimeLive.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
OpenCodeRuntime.layer.pipe(Layer.provide(OpenCodeServerLedger.layerTest)),
).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer))),
),
),