Skip to content

Commit e52c863

Browse files
sahrizviclaude
andcommitted
fix(review): [R20 S4] address kilo-code-bot review — blockScalarStart regex tightened
kilo-code-bot suggestion on PR #1028 — the earlier `blockScalarStart` regex accepted only `|`/`>` with an optional `+`/`-` chomping indicator, so YAML block-scalar headers carrying an explicit indentation indicator (`description: |2`, `|+2`, `|2-`) or a trailing comment (`description: | # legacy`) failed to open a scalar. Body lines beginning with a risk keyword (`data_tests:`, `constraints:`, …) then false-positive promoted the file to `full`. Safe-direction over-tiering (never a wrong verdict), but this regex is the sole scalar gate — widen it to close the gap. Regex now: `[|>](?:[+-]?[1-9]?|[1-9]?[+-]?)[ \\t]*(?:#.*)?$`. - `[|>]` opener - `(?:[+-]?[1-9]?|[1-9]?[+-]?)` chomp+indent in either order - optional trailing `# comment` New regression test loops over `|2`, `|+2`, and `| # legacy comment` opener shapes and asserts each produces `trivial` on a diff whose body lines contain risk keywords. Full altimate review suite: 3808 pass / 640 skip / 0 fail (was 3807 baseline — 1 new test). Co-Authored-By: Claude Opus 4.7 <[email protected]> Claude-Session: https://claude.ai/code/session_017zXDXMiNFh4qDPxPCfa2of
1 parent 4544cf8 commit e52c863

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎packages/opencode/src/altimate/review/risk-tier.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ function changedLinesForScan(diff: string | undefined): string {
138138
const lines = diff.split("\n")
139139
const out: string[] = []
140140
let scalarIndent = -1
141-
const blockScalarStart = /^[ \t]*[^\s#:][^:]*:[ \t]*[|>][+-]?[ \t]*$/
141+
// YAML block-scalar header. The optional trailing tail covers:
142+
// - explicit indentation indicator (1-9) either before or after the
143+
// chomping indicator: `|2`, `|+2`, `|2+`, `>2-`
144+
// - trailing comment: `description: | # legacy`
145+
// kilo-code-bot suggestion — the earlier form matched only `|`/`>`
146+
// with an optional `+`/`-` chomp, so `|2` and `| # comment` skipped the
147+
// opener → body lines beginning with a risk keyword false-positive
148+
// promoted (safe-direction over-tiering, but still wrong).
149+
const blockScalarStart = /^[ \t]*[^\s#:][^:]*:[ \t]*[|>](?:[+-]?[1-9]?|[1-9]?[+-]?)[ \t]*(?:#.*)?$/
142150
for (const raw of lines) {
143151
// Skip hunk headers entirely — they aren't code and would confuse the
144152
// block-scalar tracker.

‎packages/opencode/test/altimate/review.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,25 @@ describe("risk-tier", () => {
590590
expect(r.tier).toBe("trivial")
591591
})
592592

593+
test("R20 S4: block-scalar header with explicit indentation indicator or trailing comment (kilo-bot review)", () => {
594+
// kilo-code-bot suggestion — `blockScalarStart` earlier accepted only
595+
// `|`/`>` with an optional `+`/`-` chomp, so `description: |2`,
596+
// `description: |+2`, and `description: | # legacy` were skipped and
597+
// their body lines could false-positive promote. All three shapes
598+
// must now open a scalar so the body is masked.
599+
for (const opener of ["description: |2", "description: |+2", "description: | # legacy comment"]) {
600+
const diff =
601+
"@@ -1,3 +1,7 @@\n" +
602+
" models:\n" +
603+
" - name: mrt_x\n" +
604+
`+ ${opener}\n` +
605+
"+ data_tests: are declared in the sibling schema.yml\n" +
606+
"+ constraints: are managed via the contract there.\n"
607+
const r = classifyPR([file("models/intermediate/int_x.yml", diff)])
608+
expect(r.tier).toBe("trivial")
609+
}
610+
})
611+
593612
test("R20 S4: block-scalar OPENED IN CONTEXT (not changed) still suppresses body (codex round-6 HIGH)", () => {
594613
// Codex R20 round-6 HIGH — an earlier version stripped only the
595614
// filtered +/- slice, so a pre-existing `description: |` in the

0 commit comments

Comments
 (0)