TenantAtlas/specs/046-inventory-sync-button/contracts/internal-actions.md
ahmido cf5b0027e3 046-inventory-sync-button (#47)
Zusammenfassung: Fügt im „Run Inventory Sync“-Modal einen include_dependencies-Toggle hinzu und persistiert die Auswahl in der InventorySyncRun.selection_payload. Tests, Quickstart und Tasks wurden entsprechend aktualisiert.

Files: InventoryLanding.php, InventorySyncButtonTest.php, quickstart.md, tasks.md
Motivation: Ermöglicht explizites Ein-/Ausschalten der Dependency-Extraktion pro Sync-Run (z. B. Assignments/Scope Tags/Foundations), statt starrer Defaults. Passt zur bestehenden selection_hash-Logik (InventorySelectionHasher) und zur deterministischen Selektionspersistenz.
Verhalten: include_dependencies ist im Modal standardmäßig true. Wird die Option gesetzt, landet der Wert als bool im selection_payload und beeinflusst selection_hash über die Normalisierung.
Tests: Neuer/angepasster Pest-Test stellt sicher, dass include_dependencies in selection_payload persistiert. Lokaler Testlauf:
./vendor/bin/sail artisan test tests/Feature/Inventory/InventorySyncButtonTest.php → alle Tests für diese Datei bestanden.
./vendor/bin/pint --dirty wurde ausgeführt (Formatting ok).
How to test (quick):
Start Sail + Queue:
Im Admin → Inventory: „Run Inventory Sync“ öffnen, Include dependencies umschalten, ausführen.
Prüfen: neu erstellter InventorySyncRun.selection_payload.include_dependencies ist der gesetzten Auswahl entsprechend. Oder laufen lassen:
Notes / Next steps:
Diese Änderung bereitet den Weg, später die Dependency-Extraction (042-inventory-dependencies-graph) optional tiefer zu integrieren.
Working tree ist sauber; es gibt ein nicht eingebundenes Verzeichnis 0800-future-features (unrelated).

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #47
2026-01-09 22:15:04 +00: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.