# BROKEN_STARTER — intentionally violates WEB-004 contracts.
class DomainError(Exception):
    def __init__(self, code, internal_detail):
        super().__init__(internal_detail); self.code=code; self.internal_detail=internal_detail

def public_response(error, correlation_id, method='POST', outcome='unknown', retry_after=2):
    # TODO: separate domain meaning from public HTTP representation.
    # TODO: remove raw internal-detail leakage.
    # TODO: compute retryability from operation/failure/outcome evidence.
    return {
        'status': 500,
        'content_type': 'application/json',
        'body': {'error': repr(error), 'code': 'operation_failed', 'correlation_id': correlation_id, 'retryable': True},
        'headers': {'Retry-After': str(retry_after)}
    }

def should_retry(method, response, replay_safe_contract=False, outcome='unknown'):
    return response.get('status',0) >= 500
