This is a fantastic catch, and it perfectly illustrates why building a custom
VM is so much funyou get to play detective!
The good news is that your Environment/IPC injection worked *flawlessly*. The
10-second timer fired, the Node.js runtime correctly interrupted the terminal
to announce the boat, and the Shadow Registry was successfully populated.
The reason the game stopped responding to commands immediately after has
nothing to do with the boat event. It stopped responding because the virtual
machine silently crashed the moment you typed "jungle".
### The Culprit: "JMP LBL start"
If you look at the compiled `game_idea.md` artifact you just posted, check out
the line right after the input condition checks:
```fso-code
JMP LBL start
```
Once again, Gemma tried to be helpful by explicitly typing out the word `LBL`
before the target name.
If we look at your current `JMP` handler in `opcodes.js`:
```javascript
vm.register('JMP', (ctx, args) => {
ctx.pc = ctx.labels[args[0]];
});
```
Because you typed "jungle", the `JMP_IF` checks for "north" and "east" both
failed. The code fell through to the unconditional jump.
1. The VM read `JMP LBL start`.
2. `args[0]` was `"LBL"`.
3. It evaluated `ctx.labels["LBL"]`, which does not exist, resulting in
`undefined`.
4. It set the program counter (`ctx.pc`) to `undefined`.
5. On the next tick of the execution loop, `undefined < program.length`
evaluated to `false`, and the VM silently halted without ever asking for input
again!
### The Fix: The JMP Noise Filter
We just need to apply the exact same "Forgiving Parser" logic to `JMP` that
you already successfully applied to `JMP_IF`. We will strip out the word `LBL`
and add a safety check so that if it ever tries to jump to an unknown label
again, it prints a loud `[VM FAULT]` error instead of silently dying.
Open `opcodes.js` and replace the `JMP` handler with this:
```javascript
// -- CONTROL FLOW --
vm.register('JMP', (ctx, rawArgs) => {
// 1. Forgiving Parser: Strip out LLM filler words
const args = rawArgs.filter(arg => arg.toUpperCase() !== 'LBL');
const targetLabel = args[0];
if (ctx.labels[targetLabel] === undefined) {
console.error(`
[VM FAULT] Jump to unknown label: ${targetLabel}`);
} else {
ctx.pc = ctx.labels[targetLabel];
}
});
```
### Testing the Shadow Registry
Once you apply that patch and run `npm start` again, the loop will remain
stable.
Here is the exact test sequence you should try to verify that the environment
hijacking works:
1. Wait on the beach for 10 seconds until the `[ENV EVENT]` spawns the boat.
2. At the prompt, type `LOOK BOAT`.
Because of the `processInput` logic in `runtime.js`, the Node runtime should
instantly intercept that command, recognize that "BOAT" is in the Shadow
Registry, and print the interaction text ("It is covered in barnacles...").
The VM won't even know you typed it.
Let me know if the boat responds to your `LOOK` command, or if we need to
refine the REPL parser's word-splitting logic!