feat(runtime): skill substrate + dynamic groups (Phase 2) #14

Merged
halofourteen merged 1 commits from feat/survival-pivot-phase-2 into main 2026-05-25 22:15:57 +03:00
halofourteen commented 2026-05-25 22:15:50 +03:00 (Migrated from github.com)

Summary

Phase 2 of plans/autonomous-survival-bot-prd.md: composable skill
contract per PRD §5.2, with version-safe registry-derived groups.

  • runtime/skills/index.js — registry + runSkill(id, ctx, args).
    Enforces preconditions, hard timeout, normalises every result to
    {ok, code, detail, worldDelta}, runs validate() and calls
    recover() on failure. Stable codes via RUNNER_CODES.
  • runtime/skills/groups.js — dynamic logs, planks, sticks,
    beds, foods, axes, pickaxes, swords derived from
    bot.registry. Empty set on missing registry → skills emit
    code:"unsupported_version" rather than throwing.
  • Reference skillsgather.logs, survive.eat, explore.wander
    wrap existing actions.js primitives behind the new contract.
  • Testsnpm test runs 14 tests covering precondition gating,
    timeout firing recover(), execute exceptions, validate flipping
    ok→false, mock-registry group filtering.

Reflex.js still calls actions.js directly; wiring the scheduler to
runSkill() lands in later phases when the survival curriculum kicks
in (Phase 3).

Test plan

  • npm test — 14/14 passing
  • Unknown skill → unknown_skill
  • Failing preconditions short-circuit execute
  • Timeout fires recover()
  • validate() failure flips ok→false with validation_failed
  • Groups handle missing registry (empty set, no throw)
  • foods() excludes hazardous items (spider_eye, rotten_flesh)

🤖 Generated with Claude Code

## Summary Phase 2 of `plans/autonomous-survival-bot-prd.md`: composable skill contract per PRD §5.2, with version-safe registry-derived groups. - **`runtime/skills/index.js`** — registry + `runSkill(id, ctx, args)`. Enforces preconditions, hard timeout, normalises every result to `{ok, code, detail, worldDelta}`, runs `validate()` and calls `recover()` on failure. Stable codes via `RUNNER_CODES`. - **`runtime/skills/groups.js`** — dynamic `logs`, `planks`, `sticks`, `beds`, `foods`, `axes`, `pickaxes`, `swords` derived from `bot.registry`. Empty set on missing registry → skills emit `code:"unsupported_version"` rather than throwing. - **Reference skills** — `gather.logs`, `survive.eat`, `explore.wander` wrap existing `actions.js` primitives behind the new contract. - **Tests** — `npm test` runs 14 tests covering precondition gating, timeout firing `recover()`, execute exceptions, validate flipping `ok→false`, mock-registry group filtering. Reflex.js still calls `actions.js` directly; wiring the scheduler to `runSkill()` lands in later phases when the survival curriculum kicks in (Phase 3). ## Test plan - [x] `npm test` — 14/14 passing - [x] Unknown skill → `unknown_skill` - [x] Failing preconditions short-circuit `execute` - [x] Timeout fires `recover()` - [x] `validate()` failure flips `ok→false` with `validation_failed` - [x] Groups handle missing registry (empty set, no throw) - [x] `foods()` excludes hazardous items (`spider_eye`, `rotten_flesh`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.