feat(api): add public-safe README status badge with badgeEnabled opt-in (#541) - #753
Conversation
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
gittensory · advisory review Reviewed 10 changed file(s) — two independent AI reviewers. Changed files (10)
Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Suggestions
Worth double-checking
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…t/541-public-readme-badge
…toby/gittensory into feat/541-public-readme-badge
…t/541-public-readme-badge
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #753 +/- ##
==========================================
+ Coverage 96.74% 96.76% +0.02%
==========================================
Files 95 97 +2
Lines 13905 13992 +87
Branches 5075 5098 +23
==========================================
+ Hits 13453 13540 +87
Misses 86 86
Partials 366 366 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@JSONbored fixed ci errors |
JSONbored
left a comment
There was a problem hiding this comment.
PR #753 — feat(api): add public-safe README status badge with badgeEnabled opt-in (#541)
Verdict: MERGE
Resolves issue #541: FULLY
CI: Green (lint, test 1/2, workers, ui, security, changes). gittensory neutral.
Highlights:
- Matches the spec: src/api/badge.ts (self-rendered SVG, no external service) + src/services/public-repo-quality.ts deriving only the three whitelisted metrics (median time-to-merge, % non-slop, coarse queue-health). Hard whitelist; no contributor/reward/trust path.
- Correct opt-in + install gating: unknown/uninstalled/not-opted-in all return a benign 404 "unavailable" badge. Routes excluded from requiresApiToken (intentionally public), cached with stale-while-revalidate; all text XML-escaped; tests assert no forbidden terms + negative paths + cache headers. Queue-health computed locally for public-safety isolation.
Concerns / required changes:
- Migration number collision: migrations/0037_badge_enabled.sql collides with PR #755's migrations/0037_gate_outcomes.sql (main at 0036). One must renumber to 0038; coordinate ordering.
Completeness vs issue: Fully satisfies the AC — badge serves only whitelisted metrics for installed+opted-in repos, cached, no private-data path, with whitelist/opt-in/cache/redaction tests. Only blocker is the shared 0037 number with #755.
Summary
GET /v1/public/repos/:owner/:repo/badge.svgand a shieldsbadge.jsonendpoint.badgeEnabledsetting. Any other repo (unknown, uninstalled, or not opted in) returns a benign 404 "unavailable" badge with no metrics. Responses are aggressively cached with stale-while-revalidate, mirroring the existing public stats route.Closes #541
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderatenpm run test:cipasses end to end. Coverage (src/**): statements 98.65%, branches 97.05%, functions 97.06%, lines 99.27% (all ≥ 97%); the two new modulessrc/services/public-repo-quality.tsandsrc/api/badge.tsare 100% statements/branches, and the new route paths are exercised by integration tests.npm auditreports 0 vulnerabilities.ui:openapi:checkreports no drift.If any required check was skipped, explain why:
npm run test:cigate was run locally and passed.Safety
requiresApiToken; negative paths (not installed / not opted in / unknown repo → 404 "unavailable") are covered by integration tests.ui:openapi:checkis clean (the curated OpenAPI spec is unchanged, consistent with the existing public stats/subnet routes).UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository. N/A — this is an API endpoint, not a web/extension UI surface (see UI Evidence note below).UI Evidence
Not applicable — this is a backend API endpoint, not a web/extension UI surface. The badge is a self-rendered SVG served at
GET /v1/public/repos/:owner/:repo/badge.svg; its exact content (label, message, color) is asserted intest/unit/badge.test.tsand the integration tests rather than via screenshots.Notes
0037_badge_enabled.sqladdsrepository_settings.badge_enabled(INTEGER NOT NULL DEFAULT 0) — the next free migration number after0036.badgeEnabledis wired through the settings read/write path so maintainers can toggle it via the existing repository-settings endpoint. It is typed optional onRepositorySettings(always populated by the DB layer; default false) to keep the diff focused and avoid churning unrelated settings fixtures.QueueHealthsignal, so no private-derived value reaches this unauthenticated surface.migrations/0037_badge_enabled.sql,src/services/public-repo-quality.ts,src/api/badge.ts,src/api/routes.ts,src/db/schema.ts,src/db/repositories.ts,src/types.ts,test/unit/public-repo-quality.test.ts,test/unit/badge.test.ts,test/integration/api.test.ts.