Skip to content

fix: include C++ sources in program MD5 - #1011

Draft
manux81 wants to merge 1 commit into
Autonomy-Logic:developmentfrom
manux81:fix/include-cpp-in-program-md5
Draft

fix: include C++ sources in program MD5#1011
manux81 wants to merge 1 commit into
Autonomy-Logic:developmentfrom
manux81:fix/include-cpp-in-program-md5

Conversation

@manux81

@manux81 manux81 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Include the generated c_blocks.h and c_blocks_code.cpp sources in the program MD5 whenever the project contains C/C++ POUs.
  • Use length-prefixed sections so the composite hash input is deterministic and unambiguous.
  • Preserve the existing MD5(program.st) behavior for projects without C/C++ POUs.
  • Reuse the same generated C-block artifacts for hashing and firmware/runtime bundle composition.
  • Update the relevant API comments to describe the expanded hash scope.

Why this is necessary

C/C++ POU bodies are extracted into the originalCppPous sidecar before Structured Text transpilation. The transpiler replaces each C/C++ body with an ST bridge, while the actual user-authored code is generated separately as c_blocks_code.cpp.

The pipeline previously calculated the MD5 from program.st only. As a result, changing only the C/C++ implementation while leaving the POU interface unchanged produced the same program.st and therefore the same MD5. The compiled program could change without the runtime/debugger digest reflecting that change, defeating stale-program detection.

Hashing the actual generated C/C++ sidecars together with program.st ensures every compiled user-program source contributes to the digest.

Impact

  • C/C++ implementation changes now produce a new PROGRAM_MD5.
  • Runtime v4, simulator, and Arduino compilation paths use the same corrected digest.
  • Projects containing no C/C++ POUs retain their previous digest and do not incur unnecessary cache invalidation.

Validation

  • Added a regression test that compiles two projects with identical ST output and different C/C++ bodies, then verifies that their MD5 values differ.
  • Added coverage confirming ST-only projects still hash the raw program.st content.
  • npm test -- --runInBand --coverage=false src/backend/shared/compile/__tests__/pipeline.test.ts — 54 tests passed.
  • ESLint passed for all changed TypeScript files.
  • Prettier check passed for all changed files.
  • git diff --check passed.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1da15dc-d1af-4eec-b0c4-bce27caaf9bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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