Verify a bug report's component and evidence before filing it
This commit is contained in:
@@ -94,6 +94,14 @@ function jw(string $f, array $d): void {
|
||||
file_put_contents($f, json_encode($d));
|
||||
}
|
||||
|
||||
// Same log the endpoint writes to, tagged so the two are tellable apart. Defined here because
|
||||
// vv_ai_log() belongs to api/ai.php and this runs detached, with no endpoint in the process.
|
||||
function wlog(string $msg): void {
|
||||
if (!is_dir('/var/log/varaverk')) return;
|
||||
@file_put_contents('/var/log/varaverk/ai.log',
|
||||
date('Y-m-d H:i:s') . ' worker ' . $msg . "\n", FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
$cfg = vv_ai_config();
|
||||
$t0 = microtime(true);
|
||||
|
||||
@@ -489,12 +497,40 @@ if ($profile === 'troubleshoot'
|
||||
// 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,
|
||||
]);
|
||||
$component = $field('component');
|
||||
|
||||
// Guard one: the component must be a real file here. A report against a path that does not
|
||||
// exist is the model naming something plausible rather than something it saw.
|
||||
//
|
||||
// Guard two: the quoted evidence must actually appear in the log it was given. This is what
|
||||
// keeps "misconfigured" out of the bug list — a genuine defect is visible in the log, while
|
||||
// a setting being false produces no such line, so an invented quote fails here instead of
|
||||
// becoming a report someone has to disprove.
|
||||
//
|
||||
// When no log was available there is nothing to check against; the report is still filed,
|
||||
// because live health state is real evidence too, but it is marked unverified and says so
|
||||
// on the card. Refusals are logged rather than swallowed — how often the model tries to file
|
||||
// junk is worth knowing, and silence would hide it.
|
||||
$verified = $scopedLog && !empty($scopedLog['ok'])
|
||||
? vv_ai_evidence_in_log($ev, $scopedLog['tail'] ?? [])
|
||||
: null;
|
||||
|
||||
if (!vv_ai_component_exists($component)) {
|
||||
wlog('bug refused: component not a real file — ' . mb_substr($component, 0, 80));
|
||||
$res = ['ok' => false];
|
||||
} elseif ($verified === false) {
|
||||
wlog('bug refused: evidence not found in ' . ($scopedLog['path'] ?? '?')
|
||||
. ' — ' . mb_substr(preg_replace('/\s+/', ' ', $ev), 0, 100));
|
||||
$res = ['ok' => false];
|
||||
} else {
|
||||
$res = vv_ai_bug_write($component, $field('summary'), $ev, [
|
||||
'asked' => mb_substr($question, 0, 300),
|
||||
'scope' => $scope,
|
||||
'log' => $scopedLog['path'] ?? null,
|
||||
'verified' => $verified,
|
||||
'profile' => $profile,
|
||||
]);
|
||||
}
|
||||
if ($res['ok']) {
|
||||
$bugFiled = $res;
|
||||
// Say what actually happened, not what sounds reassuring. This is written to a file on
|
||||
|
||||
Reference in New Issue
Block a user