rlsbl v0.40.1 /rlsbl.layers
On this page

Layer configuration loading and validation for monorepo architectural rules.

#rlsbl.layers

#rlsbl.layers

Layer configuration loading and validation for monorepo architectural rules.

Reads the [layers] section from workspace.toml and provides utilities for resolving package-to-layer assignments and validating that every workspace project is assigned to exactly one layer.

#LayerConfig

LayerConfig
FieldTypeDefault
orderlist[str]
assignmentsdict[str, list[str]]
unrestrictedlist[str]field(default_factory=list)
forbidden_targetslist[str]field(default_factory=list)
allowlist[dict[str, str]]field(default_factory=list)

#load_layer_config

python
def load_layer_config(root: str) -> LayerConfig | None

Read the [layers] section from workspace.toml.

Returns None if the file has no [layers] section. Raises ValueError on invalid structure. Raises FileNotFoundError if workspace.toml doesn't exist.

#_validate_string_list

python
def _validate_string_list(parent: dict, key: str, context: str) -> list[str]

Validate and return an optional list-of-strings field.

#resolve_package_layer

python
def resolve_package_layer(name: str, config: LayerConfig) -> str | None

Resolve which layer a package belongs to based on assignment globs.

Returns the layer name if matched, None if unassigned.

#check_layer_violations

python
def check_layer_violations(projects: list[dict], config: LayerConfig, graph) -> list[str]

Check dependency edges for layer violations.

Returns a list of violation strings (empty means all good). The graph argument is a WorkspaceGraph instance.

#_is_explicitly_allowed

python
def _is_explicitly_allowed(source: str, target: str, allow: list[dict[str, str]]) -> bool

Check if an edge is explicitly allowed by an override rule.

#validate_layer_assignments

python
def validate_layer_assignments(projects: list[dict], config: LayerConfig) -> list[str]

Validate that every project is assigned to exactly one layer.

Returns a list of error messages (empty means valid).