feat(rees): add real before/after complexity-delta analyzer - #4758
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 92b6706 | Commit Preview URL Branch Preview URL |
Jul 11 2026, 12:33 AM |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4758 +/- ##
=======================================
Coverage 94.23% 94.23%
=======================================
Files 441 441
Lines 38793 38793
Branches 14129 14129
=======================================
Hits 36556 36556
Misses 1577 1577
Partials 660 660
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-11 00:27:26 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. 🟩 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.
|
complexity.ts can only score newly-added functions (diff-hunk only) against a fixed threshold, so a PR that meaningfully simplifies an existing gnarly function gets no credit. Add a complexityDelta analyzer that uses the shared reconstructOldContent primitive (#4739) to recover a changed file's pre-PR text, re-runs complexity.ts's own decision-point counting against both versions, and diffs matched functions by name into a structured {file,line,name,before,after,delta} finding. Registered as a separate AnalyzerName (github-light, requires a token/headSha) rather than folded into complexity's existing entry: merging the network fetch into that entry's single requires/cost would gate complexity's free, local, always-on check behind github-token/head-sha (scheduler.ts skips a descriptor's run entirely based on declared requires), regressing it whenever either is unavailable, or mislabel the network-dependent half as cost:local. Part of epic #4737 (PR improvement signal), sub-issue #4740.
8be2439 to
7944d24
Compare
…mes twin src/review/enrichment-analyzer-names.ts and its hand-duplicated engine-package counterpart must stay in normalized parity; the complexityDelta entry added in #4740 only landed on the main-app copy.
7944d24 to
92b6706
Compare


Summary
complexityDeltaREES analyzer that uses the sharedreconstructOldContentprimitive (Generalize reconstructOldContent into a shared before-content capability on AnalysisContext #4739) to recover a changed file's pre-PR text, re-runscomplexity.ts's own decision-point counting against both the reconstructed old and current head versions, matches functions by name, and diffs the two scores into a structured{file, line, name, before, after, delta}finding.complexity.tsonly scores newly-added functions (whose opening line is visible in the diff) against a fixed absolute threshold, so a PR that meaningfully simplifies an existing gnarly function currently gets no credit at all.AnalyzerName(complexityDelta,cost: "github-light",requires: ["files","github-token","head-sha"]) rather than folded intocomplexity's existing entry. Reasoning documented in both files' headers: merging the network-dependent fetch intocomplexity's singlerequires/costwould either (a) gatecomplexity's existing free, local, always-on absolute-threshold check behind a token/headSha — regressing it whenever either is unavailable, sincescheduler.ts'sskipReasonForAnalyzerskips a descriptor'srunentirely based on its declaredrequires, beforerunis ever invoked — or (b) mislabel the network-dependent half ascost: "local", letting it dodge thegithub-lightconcurrency/timeout budget and thefastprofile's network-free guarantee. Two honestly-classified descriptors instead of one dishonest one.complexity.ts's own absolute-threshold behavior (scanPatchForComplexity/scanComplexity/ComplexityFinding) is completely unchanged — only additive exports (isJsTsPath,scanContentForComplexity) so the new analyzer reuses the identical file-eligibility filter and decision-point counting rather than duplicating it.null(unreconstructable patch) and""(wholly-added file) returns fromreconstructOldContentare treated identically via plain truthiness (if (!oldContent)), per that function's own doc comment — never a strict=== nullcheck, which would wrongly treat a brand-new file's""as valid before-content.Closes #4740
Part of epic #4737
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #4740(a complete, independently-resolved sub-issue of epic Epic: PR improvement signal — quality-delta scoring as the positive-axis counterpart to slop-risk #4737).Validation
git diff --check— clean.npm run actionlint— not run; no.github/workflows/**changes in this diff.npm run typecheck— clean.npm run test:coverage— not run; this change is scoped toreview-enrichment/**(a separate Node--test-based service; percodecov.yml, "coverage is collected by vitest (v8) oversrc/**", soreview-enrichment/**is outside that gate entirely) plus one non-branching array-literal addition insrc/review/enrichment-analyzer-names.ts(module-levelconstarray, executed on import by every existing test that already imports it transitively). Ran REES's own full suite instead:npm run rees:test— 1260/1260 passing, including 52 tests across the new/changed complexity files. Also ran the specific affected root unit test,test/unit/review-enrichment-config.test.ts— 17/17 passing.npm run test:workers— not run; no Workers runtime code touched.npm run build:mcp/npm run test:mcp-pack— not run; no MCP package changes.npm run ui:openapi:check— not run; no OpenAPI/API schema changes (this is an internal REES analyzer registration, not a documented HTTP endpoint change).npm run ui:lint/npm run ui:typecheck/npm run ui:build— not run; the onlyapps/gittensory-ui/**file touched is the auto-regeneratedrees-analyzers.tsdata catalog (vianpm run metadata), not hand-authored UI logic.npm audit --audit-level=moderate— clean, 0 vulnerabilities (no new dependencies added).reconstructOldContentdegradation cases (nullvs""), each as its own distinct test.Safety
Notes
npm run rees:test(1260/1260 tests passing, Node 22 via.nvmrc), rootnpm run typecheck(clean),npm audit --audit-level=moderate(clean),git diff --check(clean).review-enrichment/analyzer-metadata.json,apps/gittensory-ui/src/lib/rees-analyzers.ts, and the generated block in.env.examplevianpm run metadata, mirroring the exact file set touched by the two closest precedent PRs that added a REES analyzer (#4155,#3594).