---

description: "Task list for feature implementation"
---

# Tasks: Tag Badge Catalog (Neutral, Suite-wide) v1

**Input**: Design documents from `/Users/ahmeddarrazi/Documents/projects/TenantAtlas/specs/060-tag-badge-catalog/`  
**Prerequisites**: `/Users/ahmeddarrazi/Documents/projects/TenantAtlas/specs/060-tag-badge-catalog/plan.md`, `/Users/ahmeddarrazi/Documents/projects/TenantAtlas/specs/060-tag-badge-catalog/spec.md`  

**Tests**: Required (Pest) because UI/runtime behavior changes are introduced.  
**Operations**: No new long-running/remote/queued/scheduled work introduced.  
**Badges**: Status-like badges remain governed by BADGE-001 (`BadgeCatalog` / `BadgeRenderer`). This feature covers tag-like (metadata) badges only.

**Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story.

## Format: `- [ ] T### [P?] [US?] Description with file path`

- **[P]**: Can run in parallel (different files, no dependencies)
- **[US#]**: Which user story this task belongs to (US1/US2/US3). Setup + Foundational + Polish tasks have no story label.
- Every task includes an exact file path (or command path).

## Phase 1: Setup (Shared Infrastructure)

**Purpose**: Ensure the local environment is ready for implementation and testing.

- [X] T001 Start local stack via `vendor/bin/sail` (run: `vendor/bin/sail up -d` and `vendor/bin/sail composer install`)
- [X] T002 Confirm baseline test green via `vendor/bin/sail` (run: `vendor/bin/sail artisan test tests/Feature/Guards/NoAdHocStatusBadgesTest.php`)

---

## Phase 2: Foundational (Blocking Prerequisites)

**Purpose**: Central tag badge semantics layer required by all user stories.

**⚠️ CRITICAL**: No user story work can begin until this phase is complete.

- [X] T003 [P] Add tag badge domain enum in `app/Support/Badges/TagBadgeDomain.php`
- [X] T004 [P] Add tag badge spec value object (neutral allowlist only) in `app/Support/Badges/TagBadgeSpec.php`
- [X] T005 Implement central catalog (domain → spec mapping + normalization + “Other: <value>” fallback) in `app/Support/Badges/TagBadgeCatalog.php`
- [X] T006 Implement Filament helper closures (label/color/icon/iconColor) in `app/Support/Badges/TagBadgeRenderer.php`
- [X] T007 [P] Add mapping tests for core domains (policy type/category/platform) in `tests/Unit/Badges/TagBadgeCatalogTest.php`
- [X] T008 [P] Add palette invariant test (never returns `success|warning|danger`) in `tests/Unit/Badges/TagBadgePaletteInvariantTest.php`
- [X] T009 Run foundational unit tests via `vendor/bin/sail` (run: `vendor/bin/sail artisan test tests/Unit/Badges/TagBadgeCatalogTest.php`)

**Checkpoint**: Tag badge catalog exists, is pure, and is unit-tested.

---

## Phase 3: User Story 1 - Read policy metadata clearly (Priority: P1) 🎯 MVP

**Goal**: Policies list shows consistent, neutral tag badges for type/category/platform without implying health or risk.

**Independent Test**: In the Policies list, the same policy type/category/platform values render with the same label + neutral color, and no tag badge uses `success|warning|danger`.

### Implementation for User Story 1

- [X] T010 [US1] Migrate policy type badges to TagBadgeRenderer in `app/Filament/Resources/PolicyResource.php`
- [X] T011 [US1] Migrate policy category badges to TagBadgeRenderer in `app/Filament/Resources/PolicyResource.php`
- [X] T012 [US1] Migrate platform badges to TagBadgeRenderer (Title Case labels) in `app/Filament/Resources/PolicyResource.php`

**Checkpoint**: User Story 1 is complete and independently verifiable on the Policies list.

---

## Phase 4: User Story 2 - Consistent tags across key surfaces (Priority: P2)

**Goal**: The same tag values render consistently across lists, detail views, relation managers, and key tools.

**Independent Test**: Pick a platform value (e.g., “Windows”) and verify it renders with the same label + neutral styling in Policies, Policy Versions, Inventory, Backup policy picker, and any detail view that shows platform tags.

### Implementation for User Story 2

- [X] T013 [US2] Create discovery report of tag-like badges (file/line hits + observed values) in `specs/060-tag-badge-catalog/discovery.md`
- [X] T014 [P] [US2] Migrate tenant environment badge to TagBadgeRenderer in `app/Filament/Resources/TenantResource.php`
- [X] T015 [P] [US2] Migrate inventory list badges (type/category/platform) to TagBadgeRenderer in `app/Filament/Resources/InventoryItemResource.php`
- [X] T016 [P] [US2] Migrate inventory detail badges (type/category/platform) to TagBadgeRenderer in `app/Filament/Resources/InventoryItemResource.php`
- [X] T017 [P] [US2] Migrate policy version list badges (policy_type/platform) to TagBadgeRenderer in `app/Filament/Resources/PolicyVersionResource.php`
- [X] T018 [P] [US2] Migrate policy version detail badges (policy_type/platform) to TagBadgeRenderer in `app/Filament/Resources/PolicyVersionResource.php`
- [X] T019 [P] [US2] Migrate policy versions relation manager tag badges to TagBadgeRenderer in `app/Filament/Resources/PolicyResource/RelationManagers/VersionsRelationManager.php`
- [X] T020 [P] [US2] Migrate backup item tag badges (policy_type/platform) to TagBadgeRenderer in `app/Filament/Resources/BackupSetResource/RelationManagers/BackupItemsRelationManager.php`
- [X] T021 [P] [US2] Migrate backup set policy picker tag badges (policy_type/platform) to TagBadgeRenderer in `app/Livewire/BackupSetPolicyPickerTable.php`
- [X] T022 [P] [US2] Migrate backup schedule frequency badge to TagBadgeRenderer (neutral allowlist) in `app/Filament/Resources/BackupScheduleResource.php`
- [X] T023 [P] [US2] Migrate platform tag badges in policy detail view to TagBadgeCatalog in `resources/views/filament/infolists/entries/policy-general.blade.php`
- [X] T024 [US2] Update and close discovery report with a “post-migration” check in `specs/060-tag-badge-catalog/discovery.md`

**Checkpoint**: User Story 2 is complete and tag consistency holds across the targeted surfaces.

---

## Phase 5: User Story 3 - Prevent regressions (Priority: P3)

**Goal**: Prevent “random tag colors” and ad-hoc tag badge semantics from reappearing.

**Independent Test**: Automated validation fails when a tag-like badge uses `success|warning|danger` or bypasses the tag badge catalog on known tag surfaces.

### Implementation for User Story 3

- [X] T025 [P] [US3] Expand mapping tests to cover environment/visibility/snapshot type/frequency in `tests/Unit/Badges/TagBadgeCatalogTest.php`
- [X] T026 [P] [US3] Add lightweight guard test for forbidden tag colors in `tests/Feature/Guards/NoForbiddenTagBadgeColorsTest.php`
- [X] T027 [US3] Tighten guard exclusions to avoid status-like false positives in `tests/Feature/Guards/NoForbiddenTagBadgeColorsTest.php`
- [X] T028 [US3] Run guard + unit tests via `vendor/bin/sail` (run: `vendor/bin/sail artisan test tests/Feature/Guards/NoForbiddenTagBadgeColorsTest.php`)

**Checkpoint**: Guardrails and tests prevent regressions.

---

## Phase 6: Polish & Cross-Cutting Concerns

**Purpose**: Final quality gates and verification before implementation work is considered done.

- [X] T029 Run formatting on changed files via `vendor/bin/sail` (run: `vendor/bin/sail php ./vendor/bin/pint --dirty`)
- [X] T030 Run full tag-badge test subset via `vendor/bin/sail` (run: `vendor/bin/sail artisan test tests/Unit/Badges/TagBadgeCatalogTest.php`)
- [X] T031 Re-run suite badge guards via `vendor/bin/sail` (run: `vendor/bin/sail artisan test tests/Feature/Guards/NoAdHocStatusBadgesTest.php`)
- [x] T032 Validate manual QA steps in `specs/060-tag-badge-catalog/quickstart.md`

---

## Dependencies & Execution Order

### Phase Dependencies

- **Setup (Phase 1)** → **Foundational (Phase 2)** → **US1 (Phase 3)** → **US2 (Phase 4)** → **US3 (Phase 5)** → **Polish (Phase 6)**

### User Story Dependencies

- **US1 (P1)**: Depends on Foundational; no dependency on US2/US3.
- **US2 (P2)**: Depends on Foundational; can proceed after (or alongside) US1.
- **US3 (P3)**: Depends on Foundational; can be implemented in parallel with US1/US2, but must be complete before final validation.

---

## Parallel Examples

### Parallel Example: User Story 1

```bash
Task: "Migrate policy type badges to TagBadgeRenderer in app/Filament/Resources/PolicyResource.php"
Task: "Migrate policy category badges to TagBadgeRenderer in app/Filament/Resources/PolicyResource.php"
Task: "Migrate platform badges to TagBadgeRenderer (Title Case labels) in app/Filament/Resources/PolicyResource.php"
```

### Parallel Example: User Story 2

```bash
Task: "Migrate tenant environment badge to TagBadgeRenderer in app/Filament/Resources/TenantResource.php"
Task: "Migrate policy version list badges (policy_type/platform) to TagBadgeRenderer in app/Filament/Resources/PolicyVersionResource.php"
Task: "Migrate inventory list badges (type/category/platform) to TagBadgeRenderer in app/Filament/Resources/InventoryItemResource.php"
Task: "Migrate backup schedule frequency badge to TagBadgeRenderer (neutral allowlist) in app/Filament/Resources/BackupScheduleResource.php"
```

### Parallel Example: User Story 3

```bash
Task: "Expand mapping tests to cover environment/visibility/snapshot type/frequency in tests/Unit/Badges/TagBadgeCatalogTest.php"
Task: "Add lightweight guard test for forbidden tag colors in tests/Feature/Guards/NoForbiddenTagBadgeColorsTest.php"
```

---

## Implementation Strategy

### MVP First (User Story 1 Only)

1. Complete Phase 1 (Setup)
2. Complete Phase 2 (Foundational)
3. Complete Phase 3 (US1)
4. Run Phase 6 tasks T029–T032 (at minimum: pint + targeted tests) before considering MVP done

### Incremental Delivery

1. Foundation ready → deliver US1 (Policies list)
2. Deliver US2 (cross-surface consistency + discovery-driven migration)
3. Deliver US3 (guardrails) and re-run all targeted tests
