SemaPLC: A Project-Grounded, Verification-Gated Agent Harness for PLC Code Generation
In industrial practice, AI-generated programmable logic controller (PLC) code must integrate with existing projects and implement the required behavior across scan cycles. Compilation alone does not establish runtime behavior, and subsequent edits can invalidate earlier verification results. We present SemaPLC, a project-grounded, verification-gated agent harness for PLC code generation. The harness combines project context and reusable PLC skills with specification review, compilation, and live-runtime validation. Its completion gate requires recorded checks to meet acceptance criteria for the current implementation. Edits invalidate previous verdicts, and failed checks guide bounded repair. We evaluate SemaPLC on 117 independent-POU tasks and 65 project-context tasks across seven language-model backbones. SemaPLC outperforms the evaluated baselines on both metrics for every backbone. Its mean verified-pass rate and dynamic score reach 72.6% and 52.2, exceeding the strongest baseline means by 8.7% points and 20.8 points, respectively. Verification-layer and failure analyses reveal how build recovery and output observability affect end-to-end results and identify behavioral errors that remain after compilation. We apply the harness in KUKA's iiQworks product environment for PLC development and discuss engineering lessons for its industrial integration and deployment. The industrial use indicates the agent assistance substantially improves PLC development efficiency by 45%.