feat(runtime): stuck-incident detector + skill metrics (Phase 6) #17

Merged
halofourteen merged 1 commits from feat/survival-pivot-phase-6 into main 2026-05-25 22:35:01 +03:00
halofourteen commented 2026-05-25 22:34:54 +03:00 (Migrated from github.com)

Summary

Phase 6 of plans/autonomous-survival-bot-prd.md. Self-improvement v2:
the bot can spot no-progress stagnation, not just exception-class
failures, and the proposal it writes carries a structured edit scope.

  • runtime/stuck-incident.js — when the same noProgressReason
    persists for ≥5 min, files a proposal whose body includes
    runtimeState, the milestone, the suggested skill,
    a slim snapshot, last action result, per-skill success/failure
    metrics, and an explicit edit-scope list. Cooldown 30 min.
  • runtime/skill-metrics.js — in-memory per-skill ok/fail
    counters. Stamped on snapshot.skillMetrics.
  • runtime/state-store.jswriteProposal({editScope})
    persists the allowed paths in frontmatter;
    readProposalEditScope(filename) reads them back so future
    scripts/auto-patch.js can refuse cherry-picks that touch other
    areas.
  • runtime/bot.js — tick() invokes the detector each tick;
    dispatchAction records into skillMetrics on both the resolved
    result and the exception path.
  • Tests — 6 new tests in runtime/stuck-incident.test.js. npm test is now 46/46.

Remaining for true Phase 6 completion: actually wiring
scripts/auto-patch.js to honour editScope and to run npm test
before cherry-pick. Tracked in the PRD checklist.

Test plan

  • npm test — 46/46
  • Detector ignores null/empty reasons
  • Detector does not fire before threshold
  • Reason change resets the timer (no premature fire)
  • Cooldown blocks back-to-back firings
  • Body includes milestone + suggested skill + metrics
  • Skill metrics record both ok and fail counters
  • Live-server: stuck on no_food_source → exactly one proposal
    in 5 min, with editScope: [runtime/skills/survive-eat.js, …]

🤖 Generated with Claude Code

## Summary Phase 6 of `plans/autonomous-survival-bot-prd.md`. Self-improvement v2: the bot can spot **no-progress stagnation**, not just exception-class failures, and the proposal it writes carries a structured edit scope. - **`runtime/stuck-incident.js`** — when the same `noProgressReason` persists for ≥5 min, files a proposal whose body includes `runtimeState`, the milestone, the suggested skill, a slim snapshot, last action result, per-skill success/failure metrics, and an explicit edit-scope list. Cooldown 30 min. - **`runtime/skill-metrics.js`** — in-memory per-skill ok/fail counters. Stamped on `snapshot.skillMetrics`. - **`runtime/state-store.js`** — `writeProposal({editScope})` persists the allowed paths in frontmatter; `readProposalEditScope(filename)` reads them back so future `scripts/auto-patch.js` can refuse cherry-picks that touch other areas. - **`runtime/bot.js`** — tick() invokes the detector each tick; dispatchAction records into `skillMetrics` on both the resolved result and the exception path. - **Tests** — 6 new tests in `runtime/stuck-incident.test.js`. `npm test` is now 46/46. Remaining for true Phase 6 completion: actually wiring `scripts/auto-patch.js` to honour `editScope` and to run `npm test` before cherry-pick. Tracked in the PRD checklist. ## Test plan - [x] `npm test` — 46/46 - [x] Detector ignores null/empty reasons - [x] Detector does not fire before threshold - [x] Reason change resets the timer (no premature fire) - [x] Cooldown blocks back-to-back firings - [x] Body includes milestone + suggested skill + metrics - [x] Skill metrics record both ok and fail counters - [ ] Live-server: stuck on `no_food_source` → exactly one proposal in 5 min, with `editScope: [runtime/skills/survive-eat.js, …]` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.