Skip to content

[port #1057] internal/literals: preserve decoded byte-slice capacity - #8

Open
luantak wants to merge 2 commits into
masterfrom
cursor/maremagnum-pr-1057-literals-slice-capacity-2676
Open

[port #1057] internal/literals: preserve decoded byte-slice capacity#8
luantak wants to merge 2 commits into
masterfrom
cursor/maremagnum-pr-1057-literals-slice-capacity-2676

Conversation

@luantak

@luantak luantak commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Validity: valid

Observable correctness: decoded []byte values had wrong cap vs source literals (nil start for seed; +1 for shuffle/split). Allocating with len=0, cap=literalLen restores semantics without changing secrecy.

Upstream

burrowers#1057

Commit layout

Commit 1 is Maremagnum's from burrowers#1057 (author preserved as on the upstream commit: autoprofiler <autoprofiler@local.invalid>); following commit(s) address luantak/mvdan review feedback and are authored by the Cursor/luantak port side.

  • 4486942 autoprofiler | internal/literals: preserve decoded byte-slice capacity
  • 547dd1c Cursor Agent | Address review feedback: refactor capacity regression test style

What this ports

  • Decoder result slices allocated with capacity exactly equal to literal length
  • Includes generation_regression_test.go (capacity-focused regression)

Feedback applied (luantak requested changes)

  1. Define the obfuscator table as a variable before the loop (not inline in for range).
  2. Extract the indented t.Run body into top-level checkByteSliceDecoderCapacity.

Note: unlike burrowers#1054 (where mvdan asked to drop unit tests), luantak asked to refactor this unit test — kept and refactored.

Testing

  • go test -short ./internal/literals/

Remaining risks

  • Low. Pure capacity semantics; decode bytes unchanged.

Notes for Paul

Pairs well with burrowers#1055/burrowers#1056.

Open in Web Open in Cursor 

autoprofiler and others added 2 commits August 11, 2026 21:03
luantak: define the obfuscator table as a variable before the loop, and
extract the indented t.Run body into a top-level helper.

Co-authored-by: Paul <luantak@pm.me>
@cursor
cursor Bot force-pushed the cursor/maremagnum-pr-1057-literals-slice-capacity-2676 branch from bbd424e to 547dd1c Compare August 11, 2026 21:05
@luantak
luantak marked this pull request as ready for review August 11, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants