@punks/cli 3.1.7 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BASELINE_CHANGELOG.md +14 -1
- package/dist/CHANGELOG.md +22 -1
- package/dist/data/control-plane.json +1 -1
- package/dist/data/scripts/sync-subagents.mjs +7 -26
- package/dist/index.js +1 -1
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +2 -2
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +1 -4
- package/dist/skills/agnostic/planning/create-spec/SKILL.md +4 -7
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +0 -3
- package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +1 -2
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +1 -14
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +0 -5
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +0 -4
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +1 -14
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +0 -4
- package/dist/skills/agnostic/research/parallel-research/DURABLE-REPORT.md +4 -7
- package/dist/skills/agnostic/research/parallel-research/SKILL.md +9 -8
- package/dist/skills/frameworks/effect/effect/SKILL.md +12 -5
- package/dist/skills/frameworks/effect/effect/references/CONFIG.md +19 -10
- package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +63 -3
- package/dist/skills/frameworks/effect/effect/references/TESTING.md +72 -2
- package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +29 -12
- package/dist/skills/frameworks/effect/effect-backend-structure/agents/openai.yaml +1 -1
- package/dist/skills/frameworks/effect/effect-backend-structure/references/layout.md +9 -9
- package/dist/skills/misc/wait-what/SKILL.md +3 -7
- package/dist/skills/phases/delivery-phase/phases/review.md +3 -1
- package/dist/skills/phases/delivery-phase/phases/router.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/spec.md +1 -4
- package/dist/skills/phases/finder-phase/SKILL.md +0 -3
- package/dist/skills/phases/finder-phase/references/frontier-lifecycle.md +1 -3
- package/dist/skills/phases/review-phase/SKILL.md +3 -4
- package/package.json +2 -2
- package/dist/skills/frameworks/effect/effect-service-design/LICENSE +0 -21
- package/dist/skills/frameworks/effect/effect-service-design/SKILL.md +0 -124
- package/dist/skills/frameworks/effect/effect-service-design/references/AUDIT.md +0 -98
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +0 -29
- package/dist/skills/phases/prototype-phase/agents/openai.yaml +0 -2
|
@@ -26,18 +26,15 @@ parent/base constraints.
|
|
|
26
26
|
decisions; never invent closure. Serialize `Dependency Readiness` and
|
|
27
27
|
`Branch/Base Intent` using the readiness contract.
|
|
28
28
|
4. Apply [spec-quality-bar.md](references/spec-quality-bar.md).
|
|
29
|
-
5.
|
|
30
|
-
Proceed only when the language contract passes without changing confirmed
|
|
31
|
-
decisions or reopening interviews.
|
|
32
|
-
6. Update existing planning-surface indexes through
|
|
29
|
+
5. Update existing planning-surface indexes through
|
|
33
30
|
[wiki-bookkeeping.md](references/wiki-bookkeeping.md).
|
|
34
|
-
|
|
31
|
+
6. Persist the completed spec and its bookkeeping in a dedicated git commit.
|
|
35
32
|
Never stage unrelated changes.
|
|
36
|
-
|
|
33
|
+
7. Push or explicitly retain the spec commit through a repository-approved
|
|
37
34
|
remote mechanism, verify the retained ref contains the spec commit, then
|
|
38
35
|
construct and verify a stable blob URL before `write-backlog` may consume it.
|
|
39
36
|
A local commit SHA plus path is insufficient.
|
|
40
|
-
|
|
37
|
+
8. Return `spec-written` with `readiness: agent-ready` and the verified stable
|
|
41
38
|
blob URL. If retention or URL verification fails, return one atomic
|
|
42
39
|
`spec-not-ready` result and do not invoke backlog projection.
|
|
43
40
|
|
|
@@ -55,9 +55,6 @@ Use [../assets/IMPLEMENTATION-NOTES-TEMPLATE.md](../assets/IMPLEMENTATION-NOTES-
|
|
|
55
55
|
|
|
56
56
|
- Create `IMPLEMENTATION-NOTES.md` from the template when missing.
|
|
57
57
|
- Append or refine when it already exists.
|
|
58
|
-
- Every create or update of `IMPLEMENTATION-NOTES.md` applies `$wait-what`
|
|
59
|
-
before writing. The update is complete when its language contract passes and
|
|
60
|
-
the recorded evidence remains unchanged.
|
|
61
58
|
- Keep it current during the run, not only at the end.
|
|
62
59
|
- For UI implementation changes, load [ui-screenshot-evidence.md](ui-screenshot-evidence.md) and keep `## UI Evidence Links` current.
|
|
63
60
|
- For tasks with `runtime_validation: required`, load [runtime-product-validation.md](runtime-product-validation.md) and keep `## Runtime Validation Evidence` current.
|
|
@@ -48,8 +48,7 @@ Every supported concept is a first-class provider backlog item that is visible,
|
|
|
48
48
|
1. Accept a Finder-selected direct classification: `fog`, `grilling`, `research`, or `prototype`.
|
|
49
49
|
2. For `fog`, preserve the frontier or uncertainty description. For `grilling`,
|
|
50
50
|
`research`, or `prototype`, preserve the precise question. Also preserve the
|
|
51
|
-
capability module when known,
|
|
52
|
-
dependencies, claim state, and map link.
|
|
51
|
+
capability module when known, dependencies, claim state, and map link.
|
|
53
52
|
3. Validate the complete intake dependency graph for missing targets, self-edges, and cycles before the first provider write.
|
|
54
53
|
4. Create exactly the requested intake item. Do not create an epic or story.
|
|
55
54
|
5. Return the immutable provider id and URL to Finder.
|
|
@@ -20,8 +20,7 @@ The direct concepts are `fog`, `grilling`, `research`, `prototype`, `epic`, and
|
|
|
20
20
|
|
|
21
21
|
## Placement
|
|
22
22
|
|
|
23
|
-
- `fog`: root-level uncertainty
|
|
24
|
-
capability module, or an execution item
|
|
23
|
+
- `fog`: root-level uncertainty, never delivery scope or a parent container
|
|
25
24
|
- `grilling`: capability-scoped human decision work
|
|
26
25
|
- `research`: capability-scoped readonly evidence work
|
|
27
26
|
- `prototype`: capability-scoped experiment work
|
|
@@ -30,18 +29,6 @@ The direct concepts are `fog`, `grilling`, `research`, `prototype`, `epic`, and
|
|
|
30
29
|
|
|
31
30
|
Each capability module groups durable product ownership. It stays separate from every execution milestone and does not determine implementation order.
|
|
32
31
|
|
|
33
|
-
## Evidence parent
|
|
34
|
-
|
|
35
|
-
Finder-derived `grilling`, `research`, or `prototype` may retain the source
|
|
36
|
-
`fog` as an evidence parent. The fog remains root-level and is not a delivery
|
|
37
|
-
item, `SPEC.md` anchor, capability module, or execution item. The concrete item
|
|
38
|
-
keeps its own classification and capability placement.
|
|
39
|
-
|
|
40
|
-
When the provider supports a native intake parent relation, use the fog as that
|
|
41
|
-
evidence parent. Otherwise, preserve an immutable evidence link without
|
|
42
|
-
inventing hierarchy that the provider cannot represent. The provider adapter
|
|
43
|
-
must declare which representation it supports before mutation.
|
|
44
|
-
|
|
45
32
|
## Traceability and story readiness
|
|
46
33
|
|
|
47
34
|
Every projected story names its source `US-###` records and covered `AC-###` records. Before mutation, prove:
|
|
@@ -133,11 +133,6 @@ Render these sections in `System.Description`; do not substitute a mutable local
|
|
|
133
133
|
- epic -> work item type chosen by your process, often `Epic` or `Feature`, with `Custom.DevpunksKind = epic`
|
|
134
134
|
- story -> child work item chosen by your process, often `User Story`, `Product Backlog Item`, or `Task`, with `Custom.DevpunksKind = story`
|
|
135
135
|
|
|
136
|
-
For Finder-derived `grilling`, `research`, or `prototype`, use the native Parent
|
|
137
|
-
relation to the source fog when the selected process supports that relation.
|
|
138
|
-
Otherwise preserve an immutable evidence link. Keep `System.AreaPath` on the
|
|
139
|
-
concrete item in both cases.
|
|
140
|
-
|
|
141
136
|
## Capability grouping
|
|
142
137
|
|
|
143
138
|
Use `/fields/System.AreaPath` for durable capability-module membership. Area paths organize work by product or feature area and stay independent from delivery chronology. Fog remains at the backlog/root area until sharpening chooses a capability module.
|
|
@@ -155,10 +155,6 @@ After creation, set Project fields:
|
|
|
155
155
|
|
|
156
156
|
Use first-class issues in the matching capability module. These are not child stories unless the provider explicitly needs a parent for visibility.
|
|
157
157
|
|
|
158
|
-
When Finder supplies a source fog parent, preserve it with `parentIssueId` or
|
|
159
|
-
`addSubIssue`. Keep the concrete issue's `Capability module` value. This is
|
|
160
|
-
evidence lineage, not epic/story hierarchy.
|
|
161
|
-
|
|
162
158
|
After creation, set Project fields:
|
|
163
159
|
|
|
164
160
|
- `Kind = grilling`, `Kind = research`, or `Kind = prototype`
|
package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md
CHANGED
|
@@ -89,22 +89,13 @@ Only when explicitly configured to use a `Kind` label group, use one matching la
|
|
|
89
89
|
|
|
90
90
|
Linear label groups allow only one label from the group per issue. Do not use workflow state as classification. Do not create a label group by default.
|
|
91
91
|
|
|
92
|
-
For pre-spec intake with a configured `Kind` group, resolve the complete intake
|
|
93
|
-
taxonomy before any write: `Kind/fog`, `Kind/grilling`, `Kind/research`, and
|
|
94
|
-
`Kind/prototype`. Create missing Kind labels only when explicit workspace policy
|
|
95
|
-
permits it. Otherwise return an exact setup blocker that lists every missing
|
|
96
|
-
label. An incomplete configured `Kind` taxonomy must not use a title prefix as
|
|
97
|
-
a workaround.
|
|
98
|
-
|
|
99
92
|
Fallback order:
|
|
100
93
|
|
|
101
94
|
1. configured label group
|
|
102
95
|
2. existing native issue label or category that exactly preserves the direct concept
|
|
103
96
|
3. stable title prefix such as `[story]`
|
|
104
97
|
|
|
105
|
-
|
|
106
|
-
permits none of these representations, fail preflight. Label creation always
|
|
107
|
-
requires explicit workspace policy.
|
|
98
|
+
If workspace policy permits none of these, fail preflight. Do not create labels implicitly.
|
|
108
99
|
|
|
109
100
|
## Repo mapping
|
|
110
101
|
|
|
@@ -117,10 +108,6 @@ requires explicit workspace policy.
|
|
|
117
108
|
- epic -> top-level issue with `Kind/epic`
|
|
118
109
|
- story -> child issue created with `parentId` and `Kind/story`
|
|
119
110
|
|
|
120
|
-
For Finder-derived `grilling`, `research`, or `prototype`, set `parentId` to the
|
|
121
|
-
source fog issue. The concrete issue keeps its capability metadata. This parent
|
|
122
|
-
is evidence lineage; it does not make fog a capability or execution item.
|
|
123
|
-
|
|
124
111
|
`grilling`, `research`, and `prototype` closure notes record the answer or verdict, evidence, observations, open decisions, and resolution pointer for Wayfinder. They do not authorize delivery.
|
|
125
112
|
|
|
126
113
|
## Delivery body contracts
|
package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md
CHANGED
|
@@ -97,10 +97,6 @@ When classification is explicitly configured, use its actual column ID from boar
|
|
|
97
97
|
|
|
98
98
|
Create each learning item as a first-class parent item in the matching capability group.
|
|
99
99
|
|
|
100
|
-
When Finder supplies a source fog parent, preserve an immutable evidence link
|
|
101
|
-
in the learning item. Keep the item in its capability group; do not turn it into
|
|
102
|
-
a fog subitem because that would lose capability placement.
|
|
103
|
-
|
|
104
100
|
When configured, set the classification column to `grilling`, `research`, or `prototype`.
|
|
105
101
|
|
|
106
102
|
Closure notes record the answer or verdict, evidence, observations, open decisions, and resolution pointer for Wayfinder. They do not authorize delivery.
|
|
@@ -17,13 +17,10 @@ written to the project wiki before the run can complete.
|
|
|
17
17
|
as required by the wiki's existing conventions.
|
|
18
18
|
3. Run 2-4 readonly lanes. Lanes never write the report.
|
|
19
19
|
4. After synthesis, the coordinator or one designated consolidator writes one
|
|
20
|
-
|
|
21
|
-
one consolidated report. Include
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- uncertainty and conflicts
|
|
25
|
-
- selected next route
|
|
26
|
-
The response points to this report and does not duplicate its synthesis.
|
|
20
|
+
Markdown report at the resolved wiki path. There is exactly one writer and
|
|
21
|
+
one consolidated report. Include the primary source for every retained
|
|
22
|
+
factual claim and separate facts, inferences, conflicts, and unresolved
|
|
23
|
+
product decisions.
|
|
27
24
|
5. Commit the report and any required route metadata in one commit, then push
|
|
28
25
|
or explicitly retain `research/<slug>` through a durable repository-approved
|
|
29
26
|
mechanism.
|
|
@@ -48,13 +48,11 @@ Use this skill only for readonly workflows. Goal: widen coverage fast, keep prom
|
|
|
48
48
|
|
|
49
49
|
## Synthesize Before Acting
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
5. Write one bounded synthesis using [DURABLE-REPORT.md](DURABLE-REPORT.md),
|
|
57
|
-
then close agents that are no longer needed.
|
|
51
|
+
- Compare outputs against the repo, docs, or other primary artifacts.
|
|
52
|
+
- Resolve disagreements with evidence, not majority vote.
|
|
53
|
+
- Follow every retained factual claim back to its primary source.
|
|
54
|
+
- Extract the few facts that matter, then decide locally.
|
|
55
|
+
- Close agents that are no longer needed.
|
|
58
56
|
|
|
59
57
|
## Good Fits
|
|
60
58
|
|
|
@@ -76,5 +74,8 @@ Use this skill only for readonly workflows. Goal: widen coverage fast, keep prom
|
|
|
76
74
|
|
|
77
75
|
Return:
|
|
78
76
|
- what each subagent covered
|
|
79
|
-
-
|
|
77
|
+
- the evidence worth trusting, with claim-level source citations
|
|
78
|
+
- conflicts or uncertainty
|
|
79
|
+
- the synthesized conclusion
|
|
80
|
+
- the next local action
|
|
80
81
|
- durable report immutable SHA, path, and verified retention reference
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: effect
|
|
3
3
|
description: |
|
|
4
|
-
Opinionated guide for building production TypeScript applications with Effect v4
|
|
4
|
+
Opinionated guide for building production TypeScript applications with Effect v4. Use when implementing Effect workflows, services, layers, schemas, configuration, schedules, caches, streams, HTTP clients, or tests.
|
|
5
5
|
license: MIT
|
|
6
6
|
compatibility: Requires Effect v4. Examples are reviewed against the version documented in this repository.
|
|
7
7
|
---
|
|
@@ -23,14 +23,13 @@ Check these before guessing:
|
|
|
23
23
|
Read only the branch references that match the task.
|
|
24
24
|
|
|
25
25
|
- Data models, schemas, brands, variants, optional keys, or decoders: read `references/SCHEMA.md`.
|
|
26
|
-
-
|
|
27
|
-
- Module namespace surfaces, scoped long-lived work, whole-function `Effect.fn` transforms, or operation error helpers: read `references/SERVICES_LAYERS.md`.
|
|
26
|
+
- Services, module surfaces, layers, runtime wiring, errors, `Effect.fn`, or test services: read `references/SERVICES_LAYERS.md`.
|
|
28
27
|
- Runtime config, env variables, `ConfigProvider`, or `layerConfig`: read `references/CONFIG.md`.
|
|
29
28
|
- Retry, repeat, polling, backoff, jitter, rate-limit-aware policies, or pass loops: read `references/SCHEDULING.md`.
|
|
30
29
|
- Memoization, per-key TTL caches, deduplicating concurrent lookups, or request batching: read `references/CACHING.md`.
|
|
31
30
|
- Streams, event sources, async iterables, queues/pubsubs, pagination, backpressure, or stream consumers: read `references/STREAMS.md`.
|
|
32
31
|
- Outgoing HTTP calls, Effect HttpClient, status handling, or HTTP rate limiting: read `references/HTTP_CLIENTS.md`.
|
|
33
|
-
- Effect tests, time, sleeps,
|
|
32
|
+
- Effect tests, time, sleeps, concurrency synchronization, or fakes: read `references/TESTING.md`.
|
|
34
33
|
- Effect-Atom data fetching, mutations, or React server state: read `references/EFFECT_ATOM.md`.
|
|
35
34
|
- Effect logging, tracing, spans, or observability: read `references/OBSERVABILITY.md`.
|
|
36
35
|
|
|
@@ -39,14 +38,17 @@ If a task spans several branches, read all matching files before editing.
|
|
|
39
38
|
## Core Defaults
|
|
40
39
|
|
|
41
40
|
- Compose workflows with `Effect.gen(function* () { ... })`.
|
|
41
|
+
- Define public service methods and non-trivial internal service methods with `Effect.fn("Domain.operation")`.
|
|
42
42
|
- Use `Effect.fnUntraced` only for internal helpers where stack-frame/span metadata is intentionally unnecessary.
|
|
43
|
+
- Prefer `Context.Service` for application services when the codebase has not standardized on another current service-tag style.
|
|
44
|
+
- Build real service implementations with `Layer.effect(Service, Effect.gen(...))` and return `Service.of({ ... })`.
|
|
43
45
|
- Model records with `Schema.Struct(...)` plus a same-name `interface`.
|
|
44
46
|
- Model typed Effect errors with `Schema.TaggedErrorClass`.
|
|
45
47
|
- Read runtime config through `Config`, not direct `process.env` access in application logic.
|
|
46
48
|
- Use `Schedule` for retry, repeat, polling, pacing, and backoff policies.
|
|
47
49
|
- Use `Stream` for effectful sources that emit many values over time and need pull, backpressure, interruption, or transformation.
|
|
48
50
|
- Prefer Effect HTTP client modules for outgoing HTTP in Effect applications when their typed errors, layers, and client transforms are useful.
|
|
49
|
-
- Prefer Effect-aware tests and deterministic synchronization over sleeps.
|
|
51
|
+
- Prefer Effect-aware tests, explicit layers, and deterministic synchronization over sleeps.
|
|
50
52
|
- Prefer decoders and `schema.makeEffect(...)` at untrusted boundaries; reserve throwing `schema.make(...)` for trusted construction, and never use casts to skip validation.
|
|
51
53
|
|
|
52
54
|
## Quick Selection Guide
|
|
@@ -59,6 +61,8 @@ If a task spans several branches, read all matching files before editing.
|
|
|
59
61
|
- External/custom discriminator such as `type`: `Schema.Struct({ type: Schema.tag("variant"), ... })` plus `Schema.toTaggedUnion("type")` when union helpers are needed.
|
|
60
62
|
- Expected typed failure: `Schema.TaggedErrorClass`.
|
|
61
63
|
- Unknown boundary payload: `Schema.decodeUnknownEffect(...)`.
|
|
64
|
+
- Service boundary: `Context.Service<Service, Interface>()(...)` plus `Layer.effect(...)` plus `Service.of(...)`.
|
|
65
|
+
- Public or non-trivial internal service method: `Effect.fn("Domain.operation")`.
|
|
62
66
|
- Runtime configuration: `Config` recipes read in layers; override with `ConfigProvider` in tests.
|
|
63
67
|
- Event source: `Stream` consumed with `Stream.runForEach(...)` and forked with `Effect.forkScoped` in the owning layer.
|
|
64
68
|
- Queue-backed event source: `Queue` for the producer boundary, `Stream.fromQueue(...)` for consumers.
|
|
@@ -76,6 +80,7 @@ If a task spans several branches, read all matching files before editing.
|
|
|
76
80
|
## Boundary Rules
|
|
77
81
|
|
|
78
82
|
- Keep HTTP handlers thin: decode input, read context, call services, map typed errors to transport responses.
|
|
83
|
+
- Keep business rules in services or domain functions, not transport handlers.
|
|
79
84
|
- Wrap HTTP clients, SDKs, CLIs, and external integrations in named effects at adapter boundaries.
|
|
80
85
|
- Decode persisted rows with Schema or SQL-specific helpers when values are not trivially trusted.
|
|
81
86
|
- Keep provider/network calls outside authoritative database transactions.
|
|
@@ -89,5 +94,7 @@ If a task spans several branches, read all matching files before editing.
|
|
|
89
94
|
- Do not introduce `Schema.Class` or `Schema.TaggedClass` as default app data-modeling patterns.
|
|
90
95
|
- Do not hand-roll `_tag` error classes when `Schema.TaggedErrorClass` fits.
|
|
91
96
|
- Do not use cause-level recovery when typed-error recovery is enough.
|
|
97
|
+
- Do not use `Layer.mergeAll(...)` or `provideMerge(...)` as blind make-it-compile tools.
|
|
98
|
+
- Do not hide required application authority, credentials, persistence, transports, or external services behind `Context.Reference` defaults.
|
|
92
99
|
- Do not add arbitrary `Effect.sleep(...)` to tests when a deterministic synchronization primitive is available.
|
|
93
100
|
- Do not hand-roll Map/TTL/prune caches or in-flight dedupe when `effect/Cache` fits.
|
|
@@ -10,13 +10,18 @@ export const dataDirectoryConfig = Config.schema(
|
|
|
10
10
|
"APP_DATA_DIR",
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Config.
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
export const layerFromEnvironment = Layer.effect(
|
|
14
|
+
Configuration.Service,
|
|
15
|
+
Effect.gen(function* () {
|
|
16
|
+
const apiKey = yield* Config.redacted("API_KEY")
|
|
17
|
+
const optionalModel = yield* Config.option(Config.string("MODEL"))
|
|
18
|
+
const enabled = yield* Config.boolean("FEATURE_ENABLED").pipe(
|
|
19
|
+
Config.withDefault(false),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
return Configuration.Service.of({ apiKey, optionalModel, enabled })
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
20
25
|
```
|
|
21
26
|
|
|
22
27
|
## Config Recipes
|
|
@@ -48,11 +53,15 @@ Library-style layers often expose both concrete `layer(options)` and config-back
|
|
|
48
53
|
export const layerConfig = (
|
|
49
54
|
config: Config.Wrap<ClientOptions>,
|
|
50
55
|
) =>
|
|
51
|
-
Layer.
|
|
56
|
+
Layer.effect(
|
|
57
|
+
Client.Service,
|
|
52
58
|
Config.unwrap(config).pipe(
|
|
53
|
-
Effect.
|
|
59
|
+
Effect.flatMap(makeClient),
|
|
60
|
+
Effect.map((client) => Client.Service.of(client)),
|
|
54
61
|
),
|
|
55
62
|
)
|
|
56
63
|
```
|
|
57
64
|
|
|
58
|
-
Use this pattern when a
|
|
65
|
+
Use this pattern when a service naturally supports runtime config while still allowing tests to pass concrete values.
|
|
66
|
+
|
|
67
|
+
Use `Layer.succeed(AppConfiguration.Service, testConfig)` when the app already wraps environment config in an application service and the test does not need to exercise Config decoding itself.
|
|
@@ -1,10 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Services, Layers, And Modules
|
|
2
2
|
|
|
3
|
-
Use this
|
|
3
|
+
Use this when defining service tags, module surfaces, layer implementations, runtime wiring, typed errors, or `Effect.fn` operation boundaries.
|
|
4
4
|
|
|
5
5
|
## Module Surface
|
|
6
6
|
|
|
7
|
-
One opinionated application-module style uses file-local role names and one canonical ES module namespace projection. Follow the existing codebase's module style when it has one; this convention is not required by Effect.
|
|
7
|
+
One opinionated application-module style uses file-local role names and one canonical ES module namespace projection. Follow the existing codebase's module style when it has one; this convention is not required by Effect.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export interface Interface {
|
|
11
|
+
readonly get: (id: UserId) => Effect.Effect<User, NotFound | PersistenceError>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Service extends Context.Service<Service, Interface>()(
|
|
15
|
+
"@app/UserRepo",
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
export const layer = Layer.effect(
|
|
19
|
+
Service,
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
const sql = yield* SqlClient.SqlClient
|
|
22
|
+
|
|
23
|
+
const get = Effect.fn("UserRepo.get")(function* (id: UserId) {
|
|
24
|
+
// ...
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return Service.of({ get })
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export class NotFound extends Schema.TaggedErrorClass<NotFound>()(
|
|
32
|
+
"UserRepo.NotFound",
|
|
33
|
+
{ id: UserId },
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
export * as UserRepo from "./user-repo.js"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Consumers use the module namespace.
|
|
8
40
|
|
|
9
41
|
```ts
|
|
10
42
|
import { UserRepo } from "./user-repo.js"
|
|
@@ -34,6 +66,25 @@ Guidance:
|
|
|
34
66
|
- The resulting `UserRepo.UserRepo === UserRepo` self-reference is unusual. Use this pattern only where the runtime and toolchain support it; otherwise use named exports or a separate barrel.
|
|
35
67
|
- Export only intentional surface; keep local schemas, row codecs, helpers, and implementation details unexported.
|
|
36
68
|
- Do not introduce TypeScript `namespace` declarations for organization.
|
|
69
|
+
- Use a named service class such as `class UserRepo extends Context.Service...` when an external library or existing codebase does not use module namespace style.
|
|
70
|
+
|
|
71
|
+
## Layer Constructors
|
|
72
|
+
|
|
73
|
+
Choose the layer constructor that matches the thing produced.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
Layer.succeed(Service, impl) // already-built service
|
|
77
|
+
Layer.sync(Service, () => impl) // lazy synchronous service
|
|
78
|
+
Layer.effect(Service, makeEffect) // effectful service acquisition
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Guidance:
|
|
82
|
+
|
|
83
|
+
- Default real implementations to `Layer.effect(Service, Effect.gen(...))`.
|
|
84
|
+
- Use `Layer.effectContext(...)` when one acquisition intentionally supplies multiple services, especially first-class test stubs or one client backing several service tags.
|
|
85
|
+
- Use `Layer.unwrap(...)` when config or runtime discovery chooses/builds the layer.
|
|
86
|
+
- Use `Layer.fresh(...)` or `Effect.provide(layer, { local: true })` only when a test or operation needs isolated acquisition.
|
|
87
|
+
- Use `Context.Reference` rarely, only for ambient/defaultable runtime references where a safe default is real.
|
|
37
88
|
|
|
38
89
|
## Long-Lived Work
|
|
39
90
|
|
|
@@ -58,6 +109,15 @@ Guidance:
|
|
|
58
109
|
- Do not run forever work inline during layer acquisition.
|
|
59
110
|
- Do not expose public `start` methods unless the domain explicitly needs manual lifecycle control.
|
|
60
111
|
|
|
112
|
+
## Runtime Wiring
|
|
113
|
+
|
|
114
|
+
- Use `Layer.provide(...)` to hide an implementation dependency.
|
|
115
|
+
- Use `Layer.provideMerge(...)` only when the dependency should remain exposed for downstream consumers.
|
|
116
|
+
- Use `Layer.mergeAll(...)` for independent exposed layers.
|
|
117
|
+
- Prefer flat, topologically sorted runtime layer values with named subgraphs.
|
|
118
|
+
- Avoid using `provideMerge` as a blind make-it-compile tool.
|
|
119
|
+
- Avoid hiding important authority or lifecycle dependencies behind broad invisible provisioning.
|
|
120
|
+
|
|
61
121
|
## Effect.fn
|
|
62
122
|
|
|
63
123
|
Use extra `Effect.fn(...)` arguments for wrappers that apply to the whole function call. Each transform receives `(effect, ...originalArgs)`.
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
# Testing
|
|
2
2
|
|
|
3
|
-
Use this when writing Effect tests involving time, retry, schedules, concurrency, workers, or config.
|
|
3
|
+
Use this when writing Effect tests, tests involving time, retry, schedules, concurrency, workers, services, fakes, or config.
|
|
4
4
|
|
|
5
5
|
## Defaults
|
|
6
6
|
|
|
7
7
|
- Use `it.effect` by default.
|
|
8
8
|
- Use `it.live` only when real time or live runtime services are the behavior under test.
|
|
9
|
-
- Use `ConfigProvider` rather than global mutation
|
|
9
|
+
- Use test layers and `ConfigProvider` rather than global mutation.
|
|
10
10
|
- Use `TestClock.setTime` / `TestClock.adjust` for sleeps, schedules, retries, leases, and timeouts.
|
|
11
11
|
- Fork sleeping effects before advancing `TestClock`.
|
|
12
12
|
- Avoid arbitrary `Effect.sleep(...)` in tests; it usually makes tests slow and flaky.
|
|
13
13
|
- Assert typed failures, rollback, interruption, finalization, retry bounds, idempotency, concurrency laws, and malformed persistence where relevant.
|
|
14
14
|
|
|
15
|
+
```ts
|
|
16
|
+
it.effect("finds a user", () =>
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const users = yield* UserRepo.Service
|
|
19
|
+
const result = yield* users.find(UserId.make("u1"))
|
|
20
|
+
expect(Option.isSome(result)).toBe(true)
|
|
21
|
+
}).pipe(Effect.provide(UserRepo.testLayer)),
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
15
25
|
## Synchronization Instead Of Sleeps
|
|
16
26
|
|
|
17
27
|
- Use `Deferred` for one-shot readiness/completion signals.
|
|
@@ -43,6 +53,66 @@ it.effect("publishes exactly once", () =>
|
|
|
43
53
|
)
|
|
44
54
|
```
|
|
45
55
|
|
|
56
|
+
## First-Class App Test Stubs
|
|
57
|
+
|
|
58
|
+
Use `TestInterface extends Interface`, `TestService`, and `testLayer` for reusable/stateful fakes.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
export interface Interface {
|
|
62
|
+
readonly send: (message: Message) => Effect.Effect<void, SendError>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class Service extends Context.Service<Service, Interface>()(
|
|
66
|
+
"@app/Notifier",
|
|
67
|
+
) {}
|
|
68
|
+
|
|
69
|
+
export interface TestInterface extends Interface {
|
|
70
|
+
readonly sentMessages: () => Effect.Effect<ReadonlyArray<Message>>
|
|
71
|
+
readonly failNextSend: (error: SendError) => Effect.Effect<void>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class TestService extends Context.Service<TestService, TestInterface>()(
|
|
75
|
+
"@app/Notifier/Test",
|
|
76
|
+
) {}
|
|
77
|
+
|
|
78
|
+
export const testLayer = Layer.effectContext(
|
|
79
|
+
Effect.gen(function* () {
|
|
80
|
+
const sent = yield* Ref.make<ReadonlyArray<Message>>([])
|
|
81
|
+
const nextFailure = yield* Ref.make<Option.Option<SendError>>(Option.none())
|
|
82
|
+
|
|
83
|
+
const service = TestService.of({
|
|
84
|
+
send: Effect.fn("Notifier.Test.send")(function* (message) {
|
|
85
|
+
const failure = yield* Ref.getAndSet(nextFailure, Option.none())
|
|
86
|
+
if (Option.isSome(failure)) return yield* Effect.fail(failure.value)
|
|
87
|
+
yield* Ref.update(sent, (messages) => [...messages, message])
|
|
88
|
+
}),
|
|
89
|
+
sentMessages: Effect.fn("Notifier.Test.sentMessages")(function* () {
|
|
90
|
+
return yield* Ref.get(sent)
|
|
91
|
+
}),
|
|
92
|
+
failNextSend: Effect.fn("Notifier.Test.failNextSend")(function* (error) {
|
|
93
|
+
yield* Ref.set(nextFailure, Option.some(error))
|
|
94
|
+
}),
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
return Context.empty().pipe(
|
|
98
|
+
Context.add(Service, service),
|
|
99
|
+
Context.add(TestService, service),
|
|
100
|
+
)
|
|
101
|
+
}),
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Guidance:
|
|
106
|
+
|
|
107
|
+
- The same object should back both the real `Service` tag and `TestService` tag.
|
|
108
|
+
- Production code depends only on the real service tag.
|
|
109
|
+
- Tests use `TestService` for control and inspection.
|
|
110
|
+
- Use function-valued service members, including zero-argument operations, so `Effect.fn` fits naturally.
|
|
111
|
+
- Use `Layer.succeed` for complete dead-simple static test implementations.
|
|
112
|
+
- Use `Layer.mock` only for tiny local partial mocks where omitted members should fail loudly if used.
|
|
113
|
+
|
|
46
114
|
## Config In Tests
|
|
47
115
|
|
|
48
116
|
Use `ConfigProvider.layer(ConfigProvider.fromUnknown(...))` when the test should exercise Config decoding.
|
|
117
|
+
|
|
118
|
+
Use `Layer.succeed(AppConfiguration.Service, config)` when the app wraps decoded config in its own service and the test does not need to exercise env decoding.
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
name: effect-backend-structure
|
|
3
3
|
description: |
|
|
4
4
|
Apply Effect-specific backend structure on top of backend-domain-structure.
|
|
5
|
-
Use when creating or changing Effect
|
|
6
|
-
DB integrations, test
|
|
7
|
-
root. Enforces
|
|
8
|
-
effect-solutions plus opensrc source lookup, and @effect/vitest
|
|
5
|
+
Use when creating or changing Effect services, layers, actions, repositories,
|
|
6
|
+
transport adapters, DB integrations, test layers, or backend boilerplate in any
|
|
7
|
+
Effect backend root. Enforces visible Effect requirements, layer-provided
|
|
8
|
+
implementations, effect-solutions plus opensrc source lookup, and @effect/vitest
|
|
9
|
+
testing conventions.
|
|
9
10
|
compatibility: Requires Effect v4. Examples are reviewed against the version documented in this repository.
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
# Effect Backend Structure
|
|
13
14
|
|
|
14
|
-
Use this skill with `$backend-domain-structure` and `$effect` for Effect backend code. `$effect` owns Effect v4 API guidance.
|
|
15
|
+
Use this skill with `$backend-domain-structure` and `$effect` for Effect backend code. `$effect` owns Effect v4 API guidance.
|
|
15
16
|
|
|
16
17
|
The agnostic skill owns the layer model:
|
|
17
18
|
|
|
@@ -20,23 +21,24 @@ The agnostic skill owns the layer model:
|
|
|
20
21
|
- `features/*`
|
|
21
22
|
- shared libraries and packages
|
|
22
23
|
|
|
23
|
-
This skill adds Effect-specific
|
|
24
|
+
This skill adds Effect-specific services, layers, dependency visibility, source lookup, and testing rules.
|
|
24
25
|
|
|
25
26
|
## Workflow
|
|
26
27
|
|
|
27
28
|
1. Identify the backend root from the current repo; do not assume a monorepo path.
|
|
28
29
|
2. Read the nearest relevant `AGENTS.md` files.
|
|
29
|
-
3. Read `$backend-domain-structure`, `$effect`,
|
|
30
|
+
3. Read `$backend-domain-structure`, `$effect`, and `references/layout.md`.
|
|
30
31
|
4. Run the relevant `effect-solutions` guides before coding.
|
|
31
32
|
5. Check local `opensrc` Effect sources when docs are vague or an API surface is unfamiliar.
|
|
32
33
|
6. Place code using the agnostic backend layers plus the Effect rules below.
|
|
33
34
|
7. Keep transport thin and run business logic through Effects.
|
|
34
|
-
8. Add or update colocated `@effect/vitest` tests for unit and integration coverage.
|
|
35
|
+
8. Add or update colocated `@effect/vitest` tests with test layers for unit coverage and live layers for integration coverage.
|
|
35
36
|
|
|
36
37
|
## Required Source Lookup
|
|
37
38
|
|
|
38
39
|
Always consult `effect-solutions` first. Use the smallest relevant set:
|
|
39
40
|
|
|
41
|
+
- `effect-solutions show services-and-layers`
|
|
40
42
|
- `effect-solutions show config`
|
|
41
43
|
- `effect-solutions show data-modeling`
|
|
42
44
|
- `effect-solutions show error-handling`
|
|
@@ -49,9 +51,20 @@ Use `opensrc` next when the guide is not enough:
|
|
|
49
51
|
|
|
50
52
|
For non-Effect libraries, run `opensrc path <package>` or `opensrc path owner/repo`.
|
|
51
53
|
|
|
54
|
+
## Services and Layers
|
|
55
|
+
|
|
56
|
+
- Define business services, repositories, and reusable capability interfaces with `Context.Service`.
|
|
57
|
+
- Build implementations with layers and return values through `Service.of(...)`.
|
|
58
|
+
- Let actions consume services/repositories through Effect accessors or `yield* Service`.
|
|
59
|
+
- Keep action requirements visible until a feature, app, runner, or test layer provides them.
|
|
60
|
+
- Compose feature dependencies in `features/<domain>/layer.ts` or the local equivalent.
|
|
61
|
+
- Compose cross-feature and infrastructure dependencies in `platform/`.
|
|
62
|
+
- Use `Layer.mergeAll` for same-level composition and shallow `Layer.provide` / `Layer.provideMerge` for wiring levels together.
|
|
63
|
+
- Avoid `Effect.provide` inside actions, services, repositories, and transport adapters except at the final runner/test boundary.
|
|
64
|
+
|
|
52
65
|
## Effect Coding Rules
|
|
53
66
|
|
|
54
|
-
- Use `Effect.fn("Domain.action")` for actions.
|
|
67
|
+
- Use `Effect.fn("Domain.action")` for actions and service methods.
|
|
55
68
|
- Use `Schema.TaggedError` for domain failures.
|
|
56
69
|
- Use branded IDs and Effect Schema for domain models.
|
|
57
70
|
- Use `Config.*` instead of reading `process.env` inside Effect code.
|
|
@@ -62,15 +75,19 @@ For non-Effect libraries, run `opensrc path <package>` or `opensrc path owner/re
|
|
|
62
75
|
|
|
63
76
|
- Keep tests inside the owning feature or module.
|
|
64
77
|
- Use `@effect/vitest`.
|
|
65
|
-
- Unit tests
|
|
66
|
-
- Integration tests use public action or transport boundaries.
|
|
67
|
-
-
|
|
78
|
+
- Unit tests provide fake leaf services/repos via test layers.
|
|
79
|
+
- Integration tests use live layers and public action or transport boundaries.
|
|
80
|
+
- Expose assertions through test-state tags in `tests/support`.
|
|
81
|
+
- Do not add test-only methods to production services.
|
|
82
|
+
- Do not use module mocks for Effect services; provide a replacement `Layer`.
|
|
68
83
|
|
|
69
84
|
## Output Checklist
|
|
70
85
|
|
|
71
86
|
- `$backend-domain-structure` was applied
|
|
72
87
|
- relevant `effect-solutions` guides were checked
|
|
73
88
|
- `opensrc` sources were checked when needed
|
|
89
|
+
- dependencies stay visible as Effect requirements or service dependencies
|
|
90
|
+
- implementations are supplied by layers, not hidden imports or module mocks
|
|
74
91
|
- code landed in the correct backend layer
|
|
75
92
|
- actions own orchestration
|
|
76
93
|
- services are only reusable mechanics
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "Effect Backend Structure"
|
|
3
3
|
short_description: "Effect backend architecture"
|
|
4
|
-
default_prompt: "Use $backend-domain-structure alongside $effect-backend-structure to shape Effect backend
|
|
4
|
+
default_prompt: "Use $backend-domain-structure alongside $effect-backend-structure to shape or bootstrap Effect backend code in any backend root; first apply agnostic backend layers, then apply Effect-specific services, layers, and testing rules."
|
|
@@ -34,14 +34,14 @@ Dependency direction:
|
|
|
34
34
|
- features may depend on other features only when the domain relationship is explicit and stable
|
|
35
35
|
- integrations do not import features
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Layer ownership:
|
|
38
38
|
|
|
39
|
-
- `platform/effect/app.ts` or local equivalent
|
|
40
|
-
- `platform/effect/request.ts` or local equivalent
|
|
41
|
-
- `features/<domain>/layer.ts`
|
|
42
|
-
- `features/<domain>/tests/support
|
|
39
|
+
- `platform/effect/app.ts` or local equivalent composes the app-wide live layer and provides infrastructure once
|
|
40
|
+
- `platform/effect/request.ts` or local equivalent builds request-scoped services and runtime context only
|
|
41
|
+
- `features/<domain>/layer.ts` composes that domain's action/repository/service requirements
|
|
42
|
+
- `features/<domain>/tests/support/layer.ts` provides fake leaf layers and test-state tags for unit tests
|
|
43
43
|
|
|
44
|
-
Do not import live implementations directly inside actions, services, repositories, or transport adapters.
|
|
44
|
+
Keep dependency requirements visible until one of these layer files provides them. Do not import live implementations directly inside actions, services, repositories, or transport adapters.
|
|
45
45
|
|
|
46
46
|
Test layout:
|
|
47
47
|
|
|
@@ -59,10 +59,10 @@ Test layout:
|
|
|
59
59
|
Testing split:
|
|
60
60
|
|
|
61
61
|
- `tests/support`
|
|
62
|
-
|
|
62
|
+
fake leaf layers plus state tags for assertions
|
|
63
63
|
- `tests/unit`
|
|
64
|
-
action and guard behavior
|
|
64
|
+
action and guard behavior on fake layers
|
|
65
65
|
- `tests/integration`
|
|
66
|
-
live router/app behavior
|
|
66
|
+
live router/app behavior on real layers
|
|
67
67
|
|
|
68
68
|
Do not recreate a package-root `tests/` folder unless the current repo already requires that convention.
|