-- =============================================================================
-- OPC Seed Script 2  –  completed work from TODO.md
-- Run against the ControlPlane database.
-- Picks up numbering at 0010 (0001–0009 covered in seed_opc.sql).
-- =============================================================================

INSERT INTO opc (id, number, title, description, type, status, priority, assignee, created_at, updated_at)
VALUES

(
    gen_random_uuid(),
    'OPC # 0010',
    'Aspire AppHost wired: Vault, MinIO, RabbitMQ, Postgres, Keycloak, Worker, API, UI',
    'Full Aspire AppHost configuration completed. All infrastructure services (Vault, MinIO, RabbitMQ, Postgres, Keycloak) and application services (Worker, API, UI) are registered and wired in the AppHost project.',
    'Feature',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0011',
    'Fix CRLF → LF on entrypoint.sh (was breaking Vault container)',
    'entrypoint.sh had Windows-style CRLF line endings which caused the Vault container to fail on startup. Fixed by enforcing LF via .gitattributes.',
    'Bug',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0012',
    'Vault initialises and unseals on first run',
    'Vault container now correctly initialises (generates root token + unseal keys) and auto-unseals on first run. Init output is written to /vault/file/init.json.',
    'Feature',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0013',
    'Pin Keycloak bootstrap password (fix persistent container password drift)',
    'Keycloak was experiencing password drift between container restarts due to the bootstrap admin credentials not being pinned. Fixed by explicitly setting the admin password so it persists across restarts.',
    'Bug',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0014',
    'Fix Keycloak endpoint name: tcp → http',
    'Keycloak Aspire resource was registered with a tcp endpoint name instead of http, causing service discovery failures. Renamed to http to align with the rest of the stack.',
    'Bug',
    'Done',
    'Medium',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0015',
    'Worker starts and correctly waits for all dependencies',
    'The Worker service was starting before infrastructure dependencies were healthy. Implemented proper wait/health-check logic so the Worker blocks until Postgres, Keycloak, Vault, RabbitMQ, and MinIO are all ready.',
    'Bug',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0016',
    'MassTransit saga pipeline with compensation',
    'Implemented the full MassTransit-based provisioning saga with forward steps and compensating transactions. Each step registers its rollback so a mid-saga failure cleanly tears down any already-provisioned resources.',
    'Feature',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0017',
    'SSE progress stream: Worker → RabbitMQ → API → browser',
    'Implemented a real-time Server-Sent Events pipeline. The Worker publishes step progress to RabbitMQ, the API consumes and streams events via SSE, and the browser receives live updates without polling.',
    'Feature',
    'Done',
    'High',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0018',
    'Frontend Diagnostics tab with full stack traces from worker',
    'Added a Diagnostics tab to the frontend that displays structured error messages and full stack traces forwarded from the Worker service, making provisioning failures debuggable directly in the UI.',
    'Feature',
    'Done',
    'Medium',
    'amadzarak',
    NOW(), NOW()
),
(
    gen_random_uuid(),
    'OPC # 0019',
    'Enforce LF line endings for *.sh and *.hcl via .gitattributes',
    'Added .gitattributes rules to enforce LF line endings for all *.sh and *.hcl files. Prevents CRLF issues from reappearing when contributors commit from Windows machines.',
    'Tech Debt',
    'Done',
    'Low',
    'amadzarak',
    NOW(), NOW()
);
