@arki/dot — Laws
For @arki/[email protected] · source AGENTS.md
AGENTS.md = laws, docs/agent-guide.md = tasks, llms.txt = map.
@arki/dot — Laws
Rules for code in this package and for apps built on it. Each law names the check that enforces it. Read docs/principles.md for the reasons behind them.
Laws
- Plugins are the app. There is no hidden core: no built-in service, no
hook outside
configure → boot → start → stop → dispose, no plugin auto-loaded from disk. A service exists only because a plugin provides it (principle 2). configureis synchronous and does no I/O. Aconfigurethat returns a Promise returnsUnexpectedDefectwithARKI_DOT_E001metadata. Async work goes inbootor in aprovidesfactory. This is what keepsdot explainfree of side effects.- Providers before consumers. Declaration order is boot order; nothing
sorts it. The wrong order is a compile error at
.use(), andARKI_DOT_E020(orARKI_DOT_E012) when the types are erased. Never "fix" it with a sort. - Never cast a manifest. Check
isFailure(builder.configure())before reading the configured result’smanifest, or readapp.manifeston a booted app. Noas, noas unknown as: the manifest types are exported, and a cast hides a wrong path until an agent readsnull. - The kernel imports no adapter.
src/**never imports@arki/db,@arki/env,@arki/kv,@arki/journalor any other adapter. Adapters take@arki/dotas an optional peer and live in their own packages (principle 5).@orpc/serveris loaded only by@arki/dot/orpc. - Error codes are API. Managed configure/boot/start/stop/dispose return inferred typed failures under A-33; unmanaged static declarations may throw. Owned resources and child tasks must settle before finalization. Kernel-generated defects preserve stable
ARKI_DOT_E*metadata inside canonicalUnexpectedDefect.cause; owned provider/boot defects retain their original cause. Diagnostics expose phase, owner, legacy ID,remediationanddocsUrl. Codes are never renumbered or reused (E009 and E010 are retired). Each code's JSDoc carries@fixand@verify. - Deterministic. Same source, same manifest, byte for byte. No clock, no random id and no host ordering inside the manifest (principle 3).
Changing this package
- A new error code takes the next free number, a JSDoc summary,
@fix,@verify, a row in the READMEFailure behaviourtable and a row in the agent guideErrorstable. - A new public export gets a JSDoc example and a test; a new entry gets a
one-sentence top comment, then
bun ../../tooling/library/src/llms.ts --write. - A change to
--jsonoutput keeps everyjqpath indocs/agent-guide.mdvalid (src/cli/json-paths.test.tschecks them). - Docs follow the Dot style: small files, a diagram where it helps, every
decision with its reason. Command output comes from
ts run expectblocks orfrom=regions, never pasted by hand. docs/plans/**is internal and does not ship (!docs/plans/**infiles).
Consuming it
- Start from the Quickstart, then the agent guide task map.
- In an app, check wiring with
dot explain --json(no side effects) and boot withdot doctor --json(boots and disposes; never callsstart).
Verify
Run in packages/dot:
bun run build
bun run test:docs
bun run typecheck
bun run test
bun run lint
bun ../../tooling/library/src/llms.ts --check
bun ../../tooling/library/src/error-index.tsThe last line must report 0 without @fix/@verify.