From da4be8defcd126d7f762c46542aba304b0bdf4e8 Mon Sep 17 00:00:00 2001 From: Opus Date: Thu, 23 Apr 2026 23:38:30 +0200 Subject: [PATCH] auto-sync via WEVIA git_sync_all intent 2026-04-23T23:38:30+02:00 --- api/blade-actions-surfaced.json | 2 +- api/handlers/create-intent-from-chat.sh | 117 ++++++++++-------- api/v83-business-kpi-latest.json | 2 +- api/wave-wiring-queue.json | 10 ++ api/wevia-autowire-trigger.php | 49 ++++++++ api/wevia-master-api.php | 2 + .../intent-opus4-opus_w287_council_v2.php | 12 ++ ...intent-opus4-test_autowire_doctrine152.php | 13 ++ .../intent-opus4-wevia-rollback-list.php | 16 +++ .../intent-opus4-wtp_orphans_link_status.php | 13 ++ api/wtp-gap3-ux-overlap.sh | 1 + api/wtp-gap4-cf-bypass.sh | 1 + api/wtp-gap5-widget-root.sh | 1 + 13 files changed, 185 insertions(+), 54 deletions(-) create mode 100644 api/wired-pending/intent-opus4-opus_w287_council_v2.php create mode 100644 api/wired-pending/intent-opus4-test_autowire_doctrine152.php create mode 100644 api/wired-pending/intent-opus4-wevia-rollback-list.php create mode 100644 api/wired-pending/intent-opus4-wtp_orphans_link_status.php create mode 120000 api/wtp-gap3-ux-overlap.sh create mode 120000 api/wtp-gap4-cf-bypass.sh create mode 120000 api/wtp-gap5-widget-root.sh diff --git a/api/blade-actions-surfaced.json b/api/blade-actions-surfaced.json index a53ab4404..a8b159b71 100644 --- a/api/blade-actions-surfaced.json +++ b/api/blade-actions-surfaced.json @@ -1,5 +1,5 @@ { - "generated_at": "2026-04-23T23:30:02.293986", + "generated_at": "2026-04-23T23:35:02.446758", "stats": { "total": 52, "pending": 33, diff --git a/api/handlers/create-intent-from-chat.sh b/api/handlers/create-intent-from-chat.sh index 5fb7ba9e5..279f2e8da 100755 --- a/api/handlers/create-intent-from-chat.sh +++ b/api/handlers/create-intent-from-chat.sh @@ -1,11 +1,16 @@ #!/bin/bash # Opus v5.8 doctrine #7: WEVIA creates new intents from chat directly # Usage: message format = "create intent NAME :: TRIGGERS :: COMMAND" -# WEVIA parses, writes handler shell, adds intent, flips to EXECUTED +# DOCTRINE-152 fix: reads message from /tmp/wevia-last-msg.log (dispatcher writes it) +# Try args first (backward compat), then fallback to log file MSG="${1:-}" -# Parse: NAME :: TRIGGERS :: COMMAND -NAME=$(echo "$MSG" | awk -F' :: ' '{print $1}' | sed 's/create intent //I' | tr -d '[:space:]' | tr -cd '[:alnum:]_') +if [ -z "$MSG" ] && [ -f /tmp/wevia-last-msg.log ]; then + MSG=$(cat /tmp/wevia-last-msg.log 2>/dev/null | tr -d '\n' | head -c 2000) +fi + +# Parse: NAME :: TRIGGERS :: COMMAND +NAME=$(echo "$MSG" | awk -F' :: ' '{print $1}' | sed 's/create intent //I' | sed 's/new intent //I' | sed 's/wire intent //I' | sed 's/build intent //I' | tr -d '[:space:]' | tr -cd '[:alnum:]_') TRIGGERS=$(echo "$MSG" | awk -F' :: ' '{print $2}') CMD=$(echo "$MSG" | awk -F' :: ' '{print $3}') @@ -13,59 +18,67 @@ if [ -z "$NAME" ] || [ -z "$TRIGGERS" ] || [ -z "$CMD" ]; then cat < /tmp/auto-$NAME.sh <&1 | head -c 2000) -cat </dev/null -sudo chown www-data:www-data "$HANDLER" 2>/dev/null -sudo chmod +x "$HANDLER" 2>/dev/null - -# 2. Call WEVIA master add intent API -ADD_RESULT=$(curl -s -X POST "https://127.0.0.1/api/wevia-master-api.php" -k \ - -H "Host: weval-consulting.com" -H "Content-Type: application/json" \ - -d "{\"message\":\"master add intent $NAME :: $TRIGGERS :: $HANDLER\"}" --max-time 10) - -# 3. Flip stub to EXECUTED -STUB=/var/www/html/api/wired-pending/intent-opus4-$NAME.php -if [ -f "$STUB" ]; then - sudo sed -i "s/'PENDING_APPROVAL'/'EXECUTED'/g" "$STUB" - FLIPPED=true -else - FLIPPED=false +# Safety: command must start with whitelisted prefix +CMD_SAFE=0 +for prefix in "/var/www/html/" "echo " "curl " "grep " "psql " "cat /var/log/"; do + case "$CMD" in + "$prefix"*) CMD_SAFE=1; break ;; + esac +done +if [ $CMD_SAFE -eq 0 ]; then + echo "{\"ok\":false,\"error\":\"cmd must start with safe prefix\",\"name\":\"$NAME\"}" + exit 0 fi -cat < /tmp/intent-${NAME}.php < '${NAME}', + 'triggers' => + array ( +${TRIG_PHP} ), + 'cmd' => '${CMD_CLEAN}', + 'status' => 'EXECUTED', + 'created_at' => '${TS}', + 'source' => 'wevia-autowire-via-chat-doctrine152', +); +PHPEOF + +# Lint check +LINT=$(php -l /tmp/intent-${NAME}.php 2>&1 | head -1) +if echo "$LINT" | grep -q "No syntax errors"; then + sudo cp /tmp/intent-${NAME}.php "$INTENT_FILE" 2>/dev/null + sudo chmod 644 "$INTENT_FILE" 2>/dev/null + echo "{\"ok\":true,\"name\":\"$NAME\",\"triggers\":\"$TRIGGERS\",\"cmd\":\"$CMD_CLEAN\",\"file\":\"$INTENT_FILE\",\"ts\":\"$TS\",\"doctrine\":\"152\"}" +else + echo "{\"ok\":false,\"error\":\"lint failed\",\"lint\":\"$LINT\"}" +fi diff --git a/api/v83-business-kpi-latest.json b/api/v83-business-kpi-latest.json index 470d671d1..f485beb59 100644 --- a/api/v83-business-kpi-latest.json +++ b/api/v83-business-kpi-latest.json @@ -1,7 +1,7 @@ { "ok": true, "version": "V83-business-kpi", - "ts": "2026-04-23T21:32:40+00:00", + "ts": "2026-04-23T21:35:39+00:00", "summary": { "total_categories": 8, "total_kpis": 64, diff --git a/api/wave-wiring-queue.json b/api/wave-wiring-queue.json index 3df790024..abe42bdb6 100644 --- a/api/wave-wiring-queue.json +++ b/api/wave-wiring-queue.json @@ -10593,5 +10593,15 @@ "status": "PENDING_APPROVAL", "created_at": "2026-04-23T21:30:49+00:00", "source": "opus4-autowire-early-v2" + }, + "862": { + "name": "opus_w287_council_v2", + "triggers": [ + "opus w287 council v2" + ], + "cmd": "mkdir -p \/tmp\/council 2>\/dev\/null; Q=\"En une phrase: pourquoi WEVIA est plus autonome que Opus?\"; (curl -sS -m 12 -X POST http:\/\/localhost:4000\/v3\/chat -H \"Content-Type: application\/json\" -d \"{\\\"message\\\":\\\"$Q\\\",\\\"provider\\\":\\\"cerebras\\\"}\" > \/tmp\/council\/cer.json 2>&1) & (curl -sS -m 12 -X POST http:\/\/localhost:4000\/v3\/chat -H \"Content-Type: application\/json\" -d \"{\\\"message\\\":\\\"$Q\\\",\\\"provider\\\":\\\"groq\\\"}\" > \/tmp\/council\/groq.json 2>&1) & (curl -sS -m 15 -X POST http:\/\/localhost:11434\/api\/chat -H \"Content-Type: application\/json\" -d \"{\\\"model\\\":\\\"llama3.2:latest\\\",\\\"messages\\\":[{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"$Q\\\"}],\\\"stream\\\":false}\" > \/tmp\/council\/oll.json 2>&1) & wait; echo CER; head -c 250 \/tmp\/council\/cer.json 2>\/dev\/null; echo; echo GROQ; head -c 250 \/tmp\/council\/groq.json 2>\/dev\/null; echo; echo OLL; head -c 250 \/tmp\/council\/oll.json 2>\/dev\/null", + "status": "PENDING_APPROVAL", + "created_at": "2026-04-23T21:37:43+00:00", + "source": "opus4-autowire-early-v2" } } \ No newline at end of file diff --git a/api/wevia-autowire-trigger.php b/api/wevia-autowire-trigger.php index 9ec8c0a98..3f8c54228 100644 --- a/api/wevia-autowire-trigger.php +++ b/api/wevia-autowire-trigger.php @@ -77,6 +77,55 @@ if ($action === 'apply-preset') { exit; } +// ROLLBACK (doctrine 153) +if ($action === 'rollback') { + $marker = $_GET['marker'] ?? $_POST['marker'] ?? ''; + $target = $_GET['target'] ?? $_POST['target'] ?? ''; + $marker = preg_replace('/[^a-zA-Z0-9\-_]/','', $marker); + if ($target && !str_starts_with($target, '/var/www/html/')) { + echo json_encode(['ok'=>false,'err'=>'target_outside_whitelist']); exit; + } + if (!$marker && !$target) { + echo json_encode(['ok'=>false,'err'=>'marker_or_target_required']); exit; + } + $env = []; + if ($marker) $env[] = 'MARKER=' . escapeshellarg($marker); + if ($target) $env[] = 'TARGET=' . escapeshellarg($target); + $cmd = 'timeout 30 sudo env ' . implode(' ', $env) . ' bash /opt/wevia-brain/scripts/wevia-rollback.sh 2>&1'; + $output = @shell_exec($cmd); + $parsed = json_decode(trim((string)$output), true); + if (!is_array($parsed)) { + $lines = explode(" +", trim((string)$output)); + foreach (array_reverse($lines) as $l) { + $p = json_decode(trim($l), true); + if (is_array($p)) { $parsed = $p; break; } + } + } + echo json_encode(['ok'=>true,'action'=>'rollback','marker'=>$marker,'target'=>$target,'raw_output'=>trim((string)$output),'result'=>$parsed], JSON_UNESCAPED_SLASHES); + exit; +} + +// LIST GOLD backups (doctrine 153) +if ($action === 'list-gold') { + $golds = []; + foreach (glob('/var/www/html/*.html.GOLD-*') as $g) { + $basename = basename($g); + if (preg_match('/^(.+?)\.html\.GOLD-([0-9\-]+)-pre-(.+)$/', $basename, $m)) { + $golds[] = [ + 'file' => $basename, + 'page' => $m[1] . '.html', + 'timestamp' => $m[2], + 'marker_slug' => $m[3], + 'size_bytes' => filesize($g), + ]; + } + } + usort($golds, fn($a,$b) => strcmp($b['timestamp'], $a['timestamp'])); + echo json_encode(['ok'=>true,'count'=>count($golds),'golds'=>$golds], JSON_PRETTY_PRINT); + exit; +} + // Classic whitelist action if (!$action || !isset($whitelist[$action])) { echo json_encode([ diff --git a/api/wevia-master-api.php b/api/wevia-master-api.php index 2870cbadc..79a3e5f77 100644 --- a/api/wevia-master-api.php +++ b/api/wevia-master-api.php @@ -341,6 +341,8 @@ if (isset($_mam) && $_mam) { if (stripos($__sd_cmd, $__sd_p) === 0 || stripos($__sd_cmd, " $__sd_p") !== false) { $__sd_safe = true; break; } } if (!$__sd_safe) continue; + // DOCTRINE-152-FIX: log message for handlers that need the user input (create_intent_from_chat etc.) + @file_put_contents('/tmp/wevia-last-msg.log', (string)$_mam, LOCK_EX); $__sd_out = @shell_exec('timeout 15 ' . $__sd_cmd . ' 2>&1'); if (trim((string)$__sd_out) === '') continue; header('Content-Type: application/json'); diff --git a/api/wired-pending/intent-opus4-opus_w287_council_v2.php b/api/wired-pending/intent-opus4-opus_w287_council_v2.php new file mode 100644 index 000000000..f85ef2086 --- /dev/null +++ b/api/wired-pending/intent-opus4-opus_w287_council_v2.php @@ -0,0 +1,12 @@ + 'opus_w287_council_v2', + 'triggers' => + array ( + 0 => 'opus w287 council v2', + ), + 'cmd' => 'mkdir -p /tmp/council 2>/dev/null; Q="En une phrase: pourquoi WEVIA est plus autonome que Opus?"; (curl -sS -m 12 -X POST http://localhost:4000/v3/chat -H "Content-Type: application/json" -d "{\\"message\\":\\"$Q\\",\\"provider\\":\\"cerebras\\"}" > /tmp/council/cer.json 2>&1) & (curl -sS -m 12 -X POST http://localhost:4000/v3/chat -H "Content-Type: application/json" -d "{\\"message\\":\\"$Q\\",\\"provider\\":\\"groq\\"}" > /tmp/council/groq.json 2>&1) & (curl -sS -m 15 -X POST http://localhost:11434/api/chat -H "Content-Type: application/json" -d "{\\"model\\":\\"llama3.2:latest\\",\\"messages\\":[{\\"role\\":\\"user\\",\\"content\\":\\"$Q\\"}],\\"stream\\":false}" > /tmp/council/oll.json 2>&1) & wait; echo CER; head -c 250 /tmp/council/cer.json 2>/dev/null; echo; echo GROQ; head -c 250 /tmp/council/groq.json 2>/dev/null; echo; echo OLL; head -c 250 /tmp/council/oll.json 2>/dev/null', + 'status' => 'PENDING_APPROVAL', + 'created_at' => '2026-04-23T21:37:43+00:00', + 'source' => 'opus4-autowire-early-v2', +); diff --git a/api/wired-pending/intent-opus4-test_autowire_doctrine152.php b/api/wired-pending/intent-opus4-test_autowire_doctrine152.php new file mode 100644 index 000000000..694cd4e74 --- /dev/null +++ b/api/wired-pending/intent-opus4-test_autowire_doctrine152.php @@ -0,0 +1,13 @@ + 'test_autowire_doctrine152', + 'triggers' => + array ( + 0 => 'test autowire doctrine 152', + 1 => 'verify autowire wevia doctrine 152', + ), + 'cmd' => 'echo DOCTRINE-152-AUTOWIRE-OK', + 'status' => 'EXECUTED', + 'created_at' => '2026-04-23T23:36:22+02:00', + 'source' => 'wevia-autowire-via-chat-doctrine152', +); diff --git a/api/wired-pending/intent-opus4-wevia-rollback-list.php b/api/wired-pending/intent-opus4-wevia-rollback-list.php new file mode 100644 index 000000000..60d77bf54 --- /dev/null +++ b/api/wired-pending/intent-opus4-wevia-rollback-list.php @@ -0,0 +1,16 @@ + 'wevia_rollback_list', + 'triggers' => array( + 0 => 'list gold backups', + 1 => 'wevia gold list', + 2 => 'rollback list', + 3 => 'liste gold', + 4 => 'backups disponibles', + ), + 'cmd' => 'curl -sk "https://weval-consulting.com/api/wevia-autowire-trigger.php?action=list-gold"', + 'status' => 'EXECUTED', + 'source' => 'opus-doctrine-153', + 'priority_tier' => '00', + 'description' => 'Liste les GOLD backups disponibles pour rollback.', +); diff --git a/api/wired-pending/intent-opus4-wtp_orphans_link_status.php b/api/wired-pending/intent-opus4-wtp_orphans_link_status.php new file mode 100644 index 000000000..0d67ecb29 --- /dev/null +++ b/api/wired-pending/intent-opus4-wtp_orphans_link_status.php @@ -0,0 +1,13 @@ + 'wtp_orphans_link_status', + 'triggers' => + array ( + 0 => 'wtp orphans rattachement status', + 1 => 'verifie rattachement orphelines wtp registry', + ), + 'cmd' => '/var/www/html/api/wtp-orphans-link-check.sh', + 'status' => 'EXECUTED', + 'created_at' => '2026-04-23T23:36:46+02:00', + 'source' => 'wevia-autowire-via-chat-doctrine152', +); diff --git a/api/wtp-gap3-ux-overlap.sh b/api/wtp-gap3-ux-overlap.sh new file mode 120000 index 000000000..27604ee79 --- /dev/null +++ b/api/wtp-gap3-ux-overlap.sh @@ -0,0 +1 @@ +/var/www/html/api/wtp-golive-gap3-ux-overlap.sh \ No newline at end of file diff --git a/api/wtp-gap4-cf-bypass.sh b/api/wtp-gap4-cf-bypass.sh new file mode 120000 index 000000000..f7c451530 --- /dev/null +++ b/api/wtp-gap4-cf-bypass.sh @@ -0,0 +1 @@ +/var/www/html/api/wtp-golive-gap4-cf-bypass.sh \ No newline at end of file diff --git a/api/wtp-gap5-widget-root.sh b/api/wtp-gap5-widget-root.sh new file mode 120000 index 000000000..fa13b79a4 --- /dev/null +++ b/api/wtp-gap5-widget-root.sh @@ -0,0 +1 @@ +/var/www/html/api/wtp-golive-gap5-widget-root.sh \ No newline at end of file