Skip to content

fix(review): widen fix-handoff code-span delimiter for backtick paths (#9289) - #9339

Closed
michiot05 wants to merge 1 commit into
JSONbored:mainfrom
michiot05:fix/fix-handoff-backtick-codespan
Closed

fix(review): widen fix-handoff code-span delimiter for backtick paths (#9289)#9339
michiot05 wants to merge 1 commit into
JSONbored:mainfrom
michiot05:fix/fix-handoff-backtick-codespan

Conversation

@michiot05

@michiot05 michiot05 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • markdownPathCodeText in src/review/fix-handoff-render.ts tried to make a finding path safe for an inline code span by backslash-escaping backticks (.replace(/`/g, "\\`")). CommonMark/GFM code spans are delimited by a run of backticks and do not honor a backslash before a backtick, so a finding.path containing a literal backtick still broke out of the `…` span and corrupted the rendered fix-handoff block.
  • Fixed by mirroring the existing, correct precedent markdownPathCode in src/review/unified-comment-bridge.ts: compute the longest backtick run in the value and wrap it in a delimiter one backtick longer (with the surrounding spaces a code span strips), instead of backslash-escaping. The |, <, > entity/pipe escaping is preserved exactly; only the backtick strategy changed.
  • Both call sites (buildFixHandoffBlock, fixHandoffAggregateItem) now consume the function's own delimiter-wrapped output directly instead of re-wrapping it in a hardcoded single backtick — the same way unified-comment-bridge.ts's callers consume markdownPathCode. src/review/unified-comment-bridge.ts is the precedent and was not modified.

Closes #9289

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 a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run typecheck — the changed file is type-clean; see the skipped-checks note about pre-existing stale-dist diagnostics in unrelated files.
  • npm run test:coverage (scoped) — src/review/fix-handoff-render.ts at 100% statements / branches / functions / lines on the diff; all touched suites pass (fix-handoff-render, fix-handoff-collapsible, unified-comment-bridge, unified-comment, local-write-tools, queue-4 — 367 tests green).
  • npm audit --audit-level=moderate — no new advisories introduced (see note).
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — added a backtick-path regression test for both the per-finding and aggregate renderers, plus an explicit </>/| escaping-preservation test.

If any required check was skipped, explain why:

  • This is an isolated src/review markdown-rendering change with no workers, MCP, UI, OpenAPI, GitHub Actions, or dependency changes, so test:workers, build:mcp, test:mcp-pack, ui:openapi:check, ui:lint, ui:typecheck, ui:build, and actionlint are not applicable.
  • Repo-wide npm run typecheck reports pre-existing errors only in unrelated files (packages/loopover-*, scripts/, attested-run files) from a stale local @loopover/engine dist — the referenced exports (assertScenarioLocalBranchInputSafe, discoverAmsPolicySpecPath, calibration/attester) exist in engine source + index.ts, so a fresh CI build resolves them. The changed file imports only LOCAL_WRITE_BOUNDARY and the InlineFinding type and has no diagnostics.
  • npm audit reports only pre-existing high-severity sharp/libvips advisories; this PR changes no dependencies and introduces none.

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 such changes).
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A (pure rendering, no API/OpenAPI/MCP surface change).
  • 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 — N/A: this is backend markdown-string rendering, not a visible UI/frontend/docs change, so no screenshots apply.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. — N/A (no docs/changelog change).

Notes

  • The rendered location now reads path :line (path in its own delimiter-wrapped span, :line outside), matching how markdownPathCode's callers compose their cells. Two sibling test assertions that pinned the old single-backtick `path:line` shape (fix-handoff-collapsible.test.ts, queue-4.test.ts) were updated to the corrected output; the previous adversarial-path assertion encoded the old broken \`-escaped form and now asserts the widened delimiter.

@michiot05
michiot05 requested a review from JSONbored as a code owner July 27, 2026 13:22
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
3967 2 3965 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.00825s 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.0118s 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 13:31:54 UTC

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

🛑 Suggested Action - Fix Blockers

Review summary
This fixes a real CommonMark/GFM bug: `markdownPathCodeText` in fix-handoff-render.ts previously backslash-escaped literal backticks in a finding path before wrapping it in a single-backtick span, but code spans do not honor backslash escapes, so a path containing a backtick could break out of the span and corrupt the rendered fix-handoff block. The fix correctly mirrors the precedent `markdownPathCode` in unified-comment-bridge.ts: it computes the longest backtick run in the value and wraps it in a delimiter one backtick longer, with the padding-space trick that lets a value starting/ending in a backtick still render as one span, and drops the now-unneeded backslash escaping (irrelevant inside a code span). Both call sites were updated to consume the function's own delimiter-wrapped output directly instead of re-wrapping in a hardcoded single backtick, avoiding double-wrapping, and the new/updated tests correctly assert the widened-delimiter output for backtick-containing paths while confirming `<`, `>`, `|` escaping is unchanged.

Nits — 3 non-blocking
  • The doc comment at src/review/fix-handoff-render.ts:41-46 is fairly long for a private helper; could be trimmed since the precedent function in unified-comment-bridge.ts already documents the technique.
  • Math.max(0, ...Array.from(...)) at src/review/fix-handoff-render.ts:48 works but a simple reduce would avoid spreading a potentially large match array onto the call stack for pathological inputs — not a real risk given path lengths.
  • Consider adding one more test where the path is only backticks (e.g. "```") to make the +1-longer-delimiter edge case fully explicit, though the existing single/double backtick cases already exercise the core logic.

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: 34 registered-repo PR(s), 20 merged, 5 issue(s).
Contributor context ✅ Confirmed Gittensor contributor michiot05; Gittensor profile; 34 PR(s), 5 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The diff rewrites markdownPathCodeText to compute a delimiter one longer than the longest backtick run in the value (mirroring markdownPathCode) instead of backslash-escaping, updates both call sites to consume the function's own delimiter-wrapped output, and adds new tests in fix-handoff-render.test.ts covering a backtick-containing path rendering as an unbroken wider-delimiter span plus preserve

Review context
  • Author: michiot05
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust
  • Official Gittensor activity: 34 PR(s), 5 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