컴백부터 K-뷰티까지 — K-컬쳐의 모든 것을 메일로 받아보세요메일로 받아보기

METAL MEDIA

공장 제어 코드를 AI가 짜면, 컴파일만 되면 끝이 아니라 실제로 돌려봐야 진짜 검증이다

arXiv:2608.185652026-08-18

SemaPLC: A Project-Grounded, Verification-Gated Agent Harness for PLC Code Generation

공장 제어 코드를 AI가 짜면, 컴파일만 되면 끝이 아니라 실제로 돌려봐야 진짜 검증이다

SemaPLC는 대형언어모델(LLM)이 산업 설비용 제어 코드(PLC용 구조화 텍스트)를 짤 때, 스스로 '됐다'고 판단하면 끝내는 게 아니라 명세 검토, 컴파일, 실제 런타임 실행이라는 세 가지 외부 검증을 모두 통과해야 완료로 인정하는 에이전트 틀이다. 독립된 코드 조각 117개 과제와, 기존 프로젝트에 통합돼 실제로 돌아가야 하는 65개 과제 두 트랙에서 일곱 개 모델을 대상으로 테스트했다. 정적 검사에서는 방법들 간 차이가 크지 않았지만, 실제 실행 결과를 비교하는 동적 검사에서는 SemaPLC가 다른 방법들을 크게 앞섰다.

METAL MEDIA 해설 도표

공장 제어 코드를 AI가 짜면, 컴파일만 되면 끝이 아니라 실제로 돌려봐야 진짜 검증이다

  1. 01PLC(산업 설비를 제어하는 프로그래머블 로직 컨트롤러)용 코드를 생성할 때, 모델이 스스로 판단해 멈추지 않고 명세 감사·컴파일·실제 런타임 실행이라는 외부 검증 3종을 모두 통과해야만 작업을 완료로 처리하는 '검증 게이트'를 도입했다.
  2. 02독립 함수 단위 코드 117개 과제(기존 벤치마크 기반)와, 실제 산업 설비 10곳에서 뽑은 기존 프로젝트에 코드를 통합해 돌려야 하는 65개 과제, 두 트랙으로 나눠 평가했다.
  3. 03독립 함수 과제에서 일곱 개 모델 전부에서 가장 높은 '엄격 검증 통과율'(평균 72.6%)을 기록했고, 이는 도구와 검증 절차를 뺀 맨몸 버전보다 평균 17.3점포인트 높은 수치다.
  4. 04프로젝트 통합 과제에서는 컴파일 성공률 평균 89.4%로 1위였고, 정적 검사(코드 텍스트만 보는 검사)에서는 근소한 차이만 있었지만, 실제로 라이브 PLC 런타임에 배포해 정답과 실행 궤적을 비교하는 동적 검사에서는 SemaPLC가 평균 52.2점으로 다른 방법들(최고 31.4점)을 크게 앞질렀다.
  5. 05다만 가장 성능 좋은 모델(GPT-5.5)에서는 우위가 좁아졌고(동적 점수 65.4 대 63.6), 동적 검사도 사전에 정해진 시나리오 안에서만 이뤄져 낯선 상황에 대한 일반화는 확인되지 않았다.
METAL MEDIA이 원문을 바탕으로 재구성한 해설 도표이며, 논문 저자의 원문 figure가 아닙니다.

무엇을 했나

  1. PLC(산업 설비를 제어하는 프로그래머블 로직 컨트롤러)용 코드를 생성할 때, 모델이 스스로 판단해 멈추지 않고 명세 감사·컴파일·실제 런타임 실행이라는 외부 검증 3종을 모두 통과해야만 작업을 완료로 처리하는 '검증 게이트'를 도입했다.
  2. 독립 함수 단위 코드 117개 과제(기존 벤치마크 기반)와, 실제 산업 설비 10곳에서 뽑은 기존 프로젝트에 코드를 통합해 돌려야 하는 65개 과제, 두 트랙으로 나눠 평가했다.
  3. 독립 함수 과제에서 일곱 개 모델 전부에서 가장 높은 '엄격 검증 통과율'(평균 72.6%)을 기록했고, 이는 도구와 검증 절차를 뺀 맨몸 버전보다 평균 17.3점포인트 높은 수치다.
  4. 프로젝트 통합 과제에서는 컴파일 성공률 평균 89.4%로 1위였고, 정적 검사(코드 텍스트만 보는 검사)에서는 근소한 차이만 있었지만, 실제로 라이브 PLC 런타임에 배포해 정답과 실행 궤적을 비교하는 동적 검사에서는 SemaPLC가 평균 52.2점으로 다른 방법들(최고 31.4점)을 크게 앞질렀다.
  5. 다만 가장 성능 좋은 모델(GPT-5.5)에서는 우위가 좁아졌고(동적 점수 65.4 대 63.6), 동적 검사도 사전에 정해진 시나리오 안에서만 이뤄져 낯선 상황에 대한 일반화는 확인되지 않았다.
