Skip to content

Layer rules: tempest lint-layers

Look up every architecture rule tempest lint-layers enforces, with its code and how to fix it.

Part of the CLI recipe.

The CLAUDE.md that tempest new writes says how a service and a repository are shaped. Prose is not a gate: a service with ten services without BaseService, repositories wrapping the SDK's list, and loose functions in a services/feeds.py passed ruff, mypy and pytest clean (#520). tempest lint-layers is the gate for those rules (and for the enum naming convention) — and tempest check runs it as a step of its own, after mypy and before pytest:

tempest lint-layers            # the project in the current directory (reads src/ or app/)
tempest lint-layers src        # the source directory itself

It reads the code with ast and never imports the project, so it runs even with a broken import. Each violation is one path:line: CODE message line, and the message says what to change:

Code Where What it flags
SVC001 services/ a public class that does not inherit BaseService (directly, through another project service, or through a *Service imported from tempest_fastapi_sdk)
SVC002 services/ a second public class in the module, or any module-level function — a helper goes to utils/
SVC003 services/ an __init__ that only calls super().__init__ with its own parameters and/or stores self.repository
REPO001 repositories/ a method whose body is only return [await] self.<BaseRepository method>(...)
ENUM001 all source a public class inheriting BaseStrEnum (directly or through another project class) whose name does not end in Enum — the message names the expected name; renaming needs no migration, because enum_type_name drops one trailing Enum (#518)
RTR001 routers/ a call to a *Controller or *Service class (a name starting upper case) anywhere in the module — route body, helper function, module level. The construction goes to a provider in api/dependencies/controllers.py and reaches the route through Depends
RTR002 routers/ a route (@<router>.get / post / put / patch / delete / head / options / trace / api_route) whose return annotation or response_model= names an ORM model, at any depth (list[ProductModel], Optional[ProductModel], a union with None)

The three cases of #520, in a project generated by tempest new, come out of tempest check like this (an excerpt of the real output; exit code 1):

$ mypy --disallow-untyped-defs --disallow-incomplete-defs .
Success: no issues found in 29 source files
$ lint-layers
src/db/repositories/news.py:18: REPO001 `NewsRepository.list_all` only forwards to BaseRepository.list; delete it and call `repository.list(...)` with those arguments at the call site.
src/services/feeds.py:9: SVC002 module-level function `page_envelope` in services/; move it to utils/, or make it a method of the service that uses it.
src/services/feeds.py:24: SVC001 `NewsService` does not inherit BaseService; subclass `BaseService[Repository, ResponseSchema]` and drop what it reimplements. A service with no repository opts out with `# tempest: no-base-service` on the class line; a type that is not a service belongs in schemas/ or core/.
src/services/feeds.py:27: SVC003 `NewsService.__init__` only stores the repository, which BaseService already does; delete it.
src/services/feeds.py:37: SVC002 `TrendService` shares this module with `NewsService`; one public class per module in services/ — move it to its own file.
14 layer finding(s).

The project as tempest new generates it passes clean, and stays clean with the CLAUDE.md ProductService / ProductRepository / product router examples copied into it — the suite's test does exactly that.

A service without a repository: explicit opt-out

A service that has no repository to hand to BaseService (a static catalogue read from a file, a facade over an external API) marks its class line with # tempest: no-base-service. The marker takes the class out of SVC001 and SVC003; SVC002 still applies.

# src/services/catalogue.py
import json
from pathlib import Path


class CatalogueService:  # tempest: no-base-service
    """Static catalogue read from a JSON file — there is no repository."""

    def __init__(self, path: Path) -> None:
        self.items: list[dict[str, str]] = json.loads(path.read_text())

It is a comment, not a class attribute, because it is an instruction to the checker and nothing at runtime reads it — the same reason # noqa is a comment.

What REPO001 lets through on purpose

A method that overrides a BaseRepository name (delete forwarding to soft_delete) is a policy, not a wrapper: whoever calls service.delete now deletes logically. And a method that calls another method defined on the same class is not a wrapper of the SDK.

Router: controller through Depends, response as a schema

The two routers/ rules cover the deviations a router shows most: building the controller by hand inside the route, and returning the ORM row. This router, written into a tempest new project, does both:

# src/api/routers/product.py
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession

from src.api.dependencies.resources import get_session
from src.controllers import ProductController
from src.db.models import ProductModel
from src.db.repositories import ProductRepository
from src.services import ProductService

router: APIRouter = APIRouter(prefix="/products", tags=["products"])


@router.get("/{product_id}")
async def get_product(
    product_id: int,
    session: AsyncSession = Depends(get_session),
) -> ProductModel:
    """Read a product."""
    controller = ProductController(ProductService(ProductRepository(session)))
    return await controller.get_by_id(product_id)

tempest lint-layers exits with code 1 and three lines (real output):

src/api/routers/product.py:15: RTR002 route `get_product` returns the ORM model `ProductModel` (return annotation); return the response schema the repository maps it to (`map_to_response`) and annotate the route with that schema.
src/api/routers/product.py:20: RTR001 `ProductController(...)` is built inside a router; move the construction to a provider in api/dependencies/controllers.py and receive it in the route as `Depends(get_...)`. A call that has to stay opts out with `# tempest: router-builds` on its line.
src/api/routers/product.py:20: RTR001 `ProductService(...)` is built inside a router; move the construction to a provider in api/dependencies/services.py and receive it in the route as `Depends(get_...)`. A call that has to stay opts out with `# tempest: router-builds` on its line.
3 layer finding(s).

The fix is the shape the project's CLAUDE.md teaches: the get_product_controller provider in src/api/dependencies/controllers.py builds the chain, the route takes controller: ProductController = Depends(get_product_controller) and annotates its return with ProductResponseSchema.

What counts as an ORM model. A name imported from a module whose path has a models segment (src.db.models, src.db.models.user), or a public class defined in a models/ directory of the project — as long as the route does not import it from a schemas module. A schema that happens to share a model's name stays clean.

A construction that has to stay in the router: # tempest: router-builds

The marker is the exception you own in writing, so review reads the reason. It covers the calls on that line, not the whole module:

# src/api/routers/reports.py
from fastapi import APIRouter

from src.services import ReportService

report_service: ReportService = ReportService()  # tempest: router-builds
router: APIRouter = APIRouter(prefix="/reports")

RTR002 has no opt-out: the fix has one shape — return the schema the repository's map_to_response produces.

What the router rules do not see

They read syntax and never import the project, so these stay out: a route with no return annotation and no response_model=; a model kept outside any models/ directory and imported from a module without that segment; the SDK's own ORM bases (BaseUserModel) used directly in a route; a controller built through an alias (factory = ProductController; factory()) or a class whose name does not end in Controller / Service.

Where @requires sits is not a rule. The permission guards recipe applies @requires to the route as its first form, and requires itself documents route handlers, controller methods and service methods as valid places. Flagging @requires on a route would flag the SDK's own documentation; choosing between the two places is review — the criterion is in Architecture › Guards.

Requires tempest-cli>=0.7.0

The step reaches tempest check through register_commands' extra_steps (tempest-cli 0.5.0), and check's --rule / --strict reach it through run_with_options (tempest-cli 0.7.0); the [cli] extra declares tempest-cli>=0.7.0, so it comes with it. tempest-cli check alone, without the SDK, does not know these rules: they belong to the SDK, and there --rule exits 2.

Layer in a context package (warning)

Four rules check the shape of the four layers — controllers/, services/, repositories/ and models/. They enter as warnings:

Code Where What it reports
LAY001 controllers/, repositories/, models/ a second class in the module (any name, private ones too) or a module-level function. In services/ SVC002 reports it, as an error
LAY002 all four layers a module directly at the layer root: models/route.py goes to models/<context>/route.py. Any context name is fine; __init__.py is exempt
LAY003 all four layers a file name that repeats the layer: services/orders/checkout_service.py becomes services/orders/checkout.py, and the class inside stays CheckoutService. Covers _controller, _service, _repository and _model
REPO002 repositories/ an import of a *Repository name from another repository module (an absolute import with a repositories segment, or a relative one). A name used only as a class base — the project's base repository — passes

A models/route.py with two models and a repository importing another print (real output, exit code 0, since they are only warnings):

src/db/models/route.py:1: LAY002 (warning) models/route.py sits at the root of the layer; move it to models/<context>/route.py (a subpackage per domain context, re-exported by models/__init__.py).
src/db/models/route.py:5: LAY001 (warning) `StopModel` shares this module with `RouteModel`; one class per module in models/ — move it to its own file in the same context package.
src/db/repositories/orders/order.py:1: REPO002 (warning) imports `CustomerRepository` from another repository; a repository reads its own tables (join in the query) and a service combines two repositories.
3 layer finding(s): 0 error(s), 3 warning(s).

The tempest new project passes all of them

The scaffold already comes in context packages (controllers/system/, db/models/users/), with relative __init__ imports, /api only in build_api_router and tests with Cenário:/Esperado:: tempest lint-layers reports nothing, not even a warning (measured with no extras, with auth,queue,tasks,ssr and with admin,email,minio,cache,tasks-redis; tests/cli/test_layer_lint.py pins all three).

What services and controllers receive (warning)

Code Where What it reports
DI001 services/, controllers/ an __init__ parameter annotated with AsyncSession (at any depth: a union with None, a string annotation). The session reaches the repository; the service receives the repository
DI002 services/, controllers/ a service __init__ taking a *Service, or a controller one taking a *Controller. Combining two services is the controller's job
DI003 the whole source a function or method named from_session. Assembly lives in the provider in api/dependencies/ (inside a request) or in a build_* function of the composition root (outside one)

This service has all three shapes (tempest lint-layers --rule DI001 --rule DI002 --rule DI003, real output):

# src/services/wallet/settlement.py
from sqlalchemy.ext.asyncio import AsyncSession

from src.services.wallet.wallet import WalletService


class SettlementService:
    """Liquida o saldo retido."""

    def __init__(self, session: AsyncSession, wallet_service: WalletService) -> None:
        """Guarda a sessão e o service da carteira."""
        self.session = session
        self.wallet_service = wallet_service

    @classmethod
    def from_session(cls, session: AsyncSession) -> "SettlementService":
        """Monta o service sobre uma sessão."""
        return cls(session, WalletService(session))
src/services/wallet/settlement.py:9: DI001 (warning) `SettlementService.__init__` takes the session (`session`); take the repository instead and let the provider in api/dependencies/ build it from the session.
src/services/wallet/settlement.py:9: DI002 (warning) `SettlementService.__init__` takes `WalletService` (`wallet_service`), a service of the same layer; combine the two one layer up, or declare the exception with its reason.
src/services/wallet/settlement.py:15: DI003 (warning) `from_session` assembles the graph inside the class; build it in a provider of api/dependencies/ for a request, or in a `build_*` function of the composition root outside one.
3 layer finding(s): 0 error(s), 3 warning(s).

When two services really must go together — in the transport service, the settlement and the wallet credit had to land in the same transaction —, the way out is a declared exception, aimed at that one parameter (for the SDK's wallet, since v0.330.0 the service receives the WalletLedger and the exception is no longer needed):

ARCHITECTURE_EXCEPTIONS: dict[str, str] = {
    "DI002 src/services/wallet/settlement.py::SettlementService.wallet_service": (
        "settlement and credit land in the same transaction"
    ),
}

Assembly outside a request

Tasks, consumers, agents and seeds have no Depends. Instead of every class getting a from_session, gather the build_* functions in a composition root and reuse it in all of those places and in the test suite. The agents with a database recipe shows the shape.

Nested function and private helper (warning)

These two rules read the source and the suite (tests/ beside src/). In the transport service, most occurrences were in the tests.

Code What it reports
STR001 a function defined inside another function — including inside a method or a local class. A callback that keeps state becomes a class with __call__; one that only binds an argument becomes functools.partial over a module-level function
STR002 a module-level function whose name starts with a single _ (__getattr__ and methods pass). It becomes a method of the class that uses it, a public function in utils/ or, in the suite, a fixture or a public helper module

With these two files (real output):

# src/utils/retry.py
from collections.abc import Awaitable, Callable


def with_retry(attempts: int) -> Callable[[], Awaitable[None]]:
    """Repeat the call until it succeeds."""

    async def wrapper() -> None:
        """Try again."""

    return wrapper
# tests/test_app.py
def _make_payload() -> dict[str, str]:
    """Build the request body."""
    return {"name": "Picos"}
src/utils/retry.py:7: STR001 (warning) `with_retry.wrapper` is defined inside a function; a callback that keeps state becomes a class with `__call__`, and one that binds an argument goes through functools.partial over a module-level function.
tests/test_app.py:1: STR002 (warning) module-level `_make_payload` is a helper with no home; make it a method of the class that uses it or a public function in utils/ (in tests: a fixture or a public helper module).
2 layer finding(s): 0 error(s), 2 warning(s).

Imports between project packages (warning)

Code What it reports
IMP001 an __init__.py importing a module of its own package with an absolute import. A neighbour is imported relatively: from .orders import OrderService
IMP002 outside an __init__.py, an import of a name from the submodule it lives in when a package above already re-exports it. The re-export is resolved transitively, through from .x import * too, and the suggestion is the top-most package that re-exports the name without containing the importing module — a service is never told to import its own layer's __init__

Both read the source and the suite. With these four files (tempest lint-layers --rule IMP001 --rule IMP002, real output):

# src/services/__init__.py
from src.services.orders import OrderService as OrderService

__all__: list[str] = ["OrderService"]
# src/services/orders/__init__.py
from .order import OrderService as OrderService

__all__: list[str] = ["OrderService"]
# src/services/orders/order.py
class OrderService:
    """Orders."""
# src/controllers/orders/order.py
from src.services.orders.order import OrderService


class OrderController:
    """Orchestrates orders."""

    def __init__(self, service: OrderService) -> None:
        """Keep the service."""
        self.service = service
src/controllers/orders/order.py:1: IMP002 (warning) `OrderService` is re-exported by `src.services`; import it from there: `from src.services import OrderService`.
src/services/__init__.py:1: IMP001 (warning) `src.services.orders` is a module of this package; import it relatively in __init__.py: `from .orders import ...`.
2 layer finding(s): 0 error(s), 2 warning(s).

When the package would close a cycle

Sometimes importing through the layer package closes a cycle: in the transport service, tasks and scripts imported api.dependencies.resources directly, because importing the api.dependencies package would close a cycle with src.tasks. That is a case for a declared exception ("IMP002 <path>::<name>": "<reason>"), not for rewriting the import.

What a package holds, and how long a file is (warning)

Code Where What it reports
INIT001 every __init__.py, source and suite a statement that does more than re-export: a def, a class, a call, a constant. A docstring, imports, the __all__ binding (+= too) and an if/try made only of those (if TYPE_CHECKING:, an optional import) pass
SIZE001 every module, source and suite a file over 1000 lines, reported at line 1001. No file is exempt

An admin/__init__.py composing its sub-routers, a service whose file name carries the layer, and a 1040-line test file come out like this (tempest lint-layers --rule INIT001 --rule SIZE001 --rule LAY003, real output, exit code 0):

src/api/routers/admin/__init__.py:5: INIT001 (warning) `admin_router: APIRouter = APIRouter(prefix="/admin")` does work in __init__.py, which only re-exports (`from .x import Y as Y`) and binds `__all__`; move it to a module of the package (router.py, factory.py, runner.py) and re-export it.
src/api/routers/admin/__init__.py:6: INIT001 (warning) `admin_router.include_router(orders_router)` does work in __init__.py, which only re-exports (`from .x import Y as Y`) and binds `__all__`; move it to a module of the package (router.py, factory.py, runner.py) and re-export it.
src/services/orders/checkout_service.py:1: LAY003 (warning) checkout_service.py repeats the layer its directory already names; rename it to checkout.py — the class inside keeps its suffix.
tests/integration/orders/test_orders.py:1001: SIZE001 (warning) test_orders.py has 1040 lines, over 1000; split it by responsibility — a service into several services, a test file into one file per theme, an __init__.py into a subpackage per domain.
4 layer finding(s): 0 error(s), 4 warning(s).

The composition moves to admin/router.py (build_admin_router()), re-exported by the __init__.py; a factory to factory.py; a seed run to runner.py. A big file splits by responsibility — the service into several services, the test into one file per theme.

Router: one per file, /api once (warning)

Code Where What it reports
RTR003 routers/ more than one router in the module (APIRouter(...), TempestAPIRouter(...) or a project subclass) — one finding per router after the first
RTR004 the whole source a prefix equal to /api (or under it) in a router construction or include_router(...) outside a build_api_router function

In the transport service, /api was repeated in 22 include_router calls. An orders module with two routers and /api baked in prints (real output):

# src/api/routers/orders.py
from tempest_fastapi_sdk import TempestAPIRouter

router: TempestAPIRouter = TempestAPIRouter(prefix="/api/orders", tags=["orders"])
admin_router: TempestAPIRouter = TempestAPIRouter(prefix="/api/admin/orders", tags=["admin"])
src/api/routers/orders.py:4: RTR004 (warning) prefix `/api/orders` set outside build_api_router(); mount the domain routers under `/api` once, in routers/api.py, and give each router only its own prefix.
src/api/routers/orders.py:5: RTR003 (warning) a second router in this module (`admin_router`); one router per file in routers/ — move it to its own module.
src/api/routers/orders.py:5: RTR004 (warning) prefix `/api/admin/orders` set outside build_api_router(); mount the domain routers under `/api` once, in routers/api.py, and give each router only its own prefix.
3 layer finding(s): 0 error(s), 3 warning(s).

The shape both rules ask for: each domain in its own file, with only its own prefix (/orders, /admin/orders), and /api set once:

# src/api/routers/api.py
from fastapi import APIRouter

from src.api.routers.admin_orders import router as admin_orders_router
from src.api.routers.orders import router as orders_router


def build_api_router() -> APIRouter:
    """Build the API router: every domain sits under ``/api``."""
    api: APIRouter = APIRouter(prefix="/api")
    api.include_router(orders_router)
    api.include_router(admin_orders_router)
    return api

Domain router: TempestAPIRouter and text in api/docs (warning)

Code Where What it reports
RTR005 routers/ a fastapi.APIRouter(...) outside a build_api_router function — on an APIRouter, @raises never becomes responses=
RTR006 routers/ summary= or description= in a route decorator, a literal or a SUMMARY_* constant — one line per keyword

The build_api_router aggregator is left out of RTR005 on purpose: a route's errors are built by the router the handler is registered on, and the class of the router that includes it changes nothing. The router with both shapes agents used to write (real output):

# src/api/routers/service_info.py
from fastapi import APIRouter, Depends

from src.api.dependencies import get_service_info_controller
from src.controllers import ServiceInfoController
from src.schemas import ServiceInfoSchema

SUMMARY_INDEX: str = "Describe the service"

router: APIRouter = APIRouter(tags=["root"])


@router.get("/", summary=SUMMARY_INDEX, description="Returns the service name.")
async def index(
    controller: ServiceInfoController = Depends(get_service_info_controller),
) -> ServiceInfoSchema:
    """Placeholder root endpoint returning the service name.

    Args:
        controller (ServiceInfoController): The injected controller.

    Returns:
        ServiceInfoSchema: The service title.
    """
    return await controller.describe()
src/api/routers/service_info.py:10: RTR005 (warning) APIRouter(...) builds this router (`router`); build it with `TempestAPIRouter` from tempest_fastapi_sdk, which turns each handler's `@raises(...)` into its `responses=` (a plain APIRouter ignores the tag).
src/api/routers/service_info.py:13: RTR006 (warning) route `index` passes `summary=` in its decorator; keep the OpenAPI text in an `EndpointDoc` constant of api/docs/<router>.py and spread it into the decorator (`**docs.INDEX`).
src/api/routers/service_info.py:13: RTR006 (warning) route `index` passes `description=` in its decorator; keep the OpenAPI text in an `EndpointDoc` constant of api/docs/<router>.py and spread it into the decorator (`**docs.INDEX`).
3 layer finding(s): 0 error(s), 3 warning(s).

The right shape — TempestAPIRouter, @raises below the decorator and an EndpointDoc in api/docs/<router>.py — is in the Service standard.

The shape of the suite (warning)

The four TST rules read the files pytest collects in the project's tests/ (test_*.py and *_test.py):

Code What it reports
TST001 a test (module-level test* or a test* method of a Test* class) whose docstring does not carry Cenário: and Esperado: — the situation the test builds and what it proves
TST002 a test that checks nothing: no assert, no with pytest.raises / warns / deprecated_call, no assert* call (mock.assert_awaited_once())
TST003 pytest.raises(Exception) or BaseException, alone or in a tuple — any bug passes
TST004 a parametrize whose id holds a value drawn at import

This file has all four (real output):

# tests/test_orders.py
from uuid import uuid4

import pytest


@pytest.mark.parametrize("order_id", [str(uuid4())])
def test_order_is_created(order_id: str) -> None:
    """The order is created."""
    with pytest.raises(Exception):
        int(order_id)


def test_receipt_is_sent() -> None:
    """Cenário: um pedido pago.

    Esperado: o recibo sai sem erro.
    """
    str(uuid4())
tests/test_orders.py:6: TST004 (warning) parametrize puts a `uuid4()` drawn at import into the test id; each pytest-xdist worker collects different ids and the run aborts — use fixed literals.
tests/test_orders.py:7: TST001 (warning) `test_order_is_created` docstring lacks Cenário:, Esperado:; say the situation the test builds (Cenário:) and what it proves (Esperado:).
tests/test_orders.py:9: TST003 (warning) pytest.raises(Exception) passes for any bug; name the exception the code raises (and `match=` its message when it matters).
tests/test_orders.py:13: TST002 (warning) `test_receipt_is_sent` checks nothing (no assert, no pytest.raises, no assert_* call); a test that cannot fail proves nothing.
4 layer finding(s): 0 error(s), 4 warning(s).

When a drawn value breaks pytest -n

Each pytest-xdist worker imports the module on its own. When a test id depends on a drawn value, each worker collects different ids and the run aborts with "Different tests were collected". Measured with pytest -n 2: random.randint(), time.time(), secrets.token_hex(), os.urandom(), str(uuid4()), uuid4().hex, f"{uuid4()}" and pytest.param(..., id=str(uuid4())) abort. A bare uuid4() or datetime.now() passes — pytest ids those objects by position (v0, v1) —, which is why TST004 only reports them once they become text or sit in ids= / id=.

Warning, error and declared exception

Every rule has a severity. An error fails the step (exit code 1); a warning prints (warning) after its code and does not. A new rule enters as a warning in one release and becomes an error in the next — so an existing service has a whole release to migrate. To migrate one rule at a time, select it with --rule (repeatable, lower case accepted):

tempest lint-layers --rule SVC002              # one rule only
tempest lint-layers --rule SVC002 --rule RTR001
tempest lint-layers --strict                   # warnings fail too

tempest check runs the step without --rule. For the gate to fail on warnings too, turn it on in pyproject.toml — the command line's --strict/--no-strict wins over the config:

[tool.tempest]
layers_strict = true

An exception the project keeps lives in one place, with a reason, reviewed in the diff like code: the ARCHITECTURE_EXCEPTIONS dict in tests/architecture_exceptions.py. The key is "<CODE> <path>" (every finding of that code in the file) or "<CODE> <path>::<subject>" (only the one about that name — the class, Class.method or the function). The path is relative to the project root. The file is read with ast too, never imported:

"""Architecture exceptions the project keeps, each with its reason."""

ARCHITECTURE_EXCEPTIONS: dict[str, str] = {
    "SVC001 src/services/catalogue/catalogue.py::CatalogueService": (
        "static catalogue, no repository to hand to BaseService"
    ),
    "REPO001 src/db/repositories/legacy/legacy.py": "wrapper kept until 2.0",
}

With that file, a src/services/catalogue/catalogue.py defining CatalogueService (no BaseService) and a module-level function load_items, and no legacy.py, tempest lint-layers prints (real output, exit code 1 because of the SVC002):

src/services/catalogue/catalogue.py:5: SVC002 module-level function `load_items` in services/; move it to utils/, or make it a method of the service that uses it.
tests/architecture_exceptions.py:7: EXC002 (warning) `REPO001 src/db/repositories/legacy/legacy.py` matches no finding; the code it excused is gone or moved — delete the entry, or fix its path.
2 layer finding(s): 1 error(s), 1 warning(s).

CatalogueService's SVC001 is gone, because the exception covers it. The REPO001 entry matches nothing and becomes the EXC002 warning: an exception does not outlive the code it excused.

Code Severity What it reports
EXC001 error, always (even under --rule) an entry the checker cannot use: key out of shape, unknown code, empty or non-literal reason, repeated key, file without the dict
EXC002 warning an entry that excuses no finding — the code changed or the path is wrong

--rule with an unknown code exits 2 and lists the valid codes. tempest check takes the same two options and hands them to the lint-layers step — tempest check --rule STR002 --strict runs the whole gate with the step filtered and warnings failing (exit code 1 with a STR002, 0 without --strict; measured on a tempest new project).

Marker or declared exception?

The # tempest: no-base-service and # tempest: router-builds markers still work. A declared exception covers any rule, including the ones with no marker, and gathers in one file what used to be scattered — review reads every reason at once.