Files
html/api/opus-arch-self-refactor.php
opus 6931d33a7d
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
V39 architect final: 7 remaining R&D caps wired (4/9/10/11/13/15/16) + doctrines 94-100
2026-04-17 19:26:56 +02:00

31 lines
1.4 KiB
PHP

<?php
// opus-arch-self-refactor.php - Cap 9 (Doctrine 95)
header('Content-Type: application/json');
$action = $_GET['action'] ?? 'status';
$sandbox = '/opt/weval-ops/refactor-sandbox';
if ($action === 'status') {
echo json_encode([
'ok'=>true,
'sandbox_exists'=>is_dir($sandbox),
'docker_available'=>!empty(shell_exec('which docker 2>/dev/null')),
'note'=>'Self-refactor requires Docker sandbox + nonreg validator. Use action=propose to queue refactor.',
]); exit;
}
if ($action === 'propose') {
$description = $_POST['description'] ?? '';
$target = $_POST['target'] ?? '';
if (!$description || !$target) { echo json_encode(['ok'=>false,'error'=>'description+target required']); exit; }
$queue = $sandbox . '/queue.json';
@mkdir($sandbox, 0755, true);
$q = file_exists($queue) ? json_decode(file_get_contents($queue), true) : [];
$q[] = ['id'=>uniqid(), 'ts'=>date('c'), 'description'=>$description, 'target'=>$target, 'status'=>'pending'];
file_put_contents($queue, json_encode($q, JSON_PRETTY_PRINT));
echo json_encode(['ok'=>true, 'queued'=>count($q)]); exit;
}
if ($action === 'queue') {
$queue = $sandbox . '/queue.json';
echo json_encode(['ok'=>true, 'queue'=>file_exists($queue) ? json_decode(file_get_contents($queue), true) : []]); exit;
}
echo json_encode(['ok'=>false, 'actions'=>['status','propose','queue']]);