"""Shared task definition for test-background-tasks. Imported by both the test runner (which calls .delay()) and the worker subprocess (which calls .serve()). Living in its own module ensures both processes compute the same `task_key` — task_key includes a hash of the function's code object, and __main__-defined tasks can hash differently depending on entrypoint (uv-script header vs direct `python `). """ from prefect import task from prefect.cache_policies import NONE # `cache_policy=NONE` disables caching so the test exercises a fresh # server-side state transition path on every invocation. Without it, # subsequent runs with the same (a, b) hit a local result-store cache # and skip the COMPLETED transition we want to observe. @task( cache_policy=NONE, persist_result=True, ) def add(a: int, b: int) -> int: return a + b