From 6c2c595a1c82e22fa00429d10e4d230b2c15f65a Mon Sep 17 00:00:00 2001 From: team 1 Date: Thu, 30 Apr 2026 18:41:26 +0200 Subject: [PATCH] patch 9 --- ...ATCH_9_0A_PROMPT_BASIS_YAML_ONLY_README.md | 33 ++++++++++ src/Config/PromptBuilderConfig.php | 61 +++++++++++++++---- 2 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 RETRIEX_PATCH_9_0A_PROMPT_BASIS_YAML_ONLY_README.md diff --git a/RETRIEX_PATCH_9_0A_PROMPT_BASIS_YAML_ONLY_README.md b/RETRIEX_PATCH_9_0A_PROMPT_BASIS_YAML_ONLY_README.md new file mode 100644 index 0000000..fb48821 --- /dev/null +++ b/RETRIEX_PATCH_9_0A_PROMPT_BASIS_YAML_ONLY_README.md @@ -0,0 +1,33 @@ +# RetrieX Patch 9.0a - PromptBuilder basis YAML-only + +This patch converts only the simple PromptBuilder basis, budget and shop-result limit values to required YAML configuration access. + +Changed file: + +- `src/Config/PromptBuilderConfig.php` + +Converted to required YAML-only access: + +- `budget.chars_per_token` +- `budget.history_padding_chars` +- `budget.output_reserve_ratio` +- `budget.output_reserve_min_tokens` +- `budget.output_reserve_max_tokens` +- `budget.safety_reserve_ratio` +- `budget.safety_reserve_min_tokens` +- `budget.safety_reserve_max_tokens` +- `budget.min_prompt_budget_tokens` +- `shop_results.max_results_in_prompt` +- `shop_results.detailed_max_count` +- `technical_product_keyword_match_threshold` + +No prompt wording rules, fact-grounding rules, retrieval logic, shop logic, AgentRunner logic, or SSE/frontend code is changed. + +After applying, run: + +```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/PromptBuilderConfig.php b/src/Config/PromptBuilderConfig.php index 3c4df76..14fa0c1 100644 --- a/src/Config/PromptBuilderConfig.php +++ b/src/Config/PromptBuilderConfig.php @@ -156,62 +156,62 @@ final class PromptBuilderConfig public function getCharsPerToken(): int { - return $this->getInt('budget.chars_per_token', 4); + return $this->getRequiredInt('budget.chars_per_token'); } public function getHistoryPaddingChars(): int { - return $this->getInt('budget.history_padding_chars', 400); + return $this->getRequiredInt('budget.history_padding_chars'); } public function getOutputReserveRatio(): float { - return $this->getFloat('budget.output_reserve_ratio', 0.25); + return $this->getRequiredFloat('budget.output_reserve_ratio'); } public function getOutputReserveMinTokens(): int { - return $this->getInt('budget.output_reserve_min_tokens', 768); + return $this->getRequiredInt('budget.output_reserve_min_tokens'); } public function getOutputReserveMaxTokens(): int { - return $this->getInt('budget.output_reserve_max_tokens', 6000); + return $this->getRequiredInt('budget.output_reserve_max_tokens'); } public function getSafetyReserveRatio(): float { - return $this->getFloat('budget.safety_reserve_ratio', 0.05); + return $this->getRequiredFloat('budget.safety_reserve_ratio'); } public function getSafetyReserveMinTokens(): int { - return $this->getInt('budget.safety_reserve_min_tokens', 256); + return $this->getRequiredInt('budget.safety_reserve_min_tokens'); } public function getSafetyReserveMaxTokens(): int { - return $this->getInt('budget.safety_reserve_max_tokens', 1024); + return $this->getRequiredInt('budget.safety_reserve_max_tokens'); } public function getMinPromptBudgetTokens(): int { - return $this->getInt('budget.min_prompt_budget_tokens', 1024); + return $this->getRequiredInt('budget.min_prompt_budget_tokens'); } public function getMaxShopResultsInPrompt(): int { - return $this->getInt('shop_results.max_results_in_prompt', 24); + return $this->getRequiredInt('shop_results.max_results_in_prompt'); } public function getDetailedShopResultsMaxCount(): int { - return $this->getInt('shop_results.detailed_max_count', 5); + return $this->getRequiredInt('shop_results.detailed_max_count'); } public function getTechnicalProductKeywordMatchThreshold(): int { - return $this->getInt('technical_product_keyword_match_threshold', 2); + return $this->getRequiredInt('technical_product_keyword_match_threshold'); } private function getInt(string $path, int $default): int @@ -228,6 +228,28 @@ final class PromptBuilderConfig return is_numeric($value) ? (float) $value : $default; } + private function getRequiredInt(string $path): int + { + $value = $this->getRequiredValue($path); + + if (!is_numeric($value)) { + throw new \InvalidArgumentException(sprintf('RetrieX prompt config value "%s" must be numeric.', $path)); + } + + return (int) $value; + } + + private function getRequiredFloat(string $path): float + { + $value = $this->getRequiredValue($path); + + if (!is_numeric($value)) { + throw new \InvalidArgumentException(sprintf('RetrieX prompt config value "%s" must be numeric.', $path)); + } + + return (float) $value; + } + private function getString(string $path, string $default): string { $value = $this->getValue($path, $default); @@ -292,6 +314,21 @@ final class PromptBuilderConfig return $current; } + private function getRequiredValue(string $path): mixed + { + $current = $this->config; + + foreach (explode('.', $path) as $segment) { + if (!is_array($current) || !array_key_exists($segment, $current)) { + throw new \InvalidArgumentException(sprintf('Missing required RetrieX prompt config path "%s".', $path)); + } + + $current = $current[$segment]; + } + + return $current; + } + public function getSystemSectionLabel(): string { return $this->getString('sections.system_label', 'SYSTEM');