Skip to content

Forbid Provides Boundary

Show a first-class structural relation check: two components declare kind provides hyperedges into the same resource, and a forbid provides ... except rule rejects every provider except the allowed one.

Matches fixtures/fail/forbid_provides_boundary/gateway.shape:

module rules
resource JsonRpcEndpoint
component Gateway {
}
component PublicApi {
}
relation GatewayProvidesRpc {
kind provides
connects Gateway -> JsonRpcEndpoint
}
relation PublicApiProvidesRpc {
kind provides
connects PublicApi -> JsonRpcEndpoint
}
rule gateway_only_rpc_ingress {
forbid provides JsonRpcEndpoint except Gateway
}

Save the model (for example shape/gateway.shape) and run shp check shape/gateway.shape. In this repository the same model is:

Terminal window
shp check fixtures/fail/forbid_provides_boundary/gateway.shape
error: forbidden provides
PublicApi provides JsonRpcEndpoint via relation PublicApiProvidesRpc.
rule gateway_only_rpc_ingress forbids provides JsonRpcEndpoint except Gateway.
caused by:
- fixtures/fail/forbid_provides_boundary/gateway.shape: relation PublicApiProvidesRpc
- fixtures/fail/forbid_provides_boundary/gateway.shape: rule gateway_only_rpc_ingress forbids provides JsonRpcEndpoint

Exit code 1.

GatewayProvidesRpc is allowed. PublicApiProvidesRpc is the offending hyperedge.

Terminal window
shp graph all --kind provides fixtures/fail/forbid_provides_boundary/gateway.shape
Hypergraph
provides:
provides GatewayProvidesRpc: Gateway (component) -> JsonRpcEndpoint (resource)
provides PublicApiProvidesRpc: PublicApi (component) -> JsonRpcEndpoint (resource)

Both provides hyperedges terminate at JsonRpcEndpoint. Removing or redirecting PublicApiProvidesRpc, or widening the rule’s except list, is what makes the model pass.

provides relations are structural claims, not component-body dependencies. The rule filters the hypergraph for providers of JsonRpcEndpoint and rejects any component outside the exception list.