发布

  • [OPIK-6857] [BE] feat: add agent insights report results endpoints (#7082)

    frostbyte_neo 发布于 2026-06-17 13:31:34 +00:00

    • agent insights

    • Move columns to the top

    • http400 fix and extend test

    • [OPIK-6857] [BE] feat: add agent insights report results endpoints

    Add backend implementation for Agent Insights steps 7 & 8: endpoints to
    store and serve report results (with time-window aggregation), along with
    generated SDK clients (Python, TypeScript) and an example notebook.

    Implements OPIK-6857: [Agent Insights] [BE] Report results Endpoints

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • chore: remove generated SDK and OpenAPI files (will regenerate via Fern)

    • fix: restore main-owned generated files deleted by cleanup commit

    • fix redundant migration

    • address PR comments

    • update migration

    • fix trailing line in migration

    • remove accidental addition

    • improve tests

    • refactor: update validation constraints and improve code readability in AgentInsightsResource and tests

    • reject oversized payload

    • extend tests

    • fix(agent-insights): address PR review comments

    • Reject null issue elements at the API boundary (List<@NotNull @Valid ReportedIssue>)
    • Use READ_ONLY transactions for findIssues/getIssue reads
    • Move issue id/metadata serialization out of the write transaction
    • Extract resolveWindow helper to share window defaults and validation

    Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

    • refactor(agent-insights): use SortingFactory for issue sorting

    Replace the bespoke AgentInsightsSortBy enum and hardcoded ORDER BY
    switch with the standard SortingFactory/SortingQueryBuilder used by
    other entities. The DAO always appends a deterministic tie-breaker
    tail (last_seen DESC, total_occurrences DESC, i.id DESC) so the
    default ordering, the secondary-metric ordering, and stable offset
    pagination are all preserved.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • refactor(agent-insights): address PR review comments
    • add @JsonCreator to AgentInsightsIssueStatus.fromString for explicit body deserialization
    • drop redundant @Schema(READ_ONLY) on response-only DTOs
    • assert whole issue object via recursive comparison in resource test

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • refactor(agent-insights): update primary key definition in agent insights tables

    • refactor(agent-insights): validate date range at the resource boundary

    Move the from_date/to_date check out of resolveWindow into a
    validateDateRangeParameters helper invoked in both GET endpoints, per
    PR review. resolveWindow keeps only default-window resolution.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(agent-insights): scope isolation tests to globally-unique issue ids

    Issue id is globally unique, so reusing the same id across projects or
    workspaces is no longer a valid scenario. Rewrite the two isolation
    tests to use distinct ids and assert that an issue is only reachable
    within its own workspace+project (404 from another scope).

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(agent-insights): assert 400 for from_date after to_date on both read endpoints

    Add a focused parameterized test exercising the list and detail routes
    with from_date > to_date, isolating the boundary date-range validation
    so it can't regress silently.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(agent-insights): split date-range validation test per endpoint

    Replace the route-parameterized test with two explicit @Test methods,
    one per read endpoint, since the list and detail routes use different
    client calls and share no act/assert flow.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • UK change and date default to now

    • refactor(agent-insights): validate metadata size via bean validation

    Replace the imperative metadata byte-size check in the service with a
    reusable @MaxJsonSize constraint on the metadata field. Oversized
    metadata now fails at the API boundary as 422, consistent with other
    payload validation.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • feat(agent-insights): reject future from_date when to_date is omitted

    to_date defaults to the current day, so a future from_date describes an
    empty window. Reject it in validateDateRangeParameters; an explicit
    future to_date remains a valid forward-looking window.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(agent-insights): use AssertJ assertions in ValidationUtilsTest

    Mirror the assertThatThrownBy / assertThatCode pattern used in
    PaginationUtilsTest for the date-range validation test.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Sonnet 4.6 noreply@anthropic.com

    下载附件