Skip to content

Phase 3: Prompt Rules Engine + Config Migration#54

Closed
DavidLambauer wants to merge 41 commits intomage-os-lab:mainfrom
DavidLambauer:feature/phase3-rules-engine-config-migration
Closed

Phase 3: Prompt Rules Engine + Config Migration#54
DavidLambauer wants to merge 41 commits intomage-os-lab:mainfrom
DavidLambauer:feature/phase3-rules-engine-config-migration

Conversation

@DavidLambauer
Copy link
Copy Markdown
Contributor

Summary

Depends on: #53 (Phase 2: Multi-Store/Locale + Enrichment Status Flags)

Config Migration (#43) Details

  • New ai_services tab in admin config, section ai_integration_enrichment under "Data Enrichment"
  • All 12 config paths migrated from catalog_ai/* to ai_integration_enrichment/*
  • Own ACL resource MageOS_CatalogDataAI::config (no longer piggy-backs on Magento_Catalog)
  • Data patch MigrateConfigToAiIntegration migrates existing config values and cleans up old paths
  • Product group relabeled to "Default Product Prompts" to clarify relationship with the rules engine

Prompt Rules Engine (#32) Details

Data layer:

  • New mageos_catalogai_prompt_rule DB table (10 columns, indexed on attribute_code and is_active)
  • PromptRule model extending Magento\Rule\Model\AbstractModel with catalog rule conditions support
  • PromptResolver service — resolves the highest-priority matching rule for a product/attribute/store, falls back to default config prompt

Admin UI:

  • Menu item under Catalog: "AI Prompt Rules"
  • Full CRUD: grid listing with mass delete, edit form with collapsible fieldsets
  • Form fields: name, active toggle, target attribute (dropdown), store views (multiselect), priority, prompt template
  • Conditions fieldset for product-level matching (uses Magento's catalog rule conditions framework)
  • Preview/test AJAX endpoint — enter a SKU to see the resolved prompt with variables substituted

Integration:

  • Enricher now uses PromptResolver instead of reading directly from Config::getProductPrompt()
  • Rule resolution: active rules filtered by attribute code, sorted by priority DESC, first match on store + product conditions wins
  • No rule match = falls back to the default prompt from Phase 1's dynamic rows config

Test plan

  • Run setup:upgrade — should create mageos_catalogai_prompt_rule table and migrate config
  • Run setup:di:compile — should complete without errors
  • Verify old config at Catalog > AI Data Enrichment no longer exists
  • Verify new config at AI Services > Data Enrichment renders correctly
  • Navigate to Catalog > AI Prompt Rules — grid should load
  • Create a rule: set name, attribute, prompt, priority, save — should persist
  • Create two rules for the same attribute with different priorities — verify higher priority wins during enrichment
  • Test store scope filtering — rule with specific store should only match that store
  • Verify enrichment still works with no rules (falls back to default prompts)
  • Test the preview endpoint — enter a SKU and verify prompt variables resolve
  • Mass delete rules from the grid

Phased roadmap covering all 12 open issues: configurable attributes,
multi-store/locale, prompt rules engine, review workflow, and
structured attribute extraction.
Detailed task-by-task plan for housekeeping (mage-os-lab#22, mage-os-lab#23, mage-os-lab#25) and
configurable attributes (mage-os-lab#27) with TDD steps, exact file paths,
and code snippets.
Multi-store/locale (mage-os-lab#12) and enrichment status flags (mage-os-lab#48):
14 tasks covering store-scoped enrichment, locale-aware prompts,
enrichment log table, and admin UI status indicators.
Config migration (mage-os-lab#43) and prompt rules engine (mage-os-lab#32):
14 tasks covering config path migration, rule CRUD admin UI,
conditions framework, PromptResolver service, and preview controller.
@DavidLambauer
Copy link
Copy Markdown
Contributor Author

Superseded by #63, which is the rules-engine half cleanly rebased onto main. The #43 config migration is parked for a separate PR coordinated with the translation module team. See the new issue I'll open shortly.

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.

Move configurations to the "AI integration" section Feature: Prompt rule system

1 participant