Skip to content

Commit 36bc4ce

Browse files
opencode-agent[bot]BenGu3
authored andcommitted
chore: generate
1 parent 98d9be7 commit 36bc4ce

2 files changed

Lines changed: 21 additions & 36 deletions

File tree

packages/opencode/test/effect/layer-node.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ describe("layer node", () => {
3535
test("replaces a layer by identity", async () => {
3636
const replacement = Layer.succeed(Value, Value.of({ value: "simulation" }))
3737
const program = Effect.map(Greeting, (item) => item.value).pipe(
38-
Effect.provide(LayerNode.buildLayer(greeting, { tiers, replacements: [LayerNode.replace(valueLayer, replacement)] })),
38+
Effect.provide(
39+
LayerNode.buildLayer(greeting, { tiers, replacements: [LayerNode.replace(valueLayer, replacement)] }),
40+
),
3941
)
4042
expect(await Effect.runPromise(program)).toBe("hello simulation")
4143
})
@@ -74,7 +76,9 @@ describe("layer node", () => {
7476
)
7577
await Effect.runPromise(
7678
Effect.map(Greeting, (item) => item.value).pipe(
77-
Effect.provide(LayerNode.buildLayer(greeting, { tiers, replacements: [LayerNode.replace(other, replacement)] })),
79+
Effect.provide(
80+
LayerNode.buildLayer(greeting, { tiers, replacements: [LayerNode.replace(other, replacement)] }),
81+
),
7882
),
7983
)
8084
expect(acquisitions).toBe(0)

specs/layer-node-tiers.md

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export const node = makeLocationNode({
3232
Tiers are declared bottom-up, from the most specific lifecycle to the most foundational:
3333

3434
```ts
35-
const tiers = LayerNode.tiers([
36-
"location",
37-
"global",
38-
])
35+
const tiers = LayerNode.tiers(["location", "global"])
3936
```
4037

4138
An earlier tier may depend on its own tier or any later tier. A later tier cannot depend on an earlier tier.
@@ -157,27 +154,18 @@ Without a custom build function, a tier's sorted layers are combined with the de
157154
The optional third argument customizes how each tier's sorted layers are constructed:
158155

159156
```ts
160-
const appLayer = LayerNode.buildLayer(
161-
root,
162-
tiers,
163-
(tier, layers) => {
164-
const combined = LayerNode.combine(layers)
165-
166-
if (tier !== "location") return combined
167-
168-
return Layer.effect(
169-
LocationServiceMap,
170-
LayerMap.make(
171-
(ref: Location.Ref) =>
172-
combined.pipe(
173-
Layer.provide(Location.layer(ref)),
174-
Layer.fresh,
175-
),
176-
{ idleTimeToLive: "60 minutes" },
177-
),
178-
)
179-
},
180-
)
157+
const appLayer = LayerNode.buildLayer(root, tiers, (tier, layers) => {
158+
const combined = LayerNode.combine(layers)
159+
160+
if (tier !== "location") return combined
161+
162+
return Layer.effect(
163+
LocationServiceMap,
164+
LayerMap.make((ref: Location.Ref) => combined.pipe(Layer.provide(Location.layer(ref)), Layer.fresh), {
165+
idleTimeToLive: "60 minutes",
166+
}),
167+
)
168+
})
181169
```
182170

183171
The callback receives:
@@ -192,12 +180,7 @@ It returns the final layer representing that tier. This permits a tier to introd
192180
Tests and alternate runtimes may replace a specific layer implementation by exact object identity:
193181

194182
```ts
195-
const layer = LayerNode.buildLayer(
196-
root,
197-
tiers,
198-
buildTier,
199-
[LayerNode.replace(Config.layer, testConfigLayer)],
200-
)
183+
const layer = LayerNode.buildLayer(root, tiers, buildTier, [LayerNode.replace(Config.layer, testConfigLayer)])
201184
```
202185

203186
The replacement applies to every placement of that exact source layer in the generated plans. Unused replacements are not acquired. A replacement must provide the same service output, must not introduce new errors, and must not have unresolved dependencies.
@@ -207,9 +190,7 @@ The replacement applies to every placement of that exact source layer in the gen
207190
Global implementations must remain outside the location freshness boundary. Conceptually:
208191

209192
```ts
210-
locationTier
211-
.pipe(Layer.fresh)
212-
.pipe(Layer.provideMerge(globalTier))
193+
locationTier.pipe(Layer.fresh).pipe(Layer.provideMerge(globalTier))
213194
```
214195

215196
The location tier contains only location implementations. Global dependencies are connected after the location build function creates its fresh or `LayerMap` boundary, so global services remain shared.

0 commit comments

Comments
 (0)