feat: Await signals with Approval demo tab - #6
Conversation
Capture the approved design for Oban-style await_signal/signal on PgFlow: mid-handler pause, durable buffer, park as waiting, and resume by run_id + step_slug.
Break the approved await-signals design into TDD tasks: helpers V05, Queries.Signals, Context/Client API, worker park catch, timeout sweeper, and Job/Flow coverage.
Park tasks with Context.await_signal/2, deliver payloads via PgFlow.signal/3, and recover expired waits. Context includes flow_slug/message_id for Worker.Server construction.
After merging step_states, overlay step_tasks with status waiting so Approve/Reject still appear if the PubSub event was missed. Snapshot started remains running.
Keep the scheduled article_flow_cleanup job off Article, Onboarding, and Approval pages.
- Make signal consumption and parking atomic with fenced retries and timeout-safe delivery - Settle terminal waits, recover expired tasks, and preserve claimed payloads across retries - Add version-aware V05 upgrades, rollback safeguards, and startup schema compatibility checks - Harden signal APIs, worker handling, demo reconciliation, and public documentation - Cover concurrency, migration, recovery, and approval flows with database-backed tests
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a538dbfc44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| </form> | ||
|
|
||
| <div class="mt-4 flex items-center justify-between"> | ||
| <form |
There was a problem hiding this comment.
Build the approval form with the shared form component
When the Approval tab renders, this new raw <form> bypasses the demo application's required Phoenix.Component.form/1 abstraction, leaving this flow inconsistent with the shared form behavior and future field/error handling. Replace it with the imported <.form> component while preserving the ID and submit event.
AGENTS.md reference: demo/AGENTS.md:L140-L140
Useful? React with 👍 / 👎.
| %{id: :await_approval, lines: 24..32, clickable: true}, | ||
| %{id: :charge, lines: 34..43, clickable: true} |
There was a problem hiding this comment.
Align the approval DSL slices with the source
When the Approval tab displays its DSL, these ranges do not match approval_flow.ex: await_approval continues through line 34, while charge starts at line 36 and continues through line 47. The current slices therefore omit the await handler's closing lines, attach an unrelated end to the charge segment, and truncate most of the charge result, so users see malformed and incomplete example code.
Useful? React with 👍 / 👎.
Summary
PgFlow.Context.await_signal/2andPgFlow.signal/3,4so Job and Flow handlers can park aswaitingand resume from a JSON payload (Oban-style buffer, last-write-wins,wait_fortimeout).waitingonstep_tasks,task_signalsstore, park/signal/consume/expire SQL. Parking does not consume a retry; stalled recovery still ignoreswaiting.[:pgflow, :worker, :task, :waiting]; PubSub maps it to{:task_waiting, ...}so LiveViews can show the parked state.create_order → await_approval → charge) with Approve / Reject callingClient.signal/3. Reconcile overlaysstep_tasks.status = waitingif the live event is missed.This is unrelated to
signal_strategy/PgFlow.Signal.Notify(pgmq worker wake-ups).Test plan
mix test test/pgflow/await_signals_test.exs test/pgflow/telemetry/pubsub_test.exs test/pgflow/context_await_signal_test.exs test/pgflow/queries/signals_test.exs test/pgflow/migrations/versions/v05_test.exs test/pgflow/client_test.exscd demo && mix test test/pgflow_demo_web/live/flow_demo_live_test.exs test/pgflow_demo/approval_flow_test.exsMIX_ENV=test mix ecto.drop && MIX_ENV=test mix ecto.create). Existing demo DBs need the same for V05.cd demo && mix phx.server→ Approval tab → Start Flow → Approve / Reject.Notes
waitingbadge is out of scope for this change.