AGENTS.md
packages/@n8n/engine/AGENTS.mdAGENTS.md
Quality
59/100
Scores the file, not the repository.Length
596 words
7 headings · 0 code blocksRepository
199k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# @n8n/engine — structure & modularity intent23## The blueprint we're following45We structure this package after the **Durable Scheduler modularity blueprint**6([Notion](https://app.notion.com/p/n8n/The-Durable-Scheduler-a-modularity-blueprint-39f5b6e0c94f8193a5fecca8306c4424),7worked example: `packages/@n8n/scheduler`, enforced by its8`src/__tests__/dependency-purity.test.ts`). The core idea: a **pure core that9decides, with every effect handed in as an injected interface**. Dependency10arrows point one way — consumers depend on the engine; the engine core reaches11for nothing.1213## Reality now: loose, but seam-aware1415We are deliberately **loose about composition at this stage**. This one package16currently holds the engine core *and* its serving/persistence infrastructure.17We expect things to shuffle, so we're not paying the full ports-and-adapters18tax yet. What we **do** commit to is keeping the internal boundaries clean, so19serving infra and persistence can later be lifted into their own packages (e.g.20a deployable engine worker) without touching core logic.2122## Layers (today, all in this package)2324- **Core (decides)** — `graph/`, `execution/`, `admittance/`. Pure25 orchestration/policy. Must not open connections, bind an HTTP server, or read26 the environment. Everything external arrives via constructor args / a deps bag27 (the `createScheduler(deps)` pattern).28- **Core interfaces** — interfaces the core depends on, each defined in its own29 core module beside a default/reference use: `AdmittanceService` (`admittance/`),30 `WorkQueue` (`queue/`), `ExecutionStore` (`execution/`). Adapters implement31 them; the core never imports the interface from an adapter. Handed in at32 construction.33- **Adapters (do)** — effectful implementations: `database/` (TypeORM entities,34 migrations, the Postgres `DataSource`, and `TypeOrmExecutionStore`), `queue/`35 (in-memory default). The Postgres/ORM coupling lives *here only*.36- **Serving infra** — `server/` (express), `serve.ts` (standalone entrypoint),37 Dockerfile. First candidate to be extracted later.38- **Composition roots** — `serve.ts` (standalone) and, in integrated mode,39 `packages/cli`. These construct the concrete adapters (the `DataSource`, etc.)40 and hand them in. **Construction lives here, not in the core.**4142## Rules that keep the seams extractable4344- Core modules (`graph`, `execution`, `admittance`) don't import `express`,45 `pg`, or `@n8n/typeorm`, don't construct a `DataSource`, and never import from46 `database/`. Persistence, queue, and HTTP are injected. The dependency arrow47 is one-way: `database/` imports the interface + domain types from the core, not48 the reverse.49- `@n8n/typeorm` / `pg` stay confined to `database/`.50- `@n8n/config` + `@n8n/di` are used only at the serving/composition layer (for51 `EngineConfig`), never in core logic. (The blueprint flags `@n8n/config` as52 debatable precisely because it pulls the DI runtime in — keep it out of core.)53- We go one step stricter than the scheduler's allowlist: **no `n8n-workflow`54 dependency at all, not even type-only** (per the Engine 2.0 design — the core55 must stay free of v1 concepts). Shared JSON types are redefined locally in56 `common/`.57- Arrows point inward: `cli`/`serve` depend on the engine; the engine never58 imports `cli`.59- When serving infra is extracted, add a `dependency-purity.test.ts` (as60 `@n8n/scheduler` does) to enforce the allowlist. Until then, this doc is the61 intent.6263## Crash recovery: reconciliation, not transactions6465Handlers advance an execution through several separate writes — claim the66execution, insert step rows, publish the next message — and we deliberately do67**not** make that sequence atomic. Crashing partway through can leave partial68state, such as an execution stuck `running` with no queued step.6970The intended answer is a reconciliation layer that detects crashed or stalled71executions and drives recovery (CAT-2938), not transactions spanning stores and72queues. So when you find a partial-write window: make the resulting state73legible to reconciliation, and don't reach for a cross-store transaction. It's a74recurring review question — this is the standing answer.7576## Known deviations — the seams to clean up on decomposition7778- `DataSource` construction currently lives in `database/`; it is really a79 composition-root concern.80
Also in n8n-io/n8n
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| n8n-io/n8n.agents/skills/AGENTS.md · 199k | AGENTS.md | setuparchagent-behaviour | 58/100 | 3 days ago | |
| n8n-io/n8n.github/CLAUDE.md · 199k | CLAUDE.md | styleagent-behaviour | 48/100 | 3 days ago | |
| n8n-io/n8nAGENTS.md · 199k | AGENTS.md | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/ai-workflow-builder.ee/AGENTS.md · 199k | AGENTS.md | agent-behaviour | 53/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/db/AGENTS.md · 199k | AGENTS.md | database | 39/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/instance-ai/CLAUDE.md · 199k | CLAUDE.md | buildteststyletesting-strategy+1 | 89/100 | 3 days ago | |
| n8n-io/n8npackages/cli/AGENTS.md · 199k | AGENTS.md | lint-format | 55/100 | 3 days ago | |
| n8n-io/n8npackages/cli/src/modules/n8n-packages/CLAUDE.md · 199k | CLAUDE.md | stylearchdependenciesmonorepo+2 | 69/100 | 3 days ago | |
| n8n-io/n8npackages/frontend/AGENTS.md · 199k | AGENTS.md | style | 40/100 | 3 days ago | |
| n8n-io/n8npackages/frontend/editor-ui/src/app/stores/workflowDocument/CLAUDE.md · 199k | CLAUDE.md | styleagent-behaviour | 58/100 | 3 days ago | |
| n8n-io/n8npackages/nodes-base/AGENTS.md · 199k | AGENTS.md | teststylearchtypes+5 | 89/100 | 3 days ago | |
| n8n-io/n8npackages/testing/playwright/AGENTS.md · 199k | AGENTS.md | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| n8n-io/n8nscripts/instance-seeding/AGENTS.md · 199k | AGENTS.md | setupstyledo-not | 65/100 | 3 days ago |
Diff against .agents/skills/AGENTS.md Diff against .github/CLAUDE.md Diff against AGENTS.md Diff against packages/@n8n/ai-workflow-builder.ee/AGENTS.md Diff against packages/@n8n/db/AGENTS.md Diff against packages/@n8n/instance-ai/CLAUDE.md Diff against packages/cli/AGENTS.md Diff against packages/cli/src/modules/n8n-packages/CLAUDE.md Diff against packages/frontend/AGENTS.md Diff against packages/frontend/editor-ui/src/app/stores/workflowDocument/CLAUDE.md Diff against packages/nodes-base/AGENTS.md Diff against packages/testing/playwright/AGENTS.md Diff against packages/@n8n/agents/AGENTS.md Diff against scripts/instance-seeding/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/inference/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+3 | 100/100 | 3 days ago |
