Skip to content

fix(code-mode): harden evaluator boundaries - #2468

Merged
Astro-Han merged 6 commits into
apache:mainfrom
Astro-Han:fix/code-mode-harden-evaluator
Aug 8, 2026
Merged

Astro-Han merged 6 commits into
apache:mainfrom
Astro-Han:fix/code-mode-harden-evaluator

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • validate the TypeScript source wrapper before transpilation and retain the post-transpile Acorn check, closing escapes that TypeScript would otherwise erase
  • materialize tool results and final output through one bounded traversal that carries the remaining structural budget across nested values and rejects impossible containers before host inspection
  • preserve sparse-array, mutation, and standard property-access semantics while replacing oversized or non-discriminating tests with small boundary cases

Refs #2466

Verification

  • npm run test --workspace @maka/code-mode (95 tests passed)
  • npm run typecheck --workspace @maka/code-mode
  • npx biome check packages/code-mode/src/interpreter.ts packages/code-mode/src/__tests__/code-mode.test.ts

Review focus

materializePlainData owns traversal state in one closure. Its requiredAfter parameter reserves the minimum bytes required by remaining array items and every open ancestor before a value is read or recursively expanded; every composite value also proves that its minimum representation fits before container inspection.

@Astro-Han
Astro-Han marked this pull request as ready for review August 8, 2026 02:50
@Astro-Han
Astro-Han merged commit 1058a44 into apache:main Aug 8, 2026
11 checks passed
@Astro-Han
Astro-Han deleted the fix/code-mode-harden-evaluator branch August 8, 2026 02:51
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