Documentation Index
Fetch the complete documentation index at: https://docs.avocadostudio.dev/llms.txt
Use this file to discover all available pages before exploring further.
Guardrail Schema Concept for Predictable AI Editing
Purpose
Define a schema contract that constrains AI-generated edits so results stay predictable, valid, and aligned with customer expectations. For implementation details, see the v1 Specification and Implementation Checklist.Why This Matters
- AI outputs become deterministic enough for production editing workflows.
- Invalid edits are blocked before they reach rendering.
- Users get clearer behavior boundaries (“what AI can safely change”).
- Product quality improves through consistent structure and copy constraints.
Current State (As Implemented)
- The project already validates:
- Edit plan structure (
EditPlan, operations) - Block props via shared schemas
- Edit plan structure (
- The editing model is page + block list (
PageDoc.blocks), without section-aware schema rules yet. - Ambiguous requests can return
needs_clarification.
Decisions (Locked for MVP)
- Hard-blocking enforcement for schema/structure violations.
- MVP scope is structural/schema guardrails only (no policy/tone/SEO/accessibility checks yet).
- Guardrails are global in MVP; per-customer profiles are introduced later with multi-customer support.
- Cross-section moves are blocked by default; allowed only when explicitly requested and valid against target section rules.
- AI is expected to generate plans that already follow guardrails; validator is a strict failsafe.
- Use one bounded auto-repair retry for deterministic schema errors only.
- Auto-repair must not do semantic rewrites; it can only fix structural/schema issues.
- If retry fails, return
needs_clarificationwith precise violating fields.
Target Concept
Use a layered schema model as an AI guardrail:- Plan Schema Guardrail
- Validate operation shape and required fields.
- Reject unknown ops and malformed payloads.
- Content Schema Guardrail
- Validate block props by block type.
- Enforce field types, ranges, enums, and required fields.
- Composition Schema Guardrail (Planned)
- Enforce page composition rules by section (planned terminology).
- Example: which block types can appear in each section, count limits, ordering policies.
- Policy Guardrail
- Enforce non-structural constraints:
- length limits
- banned phrases/claims
- URL format restrictions
- optional brand tone constraints
Guardrail Pipeline
- User request enters orchestrator.
- AI proposes an edit plan.
- Validate plan schema.
- Validate content/composition/policy schemas.
- If valid: apply atomically and version.
- If invalid but repairable: auto-repair with strict bounded retries.
- If still invalid/ambiguous: return
needs_clarificationwith focused suggestions.
Predictability Principles
- No direct AI writes to React/TS files.
- All mutations pass through typed operations.
- All operations pass schema checks before persistence.
- Fallback behavior is explicit and user-visible.
Customer Expectation Model
Customers can expect:- Safe edits that preserve site structure.
- Clear failure mode when requests exceed constraints.
- Repeatable outcomes for similar prompts.
- Arbitrary free-form structural changes outside allowed schemas.
- Silent acceptance of invalid/unsafe requests.
Iteration Plan
v1 (Baseline Hardening)
- Tighten field-level schema constraints for existing blocks.
- Add explicit validation error categories:
schema_violationpolicy_violationambiguity
- Improve
needs_clarificationsuggestions from schema metadata.
v2 (Section-Aware Composition)
- Introduce section-aware composition schema (planned model).
- Add section-level constraints:
- allowed block types
- min/max counts
- optional ordering rules
- Extend operations with section context (planned).
v3 (Policy + Quality Signals)
- Add policy packs per customer/site profile.
- Add quality checks for readability, SEO basics, accessibility hints.
- Add explainable rejection messages mapped to policy keys.
Success Metrics
- Validation failure rate decreases release-over-release.
- Auto-repair success rate increases without increasing regressions.
- Fewer clarification loops per successful edit.
- Higher user acceptance of first applied result.
Open Design Questions
- How strict should auto-repair be before returning clarification?
- Which policy constraints are global vs customer-specific?
- Should section constraints be hard-blocking or soft-warning at first rollout?
- What telemetry is required to evaluate guardrail effectiveness?
Next Step
Convert this concept into a concreteGuardrail Schema v1 specification with:
- Field-level constraints per block type.
- Error taxonomy and response contract.
- Auto-repair retry strategy and stopping rules.
- Acceptance tests for valid/invalid edit scenarios.