The helper retries TimeoutError and otherwise preserves failures. Keep that behavior by default, but let each caller inject its own retry decision.
Refactor run(operation, max_attempts, should_retry=None). max_attempts is a positive integer and includes the first call. Return the operation's exact successful result. By default only TimeoutError is retryable; a custom should_retry(error) replaces that default. On an Exception with attempts remaining, call the chosen policy once; retry only if it returns truthy. Never call the policy after the final attempt or on success. Re-raise the same operation exception when it is not retried. If a custom policy raises, propagate that error immediately. Do not catch BaseException subclasses outside Exception. Policies are per invocation, never global, and no sleeping/backoff is required.
retry.py is the module src/retry.py of the src package, as the import in test_public.py shows.