crbench//

← all cases

Reusing a scratch buffer for end keys corrupts every recorded span via the retaining writer

Tier 1 easy go · cross-file · authored, execution-grounded case

Ground-truth defects

d1 · correctness · high · builder.go:8
BuildFromKeys() is changed to reuse one scratch buffer for every end key — a normal-looking allocation optimization in isolation. But the unchanged writer.go Record() stores the slices as-is (no copy), so every entry's End aliases that single reused buffer and, after the loop, reads back as the LAST key — silently corrupting all the earlier spans. The diff looks fine on its own; the bug is only knowable by reading the unchanged Record() in writer.go to see it retains the slice. No panic.

The change under review

diff
diff --git a/builder.go b/builder.go
index 6b0d28e..c55cbfc 100644
--- a/builder.go
+++ b/builder.go
@@ -3,8 +3,10 @@ package manifest
 // BuildFromKeys records one entry per adjacent key pair.
 func BuildFromKeys(keys [][]byte) []Entry {
 	w := &Writer{}
+	scratch := make([]byte, 0, 16)
 	for i := 0; i+1 < len(keys); i++ {
-		w.Record(keys[i], keys[i+1])
+		scratch = append(scratch[:0], keys[i+1]...)
+		w.Record(keys[i], scratch)
 	}
 	return w.Entries()
 }

Leaderboard for this case

