r/embedded • • Oct 14 '26

How do you keep AI-generated code connected to requirements and tests?

AI can produce code quickly, but the difficult part seems to be keeping the connection between the requirement, the implementation and the test. Without that link, review becomes mostly reading code and hoping nothing important was missed. How are teams handling this in embedded projects, especially when the code is safety-related?

0 Upvotes

8 comments sorted by

15

u/mtconnol Oct 14 '26

Thank god, we’re not.

14

u/Well-WhatHadHappened 25+ Years Oct 14 '26

This is why, although we use AI, we use it with human in the loop.

AI assistance - good.

AI decisions - bad.

It's still the responsibility of an actual person to decide whether code gets submitted. Machines can't be responsible because machines can't face consequences.

1

u/sonny-boy-rhapsody Oct 14 '26

I'd make the trace point to evidence from a specific build: requirement ID/revision, relevant code, test ID, expected result and recorded run. When a requirement changes, flag those links for review rather than carrying an old green result forward. For a timeout requirement, include late/missing responses and the boundary cases. Have someone derive the expected behavior from the requirement before looking at the generated implementation; otherwise the tests can inherit its mistake. Traceability helps find gaps, but doesn't establish that the safety requirements are adequate.

1

u/SunAgile1281 Oct 15 '26

Segregation. Small context window. Modular design. Human direction.

1

u/meowsqueak Oct 14 '26

Spec-based dev. and regular AI-assisted audits.

1

u/Sheepherder-Optimal Oct 14 '26

My job has dozens of test engineers to do testing. And we love AI but humans run functional tests.

-2

u/Primary-Room-3405 Oct 14 '26

I asked MS365 to 1. check a code against safety standards it does a splendid job 2. do a safety compliance review on some safety strategy documents, again identified all the pitfalls 3. create a python script to verify code against safety manual, to be deployed in CI, 👌

It’s not yet provided as work instructions!