Recursion can involve lambdas and callbacks invoked by a standard function. Without a counting rule, different targets could report failure at different call sites.
Decision
For TPZ5009, count named functions, lambdas, user callbacks, protocol methods and receiver methods. Do not count standard functions themselves or defer blocks.
Concurrent arms inherit the depth at group entry. Implementations must avoid stack exhaustion below 1000 active calls.
Alternatives considered
Leave depth to target-specific stack limits. The same program could stop at different calls on different targets.
Why
The program structure shows which operations add to depth.