feat(v0.4.1): make the Settlement Contract honest end-to-end

Patches each link of the closed-loop chain (world-truth -> invariant ->
dispatch -> worldDelta -> milestone) so the contract can no longer advance
on a lie or stall on an unreachable milestone, and surfaces the result on
the monitor.

- Unblock M6_lighting: add gather.coal producer (mirrors gather.stone,
  strict expectGain), register it, add the skill-graph node, and make
  curriculum.shelter.torch two-step (gather coal -> craft torch). craft.torch
  needed coal but no skill produced it, so the contract pinned on M6 forever
  and starved M7/M8/M9. One curriculum edit fixes both rails.
- M8 no longer falsely satisfied: build-shelter records locations.shelter
  only on real progress (setLocation moved below the no_progress guard).
- M2_bed made monotonic: sleepInBed writes locations.bed when the bot places
  its own bed, so M2 stays met after the carried bed item is consumed.
- Observability: new ink-free tui/format.js helper renders per-tick
  state / firing rail / active skill / blocked prerequisite / stall reason
  in the monitor header (fields bot.js already computes but never showed).
- Harden the valid-skill-id guardrail: skillRegistryPrompt preserves the
  "NEVER invent" footer when truncating (a growing registry was dropping it),
  and fix the stale "tech-tree > autonomous" reflex chain in the escalation
  prompt.

Tests: 494/494 passing; new build-shelter / invariants / format suites plus
skill-graph, curriculum, skill-registry cases. lint-patch clean. Deferred
audit findings recorded in plans/v0.4.0-vnext.md (local).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-29 12:33:45 +03:00
co-authored by Claude Opus 4.8
parent 5613f75a77
commit cd63edfeaf
17 changed files with 590 additions and 15 deletions
+12 -2
View File
@@ -58,8 +58,18 @@ test("registryPrompt: contains the real ids grouped by namespace", () => {
assert.doesNotMatch(txt, /survive\.shelter[^-]/);
});
test("registryPrompt: respects limit parameter", () => {
test("registryPrompt: respects limit and preserves the NEVER-invent guardrail when truncating", () => {
const short = skillRegistryPrompt({ limit: 200 });
assert.ok(short.length <= 200, `expected <=200, got ${short.length}`);
assert.ok(short.endsWith("..."));
// The skill LIST is truncated (…), but the guardrail footer must always
// survive — otherwise a growing registry silently stops telling the LLM
// not to hallucinate skill ids.
assert.match(short, /\.\.\./, "list should be truncated");
assert.match(short, /NEVER invent/, "guardrail footer must survive truncation");
});
test("registryPrompt: default limit fits the full registry incl. the guardrail footer", () => {
const full = skillRegistryPrompt();
assert.match(full, /NEVER invent/);
assert.doesNotMatch(full, /\n\.\.\.\n/, "default prompt should not be truncated");
});