Send all health checks as live state, not only the failing ones

Asked what was wrong, it answered "AI_ENABLED=false" — read from the conf
template, which records the shipped default, while the live value was true.
Passing checks are what tell the model the current value of a setting;
without them a documented default fills the silence. The prompt now states
explicitly that live state overrides any documented default.
This commit is contained in:
Gmer4Lfe
2026-08-02 17:45:41 -04:00
parent 69ffb5e1dc
commit 198532e280
+23 -12
View File
@@ -135,15 +135,20 @@ $diagnostic = (bool)preg_match(
$diagBlock = '';
if ($diagnostic) {
$bad = array_filter(vv_ai_health(), fn($c) => in_array($c['state'], ['bad', 'warn'], true));
if ($bad) {
$diagBlock .= "CURRENT CONFIGURATION PROBLEMS\n";
foreach ($bad as $c) {
$diagBlock .= '- [' . strtoupper($c['state']) . '] ' . $c['label'] . ': ' . $c['detail']
. ($c['fix'] !== '' ? ' — ' . $c['fix'] : '') . "\n";
}
$diagBlock .= "\n";
// Every check, not only the failing ones. Passing checks are what tell the model the
// current value of a setting — without them it has no live signal for anything healthy,
// and a documented default fills the gap. That produced a confidently wrong answer:
// asked what was wrong, it reported "AI_ENABLED=false" read from the conf *template*
// while the live value was true. Documentation records defaults; only this block records
// what is actually set.
$diagBlock .= "LIVE SYSTEM STATE (authoritative — measured just now)\n";
foreach (vv_ai_health() as $c) {
$mark = ['ok' => 'OK', 'warn' => 'WARNING', 'bad' => 'PROBLEM'][$c['state']] ?? '?';
$diagBlock .= '- [' . $mark . '] ' . $c['label'] . ': ' . $c['detail']
. ($c['state'] !== 'ok' && $c['fix'] !== '' ? ' — FIX: ' . $c['fix'] : '') . "\n";
}
$diagBlock .= "\n";
$logs = vv_ai_recent_logs(40);
if ($logs) {
$diagBlock .= "RECENT WARNINGS AND ERRORS (newest last)\n" . implode("\n", $logs) . "\n\n";
@@ -159,10 +164,16 @@ $system = "You are Varaverk's documentation assistant. Varaverk is this user's p
if ($diagBlock !== '') {
$system .= "This is a diagnostic question, so live system state is included alongside the "
. "documentation. Use the passages to explain how the thing is supposed to work, "
. "and the live state to say what is actually wrong. When a configuration problem "
. "is listed, name the specific setting and the file it lives in. Log lines are "
. "evidence, not citations — cite only the numbered passages.\n\n"
. "documentation.\n\n"
. "CRITICAL: where the live state contradicts anything in the passages, the live "
. "state is correct. The passages include conf templates and design notes that "
. "record DEFAULT values, not this system's current ones — a template showing "
. "AI_ENABLED=false says what a fresh install ships with, never what is set here. "
. "Never report a documented default as the current value.\n\n"
. "Use the passages to explain how a thing is supposed to work, and the live state "
. "to say what is actually happening. When a problem is listed, name the specific "
. "setting and the file it lives in. Log lines are evidence, not citations — cite "
. "only the numbered passages.\n\n"
. $diagBlock;
}