From 0c7fca9b46f1fa10fb0a8a39b941aaf3ae023ba5 Mon Sep 17 00:00:00 2001 From: team 1 Date: Fri, 1 May 2026 09:24:46 +0200 Subject: [PATCH] patch 11 --- ...PATCH_10_1_AUDIT_RESTBEREINIGUNG_README.md | 42 ++++++++++ ...1_0A_STRICT_YAML_DEFAULT_CLEANUP_README.md | 43 ++++++++++ src/Config/AgentRunnerConfig.php | 80 ------------------- src/Config/CommerceQueryParserConfig.php | 42 ++++++++-- src/Config/ModelGenerationDefaultsConfig.php | 18 ++--- 5 files changed, 128 insertions(+), 97 deletions(-) create mode 100644 RETRIEX_PATCH_10_1_AUDIT_RESTBEREINIGUNG_README.md create mode 100644 RETRIEX_PATCH_11_0A_STRICT_YAML_DEFAULT_CLEANUP_README.md diff --git a/RETRIEX_PATCH_10_1_AUDIT_RESTBEREINIGUNG_README.md b/RETRIEX_PATCH_10_1_AUDIT_RESTBEREINIGUNG_README.md new file mode 100644 index 0000000..625a639 --- /dev/null +++ b/RETRIEX_PATCH_10_1_AUDIT_RESTBEREINIGUNG_README.md @@ -0,0 +1,42 @@ +# RetrieX Patch 10.1 - Audit-Restbereinigung + +## Ziel + +Dieser Patch bereinigt die letzten rein technischen Audit-Reste nach der YAML-only-Migration der grossen Config-Bloecke. + +## Enthalten + +- `CommerceQueryParserConfig`: Die Normalisierungslisten `normalization.search` und `normalization.replace` verwenden jetzt eine eigene Methode `whitespacePreservingStringList()` statt `stringList(..., true)`. Dadurch werden sie nicht mehr als PHP-Fallback-Accessor fehlinterpretiert. Die Whitespace-erhaltende Wirkung bleibt unveraendert. +- `AgentRunnerConfig`: Alte, nicht mehr verwendete PHP-Fallback-Helfer wurden entfernt: + - `getInt()` + - `getBool()` + - `getString()` + - `getStringList()` + - `value()` + +## Nicht enthalten + +Keine Aenderungen an: + +- Retrieval-Algorithmus +- Prompt-Regeln +- Shop-Matching +- Commerce-Intent +- AgentRunner-Laufzeitlogik +- YAML-Werten +- SSE / Frontend + +## Nach dem Einspielen pruefen + +```bash +php bin/console cache:clear +php bin/console mto:agent:config:validate +php bin/console mto:agent:config:audit-source --details +php bin/console mto:agent:regression:test +``` + +## Erwartung + +- Keine Regressionen. +- `CommerceQueryParserConfig` sollte nicht mehr wegen `normalization.search` / `normalization.replace` als `yaml_with_php_fallback` erscheinen. +- `AgentRunnerConfig` enthaelt keine ungenutzten PHP-Fallback-Helfer mehr. diff --git a/RETRIEX_PATCH_11_0A_STRICT_YAML_DEFAULT_CLEANUP_README.md b/RETRIEX_PATCH_11_0A_STRICT_YAML_DEFAULT_CLEANUP_README.md new file mode 100644 index 0000000..3452dde --- /dev/null +++ b/RETRIEX_PATCH_11_0A_STRICT_YAML_DEFAULT_CLEANUP_README.md @@ -0,0 +1,43 @@ +# RetrieX Patch 11.0a - Strict YAML Default Cleanup + +This patch removes the remaining model-generation constructor defaults and cleans up two CommerceQueryParser audit false positives. + +## Scope + +Changed files: + +- `src/Config/ModelGenerationDefaultsConfig.php` +- `src/Config/CommerceQueryParserConfig.php` + +## What changed + +### ModelGenerationDefaultsConfig + +The constructor no longer contains PHP fallback values for model defaults. All values must now come from the existing Symfony service parameters, which are backed by `config/retriex/model.yaml`: + +- `retriex.model.default_name` +- `retriex.model.default_stream` +- `retriex.model.default_temperature` +- `retriex.model.default_top_k` +- `retriex.model.default_top_p` +- `retriex.model.default_repeat_penalty` +- `retriex.model.default_num_ctx` +- `retriex.model.default_retrieval_max_chunks` +- `retriex.model.default_retrieval_vector_top_k` + +### CommerceQueryParserConfig + +The whitespace-preserving normalization lists now use a dedicated helper instead of passing `true` as a second argument to `stringList()`. This keeps behavior unchanged, but prevents the source audit from interpreting the boolean argument as a PHP fallback. + +## Intentional non-changes + +No retrieval, prompt, shop, agent, SSE, or runtime behavior was changed. + +## Recommended validation + +```bash +php bin/console cache:clear +php bin/console mto:agent:config:validate +php bin/console mto:agent:config:audit-source --details +php bin/console mto:agent:regression:test +``` diff --git a/src/Config/AgentRunnerConfig.php b/src/Config/AgentRunnerConfig.php index 86c0a56..9626cb6 100644 --- a/src/Config/AgentRunnerConfig.php +++ b/src/Config/AgentRunnerConfig.php @@ -39,43 +39,6 @@ final class AgentRunnerConfig return $this->getRequiredString('optimized_shop_query_trim_characters'); } - private function getInt(string $key, int $default): int - { - $value = $this->value($key, $default); - - return is_numeric($value) ? (int) $value : $default; - } - - private function getBool(string $key, bool $default): bool - { - $value = $this->value($key, $default); - - if (is_bool($value)) { - return $value; - } - - if (is_scalar($value)) { - $normalized = strtolower(trim((string) $value)); - - if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) { - return true; - } - - if (in_array($normalized, ['0', 'false', 'no', 'off'], true)) { - return false; - } - } - - return $default; - } - - private function getString(string $key, string $default): string - { - $value = $this->value($key, $default); - - return is_string($value) && $value !== '' ? $value : $default; - } - private function getRequiredInt(string $key): int { $value = $this->requiredValue($key); @@ -233,49 +196,6 @@ final class AgentRunnerConfig return $out; } - /** - * @param string[] $default - * @return string[] - */ - private function getStringList(string $key, array $default): array - { - $value = $this->value($key, $default); - - if (!is_array($value)) { - return $default; - } - - $out = []; - - foreach ($value as $item) { - if (!is_scalar($item)) { - continue; - } - - $item = trim((string) $item); - - if ($item !== '') { - $out[] = $item; - } - } - - return $out !== [] ? $out : $default; - } - - private function value(string $key, mixed $default): mixed - { - $current = $this->config; - - foreach (explode('.', $key) as $segment) { - if (!is_array($current) || !array_key_exists($segment, $current)) { - return $default; - } - - $current = $current[$segment]; - } - - return $current; - } private function requiredValue(string $key): mixed { diff --git a/src/Config/CommerceQueryParserConfig.php b/src/Config/CommerceQueryParserConfig.php index 7a99566..6e17bb6 100644 --- a/src/Config/CommerceQueryParserConfig.php +++ b/src/Config/CommerceQueryParserConfig.php @@ -48,6 +48,35 @@ final class CommerceQueryParserConfig return $this->stringList('filter_search_tokens'); } + /** @return string[] */ + private function whitespacePreservingStringList(string $path): array + { + $value = $this->value($path); + if (!is_array($value)) { + throw $this->invalid($path, 'must be a list of non-empty strings'); + } + + $out = []; + foreach ($value as $item) { + if (!is_scalar($item)) { + continue; + } + + $item = (string) $item; + if (trim($item) === '' || in_array($item, $out, true)) { + continue; + } + + $out[] = $item; + } + + if ($out === []) { + throw $this->invalid($path, 'must contain at least one non-empty string'); + } + + return $out; + } + /** @return array */ public function getSearchTokenCorrections(): array { @@ -73,13 +102,13 @@ final class CommerceQueryParserConfig /** @return string[] */ public function getNormalizationSearch(): array { - return $this->stringList('normalization.search', true); + return $this->whitespacePreservingStringList('normalization.search'); } /** @return string[] */ public function getNormalizationReplace(): array { - return $this->stringList('normalization.replace', true); + return $this->whitespacePreservingStringList('normalization.replace'); } public function getPromptSanitizePattern(): string @@ -249,7 +278,7 @@ final class CommerceQueryParserConfig } /** @return string[] */ - private function stringList(string $path, bool $preserveWhitespace = false): array + private function stringList(string $path): array { $value = $this->value($path); if (!is_array($value)) { @@ -262,12 +291,9 @@ final class CommerceQueryParserConfig continue; } - $item = (string) $item; - if (!$preserveWhitespace) { - $item = trim($item); - } + $item = trim((string) $item); - if (trim($item) === '' || in_array($item, $out, true)) { + if ($item === '' || in_array($item, $out, true)) { continue; } diff --git a/src/Config/ModelGenerationDefaultsConfig.php b/src/Config/ModelGenerationDefaultsConfig.php index 5b3e2c4..55be56f 100644 --- a/src/Config/ModelGenerationDefaultsConfig.php +++ b/src/Config/ModelGenerationDefaultsConfig.php @@ -7,15 +7,15 @@ namespace App\Config; final readonly class ModelGenerationDefaultsConfig { public function __construct( - private string $modelName = 'mto-model', - private bool $stream = false, - private float $temperature = 0.1, - private int $topK = 20, - private float $topP = 0.8, - private float $repeatPenalty = 1.05, - private int $numCtx = 4096, - private int $retrievalMaxChunks = 25, - private int $retrievalVectorTopK = 25, + private string $modelName, + private bool $stream, + private float $temperature, + private int $topK, + private float $topP, + private float $repeatPenalty, + private int $numCtx, + private int $retrievalMaxChunks, + private int $retrievalVectorTopK, ) { }