09. Bailiff
Bailiff is an ESLint plugin plus a CLI wrapper. Violations show up as editor squiggles, so nobody has to remember to leave a code review comment.
This is the feature that separates Avelon from a boilerplate. A template is advice. A linter is a decision.
Rules
Every rule ships with a documented reason, and an autofix or codemod where one is possible. A rule you can't explain in 1 sentence doesn't belong in the set.
Every rule is an error except controller-thinness, which is a warning:
no-vendor-import- no vendor SDK imported outside a driver package oravelon.config.tsno-cross-layer- Views can't import Models. Controllers can't import Controllers. Models can't import anything underHttp/no-orphan-query- database access only in Models, Actions, Errands, and seeds. Never in a component or a pageno-unwarded-Scrivener.unwarded()only inapp/Errands/anddatabase/seeds/require-ward- every model has a wardno-raw-outside-drivers-driver.raw()only inapp/Drivers/,avelon.config.ts, or behind an explicit disable commentno-hand-edited-generated- any diff to generated paths that didn't come from a generatorno-bun-in-core-@avelonjs/coreand@avelonjs/ormmay not importbun:*no-model-across-boundary- a model instance passed toview()instead of a serializerrequire-request- a write action validates through a Requestno-fake-transaction- sequential writes wrapped in try/catch and named like a transactionrelation-depth-.with()chains past the configured driver'smaxRelationDepthno-lib-dumping- there is nolib/. A file has a home or it doesn't existno-not-supported-error- throwing on an unsupported capability instead of typing it awayattribute-schema-match- model attribute declarations matchdatabase/types.tscontroller-thinness- a controller action past N statements suggests an Actionno-any-public-anyin an exported signaturerequire-disable-reason- abailiff-disable-next-linecomment names the rule and a reason after--
Why Each Error Rule Exists
no-vendor-import
This is the whole driver system. One import in a controller and the abstraction is decorative.
no-cross-layer
Keeps the structure legible after the person who set it up leaves. A view importing a model is how "just this once" becomes an architecture.
no-orphan-query
Stops the pattern where a component fetches its own data. That's how you get 40 queries on a page and no way to see them.
no-unwarded and require-ward
Data leak prevention. A model without a ward is a table anybody can read.
no-hand-edited-generated
Protects the upgrade path. A hand-edit to a generated router silently disappears at the next sync, and the person who made it won't connect the two events.
no-model-across-boundary
Turns a confusing serialization error at runtime into a clear one at authoring time.
no-fake-transaction
Subtle, and worth the rule. Code that reads as atomic and isn't produces partial writes under failure. Reviewers don't catch it because it looks correct.
attribute-schema-match
Makes a column rename a type error rather than an incident.
Escape Hatches
Every rule can be disabled inline, and every disable needs a reason:
// bailiff-disable-next-line no-raw-outside-drivers -- pgvector similarity, no IR support yet
const sql = DB.raw()
A bare // bailiff-disable-next-line with no reason is itself an error.
This matters more than the rules do. A linter with no escape hatch gets disabled wholesale, and then you lose the entire thesis.
A disable with a reason is a searchable list of everywhere the framework wasn't good enough. That's a roadmap.
Running It
reeve bailiff
reeve bailiff --fix
reeve bailiff --explain no-orphan-query
reeve bailiffruns all rules--fixruns the autofixable rules only
What a Scan Skips
A default scan skips:
node_modules.nextdistarchive/spikes/
Archive trees are history and spikes are throwaway, so neither is product code. Application and library code still has to obey the rules.
Tests under @avelonjs/core and @avelonjs/orm may import bun:test, because they aren't the runtime graph. bun:* in those packages' src/ is still an error.
Where It Runs
Bailiff ships in reeve doctor and in the default CI workflow.
Editor integration is the ESLint plugin, so you don't need a separate extension.
Configuration
Rules are on by default.
A project that lints with ESLint directly can downgrade a rule to warn or disable it. Do that in its ESLint config, after bailiff.configs.recommended.
reeve bailiff always lints with the recommended config, so CI reports every rule at its default severity.
A project-specific rule uses the same plugin API the built-in rules use.