The widget contract must conform to WidgetConfigSchema.
Reference example:
{
"data": {
"slides": [
{
"text": "Over 20 years experience"
}
]
},
"settings": {
"mode": {
"desktop": "static",
"tablet": "slider",
"mobile": "slider"
},
"theme": "light"
}
}The self-healing workflow operates under the following assumptions:
The following components are assumed to be healthy:
- Widget runtime
- Deployment platform
- Build pipeline
- Zod validation library
- Node.js runtime
- Storage layer
- Observability infrastructure
The self-healing workflow is responsible for repairing contract-related defects.
Examples:
- Missing required fields
- Invalid enum values
- Structural contract issues
- Constraint violations
The self-healing workflow does not attempt to repair:
- Platform outages
- Infrastructure failures
- Runtime defects
- Widget implementation defects
- Third-party dependency defects
- Network failures
- Site outages
These incidents must be escalated for manual investigation.
The self-healing workflow should only attempt repairs when the root cause is believed to be the contract itself.
When confidence is low, the workflow must:
- Preserve the Last Known Valid Contract
- Notify the team
- Escalate for review
The deployment contract must pass validation against:
WidgetConfigSchema
The schema is the authoritative source of truth for:
- Required fields
- Allowed values
- Minimum and maximum constraints
- Default values
- Structural validation
Agents should not duplicate schema rules.
Validate the deployment contract against the widget's Zod schema.
WidgetConfigSchema.safeParse(contract)If validation fails:
- Collect all Zod validation errors
- Extract the failing path
- Extract the failing constraint
- Generate an incident
Example:
{
"path": ["data", "slides"],
"code": "too_small"
}For each validation error:
- Search the widget repair registry
- Determine whether a repair rule exists
Example:
too_small:data.slides
maps to:
Generate default slide
If one or more validation errors cannot be repaired:
Mark Incident As Unresolved
Restore Last Known Valid Contract
Notify Team
Escalate For Review
Before repairs are executed:
- Notify the team
- Present the repair plan
- Await approval
If approval is denied:
- Notify the team
- Record the decision
- Restore the Last Known Valid Contract
- Mark the incident as unresolved
- Terminate the self-healing process
For each repairable validation error:
- Execute the repair rule
- Update the contract
- Record the change
Example:
Slide count below minimum
↓
Insert placeholder slide
Re-run schema validation.
WidgetConfigSchema.safeParse(contract)If validation succeeds:
Mark Incident As Resolved
Store New Valid Contract
Notify Team
If validation still fails:
Mark Incident As Unresolved
Restore Last Known Valid Contract
Notify Team
Escalate For Review
Each widget maintains a registry of repair strategies.
Example:
{
'too_small:data.slides': repairMissingSlides,
'invalid_enum_value:settings.theme': repairTheme,
'too_big:data.slides.*.text': repairLongText
}The registry defines how validation failures can be automatically repaired.
A contract is considered healed when:
- All validation errors are resolved
- WidgetConfigSchema validation succeeds
- A valid contract is produced
- Required approvals have been obtained
- The contract can be used by the widget
The platform must maintain a Last Known Valid Contract (LKVC).
The LKVC represents the most recent contract that:
- Passed WidgetConfigSchema validation
- Accepted by the platform
- Produced a valid widget
The LKVC is used as the rollback target when:
- Validation cannot be repaired
- Repairs are rejected
- Repairs fail validation
- Deployment fails after repair
The self-healing workflow should emit:
- contract.validation.started
- contract.validation.failed
- repair.plan.generated
- repair.approved
- repair.executed
- contract.validation.succeeded
- contract.rollback.executed
- incident.escalated