fix(v0.3.1): mechanical food/stuck fixes — bot reaches the chicken now
The wedge wasn't only in the manifesto layer; several mechanical bugs kept the bot in a dead random-walk: - storyline / manifesto / curriculum: "local food" now means an edible passive mob within <=32 blocks. A distant chicken or a cod no longer fools the bot into dispatching acquire-food (which then fails on no_path). Long-range food goes through scout-food instead. - scout-food: partial approach to a target now counts as progress (approached_target, e.g. moved:14); a blocked heading is NOT counted as movement; added blind/tunnel fallback so it doesn't die when the pathfinder can't route cleanly. - acquire-food: on no_path it now also tries a blind/tunnel approach to the animal; no_drop routes back into food scouting instead of giving up. - explore.far / relocate / flee: fewer false "done" results (micro-steps no longer counted as success), more genuine escapes from stuck. - scripts/show-story.js: live IPC now actually renders the current storyline step. Verification: scripts/lint-patch.js clean; npm test 404/404 green; bot relaunched in tmux `pepa`. Live logs show real progress — bot switched to survive.scout-food, approached the chicken (approached_target moved:14), then reached survive.acquire-food: hunting chicken. Food isn't fully closed yet but the remaining issue is concrete pickup/drop, not dead random-walk. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { runSkill, RUNNER_CODES, _registerForTest } from "./index.js";
|
||||
import { __testing as scoutFoodTesting } from "./scout-food.js";
|
||||
|
||||
const ctx = {}; // skills under test ignore ctx fully
|
||||
|
||||
@@ -37,6 +38,27 @@ test("preconditions gate execution", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("precondition failures can return recovery hints", async () => {
|
||||
const teardown = _registerForTest({
|
||||
id: "test.precondition-recover",
|
||||
title: "blocked with recovery",
|
||||
timeoutMs: 1000,
|
||||
preconditions: () => ({ ok: false, code: "no_target", detail: "none nearby" }),
|
||||
execute: async () => {
|
||||
throw new Error("should not run");
|
||||
},
|
||||
recover: (_ctx, result) => ({ hint: "scout-food", saw: result.code }),
|
||||
});
|
||||
try {
|
||||
const res = await runSkill("test.precondition-recover", ctx);
|
||||
assert.equal(res.ok, false);
|
||||
assert.equal(res.code, "no_target");
|
||||
assert.deepEqual(res.recovery, { hint: "scout-food", saw: "no_target" });
|
||||
} finally {
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
|
||||
test("gather.logs precondition refuses nearby hostiles", async () => {
|
||||
const bot = { registry: { blocksByName: { oak_log: { id: 1 } } } };
|
||||
const res = await runSkill("gather.logs", {
|
||||
@@ -48,6 +70,18 @@ test("gather.logs precondition refuses nearby hostiles", async () => {
|
||||
assert.match(res.detail, /unsafe to gather logs: drowned 6\.1 blocks away/);
|
||||
});
|
||||
|
||||
test("scout-food progress counts intended cardinal, not sideways tunnel drift", () => {
|
||||
const north = scoutFoodTesting.CARDINALS.find((c) => c.name === "N");
|
||||
assert.deepEqual(
|
||||
scoutFoodTesting.cardinalProgress({ x: 0, z: 0 }, { x: 0, z: -9 }, north),
|
||||
{ along: 9, total: 9, driftName: "N" },
|
||||
);
|
||||
assert.deepEqual(
|
||||
scoutFoodTesting.cardinalProgress({ x: 0, z: 0 }, { x: 9, z: 0 }, north),
|
||||
{ along: 0, total: 9, driftName: "E" },
|
||||
);
|
||||
});
|
||||
|
||||
test("preconditions that throw produce precondition_failed", async () => {
|
||||
const teardown = _registerForTest({
|
||||
id: "test.precondition-throw",
|
||||
|
||||
Reference in New Issue
Block a user