File AI-detected Varaverk defects as deduped reports, surfaced on the AI tab and counted in the coffee report

This commit is contained in:
Gmer4Lfe
2026-08-05 20:48:54 -04:00
parent 9d4a62fa5e
commit 2c5e412d91
5 changed files with 213 additions and 1 deletions
+42 -1
View File
@@ -278,7 +278,19 @@ if ($profile === 'chat') {
. "sends someone hunting through code they did not write and cannot fix, which is "
. "the least useful place you can send them.\n\n"
. "Do not suggest editing conf files by hand. Settings on this page have controls, "
. "and the operator is reading this inside the WebGUI. Name the control.\n\n";
. "and the operator is reading this inside the WebGUI. Name the control.\n\n"
. "IF IT REALLY IS A DEFECT, FILE IT\n"
. "When — and only when — the evidence shows Varaverk itself misbehaving rather than "
. "a setting, finish your reply with exactly this block so it gets recorded:\n\n"
. "[VARAVERK-BUG]\n"
. "component: <the script or file at fault, e.g. Arrs_Stack/arr_sync.sh>\n"
. "summary: <one line, what is wrong>\n"
. "evidence: <the log line or lines that show it, quoted verbatim>\n"
. "[/VARAVERK-BUG]\n\n"
. "Leave the block out entirely for anything explained by configuration, by a host "
. "being offline, or by a job simply not having run. The evidence field is not "
. "optional and must be a line you actually saw — a report nobody can check is worse "
. "than no report, because it costs someone an investigation to disprove.\n\n";
} elseif ($profile === 'code') {
$system = "You are drafting a short shell script for the operator of an Unraid server, to be "
@@ -461,6 +473,35 @@ if ($profile === 'code' && preg_match_all('/```(?:\w+)?\n(.*?)```/s', $answer, $
}
}
// Pull the bug block out of the answer and file it. Stripped from what the operator sees — the
// block is a machine contract, not prose — and replaced with a one-line confirmation so the
// filing is never silent. A malformed or evidence-free block is dropped rather than filed:
// the guard lives here, in code, not in the instruction that asked for it. A prompt is a
// request; this is the part that decides.
$bugFiled = null;
if ($profile === 'troubleshoot'
&& preg_match('/\[VARAVERK-BUG\](.*?)\[\/VARAVERK-BUG\]/s', $answer, $bm)) {
$answer = trim(preg_replace('/\[VARAVERK-BUG\].*?\[\/VARAVERK-BUG\]/s', '', $answer));
$field = function (string $k) use ($bm): string {
return preg_match('/^\s*' . $k . '\s*:\s*(.+?)\s*$/mi', $bm[1], $m) ? trim($m[1]) : '';
};
// evidence may run to several lines; take everything after the label.
$ev = preg_match('/^\s*evidence\s*:\s*(.*)$/mis', $bm[1], $em) ? trim($em[1]) : '';
$res = vv_ai_bug_write($field('component'), $field('summary'), $ev, [
'asked' => mb_substr($question, 0, 300),
'scope' => $scope,
'log' => $scopedLog['path'] ?? null,
'profile' => $profile,
]);
if ($res['ok']) {
$bugFiled = $res;
$answer .= "\n\n_Filed as bug " . $res['id']
. ($res['seen'] > 1 ? ' — seen ' . $res['seen'] . ' times' : '') . "._";
}
}
$evalCount = (int)($d['eval_count'] ?? 0);
$evalNs = (int)($d['eval_duration'] ?? 0);
$tokS = $evalNs > 0 ? round($evalCount / ($evalNs / 1e9), 1) : null;