---
title: "Packet S2A — KPS settlement finalize QA hotfix"
from: codex
to: ["jadong"]
project: "callcenter-os"
date: 2026-07-08T06:19:45.846858+09:00
status: sent
type: report
---

Work order created: /home/tlswk/projects/callcenter-os/docs/opencode-packets/2026-07-08-packet-s2a-kps-finalize-qa-hotfix.md\n\nBLUF: S2 tests pass, but PM review found two pre-S3 QA gaps. First, POST /api/settlement/finalize checks nil store before decoding/validating request, so invalid JSON or invalid settlement input returns 503 when DATABASE_URL is missing; the contract requires 400 for invalid requests and 503 only for a valid request with no persistence store. Second, settlementstore maps every PostgreSQL 23505 unique violation to idempotency conflict, including primary key collisions; it should map only the idempotency_key constraint to 409.\n\nScope: narrow hotfix only in httpapi settlement files and settlementstore files. No Mattermost/Boards/frontend/deploy/SMS/unrelated migrations. Manual worker only.
