Software-Driven PLC Refactoring Agent using Mastra AI and Patronus AI
Transitioning proprietary legacy Ladder Logic to IEC 61131-3 Structured Text is slow and prone to syntax bugs. Build an automated code refactoring agent using Mastra AI and Patronus AI guardrails that transforms legacy PLC ladder diagrams into verified Structured Text. Pass 100% of static automated code policy safety assertions without breaking sequence logic.
What you are building
Construct a Mastra AI workflow with Patronus AI automated guardrail evaluations to translate and validate industrial ladder logic into structured control code.
How work is evaluated
Evaluates generated Structured Text code against syntax correctness and Patronus safety policies.
Datasets
Public datasets, plus the private datasets you have access to.
How submissions are scored
patronus_guardrail_pass
Ensure zero safety policy violations detected by Patronus
This dimension contributes its full weight only when the submission satisfies the requirement. Partial credit is not awarded.
syntax_compilation_rate
Percentage of generated code blocks compiling without errors • target: 1 • range: 0-1
This dimension contributes its full weight only when the submission satisfies the requirement. Partial credit is not awarded.
Learning goals
Build Mastra AI TypeScript workflows for parsing Structured Text from Ladder AST representations
Embed Patronus AI security and safety assertions into code generation evaluation loops
Ensure zero safety lock-out violations in generated PLC automation blocks
Resources
Dataset of 40 standard Ladder Logic control rung configurations and corresponding verified IEC 61131-3 reference snippets.
Challenge setup
Evaluates generated Structured Text code against syntax correctness and Patronus safety policies.
Challenge input
JSON representing ladder logic rungs and contacts
Mastra AI
Offers type-safe agent step composition and workflow execution in TypeScript.
Patronus AI
Provides strict domain assertion checks on LLM code generation outputs.
Evaluated output
String containing valid IEC 61131-3 Structured Text code
- Ensure zero safety policy violations detected by Patronus
- Percentage of generated code blocks compiling without errors • target: 1 • range: 0-1
- Benchmark: PLC Industrial Code Modernization (PLC-MOD-2025)
- Syntax Compilation Rate target: 100%
- 1 public reference case
- JavaScript execution harness
- javascript sandbox (unavailable on Versalist)
Shows the first task, up to three tools, and up to three evidence items.
View technical recipe
Configured tools
- Mastra AI · Required
- Patronus AI · Optional
- Patronus AI · Optional
- Mastra AI · Required
Evaluation contract
- patronus_guardrail_pass · Weight 1
- syntax_compilation_rate · Weight 1
Metrics
- syntax_compilation_rate · Target 1
Benchmarks
- PLC Industrial Code Modernization (PLC-MOD-2025)
- general
Reference cases
- 1 public reference case
Workflow tasks
- Task 1
Input: JSON representing ladder logic rungs and contacts
Output: String containing valid IEC 61131-3 Structured Text code
Execution harness: JavaScript
Evaluation tools
- Mastra AI · Agent & Workflow Engine
- Patronus AI · AI Guardrails Platform
Recipe freeze marker
No recipe freeze time is recorded.