Verifying Non-Functional Requirements: Performance, Security, and Style in Code Evals

Verifying Non-Functional Requirements: Performance, Security, and Style in Code Evals

Functional correctness is the floor, not the ceiling. A model that produces code passing all unit tests can still allocate memory quadratically, expose a SQL injection surface, or output a style so inconsistent that no human maintainer would merge it. Verifying non-functional requirements in code evals is the problem that separates shallow code benchmarks from ones that actually predict production quality. This post explains how to design verifiers for performance, security, and style properties, where each approach breaks down, and what failure modes to expect in post-training pipelines.

What Verifying Non-Functional Requirements in Code Evals Actually Means

Non-functional requirements (NFRs) specify how a system behaves, not what it computes. In code evals, verifying non-functional requirements means checking properties that unit tests do not capture: asymptotic complexity, absence of known vulnerability patterns, adherence to a style contract. Each property requires a different verifier class, a different signal-to-noise profile, and a different failure taxonomy.

The three primary NFR classes in code evals are:

  • Performance: time complexity, space complexity, throughput under load, latency percentiles.

  • Security: absence of injection vulnerabilities, unsafe deserialization, hardcoded secrets, insecure cryptographic primitives.

  • Style: linting compliance, naming conventions, cyclomatic complexity ceilings, docstring coverage.

Each class can be verified programmatically, but the verifier design, the false-positive rate, and the reward-hacking surface differ substantially across them.

How to Verify Performance Properties Without Reward Hacking

Performance verification is the hardest NFR class to operationalise as a training signal because runtime is hardware-dependent, noisy, and gameable. Three verifier strategies exist, each with a different trade-off profile.

Verifier strategy

Signal type

Reward-hacking risk

When to use

Wall-clock timing (repeated runs, trimmed mean)

Continuous

High: model learns to emit early-exit stubs

Never as sole signal

Static complexity analysis (AST-based Big-O annotation)

Categorical

Medium: model learns to restructure loops superficially

Screening, not scoring

Algorithmic class oracle (expert-written reference + equivalence check)

Binary

Low if oracle is hidden

Primary signal for training

The algorithmic class oracle is the most defensible approach. An expert authors a reference solution in the correct complexity class. The verifier checks whether the submitted solution produces identical outputs on a hidden stress-test suite designed to surface sub-optimal solutions at scale. A solution that is functionally correct but O(n²) on a 10⁴-element input will time out; the timeout is the signal, not a runtime measurement.

This design sidesteps hardware noise and is difficult to game because the stress-test suite is held out. The cost is expert authoring time: each task requires a reference solution, a complexity-discriminating input generator, and a timeout threshold calibrated to the target complexity class. As noted in the discussion of reward hacking in rubric-based grading, any scalar reward signal that models can observe during training will eventually be exploited; holding out the stress-test inputs is the primary defence.

Verifying Security Properties: Static Analysis, Taint Tracking, and Expert Rubrics

Security verification decomposes into two distinct problems: detecting known vulnerability patterns and detecting novel unsafe constructs. Only the first is tractable with fully automated verifiers today.

Static analysis tools (Bandit for Python, Semgrep with community rulesets, CodeQL for Java and C++) provide binary or categorical signals for a defined vulnerability taxonomy. They are fast, deterministic, and easy to integrate into an eval harness. Their limitation is recall: they flag what their rules cover, nothing else. A model that learns to avoid flagged patterns while introducing semantically equivalent unsafe constructs will pass the verifier.

Taint-tracking verifiers trace data flow from untrusted sources to sensitive sinks. They catch injection classes that pattern-matching misses. The operational cost is higher: taint analysis requires language-specific tooling, can produce false positives on sanitised paths, and is slower to run at eval scale.

Expert rubrics are necessary for anything outside the automated verifier's coverage. A security practitioner reviews the generated code against a structured checklist: authentication boundaries, privilege escalation paths, secrets handling, cryptographic primitive selection. This is expensive and does not scale to thousands of samples, but it is the only reliable signal for novel vulnerability classes.

A practical pipeline combines all three in sequence: static analysis as a fast filter, taint tracking on the subset that passes, expert review on a stratified sample. The stratified sample should oversample edge cases and novel constructs, not random draws. This mirrors the spot-audit logic described in verifying synthetic data with expert spot audits.