Figure 1: Overview of the SemaPLC agent harness: a model-agnostic agent core, grounded in the task or project context, acts through a shared PLC MCP tool layer, and a verification gate decides completion.
Figure 1: Overview of the SemaPLC agent harness: a model-agnostic agent core, grounded in the task or project context, acts through a shared PLC MCP tool layer, and a verification gate decides completion.
Table 1: Function track: strict verified pass rate (%, denominator 117; inconclusive and empty generations count as failure). All methods are graded by the same held-out judge. bare is SemaPLC with the harness stripped from the same backbone (no skills and tools); full is the complete harness. DS = DeepSeek.
SemaPLC
ModelLLM4PLCAutoPLCAgents4PLCbarefull
MiniMax-M2.722.249.653.839.369.2
MiniMax-M315.465.055.660.769.2
Qwen3.5-Plus13.767.567.562.475.2
DS-V4-Flash41.054.754.734.267.5
DS-V4-Pro43.661.562.455.669.2
GLM-5.230.859.074.463.276.1
GPT-5.544.479.578.671.882.1
Mean30.262.463.955.372.6
Worst13.749.653.834.267.5
Table 2: Project-context track (0–100, best per column in bold): integrated-project compile rate, assertion-oracle static score, and live-runtime dynamic score, all over the full 65-task denominator. Worst/Best/Mean summarize each method over the seven models.
MiniMaxMiniMaxQwen3.5DeepSeekDeepSeek
MethodM2.7M3PlusV4-FlashV4-ProGLM-5.2GPT-5.5WorstBestMean
Integrated compilation
LLM4PLC47.753.816.960.052.380.0100.016.9100.058.7
AutoPLC69.295.458.458.595.495.498.558.498.581.5
Agents4PLC47.769.240.075.478.589.298.540.098.571.2
SemaPLC81.595.480.084.689.295.4100.080.0100.089.4
Static behavior
LLM4PLC76.176.774.570.369.277.186.369.286.375.7
AutoPLC68.973.568.976.266.575.588.866.588.874.0
Agents4PLC63.473.577.671.464.562.888.662.888.671.7
SemaPLC74.984.979.978.081.288.084.174.988.081.6
Dynamic behavior
LLM4PLC3.026.16.618.413.934.654.53.054.522.4
AutoPLC4.043.519.823.945.721.961.14.061.131.4
Agents4PLC4.530.811.428.328.844.663.64.563.630.3
SemaPLC31.352.143.154.157.461.965.431.365.452.2
Table 3: Project-track verification-layer ablation on DeepSeek-V4-Flash (65 tasks), adding checks cumulatively. Comp./Static/Dyn. use the Table 2 metrics; Tok./Reqs. are mean tokens and model requests per task.
Verification layersComp.StaticDyn.Tok.Reqs.
None (generate only)64.671.523.134k8.9
+ Spec70.874.030.360k14.6
+ Compile83.177.843.774k25.5
+ Runtime (full)84.678.054.1129k47.8
Table 4: Outcome shares (%) of the 3,590 golden-reference scenario–port value checks (65 project-track tasks, DeepSeek-V4-Flash) under the cumulative arms of Table 3. The Correct row equals the Dyn. column of Table 3; subshares may not sum exactly to the totals due to rounding.
OutcomeNone+Spec+Compile+Runtime
Check failed76.969.756.345.9
not built/run33.424.519.73.3
port missing41.335.720.018.2
wrong value (normal)0.93.04.97.1
wrong value (breach)1.26.511.717.3
Correct23.130.343.754.1
Table 5: Function-track formal-verification coverage of the held-out pipeline, pooled over 1,293 delivered programs from SemaPLC runs. Conclusive means satisfied or violated.
Program groupProgramsProps.Concl. %Inconcl. %
No REAL/timer916465375.724.3
With REAL345184587.013.0
With timer (TON)321740.0100.0
Table 6: Interaction cost per task against the strongest baseline: requests and end-to-end wall-clock seconds. Values are per-model per-task aggregates (means for requests, medians for times) averaged over the seven models, with across-model ranges in parentheses. Both methods call the same endpoints.
MethodRequests / taskTime / task (s)
Function track
Agents4PLC6.3 (4.4 – 7.2)454 (241 – 688)
SemaPLC6.5 (5.5 – 7.6)71 (41 – 156)
Project track
Agents4PLC6.9 (6.8 – 7.0)344 (47 – 917)
SemaPLC34.1 (16.4 – 60.4)347 (25 – 1380)
Table S1: PLC tools exposed over the Model Context Protocol.
ToolFunction
plc_checkSyntax/semantic check of a bare POU with the same compiler as the evaluation
plc_compileFull ST compilation with structured, line-anchored diagnostics
plc_detectIOExtract the located-I/O surface (addresses, types, directions)
plc_uploadUpload the compiled program to the runtime and return build logs
plc_buildAndRunCompile, upload, and start in one call with per-stage results
plc_startStart the loaded program
plc_stopStop the running program
plc_statusRuntime state query
plc_getLogsRuntime logs with an error flag
plc_readVariablesRead live variable values over the debug protocol
plc_forceVariablesForce or release input values to simulate external signals
plc_traceSample variables over time (timers, state machines, counters)
plc_recordFetch the per-scan recording of transitions for scan-precise sequences
plc_waitForPoll one variable until a comparison holds or times out
plc_verifyBehaviorAtomic force, expect, and release check of a downstream effect
plc_buildSimulationBuild an animated process-simulation scene for the running program
Table S2: Command-line entry points of the same tool server.
CommandFunction
verifyRun a declarative verify plan (build, drive cases, assert, clean up) and emit a JSON verdict envelope
compileCompile an ST file and print the structured result
buildAndRunCompile, upload, and start: the full deploy loop from the shell
detectIOExtract the located-I/O map from an ST file
genModbusConfigGenerate the Modbus slave configuration from the located I/O
readVariablesRead runtime variable values
forceForce or release runtime variables to simulate inputs
traceSample variables over time
waitForPoll a variable until the comparison holds or times out
genSceneSuggest a process-simulation scene from the located I/O
statusQuick runtime status check
serveStart the MCP stdio server under a chosen tool profile
Table S3: The skill library, one skill per verification layer. Skill names are abbreviated.
SkillRole
spec-reviewRequirement-to-logic checklist run before delivery, covering named devices and signals, function-block instance calls, and published-variable drivers
fix-compile-errorRepair the earliest diagnostic only, recheck, at most two rounds, then report stuck
benchmark-verifyRuntime behavior check: build an injectable test copy, deploy it, drive self-derived scenarios, assert published outputs
Table S4: Information seen by the agent during generation versus information used for final scoring.
Information / resultSeen by method?Scores result?
Requirement + contextYesNo
Compiler diagnosticsYesYes
Agent’s own audit feedbackYesNo
Held-out function judgeNoYes
Project assertion oracleNoYes
Golden reference / traceNoYes

