fix(v0.3.1): sated bot stops chasing food + perf-leak + fuzzy improvement dedup

Third day of "bot just walks back and forth burning tokens". Root
causes were mechanical, not the manifesto:

1. SATED BOT CHASING FOOD (the big one)
   Bot had food=17 (nearly full) but storyline first_food + manifesto
   L1 required 2+ food ITEMS in inventory, so it looped scout-food /
   acquire-food for hours instead of working. Now both treat a hunger
   bar >= 14 (SATED_FOOD) as satisfied even with empty food inventory —
   a full bot chops wood / makes tools and grabs food opportunistically,
   only hard-pursuing food when actually hungry (< 14).
   manifesto/needs.js foodDetect + goal/storyline.js first_food.completed.

2. perf_hooks MEMORY LEAK (overnight OOM suspect)
   "MaxPerformanceEntryBufferExceededWarning: 1,000,001 measure entries".
   mineflayer/pathfinder emit perf marks we never consume. Added a
   60s reaper in bot.js (performance.clearMeasures/clearMarks). unref'd.

3. IMPROVEMENT QUEUE SELF-DUPLICATING
   The LLM re-filed closed gaps with reworded titles (#5/#8/#9 were
   dupes of implemented #1/#2/#3). Exact-title dedup missed them.
   Replaced with token-set fuzzy match (isDuplicateTitle): jaccard>=0.75
   OR >=3 shared meaningful tokens with jaccard>=0.5. Also: a re-filed
   gap that's already implemented/rejected is NOT resurrected as a new
   open row. Cleared all 5 open requests (now genuinely implemented).

Also confirmed (no change needed):
- canDig=true is a DELIBERATE codebase-wide choice ("without it the bot
  gets permanently stuck", actions.js). The stale memory recommending
  canDig=false is updated. ViaBackwards dig works partially (dug:1
  moved:1.8 observed); false would trap the bot in every pit.
- scout-food already has blind/tunnel fallback + 12s step timeout
  (operator's earlier edits) so trapped-pathfinder degrades instead of
  hanging 30s.

Tests: 407 green (was 404). Updated needs/state/storyline tests for the
SATED_FOOD threshold; added fuzzy-dedup + tokenize/jaccard tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 09:34:42 +03:00
co-authored by Claude Opus 4.7
parent 1cf60f81e9
commit 502d7ebae4
7 changed files with 153 additions and 25 deletions
+9 -8
View File
@@ -232,16 +232,17 @@ export const STORYLINE = Object.freeze([
title: "Найти первую еду",
narration_ru: "Нужна еда — ищу корову, курицу или ягоды.",
completed(snap) {
return countAny(snap?.inventory, FOOD_ITEMS) >= 2;
// Done if we have a stock (≥2 food items) OR the hunger bar is
// comfortable (≥14). A sated bot should be chopping wood, not
// chasing a chicken it doesn't need — it'll grab food
// opportunistically when one wanders close.
if (countAny(snap?.inventory, FOOD_ITEMS) >= 2) return true;
if ((snap?.food ?? 20) >= 14) return true;
return false;
},
suggestSkill(snap) {
// Two-tier strategy:
// - If a passive food mob is visible nearby (≤24 blocks in
// snapshot), kill it locally with acquire-food.
// - Otherwise scout-food does long-range biome-aware search.
// It commits to a cardinal for ~200 blocks, rescans, and
// on biome boundary detection heads toward food-capable
// terrain.
// Only reached when the bot is actually hungry (food < 14) and
// has no stock. Local mob → acquire-food; else long-range scout.
if (hasLocalFoodMob(snap)) return { skillId: "survive.acquire-food" };
return { skillId: "survive.scout-food" };
},
+7 -3
View File
@@ -73,10 +73,14 @@ test("step first_tools: requires all three wood tools", () => {
assert.equal(s.completed(snap({ inventory: { stone_pickaxe: 1, stone_axe: 1, stone_sword: 1 } })), true);
});
test("step first_food: completed at ≥2 food items", () => {
test("step first_food: completed at ≥2 food items, OR when sated (food≥14)", () => {
const s = getStep("first_food");
assert.equal(s.completed(snap()), false);
assert.equal(s.completed(snap({ inventory: { bread: 2 } })), true);
// hungry + no food → not done
assert.equal(s.completed(snap({ food: 8 })), false);
// hungry + 2 food items → done (have a stock)
assert.equal(s.completed(snap({ food: 8, inventory: { bread: 2 } })), true);
// sated (food≥14) + no food → done (don't chase food while full)
assert.equal(s.completed(snap({ food: 17 })), true);
});
test("step first_food: local hunt only for edible passive mobs within acquire range", () => {