Verifying Style: Linting, Complexity Metrics, and the Consistency Problem

Style verification is the most tractable NFR class programmatically and the most likely to produce misleading training signals if designed carelessly.

A linting-based verifier (Pylint, ESLint, Ruff, Checkstyle) produces a violation count or a pass/fail against a configured ruleset. The signal is cheap to compute and fully deterministic. The problem is that linting compliance is necessary but not sufficient for style quality. A model can learn to emit linting-clean code that is still structurally incoherent: deeply nested conditionals, single-letter variable names that happen to satisfy the naming regex, functions with cyclomatic complexity just under the ceiling.

More discriminating style verifiers add:

  • Cyclomatic complexity ceiling: reject functions above a threshold (commonly 10 for production-grade code). Tools: Radon (Python), lizard (multi-language).

  • Cognitive complexity scoring: a metric developed by SonarSource that weights nesting depth more heavily than cyclomatic complexity. Closer to human readability judgement.

  • Docstring and type annotation coverage: computable as a ratio; set a floor per task specification.

  • Naming convention enforcement: regex-based, but must be scoped to identifiers with semantic weight (public API surface), not internal helpers.

The consistency problem is harder. Style is partly relational: a codebase is consistent when its conventions are uniform, not when each file independently passes a linter. Evaluating consistency requires a multi-file context, which most code eval harnesses do not support. For single-function tasks, consistency verification is limited to internal consistency within the submission. For repository-level tasks, a diff-based verifier that checks whether the submission follows the conventions already present in the provided context is more meaningful than a standalone linter pass.

Worked Illustrative Example: A Three-Layer NFR Verifier for a Sorting Task

Illustrative example (numbers are constructed for clarity, not empirical results):

Task: implement a function that sorts a list of integers in ascending order. Functional requirement: passes 20 unit tests covering edge cases. Non-functional requirements: O(n log n) average complexity, no use of Python's built-in sorted() or list.sort(), no hardcoded values, cyclomatic complexity below 8.

Layer 1: Functional verifier. Run 20 unit tests. Pass/fail. Cost: negligible.

Layer 2: Performance verifier. Run the submission against three input sizes: n=100, n=10,000, n=1,000,000. Measure wall-clock time with a 5-second timeout at n=1,000,000. An O(n²) implementation (bubble sort) will time out at n=1,000,000 on standard hardware. The timeout is the signal. Additionally, an AST check confirms that sorted and list.sort are not called anywhere in the submission tree.

Layer 3: Style verifier. Radon computes cyclomatic complexity. Ruff checks for linting violations against a pinned ruleset. Both must pass. A human reviewer spot-audits 5% of submissions for naming quality and structural clarity, using a four-point rubric (1: incomprehensible, 2: functional but opaque, 3: readable, 4: exemplary).

Illustrative pass rates across 200 model-generated submissions: Layer 1 passes 87%, Layer 2 passes 61% of those, Layer 3 passes 79% of those. The combined pass rate is approximately 42%. This gap between functional and full-NFR compliance is the signal that matters for post-training: a model that scores 87% on functional tests but 42% on the full rubric is not production-ready, and the training signal should reflect that.

Common Failure Modes in NFR Verification

1. Using wall-clock time as the sole performance signal. Detection: high variance across repeated runs; models learn to emit minimal stubs. Fix: replace with timeout-based stress tests against hidden inputs in the target complexity class.

2. Static analysis tool misconfiguration. Detection: verifier passes known-vulnerable patterns from the tool's own test suite. Fix: run the tool against a golden set of vulnerable and clean samples before deploying; pin the tool version and ruleset hash.

3. Linting compliance masking structural incoherence. Detection: linting pass rate near 100% while human reviewers rate readability at 2 or below. Fix: add cyclomatic complexity and cognitive complexity checks; add a human spot-audit tier.

4. Reward hacking through verifier-visible patterns. Detection: model outputs cluster around the exact threshold (for example, cyclomatic complexity of exactly 9 when the ceiling is 10). Fix: vary thresholds across tasks; hold out the exact ceiling values from the task prompt.

