Skip to content

review/content-lane: duplicates.ts's block-scalar detection lags source-evidence.ts's hardened version (comment-tolerance, digit order) - #9366

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
phamngocquy:miner/issue-9290
Jul 27, 2026
Merged

Conversation

@phamngocquy

Copy link
Copy Markdown
Contributor

Summary

src/review/content-lane/duplicates.ts has two call sites (parseSimpleFrontmatter at line ~77
and findDuplicateFrontmatterKeys at line ~132) that detect a YAML block-scalar header (|, >,
|-, |2-, etc.) using:

/^[|>][+-]?\d*$/.test(inline)

The sibling parser in src/review/content-lane/source-evidence.ts was previously hardened (in
#8016) into a shared, more correct check:

const BLOCK_SCALAR_INDICATOR = /^[|>](?:[+-]?\d?|\d[+-]?)$/;
function isBlockScalarHeader(raw: string): boolean {
  return BLOCK_SCALAR_INDICATOR.test(stripYamlComment(raw));
}

This hardened version (a) accepts the indentation digit before or after the chomping indicator
(|2- as well as |-2), and (b) strips a trailing inline comment first, so | # sources below
is still recognized as a block-scalar header. duplicates.ts's regex has neither fix.

Concretely, duplicates.ts fails to recognize: |2- (digit-then-chomp order), and any
block-scalar header with a trailing comment (| # note, |- # note, |2- # trailing). When that
happens, the header line collapses to the literal string "|" and the real indented block content
that follows is silently skipped by the parser loop (indented lines don't match the key: regex).

This directly undermines duplicates.ts's own stated purpose (per its file-level doc comment: "a
regex parser that silently drops block/folded/list values would let a contributor hide a
protected-field edit and bypass the protected-edit + duplicate gates"). A protected field written
as description: | # note followed by indented content would parse to "|" both before and after
an edit, so protectedFrontmatterChanges would never detect the real content change, and two
semantically-different entries using this style would collide as "same normalized description" in
the duplicate detector.

This is the same cross-file divergence class already fixed twice between these exact two files:
#7250 and #8016 (both closed) — this issue is the same class of gap, this time in the
opposite direction (source-evidence.ts is ahead, duplicates.ts lags).

Deliverables

  • duplicates.ts's parseSimpleFrontmatter recognizes |2--style and comment-trailing
    block-scalar headers identically to source-evidence.ts.
  • duplicates.ts's findDuplicateFrontmatterKeys recognizes the same headers identically.
  • New test cases (in the existing duplicates.ts test file under test/unit/) covering: a
    |2- header, a |- # comment header, and a > # comment header, each asserting the
    indented block content that follows is correctly captured (for parseSimpleFrontmatter) or
    correctly skipped without producing a spurious duplicate/parse error (for
    findDuplicateFrontmatterKeys).

All three deliverables are required in this single PR.

Test plan

This repo enforces 99%+ Codecov patch coverage, branch-counted, on every changed line/branch in
src/**. The new test cases above must exercise both fixed call sites.

Fixes #9290

@phamngocquy
phamngocquy requested a review from JSONbored as a code owner July 27, 2026 14:28
@superagent-security

superagent-security Bot commented Jul 27, 2026

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.46%. Comparing base (ffdea0c) to head (40b0340).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9366      +/-   ##
==========================================
+ Coverage   75.38%   75.46%   +0.08%     
==========================================
  Files         275      276       +1     
  Lines       58023    58227     +204     
  Branches     6181     6263      +82     
==========================================
+ Hits        43739    43943     +204     
  Misses      14014    14014              
  Partials      270      270              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/review/content-lane/duplicates.ts 100.00% <100.00%> (ø)

…source-evidence.ts

Harden parseSimpleFrontmatter and findDuplicateFrontmatterKeys to match
source-evidence.ts (|2-, comment-trailing headers). Add unit tests.

Fixes JSONbored#9290

Co-authored-by: Cursor <cursoragent@cursor.com>
@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

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-27 15:23:24 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This ports source-evidence.ts's hardened block-scalar detection into duplicates.ts's two call sites (parseSimpleFrontmatter and findDuplicateFrontmatterKeys), replacing the narrower `/^[|>][+-]?\d*$/` regex with a shared `isBlockScalarHeader`/`stripYamlComment` pair that accepts digit-before-or-after-chomp order and strips a trailing inline comment before matching. I traced the new `BLOCK_SCALAR_INDICATOR` regex against the added test cases (`|2-`, `|- # trailing note`, `> # folded note`) and it matches correctly, and the block-gather loop still uses the raw (unstripped) `inline` for the `>` vs `|` join-style check, which is fine since the comment suffix doesn't change the leading character. The change is narrowly scoped to the stated divergence, mirrors the sibling module's already-reviewed logic (#8016), and ships matching tests for both `parseSimpleFrontmatter` and `findDuplicateFrontmatterKeys` including the false-positive-avoidance case (indented pseudo-keys inside the comment-suffixed block body).

Nits — 4 non-blocking

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 #9290
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: 13 registered-repo PR(s), 6 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor phamngocquy; Gittensor profile; 13 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff ports BLOCK_SCALAR_INDICATOR, isBlockScalarHeader, and stripYamlComment into duplicates.ts and applies isBlockScalarHeader at both call sites (parseSimpleFrontmatter and findDuplicateFrontmatterKeys), matching source-evidence.ts's logic exactly, and adds the required |2-, |- # comment, and > # comment test cases for both functions.

Review context
  • Author: phamngocquy
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Java, Python, Lua, Jupyter Notebook, C, Dockerfile, JavaScript, Shell
  • Official Gittensor activity: 13 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 83b6867 into JSONbored:main Jul 27, 2026
10 checks passed
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/content-lane: duplicates.ts's block-scalar detection lags source-evidence.ts's hardened version (comment-tolerance, digit order)

1 participant