# Evaluation example: generated-page acceptance

Internal repo artifact · Inspired by Frustration · 2026-10-21 snapshot

Source commit: `c9cd4790e42c99b35eed3731bd2c6a5a44c941d8`

Not a client outcome or a model-quality benchmark.

These are real source extracts from our own application. No customer data, credentials or generated screenshots are included. Checksums identify the complete source files at the snapshot; excerpts below are unmodified.

## What to inspect

The rebuild engine checks generated DesignSpec objects before delivery: required nav/hero/footer sections, empty links and content, and a minimum OKLCH lightness difference. The tests include both accepted and rejected fixtures. A rejected fixture returns explicit issue codes; it does not become an acceptable result because generation succeeded.

## Limits

This is deterministic output evaluation, not a measured LLM quality dataset. Fixtures are synthetic test inputs, not customer projects. The lightness heuristic is not a WCAG contrast calculation. It does not prove factual accuracy, task success, injection resistance or accessible rendered output. No pass-rate, cost or production-success claim is made.

## Reproduce in the source repository

Run `bun run --cwd apps/inspired-api test lib/rebuild/qa.test.ts` after installing the repository dependencies. The source repository may require access. These extracts are independently readable; a local reproduction is not a production benchmark.

Source: `apps/inspired-api/lib/rebuild/qa.ts`
SHA-256: `445c679355a37e50176a9bdbcabce5bdc20324e25b7e2df3360d61931ef9a196`

```ts
/**
 * QA gate for the rebuild engine (spec §7 step 4).
 *
 * Checks a generated DesignSpec for:
 *  - presence of required sections (nav, hero, footer)
 *  - sufficient bg/fg contrast in OKLCH lightness (delta >= 0.45)
 *  - empty hrefs (link_placeholder)
 *  - empty required content fields (empty_field), excluding the exempt set
 *
 * Pure function. No I/O, no external deps.
 */

import type { DesignSpec } from '@ibf/rebuild-types'

type IssueCode =
  | 'missing_section'
  | 'low_contrast'
  | 'link_placeholder'
  | 'empty_field'

interface Issue {
  code: IssueCode
  field: string
}

export interface QaResult {
  ok: boolean
  issues: Issue[]
}

const REQUIRED_SECTIONS = ['nav', 'hero', 'footer'] as const
const CONTRAST_DELTA_MIN = 0.45
const EXEMPT_FIELDS = new Set(['eyebrow', 'sub', 'tagline', 'secondaryCta'])
const HREF_KEYS = new Set(['href', 'ctaHref'])

/**
 * Parse the first numeric L value out of an `oklch(L ...)` string. Returns
 * NaN when the input does not match the expected shape. Accepts plain numbers
 * or percentages (the latter normalized to 0..1).
 */
function parseOklchLightness(raw: string): number {
  const match = /oklch\(\s*([0-9]*\.?[0-9]+)(%?)/i.exec(raw)
  if (!match || !match[1]) return NaN
  const n = Number.parseFloat(match[1])
  if (!Number.isFinite(n)) return NaN
  return match[2] === '%' ? n / 100 : n
}

/**
 * Walk a section's fields and collect empty-string findings. Treats any key
 * named `href`/`ctaHref` as a link; everything else (string-valued) is a
 * required content field unless it appears in the exempt set.
 */
function walkSection(
  node: unknown,
  path: string,
  issues: Issue[],
): void {
  if (node === null || node === undefined) return
  if (Array.isArray(node)) {
    node.forEach((item, idx) => walkSection(item, `${path}[${idx}]`, issues))
    return
  }
  if (typeof node !== 'object') return

  for (const [key, value] of Object.entries(node as Record<string, unknown>)) {
    const childPath = path ? `${path}.${key}` : key

    if (typeof value === 'string') {
      const isEmpty = value.trim() === ''
      if (!isEmpty) continue
      if (HREF_KEYS.has(key)) {
        issues.push({ code: 'link_placeholder', field: childPath })
        continue
      }
      if (EXEMPT_FIELDS.has(key)) continue
      issues.push({ code: 'empty_field', field: childPath })
      continue
    }

    if (value && typeof value === 'object') {
      walkSection(value, childPath, issues)
    }
  }
}

export function qaCheck(spec: DesignSpec): QaResult {
  const issues: Issue[] = []

  // 1. Required sections
  const presentTypes = new Set(spec.sections.map((s) => s.type))
  for (const required of REQUIRED_SECTIONS) {
    if (!presentTypes.has(required)) {
      issues.push({ code: 'missing_section', field: required })
    }
  }

  // 2. Contrast: |L(bg) - L(fg)| >= 0.45
  const lBg = parseOklchLightness(spec.theme.bg)
  const lFg = parseOklchLightness(spec.theme.fg)
  if (
    !Number.isFinite(lBg) ||
    !Number.isFinite(lFg) ||
    Math.abs(lBg - lFg) < CONTRAST_DELTA_MIN
  ) {
    issues.push({ code: 'low_contrast', field: 'theme.bg/theme.fg' })
  }

  // 3. Empty hrefs + empty required content fields
  spec.sections.forEach((section, idx) => {
    walkSection(section, `sections[${idx}]`, issues)
  })

  return { ok: issues.length === 0, issues }
}
```

