refactor(review): consolidate 3 duplicate helper implementations - #4677
Merged
Conversation
Three independent, low-risk duplicate cleanups from the review-stack architecture audit's duplication dimension: - isCommentLine: extracted the byte-identical body shared by unsafe-any.ts, complexity.ts, and floating-promise.ts into a new isBasicCommentLine export in review-enrichment's diff-lines.ts. hardcoded-url.ts and a11y-regression.ts keep their own isCommentLine override, now composing the shared base plus their deliberate per-language extras (shell/Python #, HTML <!--, JSX import/from) instead of re-deriving the whole regex. - authoritativeContributorRepoStats: exported the single implementation from services/decision-pack.ts and pointed api/routes.ts, mcp/server.ts, and queue/processors.ts at it instead of each carrying its own copy. - hasUnsafeWildcardCount: packages/gittensory-engine/src/scoring/preview.ts now imports the wildcard-safety check from its own package's signals/change-guardrail.ts instead of re-deriving a third hand- maintained copy; the guarded host/engine change-guardrail.ts pair is untouched. No behavior change. Validated with typecheck, the engine package's own build and test suite, the engine-parity contract test, review-enrichment's node:test suite, and targeted vitest runs (coverage scoped to the changed files) against the decision-pack, api, mcp, queue, and scoring tests.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 1cee567 | Commit Preview URL Branch Preview URL |
Jul 10 2026, 11:31 AM |
Contributor
|
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 #4677 +/- ##
=======================================
Coverage 94.14% 94.14%
=======================================
Files 435 435
Lines 38566 38550 -16
Branches 14060 14054 -6
=======================================
- Hits 36308 36293 -15
Misses 1599 1599
+ Partials 659 658 -1
🚀 New features to boost your workflow:
|
2 tasks
This was referenced Jul 10, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainbefore fixing:isCommentLine(5 bodies inreview-enrichment/src/analyzers/):unsafe-any.ts,complexity.ts, andfloating-promise.tscarried a byte-identicalisCommentLine. Extracted it as a newisBasicCommentLineexport indiff-lines.ts(the existing home for shared diff-line predicates, alongsideisDiffFileHeaderLine), and pointed those 3 files at the import.hardcoded-url.tsanda11y-regression.tskeep their ownisCommentLine— each now composes the shared base plus its deliberate per-language extra (#/<!--for shell/Python/HTML,<!--/import/fromfor JSX) instead of re-deriving the whole regex, documented as an override.authoritativeContributorRepoStats(4 copies): confirmed all 4 still functionally identical (only type-spelling/formatting differed). Exported the one inservices/decision-pack.tsand replaced the local copies inapi/routes.ts,mcp/server.ts, andqueue/processors.tswith an import.hasUnsafeWildcardCount(3rd private copy): the guarded host/engine pair (src/signals/change-guardrail.ts↔packages/gittensory-engine/src/signals/change-guardrail.ts) is untouched.packages/gittensory-engine/src/scoring/preview.tshad a 3rd, non-exported copy invisible to the engine-parity drift check by construction — it now importshasUnsafeWildcardCountfrom its own package'ssignals/change-guardrail.tsinstead of redefining it.Fixes #4611
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥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:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run typecheck(full, clean),npm --workspace @jsonbored/gittensory-engine run build(clean),npm run rees:test(review-enrichment's own build + node:test suite, 1224/1224 passing),npm run test:engine-parity(15/15, confirms the guarded host/enginechange-guardrail.tspair is untouched),npm run test --workspace @jsonbored/gittensory-engine(the engine package's own standalone suite, 349/349), and targetedvitest runagainst every test file that exercises a changed line (decision-pack.test.ts,api.test.ts, thequeue.test.tscontributor-evidence tests,scoring.test.ts) with--coveragescoped to the changed files —decision-pack.tsat 98.96%/96.76% (line/branch) withauthoritativeContributorRepoStatsfully exercised,preview.tsat 98.73%/99.56% withhasUnsafeWildcardCountfully exercised on both branches, and theprocessors.tscall site directly confirmed executed via the lcov report.actionlint/test:workers/build:mcp/test:mcp-pack/ui:*/npm auditare not exercised by this diff (no workflow, workers-pool, MCP-package-build, UI, or dependency changes) and are left to CI. Rebased onto freshmainimmediately before pushing (main had moved, including an unrelated review-enrichment dedupe PR and a largequeue/processors.tschange) and re-ran the full validation pass above against the rebased tree with identical results.Safety
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.Not applicable: no auth/cookie/CORS/GitHub App/Cloudflare/session changes, no API/OpenAPI/MCP request/response shape changes, and no UI/docs changes in this PR.
UI Evidence
Not applicable — no visible UI, frontend, docs, or extension changes.
Notes
main(not just the issue text) before fixing, since line numbers had drifted (e.g.authoritativeContributorRepoStatsinqueue/processors.tshad moved by ~340 lines).