Expand description
Architecture rules for ctx check.
Rules live in .ctx/rules.toml and are checked against the code
intelligence index. The file declares named layers (glob patterns over
indexed file paths) plus four kinds of rules:
[[rules.forbidden]]– layer A must not depend on layer B[[rules.allowed_dependents]]– only the listed layers may depend on a layer[[rules.limit]]– metric thresholds (fan-in/fan-out/complexity/file symbols)[[rules.no_new_dependents]]– frozen paths that must not gain callers
This module contains the serde model, glob compilation/validation, and
pure evaluation functions over a pre-built list of FileDeps, so the
rule engine is unit-testable without a database.
Structs§
- Allowed
Dependents Rule [[rules.allowed_dependents]]: only layers inonlymay depend onlayer.- Compiled
Rules - A
RulesFilewith all glob patterns compiled. - FileDep
- A cross-file dependency (call/implements/extends/uses edge or resolved import).
- Forbidden
Rule [[rules.forbidden]]: dependencies fromfromtotoare violations.- Limit
Rule [[rules.limit]]: a metric threshold over symbols or files.- NoNew
Dependents Rule [[rules.no_new_dependents]]: frozen paths that must not gain dependents.- Rule
Groups - The
[rules]table. - Rules
File - Parsed
.ctx/rules.toml. - Violation
- One rule violation.
Enums§
- Endpoint
- One endpoint of a dependency: either a resolved symbol or a whole file (file-level endpoints come from import resolution).
- Metric
- Metric checked by a
[[rules.limit]]rule. - Rule
Kind - Which rule group a violation belongs to.
- Scope
- Scope of a
[[rules.limit]]rule.
Constants§
- DEFAULT_
RULES_ PATH - Default location of the rules file, relative to the project root.
- SUPPORTED_
VERSION - The rules file format version this build understands.
Functions§
- evaluate
- Evaluate all rules and return the violations.