Route definitional questions to the narrative docs, and tolerate misspelling

"What is Varaverk" matched the PURPOSE intent, so retrieval returned every
script's one-line purpose and the model answered that the context does not
define the system — while README.md sat in the index unread. A definitional
question with no explicit filter now goes to kind=readme.

Varaverk is a coined word with no spell-check, so it arrives as varavrk,
veraverk, varavek. Edit distance catches those without a pattern that needs
extending per typo. This is search, not identity — a near-miss only widens a
document search, unlike hostname resolution where it must never resolve.
This commit is contained in:
Gmer4Lfe
2026-08-03 18:17:56 -04:00
parent 9d189e9dbf
commit 452bf0e544
2 changed files with 37 additions and 1 deletions
+8 -1
View File
@@ -107,6 +107,12 @@ $tRetrieve = 0.0;
if ($profile === 'varaverk') {
jw($jobFile, ['status' => 'retrieving']);
// A definitional question with no explicit filter goes to the narrative docs. Left alone,
// intent routing boosts PURPOSE and returns every script's one-line purpose, so the model
// reports that the context does not define Varaverk while README.md sits in the index
// unread. An explicit --kind from the user always wins.
if ($kind === '' && vv_ai_is_definitional($question)) $kind = 'readme';
$r = vv_ai_retrieve($question, $kind);
if (!$r['ok']) {
jw($jobFile, ['status' => 'error', 'error' => $r['error'] ?? 'retrieval failed']);
@@ -265,7 +271,8 @@ if ($diagBlock !== '') {
// ignore. Detection only ever makes the model MORE cautious, so a false positive costs a
// redirect rather than a wrong answer.
if ($profile === 'chat'
&& preg_match('/\b[\w.-]+\.sh\b|\b[A-Z][A-Z0-9]*(_[A-Z0-9]+)+\b|\bvaraverk\b/', $question)) {
&& (vv_ai_mentions_varaverk($question)
|| preg_match('/\b[\w.-]+\.sh\b|\b[A-Z][A-Z0-9]*(_[A-Z0-9]+)+\b/', $question))) {
$system .= "NOTE: the operator's message appears to name a specific Varaverk component. "
. "You cannot see the documentation in this mode, so you do not know what it does. "
. "Say that plainly, point them at the Varaverk Assistant profile, and do not "