Skip to content

[api] AIN-299 W5: public live counter (aggregate-only)#91

Merged
hizrianraz merged 2 commits into
mainfrom
hizrianraz/ain-299-w5-audit-counter
May 28, 2026
Merged

[api] AIN-299 W5: public live counter (aggregate-only)#91
hizrianraz merged 2 commits into
mainfrom
hizrianraz/ain-299-w5-audit-counter

Conversation

@hizrianraz
Copy link
Copy Markdown
Contributor

@hizrianraz hizrianraz commented May 28, 2026

GET /v1/stats/public/counter — 4 aggregate fields, 60s cache, NO PII (3 unit tests enforce). AIN-293 Slack code deferred to post-Spark Fri.


Note

Medium Risk
New unauthenticated public endpoint reads production aggregates (routing, agents, cost); privacy is schema- and test-guarded but cache is per-process only until multi-worker scaling.

Overview
Adds a public GET /v1/stats/public/counter endpoint on the existing stats router so the marketing site can poll aggregate-only live metrics: routed decisions (lifetime and 24h, cheapest_clearing_floor on routing_outcomes), active agents, and cumulative succeeded inference cost in USD.

Responses are built from a single multi-subquery SQL read, wrapped in a CounterResponse schema with fetched_at and cache_ttl_sec. A 60-second in-process cache limits DB load under frequent polling; module notes call out single-worker behavior and a future Redis/shared cache if the API scales out.

Privacy is explicit in the API contract (no agent/tenant/per-row IDs). tests/unit/test_audit_counter_no_pii.py locks schema fields, types, and absence of UUID-shaped strings in JSON. The OpenAPI v1 contract smoke test now expects this route.

Reviewed by Cursor Bugbot for commit 13805df. Bugbot is set up for automated code reviews on this repo. Configure here.

GET /v1/stats/public/counter · 60s cache · 3 fields + Decimal cost.
NO PII (3 unit tests). AIN-293 Slack code-only deferred to post-Spark.
7 tests pass. pre-commit clean.

Refs: AIN-299 · §D3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

AIN-299 [Marketing] Live public audit counter — ainfera.ai transparency surface (eat-our-own-cooking)

Live public audit counter — eat-our-own-cooking transparency surface

Polsia-style transparency move on Ainfera's terrain. Free positioning, single Aulë day, no critical path.

What

Component on ainfera.ai (footer or hero) that polls /v1/audit/public every N seconds (60s reasonable) and displays live aggregate:

Metric Source
Routed decisions (lifetime) count(audit_events WHERE event_type='inference.routed')
Agents served count(distinct agents.id WHERE status='active')
Cumulative inference cost routed sum(inferences.cost_usd)
(Optional) cumulative savings vs baseline from routing_outcomes delta corpus once Labs daily cron has 14d data

Display in dark mode (Brand v1.3: #070B14 bg · #E8EDF5 ink · #4D95E8 accent · IBM Plex Sans 500).

Why

Perplexity external pressure-test 2026-05-28 surfaced this as the highest-extraction insight: Ainfera's /v1/audit/public feed is live but no marketing surface exposes it. Polsia's live dashboard of 7,600+ companies is a marketing wedge — Ainfera's equivalent is the audit chain. Same play, different proof artifact.

Eat-our-own-cooking corollary: routing 100% of internal LLM calls (fleet + Aulë IDE) through ainfera-inference is already locked. Surfacing the audit publicly = marketing for free.

Scope

  • Add /api/audit-counter aggregator endpoint in ainfera-ai/api (60s cache; tenant-aggregate counts, no per-agent leak)
  • Marketing site component (ainfera-ai/web or current marketing repo): React/Vue/static, polls endpoint, animates count-up
  • Brand v1.3 styling
  • Verify no PII leaks via audit-counter (only aggregate counts, never agent_id or tenant_id)
  • A11y: numbers announced for screen readers only on full minute (not every tick)

Acceptance

  • Counter renders on ainfera.ai
  • Polls /v1/audit/public aggregate every 60s
  • Numbers monotonically non-decreasing across reload (proves not fake)
  • 0 PII in network response (verify in browser devtools)
  • Dark-mode compliant
  • Smoke test: counter increments after a fresh routed call

Apply window

Post-Spark migration (Week of 2026-06-08+). Not on critical path. Single Aulë day once daily cadence is stable.

Linked

Source

External pressure-test 2026-05-28 (Perplexity analysis) — sole actionable extraction. Other Perplexity recommendations (local Qwen judge, α=25%, agentium.yaml) rejected for lock conflicts.

Review in Linear

…l cache

Refs: AIN-299 W5 follow-up

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hizrianraz hizrianraz merged commit 24d28cf into main May 28, 2026
4 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