Repository navigation
feat: plan 034 PR A — Extension API v1: registrar, yaymatik_fire, Run, data fields and facts, missing plugin - #41
Merged
Conversation
…og, 033 tester steps in phases
…th check › Extensions
…ymatik_fire, Run, extension triggers and actions
…plugin issue, Skipped steps, Health check
…snapshots, PR A text
Steps and the trigger resolve through stepOf, so a step of a plugin that is off shows its label and a greyed tile like its canvas card. "Removed step" stays for ids neither the registry nor the inactive steps know. The missing_plugin health check test now covers 2 active, 1 inactive and 1 draft workflow.
Cause, measured on the editor route (viewport 773px, admin bar 32px): #wpbody-content and #yaymatik are exactly 741px, no admin notices, no padding, and Query Monitor's container is 0px tall. The page scrolls because the WP admin menu (#adminmenuwrap) is 787px, taller than the 741px below the admin bar, so WP unpins it (position: relative) and it sets #wpbody/#wpwrap to 787px: document 819px vs viewport 773px, 46px of scroll. Clicking a step card then scrolls the window and the editor's header row slides under the sticky plugin header. While EditorLayout is mounted, <html> gets yaymatik-editor-open (overflow: hidden) and the window scrolls to the top; the class goes on unmount. Only <html>: overflow on <body> makes body the sticky header's scroller and pushes the header down by the admin bar. Checked in the editor and in template preview.
…st cleans up on failure
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.
Summary
Other plugins can now add triggers, actions, data fields and data items to YayMatik through one hook, with arrays, without extending a YayMatik class (
docs/extension-api.md, agreed Nov 13; public surface simplified 11:47).add_action( 'yaymatik_register', fn( $r ) => $r->module( [...] )->trigger( … ) ). Fields and types are arrays and type names; callbacks are any PHP callable.do_action( 'yaymatik_fire', $trigger_id, [ 'user_id' => …, 'points' => … ] ). Payload ids become the run's data and subject (order → cart → review → user → the module's item), declared facts becometrigger.<key>. The event takes the core path: Dispatcher, claims, run ceiling, loop guard.run( $config, $run )returns$run->done()/skip()/fail();$runreadsorder(),user(),customer_email(),cart(),item(),get(),render().missing_plugin), an active one keeps running and skips those steps ("Acme Rewards isn't active."), and Health check lists it.Base:
develop6be688a. No schema change (two options:yaymatik_extension_errors,yaymatik_extension_steps, both autoloaded). Core behaviour for 1.0 workflows is unchanged; every core edit is listed under "Core changes".Checkpoints
docs/extension-api.md, design and decision log § EX, roadmap, 033 tester steps in phases.Extension\Diagnostics(last 50, one write per module and callback per 10 minutes, count is a lower bound), a second id claim recorded, Health check › Extensions.Api\Registrar,Api\Module,Api\Run;Declaration(id rules, field arrays → core fields, type names → core types);Fire(yaymatik_fire, waits forinit);ExtensionTrigger/ExtensionAction/RunAdapter;Step::setup_issue()/setup_issue_code()/context_error(); open picker categories.data_fields()on core items,data_item()withload,CustomerView/CartView, triggerfacts(Insert variable, conditions, run detail, previews).missing_pluginissue, Skipped steps, Health check row, greyed cards.privacy_subjects,SurfaceTest(public classes),CoreStepsTest+docs/extension-api-core.md(./run.sh extension-core).Tests
ReferenceConsumerTest).yaymatik_firestarts one run, with or withoutemits(DispatcherWorkerTest).ExecutorTest).check-late-module(19 checks: registrar module on plugins_loaded 20,yaymatik_firestarts a run, refused declaration, plugin off → saves, activate 400missing_plugin),check-privacy-index(module subjects found by export).check-allon wp-env and wp-env-min, e2e 11/11.Review notes
/code-review highon CP1–CP5; every finding fixed in its checkpoint (listed in the plan's Deviations).setup_issue_codeother than the cart's own, nocontext_error.Core changes
ModuleRegistry: runsyaymatik_registeronce when it first builds; accepts module, step and data item objects; refreshes the step index.StepRegistry/DataRegistry: don't cache whileyaymatik_registerruns;DataRegistry::field( 'trigger.<key>', $trigger )reads that trigger's facts.Step/Trigger:setup_issue(),setup_issue_code(),context_error(),facts(),sample_facts(); defaults change nothing.Validator: per-node setup issue,context_error, facts,missing_plugin.Executor:context_error, Skipped for an inactive step.GraphSchema::prepare()keeps saved inactive nodes.Criteria: rule keys keep digits; a fact rule is checked against the trigger.Scope::timestamp()reads a date fact.RefResolver: loaders for extension data items.SampleValues: a field's own sample.EmailPreview: fact samples; inactive nodes kept.RunPresenter:facts.HealthCheck:missing_plugin,extensions.PersonSubjects: module subjects.Runtime: hooksyaymatik_fire.Catalog:categories,inactiveSteps.Browser steps (Jack)
0 Understand
Another plugin (the "Acme Rewards" example) adds a trigger, an action, a customer field and a fact. Its trigger starts when the plugin calls
yaymatik_fire. When the plugin is turned off, its steps stay but can't run.1 Prepare
pnpm dev..claude/local/034-example-acme.phptowp-content/plugins/acme-rewards/acme-rewards.php. Delete its section 5 (email action) and section 6 (template): they come in PR B. Add any one-colour 24×24logo.svgbeside it. Activate "Acme Rewards for YayMatik (example)".2 Steps
yaymatik_firetrigger and an array-declared action run like core steps (the action's ownyaymatik_fireis stopped by Acme's hourly limit).data_fields( 'customer' ).missing_plugin.