Skip to content

fix(compiler): address build-time iteration review feedback (#511)#621

Merged
cssbruno merged 1 commit into
mainfrom
fix/build-iteration-review-511
Jun 22, 2026
Merged

fix(compiler): address build-time iteration review feedback (#511)#621
cssbruno merged 1 commit into
mainfrom
fix/build-iteration-review-511

Conversation

@cssbruno

Copy link
Copy Markdown
Owner

Follow-up to #613 (merged) addressing the Codex review findings on the build-time iteration work.

# Finding Fix
1 reverse/take copied list elements without charging the budget, so repeated transforms bypassed the per-block cap Charge len(result) against env.consume in both
2 The literal splitter only entered string mode for ", so a comma inside a Go raw string (`a,b`) was treated as a separator and broke parsing exprScanner now tracks backtick raw strings
3 The depth limit was only checked before parsing the outer expression; deeply nested parens/operators recursed past it buildEvalAST enforces the depth limit and descends via env.deeper()
4 List/object number values used the raw literal text, so 01 serialized as invalid JSON [01] Emit canonical JSON numbers, preserving exact wide-integer literals (9007199254740993 stays exact)
5 Go build-helper output was decoded into float64, rounding large integer IDs inside returned slices/structs Decode with json.Decoder.UseNumber; handle json.Number
6 seq(-9e18, 9e18) overflowed int at end-start before the budget check, risking a panic Bound seq operands to the safe-integer range

All six are real correctness issues; each ships with a regression test (TestBuildDataReviewRegressions, TestBuildFunctionOutputPreservesWideIntegers).

go test ./internal/buildgen/ passes; gofmt/go vet clean.

Address Codex review findings on the merged build-time iteration work:

- reverse/take now charge copied elements against the per-block budget, so
  repeated list-producing transforms cannot bypass the documented cap.
- The literal splitter tracks Go raw strings (backticks), so a comma inside a
  raw-string list/object element no longer breaks parsing.
- Recursive AST evaluation enforces the nesting-depth limit, so deeply nested
  parentheses/operators produce a diagnostic instead of risking stack overflow.
- List/object number values serialize as canonical JSON (e.g. 01 -> 1) while
  preserving exact wide-integer literals.
- Go build helper output is decoded with json.Decoder.UseNumber, so large
  integer IDs inside returned slices/structs keep full precision.
- seq bounds are constrained to the safe-integer range so end-start cannot
  overflow int before the budget/limit check.

Adds regression tests for each.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d695a4396f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

decoder.UseNumber()
var raw map[string]any
if err := json.Unmarshal(output, &raw); err != nil {
if err := decoder.Decode(&raw); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject trailing helper stdout after JSON decode

In the build-data runner path I checked, stdout is supposed to be exactly one JSON object while stderr is handled separately. Switching from json.Unmarshal to a single Decode accepts {"title":"ok"} debug or a second JSON object after the first and silently ignores the trailing bytes, so a helper that writes trailing stdout can produce a successful build with only the first object instead of surfacing corrupted helper output. After this decode, check that the decoder is at EOF (or otherwise reject non-whitespace trailing data).

Useful? React with 👍 / 👎.

@cssbruno cssbruno merged commit f637a11 into main Jun 22, 2026
16 checks passed
@cssbruno cssbruno deleted the fix/build-iteration-review-511 branch June 22, 2026 02:47
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.

1 participant