fix(compiler): key the compile cache by headers and keep the HEX out of the REST response - #162
Merged
Merged
Conversation
…of the REST response The direct compiler hashed code without headers, so a header-only change could return a stale cached success. It now uses the worker's sketch identity. The REST response and the result cache no longer carry the unused binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
R6 of the refactoring series (
docs/UNOSIM_REFACTORING_OPL.md), audit findings A4, A5 and the.incbinchannel S1-INCBIN found during R1.Findings re-verified
ArduinoCompilerhashedcode + fqbn + entryFilewithout headers, while the compile worker includes headers. In local mode and on the pool fallback, a header-only edit hit the on-disk cache and returned the previous success./api/compilereturnedbinary. The client never reads it.Uint8Arrayserialised as an object afterpostMessage); without the binary it is 562 bytes..incbinin inline assembler could embed a server file into a client-visible payload. That channel closes here.Change
ArduinoCompileruses the worker'sbuildSketchHash(code, headers, entry file, FQBN). Both paths now share cache entries.librariesstay out of the hash: they are not passed toarduino-cli./api/compilestripsbinarybefore responding and before writing the result cache.ArduinoCompileritself still returns the binary (toolchain canaries unchanged). The simulation path never used the REST binary.Tests
arduino-compiler-cache-key.test.ts(header-only change compiles again; a direct compile hits an entry written under the worker identity),compiler-binary-payload.test.ts(fresh response, cached response and LRU entry carry nobinary).npm run check,check:docs, ESLint, unit 2707 passed, integration-toolchain 14/15 (1 skipped as before), pre-push incl. Sonar quality gate PASSED.🤖 Generated with Claude Code