diff --git a/config/retriex/agent.yaml b/config/retriex/agent.yaml index 0a0ccc2..6a54c52 100644 --- a/config/retriex/agent.yaml +++ b/config/retriex/agent.yaml @@ -573,60 +573,12 @@ parameters: # search. Example: "Anschlusskabel pH/Redox länger 20m" becomes # "anschlusskabel redox" so the shop can return 25m/50m/100m cables. min_query_tokens_after_cleanup: 2 - product_type_terms: - - anschlusskabel - - kabel - - sensorkabel - - elektrodenkabel - - elektrodenanschlusskabel - - messkabel - - verbindungskabel - - steckerkabel - - elektrode - - sensor - - puffer - - kalibrierpuffer - stop_terms: - - zeige - - zeig - - suche - - such - - mir - - bitte - - für - - fuer - - nach - - mit - - ohne - - von - - zum - - zur - - der - - die - - das - - ein - - eine - - einen - - länger - - laenger - - lang - - kürzer - - kuerzer - - größer - - groesser - - kleiner - - über - - ueber - - unter - - mindestens - - maximal - - maximum - - minimum - - ab - - bis - - mehr - - weniger - - als + # Direct product/accessory cleanup terms are resolved from + # config/retriex/vocabulary.yaml. Local lists may still be added here + # as project-specific overrides, but the default source is vocabulary. + vocabulary_views: + product_type_terms: search_repair.direct_product_type_terms + stop_terms: search_repair.direct_product_attribute_stop_terms comparative_constraint_patterns: - '/\b(?:länger|laenger|kürzer|kuerzer|größer|groesser|kleiner|über|ueber|unter|mindestens|maximal|maximum|minimum|ab|bis|mehr\s+als|weniger\s+als)\s+(?P\d+(?:[,.]\d+)?\s*[\p{L}µ°%]*)\b/iu' diff --git a/config/retriex/search_repair.yaml b/config/retriex/search_repair.yaml index 3848b65..d64e5c5 100644 --- a/config/retriex/search_repair.yaml +++ b/config/retriex/search_repair.yaml @@ -11,47 +11,9 @@ parameters: # Query repair must stay on the requested product/accessory type for # direct attribute lookups. It may relax comparative constraints, but it # must not expand to unrelated RAG model/device candidates. - stop_terms: - - zeige - - zeig - - suche - - such - - mir - - bitte - - für - - fuer - - nach - - mit - - ohne - - von - - zum - - zur - - der - - die - - das - - ein - - eine - - einen - - länger - - laenger - - lang - - kürzer - - kuerzer - - größer - - groesser - - kleiner - - über - - ueber - - unter - - mindestens - - maximal - - maximum - - minimum - - ab - - bis - - mehr - - weniger - - als + # Direct product/accessory stop terms are resolved from + # config/retriex/vocabulary.yaml view search_repair.direct_product_attribute_stop_terms. + # A local stop_terms list may still be added here as an explicit project override. comparative_constraint_patterns: - '/\b(?:länger|laenger|kürzer|kuerzer|größer|groesser|kleiner|über|ueber|unter|mindestens|maximal|maximum|minimum|ab|bis|mehr\s+als|weniger\s+als)\s+(?P\d+(?:[,.]\d+)?\s*[\p{L}µ°%]*)\b/iu' diff --git a/config/retriex/vocabulary.yaml b/config/retriex/vocabulary.yaml index 8c89296..79f94bd 100644 --- a/config/retriex/vocabulary.yaml +++ b/config/retriex/vocabulary.yaml @@ -49,6 +49,47 @@ parameters: - service set - serviceset - service-set + direct_product_attribute_stop_terms: + - zeige + - zeig + - suche + - such + - mir + - bitte + - für + - fuer + - nach + - mit + - ohne + - von + - zum + - zur + - der + - die + - das + - ein + - eine + - einen + - länger + - laenger + - lang + - kürzer + - kuerzer + - größer + - groesser + - kleiner + - über + - ueber + - unter + - mindestens + - maximal + - maximum + - minimum + - ab + - bis + - mehr + - weniger + - als views: shop: device_query: @@ -416,6 +457,9 @@ parameters: - sensor - puffer - kalibrierpuffer + direct_product_attribute_stop_terms: + include: + - direct_product_attribute_stop_terms accessory_candidate_terms: add: - indikator diff --git a/config/services.yaml b/config/services.yaml index 15f19f3..338aeac 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -136,6 +136,7 @@ services: App\Config\AgentRunnerConfig: arguments: $config: '%retriex.agent.config%' + $vocabulary: '@App\Config\DomainVocabularyConfig' App\Config\NdjsonHybridRetrieverConfig: arguments: diff --git a/patch_history/RETRIEX_PATCH_43E_DIRECT_ATTRIBUTE_VOCABULARY_VIEW_README.md b/patch_history/RETRIEX_PATCH_43E_DIRECT_ATTRIBUTE_VOCABULARY_VIEW_README.md new file mode 100644 index 0000000..fb32031 --- /dev/null +++ b/patch_history/RETRIEX_PATCH_43E_DIRECT_ATTRIBUTE_VOCABULARY_VIEW_README.md @@ -0,0 +1,84 @@ +# RetrieX Patch p43E – Direct Attribute Vocabulary View Consolidation + +## Ziel + +p43E reduziert weitere doppelt gepflegte Direct-Attribute-Begriffe, ohne fachliche Runtime-Logik, Scoring, Prompt-Regeln, Retrieval oder Admin-UI zu verändern. + +Der Patch setzt auf dem grünen p43D-Stand auf. + +## Änderungen + +- `config/retriex/agent.yaml` + - `shop_prompt.product_attribute_query_cleanup.product_type_terms` wird nicht mehr lokal als Liste gepflegt. + - `shop_prompt.product_attribute_query_cleanup.stop_terms` wird nicht mehr lokal als Liste gepflegt. + - Beide Listen werden über `vocabulary_views` aus `config/retriex/vocabulary.yaml` referenziert. + +- `config/retriex/search_repair.yaml` + - Lokale `direct_product_attribute_lookup.stop_terms` entfernt. + - SearchRepair nutzt weiterhin lokale Overrides, falls künftig bewusst wieder ein projektspezifischer Override ergänzt wird. + +- `config/retriex/vocabulary.yaml` + - Zentrale Klasse `direct_product_attribute_stop_terms` ergänzt. + - Zentrale View `search_repair.direct_product_attribute_stop_terms` ergänzt. + - Bestehende View `search_repair.direct_product_type_terms` bleibt die zentrale Quelle für direkte Produktart-Begriffe. + +- `src/Config/AgentRunnerConfig.php` + - `DomainVocabularyConfig` wird optional injiziert. + - Direct-Attribute-Produktart- und Stop-Term-Zugriffe lösen nun lokale Overrides oder Vocabulary-Views auf. + +- `src/Config/SearchRepairConfig.php` + - `getDirectProductAttributeLookupStopTerms()` nutzt lokale Overrides oder die neue zentrale Vocabulary-View. + +- `config/services.yaml` + - `DomainVocabularyConfig` wird an `AgentRunnerConfig` injiziert. + +## Effektive Listen + +Die effektiven Listen bleiben gegenüber p43D unverändert: + +- AgentRunner Direct-Attribute `product_type_terms`: 12 vorher / 12 nachher, identisch. +- AgentRunner Direct-Attribute `stop_terms`: 40 vorher / 40 nachher, identisch. +- SearchRepair Direct-Attribute `product_type_terms`: 12 vorher / 12 nachher, identisch. +- SearchRepair Direct-Attribute `stop_terms`: 40 vorher / 40 nachher, identisch. + +## Bewusst nicht geändert + +- Keine neue Fachlogik. +- Keine Scoringänderung. +- Keine Prompt-Regeländerung. +- Keine Retrievaländerung. +- Keine Admin-UI. +- Keine neuen harten Listen im PHP-Core. + +## Lokale Checks in dieser Patch-Erstellung + +Grün: + +```bash +php -l src/Config/AgentRunnerConfig.php +php -l src/Config/SearchRepairConfig.php +``` + +Zusätzlich wurde per YAML-/Listenvergleich geprüft, dass die effektiven Direct-Attribute-Listen identisch zum p43D-Stand bleiben. + +Nicht lokal ausführbar in dieser Umgebung: + +```bash +bin/console mto:agent:config:validate +bin/console mto:agent:regression:test +bin/console mto:agent:config:audit-source --details +bin/console mto:agent:config:audit-patterns --details +``` + +Grund: Der entpackte ZIP-Stand enthält kein `vendor/`; `bin/console` bricht deshalb mit `Dependencies are missing` ab. Ein lokaler `composer install` war in der Ausführungsumgebung nicht möglich, da PHP-Extensions (`curl`, `dom`, `sqlite3`, `xml`) fehlen und externe Downloads nicht aufgelöst werden konnten. + +## Empfohlene Pflichtchecks nach Einspielen + +```bash +php -l src/Config/AgentRunnerConfig.php +php -l src/Config/SearchRepairConfig.php +bin/console mto:agent:config:validate +bin/console mto:agent:regression:test +bin/console mto:agent:config:audit-source --details +bin/console mto:agent:config:audit-patterns --details +``` diff --git a/src/Config/AgentRunnerConfig.php b/src/Config/AgentRunnerConfig.php index 9674576..910f259 100644 --- a/src/Config/AgentRunnerConfig.php +++ b/src/Config/AgentRunnerConfig.php @@ -11,6 +11,7 @@ final class AgentRunnerConfig */ public function __construct( private readonly array $config = [], + private readonly ?DomainVocabularyConfig $vocabulary = null, ) { } @@ -420,6 +421,35 @@ final class AgentRunnerConfig } + /** + * @return string[] + */ + private function getConfiguredStringListOrVocabularyView(string $configPath, string $viewPathConfigPath): array + { + if ($this->optionalValue($configPath) !== null) { + return $this->getRequiredStringList($configPath); + } + + if ($this->vocabulary === null) { + throw new \InvalidArgumentException(sprintf( + 'RetrieX agent config path "%s" is missing and no vocabulary resolver is available.', + $configPath + )); + } + + $viewPath = $this->getRequiredString($viewPathConfigPath); + $terms = $this->vocabulary->view($viewPath, []); + + if ($terms === []) { + throw new \InvalidArgumentException(sprintf( + 'RetrieX agent vocabulary view "%s" resolved to an empty list.', + $viewPath + )); + } + + return $terms; + } + /** * @return array */ @@ -932,7 +962,10 @@ final class AgentRunnerConfig */ public function getShopQueryProductAttributeCleanupProductTypeTerms(): array { - return $this->getRequiredStringList('shop_prompt.product_attribute_query_cleanup.product_type_terms'); + return $this->getConfiguredStringListOrVocabularyView( + 'shop_prompt.product_attribute_query_cleanup.product_type_terms', + 'shop_prompt.product_attribute_query_cleanup.vocabulary_views.product_type_terms' + ); } /** @@ -940,7 +973,10 @@ final class AgentRunnerConfig */ public function getShopQueryProductAttributeCleanupStopTerms(): array { - return $this->getRequiredStringList('shop_prompt.product_attribute_query_cleanup.stop_terms'); + return $this->getConfiguredStringListOrVocabularyView( + 'shop_prompt.product_attribute_query_cleanup.stop_terms', + 'shop_prompt.product_attribute_query_cleanup.vocabulary_views.stop_terms' + ); } /** diff --git a/src/Config/SearchRepairConfig.php b/src/Config/SearchRepairConfig.php index 613b038..70869d8 100644 --- a/src/Config/SearchRepairConfig.php +++ b/src/Config/SearchRepairConfig.php @@ -72,7 +72,10 @@ final class SearchRepairConfig /** @return string[] */ public function getDirectProductAttributeLookupStopTerms(): array { - return $this->requiredStringList('direct_product_attribute_lookup.stop_terms'); + return $this->configOrVocabularyStringList( + 'direct_product_attribute_lookup.stop_terms', + 'search_repair.direct_product_attribute_stop_terms' + ); } /** @return string[] */