Skip to content

feat(enrichment): image/binary asset weight-delta analyzer - #1621

Merged
JSONbored merged 6 commits into
JSONbored:mainfrom
oktofeesh1:feat/enrichment-asset-weight-scanner
Jun 29, 2026
Merged

feat(enrichment): image/binary asset weight-delta analyzer#1621
JSONbored merged 6 commits into
JSONbored:mainfrom
oktofeesh1:feat/enrichment-asset-weight-scanner

Conversation

@oktofeesh1

@oktofeesh1 oktofeesh1 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Closes feat(enrichment): Image/binary asset weight delta #1506.
  • Adds a REES analyzer that flags heavy binary image/font/archive/media assets added by a PR or grown by at least 100 KB.
  • Forwards each stored PR file's status into REES so modified binaries can be compared against baseSha and rendered as growth instead of new additions.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • 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
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • None. Also ran npm --prefix review-enrichment test for the standalone REES package.

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. Not applicable; this change only adds REES analysis and forwards stored PR file metadata.
  • API/OpenAPI/MCP behavior is updated and tested where needed. No public API/OpenAPI/MCP schema changes are needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. Not applicable; no UI changes.
  • Visible UI changes include a UI Evidence section 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. Not applicable; no visible UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. Not applicable; no docs or changelog changes.

UI Evidence

No visible UI, frontend, docs, or extension changes.

Notes

  • The branch is rebased onto current main, resolving the previous merge conflict.
  • The server wire test now asserts file status is included in the REES request body.
  • The REES package regression runs the grown-binary case through buildBrief, so the analyzer is exercised through the production registry path.

Comment thread review-enrichment/src/analyzers/asset-weight.ts Outdated
@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jun 27, 2026
@dosubot dosubot Bot added the size:L label Jun 28, 2026
@superagent-security superagent-security Bot removed the pr:flagged PR flagged for review by security analysis. label Jun 28, 2026
@loopover-orb

loopover-orb Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review — held for maintainer review

7 files · 1 AI reviewer · no blockers · readiness 55/100 · CI green · unknown

⏸️ Held for maintainer review — Large change — held for manual review

Review summary
This adds a REES analyzer for binary asset size findings, wires PR file status/previous path through enrichment, and renders added/grown asset findings into the prompt brief. The main analyzer logic is coherent: it evaluates all binary candidates before capping findings, treats copied files as added, and compares modified/renamed files against base sizes only when base data is available. I do not see a must-fix runtime or contract break in the provided diff.

Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #1506
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Review load ❌ 8/20 Readiness component derived from cached public PR metadata and labels; size label size:L.
Validation evidence ❌ 5/25 Cached preflight status is hold.
Open PR queue ❌ 3/10 17 open PR(s), 12 likely reviewable, 5 unlinked.
Contributor context ✅ Confirmed Gittensor contributor oktofeesh1; Gittensor profile; 267 PR(s), 6 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Nits — 7 non-blocking
  • nit: review-enrichment/src/analyzers/asset-weight.ts:213 still fetches base sizes even when the head size map is empty, so a failed/non-matching head lookup can spend extra API budget before returning no findings.
  • nit: review-enrichment/src/analyzers/asset-weight.ts:150 should check the Contents fallback response is a file/blob before trusting a numeric size, because the current shape would accept any non-array object with a size field.
  • nit: review-enrichment/src/render.ts:35 formats sub-MiB values with integer KiB but MiB with one decimal, which is readable but makes threshold-adjacent values less precise in the brief.
  • In review-enrichment/src/analyzers/asset-weight.ts:213, return early when `headSizes.size === 0` before fetching base sizes to preserve the documented fail-safe behavior and reduce wasted GitHub calls.
  • In review-enrichment/src/analyzers/asset-weight.ts:150, require `json.type === "file"` or equivalent before `sizes.set(path, json.size)` in the Contents API fallback.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
  • Large change — held for manual review — Split this into smaller, focused PRs, or a maintainer reviews and merges it manually.
Review context
Contributor next steps
  • Review top overlaps.
  • Add scope summary.
  • Fix blocker.
  • Expect slower review.
  • Refresh registry data or choose a registered active repo.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review details

Generated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative.

