fix(pipeline): plumb xml2st keep_structs through the shared port contract - #797
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds a readonly ChangesXML-to-ST transpilation xml2stArgs propagation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Actionable comments posted: 0 |
…contract
User-reported bug on openplc-web staging: declaring a STRUCT data type
broke the build with `Undefined type 'MY_QUEUE'` out of strucpp. The
same project compiled fine on the desktop editor.
Root cause: xml2st flag drift. Editor's `handleTranspileXMLtoST`
hardcoded `--keep-structs`; the web's compile-service `/generate-st`
endpoint hardcoded the unflagged invocation, so structs got rewritten
to FUNCTION_BLOCKs and strucpp rejected them.
Fix: the shared port contract carries an array of raw xml2st CLI
tokens (`TranspileXmlToStArgs.xml2stArgs: readonly string[]`) — not a
typed boolean per flag — so future xml2st options are a one-line
append in `runCompilePipeline` with no per-platform changes needed.
The shared pipeline sets `['--keep-structs']` for strucpp targets.
- Editor adapter passes the array through verbatim to the local
xml2st binary (trusted) via `handleTranspileXMLtoST`'s new third
positional arg.
- Web adapter (companion PR on openplc-web) filters the array
against its `KNOWN_XML2ST_FLAGS` allowlist, dropping + warning
on anything unknown before sending to the service.
- compiler-service (separate PR on its feat/strucpp-support branch)
accepts `xml2st_args: list[str]` and validates against an
identical server-side allowlist (defence in depth).
Internal editor callers (`compileForDebug`, `compileLibrary`) now
pass `['--keep-structs']` explicitly — same effective behaviour as
the old hardcode.
Regression guards:
- `pipeline.test.ts`: asserts `port.transpileXmlToSt` receives
`xml2stArgs: ['--keep-structs']`. Future refactors that drop
the flag from the pipeline break here.
- `editor-compiler-platform-port.test.ts`: two new cases verify
the editor adapter forwards both a populated array and an empty
array verbatim to `handleTranspileXMLtoST` (no silent defaults).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4a6b6ab to
c955139
Compare
|
Actionable comments posted: 0 |
Summary
User-reported bug on openplc-web staging: declaring a STRUCT data type breaks the build with
Undefined type 'MY_QUEUE'out of strucpp. Same project compiles fine on the desktop editor.Root cause: xml2st flag drift between platforms. Editor's
handleTranspileXMLtoSThardcoded--keep-structs; web's compile-service/generate-stendpoint hardcoded the unflagged invocation. Structs got rewritten to FUNCTION_BLOCKs (matiec's legacy workaround) and strucpp rejected them as type-vs-instance mismatches.Architecture
The shared port contract carries an array of raw xml2st CLI tokens, not typed booleans per flag. Future xml2st options are a one-line append in
runCompilePipelinewith no per-platform code changes.xml2stArgs: ['--keep-structs']for strucpp targets at the single call site inpipeline.ts.KNOWN_XML2ST_FLAGSallowlist, drops + warns on anything unknown.feat/strucpp-support): acceptsxml2st_args: list[str]validated against a server-side allowlist (defence in depth).Changes
src/middleware/shared/ports/compiler-platform-port.ts—TranspileXmlToStArgs.xml2stArgs: readonly string[]src/backend/shared/compile/pipeline.ts— single call site sets['--keep-structs']src/backend/editor/compiler/compiler-module.ts—handleTranspileXMLtoSTtakes a third positionalextraXml2stArgs: readonly string[], spreads into spawn argv. Internal callers (compileForDebug,compileLibrary) pass['--keep-structs']src/backend/editor/compiler/editor-compiler-platform-port.ts— adapter forwardsargs.xml2stArgsinto the handlerRegression guards
pipeline.test.ts: asserts the pipeline passesxml2stArgs: ['--keep-structs'].editor-compiler-platform-port.test.ts: two new tests verify the adapter forwards a populated array and an empty array verbatim (no silent defaults).Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests