Repository navigation
refactor(workflows)!: delete one-release workflow dispatch/step-type fallbacks - #579
Merged
Merged
Conversation
…fallbacks Fixes #572. Deletes the two one-release back-compat fallbacks that #567/#574 shipped for exactly one release (v0.12.1): - The `wp_agent_workflow_handler` first-callable-wins dispatch fallback and `register_workflow_handler()` in `agents_run_workflow_dispatch()`. Replaced with an explicit unattributed-dispatch rule: when no runtime is identifiable (no explicit `runtime` input, no registered spec `meta.runtime`), dispatch to the single registered runtime handler if exactly one is registered; zero is the existing `no_handler` WP_Error; more than one is a new `agents_run_workflow_ambiguous_runtime` WP_Error listing the registered keys. An attributed runtime (explicit or via spec meta) with no matching handler is `no_handler` — no fallback to any other registered handler. - The `wp_agent_workflow_known_step_types` and `wp_agent_workflow_step_handlers` legacy filters layered on top of `WP_Agent_Workflow_Step_Type_Registry` (runner constructor, runner `default_step_handlers()`, and `register-reconcile-workflow-branch.php`'s `agents_workflow_resolve_step_handlers()`). The registry is now the sole source for known step types and their handlers. Caller-supplied constructor `$step_handlers` still merge on top of registry defaults. `WP_Agent_Workflow_Spec_Validator::KNOWN_STEP_TYPES` is also removed — nothing in `src/` read it. The `wp_agent_workflow_run_recorder( $recorder, $runtime, $run_id )` filter is NOT touched — it is the scoped seam, not a fallback. Only the BACK-COMPAT paragraph in `agents_workflow_resolve_recorder()`'s docblock (documenting that WordPress's own "only pass declared args" mechanic lets an old zero-argument hook keep resolving every run) is removed, since that mechanic isn't going away and the paragraph read as if it would. Updates `docs/channels-workflows-operations.md` to the final (no back-compat) contract, and migrates every test that exercised the deleted filters/helper to `register_workflow_step_type()` / `register_workflow_runtime_handler()`, adding coverage for the new unattributed-dispatch rule (single runtime dispatches, two runtimes is ambiguous, zero is `no_handler`, an explicit unknown runtime is `no_handler`). Deletes the `workflow-step-type-registry-smoke.php` section that only asserted the legacy two-filter registration path. BREAKING CHANGE: `wp_agent_workflow_handler` filter and `register_workflow_handler()` are removed — register via `register_workflow_runtime_handler( string $runtime, callable $handler )` instead. `wp_agent_workflow_known_step_types` and `wp_agent_workflow_step_handlers` filters are removed — register via `WP_Agent_Workflow_Step_Type_Registry::register()` or `register_workflow_step_type()` instead. `WP_Agent_Workflow_Spec_Validator::KNOWN_STEP_TYPES` is removed — use `WP_Agent_Workflow_Step_Type_Registry::types()`. Must merge only after Automattic/intelligence#1085 (the migration this followed) is deployed. AI disclosure: AI assistance: Yes / Tool: OpenCode / Used for: implementation and tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #572
What changed
Deletes the two one-release back-compat fallbacks that #567/#574 shipped for exactly one release (v0.12.1), per #572's "do this once" trigger (Automattic/intelligence#1082 merged and deployed; v0.12.1 shipped with the fallbacks present).
1. Dispatch (
agents_run_workflow_dispatch())Removed the
wp_agent_workflow_handlerfirst-callable-wins fallback andregister_workflow_handler().New unattributed-dispatch rule — applies when no runtime is identifiable (no explicit
runtimeinput, no registered specmeta.runtime):wp_agent_workflow_runtime_handlers→ dispatch to itagents_run_workflow_no_handlerWP_Erroragents_run_workflow_ambiguous_runtimeWP_Error, listing the registered keysAn attributed runtime (explicit
runtimeinput or specmeta.runtime) with no matching handler isno_handler— no fallback to any other registered handler, attributed or not.agents_run_workflow_dispatch_failedstill fires on every error path.2. Step types
Removed the legacy
wp_agent_workflow_known_step_types(validator) andwp_agent_workflow_step_handlers(runner constructor, runnerdefault_step_handlers(), andregister-reconcile-workflow-branch.php'sagents_workflow_resolve_step_handlers()) filters.WP_Agent_Workflow_Step_Type_Registryis now the sole source for known step types and their handlers — no more filter layered on top. Caller-supplied constructor$step_handlersstill merge on top of registry defaults (unchanged).WP_Agent_Workflow_Spec_Validator::KNOWN_STEP_TYPESis also removed — confirmed viagit grepthat nothing insrc/read it (only a doc comment and the docs file referenced it).3. Recorder — NOT touched (per #572, this is the scoped seam, not a fallback)
wp_agent_workflow_run_recorder( $recorder, $runtime, $run_id )is unchanged. Only removed the BACK-COMPAT paragraph inagents_workflow_resolve_recorder()'s docblock, which documented that WordPress's own "only pass declared args" mechanic lets an old zero-argument hook keep resolving every run on the site — that mechanic isn't going away (it's not something agents-api's code implements or can delete), so the paragraph read as a stale promise to remove something that was never actually a code fallback.workflow-scoped-seams-smoke.php's "LEGACY BACK-COMPAT" recorder section still passes unchanged since the underlying behavior wasn't removed.4. Docs
docs/channels-workflows-operations.mdrewritten to the final (no back-compat) contract at all three back-compat call-outs (step-type filters/constant, dispatch fallback, recorder zero-arg note).5. Tests
Migrated every test that exercised the deleted filters/helper to
register_workflow_step_type()/register_workflow_runtime_handler():agents-workflow-ability-smoke.php— rewrote the dispatch section for the new unattributed rule (single/zero/two runtimes, explicit unknown runtime)workflow-scoped-seams-smoke.php— section 3 rewritten the same way; section 2 (recorder legacy zero-arg contract) untouched since that behavior is intentionally keptworkflow-runner-smoke.php—throwing/custom_nestedstep types now registered viaregister_workflow_step_type(); the "unknown step type, no handler" scenario now constructs theWP_Agent_Workflow_Specdirectly (bypassing the validator), since the unified registry makes "validates but has no handler" unreachable through normal registrationworkflow-spec-validator-smoke.php,workflow-await-smoke.php,workflow-cancel-fencing-smoke.php— sameregister_workflow_step_type()migration for their fixture step typesworkflow-step-type-registry-smoke.php— deleted the "Legacy two-filter registration still validates and runs" section entirely (it only asserted the deleted back-compat path)BREAKING CHANGE
wp_agent_workflow_handlerfilter andregister_workflow_handler()are removed — register viaregister_workflow_runtime_handler( string $runtime, callable $handler )instead.wp_agent_workflow_known_step_typesandwp_agent_workflow_step_handlersfilters are removed — register viaWP_Agent_Workflow_Step_Type_Registry::register()orregister_workflow_step_type()instead.WP_Agent_Workflow_Spec_Validator::KNOWN_STEP_TYPESis removed — useWP_Agent_Workflow_Step_Type_Registry::types().Grep evidence
Verification
Do not merge until Automattic/intelligence#1085 is deployed. That PR migrates Intelligence's remaining zero-argument recorder claim / unscoped dispatch usage; merging this before it deploys removes the unattributed-dispatch fallback Intelligence currently relies on.
AI disclosure
AI assistance: Yes / Tool: OpenCode / Used for: implementation and tests.