TenantAtlas/specs/046-inventory-sync-button/contracts/internal-actions.md
Ahmed Darrazi 68695cd024 feat(046): inventory sync policy type selection
- Use searchable multi-select with select all/clear\n- Track bulk progress per policy type\n- Update tests and spec tasks/quickstart
2026-01-09 16:17:00 +01:00

34 lines
1.5 KiB
Markdown

# Contracts: Internal UI Actions (046)
This feature does not introduce a public HTTP API. It adds an internal Filament UI action that dispatches a queued job.
## Action: Start Inventory Sync
**Surface**: Filament Page action (Inventory area)
**Inputs**
- `tenant_id`: from `Tenant::current()` (required)
- `selection_payload` (required; default “full inventory”):
- `policy_types`: `PolicyTypeResolver::supportedPolicyTypes()`
- `categories`: `[]`
- `include_foundations`: `true`
- `include_dependencies`: `true`
- `user_id`: `auth()->id()` (required)
**Side effects**
- Creates `BulkOperationRun` (resource `inventory`, action `sync`, total_items `1`) so the bottom-right progress widget displays the operation.
- Dispatches `RunInventorySyncJob` with the needed identifiers.
- Creates an `InventorySyncRun` with status `running` once the job begins execution.
- Writes audit log entries:
- `inventory.sync.dispatched`
- terminal: `inventory.sync.completed|inventory.sync.failed|inventory.sync.skipped`
- Sends Filament database notifications to the initiating user:
- started
- completed/failed/skipped
**Failure modes**
- Tenant not selected: action should be unavailable or no-op.
- Unauthorized user: action hidden/denied.
- Concurrency/lock gating: no overlapping run; user receives an informational message; run may be marked `skipped` with an error code.
- Queue not running: operation remains queued; user can observe this via progress widget + run list.