Add a tenant feature flag
Only platform admins change features. FeatureService.IsFeatureEnabledAsync returns the first rule that decides:
- Admin lock: a
TenantFeatureConfigwithIsAdminLockedreturns itsIsEnabled, overriding the plan. - Plan: a feature the plan doesn't grant (
PlanFeature) is off. - Tenant config row: returns its
IsEnabled. - Presets: with no row,
TenantPresetCatalog.Resolve(tenant.Presets).
Rows are a snapshot written from presets at tenant creation and on preset changes, so existing tenants resolve a new feature through rule 4.
Steps
- Enum:
TenantFeature(src/Core/Logistics.Domain.Primitives/Enums/Tenancy/Tenant/).[Description]only for acronyms. The admin features page lists every value automatically. - Plans (if tier-restricted): add it to the tier arrays in
SubscriptionPlanSeeder. Enterprise gets everything. - Presets: features default to on. A cargo-specific feature goes in
CargoFeatures(likeVehicleTransport→CarHauler); one a solo operator never uses goes inSoloExcludedFeatures. - API:
[RequiresFeature(TenantFeature.X)]on every command and query in the module. Gating only writes still serves the data. When the feature is a field value on a shared request (a load type), check it in the shared write path withIFeatureService.CheckFeatureAsync(seeIVehicleTransportFeatureChecker) so the error code still triggers the upgrade prompt. - Jobs: Hangfire bypasses the pipeline. Every job touching the feature checks
IsFeatureEnabledAsyncin its body (seeadd-hangfire-job). - UI:
features.isEnabled("x")fromFeatureService; routes usefeatureGuardFromData(@logistics/shared/guards) withdata.feature.
Verify
A tenant on a plan without the feature is blocked in the API and the UI; an admin lock with IsEnabled = true grants it outside the plan.