# Handler Closures Transformation Spec ## Background - The `dx1/unify-types` branch introduces a unified cell/stream type system built on the new `CELL_BRAND` symbol and capability interfaces (`IReadable`, `IWritable`, `IKeyable`, etc.). - API exports and `commontools.d.ts` now define `HandlerFunction` in terms of `HandlerState` and `StripCell`, and the runner augments these interfaces with runtime-specific behaviour. - Schema generator and opaque-ref transformers detect cell kinds via `CELL_BRAND`, keeping the hierarchical capture utilities valid across transformers. ## Impact on Handler Closures - Generated handler callbacks must follow the public signature `(event, props)` so that `HandlerState` inference works and schema injection can attach `toSchema` calls automatically. - Captured values should appear under the `params` object we pass to `handler(...)`; we can reuse the hierarchical capture tree helpers we built for map closures to keep names/structure intact. - Inline closures should only be rewritten when they are literal functions supplied to `on*` JSX attributes and are not already wrapped in `handler(...)`. ## Behaviour Overview - Detect eligible JSX attributes using the existing `isEventHandlerJsxAttribute` helper (prop name starts with `on`). - For inline arrow functions transform ```tsx