Skip to content

fix(workflows): reload a saved workflow only after its commit - #581

Draft
Silthus wants to merge 3 commits into
masterfrom
email-v2/00-reload-after-commit
Draft

Silthus wants to merge 3 commits into
masterfrom
email-v2/00-reload-after-commit

Conversation

@Silthus

@Silthus Silthus commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Part of the code-first rebuild of the email send stack; replaces parts of PostHog#121867 (the workflow reload it needs, split out to land first).

Problem

Impact

Pays into Grow Workflows: an edit or a pause takes effect on the workers as soon as it commits. In scope: Workflows, every workflow save.

Merge Danger

Warning

🟡 Merge risk: medium · two-way door: a revert brings back the reload before commit

Changes

Kind Files Lines
Production 3 +9 −24
Tests 3 +55 −19
  • A saved workflow reloads on the workers once the save commits. hog_flow_saved publishes the reload in transaction.on_commit(..., robust=True).
  • hog_flow_deleted already published after commit, and is now robust=True too.
  • The separate after-commit reload in sync_transactional_workflow is gone, because the save now covers it.
  • Mechanical: the comment on the pause writer's queryset update now gives the reason that still holds.

Saves that now reload at the outer commit, from transaction.atomic blocks on master:

  • services/hog_flow_writes.py: create, update, edit content, and publish a draft. A save that changes only draft and draft_updated_at never reloads.
  • services/hog_flow_revisions.py (restore) and services/workflow_proposals.py (apply).
  • Transactional email workflows and message template updates (sync_transactional_workflow).
  • The refresh_hog_flows, migrate_hog_flow_secret_inputs and strip_placeholder_sender_overrides commands.

The pause and resume writers and refresh_affected_hog_flows publish their own reload after commit, and do not change.

How did you test this code?

Test seams: the post_save and post_delete receivers (test_hog_flow.py), the transactional template PATCH endpoint (test_transactional_email.py), and the refresh_hog_flows command (test_refresh_hog_flows.py). Each runs the commit callbacks with captureOnCommitCallbacks(execute=True).

Test rationale, run red against master first:

  • An email pause save whose reload runs before the commit.
  • A transactional template update whose reload runs inside its transaction.
  • A failed reload publish, on save and on delete, that fails the save or skips the commit callbacks after it.

Proofs:

  • Live run on a local stack: Django at this head, cdp-api and the CDP workers at master, on data that master wrote first (saved with fleet proof). Each send runs about 3 ms after its save answers.
Case Save Send Delivered
Template update, three subjects in a row 200 202 Each email has the subject just saved
Workflow update, three subjects in a row 200 202 Each email has the subject just saved
Workflow set to draft, then archived 200 400 transactional_email_paused Nothing
Workflow set active again, after each 200 202 Yes
  • Worker logs: each save gives exactly one reload on each worker and on cdp-api, and it arrives before the save answers. On master the same save gives two: one before the commit and one after it.
  • Prod shape: a gap until read-only production access exists on 2026-11-02.

CI: the fork has no Depot runners, so those jobs never start, and no secret for the project-board app, so flags-project-board fails; the other GitHub-hosted checks pass. The lane check passes: the PR changes only the Python side.

Release status

  • No feature flag controls this change

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5.5 (claude-opus-5-5)

Question Answer Who Where
Does the reload-after-commit fix land inside #578 or on its own? On its own, off master, landing before #580 and #578 👤 Human map #461, 2026-10-25
May the code carry comments? No; names carry the reasons 👤 Human map #461, 2026-10-25

Involvement: one decision from Michael; reviewed inside #578 in two rounds (GPT-6.1 Sol, Opus fresh eyes).

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🤖 CI report

⚠️ Comment density — 5% of added code lines are comments (4 of 79)

This section warns when comments are more than 3% of the code lines a PR adds, and alerts above 6%. Before agent-assisted PRs, the typical share was about 2%. Only full-line comments count. Docstrings, generated files, snapshots, migrations, and workflow files are left out.

Comments that restate the code, record how the change came about, or narrate the next line add noise for the next reader. Keep the comments that explain a reason the code cannot show, and remove the rest. See .agents/skills/writing-code-comments/SKILL.md for the house rules.

Files with the most added comment lines:

File Comment lines Added lines
products/workflows/backend/services/workflow_email_health.py 4 4

This check does not block merging. It updates on every push and clears when the share drops.

Silthus and others added 3 commits October 29, 2026 04:35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…loads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…that still holds

The post_save reload now publishes after commit, so the old reason no
longer matches the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus
Silthus force-pushed the email-v2/00-reload-after-commit branch from 2938704 to 7044941 Compare October 29, 2026 06:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant