Evaluating Requirement Fidelity in AI-Assisted Frontend Development

    A practical framework for evaluating whether AI-generated frontend pages truly implement product requirements, covering page structure, interaction logic, data constraints, measurable evaluation dimensions, requirement decomposition, and rule-based testing.

    1. Background

    Giving a product requirements document to a code-generation tool and receiving an accessible page in return has become common over the past few years. Teams usually care about practical questions: Can the generated page be used immediately? How much manual modification is required? Which requirements are likely to be missed?

    A page that “looks complete” is not necessarily a page that fully implements the requirements. A login page may contain a carousel, form, and buttons, but that only confirms that the visual layer is present. Whether filters work, whether field dependencies are correct, and whether validation covers edge cases must be verified separately.

    Using frontend page development as the example, this article explains how to break requirements into testable items, design an evaluation framework, identify common deviations, and improve implementation fidelity.

    2. Three Levels of Requirement Fidelity

    A complete frontend requirement usually contains three types of information. Each level should be evaluated separately.

    2.1 Page Structure

    The page structure layer answers: “What appears on the page, and how is it arranged?”

    It includes section divisions, relationships between lists and detail views, navigation placement, and responsive behavior. This is usually the easiest layer for AI tools to implement correctly because common page patterns—such as top navigation, a sidebar, and a content area—are widely represented in training data.

    2.2 Interaction Logic

    The interaction logic layer answers: “What happens after the user performs an action?”

    Examples include:

    • Whether multiple filters use AND or OR logic
    • Which default values are restored after clicking Reset
    • Whether filter state is preserved when changing pages
    • Whether multiple list pages share the same filtering component

    Most implementation deviations occur at this level. A requirement may describe filtering rules, while the generated result only renders the filter controls without connecting the conditions to the data request.

    2.3 Data Constraints

    The data constraints layer answers: “What are the fields, and what rules apply to them?”

    It includes field types, required conditions, length limits, field dependencies—for example, displaying additional information only after a particular account type is selected—and the order of validation before submission.

    Errors in complex forms are often concentrated at this level. All fields may be rendered, but conditional-display logic can be reversed, or validation may run only on submission even though the requirements call for real-time validation while the user is typing.

    3. Build an Evaluation Framework

    Evaluation should use fixed dimensions. Otherwise, conclusions may depend too heavily on personal impressions. At minimum, consider the following six dimensions:

    Dimension Meaning Measurement
    Page completeness Whether required pages and sections exist Check each page against the page inventory
    Functional coverage The proportion of interaction items implemented Implemented items divided by total items
    Rule accuracy Whether validation and dependency logic are correct Pass rate across test cases
    Runnability Whether the result can be started and accessed without modification Boolean value, plus the number of fixes required on the first run
    Generation time Time from submitting the requirements to obtaining a usable result Minutes, with queue time recorded
    Rework cost Time spent on manual corrections Engineering hours, categorized by issue type

    Coverage and accuracy should be evaluated separately. High coverage with low accuracy means the model generated the code but did not correctly understand the rules. These issues are often the hardest to detect before release.

    Generation time can be strongly affected by service load. Tests should be repeated at different times, and the median of multiple results should be recorded to avoid drawing conclusions from a single measurement.

    4. Break Requirements into Testable Items

    Evaluation requires breaking the document into items that can be judged with a simple yes-or-no decision. A statement such as “The filtering feature should be easy to use” cannot be tested directly. It should be rewritten as:

    “The status filter is single-select, defaults to All, and refreshes the list with one request after the selection changes.”

    The following is an example of a structured breakdown:

    1. {
    2. "page": "Product List Page",
    3. "items": [
    4. {
    5. "id": "LIST-001",
    6. "type": "filter",
    7. "desc": "The status filter is single-select and defaults to all",
    8. "expect": { "default": "all", "mode": "single" }
    9. },
    10. {
    11. "id": "LIST-002",
    12. "type": "filter",
    13. "desc": "Keyword and status filters use AND logic",
    14. "expect": { "combine": "AND" }
    15. },
    16. {
    17. "id": "LIST-003",
    18. "type": "interaction",
    19. "desc": "Clicking Reset clears all filters and returns to the first page",
    20. "expect": { "resetPage": 1 }
    21. }
    22. ]
    23. }

    Each item has a unique identifier, making it easier to reference the requirement in defect records.

    4.1 Use Test Code to Verify Rules

    For the data-constraint layer, rules can be implemented as pure functions and kept separate from the page. This allows validation logic to be tested independently of the user interface. The following rule is illustrative:

    `javascript // The password must be 8 to 32 characters long and must not contain whitespace function validatePassword(password) {)