Skip to content

feat(flow): PR #397 rebased on develop + flow_failed realtime forwarding + docs - #408

Closed
esafwan wants to merge 3 commits into
developfrom
task/PR-397-apply
Closed

feat(flow): PR #397 rebased on develop + flow_failed realtime forwarding + docs#408
esafwan wants to merge 3 commits into
developfrom
task/PR-397-apply

Conversation

@esafwan

@esafwan esafwan commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Supersedes/repairs #397 (head 746a2e22): flow-engine loop routing, edge serialization key mismatch, approval routing/permissions, trigger.schedule/trigger.doc-event validation, approvals inbox — all defects verified live on develop. This PR is that change rebased onto current develop plus the two follow-ups identified in intake: the flow_failed realtime event was not forwarded to the frontend (the new ApprovalsBell would wait up to 60s to notice a rejection), and the AGENTS.md Flow Engine section drifted.

Scope

Key decisions

Agent contributions

Intake dossier + repair (cherry-pick, flow_failed fix, typecheck, AGENTS.md update) by the release-orchestration pipeline, which also verified diffs and ran bench validation.

Tests executed

  • py_compile on the 3 changed Python files; npx tsc -b green.
  • Isolated bench 16_ro: bench migrate OK (Flow Run perm sync), console smoke: trigger.schedule/trigger.doc-event node schemas present, rejection-fails-run path present, loop dispatch present.
  • Full test suite: crashes identically to develop baseline (pre-existing test-runner bug — fixed separately in fix(tests): migrate off deprecated FrappeTestCase so the suite runs on Frappe 16 #407). No new failures introduced.

Risks and limitations

  • Behavior changes (intended): rejection without a meta.outcome=rejected edge now FAILS the run; loop nodes now actually iterate — flows authored against the buggy behavior will change.
  • If refactor: Align database transactions with Frappe standards to improve performance #404 lands first, approve_flow_run's new rejection path must keep its commit semantics (_fail_flow_run self-commits today).
  • ApprovalsBell UX not exercised live beyond smoke; compile/typecheck-level verification only.

Rollback

Revert the 3 commits; flow_run.json perm change rolls back on migrate.

Remaining work

  • Automated engine tests for loop/approval routing (no flow test harness exists yet).
  • Live UI smoke of the bell (realtime + poll paths).

esafwan added 3 commits July 20, 2026 07:34
…oval routing/permissions; add approvals inbox bell

- Engine: honor loop executor next_node_id; reject decisions no longer
  follow approval-path edges; approval_type 'user'/'users' treated as
  synonyms in notifications, permission checks, and pending-approvals API
- Validation: allow trigger.schedule and trigger.doc-event node types
- Permissions: Huf Manager can create Flow Runs; approve endpoint requires
  read + approver identity; agent tool handlers enforce permissions and
  approver identity; webhook runs execute as flow owner instead of Guest
- Builder: edge editor writes edgeType/condition keys the serializer reads,
  adds priority and approval-outcome (meta.outcome) controls; trigger types
  round-trip through the serializer
- New ApprovalsBell in the unified header: pending-approvals inbox with
  badge, realtime + polled refresh, inline approve/reject, run deep link
Adds 'flow_failed' to the forwarded flowEvents array so the
ApprovalsBell updates immediately on flow rejection without
waiting for the 60s poll. Mirrors existing flow_completed
forwarding.
- Approval routing: rejection without a meta.outcome=rejected edge fails
  the run (was: fell through success path); loop nodes route body/done
  via executor next_node_id
- Huf Manager role has create on Flow Run (bench migrate required)
- Agent tool handlers (run/get/resume/approve flow) enforce the same
  permission checks as REST endpoints
- Note user/users approval_type synonym handling
@esafwan

esafwan commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by consolidated Flow execution PR #475: feat(flow): consolidate routing, approvals, and failure handling.

@esafwan esafwan closed this Jul 26, 2026
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