feat(runtime): scheduler-via-runSkill + Pi banter escalation + base-site (follow-ups) (#20)
Three closures of remaining PRD follow-ups, one merge:
1. Reflex scheduler now drives behaviour from the curriculum.
- reflex.js: replaced ad-hoc techTreeReflex + autonomousReflex with
curriculumReflex that dispatches the skill suggested by
snapshot.curriculum.plan via runSkill. Per-skill backoff for
missing_tool / missing_material / no_target / no_food_source /
unsupported_version. recover() hint with `{hint:"wander"}` swaps
the next tick to wander for 60 s.
- Chain is now: defend > eat > sleep > curriculum > idle.
- reflex.test.js: 11 new tests covering busy/disconnected,
defend/eat preemption, dispatch by id, unknown-skill fallback,
per-skill + wander-hint backoffs, onComplete updating backoff.
2. Pi escalation for ADDRESSED_BANTER with hard rate limit.
- bot.js: when generateReply returns {escalate:true}, spawn askPi
with bot state + last 5 lines from that speaker (redacted via
chatMemory). Reply capped at 200 chars, sent as one chat line.
- Rate cap: 6 calls/hour, 90 s min gap. Suppressed escalations
log once and silently drop.
3. Phase 4 substrate.
- runtime/locations.js: atomic JSON store
(state/<host>/locations.json) with setLocation / getLocation /
nearestLocation / removeLocation; 6 tests.
- runtime/base-site.js: scoreCurrentPosition(bot) + pure scoreSite
bundle (wood / stone / water / flatness / no-players /
no-foreign-builds, owned-blocks excluded from claim penalty);
6 tests.
- runtime/skills/choose-base.js: village.choose-base skill — scores
the current spot, writes locations.base if score ≥ 8, otherwise
returns code:"too_weak" with a wander recover hint.
- curriculum.js: new final milestone village.base-site fires
village.choose-base until a base location exists.
- bot.js: stamps snapshot.locations from listLocations() each tick
so the curriculum can read it without coupling to disk.
docs/runtime.md updated with three new sections.
npm test now 116/116.
Co-authored-by: Yuriy Mayatnikov <mayatnikov@me.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #20.
This commit is contained in:
@@ -122,7 +122,10 @@ test("all done → null", () => {
|
||||
stone_axe: 1, stone_pickaxe: 1, stone_sword: 1, furnace: 1,
|
||||
bread: 4, chest: 1, torch: 8,
|
||||
};
|
||||
assert.equal(nextMilestone(snap(inv, { food: 20 })), null);
|
||||
assert.equal(
|
||||
nextMilestone(snap(inv, { food: 20, locations: { base: { x: 0, y: 64, z: 0 } } })),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test("isInventoryFull threshold = 32 distinct stacks", () => {
|
||||
@@ -146,7 +149,7 @@ test("inventoryFull flag is returned alongside milestone, not as override", () =
|
||||
test("listMilestones exposes ordered ids for diary/TUI", () => {
|
||||
const ms = listMilestones();
|
||||
assert.equal(ms[0].id, "wood.16");
|
||||
assert.equal(ms[ms.length - 1].id, "shelter.torch");
|
||||
assert.equal(ms[ms.length - 1].id, "village.base-site");
|
||||
for (const m of ms) {
|
||||
assert.equal(typeof m.id, "string");
|
||||
assert.equal(typeof m.title, "string");
|
||||
|
||||
Reference in New Issue
Block a user