v0.3.0-rc.1: live skill registry + fast advisor scaffold

Roots out the v0.2.x failure mode: Pi-extracted lessons routinely named
hallucinated skill ids (relocate.surface, choose.safe.surface,
survive.shelter, gather.visible_log, …). All 47 Pi-lessons in the live DB
had applied_count=0 because normalisePreferSkill couldn't find them.

Fix:
1. runtime/skill-registry.js — single source of truth derived from
   skills/index.js. Exports listSkillIds, isRegistered, and a
   prompt-ready block (skillRegistryPrompt) grouped by namespace.
2. Pi prompts (coach/postmortem, coach/reflect) embed the live registry
   with a "USE ONLY THESE, never invent" instruction. Lessons are
   filtered at write-time too — anything not in the registry and not a
   known mode name gets dropped.
3. coach/advice.js — normalisePreferSkill now returns null for unknown
   ids, hardening consult() against any hallucinations that slip
   through. Warn-logged for visibility.

Also lays the LLM substrate for the rest of v0.3.0:

- runtime/llm/provider.js — OpenAI-compatible chat client. Configured
  via PEPA_FAST_LLM_{BASE_URL,API_KEY,MODEL,TIMEOUT_MS}. Safe no-op
  unless API_KEY is set. Supports JSON-mode.
- runtime/coach/fast-advisor.js — tactical advisor tier (scaffold).
  Exposes advise() that asks the fast LLM what to do RIGHT NOW when
  the reflex is wedged/stuck. Rejects hallucinated skill ids using the
  registry. Rate-limited 6/h, 30s cooldown. Not auto-triggered yet —
  wired into reflex in rc.3 (awareness layer).

Tests: 279 green (+24 vs rc.3): 5 registry, 9 provider, 10 advisor.

See dev/v0.3.0/PLAN.md for the full iteration design (manifesto needs
ladder, event-driven awareness, skill pre-emption) and STATUS.md for
shipped/pending tracking.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 17:39:43 +03:00
co-authored by Claude Opus 4.7
parent 865aae1213
commit fcfa2277ba
13 changed files with 1113 additions and 20 deletions
+65
View File
@@ -0,0 +1,65 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import {
listSkillIds,
isRegistered,
describeSkill,
skillRegistryPrompt,
} from "./skill-registry.js";
test("registry: lists at least the known v0.2 skill set", () => {
const ids = listSkillIds();
assert.ok(ids.length >= 20, `expected 20+ skills, got ${ids.length}`);
for (const must of [
"gather.logs",
"survive.eat",
"survive.sleep",
"survive.flee",
"survive.pillar-up",
"explore.far",
"explore.wander",
"recovery.tunnel-out",
"village.choose-base",
"village.build-shelter",
]) {
assert.ok(ids.includes(must), `registry missing ${must}`);
}
});
test("isRegistered: true for real, false for hallucinated", () => {
assert.equal(isRegistered("survive.flee"), true);
assert.equal(isRegistered("relocate.surface"), false);
assert.equal(isRegistered("choose.safe.surface"), false);
assert.equal(isRegistered("gather.visible_log"), false);
assert.equal(isRegistered("survive.shelter"), false);
assert.equal(isRegistered("tunnel-out"), false, "missing recovery. prefix");
assert.equal(isRegistered(null), false);
assert.equal(isRegistered(""), false);
assert.equal(isRegistered(42), false);
});
test("describeSkill: returns shape for known id", () => {
const s = describeSkill("survive.pillar-up");
assert.ok(s, "expected description");
assert.equal(s.id, "survive.pillar-up");
assert.ok(typeof s.timeoutMs === "number" && s.timeoutMs > 0);
});
test("registryPrompt: contains the real ids grouped by namespace", () => {
const txt = skillRegistryPrompt();
assert.match(txt, /Valid skill ids/);
assert.match(txt, /survive:/);
assert.match(txt, /- survive\.flee/);
assert.match(txt, /- recovery\.tunnel-out/);
assert.match(txt, /NEVER invent/);
// must NOT contain hallucinated ids
assert.doesNotMatch(txt, /relocate\.surface/);
assert.doesNotMatch(txt, /survive\.shelter[^-]/);
});
test("registryPrompt: respects limit parameter", () => {
const short = skillRegistryPrompt({ limit: 200 });
assert.ok(short.length <= 200, `expected <=200, got ${short.length}`);
assert.ok(short.endsWith("..."));
});