Executable boundary checks
pnpm check:boundaries runs the checker in tools/checks/run.ts. pnpm check runs it too.
Enforced boundaries
The policy is tools/checks/policy.ts.
- Every package must have a policy; a new package without one fails.
- A package may depend on and import only the Werker packages its policy lists (the table is in Architecture).
- Third-party packages with an owner may only be declared or imported
by that owner:
pgby@werkerai/db,better-authby@werkerai/auth,@earendil-works/pi-aiand@daytona/sdkby@werkerai/connections,nodemailerby@werkerai/connections,cittyby@werkerai/cli,@earendil-works/pi-codemodeby@werkerai/runtimeand@werkerai/scripts, other@earendil-works/*packages by@werkerai/runtime, andtmcpand@tmcp/*by@werkerai/app. .sqlfiles may only live underpackages/db/.- Production domain and rules modules cannot import Node built-ins. Test files are exempt.
- Package imports must be declared by the importing package.
- Imports must match the target package's public exports.
- Relative imports cannot reach outside their package.
- Application packages cannot be imported as package APIs, except
where a policy's
appsnames one (apps/reelsimportsapps/app's exports). - Unknown
@werkerai/*package imports are rejected. - Names: application-owned variables, functions, parameters and type
or class members use snake_case (no
UPPER_CASEconstants); types, interfaces and classes use PascalCase. Object-literal keys and third-party names are left alone, and library exports are not given snake_case aliases. External contract keys an owned type must mirror are allowlisted inexternal_property_names(tools/checks/naming.ts). Code copied from upstream projects, listed invendored_paths(tools/checks/policy.ts), keeps its upstream names: the shadcn-svelte primitives inpackages/ui/src/components/ui/,packages/ui/src/hooks/,packages/ui/src/highlighter.tsandtools/oxlint/anti-slop/. $effectis not used inapps/app/src/,apps/site/src/,apps/reels/src/orpackages/ui/src/: derive state with$derived, update it in event handlers, and set up DOM or library work with{@attach}oronMount(tools/checks/runes.ts).- In the same UI source directories, the navigation check flags
invalidateAllin scripts and template expressions. SvelteKit usesrefreshAllfor both the function and the navigation option. - Nested ternaries: outside
vendored_paths, a ternary cannot sit directly in another ternary's condition or branch, in scripts or Svelte template expressions. Use if/return,$derived.by,{#if}blocks or a lookup object (tools/checks/ternaries.ts). - Tools are defined with
define_tool(packages/runtime/src/tools/define.ts), which limits a tool's name to those in the registry; nothing else inpackages/runtime/src/may name pi-durable'sdefineTool(tools/checks/registry.ts).
Size limits
tools/checks/size.ts measures every source file outside vendored_paths, except test files (*.test.ts, *.spec.ts). The
limits are size_limits in tools/checks/policy.ts:
| What | Limit |
|---|---|
| A function, method or callback | 100 lines |
A top-level try, if, loop or block | 100 lines |
A .ts or .js file | 500 lines |
| A Svelte component, script and markup together | 400 lines |
- A function inside a long function is measured as well, and named
outer.inner. - Lines include blank lines and comments.
size_exempt(tools/checks/policy.ts) lists files with no file-length limit, each with a reason: currentlypackages/domain/src/registry.ts. Their functions are still measured..sqlfiles are not measured.
Code that was over a limit when the check was added is recorded in tools/checks/size-baseline.json, keyed by file path, or path#name for a function. The check fails when:
- something not in the baseline is over its limit;
- something in the baseline is longer than its recorded size;
- something in the baseline is shorter than its recorded size, or is
no longer over its limit.
pnpm check:sizes:lowerthen lowers or removes the entry. That command never adds an entry or raises one.
So a recorded size only goes down. Two functions with the same name in one file share one entry, the longer of the two.
Folders
tools/checks/layout.ts: when five or more files in one folder share
a first word (sandbox-types.ts, sandbox-files.ts, ...), the check
fails and names the folder to make: the files move into sandbox/ and
drop the prefix (sandbox/types.ts). The number is prefix_group_limit in tools/checks/policy.ts.
- A file and its tests count as one.
- Files named after the folder they are already in
(
components/run/run-view.svelte) are left alone. - SvelteKit route files (
+page.svelte) andvendored_pathsare not counted.
Two oxlint rules in the root vite.config.ts sit beside the size
check: max-depth (blocks nested at most 4 deep) and max-params (at
most 6 parameters). max-depth is off for three files whose long
functions are in the baseline; the list is in vite.config.ts.
Implementation
The checker discovers source and package manifests from the filesystem, including new untracked files. It ignores dependencies and generated build output.
TypeScript's compiler API inspects imports, re-exports, import types,
literal dynamic imports, and literal require calls. The Svelte
compiler locates component script blocks before TypeScript parses
them. Comments and strings resembling imports are not treated as
imports.
Import checks are static: computed module names are not checked.
Tests and commands
pnpm check:boundaries
pnpm check:sizes:lower
pnpm test:boundaries
pnpm check
pnpm test:unit Checker tests build temporary fixture repositories.
The registry
packages/domain/src/registry.ts lists every part the platform has:
the kinds of record that can be created, what starts work, what an
agent can be given, and the tools, capabilities and connection
adapters behind them. Registry is that list as a page.
Package tests fail when the code has a part the registry lacks:
- a table or a column in
packages/db/sql/(packages/db/src/registry.test.ts); - a tool (
define_tool, above), and the tools a service connection gives a run (packages/runtime/src/registry.test.ts); - a model or sandbox adapter
(
packages/connections/src/registry.test.ts); - a bindable capability (a type in
packages/core/src/connections/connections.ts); apps/site/src/content/docs/engineering/registry.mddiffering from the registry (packages/domain/src/registry-page.test.ts;pnpm docs:registrywrites it).
They cannot see a new global from a library upgrade, an environment variable, or a change in behaviour that adds no table, column, tool, adapter or capability.