Skip to content

Admin UI metrics and config workflow polish#84

Closed
nonithebot wants to merge 33 commits into
ajaysinghj8:feat/prometheus-metricsfrom
nonithebot:noni/admin-ui-metrics-polish
Closed

Admin UI metrics and config workflow polish#84
nonithebot wants to merge 33 commits into
ajaysinghj8:feat/prometheus-metricsfrom
nonithebot:noni/admin-ui-metrics-polish

Conversation

@nonithebot

Copy link
Copy Markdown

This PR continues the admin UI work after #83.

Included:

  • metrics/dashboard polish
  • persistent audit log support
  • config history + rollback workflow
  • config editor workflow hardening
  • raw config preview
  • inline validation feedback
  • YAML draft import/export
  • auth gate + admin secret UX polish
  • config payload guardrails

Validation run locally:

  • npm test -- --runInBand
  • npm run lint
  • cd admin-ui && npm run build

Follow-up to the earlier admin/API batch PR.

ajaysinghj8 and others added 30 commits February 28, 2026 01:24
…trics

feat(metrics): add prometheus-compatible metrics endpoint for cache m…
…mary, purge safety

- nameSpaceHandler: match both /path and /path/ against allow/deny glob patterns
  so trailing-slash requests are handled consistently without pattern-specific quirks
- config.reader: warn on unknown namespace keys (with list of known keys) to catch
  typos before they silently become no-ops
- index.ts: print a human-readable startup summary of config version, enabled features,
  and each namespace (expose→target, cache config, allow/deny lists)
- purgeCache: add broadPatternWarning() — purge responses include a 'warning' field
  when the pattern lacks the 'O:<namespace>' prefix that scopes it to one namespace;
  add optional OSHAM_PURGE_SECRET env-var gate: if set, callers must supply the value
  in x-osham-purge-secret header or receive 401
- tests: 9 new cases covering trailing-slash allow/deny, single-star depth enforcement,
  nested precedence, unknown-key warnings, broad-pattern warning, and purge auth

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- config.reader: add KNOWN_TOP_LEVEL_KEYS set and warn on unknown top-level
  scalar keys (e.g. 'purges: true' as a typo for 'purge: true') instead of
  silently treating them as namespace candidates and throwing a confusing error
- config.reader: filter namespaceKeys to only object-valued non-reserved keys
  so typo scalars are skipped cleanly after the warning
- test: add two new Config Validation tests covering top-level unknown key
  warnings and the absence of warnings on all known top-level keys
- docs/purge-cache.md: document OSHAM_PURGE_SECRET authentication, explain
  the broad-pattern warning, and expand the security guidance section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…es 1+2)

Adds /__osham/admin/* route foundation with shared-secret auth middleware
(OSHAM_ADMIN_SECRET / x-osham-admin-secret header), plus four config endpoints:

  GET  /__osham/admin/config           – return structured IFullConfig + meta
  POST /__osham/admin/config/validate  – validate proposed config, return errors/warnings
  PUT  /__osham/admin/config           – validate + atomically save to cache-config.yml
  POST /__osham/admin/config/reload    – re-read file, update in-memory admin state

New files:
  src/admin.state.ts              – shared admin state (config, meta, revision)
  src/middlewares/adminConfig.ts  – all admin route handlers

Changes:
  src/config.reader.ts  – add validateConfigCollecting() (collects errors/warnings, no throw)
  src/index.ts          – initialise admin state at startup; mount AdminConfig middleware
  test/index.js         – 14 new tests covering auth and all four config endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Purge page:
- Loading state; button disabled while request in flight
- Client-side broad-pattern warning (*, **) shown before submit
- Confirmation checkbox required for all live (non-dry-run) purges;
  danger styling when pattern is also broad
- Result rendered as structured card (status pill, deleted count,
  backend warnings) instead of raw JSON dump
- Pattern/dryRun changes clear stale result and confirmation state

Audit page:
- Loading state with disabled Refresh button during fetch
- Refresh button to manually re-poll without page reload
- Timestamps formatted via toLocaleString() instead of raw ISO
- Fifth column "Details" surfaces key fields from AuditEvent.details
  (pattern + deleted count for purge events, revision for config events)
- Result column uses status-pill with enabled/disabled color coding
- Empty-state message when no events have been recorded yet

Styles:
- .purge-warning / .purge-warning--danger alert banners
- .purge-result / .purge-result-row structured result card

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ajaysinghj8 ajaysinghj8 changed the base branch from master to feat/prometheus-metrics March 24, 2026 17:07
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