Concepts
Configuration
Every configuration key Fensu reads, how it discovers config, and how to override thresholds and contracts.
Fensu is configured with fensu.toml or [tool.fensu] in pyproject.toml.
Configuration declares the scopes Fensu scans, the rules it runs, and any
threshold, exception, or contract overrides.
Where config comes from
Section titled “Where config comes from”fensu check, fensu rule, and fensu skills search upward from the current
directory for:
fensu.tomlpyproject.tomlcontaining[tool.fensu]
The nearest directory wins, and fensu.toml takes precedence over
pyproject.toml in the same directory. The first source found is used whole;
sources are never merged.
roots = ["src/my_package"]tests = ["tests"]tooling = ["scripts"]select = ["FF"]
[thresholds]max_positional_args = 1[tool.fensu]roots = ["src/my_package"]tests = ["tests"]tooling = ["scripts"]select = ["FF"]
[tool.fensu.thresholds]max_positional_args = 1Named analyzer targets
Section titled “Named analyzer targets”Flat top-level keys configure a single Python project. Use explicit [targets.<name>]
tables for multiple projects or Rust, TypeScript, and Svelte analyzers:
[targets.backend]analyzer = "python"root = "."roots = ["src/acme"]ownership_roots = ["src/acme/sources/*", "src/acme/runtime"]tests = ["tests"]select = ["FF"]
[targets.web]analyzer = "svelte"root = "frontend"roots = ["src"]tests = ["tests"]test_layout = "mirrored"rule_packs = ["sveltekit"]select = ["FPSK"]
[targets.rust]analyzer = "rust"roots = ["crates"]tests = []tooling = ["crates/project-tools"]rule_packs = ["rust"]select = ["FPRS"]Each target requires analyzer (python, rust, typescript, or svelte) and
roots. root defaults to . and resolves the target’s paths relative to the
configuration directory. Explicit targets cannot be mixed with flat top-level
keys except top-level [repository_rules] (see
Repository rules). fensu check runs every target
unless --target NAME selects one.
Web targets also accept test_layout, ui_kit, shadcn, openapi, and
generated (see TypeScript and SvelteKit).
Rust targets discover Cargo workspace members automatically (see
Rust).
Validation is strict
Section titled “Validation is strict”Fensu fails closed on invalid configuration rather than silently dropping typos:
- Unknown keys, missing
roots, missing paths on disk, nested or overlappingroots, and duplicate scope package names are rejected. - A rule cannot appear in both
selectandwarn, or bothwarnandignore. - All thresholds, role names, pack names, rule options, globs, and required
reasonfields are validated before evaluation starts.
Top-level keys
Section titled “Top-level keys”| Key | Type | Default | Purpose |
|---|---|---|---|
targets | table of tables | none | Named analyzer targets; mutually exclusive with flat keys. |
repository_rules | table | none | Cross-target custom-rule policy for named targets. |
roots | list of strings | required | Product code scopes (no nesting or overlap). |
ownership_roots | list of strings | analyzer-specific | Directories below which domains and subdomains begin. |
tests | list of strings | ["tests"] | Test scopes. |
test_scopes | list of strings | ["unit", "integration", "e2e"] | Allowed directory names directly under a test root. |
tooling | list of strings | [] | Dev tooling scopes. |
select | list of selectors | complete analyzer policy | Blocking rules to enable. |
warn | list of selectors | [] | Advisory rules evaluated by fensu check --warn. |
ignore | list of selectors | [] | Rule codes to disable. |
rule_paths | list of strings | [] | Directories or files of Python custom rules to load. |
rule_modules | list of strings | [] | Importable Python modules holding custom rules. |
rule_packs | list of strings | [] | Fensu-shipped native policies to activate. |
rule_options | rule-code tables | declared defaults | Per-rule option overrides. |
thresholds | table | shipped defaults | Global threshold overrides. |
threshold_overrides | array of tables | [] | Path-scoped threshold overrides with reason. |
rule_exceptions | array of tables | [] | Exact rule/file (and optional symbol) exceptions with reason. |
rule_ignores | array of tables | [] | Path-scoped rule suppressions with reason. |
evaluation | table | all discovered files | Direct evaluation include / exclude globs. |
cache | table | caching on | Persistent result cache settings for fensu check. |
custom_host_timeout_seconds | integer (1–600) | 30 | Custom-rule timeout for Rust, TypeScript, and Svelte targets. |
skills | table | inferred identity | Generated agent-skill settings. |
roles | table of tables | none | Per-role threshold overrides. |
contracts | table | ten shipped patterns | Function-name glob to behavior contracts. |
Ownership roots
Section titled “Ownership roots”roots declares which product code Fensu scans; ownership_roots declares
where domain ownership begins inside that tree when structural grouping
directories sit above domains:
[targets.app]analyzer = "python"roots = ["src/example"]ownership_roots = ["src/example/sources/*", "src/example/runtime"]src/example/├── sources/ # structural group│ ├── region_a/ # ownership root│ │ ├── orders/main/process.py│ │ └── partners/importing/main/load.py│ └── region_b/ # ownership root│ └── inventory/main/refresh.py└── runtime/ # ownership root └── observability/main/report.pyPatterns are target-relative POSIX globs supporting *, standalone **, and
brace alternatives (src/example/{sources/*,runtime}). Deepest concrete root
wins; equal-specificity overlaps, unmatched patterns, unused roots, and roots
crossing main/, _helpers/, or classes/ fail closed. Structural directories
above or at an ownership root cannot hold role files directly.
Defaults when omitted:
| Analyzer | Default ownership roots |
|---|---|
| Python | Each configured product root. |
| TypeScript and Svelte | The lib/ directory below each product root. |
| Rust | Cargo-inferred crate source roots. |
Selection
Section titled “Selection”select, warn, and ignore accept rule-code prefixes or exact codes:
| Selector | Matches |
|---|---|
FF / FFR / FFR3 / FFR301 | All core rules, one family, one bucket, or one exact rule. |
FP / FPTS / FPSK / FPRS / FPDG | All activated native packs, or one pack namespace (FPDGA = Dagster annotation aliases). |
X / XDB / XDB001 | All custom rules, one namespace, or one custom rule. |
select defaults to ["FF"] for Python and ["FP"] for Rust, TypeScript, and
Svelte targets (Rust activates rust automatically; web packs must be listed in
rule_packs).
select = ["FFL", "FFR", "FFS", "FFN", "FFH", "FFT"]ignore = ["FFH007", "FFA103"] # ignore always wins over select- A rule runs when it is enabled by default and matches
select, or is named by its exact code inselect(the only way to enable opt-in rules such asFFS102). ignorealways wins overselect.- Activating a pack in
rule_packsmakes its catalogue available; select its prefix separately.
The warn tier
Section titled “The warn tier”warn defines an advisory ruleset evaluated only with
fensu check --warn. Warnings are reported after faults
and never affect the exit code:
select = ["FFL", "FFR", "FFS", "FFN", "FFH", "FFT"]warn = ["FFA"]A resolved rule cannot appear in both select and warn, or both warn and
ignore.
Exact rule exceptions
Section titled “Exact rule exceptions”Use [[rule_exceptions]] for an unavoidable finding in one exact file. Add
symbols to narrow the waiver to named functions or methods:
[[rule_exceptions]]rule = "FFS120"path = "src/my_package/integrations/_helpers/callbacks.py"symbols = ["ProgressCollector.update"]reason = "The external API invokes this callback positionally."Omit symbols to waive matching findings across the whole file (symbols = []
is rejected). Rule code, repository-relative file path, and symbols must be exact
(no globs or line numbers). Every exception and listed symbol must suppress a
fault; stale exceptions fail fensu check. Rust uses item paths such as
Record::load (see Rust).
Path-scoped rule ignores
Section titled “Path-scoped rule ignores”Use [[rule_ignores]] to suppress findings for matching rule selectors and path
globs while keeping the rules and project context active:
[[rule_ignores]]rules = ["FFA", "XGENERATED"]paths = ["src/my_package/generated/**", "conftest.py"]reason = "Generated interfaces are checked by their source schema."A finding is suppressed only when one entry matches both its rule code and its
reported path. Applies to both blocking and --warn runs. Path-scoped ignores
are not stale-checked; exact rule_exceptions are validated first so a broad
ignore cannot hide a stale exact waiver.
Evaluation targeting
Section titled “Evaluation targeting”[evaluation] narrows which discovered files receive direct rule execution
during gradual adoption:
[evaluation]include = ["src/my_package/compiler/**", "tests/unit/src/my_package/compiler/**"]exclude = ["src/my_package/compiler/generated/**"]| Configuration | Direct evaluation targets |
|---|---|
| Neither key | Every discovered source file. |
exclude only | Every discovered file except excluded matches. |
include only | Only included matches. |
include and exclude | Included matches minus excluded matches (exclude wins). |
Every include glob must match at least one discovered file and leave at least
one target; unmatched excludes are allowed. Excluded files remain part of
project context for imports, ownership resolution, and fensu map.
fensu check reports target and discovery counts when
filtering is active.
Choosing the right boundary
Section titled “Choosing the right boundary”| Control | Effect |
|---|---|
roots, tests, tooling | Define the discovered project universe and each file’s scope. |
warn | Report matching rules as nonblocking advice with fensu check --warn. |
ignore | Disable matching rules globally. |
rule_exceptions | Waive one exact file or symbol finding and fail when stale. |
rule_ignores | Keep rules and context active while suppressing matching selector/path findings. |
evaluation.include / exclude | Restrict which discovered files receive direct rule execution. |
Test scopes
Section titled “Test scopes”test_scopes lists the allowed top-level directories under a test root
(default ["unit", "integration", "e2e"]). Setting it replaces the default:
test_scopes = ["unit", "integration", "e2e", "real"]Entries must be unique, non-empty lowercase directory names. FFT002 rejects
unlisted directories so typos such as tests/uint/ never go unchecked.
Thresholds
Section titled “Thresholds”[thresholds] overrides shipped numeric limits globally (see
Default thresholds for all
names and defaults; 0 disables min_* thresholds):
[thresholds]max_statements = 50max_positional_args = 1max_file_lines = 1500Per-role overrides
Section titled “Per-role overrides”[roles.<role>] overrides thresholds for one fixed Fensu role (main, helpers,
classes, models, types, constants, exceptions, entry):
[roles.entry]max_statements = 30Path-scoped threshold overrides
Section titled “Path-scoped threshold overrides”[[threshold_overrides]] overrides thresholds for matching fault paths (most
specific glob wins; ties go to the later entry; beats [roles] and
[thresholds]):
[[threshold_overrides]]paths = ["src/my_package/reporting/**"]thresholds = { max_file_lines = 3000 }reason = "Generated report tables exceed the default line budget."Each entry requires paths (repository-relative POSIX globs), thresholds
(non-negative integers), and a non-empty reason. For container and package
size rules (max_helpers_container_buckets, max_crate_code_lines), match the
reported path (_helpers/__init__.py, package __init__.py, or Cargo.toml).
Contracts
Section titled “Contracts”[contracts] maps function-name globs to naming-family behaviors:
| Behavior | Rule | Requirement |
|---|---|---|
no-return | FFN001 | Do not return a meaningful value. |
returns-bool | FFN002 | Declare bool, TypeGuard, or TypeIs. |
returns-value | FFN003 | Do not explicitly declare None. |
returns-iterator | FFN004 | Yield or declare an iterator or generator return. |
Shipped defaults: validate_* and enforce_* (no-return); is_*, has_*,
can_*, supports_* (returns-bool); get_*, to_*, as_* (returns-value);
iter_* (returns-iterator). Add project patterns directly:
[contracts]"write_*" = "no-return""yield_*" = "returns-iterator"Conflicting patterns on one function fail configuration. For other behaviors, write a custom rule.
Native rule packs
Section titled “Native rule packs”rule_packs activates shipped native policies (dagster, typescript,
sveltekit, rust):
rule_packs = ["dagster"]select = ["FPDG"]See Native rule packs and the Dagster, TypeScript and SvelteKit, and Rust pages for pack rules and options.
Custom rule loading
Section titled “Custom rule loading”rule_paths (directories or .py files loaded in isolation) and rule_modules
(importable repository modules) load @rule-decorated checks into the same
catalogue as core and pack rules:
tooling = ["scripts"]rule_paths = ["scripts/fensu_policy/rules"]rule_modules = ["company_architecture.rules"]select = ["FF", "XAC001"]See Custom rules for the authoring API.
Rule options
Section titled “Rule options”Override typed rule options by exact rule code; only overrides belong in TOML (defaults live in rule definitions, and list overrides become immutable tuples):
[rule_options.XAC001]allowed_names = ["alpha", "beta"]strict = trueFensu validates all [rule_options.*] tables against the full catalogue before
evaluation, including unselected rules.
[cache] ([tool.fensu.cache] in pyproject.toml) controls the persistent
result cache used by fensu check:
| Key | Type | Default | Purpose |
|---|---|---|---|
enabled | boolean | true | Persist and reuse per-file results between runs. |
require_cacheable | boolean | false | Verify selected custom rules use only tracked inputs so runs stay cached. |
Override for a single run with --cache or --no-cache. See
Keeping custom rules cacheable.
Skills
Section titled “Skills”[skills] sets the project slug used by fensu skills (for
example .agents/skills/fensu-acme-api/SKILL.md):
[skills]name = "acme-api"When omitted, Fensu infers the name from [project].name in pyproject.toml,
then the configuration directory name.
The self-hosted example
Section titled “The self-hosted example”Fensu checks both its Python and Rust codebases with named targets:
[targets.python]analyzer = "python"roots = ["src/fensu"]tests = ["tests"]tooling = ["scripts"]select = ["FF"]
[targets.rust]analyzer = "rust"roots = ["crates"]tests = []tooling = ["crates/fensu-rust"]rule_packs = ["rust"]select = ["FPRS"]