Skip to content

refactor: make handler_configs/handler_slugs single source of truth (#233)#259

Merged
chubes4 merged 1 commit into
Extra-Chill:mainfrom
Sarai-Chinwag:refactor/handler-configs-source-of-truth
Feb 17, 2026
Merged

refactor: make handler_configs/handler_slugs single source of truth (#233)#259
chubes4 merged 1 commit into
Extra-Chill:mainfrom
Sarai-Chinwag:refactor/handler-configs-source-of-truth

Conversation

@saraichinwag
Copy link
Copy Markdown
Contributor

Summary

Eliminates duplication between singular (handler_slug/handler_config) and plural (handler_slugs/handler_configs) fields. Plural fields are now the only source of truth for flow step handler configuration.

The Problem

PRs #247-249 added handler_slugs and handler_configs for multi-handler support but kept writing to the singular fields too. This created two sources of truth, and updateHandler() only wrote to singular — so editing a handler on a multi-handler step left handler_configs stale.

The Fix

New utilities in FlowStepHelpers:

  • normalizeHandlerFields() — converts legacy singular fields to plural format on read. Called whenever step config is loaded from DB.
  • getPrimaryHandlerSlug() / getPrimaryHandlerConfig() — convenience getters that read from plural fields with legacy fallback.

All writes go to plural only:

  • updateHandler() — writes to handler_configs[$slug] and handler_slugs, never handler_slug/handler_config
  • addHandler() — normalizes first, writes plural only
  • removeHandler() — normalizes first, writes plural only

Backward compatibility maintained:

  • API responses (FlowFormatter) derive handler_slug and handler_config from plural fields for consumers that read singular
  • Ability input schemas still accept singular for ergonomics (AI agents send singular when configuring one handler)
  • Legacy DB data (only has singular fields) auto-migrated on read via normalization

Files Changed (16)

Core write path: FlowStepHelpers, UpdateFlowStepAbility
Abilities: ConfigureFlowStepsAbility, ValidateFlowStepsConfigAbility, FlowHelpers, ExecuteWorkflowAbility
API: FlowSteps REST, FlowFormatter, CreatePipeline chat tool
Engine: Step.php runtime, PipelineSystemPromptDirective, ImportExport
Display: SettingsDisplayService
Frontend: FlowStepCard.jsx, ModalManager.jsx
Tests: FlowAbilitiesTest fixtures

@saraichinwag saraichinwag force-pushed the refactor/handler-configs-source-of-truth branch from 2a9eea5 to 3bb4e7d Compare February 17, 2026 16:35
@saraichinwag
Copy link
Copy Markdown
Contributor Author

Self-audit complete. Found and fixed 3 additional gaps the sub-agent missed:

  • FlowsCommand.php extractHandlers() — was reading handler_slug from flow config, now reads handler_slugs with fallback
  • FlowsCommand.php extractPrompt() — was reading handler_config['prompt'] from flow config, now reads from handler_configs via primary slug with fallback
  • FlowsCommand.php handler step detection — was checking handler_slug, now checks handler_slugs with fallback
  • ChatPipelinesDirective.php — was reading handler_slug from flow config, now reads handler_slugs with fallback

All remaining handler_slug/handler_config references are either:

  • Inside normalization/getter methods (FlowStepHelpers)
  • Ability INPUT parameters (not stored config)
  • Handler identity operations (HandlerAbilities, Auth)
  • Runtime tool definitions (tool_def, not flow config)
  • Derived API response values (FlowFormatter)
  • Legacy fallbacks after checking plural first (ToolExecutor, filterByHandlerSlug)

Total: 18 files changed, 268 additions, 107 deletions.

@saraichinwag saraichinwag force-pushed the refactor/handler-configs-source-of-truth branch from 3bb4e7d to f0add3f Compare February 17, 2026 16:42
@saraichinwag saraichinwag force-pushed the refactor/handler-configs-source-of-truth branch from f0add3f to 0c9152c Compare February 17, 2026 16:42
@chubes4 chubes4 merged commit d13ab99 into Extra-Chill:main Feb 17, 2026
saraichinwag added a commit to Sarai-Chinwag/data-machine that referenced this pull request Feb 17, 2026
…ization

Non-handler step types (Agent Ping, Webhook Gate) store settings directly
in handler_config without a handler_slug. The normalization introduced in
the source-of-truth refactor (Extra-Chill#259) was unsetting handler_config for all
steps without a handler_slug, causing these settings to appear blank in
the pipeline builder UI.

Now only unset handler_config when a handler_slug is present (meaning the
config has been migrated into handler_configs). When no handler_slug exists,
handler_config is preserved as a plain settings bag for non-handler steps.
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