Skip to content

fix(rees): stop dropping added lines whose content starts with ++#2398

Closed
glorydavid03023 wants to merge 1 commit into
JSONbored:mainfrom
glorydavid03023:fix/rees-added-line-plus-prefix
Closed

fix(rees): stop dropping added lines whose content starts with ++#2398
glorydavid03023 wants to merge 1 commit into
JSONbored:mainfrom
glorydavid03023:fix/rees-added-line-plus-prefix

Conversation

@glorydavid03023

Copy link
Copy Markdown
Contributor

Summary

collectAddedLines and filesHaveAddedLines in review-enrichment/src/analysis-context.ts skipped any patch body line starting with +++ or ---. That guard is meant only for unified-diff file headers (+++ b/file, --- a/file), which always have the marker run followed by a space. Git renders an added line whose content is ++x as + + ++x = +++x (no space), so it was mistaken for a header:

  • the ++x added line was dropped from addedLines, and because newLine was not advanced for it, every following added line in the hunk was numbered one too low;
  • filesHaveAddedLines returned false for a PR whose only addition starts with ++;
  • addedLines feeds analyzers such as secret-scan.ts, so a secret on an added line whose content starts with ++ was silently skipped.
collectAddedLines([{ path: "a.ts", patch: "@@ -1,0 +1,2 @@\n+++x\n+const y = 1;" }])
// actual:   [{ line: 1, text: "const y = 1;" }]                       (++x lost, next line mis-numbered)
// expected: [{ line: 1, text: "++x" }, { line: 2, text: "const y = 1;" }]

Fix: track whether the parser is inside a hunk. The diff preamble (+++ /--- headers, diff/index/mode lines) only precedes the first @@; inside a hunk the first character is always the +/-/space op, so +++x is correctly read as an addition. This fixes the whole class (any content beginning with ++/--, with or without a following space), not just one reproduction. Pure diff parser — no schema or API change.

No issue because issue creation is restricted on this repo for outside accounts; this is a small, self-evident correctness fix.

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 (the rees package tsc -p tsconfig.json build is clean)
  • npm run test:coverage (N/A — review-enrichment/** is outside Codecov's src/**/*.ts include; see note)
  • 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:

  • The change is confined to the review-enrichment (rees) package, which has its own build + test. I ran npm --prefix review-enrichment run build (clean) and node --test test/analysis-context.test.ts12/12 pass, including the added regression and all pre-existing cases (byte-cap, context-only, dependency scans). review-enrichment/** is outside Codecov's src/** include, so it carries no patch-coverage obligation. I did not commit review-enrichment/analyzer-metadata.json or apps/gittensory-ui/src/lib/rees-analyzers.ts: analysis-context.ts is not an analyzer, so it does not affect the analyzer registry those files are generated from (the local metadata:check staleness is a pre-existing LF↔CRLF artifact that reproduces on unmodified main and passes in CI's Linux checkout). I did not run the UI/workers/MCP steps (unrelated to this rees-only diff).

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/cookie/CORS/session changes.
  • API/OpenAPI/MCP behavior is updated and tested where needed. (No API/OpenAPI/MCP surface changed; this is an internal diff parser.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A: no UI change.
  • Visible UI changes include a UI Evidence section below. — N/A: no visible UI change.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. (No docs/changelog change needed.)

Notes

  • Regression test in review-enrichment/test/analysis-context.test.ts asserts collectAddedLines returns [[1, "++x"], [2, "const y = 1;"]] for the +++x patch (recovered line + corrected numbering) and that filesHaveAddedLines returns true for a +++x-only patch.
  • Both collectAddedLines and filesHaveAddedLines were fixed identically (the deletion side ---x is likewise no longer mistaken for a --- header).
  • No UI Evidence section: there is no visible UI, frontend, docs, or extension change.

collectAddedLines and filesHaveAddedLines skipped any patch body line starting
with +++ or ---. That guard is only meant for unified-diff file headers
(`+++ b/file`, `--- a/file`), which always have the marker run followed by a
space. Git renders an added line whose content is `++x` as `+` + `++x` =
`+++x`, so it was mistaken for a header: the line was dropped from addedLines,
newLine was not advanced (mis-numbering every following added line), and
filesHaveAddedLines returned false for a PR whose only addition starts with ++.
addedLines feeds analyzers such as secret-scan, so a secret on such a line was
silently skipped.

Track whether the parser is inside a hunk instead: the diff preamble only
precedes the first @@, and inside a hunk the first character is always the
+/-/space op, so `+++x` is correctly read as an addition. This fixes the whole
class (any content beginning with ++/--, with or without a following space).
Adds a regression test.

No issue because issue creation is restricted on this repo; this is a small,
self-evident correctness fix in a pure diff parser with no schema or API change.
@dosubot dosubot Bot added the size:S label Jul 1, 2026
@loopover-orb

loopover-orb Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - reject/close recommended

Review updated: 2026-07-02 05:07:39 UTC

2 files · 1 AI reviewer · 1 blocker · readiness 73/100 · CI green · unknown

🛑 Suggested Action - Reject/Close

  • AI reviewers agree on a likely critical defect: review-enrichment/src/analyzers/secret-scan.ts:54 still skips every patch body line starting with `+++`, and `scanSecrets` calls `scanPatch` directly, so an added line whose content starts with `++` is still invisible to the secret analyzer despite this PR claiming to fix that path. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.

Review summary
The shared analysis-context parser now correctly treats `+++x` inside a hunk as an added line and keeps line numbering aligned for the shared added-line surface. That part is correct, but the PR does not fix the analyzer path described in the PR: the secret analyzer still reparses raw patches with the old unanchored header guard, so the security-relevant failure remains reachable.

Blockers

  • review-enrichment/src/analyzers/secret-scan.ts:54 still skips every patch body line starting with `+++`, and `scanSecrets` calls `scanPatch` directly, so an added line whose content starts with `++` is still invisible to the secret analyzer despite this PR claiming to fix that path.
Nits — 3 non-blocking
  • review-enrichment/test/analysis-context.test.ts:19 only covers the shared context helpers, so it would not catch the still-broken analyzer entrypoint; add a registry or secret-scan test that drives `buildBrief` or `scanSecrets` with `@​@​ -1,0 +1,1 @​@​\n+++const token = ...`.
  • Either update `scanPatch` to use the same in-hunk parsing rule as `collectAddedLines`, or route the analyzer through `scanAddedLinesForSecrets(context.addedLines)` if the cap semantics are acceptable; then add a production-path test for the analyzer.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Why this is blocked

  • review-enrichment/src/analyzers/secret-scan.ts:54 still skips every patch body line starting with `+++`, and `scanSecrets` calls `scanPatch` directly, so an added line whose content starts with `++` is still invisible to the secret analyzer despite this PR claiming to fix that path.
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ✅ No-issue rationale PR body explains why no issue is linked.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (size label size:S; no linked issue context).
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: 211 registered-repo PR(s), 140 merged, 9 issue(s).
Contributor context ✅ Confirmed Gittensor contributor glorydavid03023; Gittensor profile; 211 PR(s), 9 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: glorydavid03023
  • 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: 211 PR(s), 9 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Triage stale or unlinked PRs.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 1, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Failing review, please see gittensory orb review comments for blockers.

@JSONbored JSONbored closed this Jul 2, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants