Verify a bug report's component and evidence before filing it

This commit is contained in:
Gmer4Lfe
2026-08-05 21:25:00 -04:00
parent 657ee435d1
commit 269ef9b2de
3 changed files with 81 additions and 7 deletions
+36
View File
@@ -815,6 +815,42 @@ function vv_ai_bug_file(array $r): string {
return vv_ai_bugs_dir() . '/' . substr(sha1(strtolower($r['component'] . '|' . $r['summary'])), 0, 12) . '.json';
}
// Does the quoted evidence actually appear in the log the model was shown?
//
// The prompt asks for a verbatim line. This checks it, because "manufactured a cause to have
// one" is the specific failure this profile was warned against and warnings are not guards —
// the same reason General Chat needed a regex behind its instruction, not just a firmer wording.
//
// Whitespace-normalised and matched on the longest quoted fragment: the model reliably keeps the
// text and unreliably keeps the indentation. A short fragment would match by coincidence, so
// anything under 25 characters is not treated as a match at all.
function vv_ai_evidence_in_log(string $evidence, array $tail): bool {
if (!$tail) return false;
$norm = fn(string $s) => preg_replace('/\s+/', ' ', trim($s));
$hay = ' ' . implode(' ⏎ ', array_map($norm, $tail)) . ' ';
$frags = array_filter(array_map($norm, preg_split('/\R/', $evidence)),
fn($l) => mb_strlen($l) >= 25);
usort($frags, fn($a, $b) => mb_strlen($b) <=> mb_strlen($a));
foreach (array_slice($frags, 0, 5) as $f) {
if (str_contains($hay, $f)) return true;
// Allow a trimmed tail of the fragment — models often drop a trailing clause.
$head = mb_substr($f, 0, max(25, (int)(mb_strlen($f) * 0.6)));
if (mb_strlen($head) >= 25 && str_contains($hay, $head)) return true;
}
return false;
}
// Is the named component a real file in this installation? A defect report against a path that
// does not exist is a confabulation, and it is free to check.
function vv_ai_component_exists(string $component): bool {
$c = trim($component);
if ($c === '' || !vv_ai_scope_ok($c)) return false;
$base = realpath(SCRIPTS_DIR);
$p = realpath(SCRIPTS_DIR . '/' . $c);
return $base !== false && $p !== false && str_starts_with($p, $base . '/') && is_file($p);
}
function vv_ai_bug_write(string $component, string $summary, string $evidence, array $ctx = []): array {
$component = trim($component);
$summary = trim($summary);