Workflow plane. Six n8n workflows, three worked scenarios and three shared mechanisms, plus a 13-rule static linter: authenticated ingress, exactly-once processing, retry to dead-letter to replay, resumable syncs, deterministic handling of model output.
Verifiable in a minute. package.json declares no dependencies, so this runs on a clean checkout with nothing installed:
node linter/cli.js lint 01-order-intake/workflow.jsonEvery rule traces to a named failure mode, and every claim is proven by a test that causes that failure on purpose. Start at docs/testing.md.
CI runs the same evidence on every push: the offline suite, the aggregate lint (non-zero on any ERROR), and the live queue-mode stack with the failure-injection suites. The badge above is the current result.
A worked reference for taking n8n workflows from "it runs on my machine" to something that survives production: authenticated ingress, exactly-once processing, bounded retries with a dead-letter path and a replay, resumable scheduled syncs, deterministic handling of model output, liveness alerting for work that silently stops happening, and a static linter for the anti-patterns behind the most common incidents.
The thesis: a hardened workflow treats every failure path as a designed, tested, wired mechanism — not a TODO. Anyone can draw the happy path. What separates a workflow that works from one that keeps working is what happens when the upstream returns a 503, when the same order arrives twice, when the model returns prose instead of JSON, when a provider goes down, and when a nightly job quietly stops running. Each of those has a defined response here, and each response is verified by a test that causes the failure on purpose.
Everything runs locally with Docker Compose and a Node.js test suite. No SaaS
accounts, no hosted state, and no dependencies — package.json declares none.
Self-hosting n8n means securing three different things, and they are not the same job. Most material treats them as one. This repository covers one of them, and says plainly which.
| Plane | What it covers | Where it lives |
|---|---|---|
| Workflow ← you are here | The automations themselves: authenticated ingress, idempotency, bounded retries, dead-lettering, model-output validation, liveness | this repository |
| Stack and container | Compose topology, reverse proxy and TLS termination, queue mode, secret delivery, capability drops, database privileges | n8n-hardened-reference |
| Host and OS | CIS Ubuntu 24.04 Level 1, Server profile: SSH policy, kernel and sysctl parameters, host firewall, auditd, patch posture | vps-hardening-reference — scope and status published, assertion suite in development |
They compose without overlapping, and each is incomplete on its own. Hardened workflows on an unhardened host leave correct logic behind an open door. A locked-down host running unhardened workflows silently drops orders. A hardened stack on an unhardened host is still an unhardened host.
What this repository does not cover. The host and OS plane — nothing here makes any claim about the machine underneath, and you should not read one into it. Nor is the Compose stack below a production deployment reference: it exists to run and exercise these workflows on loopback, and a stack built to face the public internet, with TLS termination and its own threat model, is the container-plane project above.
| Path | What it is |
|---|---|
01-order-intake/ |
HMAC-authenticated webhook → validation → idempotent claim → bounded retry → dead-letter → response. |
02-crm-sync/ |
Scheduled delta sync with a PostgreSQL watermark advanced only to the last record that succeeded with no failure before it. |
03-support-triage/ |
Model-assisted triage with a deterministic parser, a JSON Schema contract, and a fallback on a genuinely different vendor. |
_shared/ |
The global error handler every workflow points at, the stale-run watchdog, and the dead-letter replay. |
deployment/ |
The Compose stack: n8n main + worker in queue mode, Valkey broker, PostgreSQL, a mock upstream API, a mock model provider, Prometheus and Grafana. |
linter/ |
A dependency-free static linter for exported workflow JSON, rules R1–R13. |
docs/ |
Golden patterns, the failure-mode taxonomy, the anti-pattern catalogue, the testing methodology, and the broker-choice rationale. |
schemas/ |
The output contract the triage workflow validates every model response against. |
curated/ |
Annotated outside references, with dated observations. |
tests/ |
Failure-injection and structural tests, run with node:test. |
typeversions.json |
Every node typeVersion this repository is pinned to, confirmed against a live instance. |
PUBLISH-CHECKLIST.md |
The publish-readiness checks that cannot honestly be automated. |
- Node.js 20 or later — declared in
package.jsonengines. - Docker, with Compose v2 — required to run the stack, and required by the parts of the test suite that render or exercise it. Without it those parts fail rather than skip: the suite does not report a pass it did not measure.
The linter needs neither a stack nor any dependency, which is why the one-command check at the top of this file works on a bare checkout.
cp .env.example .env # then set local values; .env is git-ignored
npm run stack:up # Compose up, waits for every service healthy
npm test # the whole suite; fails loudly if the stack is downThen:
- n8n — http://127.0.0.1:5678
- Grafana ops overview — http://127.0.0.1:3030
- Prometheus — http://127.0.0.1:9090
All three are bound to loopback only.
Eleven patterns, each implemented by a workflow here and each explained in
docs/golden-patterns.md: error-handler-first,
idempotency before the side effect, retry with an explicit stop, validate before
acting, two-layer webhook authentication with constant-time comparison, rate
limiting by pacing rather than retrying, timezone-pinned schedules, a watchdog
for silence, partial-failure isolation with a replay, deterministic parsing with
schema validation, and a provider fallback that fails independently.
Patterns no static check can see are tagged [structural] rather than left
implying coverage that does not exist.
The six classes of failure those patterns answer — transient, permanent,
invalid-input, silent-skip, rate-limit, and model-or-provider failure — are set
out with their wired defences in
docs/failure-mode-taxonomy.md.
Each linter rule maps to a production incident, catalogued in
docs/anti-patterns.md. The headline entry is n8n issue
#9236: a node configured with
retries whose error behaviour lets the workflow continue down the success path
carrying an error object, so the retries happen, all of them fail, and the
execution is still recorded as successful.
The catalogue also covers the two traps that need a whole workflow to fix rather than a rule — nothing alerting when a workflow stops running, and a "fallback" that shares fate with the thing it is protecting.
node linter/cli.js lint 01-order-intake/workflow.jsonThirteen rules over exported workflow JSON: missing error workflow, unpinned
typeVersion, a webhook with no response node, a side-effecting call with no
retry, SQL built from an expression, a hardcoded secret, swallowed errors, a
network call with no timeout, a schedule with no timezone, unvalidated model
output, a model repairing another model's output, single-vendor dependency, and
resumable state kept in workflow static data.
It is standard-library only and runs from a checkout with nothing installed. The
bar is zero false positives across the clean fixture set, which includes this
repository's own workflows — a rule that fires on hardened, working workflows
trains people to ignore the linter. Scope, the repo-scan design, and why one
obvious rule is deliberately deferred are in
linter/ROADMAP.md.
deployment/ runs n8n in queue mode: main handles ingress and
enqueues, a worker executes. The broker is authenticated and unpublished to the
host, and the stack fails closed if its password is unset. Secrets are delivered
per service rather than broadcast, so exactly one secret is reachable from a Code
node — enforced by a test, not by convention.
Observability is wired in. Prometheus scrapes both n8n processes, and a pre-provisioned Grafana dashboard covers execution rate, duration, error rate, queue depth, event-loop lag and memory. Panel expressions use metric names taken from a live scrape, because a dashboard built on names copied from documentation renders empty while the API still returns HTTP 200.
deployment/README.md— stack walkthrough, pinning rationale, and how to verify queue mode.deployment/docs/environment-reference.md— every variable with its reason, retention tuning, and the no-catch-up caveat.deployment/docs/enterprise-ha-architecture.md— the multi-main architecture, what it requires, and why this stack is not it.
Host and OS hardening — SSH policy, kernel and sysctl parameters, host firewall, auditd, patch posture — is out of scope here, and it is not the container-plane project's job either: it is the third plane, whose scope and status are published and whose assertion suite is in development. Public-internet exposure and TLS termination belong to the container plane. See The three planes.
The suite injects failures rather than confirming the happy path, and asserts
against the transport and the database rather than the workflow's own account of
itself. Methodology, the dual-counter pattern, the fixture-response pattern, and
an explicit list of what the suite does not cover are in
docs/testing.md.
Outside material worth reading, with the criteria each entry had to meet and the
date each claim was observed:
curated/curated-collections.md.
- n8n v2.x. The stack pins an exact image tag and digest, and
typeversions.jsonpins every nodetypeVersionin use. - PostgreSQL is required for queue mode. SQLite cannot back a distributed deployment, and MySQL support was removed in n8n v2.0.
- Task runners are external in v2.0 and later; the stack enables them explicitly rather than relying on a default.
- n8n is distributed under the fair-code Sustainable Use License, which is not an OSI-approved open-source licence. Multi-main high availability and log streaming require a self-hosted Enterprise plan; Prometheus metrics do not, which is why this repository can demonstrate them.
MIT — see LICENSE. To report a vulnerability, see
SECURITY.md.
A workflow that works in a demo can still lose an order. Each workflow here answers a failure a demo never shows. The five worked scenarios are an unauthenticated webhook, the same order arriving twice, an upstream 503, a model returning prose instead of JSON, and a scheduled job that silently stops.
For each one, a test in tests/ causes the failure on purpose and checks the response, so you can re-run the evidence yourself. The same failure modes are the ones that drop inbound leads between the form and the CRM.
These are the patterns I apply when I repair and harden a client's n8n workflows, after a written diagnosis has found the cause.
Jarrod Wright, working as The Certainty Engineer. I step in when a production n8n workflow or AI agent breaks, working across three planes: the workflows, the container stack they run on, and the host underneath. These repositories are the reference implementations I work from.
Every engagement follows one sequence. Triage is free: what broke, and whether I'm the right person.
Then comes a paid, written diagnosis, where every root cause is backed by evidence and the report names causes, never people.
No repair starts before that. It's proven against a test that reproduces the failure, and handed back with a runbook so you can run it without me. The method follows Google SRE incident practice, ITIL 4 change control and NIST SP 800-61r3 for security incidents.
The same engineering backs inbound-aware GTM systems I build for SaaS teams whose inbound runs on automations. The work covers speed-to-lead with a system SLA, dormant-pipeline recycling from your own systems, and pipeline reporting. That work starts the same way, with a written diagnosis.
If that is close to what you need, email jarr.wright@gmail.com. Tell me what you are running and what is breaking. I reply within 24 hours, and I'll tell you straight whether I can help and what the first step costs.
If you would rather ask in public first, open an issue on this repository.
If you found me through a freelancing platform, please keep the conversation there until a contract is in place.