This adds a REES analyzer for binary asset size findings, wires PR file status/previous path through enrichment, and renders added/grown asset findings into the prompt brief. The main analyzer logic is coherent: it evaluates all binary candidates before capping findings, treats copied files as added, and compares modified/renamed files against base sizes only when base data is available. I do not see a must-fix runtime or contract break in the provided diff.

Nits (5)

  • nit: review-enrichment/src/analyzers/asset-weight.ts:213 still fetches base sizes even when the head size map is empty, so a failed/non-matching head lookup can spend extra API budget before returning no findings.
  • nit: review-enrichment/src/analyzers/asset-weight.ts:150 should check the Contents fallback response is a file/blob before trusting a numeric size, because the current shape would accept any non-array object with a size field.
  • nit: review-enrichment/src/render.ts:35 formats sub-MiB values with integer KiB but MiB with one decimal, which is readable but makes threshold-adjacent values less precise in the brief.
  • In review-enrichment/src/analyzers/asset-weight.ts:213, return early when `headSizes.size === 0` before fetching base sizes to preserve the documented fail-safe behavior and reduce wasted GitHub calls.
  • In review-enrichment/src/analyzers/asset-weight.ts:150, require `json.type === "file"` or equivalent before `sizes.set(path, json.size)` in the Contents API fallback.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jun 28, 2026
@JSONbored JSONbored added the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jun 28, 2026
@oktofeesh1
oktofeesh1 force-pushed the feat/enrichment-asset-weight-scanner branch from e3990c3 to d2be23f Compare June 28, 2026 04:51
@loopover-orb loopover-orb Bot removed the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jun 28, 2026
@oktofeesh1
oktofeesh1 force-pushed the feat/enrichment-asset-weight-scanner branch from d2be23f to f382cda Compare June 28, 2026 06:31
@JSONbored JSONbored added the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jun 28, 2026
@loopover-orb loopover-orb Bot removed the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jun 28, 2026
@oktofeesh1
oktofeesh1 force-pushed the feat/enrichment-asset-weight-scanner branch from 0cc500b to 65a2026 Compare June 28, 2026 12:36
@JSONbored JSONbored added the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.58%. Comparing base (9df67cc) to head (e11542b).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1621   +/-   ##
=======================================
  Coverage   95.58%   95.58%           
=======================================
  Files         204      204           
  Lines       22295    22297    +2     
  Branches     8053     8055    +2     
=======================================
+ Hits        21310    21312    +2     
  Misses        408      408           
  Partials      577      577           
Files with missing lines Coverage Δ
src/review/enrichment-wire.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.

Adds a REES analyzer that flags a PR committing or growing a heavy image/font/
binary blob — repo + CDN/cold-start bloat the textual diff hides behind 'Binary
files differ'. Binary sizes are not in the patch, so it fetches the repo's git
tree at headSha (and baseSha for modified files) with the request's short-lived
GitHub token — one recursive call returns every blob size and sidesteps the
Contents API 1 MB cap — then it is pure size arithmetic. Flags a newly-added
blob >= 100 KB or growth >= 100 KB; text formats (.svg/.json) are excluded.

repoFullName is validated to exactly two safe owner/repo segments (no extra
slash, no '.'/'..' traversal) and sha to a commit-SHA pattern, and every path
segment is URL-encoded, so a hostile repoFullName cannot redirect the
token-bearing request to another repo. Fail-safe: returns [] without a token or
on a failed/unsafe fetch. Bounded by MAX_FILES; injects fetch for tests,
mirroring the dependency-scan analyzer.

Closes JSONbored#1506.
Compare renamed and copied binary assets against their previous paths, and keep truncated Git tree responses useful by falling back to candidate-path size lookups.

Pin the GitHub API version for asset size fetches and render binary-scaled sizes with KiB/MiB labels.

Validation: npm run test:ci; npm audit --audit-level=moderate.
@oktofeesh1
oktofeesh1 force-pushed the feat/enrichment-asset-weight-scanner branch from fd03b2b to ec216c9 Compare June 29, 2026 00:12
Treat copied binary paths as newly added assets so heavy copied files are reported by their full introduced size instead of being discounted against the source path.

Add a regression test that covers an equal-size copied binary and verifies the base tree is not fetched for that classification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(enrichment): Image/binary asset weight delta

2 participants