Skip to content

feat(review): instrument impact-map + add a public AI-reuse-rate trend (#4448) - #4671

Merged
JSONbored merged 1 commit into
mainfrom
feat/ai-reuse-rate-4448-impact-map-and-aggregate
Jul 10, 2026
Merged

feat(review): instrument impact-map + add a public AI-reuse-rate trend (#4448)#4671
JSONbored merged 1 commit into
mainfrom
feat/ai-reuse-rate-4448-impact-map-and-aggregate

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Scope

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally — 100% line/branch coverage on both new/changed src/** files (impact-map.ts, public-reuse-rate-trend.ts), confirmed via scoped coverage runs
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — hit/miss invariants, both fail-safe audit-write-failure directions, a falsy-project regression, and an end-to-end SQL-discrimination test confirming the aggregate query counts real event types (and only real event types) correctly

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A, no auth/session surface touched.
  • API/OpenAPI/MCP behavior is updated and tested where needed — PublicStatsSchema extended with reuseRateTrend, regenerated via npm run ui:openapi, settings-parity checked.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, backend-only change (no frontend chart in this slice).
  • Visible UI changes include a UI Evidence section. — N/A, backend-only change, no visible UI.
  • Public docs/changelogs are updated where needed. — N/A, no changelog edits in a normal PR; no public docs yet since there's no chart consuming it until the follow-up PR.

#4448)

Completes #4448's cache-hit/miss instrumentation coverage and adds the
aggregate public "how often we avoid redoing AI work" trend, both part
of epic #4445.

Instrumentation: adds cache hit/miss telemetry to impact-map's query
cache (impact_map_query_cache, #4500) -- the last of the genuinely
cache-backed AI-touching capabilities that had zero reuse-rate signal,
mirroring the established incr()+recordAuditEvent pattern exactly
(repo_culture_profile #4509, grounding/review-memory this same epic).
computeImpactMap now takes `env` as an explicit first argument (the
existing RagInfra/StorageAdapter seam intentionally stays storage-only
for portability, so telemetry is threaded separately).

Two of the six capabilities the parent issue named -- enrichment and
reputation -- are deliberately NOT instrumented: neither has a cache or
any other "reuse a prior result" mechanism to measure. Enrichment always
POSTs fresh to the external REES on every invocation (no local cache);
reputation is a pure D1 aggregate with no caching layer (its own
redundant-re-derivation issue was fixed differently, by threading a
pre-computed value caller-to-callee in #4507). Forcing a fabricated
hit/miss signal onto either would misrepresent their real architecture
and just show 100%-miss forever, adding noise instead of signal.

Aggregate: new src/services/public-reuse-rate-trend.ts, extending
GET /v1/public/stats with reuseRateTrend -- 8 trailing weeks of
hits/(hits+misses) across every github_app.*_cache_hit / *_cache_miss
event (a naming convention, not a hardcoded capability list, so it
automatically covers today's eight capabilities and any future one that
follows the same convention) plus ai_review's three non-suffix-conforming
reuse variants (frozen/paused/one-shot), which are the same "avoided a
redundant AI call" signal under a different name.

Deliberately not a cron/rollup table, mirroring #4447's own design:
audit_events is already durable, so a live day-bucketed re-query
recomputes any historical week correctly on every request. Deliberately
NOT scoped to the public-stats repo allowlist either (unlike accuracy) --
a cache-hit/miss event carries no PR content or repo-specific outcome, so
the aggregate number doesn't reveal per-repo activity, and target_key
isn't uniformly shaped across all eight capabilities.

Only the homepage/`/stats` trend chart is deferred to a follow-up PR,
matching the capture-then-extend split already used for #4446 and #4447.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui f580243 Commit Preview URL

Branch Preview URL
Jul 10 2026, 11:17 AM

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored
JSONbored merged commit 89ae2d5 into main Jul 10, 2026
9 checks passed
@JSONbored
JSONbored deleted the feat/ai-reuse-rate-4448-impact-map-and-aggregate branch July 10, 2026 11:18
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.14%. Comparing base (7e76b2e) to head (f580243).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4671   +/-   ##
=======================================
  Coverage   94.13%   94.14%           
=======================================
  Files         434      435    +1     
  Lines       38542    38576   +34     
  Branches    14056    14060    +4     
=======================================
+ Hits        36282    36316   +34     
  Misses       1601     1601           
  Partials      659      659           
Files with missing lines Coverage Δ
src/api/routes.ts 94.26% <100.00%> (ø)
src/openapi/schemas.ts 100.00% <ø> (ø)
src/queue/processors.ts 95.29% <100.00%> (ø)
src/review/impact-map.ts 100.00% <100.00%> (ø)
src/services/public-reuse-rate-trend.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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