This commit is contained in:
team 1
2026-05-01 09:24:46 +02:00
parent 0442a24d4c
commit 0c7fca9b46
5 changed files with 128 additions and 97 deletions

View File

@@ -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.

View File

@@ -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
```

View File

@@ -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
{

View File

@@ -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<string, string> */
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;
}

View File

@@ -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,
) {
}