# Table: `host_tags`

Stores active and retired tag associations for canonical hosts.

## Columns

| Column | Type | Null | Default | Notes |
|--------|------|------|---------|-------|
| `host_fqdn` | `TEXT` | no | none | Canonical host FQDN. References `hosts(fqdn)`. |
| `tag_id` | `TEXT` | no | none | Tag identifier. References `tags(tag_id)`. |
| `status` | `TEXT` | no | `'active'` | Association lifecycle state. |
| `created_at` | `TEXT` | no | none | ISO UTC creation timestamp. |
| `retired_at` | `TEXT` | yes | none | ISO UTC retirement timestamp. |

## Keys And Indexes

- Primary key: `(host_fqdn, tag_id)`
- Lookup index: `idx_host_tags_tag_status` on `(tag_id, status)`

## Relationships

References:

- `hosts.fqdn`
- `tags.tag_id`

## Definition

```sql
CREATE TABLE IF NOT EXISTS host_tags (
    host_fqdn TEXT NOT NULL,
    tag_id TEXT NOT NULL,
    status TEXT NOT NULL DEFAULT 'active',
    created_at TEXT NOT NULL,
    retired_at TEXT,
    PRIMARY KEY (host_fqdn, tag_id),
    FOREIGN KEY (host_fqdn) REFERENCES hosts(fqdn) ON UPDATE CASCADE ON DELETE RESTRICT,
    FOREIGN KEY (tag_id) REFERENCES tags(tag_id) ON UPDATE CASCADE ON DELETE RESTRICT
);

CREATE INDEX IF NOT EXISTS idx_host_tags_tag_status
ON host_tags(tag_id, status);
```
