Skip to content

Commit 1275ac4

Browse files
Organize machine internals
1 parent 1951844 commit 1275ac4

77 files changed

Lines changed: 646 additions & 147 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@typeonce/effect-machine": patch
3+
---
4+
5+
Organize public, internal, testing, and unstable modules into Effect-shaped directories without changing package entrypoints. Add a TypeScript-resolved architecture check that enforces dependency direction, test boundaries, acyclic runtime imports, and internal naming conventions.

CONTRIBUTING.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,55 @@
33
This project generally does not accept unsolicited pull requests. Open an issue first describing the problem or use case and, for API changes, the public API you want to add or change.
44

55
Wait for the proposal to be discussed and accepted before starting an implementation or opening a pull request. Pull requests without prior agreement may be closed.
6+
7+
## Repository architecture
8+
9+
The source tree follows Effect's public-module/internal-implementation split:
10+
11+
```text
12+
src/
13+
├── Machine.ts
14+
├── index.ts
15+
├── testing/
16+
├── unstable/
17+
└── internal/
18+
├── machine/
19+
└── testing/machine/
20+
```
21+
22+
Public entrypoints and public modules use Effect-style names. Private files sit
23+
under the domain they implement and use responsibility names such as
24+
`planner.ts`, `process.ts`, and `runtime.ts`; they do not repeat `machine` in
25+
every filename. Runtime tests mirror the same domains. Tests below
26+
`test/internal/` are the only white-box suites allowed to import `src/internal`.
27+
28+
The core dependency direction is:
29+
30+
```text
31+
public entrypoint -> public module -> process -> planner
32+
| |
33+
v v
34+
runtime model
35+
| |
36+
└-> errors <-┘
37+
```
38+
39+
Internal machine modules may refer back to the public `Machine` types through
40+
type-only imports. The runtime is intentionally unaware of the model, planner,
41+
and process layers. Testing implementations are isolated under
42+
`src/internal/testing` and may only be consumed by the public testing module or
43+
other testing internals.
44+
45+
`pnpm check:architecture` builds a TypeScript dependency graph using the
46+
project's NodeNext resolver. It distinguishes type-only and runtime edges,
47+
understands imports, re-exports, and dynamic imports, and enforces:
48+
49+
- public entrypoints do not leak internals;
50+
- internal back-edges and layer dependencies keep their intended direction;
51+
- production code does not depend on testing internals;
52+
- black-box tests do not depend on implementation internals;
53+
- production runtime imports are acyclic;
54+
- private directories have no barrels or legacy `machine*` filenames.
55+
56+
The checker has executable fixture tests and runs as part of `pnpm check`. Add
57+
new rules only with a failing fixture that demonstrates the boundary.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
"import": "./dist/index.js"
2828
},
2929
"./reactivity": {
30-
"types": "./dist/reactivity.d.ts",
31-
"import": "./dist/reactivity.js"
30+
"types": "./dist/unstable/reactivity/index.d.ts",
31+
"import": "./dist/unstable/reactivity/index.js"
3232
},
3333
"./cluster": {
34-
"types": "./dist/cluster.d.ts",
35-
"import": "./dist/cluster.js"
34+
"types": "./dist/unstable/cluster/index.d.ts",
35+
"import": "./dist/unstable/cluster/index.js"
3636
},
3737
"./testing": {
38-
"types": "./dist/testing.d.ts",
39-
"import": "./dist/testing.js"
38+
"types": "./dist/testing/index.d.ts",
39+
"import": "./dist/testing/index.js"
4040
},
4141
"./package.json": "./package.json"
4242
},
@@ -48,14 +48,15 @@
4848
"build": "tsc -p tsconfig.build.json",
4949
"test": "vitest run",
5050
"test:types": "tstyche",
51+
"check:architecture": "node --test scripts/check-architecture.test.mjs && node scripts/check-architecture.mjs",
5152
"typecheck": "tsc -p tsconfig.json --noEmit",
5253
"perf:types": "pnpm build && node scripts/type-performance.mjs",
5354
"perf:runtime": "pnpm build && node --expose-gc scripts/runtime-performance.mjs",
5455
"format": "dprint fmt",
5556
"format:check": "dprint check",
5657
"test:consumer": "node scripts/test-consumer.mjs",
5758
"pack:check": "node scripts/pack-check.mjs",
58-
"check": "pnpm format:check && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
59+
"check": "pnpm format:check && pnpm check:architecture && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check",
5960
"changeset": "changeset",
6061
"version-packages": "changeset version",
6162
"release": "pnpm build && changeset publish"

0 commit comments

Comments
 (0)