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 Go DBC mechanisms, request-scoped failure behavior, expected errors versus invariant violations, and semantic invariants.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Preconditions",
"description": "Documents input requirements for order ID, non-empty lines, SKU validity, and positive quantities.",
"max_score": 12
},
{
"name": "Postconditions",
"description": "Documents guarantees for successful reservation ID, line preservation/copying, and non-nil result on success.",
"max_score": 10
},
{
"name": "Semantic invariant",
"description": "Documents a business invariant such as reservations only exist for positive quantities tied to a valid order.",
"max_score": 8
},
{
"name": "Go mechanisms",
"description": "Uses Go-appropriate errors for expected invalid requests and reserves panic for true invariant violations if any.",
"max_score": 12
},
{
"name": "No silent nil",
"description": "Does not silently return nil success/defaults for contract violations such as empty lines.",
"max_score": 10
},
{
"name": "Clear messages",
"description": "Contract failures or returned errors have clear messages indicating the violated condition.",
"max_score": 8
},
{
"name": "Request transaction",
"description": "Notes invalid request should fail the request/operation, not crash the long-running server process.",
"max_score": 8
},
{
"name": "Comments docs",
"description": "Adds contract comments near ReserveInventory or related types.",
"max_score": 8
},
{
"name": "Bad cases",
"description": "Includes tests/table cases for empty order ID, empty lines, blank SKU, and non-positive quantity.",
"max_score": 10
},
{
"name": "Good cases",
"description": "Includes valid reservation tests/examples.",
"max_score": 6
},
{
"name": "Prioritization",
"description": "Explains why this public/correctness-critical boundary deserves contracts.",
"max_score": 8
}
]
}