🛡️ P2.5 Frontend Validation — Live Test

Calls the production bridge endpoint POST /api/agent/plan/validate with 5 test plans (2 valid, 2 invalid, 1 warning-only), then renders what the frontend's formatValidationIssues() would show in the chat.

Results: 5 passed, 0 failed (of 5)

🟢 ALL TESTS PASS

✅ Valid plan: BlogPost.title + BlogPost.body

Expected: error=False, warning=False | Got: error=0, warning=0

Plan:

{
  "summary": "x",
  "spec": {
    "appName": "x",
    "contentTypes": [
      "BlogPost"
    ],
    "files": [
      {
        "name": "i.html",
        "intent": "list",
        "sweeps": {
          "data_shapes": [
            "BlogPost.title",
            "BlogPost.body"
          ]
        }
      }
    ]
  }
}

Bridge response:

{
  "ok": true,
  "issues": [],
  "summary": {
    "errors": 0,
    "warnings": 0
  }
}

formatValidationIssues() output:

(empty — no issues)

✅ Bad field: BlogPost.fakeField

Expected: error=True, warning=False | Got: error=1, warning=0

Plan:

{
  "summary": "x",
  "spec": {
    "appName": "x",
    "contentTypes": [
      "BlogPost"
    ],
    "files": [
      {
        "name": "i.html",
        "intent": "list",
        "sweeps": {
          "data_shapes": [
            "BlogPost.fakeField"
          ]
        }
      }
    ]
  }
}

Bridge response:

{
  "ok": false,
  "issues": [
    {
      "severity": "error",
      "code": "UNKNOWN_FIELD",
      "message": "spec.files[0].sweeps.data_shapes[0] references field \"fakeField\" which is not on content type \"BlogPost\". Valid fields: title, slug, body, author, published_at, tags, cover_image",
      "path": "$.spec.files[0].sweeps.data_shapes[0]"
    }
  ],
  "summary": {
    "errors": 1,
    "warnings": 0
  }
}

formatValidationIssues() output:

❌ 1 validation error:
  • spec.files[0].sweeps.data_shapes[0] references field "fakeField" which is not on content type "BlogPost". Valid fields: title, slug, body, author, published_at, tags, cover_image  ($.spec.files[0].sweeps.data_shapes[0])

✅ Unknown type: NotARealType

Expected: error=True, warning=False | Got: error=1, warning=0

Plan:

{
  "summary": "x",
  "spec": {
    "appName": "x",
    "contentTypes": [
      "NotARealType"
    ],
    "files": []
  }
}

Bridge response:

{
  "ok": false,
  "issues": [
    {
      "severity": "error",
      "code": "UNKNOWN_CONTENT_TYPE",
      "message": "spec.contentTypes[0] references \"NotARealType\" but that content type does not exist. Use one of: ",
      "path": "$.spec.contentTypes[0]"
    }
  ],
  "summary": {
    "errors": 1,
    "warnings": 0
  }
}

formatValidationIssues() output:

❌ 1 validation error:
  • spec.contentTypes[0] references "NotARealType" but that content type does not exist. Use one of:   ($.spec.contentTypes[0])

✅ Real Listing fields

Expected: error=False, warning=False | Got: error=0, warning=0

Plan:

{
  "summary": "x",
  "spec": {
    "appName": "x",
    "contentTypes": [
      "Listing"
    ],
    "files": [
      {
        "name": "l.html",
        "intent": "list",
        "sweeps": {
          "data_shapes": [
            "Listing.title",
            "Listing.price",
            "Listing.location"
          ]
        }
      }
    ]
  }
}

Bridge response:

{
  "ok": true,
  "issues": [],
  "summary": {
    "errors": 0,
    "warnings": 0
  }
}

formatValidationIssues() output:

(empty — no issues)

✅ Missing contentTypes but mentions 'list'

Expected: error=False, warning=True | Got: error=0, warning=1

Plan:

{
  "summary": "x",
  "spec": {
    "appName": "x",
    "files": [
      {
        "name": "l.html",
        "intent": "list of items"
      }
    ]
  }
}

Bridge response:

{
  "ok": true,
  "issues": [
    {
      "severity": "warning",
      "code": "MISSING_CONTENT_TYPES",
      "message": "spec has files that mention data shapes (list/grid/card/post/etc) but spec.contentTypes is empty. Add content type names to spec.contentTypes so the LLM uses canonical schemas.",
      "path": "$.spec.contentTypes"
    }
  ],
  "summary": {
    "errors": 0,
    "warnings": 1
  }
}

formatValidationIssues() output:

⚠️  1 warning:
  • spec has files that mention data shapes (list/grid/card/post/etc) but spec.contentTypes is empty. Add content type names to spec.contentTypes so the LLM uses canonical schemas.  ($.spec.contentTypes)

Generated 2026-07-29 by Mavis (VibeCoder thread) — P2.5 verification.