Stop proposing to remember what the UI map already says
The map documents 447 settings, so without this every question about where a control lives earns a proposal that costs a dismissal and teaches nothing.
This commit is contained in:
@@ -111,6 +111,28 @@ function vv_ai_mem_is_dup(string $text, ?array $known = null): bool {
|
||||
// rather than stating a fact, and it would eat the budget it is competing for.
|
||||
const VV_AI_MEM_MAX_LINE = 220;
|
||||
|
||||
// Where a setting lives in the UI is documented, and documentation does not belong in memory —
|
||||
// memory is for what the documents cannot tell you. The UI map made this a real problem rather
|
||||
// than a theoretical one: it describes 447 settings, so without this the assistant will propose
|
||||
// "X is on the Settings tab" over and over, each one costing a dismissal.
|
||||
//
|
||||
// Gated on WHICH document the candidate is nearest to, not on how near. A plain score threshold
|
||||
// was tried first and does not separate these: a genuine fact about rsync scores 0.78 against
|
||||
// rsync.sh because it is about rsync, higher than the junk proposal that started this at 0.75.
|
||||
// Similarity measures topic, not novelty. But the junk lands on the UI map and nothing worth
|
||||
// remembering ever has — that is a difference in kind, and kind is what the index records.
|
||||
const VV_AI_MEM_UI_NEAR = 0.62;
|
||||
|
||||
function vv_ai_mem_is_ui_fact(string $text): bool {
|
||||
// Retrieval needs the index and the embedder. If either is unavailable the answer is "not
|
||||
// provably documented", which files the proposal — the operator can still dismiss it, and
|
||||
// failing closed here would silently stop learning whenever Ollama was restarting.
|
||||
$r = @vv_ai_retrieve($text, '', '', 1);
|
||||
if (empty($r['ok']) || empty($r['results'])) return false;
|
||||
$top = $r['results'][0];
|
||||
return ($top['kind'] ?? '') === 'ui' && (float) ($top['score'] ?? 0) >= VV_AI_MEM_UI_NEAR;
|
||||
}
|
||||
|
||||
function vv_ai_mem_propose(string $text, array $meta = []): array {
|
||||
if (!vv_ai_mem_learn_enabled()) return ['ok' => false, 'error' => 'learning disabled'];
|
||||
|
||||
@@ -118,6 +140,7 @@ function vv_ai_mem_propose(string $text, array $meta = []): array {
|
||||
if ($text === '') return ['ok' => false, 'error' => 'empty'];
|
||||
if (mb_strlen($text) > VV_AI_MEM_MAX_LINE) return ['ok' => false, 'error' => 'too long'];
|
||||
if (vv_ai_mem_is_dup($text)) return ['ok' => false, 'error' => 'duplicate'];
|
||||
if (vv_ai_mem_is_ui_fact($text)) return ['ok' => false, 'error' => 'already in the UI map'];
|
||||
|
||||
$id = substr(hash('sha256', $text . microtime(true)), 0, 12);
|
||||
$row = [
|
||||
|
||||
Reference in New Issue
Block a user