TenantAtlas/specs/145-tenant-action-taxonomy-lifecycle-safe-visibility/quickstart.md
ahmido 440e63edff feat: implement tenant action taxonomy lifecycle visibility (#174)
## Summary

Implements Spec 145 for tenant action taxonomy and lifecycle-safe visibility.

This PR:
- adds a central tenant action policy surface and supporting value objects
- aligns tenant list, detail, edit, onboarding, and widget surfaces around lifecycle-safe actions
- standardizes operator-facing lifecycle wording around View, Resume onboarding, Archive, Restore, and Complete onboarding
- tightens onboarding and tenant lifecycle authorization semantics, including honest 404 vs 403 behavior
- updates related regression coverage and spec artifacts for Spec 145
- fixes follow-on full-suite regressions uncovered during validation, including onboarding browser flows, provider consent fixtures, workspace redirect DI expectations, and critical table/action/UI expectation drift

## Validation

Executed and passed:
- vendor/bin/sail bin pint --dirty --format agent
- vendor/bin/sail artisan test --compact

Result:
- 2581 passed
- 8 skipped
- 13534 assertions

## Notes

- Base branch: dev
- Feature branch commit: a33a41b
- Filament v5 / Livewire v4 compliance preserved
- No panel provider registration changes; Laravel 12 provider registration remains in bootstrap/providers.php
- No new globally searchable resource behavior added in this slice
- Destructive lifecycle actions remain confirmation-gated and authorization-protected

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #174
2026-03-16 00:57:17 +00:00

99 lines
4.3 KiB
Markdown

# Quickstart: Implementing Spec 145
## Preconditions
1. Start Sail if it is not already running.
```bash
vendor/bin/sail up -d
```
2. Confirm you are on the feature branch.
```bash
git branch --show-current
```
Expected branch: `145-tenant-action-taxonomy-lifecycle-safe-visibility`
## Implementation Sequence
1. Add the central tenant-action policy surface.
Target areas:
- `app/Services/Tenants/`
- `app/Support/Tenants/`
2. Refactor tenant-management surfaces to consume the central action policy.
Target areas:
- `app/Filament/Resources/TenantResource.php`
- `app/Filament/Resources/TenantResource/Pages/ViewTenant.php`
- `app/Filament/Resources/TenantResource/Pages/EditTenant.php`
- `app/Filament/Resources/TenantResource/Pages/ListTenants.php`
3. Keep onboarding workflow actions distinct and reuse onboarding lifecycle rules instead of duplicating tenant-surface logic.
Target area:
- `app/Filament/Pages/Workspaces/ManagedTenantOnboardingWizard.php`
4. Reuse existing centralized semantics instead of adding local mappings.
Relevant existing files:
- `app/Services/Tenants/TenantOperabilityService.php`
- `app/Support/Tenants/TenantLifecycle.php`
- `app/Support/Badges/Domains/TenantStatusBadge.php`
- `app/Support/Audit/AuditActionId.php`
- `app/Support/Rbac/UiEnforcement.php`
5. Keep User Story 3 implementation boundaries explicit.
- `T023` owns runtime reuse of the resolved action catalog across list, detail, and onboarding surfaces.
- `T024` owns only action-surface declaration cleanup and overflow-contract alignment.
- Do not move catalog-resolution logic into action-surface declarations.
6. Preserve Filament v5 and Livewire v4 compliance.
- No v3/v4 Filament APIs.
- No provider registration changes are needed; Laravel 12 panel providers remain in `bootstrap/providers.php`.
- Destructive actions remain confirmation-gated.
## Focused Test Pass
Run the minimum targeted suite first:
```bash
vendor/bin/sail artisan test --compact tests/Unit/Tenants/TenantOperabilityServiceTest.php
vendor/bin/sail artisan test --compact tests/Unit/Tenants/TenantActionPolicySurfaceTest.php
vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantResourceAuthorizationTest.php
vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantLifecycleActionVisibilityTest.php
vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantLifecycleActionNamingTest.php
vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantActionSurfaceConsistencyTest.php
vendor/bin/sail artisan test --compact tests/Feature/Rbac/EditTenantArchiveUiEnforcementTest.php
vendor/bin/sail artisan test --compact tests/Feature/Onboarding/OnboardingDraftLifecycleTest.php
vendor/bin/sail artisan test --compact tests/Feature/TenantRBAC/TenantSwitcherScopeTest.php
vendor/bin/sail artisan test --compact tests/Feature/TenantRBAC/ArchivedTenantRouteAccessTest.php
```
These focused tests are part of the required regression baseline for this spec slice. Extend them as needed, but do not treat the central action-policy, confirmation-regression, or cross-surface consistency coverage as optional.
## Formatting
Run Pint after edits:
```bash
vendor/bin/sail bin pint --dirty --format agent
```
## Manual Verification Checklist
1. `draft` tenant on `/admin/tenants`: shows `View` and onboarding-oriented action, not `Archive`.
2. `onboarding` tenant on `/admin/tenants/{tenant}`: shows `Resume onboarding` and readiness/support actions, not active-only lifecycle actions.
3. `active` tenant on index and detail: shows `Archive`, not onboarding-only lifecycle actions.
4. `archived` tenant on index and detail: shows `Restore`, not `Archive` or `Resume onboarding`.
5. Onboarding wizard route: onboarding completion remains workflow-contextual and does not become a generic tenant action.
6. Non-member access still resolves as 404; in-scope member without capability is denied as 403 or disabled-in-UI per existing helper semantics.
## Done Criteria
The implementation is ready for completion review when:
- lifecycle-action assembly is centralized,
- index/detail/onboarding surfaces no longer drift semantically,
- audit and badge semantics remain centralized,
- targeted Pest coverage passes,
- and the Action Surface Contract still validates for touched Filament surfaces.