easy · 9 of 9 bots fully caught it (100% solve rate) · 100% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 1/1 100.0% 1 0
2 Cubic solved 1/1 100.0% 1 0
3 cursor solved 1/1 100.0% 1 0
4 Drape (Deep Review) solved 1/1 100.0% 1 0
5 Drape (Review) solved 1/1 100.0% 1 0
6 greptile solved 1/1 100.0% 1 0
7 Mjolnir (Opus 5.5) solved 1/1 100.0% 2 0
8 Mjolnir (Sonnet 5.5) solved 1/1 100.0% 2 0
9 qodo solved 1/1 100.0% 1 0

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
builder.go:9
The same `scratch` buffer is passed as `end` on every loop iteration, and `Writer.Record` keeps the slice as-is without copying it. That means every entry's `End` points at the same backing array, so each later `append(scratch[:0], ...)` overwrites the `End` of entries already recorded. While keys fit in the existing capacity (16 bytes at first), all entries end up with the last key's value as `End`. When a key is longer and `append` reallocates, entries share whichever buffer was current when they were written, so the values come out partly wrong instead. Either way the manifest's key ranges are corrupted. Before this change, `keys[i+1]` was passed directly, so each `End` was distinct. Fix: allocate a fresh copy per entry (e.g. `append([]byte(nil), keys[i+1]...)`), or have `Record` copy its inputs.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (2)
builder.go:8
<!-- cubic:v=925ee2ce-4f59-49ec-8973-7cbc4e727c44 --> <!-- cubic:review-run=f6de5bc4-d482-5254-b148-ed366665a0ea --> <!-- metadata:{"confidence":10} --> P1: When there are multiple adjacent pairs, reusing `scratch` overwrites earlier `Entry.End` values because `Writer.Record` stores slices as-is. Pass each key directly or allocate a distinct copy for every recorded entry. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At builder.go, line 8: <comment>When there are multiple adjacent pairs, reusing `scratch` overwrites earlier `Entry.End` values because `Writer.Record` stores slices as-is. Pass each key directly or allocate a distinct copy for every recorded entry.</comment> <file context> @@ -3,8 +3,10 @@ package manifest + scratch := make([]byte, 0, 16) for i := 0; i+1 < len(keys); i++ { - w.Record(keys[i], keys[i+1]) + scratch = append(scratch[:0], keys[i+1]...) + w.Record(keys[i], scratch) } </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **1 issue found** across 1 file <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="builder.go"> <violation number="1" location="builder.go:8"> P1: When there are multiple adjacent pairs, reusing `scratch` overwrites earlier `Entry.End` values because `Writer.Record` stores slices as-is. Pass each key directly or allocate a distinct copy for every recorded entry.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/2/ai_pr_review_github_delivery_242e66e0fd824af976e93c60384d99b16b40c8a139402abc2153ead9c2bd361a?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F2)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_242e66e0fd824af976e93c60384d99b16b40c8a139402abc2153ead9c2bd361a:2b6719e155e29d44f0e47ca6dde70ed2f1f1b19d:f6de5bc4-d482-5254-b148-ed366665a0ea -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (2)
builder.go:9
### Reused scratch aliases stored entries **High Severity** <!-- DESCRIPTION START --> `scratch` is reused across loop iterations, but `Record` stores the `end` slice as-is without copying. Each later `append` overwrites the same backing array, so earlier entries' `End` values become the last key written (or a truncated mix of it) instead of the original adjacent key. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 0fe81574-7dbd-4e43-bbec-cdadfb6e8fb5 --> <!-- LOCATIONS START builder.go#L5-L9 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFjMGJhZjlmLTY5YzYtNDUwOC1hOTljLTA4NDA2ZWVjNzRmMCIsImVuY3J5cHRpb25LZXkiOiJMaFIyWEhIWWxnNzRoVFdkelVlN2xwdUhCUERNMVdYVllQbjJxS1FmOXc4IiwiYnJhbmNoIjoidDEtZ28tc2xpY2UtYWxpYXMtY29ycnVwdHMtbWFuaWZlc3QiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFjMGJhZjlmLTY5YzYtNDUwOC1hOTljLTA4NDA2ZWVjNzRmMCIsImVuY3J5cHRpb25LZXkiOiJMaFIyWEhIWWxnNzRoVFdkelVlN2xwdUhCUERNMVdYVllQbjJxS1FmOXc4IiwiYnJhbmNoIjoidDEtZ28tc2xpY2UtYWxpYXMtY29ycnVwdHMtbWFuaWZlc3QiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjoyLCJjb21taXRTaGEiOiJiMWVlMGIxODI1YmUxOTdjNzIyOTVkMzJiOTI0YzNjZWQ1NmUwNDkzIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b1ee0b1825be197c72295d32b924c3ced56e0493. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpiZjBkY2FhZC00YTk3LTQ5ZTYtOGIyOC1kMTVhMmVkOTk1OWEiLCJlbmNyeXB0aW9uS2V5IjoiTFFUT1VBLUR6c09OMVlNcTNvZUdlcHRBb0ltOG9Vc3V0NDgxRzFXMUFWbyIsImJyYW5jaCI6InQxLWdvLXNsaWNlLWFsaWFzLWNvcnJ1cHRzLW1hbmlmZXN0IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b1ee0b1825be197c72295d32b924c3ced56e0493. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
builder.go:9
**Entries' End keys overwritten by later keys** `Record` stores the slice as-is, but `scratch` is reused each iteration, so earlier entries' End aliases the same buffer and shows the last key copied. Pass `keys[i+1]` directly, or copy the key for each entry. ``` builder.go:6 scratch := make([]byte, 0, 16) builder.go:7 for i := 0; i+1 < len(keys); i++ { builder.go:8 scratch = append(scratch[:0], keys[i+1]...) builder.go:9 w.Record(keys[i], scratch) writer.go:14 // Record appends an entry for the [start, end) span. The slices are stored as-is. writer.go:15 func (w *Writer) Record(start, end []byte) { writer.go:16 w.entries = append(w.entries, Entry{Start: start, End: end}) ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (1)
builder.go:7
**Reused scratch buffer corrupts stored entry ends** `Writer.Record` keeps the slices it is given without copying. `BuildFromKeys` now passes the same `scratch` buffer on every iteration, so every entry's `End` points at one shared array. Remove the scratch buffer and pass keys[i+1] directly, or copy into a fresh slice per entry. ``` builder.go:6 scratch := make([]byte, 0, 16) builder.go:7 for i := 0; i+1 < len(keys); i++ { builder.go:8 scratch = append(scratch[:0], keys[i+1]...) builder.go:9 w.Record(keys[i], scratch) writer.go:14 // Record appends an entry for the [start, end) span. The slices are stored as-is. writer.go:15 func (w *Writer) Record(start, end []byte) { writer.go:16 w.entries = append(w.entries, Entry{Start: start, End: end}) writer.go:17 } ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (2)
builder.go:10
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Shared Buffer Corrupts Endpoints** When `BuildFromKeys` processes multiple pairs, every recorded endpoint shares the reused `scratch` buffer. `Writer.Record` stores each slice as-is, so later iterations overwrite endpoints already stored in earlier entries. The returned manifest therefore no longer represents the original adjacent key pairs. ```suggestion for i := 0; i+1 < len(keys); i++ { w.Record(keys[i], keys[i+1]) } ```
PR-level
<h3>Greptile Summary</h3> This PR changes `BuildFromKeys` to copy endpoint keys into a reusable scratch buffer before recording them. - Reduces per-iteration allocation intent by reusing one byte slice. - Introduces aliasing because `Writer.Record` retains the supplied slice, causing earlier endpoints to be overwritten. <h3>Confidence Score: 4/5</h3> The PR is not safe to merge because manifests built from three or more keys can contain overwritten endpoint values. `BuildFromKeys` passes the same mutable backing array to every call to `Writer.Record`, which retains it without copying; later iterations therefore mutate endpoints already stored in earlier entries. **Files Needing Attention:** builder.go <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | builder.go | Reuses one scratch buffer for all recorded endpoints even though `Writer.Record` retains those slices, corrupting earlier entries. | </details> <details open><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart LR A[Copy first endpoint into scratch] --> B[Record entry retaining scratch] B --> C[Overwrite scratch with next endpoint] C --> D[Earlier entry observes overwritten bytes] D --> E[Returned manifest contains corrupted endpoints] ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update builder.go"](https://github.com/drape-io/crbench-greptile-2026-09/commit/1d969c01c1da3ea322da1a8624fc9edbbd3dba35) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284066)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · impact high
Writer.Record stores the slices it receives without copying them (writer.go:16 `Entry{Start: start, End: end}`). Because of that, every End shares scratch's backing array, and each later append overwrites the End values already recorded. The old code passed keys[i+1] directly and didn't have this problem. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact high
raw comments (2)
builder.go:6
[P1] Every entry's End aliases the reused scratch buffer `Writer.Record` keeps the slices it is given as-is (writer.go:14-16), so each `Entry.End` points at the same `scratch` backing array. On every later iteration, `append(scratch[:0], keys[i+1]...)` writes over that array, which changes the End of entries that were already recorded. For keys of 16 bytes or less, which never force a reallocation, every entry returned by `BuildFromKeys` ends up with End equal to the last key (truncated or garbled when key lengths differ), so the manifest's spans are wrong. When a longer key forces a reallocation, only some entries are corrupted, which makes the bug look intermittent. The old code passed `keys[i+1]` directly and did not have this problem. If the goal is to decouple End from the caller's `keys`, each End needs its own copy, for example `append([]byte(nil), keys[i+1]...)`, not a shared scratch buffer.
builder.go:6
[P1] Reused scratch buffer aliases every recorded End key `Writer.Record` keeps the slices it gets without copying them (writer.go says "The slices are stored as-is"). Every loop iteration hands it the same `scratch` backing array and then overwrites that array in place with `append(scratch[:0], ...)`. So any entries whose End keys fit in the buffer end up sharing one array, and their `End` values all change to whatever was written last. A key longer than the current capacity makes `append` allocate a new array, so the result also depends on key length. Example: keys `a`, `b`, `c` should produce entries `{a,b}` and `{b,c}`, but this code returns `{a,c}` and `{b,c}`. The manifest is wrong for any input with three or more keys. Before this change, `keys[i+1]` was passed directly and each entry had its own End slice.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ off by one
valid · matches d1 · impact high
valid · impact high
writer.go Record stores slices as-is (`Entry{Start: start, End: end}`), so every entry's End shares the scratch backing array and gets overwritten by later iterations. The old code passed keys[i+1] directly, which did not alias. A reallocation happens only when a key is longer than the current capacity, and entries recorded after it still share the new array. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
builder.go:6
[P0] Reused scratch buffer is stored by reference in every entry `Writer.Record` stores `start` and `end` as-is (see the "stored as-is" comment in writer.go). In `BuildFromKeys`, the same `scratch` buffer is passed as `end` on every iteration and then overwritten by `append(scratch[:0], ...)`. All returned `Entry.End` values therefore share one backing array. After the loop they all hold the contents of the last key, or a mix of bytes if the lengths differ. For any input with 3 or more keys, every entry except the last gets a wrong `End`. It is also not the next entry's `Start`, because `Start` still aliases `keys[i]`. The copy buys nothing, because the original `keys[i+1]` was already safe to store. Either pass `keys[i+1]` directly, or allocate a fresh copy per entry, for example `append([]byte(nil), keys[i+1]...)`.
builder.go:6
[P1] Reused scratch buffer is aliased by every recorded entry's End `Writer.Record` stores its `start` and `end` slices as-is (writer.go: "The slices are stored as-is"). The loop now passes the same `scratch` buffer on every iteration, refilled via `append(scratch[:0], ...)`. Every `Entry.End` therefore points at one shared backing array. When `BuildFromKeys` returns, all entries' `End` hold the last copied key (`keys[len-1]`), or a mix of bytes if key lengths differ. The `End` of one entry no longer matches the `Start` of the next, so the manifest is corrupted. This happens for any input with 3 or more keys (2 or more entries). Fix it by allocating a fresh copy per entry, or by not copying at all, since `keys[i+1]` is already a stable slice.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✓ exact
valid · matches d1 · impact high
raw comments (3)
builder.go:9
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Earlier manifest spans are corrupted <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>BuildFromKeys</i></b> resets and overwrites one reusable <b><i>scratch</i></b> backing array, while <b><i>Writer.Record</i></b> retains each <b><i>end</i></b> slice as-is. Whenever multiple copied keys fit the same allocation, recording a later span changes the end key of an earlier returned entry, with shorter replacements also leaving stale suffix bytes under the earlier slice length. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description `BuildFromKeys` passes a reused scratch slice to `Writer.Record`, which stores that slice without copying, causing previously recorded entry boundaries to be overwritten. ## Fix Focus Areas - builder.go[6-9] ## Recommended Fix Remove the shared scratch buffer and pass `keys[i+1]` directly as before. If entries must own copied boundary data, allocate an independent copy for every iteration rather than reusing one backing array. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>PR Summary by Qodo</h3> Copy manifest end keys before recording spans <code>🐞 Bug fix</code> <code>🕐 Less than 10 minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Copies each end key into a reusable scratch buffer before recording manifest spans. >• Reuses one backing array, allowing later iterations to overwrite previously recorded end keys. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid graph TD K["Input keys"] --> P["Adjacent pairs"] --> S["Shared scratch"] --> W["Writer.Record"] --> E["Manifest entries"] ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Allocate an end-key copy per entry</b></summary> <dl> <dd> - ➕ Guarantees each recorded end key has independent backing storage - ➕ Preserves Writer&#x27;s documented store-as-is contract - ➕ Keeps ownership handling local to BuildFromKeys - ➖ Adds one allocation and copy per manifest entry </dd> </dl> </details> <details> <summary><b>2. Make Writer own recorded boundaries</b></summary> <dl> <dd> - ➕ Centralizes slice ownership for every Writer caller - ➕ Protects both start and end keys from later mutation - ➖ Changes Writer&#x27;s documented semantics - ➖ Adds up to two allocations per entry - ➖ May impose unnecessary copying on callers with immutable buffers </dd> </dl> </details> >**Recommendation:** Do not merge the shared-scratch implementation as written: Writer retains each slice, so subsequent iterations overwrite earlier end keys sharing the same backing array. Allocate a unique end-key copy for every entry, such as `append([]byte(nil), keys[i+1]...)`; changing Writer ownership is broader and conflicts with its current contract. </dd> </dl> </details> <details> <summary> Files changed (1) <code> +3 / -1 </code> </summary> <dl> <dd> <br/> <details> <summary>Bug fix (1) <code> +3 / -1 </code></summary> <dl> <dd> <details> <summary>builder.go<code>Route end keys through a reusable scratch slice</code> <code>+3/-1</code></summary> <br/> >Route end keys through a reusable scratch slice > ><pre> >• BuildFromKeys now copies each end key into a scratch slice before calling Writer.Record. Since the same backing array is reused and Writer stores slices as-is, multiple entries may alias that array and earlier end keys can be corrupted. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/2/files#diff-5dce70063c4b1b07e611b3fcd32da0445a0b95970028c8992beb9c955e38320f'>builder.go</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (1)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Earlier manifest spans are corrupted <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>BuildFromKeys</i></b> resets and overwrites one reusable <b><i>scratch</i></b> backing array, while <b><i>Writer.Record</i></b> >retains each <b><i>end</i></b> slice as-is. Whenever multiple copied keys fit the same allocation, recording a >later span changes the end key of an earlier returned entry, with shorter replacements also leaving >stale suffix bytes under the earlier slice length. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[builder.go[R8-9]](https://github.com/drape-io/crbench-qodo-2026-09/pull/2/files#diff-5dce70063c4b1b07e611b3fcd32da0445a0b95970028c8992beb9c955e38320fR8-R9)</code> > >```diff >+ scratch = append(scratch[:0], keys[i+1]...) >+ w.Record(keys[i], scratch) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The loop repeatedly writes new key bytes into the same scratch allocation and passes that slice to ><b><i>Record</i></b>. <b><i>Record</i></b> explicitly stores both slices as-is, and <b><i>Entries</i></b> returns those retained entries >without copying, proving that prior <b><i>End</i></b> fields continue to alias storage overwritten by subsequent >iterations. ></pre> > > <code>[builder.go[6-11]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fa1281d911a26c2e27765e9ba670b2bdc00958f2/builder.go/#L6-L11)</code> > <code>[writer.go[14-17]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fa1281d911a26c2e27765e9ba670b2bdc00958f2/writer.go/#L14-L17)</code> > <code>[writer.go[19-22]](https://github.com/drape-io/crbench-qodo-2026-09/blob/fa1281d911a26c2e27765e9ba670b2bdc00958f2/writer.go/#L19-L22)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >`BuildFromKeys` passes a reused scratch slice to `Writer.Record`, which stores that slice without copying, causing previously recorded entry boundaries to be overwritten. > >## Fix Focus Areas >- builder.go[6-9] > >## Recommended Fix >Remove the shared scratch buffer and pass `keys[i+1]` directly as before. If entries must own copied boundary data, allocate an independent copy for every iteration rather than reusing one backing array. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>⚖️ Balanced</code>: This changes runtime slice ownership and manifest construction semantics, creating a subtle aliasing risk that warrants a careful review.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/fa1281d911a26c2e27765e9ba670b2bdc00958f2 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>