Skip to content

fix(admin): bound overview history and paginate alerts - #440

Open
deepjerry-ai wants to merge 6 commits into
mainfrom
codex/fix-overview-433
Open

deepjerry-ai wants to merge 6 commits into
mainfrom
codex/fix-overview-433

Conversation

@deepjerry-ai

@deepjerry-ai deepjerry-ai commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Bound the history-dependent overview payload and preserve lifetime statistics as retained data grows. Historical alerts now have server-side pagination, and slow analytics load independently from the usable console.

Related Issue

Related to #433.

Changes

  • Return the latest 20 alerts in overview. Page alert history with a default size of 50 and enforced maximum of 100, filtering by UTC time, severity and project. Preserve project quota-event counts and latest occurrence through separate permission-scoped aggregates.

  • Return model counts in overview and load definitions on their consuming pages. Add bounded, authorization-scoped model search with capability/modality matching and literal wildcard handling.

  • Maintain lifetime totals and breakdown dimensions transactionally through database triggers, including corrections, deletions and writes from other application instances. PostgreSQL writers reserve separate transaction shards to avoid row-lock serialization, and reads aggregate signed contributions before filtering. Preserve overlapping OR permission scopes without duplicate counting.

  • Backfill existing rows in bounded, resumable batches with cluster leases and a durable completion marker. Keep the page usable during preparation and hide global progress counts from scoped users.

  • Cache successful summaries for 15 seconds, coalesce concurrent refreshes, propagate cancellation and enforce query deadlines. Mark successful results up to 60 seconds old as stale on failure, then hide expired values and their derived trends.

  • Use PostgreSQL NUMERIC and compensated SQLite monetary accumulation. Protect source persistence and corrected totals at extreme numeric ranges, with an explicitly documented SQLite raw-aggregation safety fallback.

  • Add per-dialect schema expansions, independently retryable concurrent PostgreSQL indexes with exact-definition postconditions, and English/Chinese/Japanese operational documentation. Reuse the held PostgreSQL migration session after committing its dirty marker to support a one-connection runtime pool.

  • Address follow-up review findings. SQLite keeps ordinary mixed amounts on compensated projection reads and detects actual range failures. Preparation polls wait for the previous refresh to finish. Failed breakdowns discard old classifications. Model search queries the server even after visiting the directory. Alert history reloads a valid page when retention shrinks the result set.

Type of Change

  • Bug fix
  • New feature
  • Refactor or maintenance
  • Documentation
  • Deployment or configuration

Verification

  • All 12 GitHub CI checks passed on 05c9f2ddbfbcc637047741d2e69d467c8cf665f0, including the PostgreSQL and pinned N-1 contracts.
  • Follow-up verification at 05c9f2dd: SQLite mixed-amount and overflow regressions, 14 isolated browser scenarios, 16 real-backend browser smoke tests, 824 frontend tests, Go vet, pinned lint and migration-manifest checks passed.
  • Complete backend suite passed through all eight repository inventory shards, including a fresh full run after the PostgreSQL CI repairs. The initial unsharded local attempt hit macOS process resource/time limits; the sharded executor completed the suite.
  • go vet ./... and pinned golangci-lint v2.12.2 passed. Targeted shared-cache, cancellation, shutdown and multi-instance backfill tests passed with -race.
  • Real PostgreSQL regression tests cover projection parity, amount correction precision, source persistence on numeric overflow, concurrent backfill/writes with lease takeover, independent same-dimension writers, signed cross-shard deletion offsets, rollback/savepoint/connection reuse, and rejection of incorrect index definitions. The complete CI PostgreSQL server command and migration-runner suite passed against a fresh local test database after correcting the initial CI failures.
  • Frontend with Node 22.23.1 passed typecheck, lint, the domain suite, 824 component tests and a production build. All 16 real-backend browser smoke tests and 10 synthetic UI scenarios passed. Captures were inspected on desktop and mobile.
  • Repository tool tests, translation checks, environment contract, source-line gate and whitespace checks passed.
  • Both databases passed the opt-in scale workload of 3 million usage rows, 3 million request rows, 100,000 alerts and 300 models, using 10 concurrent callers and 100 samples per mode. Overview p95 was approximately 8.0 ms cold / 1.6 ms warm after review fixes on SQLite, and 22.9 ms cold / 13.6 ms warm on PostgreSQL. The overview/breakdown/timeseries chain measured approximately 4.4 ms and 40.7 ms respectively.
  • These measurements use synthetic retained-history rows dated 2026-01-01, outside the fixture's recent trend window. They establish performance for that distribution. PostgreSQL populated pending-index builds completed in approximately 1.2 seconds each. Production OOM attribution and peak RSS require production request/heap evidence.

