Skip to content

feat(agent): enrich service intelligence and incident summaries - #350

Merged
hoalongnatsu merged 2 commits into
mainfrom
feature/update
Aug 27, 2026
Merged

feat(agent): enrich service intelligence and incident summaries#350
hoalongnatsu merged 2 commits into
mainfrom
feature/update

Conversation

@hoalongnatsu

@hoalongnatsu hoalongnatsu commented Aug 27, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Makes the Agent Services surface accurate and useful across logs, metrics,
traces, and incidents:

  • Adds an optional IncidentServiceCounter storage capability for org-,
    service-, and time-scoped counts plus bounded recent incidents.
  • Implements the capability in Postgres, file, and memory storage. Postgres uses
    aggregate-only count SQL, a hard-limited recent-list query, and a composite
    (org_id, service, created_at DESC) index.
  • Fixes service incident summaries that could report zero when a service's rows
    fell outside the newest 500 incidents.
  • Applies the operator-configured incident count window to service summaries and
    returns the effective window with the count, including unbounded all.
  • Shows licensed Metrics and Traces counts in the Services eye preview using one
    shared /intel query.
  • Splits service detail into separate Metrics and Traces cards while retaining
    independent loading, locked, empty, and error states.
  • Reworks Agent Overview into two side-by-side cards: Signals learned and
    Detect breakdown, using accessible conventional vertical bar charts.
  • Removes the unused *config.Config dependency from report preview rendering.

Why?

Service detail previously filtered only the newest 500 incidents across the
entire deployment. A service with older-but-still-in-window incidents could show
0 even though the Incidents page found matching records. Postgres now performs
indexed, service-scoped queries rather than loading full payload histories.

The Services UI also stopped at log patterns and incidents even when licensed
metrics and traces intelligence was available. Operators had to leave the
service context to understand what had been learned. Agent Overview had the
opposite problem: multiple raw key/count tables were hard to scan and visually
disconnected from the signal summary.

How to test

Automated

cd versus-incident

gofmt -l pkg cmd              # no output
go vet ./...
go test ./...

cd ui
npx tsc -b
npm run lint
npx vitest run --reporter=dot # 721 tests / 57 files
npm run build

Run storage parity against an isolated Postgres database — the test truncates
its target, so never use development or production data:

TEST_POSTGRES_DSN='postgres://user:pass@localhost:5432/service_counter_test?sslmode=disable' \
  go test ./pkg/storage -run '^TestIncidentServiceCounterParity$' -count=1 -v

Manual

  1. Start the OSS stack and open Agent → Services.
  2. Open a service with the eye action. Confirm log-pattern and incident counts
    load; Metrics/Traces remain absent on an OSS/unlicensed binary.
  3. Open the full service page. Confirm the incident count, severity bands, and
    latest incidents match rows attributed to that exact service in the active
    incident count window, and the window is shown beside the count.
  4. Seed more than 500 unrelated newer incidents and confirm the target service's
    count remains accurate.
  5. Save incidents out of chronological insertion order and confirm the recent
    list remains ordered by created_at DESC.
  6. In a licensed deployment, confirm the peek adds Metrics/Traces counts and the
    full page renders separate Metrics and Traces cards from one /intel request.
  7. Open Agent Overview. Confirm one row contains Signals learned and
    Detect breakdown, with standard vertical bar charts, exact values, and no
    shadow verdict/outcome card.

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (config / API / default behavior)
  • Documentation only
  • Refactor (no functional change) — report-render signature cleanup
  • CI / build / chore

Checklist

  • go test ./... passes locally
  • go vet ./... is clean
  • Code is gofmt'd
  • Added or updated tests for the change
  • Updated user-facing docs under src/ if behavior changes — service detail
    and overview UX documentation remains a follow-up
  • Updated ROADMAP.md if this closes a roadmap item
  • No secrets, tokens, or webhook URLs introduced in source / YAML
  • No new third-party dependencies

@hoalongnatsu
hoalongnatsu merged commit c06e41e into main Aug 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant