Skip to content

feat(enrichment): add magic-number analyzer - #3324

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
joaovictor91123:feat/magic-number-analyzer
Jul 5, 2026
Merged

feat(enrichment): add magic-number analyzer#3324
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
joaovictor91123:feat/magic-number-analyzer

Conversation

@joaovictor91123

Copy link
Copy Markdown
Contributor

Summary

  • Adds the magicNumber REES analyzer for non-trivial numeric literals newly introduced in non-test source diffs.
  • Registers the analyzer across REES metadata, rendered briefs, UI analyzer metadata, and the shared analyzer-name list.
  • Adds focused tests for tokenization, suppression heuristics, diff line tracking, caps, abort handling, rendering, and registry integration.

Fixes #2018

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 >=99% coverage of the lines AND branches you changed (aim for 100% 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

Additional validation:

  • npm --prefix review-enrichment run build
  • node review-enrichment/test/magic-number.test.ts
  • node review-enrichment/test/analyzer-registry.test.ts
  • node review-enrichment/scripts/generate-analyzer-metadata.mjs --check
  • npm run db:migrations:check

If any required check was skipped, explain why:

  • npm run test:coverage was not run locally; this change is covered by the focused REES analyzer suite and CI will run coverage in its Linux environment.
  • npm run test:mcp-pack was not run; this PR does not change MCP packaging.
  • npm run ui:openapi:check was not run separately; npm run ui:build regenerated OpenAPI successfully and the intended UI change is generated REES analyzer metadata.
  • npm run ui:lint fails locally on Windows CRLF formatting across many untouched UI files before reaching this change.
  • npm run rees:test was also run locally: 918/920 tests passed; the two failures were existing Sentry CLI upload tests whose mocked process returned a Windows-style null status. The new magic-number tests passed in that run.

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.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • 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.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

No visible UI change. The UI diff is generated analyzer metadata consumed by the existing REES analyzer reference surface.

Notes

  • The analyzer reports only { file, line, value } and does not copy surrounding source into rendered briefs.

@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 02:51:35 UTC

11 files · 1 AI reviewer · no blockers · readiness 62/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
The PR adds a local `magicNumber` analyzer and wires it through the REES registry, render path, generated metadata, UI metadata, shared analyzer-name list, docs, and focused tests. The scanner is bounded, added-line-only, source-path gated, and public-safe in its rendered output, which matches the intended analyzer shape. I do not see a reachable correctness defect in the visible diff; the remaining points are precision/maintenance nits rather than blockers.

Nits — 6 non-blocking
  • nit: review-enrichment/src/analyzers/magic-number.ts:183 allowlisting uses absolute magnitude, so `-2` is suppressed even though the descriptor/docs only call out `2` and `-1`; either document signed `±2` as intentional or special-case the signed sentinel set.
  • nit: review-enrichment/src/analyzers/magic-number.ts:60 `sourceExtOf` treats `*.d.ts` as ordinary TypeScript source, so declaration files can produce findings even though they often contain structural numeric literal types rather than implementation constants; confirm that is intentional or suppress declaration-only paths.
  • nit: review-enrichment/src/analyzers/magic-number.ts:208 `stripInlineComments` cuts on the first `/*` and does not model block-comment state, so a line of real code after an inline block comment stays hidden; that is precision-first but worth documenting because it creates a deliberate false-negative class.
  • review-enrichment/src/analyzers/magic-number.ts:183: make the signed allowlist explicit, for example by checking the normalized literal string before falling back to magnitude-based powers/scales, or update the registry/README wording to say `-2` is intentionally silent too.
  • review-enrichment/src/analyzers/magic-number.ts:54: consider adding a path test for `src/types.d.ts` and either suppress it or pin the current behavior so future reviewers know declaration files are in scope.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2018
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 104 registered-repo PR(s), 58 merged, 8 issue(s).
Contributor context ✅ Confirmed Gittensor contributor joaovictor91123; Gittensor profile; 104 PR(s), 8 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: joaovictor91123
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 104 PR(s), 8 issue(s).
  • Related work: Titles/paths share 5 meaningful terms. (issue #2025, issue #1514)
  • Related work: Titles/paths share 7 meaningful terms. (issue #2025, issue #2017)
  • Related work: Titles/paths share 7 meaningful terms. (issue #2025, issue #2033)
  • Additional title-only matches omitted; title-only overlap does not block.
Contributor next steps
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Await review-lane availability.
  • 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.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (7df540c) to head (c2ef700).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3324   +/-   ##
=======================================
  Coverage   93.76%   93.76%           
=======================================
  Files         277      277           
  Lines       30507    30507           
  Branches    11108    11108           
=======================================
  Hits        28605    28605           
  Misses       1257     1257           
  Partials      645      645           
Files with missing lines Coverage Δ
src/review/enrichment-analyzer-names.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit e759c91 into JSONbored:main Jul 5, 2026
9 checks passed
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

None yet

Development

Successfully merging this pull request may close these issues.

feat(enrichment): magic-number heuristic analyzer

1 participant