Skip to content

telemetry: public /api/stats endpoint (Tier B showcase)#1

Merged
IgnazioDS merged 1 commit intomainfrom
telemetry-public-stats
Apr 27, 2026
Merged

telemetry: public /api/stats endpoint (Tier B showcase)#1
IgnazioDS merged 1 commit intomainfrom
telemetry-public-stats

Conversation

@IgnazioDS
Copy link
Copy Markdown
Owner

Summary

  • Adds a stdlib-only Vercel Python serverless function at api/stats.py exposing the public Tier-B telemetry contract
  • Returns honest GitHub-derived metrics (commits_30d, commits_total, last_commit_at, primary_language, repo_stars, lines_of_code) with mode: "showcase" flagged so the homepage widget renders this tile as a deployed scaffold rather than a live workload system

Why showcase mode

Per the schema at https://github.com/IgnazioDS/IgnazioDS/blob/main/TELEMETRY_SCHEMA.md, this repo is currently a static landing page with a CLI scaffold. Reporting fabricated eval_runs_total / last_pass_rate / regressions_caught_30d counters would violate the credibility constraint of the homepage telemetry panel. The endpoint instead reports real signals about the codebase. When promoted to live workload, the implementation upgrades to Tier A and mode flips to live.

Verification (local with real GitHub call)

{
  "system": "evalops",
  "mode": "showcase",
  "status": "operational",
  "last_deployed_at": "2026-04-27T18:41:57Z",
  "last_commit_at": "2026-04-01T16:54:50Z",
  "metrics": { "commits_30d": 1, "commits_total": 3, "primary_language": "Python", "repo_stars": 0, "lines_of_code": 1177 },
  "schema_version": 1,
  "generated_at": "2026-04-27T18:42:18Z"
}

Test plan

  • Local: python3 -m unittest tests.test_stats — 6/6 pass
  • Local: real GitHub call returns the above shape with live values
  • Live preview: curl <preview>/api/stats returns HTTP 200
  • Browser CORS preflight from https://eleventh.dev
  • Production verification after merge: curl https://evalops-workbench.vercel.app/api/stats

Adds a stdlib-only Vercel Python serverless function at api/stats.py
that exposes honest, GitHub-derived metrics about the codebase. The
endpoint is consumed by the Production Telemetry panel on
https://eleventh.dev.

Per the schema at
https://github.com/IgnazioDS/IgnazioDS/blob/main/TELEMETRY_SCHEMA.md
this system runs in showcase mode (Tier B): the Vercel deploy is a
public landing page, not a system serving production workload. Rather
than fabricate eval_runs_total / last_pass_rate / regressions_caught_30d counters that would have nothing to count, the
endpoint reports real signals about the codebase:

- commits_30d, commits_total      via GitHub Link header pagination
- primary_language, repo_stars    via GET /repos/:owner/:repo
- last_commit_at                  via GET /repos/.../commits?per_page=1
- lines_of_code                   via committed api/_telemetry_static.json
- mode = "showcase"               explicit Tier-B signal for the widget

Implementation:
- BaseHTTPRequestHandler entrypoint, no third-party deps
- 5-min module-scope cache stays under GitHub's 60-req/hr unauth limit
- SAFETY_CAPS clamps every counter
- Never returns HTTP 5xx: GitHub failures degrade to status="degraded"
  with last-good-cache or zeroed metrics
- CORS headers set both at vercel.json edge and inside the handler
- Tests: 6/6 unittest pass (happy, degraded, stale-cache, caps, handler 200, OPTIONS 204)

To refresh lines_of_code before deploying:
  python3 scripts/compute_telemetry_static.py
  git add api/_telemetry_static.json
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evalops-workbench Ready Ready Preview, Comment Apr 27, 2026 6:44pm

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 359e3433cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/stats.py
Comment on lines +112 to +114
last_commit_at = (
latest_commits[0].get("commit", {}).get("author", {}).get("date")
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use committer date for last_commit_at

last_commit_at is currently taken from commit.author.date, which can be arbitrarily old on cherry-picks or rebased history, so the endpoint can report a stale “last commit” time even when new commits were just applied. This impacts telemetry accuracy for the primary status widget; using commit.committer.date (or repo pushed_at) avoids false regressions in freshness.

Useful? React with 👍 / 👎.

@IgnazioDS IgnazioDS merged commit 09b1ce3 into main Apr 27, 2026
3 checks passed
@IgnazioDS IgnazioDS deleted the telemetry-public-stats branch April 27, 2026 19:05
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