왜 중요한가

공장, 발전소, 정수처리장을 돌리는 PLC 코드가 AI로 자동 생성될 때, 컴파일만 통과한 코드도 타이머 오류나 잘못된 상태 전환처럼 실제 운전 중 사고로 이어질 결함을 숨길 수 있다는 점을 보여준다. 코드 생성 AI를 산업 현장에 적용하려는 개발자나 안전 담당자에게, 정적 검사만으로는 신뢰성을 판단할 수 없고 실제 실행 검증이 필수라는 실무적 기준을 제시한다.

이 논문의 용어

  • PLC(프로그래머블 로직 컨트롤러) · 공장 설비나 기계를 자동으로 제어하는 산업용 소형 컴퓨터
  • POU(프로그램 조직 단위) · PLC 프로그램을 구성하는 독립된 함수·블록 단위 코드 조각
  • Structured Text(ST) · PLC를 프로그래밍하는 텍스트 기반 언어 중 하나
  • MCP(모델 컨텍스트 프로토콜) · AI 모델이 외부 도구를 표준화된 방식으로 호출할 수 있게 하는 통신 규격
  • 동적 검사(runtime validation) · 코드를 실제로 실행시켜 정답 코드와 실행 결과(변수 값 변화 등)를 비교하는 검증 방식

저자 · Yanlun Tu

arXiv에서 원문 보기

최신 논문

논문 전체 보기 →

METAL MEDIA 최신 기사

그림 출처: Yanlun Tu et al., arXiv:2608.18565, CC BY 4.0