Skip to content

fix(review): widen fix-handoff-render's code-span delimiter for backtick paths - #9353

Closed
galuis116 wants to merge 1 commit into
JSONbored:mainfrom
galuis116:fix/fix-handoff-backtick-delimiter-9289
Closed

fix(review): widen fix-handoff-render's code-span delimiter for backtick paths#9353
galuis116 wants to merge 1 commit into
JSONbored:mainfrom
galuis116:fix/fix-handoff-backtick-delimiter-9289

Conversation

@galuis116

Copy link
Copy Markdown
Contributor

Summary

  • markdownPathCodeText in src/review/fix-handoff-render.ts tried to make a finding's path safe for an inline markdown code span by backslash-escaping a backtick. CommonMark/GFM code spans are delimited by a run of backticks, not affected by a preceding backslash — a backslash-escaped backtick still prematurely closes the span, so a finding.path containing a literal backtick corrupted the rendered fix-handoff block.
  • The fix mirrors the correct pattern already used twice in src/review/unified-comment-bridge.ts (markdownPathCode, markdownChangedFilePath): compute a code-span delimiter longer than any backtick run found inside the value, instead of trying to escape backticks. markdownPathCodeText now returns the full delimiter-wrapped span itself (matching markdownPathCode's return shape).
  • Its two callers (buildFixHandoffBlock, fixHandoffAggregateItem) previously re-wrapped the result in a hardcoded single backtick — updated to use the function's own delimiters directly, mirroring how unified-comment-bridge.ts's callers already consume markdownPathCode's return value.
  • Entity-escaping for |, <, > is preserved unchanged — only the backtick-handling strategy changed.
  • src/review/unified-comment-bridge.ts itself was not touched (already correct, the precedent to copy from).

Because the rendered format changed (the code span now has spaces around the value and, when a path has no embedded backtick, uses the same single-backtick-with-spaces style markdownPathCode uses), several pre-existing tests across test/unit/fix-handoff-render.test.ts, test/unit/fix-handoff-collapsible.test.ts, and test/unit/queue-4.test.ts asserted on the old tight `path:line` string and needed their expected strings updated to match the new, correct rendering — verified by grepping the whole test suite for every consumer of buildFixHandoffBlock/buildFixHandoffAggregateBlock's rendered output, not just the two files this issue named.

Scope

Validation

  • git diff --check
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries
  • npm run actionlint
  • A scoped tsc --noEmit (root tsconfig.json's full flag set) against every changed file — clean
  • npx vitest run test/unit/fix-handoff-render.test.ts test/unit/fix-handoff-collapsible.test.ts test/unit/queue-4.test.ts — 146/146 passing, including a new test case with a finding.path containing a literal backtick (asserting the rendered code span widens to two backticks and stays unbroken) and a new test case covering the preserved </>/| entity-escaping
  • Scoped coverage on src/review/fix-handoff-render.ts — 100% statements/branches/functions/lines

If any required check was skipped, explain why:

  • The whole-repo npm run typecheck/npm run test:coverage (unsharded) reliably OOM in this sandbox regardless of diff size — a known sandbox resource constraint documented across many prior PRs, not a signal about this change. The scoped typecheck and 100%-branch scoped coverage above stand in for it.

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

This is a backend-only markdown-rendering fix (src/review/fix-handoff-render.ts) with no rendered UI delta — before and after are the same production capture at each required viewport. apps/loopover-ui is dark-mode-only, so only the Dark row per viewport applies.

Viewport · Theme Before After
Desktop · Dark Desktop · Dark before Desktop · Dark after
Tablet · Dark Tablet · Dark before Tablet · Dark after
Mobile · Dark Mobile · Dark before Mobile · Dark after

Notes

  • Precedent: src/review/unified-comment-bridge.ts:722 (markdownPathCode) and :624 (markdownChangedFilePath).

…ick paths

markdownPathCodeText backslash-escaped an embedded backtick, which Markdown does
not honor inside code spans -- the escaped backtick still closed the span early,
corrupting the rendered fix-handoff block. Now mirrors unified-comment-bridge.ts's
markdownPathCode: choose a delimiter longer than any backtick run in the value.
Callers (buildFixHandoffBlock, fixHandoffAggregateItem) use the function's own
delimiter-wrapped output directly instead of re-wrapping it in a hardcoded backtick.
@galuis116
galuis116 requested a review from JSONbored as a code owner July 27, 2026 13:52
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
3970 2 3968 11
View the top 2 failed test(s) by shortest run time
test/unit/selfhost-pg-retention.test.ts > runRetentionPrune + processJob on the Postgres backend (#977) > processJob prune-retention deletes eligible rows and records a success audit event on Postgres
Stack Traces | 0.00628s run time
AssertionError: expected 3 to be +0 // Object.is equality

- Expected
+ Received

- 0
+ 3

 ❯ test/unit/selfhost-pg-retention.test.ts:119:44
test/unit/selfhost-pg-retention.test.ts > pruneExpiredRecords on the Postgres backend (#977) > deletes across multiple bounded batches and stops at the per-table cap, same as the SQLite path
Stack Traces | 0.0139s run time
AssertionError: expected +0 to be 4 // Object.is equality

- Expected
+ Received

- 4
+ 0

 ❯ test/unit/selfhost-pg-retention.test.ts:76:33

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-27 14:03:30 UTC

4 files · 1 AI reviewer · no blockers · CI failing · unstable

🛑 Suggested Action - Fix Blockers

Review summary
This PR correctly fixes a real CommonMark bug: `markdownPathCodeText` previously backslash-escaped an embedded backtick before the caller re-wrapped it in a single backtick span, but Markdown code spans don't honor backslash-escaping of their own delimiter, so a `finding.path` containing a literal backtick prematurely closed the span. The fix switches to a delimiter-longer-than-any-embedded-backtick-run strategy (mirroring the existing correct pattern in `unified-comment-bridge.ts`'s `markdownPathCode`), and both callers (`buildFixHandoffBlock`, `fixHandoffAggregateItem`) were updated to stop re-wrapping the already-delimited return value. The rendering-format change (spaces around the span, line number now outside the span) is correctly reflected across all four touched test files, and a new backtick-in-path test (#9289) plus an entity-escaping-preserved test were added.

Nits — 5 non-blocking
  • src/review/fix-handoff-render.ts's `Math.max(0, ...Array.from(safeValue.matchAll(/`+/g), ...))` spreads every backtick-run match into `Math.max`'s argument list — fine for realistic path lengths but a `.reduce` would avoid the spread entirely.
  • The two CI failures (`validate`, `validate-tests`) have no detail provided, and this PR's branch is 1 commit behind the default branch — worth rebasing to rule out a stale-branch cause before assuming a content defect.
  • Consider a short inline comment at the `delimiter` computation noting why it must be computed on `safeValue` (post-escape) rather than the raw `value`, even though backtick positions are unaffected by the earlier `\`/`|`/`<>` replacements — a future reader may otherwise assume ordering matters here.
  • Possible screenshot-table issue: identical images (row 1) — Advisory only — verify the screenshot-table images against the stated change before deciding.
  • Possible screenshot-table issue: identical images (row 2) — Advisory only — verify the screenshot-table images against the stated change before deciding.

CI checks failing

  • validate
  • validate-tests

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9289
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 (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 1854 registered-repo PR(s), 1211 merged, 54 issue(s).
Contributor context ✅ Confirmed Gittensor contributor galuis116; Gittensor profile; 1854 PR(s), 54 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff rewrites markdownPathCodeText to compute a delimiter longer than the longest backtick run in the value (matching markdownPathCode's approach) instead of backslash-escaping, updates both call sites to consume the function's own delimiter-wrapped output instead of re-wrapping in a hardcoded backtick, preserves |/</> escaping, and adds a new test case with an embedded backtick in the path as

Review context
  • Author: galuis116
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Python, TypeScript, Dart, HTML, MDX, Rust, C++
  • Official Gittensor activity: 1854 PR(s), 54 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

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

None yet

Development

Successfully merging this pull request may close these issues.

review: fix-handoff-render's markdownPathCodeText backslash-escapes backticks, which markdown code spans don't honor

1 participant