# Data Model: Inventory Coverage Interactive Table

## Overview

This feature does not introduce persistent storage. It defines runtime view-model objects that shape existing coverage metadata into a Filament table.

## Entities

### CoverageTableRow

- Purpose: Represents one row in the interactive coverage table.
- Source: Derived from `InventoryPolicyTypeMeta::supported()` and `InventoryPolicyTypeMeta::foundations()` plus `CoverageCapabilitiesResolver`.

#### Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `key` | string | yes | Stable runtime identifier composed from segment and type for table keys and deterministic ordering |
| `segment` | enum(`policy`,`foundation`) | yes | Distinguishes supported policy types from foundation types |
| `type` | string | yes | Stable policy type identifier |
| `label` | string | yes | Human-readable label derived from shared badge metadata |
| `category` | string | yes | Coverage category from the metadata catalog |
| `dependencies` | bool | yes | Whether dependency support is available for the type |
| `restore` | string nullable | no | Restore mode value when present in the current data shape |
| `risk` | string | yes | Risk state from the existing metadata source |
| `source_order` | int | yes | Preserves deterministic fallback ordering from the source lists |

#### Validation Rules

- `key` must be non-empty and unique within the dataset.
- `segment` must be one of `policy` or `foundation`.
- `type` must be non-empty.
- `category` and `risk` must match values already emitted by the metadata source.
- `restore` may be null; if present, it must match a restore-mode value supported by the shared badge catalog.

### CoverageTableDataset

- Purpose: Aggregates the derived rows and the filter metadata required by the table.

#### Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `rows` | list<CoverageTableRow> | yes | Full runtime dataset rendered by the table |
| `categories` | list<string> | yes | Distinct category options available for filtering |
| `restore_modes` | list<string> | no | Distinct restore values available for filtering; empty when restore metadata is absent |

#### Relationships

- One `CoverageTableDataset` contains many `CoverageTableRow` objects.
- Badge rendering for each `CoverageTableRow` is derived from shared badge catalogs, not embedded or persisted.

### CoverageTableState

- Purpose: Represents the transient UI state managed by Filament table interactions.

#### Fields

| Field | Type | Description |
|-------|------|-------------|
| `search` | string nullable | Current free-text search term |
| `category_filter` | string nullable | Selected category filter |
| `restore_filter` | string nullable | Selected restore filter when available |
| `sort_column` | string nullable | Current sort column |
| `sort_direction` | enum(`asc`,`desc`) nullable | Current sort direction |
| `page` | int | Current pagination page |

## State Transitions

- Initial load: Build `CoverageTableDataset` from existing metadata sources and render default sort order.
- Search update: Narrow `rows` by matching `type` and `label`.
- Category filter update: Narrow `rows` to selected category.
- Restore filter update: Narrow `rows` to selected restore mode when that filter exists.
- Reset action: Clear search and filters and return to the default dataset view.

## Notes

- No database migrations, model classes, or storage contracts change in this feature.
- The runtime row model exists only to shape existing metadata for a native Filament table experience.