Standards review

Reviewed migration safety, retry/postconditions, lifecycle deadlines and shared state. Findings were fixed and rechecked. The release prerequisite below remains explicit.

Spec review

Reviewed bounded responses, full statistics, permission isolation, stale-result expiry, model navigation/search, monetary corrections and concurrent/resumable backfill. Reported implementation defects were fixed with regression coverage.

Compatibility, Security, and Operations

The admin overview emits model counts and summary_status; model consumers fetch definitions explicitly. Alert-history consumers iterate the paged response. Deploy the matching admin frontend and backend together.

Schema migrations 12–18 add the projection structures, concurrent indexes and completion state. PostgreSQL index migrations have independent budgets and recovery checks. The online worker starts with the existing background scheduler and releases owned leases on graceful shutdown.

Release prerequisite: the shipped v0.11.0 runner rejects the newer migration ledger entries. Publish and deploy a compatible bridge release before rolling out this change. A local bridge candidate retains target 11 and verifies the exact additive migration checksums through 18. SQLite and PostgreSQL tests started the candidate before and after upgrade, exercised project, key, provider, model, gateway and audit writes after rollback, then verified the feature release read and counted those writes. The official bridge artifacts and managed upgrade flow remain a release step.

SQLite's exceptional numeric-safety fallback scans retained history while retaining permission scoping, caching and deadlines. Normal-range lifetime reads use the projection. Fixtures and benchmark data are synthetic.

Documentation

  • Added English, Chinese and Japanese documentation-index links to the overview guide.
  • Clarified projection-backed overview summaries and lifetime breakdowns, standalone summary queries, range reports and permission-specific quota counts.
  • Documented the rollback bridge prerequisite and the fixed historical dataset's empty recent-trend window. The base v0.11.0 verifier rejected the temporary upgraded schema with unknown_applied_version (version 12), confirming the prerequisite.
  • Documentation translation checks, whitespace checks and all nine added documentation links passed.

Checklist

  • The PR title and body are written in English.
  • Tests were added or updated for behavior changes, or the reason they are unnecessary is documented.
  • No credentials, local .env files, databases, backups, or runtime logs are included.
  • Environment variable changes are synchronized across examples, Compose, start.sh, and deployment documentation where applicable. The scale switch is test-only.
  • Shared user-facing behavior is documented consistently in English, Simplified Chinese, and Japanese where applicable.
  • data/model-catalog.yaml remains tracked and catalog changes were reviewed where applicable.
  • git diff --check passes.

deepjerry-ai and others added 5 commits November 18, 2026 04:36
Replace retained-history materialization with bounded previews, paged alerts, and incremental lifetime projections. Preserve scoped visibility, correction handling, cancellation, and online backfill progress.
Co-Authored-By: OpenAI Codex <noreply@openai.com>

@astaxie astaxie left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff at 05c9f2ddbfbcc637047741d2e69d467c8cf665f0 against the PR base, issue #433 and the overview guide.

Standards

No actionable finding. The shared behavior has English, Simplified Chinese and Japanese guidance, and the changed UI has named acceptance scenarios. The documented compatible bridge release remains a deployment prerequisite; this review does not establish that those release artifacts have shipped.

Spec

No confirmed new actionable finding. Reviewed projection accounting, permission scopes, backfill/concurrency handling, cache expiry/cancellation, alert pagination, model search and frontend loading/status behavior. Focused overview, projection, alert-page, quota-event and model-search Go tests pass.

GitHub CI passes on this exact head. Full local backend/frontend/browser suites and PostgreSQL integration were not rerun for this review.

Findings: Standards 0; Spec 0.

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.

2 participants