Skip to content

BUG-45: GET /admin/kpi differs from the KPI definitions: one mixed lead time, another auto-approval formula, no approval turnaround, no schema #174

Closed

Description

@ephico2real2

Part of #16

What is wrong: The KPI rows of GET /api/v1/admin/kpi differ from the definitions of docs/01 and of docs/17-kpis.md in four ways. (1) "Lead time p90 (all)" mixes auto-approved and approved requests, whose targets are 10 minutes and 1 business day. (2) "Auto-approval rate" divides by all requests, and the design divides by the requests that matched a policy. (3) The approval turnaround is not in the response. (4) The response model is dict[str, Any] for each part, so the OpenAPI document has no schema of a KPI row, and a row has no stable ID.

Where: cmapi/src/cmapi/core/kpi.py, kpi_report. cmapi/src/cmapi/routers/admin.py, KpiView.

How to prove it: Tests in cmapi/tests/service/test_kpis.py: with one auto-approved and one approved synced request, the two lead times differ; with one request that a guard stopped, the auto-approval rate is 0.5; each row has an id that docs/17 lists as live.

Measured or inferred: Read from the code and measured with the recorded sample on 2026-11-13, in the KPI review.

Severity: Medium.

What must hold after the fix: Each live KPI of docs/17 is one row with a stable id, the designed formula, a unit, a target and targetStatus. The response has typed models. A test fails when a live KPI of docs/17 is missing from the response.

Research: docs/17-kpis.md has the definitions and their sources.

Solution (inline, not applied): Not written here. Where the tag is In-Progress, the fix is on branch kpis.

Class: INV. The fix adds the KPI contract and its check.

Activity

  1. added
    bug
    class:INV
    status:open
    sev:medium
    In-Progress
    on Nov 13, 2026
  2. added
    In-QA
    and removed
    In-Progress
    on Nov 13, 2026
  3. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    In-QA: pull request #177 closes this issue. Its tests failed before the change and pass after it; GitHub's checks on its head were not read yet when this was written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-QAbugclass:INVsev:mediumstatus:open

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions