fix(content-lane): parse zero-indent YAML block sequences in frontmatter - #9891
Conversation
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-29 19:21:12 UTC
Review summary Nits — 2 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
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.
|
parseSimpleFrontmatter's sequence branch only consumed lines beginning with whitespace, so a ZERO-INDENT block sequence — valid YAML that js-yaml/gray-matter (the site build's own parser) accept — author: - Alice was dropped, leaving the field an empty string. A contributor could therefore hide a protected-field edit (the value parses identically before/after) or evade the duplicate/source-evidence gates, the exact bypass the parser's own contract says it exists to prevent. Extend the consume loop to also accept a zero-indent line starting with `-`, stopping at a blank line or the next top-level key. Applied identically to the byte-equivalent copy in source-evidence.ts and to findDuplicateFrontmatterKeys's mirroring skip loop, so a zero-indent sequence value is never mistaken for a duplicate top-level key. Indented sequences, block scalars, flow sequences, and inline scalars are unchanged. Closes JSONbored#9664
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9891 +/- ##
==========================================
+ Coverage 79.28% 79.42% +0.14%
==========================================
Files 281 283 +2
Lines 58516 58922 +406
Branches 6777 6933 +156
==========================================
+ Hits 46393 46799 +406
Misses 11840 11840
Partials 283 283
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Summary
parseSimpleFrontmatter(src/review/content-lane/duplicates.ts) states it captures each top-level field's value regardless of scalar style — a parser that silently drops a value "would let a contributor hide a protected-field edit and bypass the protected-edit + duplicate gates". Its sequence branch broke that contract: it only consumed lines beginning with whitespace, so a zero-indent block sequence — valid YAML that js-yaml/gray-matter (the site build's own parser) accept —was dropped, leaving
author/downloadUrlempty strings. A protected-field edit written this way parses identically before and after (both""), soprotectedFrontmatterChangessees no change, and the duplicate/source-evidence gates never see the value.Fix
Extend the sequence-consume loop to also accept a zero-indent line starting with
-, stopping at a blank line or the next top-levelkey:(a line matching/^([A-Za-z][A-Za-z0-9_]*):/terminates the sequence even at zero indent, so it is never swallowed). Applied identically to:src/review/content-lane/source-evidence.ts, andfindDuplicateFrontmatterKeys's mirroring skip loop, so a zero-indent- itemis never mistaken for a duplicate top-level key.Indented sequences, block scalars (
|/>), flow sequences, and inline scalars are unchanged; already-lowercase/indented inputs are byte-identical. No YAML library added (the module exists to avoid one).Tests
parseSimpleFrontmatterreturns{author: "Alice", downloadUrl: "https://good.example/x.zip"}for the zero-indent example (content-lane-duplicates.test.ts), and the same value is captured viaextractSubmittedSourceUrlsfor thesource-evidence.tscopy (content-lane-source-evidence.test.ts).protectedFrontmatterChangesreturns["author"]when before/after differ only in a zero-indentauthor:sequence value.findDuplicateFrontmatterKeysreturns[]for two different keys each carrying a zero-indent sequence.Both suites pass (183 total); the parser/protected/source-evidence cases fail against the current indent-only loop.
Closes #9664