Source: `apps/inspired-api/lib/rebuild/qa.test.ts`
SHA-256: `85ff3d48ac7b55bdb079363c0513e999b742973d71e7032be7d0869086fca13d`

```ts
/**
 * Tests for the rebuild QA gate (spec §7 step 4).
 */

import { describe, it, expect } from 'vitest'
import type { DesignSpec } from '@ibf/rebuild-types'
import { qaCheck } from './qa'

function makeSpec(overrides: Partial<DesignSpec> = {}): DesignSpec {
  const base: DesignSpec = {
    meta: {
      title: 'Acme',
      description: 'A demo company',
      sourceUrl: 'https://example.com',
    },
    theme: {
      bg: 'oklch(0.15 0.02 250)',
      fg: 'oklch(0.98 0 0)',
      primary: 'oklch(0.7 0.18 250)',
      onPrimary: 'oklch(0.1 0 0)',
      muted: 'oklch(0.5 0.02 250)',
      border: 'oklch(0.3 0.02 250)',
      display: 'Inter',
      body: 'Inter',
      mono: 'JetBrains Mono',
    },
    sections: [
      {
        type: 'nav',
        brand: 'Acme',
        links: [{ label: 'Home', href: '/' }],
      },
      {
        type: 'hero',
        headline: 'Welcome',
        ctaLabel: 'Start',
        ctaHref: '/start',
      },
      {
        type: 'footer',
        brand: 'Acme',
        links: [{ label: 'Terms', href: '/terms' }],
      },
    ],
  }
  return { ...base, ...overrides }
}

describe('qaCheck', () => {
  it('passes a complete valid spec', () => {
    const result = qaCheck(makeSpec())
    expect(result.ok).toBe(true)
    expect(result.issues).toEqual([])
  })

  it('flags missing nav, hero, footer sections', () => {
    const spec = makeSpec({
      sections: [
        {
          type: 'features',
          items: [
            { title: 'A', body: 'aa' },
            { title: 'B', body: 'bb' },
          ],
        },
      ],
    })
    const result = qaCheck(spec)
    expect(result.ok).toBe(false)
    const codes = result.issues.map((i) => i.code)
    expect(codes).toContain('missing_section')
    const fields = result.issues
      .filter((i) => i.code === 'missing_section')
      .map((i) => i.field)
    expect(fields).toEqual(expect.arrayContaining(['nav', 'hero', 'footer']))
  })

  it('flags low contrast between bg and fg', () => {
    const spec = makeSpec({
      theme: {
        ...makeSpec().theme,
        bg: 'oklch(0.5 0.02 250)',
        fg: 'oklch(0.55 0 0)',
      },
    })
    const result = qaCheck(spec)
    expect(result.ok).toBe(false)
    expect(result.issues.map((i) => i.code)).toContain('low_contrast')
  })

  it('flags empty href as link_placeholder', () => {
    const spec = makeSpec()
    // Force an empty href on the hero CTA
    spec.sections[1] = {
      type: 'hero',
      headline: 'Welcome',
      ctaLabel: 'Start',
      ctaHref: '   ',
    }
    const result = qaCheck(spec)
    expect(result.ok).toBe(false)
    expect(result.issues.map((i) => i.code)).toContain('link_placeholder')
  })

  it('flags empty required content field as empty_field', () => {
    const spec = makeSpec()
    // Force empty headline (a required content field)
    spec.sections[1] = {
      type: 'hero',
      headline: '   ',
      ctaLabel: 'Start',
      ctaHref: '/start',
    }
    const result = qaCheck(spec)
    expect(result.ok).toBe(false)
    const codes = result.issues.map((i) => i.code)
    expect(codes).toContain('empty_field')
  })

  it('does not flag exempt empty fields (eyebrow, sub, tagline, secondaryCta)', () => {
    const spec = makeSpec()
    // Inject exempt empties on the nav section via a cast — these are not on
    // the schema but the QA walker must tolerate them.
    ;(spec.sections[0] as unknown as Record<string, unknown>).eyebrow = ''
    ;(spec.sections[0] as unknown as Record<string, unknown>).sub = '   '
    ;(spec.sections[0] as unknown as Record<string, unknown>).tagline = ''
    ;(spec.sections[0] as unknown as Record<string, unknown>).secondaryCta = ''
    const result = qaCheck(spec)
    expect(result.ok).toBe(true)
    expect(result.issues).toEqual([])
  })
})
```
