Skip to content

Verification Engineering for AI-Generated Code: Build an Evidence Gate

Implement verification engineering with independent requirements, change-impact analysis, isolated checks and revision-bound approval. Includes an offline release-gate exercise.

BY AISECURITYINTERVIEWS EDITORIAL · EDITORIAL TEAM · UPDATED NOVEMBER 15, 2026 · 5 MIN READ

PRACTICE THIS:Verification engineering foundations ·Apply independent patch verification

An agent changes an export endpoint. The patch compiles, its new tests pass, and a second model recommends merging. The unanswered question is whether a customer can now download another tenant's queued export. Verification engineering starts with that requirement and follows it through the exact artifact proposed for release.

This guide uses a fictional export service. It is an independent design using ordinary engineering controls, with no dependency on a commercial verification product. Its outcome is a reviewable decision, not a probability that the code is safe.

1. Write the contract before asking for a repair

Record the protected asset, the caller, the entry point and the enforcement boundary. Here the asset is an export containing customer records. The caller can choose an export identifier but cannot choose its trusted ownership metadata. The server must authorize the requested object using current access rules before returning bytes.

Freeze both required behavior and forbidden behavior. An authorized customer must still retrieve a ready export. An unrelated tenant must receive no record bytes. An expired grant must not be revived by a cached response. If a queued job uses a different identity, that path needs its own contract.

OWASP ASVS 5.0.0 provides requirements to adapt; it cannot know your export lifecycle. Put local requirement IDs beside the relevant versioned ASVS references. A requirement changed during repair needs explicit review, rather than silently changing the test's expected result.

2. Map impact beyond the changed file

Start from the diff, then inspect callers, shared libraries, schemas, configuration, queues, caches and downstream consumers. A changed helper may affect both the browser route and a scheduled job. A migration can alter existing rows even when the new API behaves correctly. Label unknown dependencies as unknown.

Use static dependency information and recent test coverage to select additional checks. Keep a mandatory suite for authorization, serialization and other high-impact invariants. Dependency inference can miss reflection, dynamic loading and operational configuration; it should not silently remove those checks. A model-generated impact report is a draft map that a knowledgeable owner reviews.

ORIGINAL WORKFLOW · VERIFICATION ENGINEERING
Keep the proposed change outside release authority

Scope the change

Requirements and affected paths

Run independent checks

Controlled runner, fixed inputs

Assemble evidence

Artifact and policy binding

Authorize promotion

Human decision for that scope

3. Build complementary checks

CheckExport-service exampleEvidence to retain
Unit contractAllowed owner succeeds; unrelated tenant failsInputs, expected outcomes and implementation revision
IntegrationReal persistence lookup supplies ownershipDatabase fixture, policy version and result
End-to-endA signed-in user requests the completed exportApplication build, environment and observed response
Property-basedTenant mismatch never returns bytes across generated casesGenerator version, seed and reproducible failing case
MutationA selected omission of an authorization check must be detectedChanged control, detecting case or explained survivor
Manual reviewCached and queued paths enforce the same policyReviewer, inspected paths and unresolved questions

The implementations under test may be AI-generated; the expected outcomes need independent authority. Keep legitimate success cases so “deny everything” cannot win. Keep negative cases outside the patch's unilateral control. A deterministic test can still encode the wrong rule, so review the oracle as well as the implementation.

Formal methods can establish specific properties of a model under assumptions. They do not erase the need to relate the model to deployed code and its environment. NIST SSDF 1.1, checked November 2026, places review and executable testing within a broader development process; naming one step “verification” does not replace the others.

4. Run checks without handing the patch production authority

A repository's test command executes code. Treat proposed build scripts, dependency hooks and workflow changes as untrusted until reviewed. Use disposable environments, synthetic records, constrained network access, resource limits and credentials with no production authority. Separate the job that tests contributions from the job allowed to sign or publish artifacts.

The GitHub Actions secure-use reference, checked November 2026, documents risks around privileged workflows and untrusted checkout. Equivalent boundaries matter in any CI system. Do not execute a contributor-controlled script merely because its filename contains “test”. Test only systems you own or are authorized to assess.

5. Reject incomplete or stale evidence

The following offline program models a release gate after trusted evidence ingestion. IDs are fictional labels. In production, obtain revisions and digests from the build system and authenticate the report producer; a JSON field cannot prove its own provenance. The program does not run proposed code or verify signatures.

required = {"tenant-boundary", "valid-export", "queue-policy"}
binding = ("commit-42", "artifact-42", "requirements-3", "suite-8")


def decide(records, expected):
    reasons = []
    for check in sorted(required):
        matches = [r for r in records if r["check"] == check]
        if len(matches) != 1:
            reasons.append(check + ": missing or ambiguous")
            continue
        record = matches[0]
        if record["binding"] != expected:
            reasons.append(check + ": stale evidence")
        if record["result"] != "pass":
            reasons.append(check + ": " + record["result"])
    return "hold" if reasons else "eligible for review", reasons


receipts = [
    {"check": check, "binding": binding, "result": "pass"}
    for check in sorted(required)
]
print(decide(receipts, binding)[0])  # => eligible for review
print(decide(receipts[:-1], binding)[0])  # => hold
changed = ("commit-43", "artifact-43", "requirements-3", "suite-8")
print(decide(receipts, changed)[0])  # => hold
receipts[0] = {**receipts[0], "result": "timeout"}
print(decide(receipts, binding)[0])  # => hold

“Eligible for review” deliberately differs from “release approved”. Add environment, toolchain, dependency and policy identities to the real record. A trusted ingestion service must reject unauthorized reporters and retain the original observations. Required checks cannot be chosen by the candidate patch itself.

SLSA artifact verification helps validate artifact origin and expected build parameters. Behavioral checks answer a separate question. An authentic build can faithfully compile a logic error, and excellent tests on another digest cannot approve this build.

6. Make approval expire with its assumptions

The review packet should state what changed, which behaviors were checked, gaps, approved deployment targets, monitoring ownership and the rollback candidate. Bind approval to the reviewed artifact and policy. New commits, changed dependencies or a different environment may require new checks. Protect required status checks and review rules from unilateral modification.

A single risk score can route a review queue, but keep hard failures visible. A cross-tenant access failure cannot be cancelled out by several successful lint checks. Report skipped checks, ambiguous results and flaky tests separately; repeated reruns until one passes conceal evidence. Assign an owner to each exception with scope and expiry.

After deployment, reconcile the running digest and observe the relevant control. A canary can expose environment-specific failures, but it cannot make a confidentiality breach reversible. Confirm the rollback target is still acceptable under current policy before treating it as a recovery option.

Start with one change class

Choose one owned endpoint and write three independent contracts: a legitimate operation, a forbidden operation and a lifecycle edge such as revocation. Record each result against an exact change. Then change the fixture's revision without rerunning checks: the gate should hold. Add a missing result and a timeout, and inspect the reasons rather than only the final status.

Continue with the verification-engineering concept, the independent patch exercise, and the agent release review. Those pages distinguish control testing, evidence quality and permission to act.

PRACTICE THIS

Continue with the product workflow, lesson or reference that fits your next step. Each resource shows its access terms.

FAQ

It connects requirements to independent checks, binds evidence to the actual change, and gives a release owner a scoped decision. It builds on testing, security review and software assurance.