Skip to content

refactor(plugins): dedup workflow engine handlers into shared helpers#102

Open
SamTolmay wants to merge 2 commits into
mainfrom
claude/workflow-api-refactor-mjlia3
Open

refactor(plugins): dedup workflow engine handlers into shared helpers#102
SamTolmay wants to merge 2 commits into
mainfrom
claude/workflow-api-refactor-mjlia3

Conversation

@SamTolmay

Copy link
Copy Markdown
Member

Extract the logic that was copy-pasted across the WorkflowAPI handlers
into shared, single-source helpers (no behavior change):

  • shared/collectionNames.js — collection-name defaults, previously
    repeated in 8 files (schema-default drift risk).
  • shared/findWorkflowConfig.js — workflowsConfig lookup by type,
    previously repeated in 6 files.
  • shared/render/resolveActionAccess.js — add hasAnyVerb +
    selectVisibleActions (the access-filter + link-collapse + annotate
    loop repeated in the three card-rendering read handlers).
  • shared/render/pruneFormData.js — the ~50-line form_data pruning block
    duplicated verbatim in GetWorkflowOverview and
    GetWorkflowActionGroupOverview.
  • shared/render/buildEntityLink.js — the entity_link chrome built in
    four handlers.
  • shared/render/collectActionGroups.js — the action_group grouping +
    declaration-order/unseen-group indexing duplicated in
    GetEntityWorkflows and GetWorkflowOverview.
  • WorkflowAPI/shared/terminateWorkflow.js — the identical
    sweep → recompute → references-merge → event → change-log →
    tracker-fire → commit → cascade tail of CancelWorkflow and
    CloseWorkflow; the handlers now declare only their documented deltas
    (lifecycle stage, event/tracker signals, sweep exception).

Structural cleanup:

  • Move GetEventsTimeline under connections/EventsTimeline/ — it is
    registered on the EventsTimeline connection, not WorkflowAPI.
  • Move dispatchNotifications to shared/phases/ — its only caller is
    commitPlan, which previously imported it from inside WorkflowAPI
    (inverted dependency).
  • Delete SubmitWorkflowAction/UserError.js — dead code, never imported.
  • GetEventsTimeline: fold the two card branches (workflow / non-workflow)
    into one card shape with a conditional access gate.
  • GetWorkflowAction: fix the out-of-order step comments; build
    entity_link from the guarded entityId (no TypeError when a doc lacks
    entity).
  • WorkflowAPI schema: eventsCollection is read by GetWorkflowAction only
    (GetEventsTimeline belongs to the EventsTimeline connection).

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh

claude added 2 commits July 9, 2026 10:30
Extract the logic that was copy-pasted across the WorkflowAPI handlers
into shared, single-source helpers (no behavior change):

- shared/collectionNames.js — collection-name defaults, previously
  repeated in 8 files (schema-default drift risk).
- shared/findWorkflowConfig.js — workflowsConfig lookup by type,
  previously repeated in 6 files.
- shared/render/resolveActionAccess.js — add hasAnyVerb +
  selectVisibleActions (the access-filter + link-collapse + annotate
  loop repeated in the three card-rendering read handlers).
- shared/render/pruneFormData.js — the ~50-line form_data pruning block
  duplicated verbatim in GetWorkflowOverview and
  GetWorkflowActionGroupOverview.
- shared/render/buildEntityLink.js — the entity_link chrome built in
  four handlers.
- shared/render/collectActionGroups.js — the action_group grouping +
  declaration-order/unseen-group indexing duplicated in
  GetEntityWorkflows and GetWorkflowOverview.
- WorkflowAPI/shared/terminateWorkflow.js — the identical
  sweep → recompute → references-merge → event → change-log →
  tracker-fire → commit → cascade tail of CancelWorkflow and
  CloseWorkflow; the handlers now declare only their documented deltas
  (lifecycle stage, event/tracker signals, sweep exception).

Structural cleanup:

- Move GetEventsTimeline under connections/EventsTimeline/ — it is
  registered on the EventsTimeline connection, not WorkflowAPI.
- Move dispatchNotifications to shared/phases/ — its only caller is
  commitPlan, which previously imported it from inside WorkflowAPI
  (inverted dependency).
- Delete SubmitWorkflowAction/UserError.js — dead code, never imported.
- GetEventsTimeline: fold the two card branches (workflow / non-workflow)
  into one card shape with a conditional access gate.
- GetWorkflowAction: fix the out-of-order step comments; build
  entity_link from the guarded entityId (no TypeError when a doc lacks
  entity).
- WorkflowAPI schema: eventsCollection is read by GetWorkflowAction only
  (GetEventsTimeline belongs to the EventsTimeline connection).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh
GetEntityWorkflows spread the raw workflow doc into its response, which
shipped the whole form_data map to any user holding a verb on any of the
workflow's actions. GetWorkflowOverview and GetWorkflowActionGroupOverview
already prune form_data to view-visible actions precisely so denied
slices (e.g. a keyed sibling the user cannot see) never reach the client
— this closes the same gap on the entity read. The module's own consumer
(actions-on-entity) reads only title/_id/groups, and visible actions'
slices still ship unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqkWUK5HgZTsXck38Sm5bh
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.

2 participants