5. Missing multi-file consistency checks. Detection: submissions pass all single-file checks but introduce naming or convention inconsistencies relative to provided context. Fix: implement a diff-based consistency verifier that extracts conventions from the context before scoring the submission.

6. Expert rubric drift. Detection: inter-annotator agreement on style rubric drops below 0.7 (Cohen's kappa) over time. Fix: re-anchor reviewers with calibration tasks quarterly; document disagreement cases as rubric refinement inputs. The principles behind domain-specific RLHF failure modes apply directly here: style overfitting is a real risk when rubric signals are weak or inconsistent.

Where This Breaks Down

NFR verification is tractable for well-scoped, single-function tasks with a fixed language and a fixed toolchain. It becomes significantly harder at the repository or system level, where performance depends on interaction effects, security depends on deployment context, and style depends on team convention rather than a universal standard.

Automated verifiers have hard coverage limits. They catch what their rules define. Novel vulnerability classes, subtle algorithmic inefficiencies in correct-complexity-class code, and context-dependent style violations all require human expert review. The cost of that review constrains the scale at which high-quality NFR evals can be produced. Any pipeline that claims full NFR coverage without expert review is either scoped to a narrow, well-defined task class or is over-claiming. Understanding why benchmark scores do not transfer across deployment contexts is essential before treating any NFR eval score as a proxy for production readiness.

Difficulty also drifts. A performance verifier calibrated against today's frontier models will be saturated as models improve. Verifiers need periodic re-calibration against current model capability, not a one-time threshold set at authoring time. This is the same saturation dynamic described in benchmark saturation timelines: evals that do not have headroom stop providing signal.

Frequently Asked Questions

Can LLM-as-judge reliably score non-functional requirements?

For style, LLM-as-judge shows moderate agreement with human experts on surface properties (naming, docstrings) but poor agreement on structural properties (cyclomatic complexity, architectural coherence). For performance and security, LLM-as-judge is unreliable without tool-augmented scaffolding. Programmatic verifiers should be the primary signal; LLM-as-judge is a supplementary signal for properties that resist programmatic definition.

How do you prevent models from gaming a linting-based style verifier?

Vary the ruleset across tasks and hold out the exact configuration from the task prompt. Add a human spot-audit tier that scores properties the linter cannot check (naming semantics, structural clarity). If the model's output distribution clusters suspiciously near any threshold, treat that as a reward-hacking signal and revise the verifier design.

What is the minimum expert review rate for security verification?

There is no universal minimum; it depends on the vulnerability surface of the task class. For tasks involving user input handling, authentication, or cryptography, 100% expert review is defensible. For tasks with narrow, well-defined scope and comprehensive static analysis coverage, a stratified 10-20% spot-audit rate is a reasonable floor, with higher rates for any submission that triggers a static analysis flag.

How should NFR verifier results be combined into a single training signal?

Avoid simple averaging. Functional correctness should gate NFR scoring: a submission that fails unit tests should not receive NFR credit. Among passing submissions, treat each NFR class as a separate dimension. A weighted sum is acceptable if the weights are grounded in task-specific importance. A submission that is functionally correct, O(n log n), and linting-clean but has one high-severity security flag should not score above a submission that is clean on all dimensions.

Does NFR verification apply to tasks beyond Python and JavaScript?

Yes, but toolchain availability varies. Static analysis coverage is strongest for Python, Java, JavaScript, and C/C++. For domain-specific languages (G-code, PLC ladder logic, VHDL), NFR verification requires custom verifiers or simulation environments. The authoring and verification challenges for those domains are substantially higher. The approach to verifying G-code programmatically illustrates how domain-specific verification is designed when standard toolchains do not exist.

What This Means in Practice

Functional correctness is table stakes. The models that matter for production deployment are the ones that produce code that is fast enough, safe enough, and readable enough for a human team to own. Verifying those properties requires layered verifiers: programmatic tools for speed and coverage, expert review for depth and novel cases, and calibration loops to catch reward hacking before it corrupts the training signal.

The design work is in the verifier, not just the task. A well-authored task with a weak verifier produces noise. A well-designed verifier suite with clear failure taxonomies produces signal that compounds across training iterations. That is where the leverage is.

If you are building code evals or post-training pipelines that need to go beyond functional correctness, talk to Chiron Data Labs about expert-authored tasks for your domain.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

Functional correctness is the floor, not the ceiling. A model that produces code passing all unit tests can still allocate memory quadratically, expose a SQL injection surface, or output a style so inconsistent that no human maintainer would merge it. Verifying non-functional requirements in code evals is the problem that separates shallow code benchmarks from ones that actually predict production quality. This post explains how to design verifiers for performance, security, and style properties, where each approach breaks down, and what failure modes to expect in post-training pipelines.

What Verifying Non-Functional Requirements in Code Evals Actually Means

Non-functional requirements (NFRs) specify how a system behaves, not what it computes. In code evals, verifying non-functional requirements means checking properties that unit tests do not capture: asymptotic complexity, absence of known vulnerability patterns, adherence to a style contract. Each property requires a different verifier class, a different signal-to-noise profile, and a different failure taxonomy.

The three primary NFR classes in code evals are:

  • Performance: time complexity, space complexity, throughput under load, latency percentiles.

  • Security: absence of injection vulnerabilities, unsafe deserialization, hardcoded secrets, insecure cryptographic primitives.

  • Style: linting compliance, naming conventions, cyclomatic complexity ceilings, docstring coverage.

Each class can be verified programmatically, but the verifier design, the false-positive rate, and the reward-hacking surface differ substantially across them.

How to Verify Performance Properties Without Reward Hacking

Performance verification is the hardest NFR class to operationalise as a training signal because runtime is hardware-dependent, noisy, and gameable. Three verifier strategies exist, each with a different trade-off profile.

Verifier strategy

Signal type

Reward-hacking risk

When to use

Wall-clock timing (repeated runs, trimmed mean)

Continuous

High: model learns to emit early-exit stubs

Never as sole signal

Static complexity analysis (AST-based Big-O annotation)

Categorical

Medium: model learns to restructure loops superficially

Screening, not scoring

Algorithmic class oracle (expert-written reference + equivalence check)

Binary

Low if oracle is hidden

Primary signal for training

The algorithmic class oracle is the most defensible approach. An expert authors a reference solution in the correct complexity class. The verifier checks whether the submitted solution produces identical outputs on a hidden stress-test suite designed to surface sub-optimal solutions at scale. A solution that is functionally correct but O(n²) on a 10⁴-element input will time out; the timeout is the signal, not a runtime measurement.

This design sidesteps hardware noise and is difficult to game because the stress-test suite is held out. The cost is expert authoring time: each task requires a reference solution, a complexity-discriminating input generator, and a timeout threshold calibrated to the target complexity class. As noted in the discussion of reward hacking in rubric-based grading, any scalar reward signal that models can observe during training will eventually be exploited; holding out the stress-test inputs is the primary defence.

Verifying Security Properties: Static Analysis, Taint Tracking, and Expert Rubrics

Security verification decomposes into two distinct problems: detecting known vulnerability patterns and detecting novel unsafe constructs. Only the first is tractable with fully automated verifiers today.

Static analysis tools (Bandit for Python, Semgrep with community rulesets, CodeQL for Java and C++) provide binary or categorical signals for a defined vulnerability taxonomy. They are fast, deterministic, and easy to integrate into an eval harness. Their limitation is recall: they flag what their rules cover, nothing else. A model that learns to avoid flagged patterns while introducing semantically equivalent unsafe constructs will pass the verifier.

Taint-tracking verifiers trace data flow from untrusted sources to sensitive sinks. They catch injection classes that pattern-matching misses. The operational cost is higher: taint analysis requires language-specific tooling, can produce false positives on sanitised paths, and is slower to run at eval scale.

Expert rubrics are necessary for anything outside the automated verifier's coverage. A security practitioner reviews the generated code against a structured checklist: authentication boundaries, privilege escalation paths, secrets handling, cryptographic primitive selection. This is expensive and does not scale to thousands of samples, but it is the only reliable signal for novel vulnerability classes.

A practical pipeline combines all three in sequence: static analysis as a fast filter, taint tracking on the subset that passes, expert review on a stratified sample. The stratified sample should oversample edge cases and novel constructs, not random draws. This mirrors the spot-audit logic described in verifying synthetic data with expert spot audits.

Verifying Style: Linting, Complexity Metrics, and the Consistency Problem

Style verification is the most tractable NFR class programmatically and the most likely to produce misleading training signals if designed carelessly.

A linting-based verifier (Pylint, ESLint, Ruff, Checkstyle) produces a violation count or a pass/fail against a configured ruleset. The signal is cheap to compute and fully deterministic. The problem is that linting compliance is necessary but not sufficient for style quality. A model can learn to emit linting-clean code that is still structurally incoherent: deeply nested conditionals, single-letter variable names that happen to satisfy the naming regex, functions with cyclomatic complexity just under the ceiling.

More discriminating style verifiers add:

  • Cyclomatic complexity ceiling: reject functions above a threshold (commonly 10 for production-grade code). Tools: Radon (Python), lizard (multi-language).

  • Cognitive complexity scoring: a metric developed by SonarSource that weights nesting depth more heavily than cyclomatic complexity. Closer to human readability judgement.

  • Docstring and type annotation coverage: computable as a ratio; set a floor per task specification.

  • Naming convention enforcement: regex-based, but must be scoped to identifiers with semantic weight (public API surface), not internal helpers.

The consistency problem is harder. Style is partly relational: a codebase is consistent when its conventions are uniform, not when each file independently passes a linter. Evaluating consistency requires a multi-file context, which most code eval harnesses do not support. For single-function tasks, consistency verification is limited to internal consistency within the submission. For repository-level tasks, a diff-based verifier that checks whether the submission follows the conventions already present in the provided context is more meaningful than a standalone linter pass.

Worked Illustrative Example: A Three-Layer NFR Verifier for a Sorting Task

Illustrative example (numbers are constructed for clarity, not empirical results):

Task: implement a function that sorts a list of integers in ascending order. Functional requirement: passes 20 unit tests covering edge cases. Non-functional requirements: O(n log n) average complexity, no use of Python's built-in sorted() or list.sort(), no hardcoded values, cyclomatic complexity below 8.

Layer 1: Functional verifier. Run 20 unit tests. Pass/fail. Cost: negligible.

Layer 2: Performance verifier. Run the submission against three input sizes: n=100, n=10,000, n=1,000,000. Measure wall-clock time with a 5-second timeout at n=1,000,000. An O(n²) implementation (bubble sort) will time out at n=1,000,000 on standard hardware. The timeout is the signal. Additionally, an AST check confirms that sorted and list.sort are not called anywhere in the submission tree.

Layer 3: Style verifier. Radon computes cyclomatic complexity. Ruff checks for linting violations against a pinned ruleset. Both must pass. A human reviewer spot-audits 5% of submissions for naming quality and structural clarity, using a four-point rubric (1: incomprehensible, 2: functional but opaque, 3: readable, 4: exemplary).

Illustrative pass rates across 200 model-generated submissions: Layer 1 passes 87%, Layer 2 passes 61% of those, Layer 3 passes 79% of those. The combined pass rate is approximately 42%. This gap between functional and full-NFR compliance is the signal that matters for post-training: a model that scores 87% on functional tests but 42% on the full rubric is not production-ready, and the training signal should reflect that.

Common Failure Modes in NFR Verification

1. Using wall-clock time as the sole performance signal. Detection: high variance across repeated runs; models learn to emit minimal stubs. Fix: replace with timeout-based stress tests against hidden inputs in the target complexity class.

2. Static analysis tool misconfiguration. Detection: verifier passes known-vulnerable patterns from the tool's own test suite. Fix: run the tool against a golden set of vulnerable and clean samples before deploying; pin the tool version and ruleset hash.

3. Linting compliance masking structural incoherence. Detection: linting pass rate near 100% while human reviewers rate readability at 2 or below. Fix: add cyclomatic complexity and cognitive complexity checks; add a human spot-audit tier.

4. Reward hacking through verifier-visible patterns. Detection: model outputs cluster around the exact threshold (for example, cyclomatic complexity of exactly 9 when the ceiling is 10). Fix: vary thresholds across tasks; hold out the exact ceiling values from the task prompt.

5. Missing multi-file consistency checks. Detection: submissions pass all single-file checks but introduce naming or convention inconsistencies relative to provided context. Fix: implement a diff-based consistency verifier that extracts conventions from the context before scoring the submission.

6. Expert rubric drift. Detection: inter-annotator agreement on style rubric drops below 0.7 (Cohen's kappa) over time. Fix: re-anchor reviewers with calibration tasks quarterly; document disagreement cases as rubric refinement inputs. The principles behind domain-specific RLHF failure modes apply directly here: style overfitting is a real risk when rubric signals are weak or inconsistent.

Where This Breaks Down

NFR verification is tractable for well-scoped, single-function tasks with a fixed language and a fixed toolchain. It becomes significantly harder at the repository or system level, where performance depends on interaction effects, security depends on deployment context, and style depends on team convention rather than a universal standard.

Automated verifiers have hard coverage limits. They catch what their rules define. Novel vulnerability classes, subtle algorithmic inefficiencies in correct-complexity-class code, and context-dependent style violations all require human expert review. The cost of that review constrains the scale at which high-quality NFR evals can be produced. Any pipeline that claims full NFR coverage without expert review is either scoped to a narrow, well-defined task class or is over-claiming. Understanding why benchmark scores do not transfer across deployment contexts is essential before treating any NFR eval score as a proxy for production readiness.

Difficulty also drifts. A performance verifier calibrated against today's frontier models will be saturated as models improve. Verifiers need periodic re-calibration against current model capability, not a one-time threshold set at authoring time. This is the same saturation dynamic described in benchmark saturation timelines: evals that do not have headroom stop providing signal.

Frequently Asked Questions

Can LLM-as-judge reliably score non-functional requirements?

For style, LLM-as-judge shows moderate agreement with human experts on surface properties (naming, docstrings) but poor agreement on structural properties (cyclomatic complexity, architectural coherence). For performance and security, LLM-as-judge is unreliable without tool-augmented scaffolding. Programmatic verifiers should be the primary signal; LLM-as-judge is a supplementary signal for properties that resist programmatic definition.

How do you prevent models from gaming a linting-based style verifier?

Vary the ruleset across tasks and hold out the exact configuration from the task prompt. Add a human spot-audit tier that scores properties the linter cannot check (naming semantics, structural clarity). If the model's output distribution clusters suspiciously near any threshold, treat that as a reward-hacking signal and revise the verifier design.

What is the minimum expert review rate for security verification?

There is no universal minimum; it depends on the vulnerability surface of the task class. For tasks involving user input handling, authentication, or cryptography, 100% expert review is defensible. For tasks with narrow, well-defined scope and comprehensive static analysis coverage, a stratified 10-20% spot-audit rate is a reasonable floor, with higher rates for any submission that triggers a static analysis flag.

How should NFR verifier results be combined into a single training signal?

Avoid simple averaging. Functional correctness should gate NFR scoring: a submission that fails unit tests should not receive NFR credit. Among passing submissions, treat each NFR class as a separate dimension. A weighted sum is acceptable if the weights are grounded in task-specific importance. A submission that is functionally correct, O(n log n), and linting-clean but has one high-severity security flag should not score above a submission that is clean on all dimensions.

Does NFR verification apply to tasks beyond Python and JavaScript?

Yes, but toolchain availability varies. Static analysis coverage is strongest for Python, Java, JavaScript, and C/C++. For domain-specific languages (G-code, PLC ladder logic, VHDL), NFR verification requires custom verifiers or simulation environments. The authoring and verification challenges for those domains are substantially higher. The approach to verifying G-code programmatically illustrates how domain-specific verification is designed when standard toolchains do not exist.

What This Means in Practice

Functional correctness is table stakes. The models that matter for production deployment are the ones that produce code that is fast enough, safe enough, and readable enough for a human team to own. Verifying those properties requires layered verifiers: programmatic tools for speed and coverage, expert review for depth and novel cases, and calibration loops to catch reward hacking before it corrupts the training signal.

The design work is in the verifier, not just the task. A well-authored task with a weak verifier produces noise. A well-designed verifier suite with clear failure taxonomies produces signal that compounds across training iterations. That is where the leverage is.

If you are building code evals or post-training pipelines that need to go beyond functional correctness, talk to Chiron Data Labs about expert-authored tasks for your domain.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

© 2026 CHIRON, SAN FRANCISCO, CA