---
id: w1/m14/t004
title: Simplify — `/simplify` over the CRD + reconciler
worker: worker1
status: done
estimate: 20m
depends_on: [w1/m14/t003]
---

## Objective

Run `/simplify` over the new `KeyValue` CRD type and reconciler to remove duplication, dead paths, and inefficiency — a behavior-preserving cleanup pass. Prefer reusing helpers already shared with the `Database` controller (tier resolution, Service/Secret projection, owner-reference plumbing) over copy-pasted variants.

## Context

- Scope: the diff introduced by t001–t003 — `lego/types/v1alpha1/keyvalue_types.go`, the Valkey tier catalog entries, `lego/operator/internal/controller/keyvalue_controller.go`, and manager wiring.
- The `Database` controller (`database_controller.go`) is the sibling to compare against: factor shared projection/tier helpers rather than maintaining parallel copies.
- Quality only — no behavior changes, no new features. Correctness/bug hunting is `/code-review` territory, not this task.

## Steps

1. Run `/simplify` scoped to the m14 changes.
2. Apply reuse/simplification/efficiency/altitude fixes it surfaces; fold Valkey-vs-Postgres duplication into shared helpers where clean.
3. Re-run `cd lego/operator && go build ./...` and `make manifests generate` to confirm the cleanup is behavior-preserving and codegen stays consistent.

## Files

- `lego/types/v1alpha1/keyvalue_types.go`
- `lego/types/tiers/*` (Valkey catalog entries)
- `lego/operator/internal/controller/keyvalue_controller.go`
- manager wiring touched in t002

## Acceptance criteria

- [ ] `/simplify` findings over the m14 diff are applied or consciously declined.
- [ ] No behavior change: the reconciler still produces the same workload/Service/Secret/route; `go build ./...` clean and codegen unchanged.
- [ ] Valkey/Postgres duplication is reduced to shared helpers where reasonable.

## Out of scope

- Bug hunting / correctness review (`/code-review`).
- Adding tests (t005) or any new surface.
