Analyze code to suggest and add Design by Contract specifications (preconditions, postconditions, invariants, semantic invariants) in any language. Trigger on: "Design by Contract", "DBC", "preconditions", "postconditions", "class invariants", "code contracts", "formal specifications", "document assumptions", "add contracts", "make this function safer", "define what this function guarantees", "add assertions to document behavior", Bertrand Meyer, Eiffel contracts, or when discussing invariants that should always hold. Do NOT skip for non-Eiffel code — DBC applies everywhere via assertions, type guards, properties.
92
90%
Does it follow best practices?
Impact
95%
1.05xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests TypeScript/JavaScript contract mechanisms for external boundary code and request/transaction failure behavior.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Prioritizes boundary",
"description": "Explains that this external webhook boundary is a high-priority place for contracts.",
"max_score": 7
},
{
"name": "Structured analysis",
"description": "Includes preconditions, postconditions, invariants or semantic invariants, and summary sections.",
"max_score": 8
},
{
"name": "Preconditions",
"description": "Specifies payload shape obligations including id, data object, amount, status, and invoice identifier requirements.",
"max_score": 12
},
{
"name": "Postconditions",
"description": "Specifies guarantees such as normalized return shape and invoice side effect only for paid events.",
"max_score": 10
},
{
"name": "Semantic invariant",
"description": "Documents a business rule such as paid invoices are only marked from valid paid provider events with valid amount/invoice id.",
"max_score": 10
},
{
"name": "TS mechanism",
"description": "Uses TypeScript-appropriate enforcement such as type guards, invariant/assert functions, schema validation, or validation methods.",
"max_score": 12
},
{
"name": "No any leakage",
"description": "Normalizes the raw payload into stable internal types so downstream code need not use any/provider-shaped data.",
"max_score": 8
},
{
"name": "Clear errors",
"description": "Malformed payloads fail immediately with clear errors rather than continuing with undefined/NaN/null/defaults.",
"max_score": 10
},
{
"name": "Request scoped",
"description": "Notes that in a long-running server the bad webhook should terminate the request/transaction, not the entire process.",
"max_score": 7
},
{
"name": "Bad cases",
"description": "Lists or tests known-bad payloads that should trigger contract failures.",
"max_score": 8
},
{
"name": "Comments docs",
"description": "Adds comments or documentation for contract assumptions and guarantees near the boundary function.",
"max_score": 8
}
]
}