feat(runtime): wedged-cant-escape proposal trigger (self-improvement v2)

Closes the self-improvement loop: when escape-pit + wedged-jump +
blind fallback all run 3× in a row without freeing the bot, fire a
dedicated proposal at the auto-improver. Pi gets the full context
(journal byKind, last 12 scenario-memory entries, current slim
snapshot) and is asked to either improve escapePit() (dig forward +
down + side, not only up) OR add a brand-new recovery.tunnel-out skill.

- runtime/stuck-incident.js: new checkWedged() path with separate
  cooldown (10 min) from the no-progress path. noteResult() ingests
  every dispatched action's detail.mode to count wedged completions.
- runtime/bot.js: dispatchAction calls stuckIncident.noteResult(res)
  after each result; tick() calls checkWedged() and files the proposal
  via writeProposal({editScope:[runtime/actions.js, runtime/skills/,
  runtime/reflex.js]}).

This is the architectural piece: a bot wedged in a 1×1 hole now
generates a proposal that Pi can act on (with edit-scope guard rails
+ npm test smoke gate from PR #19), instead of looping wedged-jump
forever.

Verified live: bot now also picks direction from journal —
"explore.far: journal says leanest quadrant=NE → prefer N" — first
time the bot uses persistent memory to choose where to go next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-26 12:24:22 +03:00
co-authored by Claude Opus 4.7
parent d960db4819
commit a57625b541
2 changed files with 130 additions and 1 deletions
+27
View File
@@ -245,6 +245,7 @@ function dispatchAction(fn, label, opts = {}) {
detail: res?.detail,
});
recordWorldDeltaToJournal(label, res, startSnap);
stuckIncident.noteResult(res);
if (!ok) {
lastFailureAt = lastResult.ts;
recordFailure(label, res?.detail);
@@ -797,6 +798,32 @@ function tick() {
}
}
// Second fast-track trigger: explicit wedged loop (escape-pit ran N
// times in a row without freeing the bot). Auto-improve picks this
// up like any other proposal — Pi writes a new escape strategy.
const wedged = stuckIncident.checkWedged({
snapshot: lastSnapshot,
lastResult,
metrics: lastSnapshot.skillMetrics,
journalSummary: worldJournal.summary(),
scenarioTail: scenarioMemory.recentTailFor({ n: 12 }),
now,
});
if (wedged?.fire) {
try {
const { filename } = writeProposal({
kind: wedged.kind,
summary: wedged.summary,
body: wedged.body,
editScope: wedged.editScope,
});
warn("wedged", `filed ${filename}: ${wedged.summary}`);
appendDiary(`wedged-proposal filed: ${filename}`);
} catch (e) {
warn("wedged", `writeProposal failed: ${e.message}`);
}
}
ipc?.broadcast(EVENT_TYPES.STATUS, lastSnapshot);
} else {
lastSnapshot = { connected: false };