You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: support passing state from execute() to finalize() via typed Memo (#69)
## Summary
- Add a default type parameter `Memo = ()` to `TypedExecutor<T>` so
executors can return typed state from `execute()` that is persisted to
SQLite and delivered to `finalize()` after children complete
- New `Domain::task_memo()` and `Domain::task_with_memo()` registration
methods for memo-producing executors; existing `Domain::task()` is
unchanged
- Add `memo BLOB` column to `tasks` and `task_history` tables (migration
009); `TypeId::of::<()>()` check avoids DB writes for non-memo tasks
- Update all doc examples (`lib.rs`, `quick-start.md`,
`migrating-to-0.5.md`) to include the new `_memo: ()` parameter in
`finalize()` signatures
Closes#64
## Details
The memo is serialized via `serde_json` at the `set_waiting` transition
(the single correct write point after execute returns and children are
detected). On finalize dispatch, the memo bytes are deserialized back
into the concrete `Memo` type. When `Memo = ()`, no serialization or DB
write occurs — the `TypeId` guard short-circuits to `Ok(None)`.
### Public API changes
| Before | After |
|---|---|
| `TypedExecutor<T>` | `TypedExecutor<T, Memo = ()>` |
| `execute() -> Result<(), TaskError>` | `execute() -> Result<Memo,
TaskError>` |
| `finalize(payload, ctx)` | `finalize(payload, memo, ctx)` |
| `Domain::task()` | `Domain::task()` (unchanged) +
`Domain::task_memo()` |
| `Domain::task_with()` | `Domain::task_with()` (unchanged) +
`Domain::task_with_memo()` |
### Migration
Existing executors with `Memo = ()` only need to add `_memo: ()` to
their `finalize()` override (if any). Executors that don't override
`finalize()` require zero changes.
## BREAKING CHANGE
`TypedExecutor::finalize()` signature adds a `Memo` parameter between
`payload` and `ctx`.
0 commit comments