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
20 lines
899 B
PHP
20 lines
899 B
PHP
<?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;
|
|
}
|
|
|