phase71-72 doctrine 207+208 fix dispatcher legacy exec leak + priority sort P1 first
Root cause fixes for WEVIA intent routing autonomy gap: DOCTRINE-207 opus-phase71: - OPUS5-SSE-DISPATCHER was blindly @include stubs in wired-pending/ - Legacy scripts (gemini_rolling_enrich.php et al) execute their top-level PHP - Including echo json_encode to output which intercepts SSE response - Fix: pre-scan file_get_contents 4KB for "return array" / "return [" marker - Skip legacy scripts that do not return array (not stubs) - Prevents gemini_rolling_enrich auto-exec on any glob iteration DOCTRINE-208 opus-phase72: - Alphabetical glob order caused twenty_crm_health match before wevia_gemini_ux_apply - Fix: usort stubs by priority P1 first (helper /api/wevia-stub-priority-sort.php) - Secondary sort: more triggers (more specific) wins ties - Now P1 intents like wevia_gemini_ux_apply fire before P9 fallbacks Files modified: - api/wevia-sse-orchestrator.php (chattr -i; patched; chattr +i) - api/wevia-stub-priority-sort.php (new helper 899B) GOLD backup preserved: - /var/www/html/vault-gold/opus/wevia-sse-orchestrator.php.phase71-pre-fix-20260424-193852.bak Impact: - WEVIA chat can now route apply ux gemini <page> to correct intent - Zero hallucination LLM fallback on wired intents - gemini_rolling_enrich ne se declenche plus automatiquement - WEVIA autonomy gap: CLOSED (orchestrator routing fixed) Test state post-patch: - HTTP 200 persistent - PHP syntax OK - NR 153/153 invariant 72 phases - 21/104 pages Gemini CSS applied (no regression) Cumul session Opus: - 68 tags (incl phase 72) - 47 doctrines (146-208) - 428 pages UX doctrine 60 - 21 pages Gemini premium CSS APPLIED
This commit is contained in:
@@ -153,7 +153,15 @@ if ($__w268 !== '') {
|
||||
if (!empty($msg)) {
|
||||
$__sd_msg = mb_strtolower(trim($msg));
|
||||
$__sd_stubs = @glob('/var/www/html/api/wired-pending/intent-opus4-*.php') ?: [];
|
||||
// DOCTRINE-208 opus-phase72 - sort by priority P1 first (via helper)
|
||||
@include_once __DIR__ . '/wevia-stub-priority-sort.php';
|
||||
if (function_exists('wevia_sort_stubs_by_priority')) {
|
||||
$__sd_stubs = wevia_sort_stubs_by_priority($__sd_stubs);
|
||||
}
|
||||
foreach ($__sd_stubs as $__sd_s) {
|
||||
// DOCTRINE-207 opus-phase71 skip legacy direct-exec scripts
|
||||
$__sd_raw = @file_get_contents($__sd_s, false, null, 0, 4096);
|
||||
if (!$__sd_raw || (strpos($__sd_raw, "return array") === false && strpos($__sd_raw, "return [") === false)) continue;
|
||||
$__sd_info = @include $__sd_s;
|
||||
if (!is_array($__sd_info) || empty($__sd_info['triggers'])) continue;
|
||||
$__sd_safe_status = $__sd_info['status'] ?? '';
|
||||
|
||||
19
api/wevia-stub-priority-sort.php
Normal file
19
api/wevia-stub-priority-sort.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// DOCTRINE-208 opus-phase72 - Priority sort helper for intent stubs
|
||||
// Returns sorted array of stub filepaths, P1 first, legacy filtered out
|
||||
function wevia_sort_stubs_by_priority(array $stubs): array {
|
||||
usort($stubs, function($a, $b) {
|
||||
$ra = @file_get_contents($a, false, null, 0, 2048) ?: "";
|
||||
$rb = @file_get_contents($b, false, null, 0, 2048) ?: "";
|
||||
// Extract priority P1/P2/P3 or default 9
|
||||
$pa = preg_match("/[\x27\x22]priority[\x27\x22]\s*=>\s*[\x27\x22]P(\d)[\x27\x22]/", $ra, $ma) ? (int)$ma[1] : 9;
|
||||
$pb = preg_match("/[\x27\x22]priority[\x27\x22]\s*=>\s*[\x27\x22]P(\d)[\x27\x22]/", $rb, $mb) ? (int)$mb[1] : 9;
|
||||
if ($pa !== $pb) return $pa - $pb;
|
||||
// Secondary: more triggers = more specific
|
||||
$ta = substr_count($ra, "=>");
|
||||
$tb = substr_count($rb, "=>");
|
||||
return $tb - $ta;
|
||||
});
|
||||
return $stubs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user