feat: prompt rules engine with store, priority, and product conditions (#32)#63
Open
DavidLambauer wants to merge 10 commits into
Open
feat: prompt rules engine with store, priority, and product conditions (#32)#63DavidLambauer wants to merge 10 commits into
DavidLambauer wants to merge 10 commits into
Conversation
Enricher now takes PromptResolver as a 5th constructor argument and delegates prompt lookup to it. The test suite swaps the existing Config getProductPrompt stubs for PromptResolver::resolve stubs and drops the .with() constraints whose signature changed with the new API. Also applies PSR-12 fixes to the files touched by the rules-engine commits.
This was referenced Apr 20, 2026
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
Fixes #32. Supersedes #54 (which was a Phase 3 bundle of #32 + #43; #43's config migration was dropped in favor of a separate coordinated effort with the translation module).
Adds an admin-managed rules engine for per-attribute AI prompts, with store scope, priority, and Magento catalog-rule conditions. Replaces the direct
Config::getProductPrompt()lookup inEnricherwith a priority-sorted rule resolver that falls back to the default prompt from the dynamic-row config.What's new
Data layer:
mageos_catalogai_prompt_ruletable (10 columns, indexed onattribute_code+is_active)PromptRulemodel extendingMagento\Rule\Model\AbstractModelwith catalog rule conditions supportService:
PromptResolver::resolve(string $attributeCode, Product $product): ?string— filters active rules, sorts by priority DESC, returns the prompt from the first rule that matches store scope and product conditions. Falls back toConfig::getProductPrompt()when no rules match.Enrichernow delegates prompt lookup toPromptResolverAdmin UI:
What's NOT in this PR
The #43 config migration to
ai_integration_enrichmentwas designed before #46 landed and no longer matches the current config surface. It'll return as a separately-scoped PR coordinated with the translation module's shared "AI Services" section. None of the rules-engine code depends on it.Test plan
setup:upgrade— createsmageos_catalogai_prompt_ruletable