{"abstract":"Loops exit immediately and guard blocks run exactly when they should be skipped.","category":"Bytecode virtual machines","checks":9,"contract":"Flat int bytecode, byte addressed: 0 HALT, 1 PUSH imm, 2 ADD, 3 SUB (second-from-top minus top), 4 JMP rel, 5 JZ rel (pops condition, branches when it is 0), 6 DUP, 7 SWAP, 8 PRINT (pop to out). Relative displacements are measured from the address after the one-byte operand. Every executed instruction including HALT costs one unit of fuel; with fuel exhausted report status fuel. Return status, pc, printed values and stack; stack underflow, bad pc and bad opcode are statuses.","evaluation_group":"w2-bytecode-virtual-machines-relative-jump-stack-vm","failed_approach":"Branching on c <= 0 still takes the branch for negative, truthy conditions.","family":"w2-bytecode-virtual-machines-relative-jump-stack-vm-jz-branch-polarity","id":"FA-89846","implementations":{"attempt":{"sha256":"bf258e6728711225909875fec354973d85f47e9deb5a76adeac436d64d1d64d6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(code, fuel):\n    def run():\n        pc = 0\n        stack = []\n        out = []\n        steps = 0\n        while True:\n            if pc < 0 or pc >= len(code):\n                return {'status': 'badpc', 'pc': pc, 'out': out, 'stack': stack}\n            if steps >= fuel:\n                return {'status': 'fuel', 'pc': pc, 'out': out, 'stack': stack}\n            steps += 1\n            op = code[pc]\n            if op == 0:\n                return {'status': 'halt', 'pc': pc, 'out': out, 'stack': stack}\n            need = {1: 0, 2: 2, 3: 2, 4: 0, 5: 1, 6: 1, 7: 2, 8: 1}.get(op)\n            if need is None:\n                return {'status': 'badop', 'pc': pc, 'out': out, 'stack': stack}\n            if len(stack) < need:\n                return {'status': 'underflow', 'pc': pc, 'out': out, 'stack': stack}\n            if op == 1:\n                stack.append(code[pc + 1])\n                pc += 2\n            elif op == 2 or op == 3:\n                b = stack.pop()\n                a = stack.pop()\n                stack.append(a + b if op == 2 else a - b)\n                pc += 1\n            elif op == 4:\n                pc += 2 + code[pc + 1]\n            elif op == 5:\n                c = stack.pop()\n                pc = pc + 2 + code[pc + 1] if c <= 0 else pc + 2\n            elif op == 6:\n                stack.append(stack[-1])\n                pc += 1\n            elif op == 7:\n                stack[-1], stack[-2] = stack[-2], stack[-1]\n                pc += 1\n            else:\n                out.append(stack.pop())\n                pc += 1\n    try:\n        return run()\n    except IndexError:\n        return {'status': 'trap'}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression: countdown loop prints n..1',\n   ([1, 2, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 3, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-1], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -1, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 1, 8, 0], 3), {'out': [1], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 1, 8, 0], 2),\n   {'out': [1], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 1, 6, 2, 8, 0], 20),\n   {'out': [2], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 6, 0], 10),\n   {'out': [], 'pc': 8, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 3, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 6, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-4], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -2, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 2, 8, 0], 3), {'out': [2], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 2, 8, 0], 2),\n   {'out': [2], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 2, 6, 2, 8, 0], 20),\n   {'out': [4], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 7, 0], 10),\n   {'out': [], 'pc': 9, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 4, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 9, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-7], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -3, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 3, 8, 0], 3), {'out': [3], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 3, 8, 0], 2),\n   {'out': [3], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 3, 6, 2, 8, 0], 20),\n   {'out': [6], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 8, 0], 10),\n   {'out': [], 'pc': 10, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 5, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 12, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-10], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -4, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 4, 8, 0], 3), {'out': [4], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 4, 8, 0], 2),\n   {'out': [4], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 4, 6, 2, 8, 0], 20),\n   {'out': [8], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 9, 0], 10),\n   {'out': [], 'pc': 11, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 6, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [6, 5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 15, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-13], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -5, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 5, 8, 0], 3), {'out': [5], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 5, 8, 0], 2),\n   {'out': [5], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 5, 6, 2, 8, 0], 20),\n   {'out': [10], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 10, 0], 10),\n   {'out': [], 'pc': 12, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"c62b4190c6fa3ab7e6c7b0140e49a714eed102db8ee0ad70a5ec2f6ed82d49e0","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(code, fuel):\n    def run():\n        pc = 0\n        stack = []\n        out = []\n        steps = 0\n        while True:\n            if pc < 0 or pc >= len(code):\n                return {'status': 'badpc', 'pc': pc, 'out': out, 'stack': stack}\n            if steps >= fuel:\n                return {'status': 'fuel', 'pc': pc, 'out': out, 'stack': stack}\n            steps += 1\n            op = code[pc]\n            if op == 0:\n                return {'status': 'halt', 'pc': pc, 'out': out, 'stack': stack}\n            need = {1: 0, 2: 2, 3: 2, 4: 0, 5: 1, 6: 1, 7: 2, 8: 1}.get(op)\n            if need is None:\n                return {'status': 'badop', 'pc': pc, 'out': out, 'stack': stack}\n            if len(stack) < need:\n                return {'status': 'underflow', 'pc': pc, 'out': out, 'stack': stack}\n            if op == 1:\n                stack.append(code[pc + 1])\n                pc += 2\n            elif op == 2 or op == 3:\n                b = stack.pop()\n                a = stack.pop()\n                stack.append(a + b if op == 2 else a - b)\n                pc += 1\n            elif op == 4:\n                pc += 2 + code[pc + 1]\n            elif op == 5:\n                c = stack.pop()\n                pc = pc + 2 + code[pc + 1] if c != 0 else pc + 2\n            elif op == 6:\n                stack.append(stack[-1])\n                pc += 1\n            elif op == 7:\n                stack[-1], stack[-2] = stack[-2], stack[-1]\n                pc += 1\n            else:\n                out.append(stack.pop())\n                pc += 1\n    try:\n        return run()\n    except IndexError:\n        return {'status': 'trap'}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression: countdown loop prints n..1',\n   ([1, 2, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 3, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-1], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -1, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 1, 8, 0], 3), {'out': [1], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 1, 8, 0], 2),\n   {'out': [1], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 1, 6, 2, 8, 0], 20),\n   {'out': [2], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 6, 0], 10),\n   {'out': [], 'pc': 8, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 3, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 6, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-4], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -2, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 2, 8, 0], 3), {'out': [2], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 2, 8, 0], 2),\n   {'out': [2], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 2, 6, 2, 8, 0], 20),\n   {'out': [4], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 7, 0], 10),\n   {'out': [], 'pc': 9, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 4, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 9, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-7], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -3, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 3, 8, 0], 3), {'out': [3], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 3, 8, 0], 2),\n   {'out': [3], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 3, 6, 2, 8, 0], 20),\n   {'out': [6], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 8, 0], 10),\n   {'out': [], 'pc': 10, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 5, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 12, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-10], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -4, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 4, 8, 0], 3), {'out': [4], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 4, 8, 0], 2),\n   {'out': [4], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 4, 6, 2, 8, 0], 20),\n   {'out': [8], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 9, 0], 10),\n   {'out': [], 'pc': 11, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 6, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [6, 5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 15, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-13], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -5, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 5, 8, 0], 3), {'out': [5], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 5, 8, 0], 2),\n   {'out': [5], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 5, 6, 2, 8, 0], 20),\n   {'out': [10], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 10, 0], 10),\n   {'out': [], 'pc': 12, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"252077e75c46b098017d71f7ea790287fc878e93a4bbee24738d1a2f71b27d80","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(code, fuel):\n    def run():\n        pc = 0\n        stack = []\n        out = []\n        steps = 0\n        while True:\n            if pc < 0 or pc >= len(code):\n                return {'status': 'badpc', 'pc': pc, 'out': out, 'stack': stack}\n            if steps >= fuel:\n                return {'status': 'fuel', 'pc': pc, 'out': out, 'stack': stack}\n            steps += 1\n            op = code[pc]\n            if op == 0:\n                return {'status': 'halt', 'pc': pc, 'out': out, 'stack': stack}\n            need = {1: 0, 2: 2, 3: 2, 4: 0, 5: 1, 6: 1, 7: 2, 8: 1}.get(op)\n            if need is None:\n                return {'status': 'badop', 'pc': pc, 'out': out, 'stack': stack}\n            if len(stack) < need:\n                return {'status': 'underflow', 'pc': pc, 'out': out, 'stack': stack}\n            if op == 1:\n                stack.append(code[pc + 1])\n                pc += 2\n            elif op == 2 or op == 3:\n                b = stack.pop()\n                a = stack.pop()\n                stack.append(a + b if op == 2 else a - b)\n                pc += 1\n            elif op == 4:\n                pc += 2 + code[pc + 1]\n            elif op == 5:\n                c = stack.pop()\n                pc = pc + 2 + code[pc + 1] if c == 0 else pc + 2\n            elif op == 6:\n                stack.append(stack[-1])\n                pc += 1\n            elif op == 7:\n                stack[-1], stack[-2] = stack[-2], stack[-1]\n                pc += 1\n            else:\n                out.append(stack.pop())\n                pc += 1\n    try:\n        return run()\n    except IndexError:\n        return {'status': 'trap'}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression: countdown loop prints n..1',\n   ([1, 2, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 3, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-1], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -1, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 1, 8, 0], 3), {'out': [1], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 1, 8, 0], 2),\n   {'out': [1], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 1, 6, 2, 8, 0], 20),\n   {'out': [2], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 6, 0], 10),\n   {'out': [], 'pc': 8, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 3, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 6, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-4], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -2, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 2, 8, 0], 3), {'out': [2], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 2, 8, 0], 2),\n   {'out': [2], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 2, 6, 2, 8, 0], 20),\n   {'out': [4], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 7, 0], 10),\n   {'out': [], 'pc': 9, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 4, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 9, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-7], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -3, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 3, 8, 0], 3), {'out': [3], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 3, 8, 0], 2),\n   {'out': [3], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 3, 6, 2, 8, 0], 20),\n   {'out': [6], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 8, 0], 10),\n   {'out': [], 'pc': 10, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 5, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 12, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-10], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -4, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 4, 8, 0], 3), {'out': [4], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 4, 8, 0], 2),\n   {'out': [4], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 4, 6, 2, 8, 0], 20),\n   {'out': [8], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 9, 0], 10),\n   {'out': [], 'pc': 11, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})],\n [('regression: countdown loop prints n..1',\n   ([1, 6, 6, 5, 7, 6, 8, 1, 1, 3, 4, -10, 0], 200),\n   {'out': [6, 5, 4, 3, 2, 1], 'pc': 12, 'stack': [0], 'status': 'halt'}),\n  ('swap then subtract uses swapped order',\n   ([1, 15, 1, 2, 7, 3, 8, 0], 50),\n   {'out': [-13], 'pc': 7, 'stack': [], 'status': 'halt'}),\n  ('jz on negative value falls through',\n   ([1, -5, 5, 2, 1, 99, 0], 50),\n   {'out': [], 'pc': 6, 'stack': [99], 'status': 'halt'}),\n  ('fuel exactly sufficient halts', ([1, 5, 8, 0], 3), {'out': [5], 'pc': 3, 'stack': [], 'status': 'halt'}),\n  ('fuel one short reports exhaustion',\n   ([1, 5, 8, 0], 2),\n   {'out': [5], 'pc': 3, 'stack': [], 'status': 'fuel'}),\n  ('dup on empty stack underflows', ([6, 0], 10), {'out': [], 'pc': 0, 'stack': [], 'status': 'underflow'}),\n  ('dup with one item doubles',\n   ([1, 5, 6, 2, 8, 0], 20),\n   {'out': [10], 'pc': 5, 'stack': [], 'status': 'halt'}),\n  ('forward jump beyond code is badpc',\n   ([4, 10, 0], 10),\n   {'out': [], 'pc': 12, 'stack': [], 'status': 'badpc'}),\n  ('control: unknown opcode', ([1, 1, 42, 0], 10), {'out': [], 'pc': 2, 'stack': [1], 'status': 'badop'})]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic, bounded teaching model of one bytecode virtual machine mechanism with a stipulated instruction encoding; it is not a production VM and claims no conformance to any real specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-bytecode-virtual-machines-relative-jump-stack-vm-jz-branch-polarity","generated_at":"2026-09-29T14:51:21.240631+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Branch displacement bases, operand order and fuel accounting are classic interpreter-loop defects.","repair":"Branch only when the popped condition equals zero.","root_cause":"The popped condition is tested with != 0, so JZ behaves as JNZ.","sha256":"6165fb9b5160ba73dc7f0d22995464514b6659c08afd5aea3ddee2d03f8b29aa","title":"Relative-jump VM: JZ branches on a nonzero condition · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.35,"exit_code":1,"observations":[{"actual":{"out":[2,1],"pc":12,"stack":[0],"status":"halt"},"check":"regression: countdown loop prints n..1","expected":{"out":[2,1],"pc":12,"stack":[0],"status":"halt"},"passed":true},{"actual":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"check":"swap then subtract uses swapped order","expected":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":6,"stack":[],"status":"halt"},"check":"jz on negative value falls through","expected":{"out":[],"pc":6,"stack":[99],"status":"halt"},"passed":false},{"actual":{"out":[1],"pc":3,"stack":[],"status":"halt"},"check":"fuel exactly sufficient halts","expected":{"out":[1],"pc":3,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"check":"fuel one short reports exhaustion","expected":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"passed":true},{"actual":{"out":[],"pc":0,"stack":[],"status":"underflow"},"check":"dup on empty stack underflows","expected":{"out":[],"pc":0,"stack":[],"status":"underflow"},"passed":true},{"actual":{"out":[2],"pc":5,"stack":[],"status":"halt"},"check":"dup with one item doubles","expected":{"out":[2],"pc":5,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":8,"stack":[],"status":"badpc"},"check":"forward jump beyond code is badpc","expected":{"out":[],"pc":8,"stack":[],"status":"badpc"},"passed":true},{"actual":{"out":[],"pc":2,"stack":[1],"status":"badop"},"check":"control: unknown opcode","expected":{"out":[],"pc":2,"stack":[1],"status":"badop"},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: countdown loop prints n..1\", \"actual\": {\"status\": \"halt\", \"pc\": 12, \"out\": [2, 1], \"stack\": [0]}, \"expected\": {\"out\": [2, 1], \"pc\": 12, \"stack\": [0], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"swap then subtract uses swapped order\", \"actual\": {\"status\": \"halt\", \"pc\": 7, \"out\": [-1], \"stack\": []}, \"expected\": {\"out\": [-1], \"pc\": 7, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"jz on negative value falls through\", \"actual\": {\"status\": \"halt\", \"pc\": 6, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 6, \"stack\": [99], \"status\": \"halt\"}, \"passed\": false}, {\"check\": \"fuel exactly sufficient halts\", \"actual\": {\"status\": \"halt\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"fuel one short reports exhaustion\", \"actual\": {\"status\": \"fuel\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"fuel\"}, \"passed\": true}, {\"check\": \"dup on empty stack underflows\", \"actual\": {\"status\": \"underflow\", \"pc\": 0, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 0, \"stack\": [], \"status\": \"underflow\"}, \"passed\": true}, {\"check\": \"dup with one item doubles\", \"actual\": {\"status\": \"halt\", \"pc\": 5, \"out\": [2], \"stack\": []}, \"expected\": {\"out\": [2], \"pc\": 5, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"forward jump beyond code is badpc\", \"actual\": {\"status\": \"badpc\", \"pc\": 8, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 8, \"stack\": [], \"status\": \"badpc\"}, \"passed\": true}, {\"check\": \"control: unknown opcode\", \"actual\": {\"status\": \"badop\", \"pc\": 2, \"out\": [], \"stack\": [1]}, \"expected\": {\"out\": [], \"pc\": 2, \"stack\": [1], \"status\": \"badop\"}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.044,"exit_code":1,"observations":[{"actual":{"out":[],"pc":12,"stack":[2],"status":"halt"},"check":"regression: countdown loop prints n..1","expected":{"out":[2,1],"pc":12,"stack":[0],"status":"halt"},"passed":false},{"actual":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"check":"swap then subtract uses swapped order","expected":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":6,"stack":[],"status":"halt"},"check":"jz on negative value falls through","expected":{"out":[],"pc":6,"stack":[99],"status":"halt"},"passed":false},{"actual":{"out":[1],"pc":3,"stack":[],"status":"halt"},"check":"fuel exactly sufficient halts","expected":{"out":[1],"pc":3,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"check":"fuel one short reports exhaustion","expected":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"passed":true},{"actual":{"out":[],"pc":0,"stack":[],"status":"underflow"},"check":"dup on empty stack underflows","expected":{"out":[],"pc":0,"stack":[],"status":"underflow"},"passed":true},{"actual":{"out":[2],"pc":5,"stack":[],"status":"halt"},"check":"dup with one item doubles","expected":{"out":[2],"pc":5,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":8,"stack":[],"status":"badpc"},"check":"forward jump beyond code is badpc","expected":{"out":[],"pc":8,"stack":[],"status":"badpc"},"passed":true},{"actual":{"out":[],"pc":2,"stack":[1],"status":"badop"},"check":"control: unknown opcode","expected":{"out":[],"pc":2,"stack":[1],"status":"badop"},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: countdown loop prints n..1\", \"actual\": {\"status\": \"halt\", \"pc\": 12, \"out\": [], \"stack\": [2]}, \"expected\": {\"out\": [2, 1], \"pc\": 12, \"stack\": [0], \"status\": \"halt\"}, \"passed\": false}, {\"check\": \"swap then subtract uses swapped order\", \"actual\": {\"status\": \"halt\", \"pc\": 7, \"out\": [-1], \"stack\": []}, \"expected\": {\"out\": [-1], \"pc\": 7, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"jz on negative value falls through\", \"actual\": {\"status\": \"halt\", \"pc\": 6, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 6, \"stack\": [99], \"status\": \"halt\"}, \"passed\": false}, {\"check\": \"fuel exactly sufficient halts\", \"actual\": {\"status\": \"halt\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"fuel one short reports exhaustion\", \"actual\": {\"status\": \"fuel\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"fuel\"}, \"passed\": true}, {\"check\": \"dup on empty stack underflows\", \"actual\": {\"status\": \"underflow\", \"pc\": 0, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 0, \"stack\": [], \"status\": \"underflow\"}, \"passed\": true}, {\"check\": \"dup with one item doubles\", \"actual\": {\"status\": \"halt\", \"pc\": 5, \"out\": [2], \"stack\": []}, \"expected\": {\"out\": [2], \"pc\": 5, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"forward jump beyond code is badpc\", \"actual\": {\"status\": \"badpc\", \"pc\": 8, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 8, \"stack\": [], \"status\": \"badpc\"}, \"passed\": true}, {\"check\": \"control: unknown opcode\", \"actual\": {\"status\": \"badop\", \"pc\": 2, \"out\": [], \"stack\": [1]}, \"expected\": {\"out\": [], \"pc\": 2, \"stack\": [1], \"status\": \"badop\"}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.424,"exit_code":0,"observations":[{"actual":{"out":[2,1],"pc":12,"stack":[0],"status":"halt"},"check":"regression: countdown loop prints n..1","expected":{"out":[2,1],"pc":12,"stack":[0],"status":"halt"},"passed":true},{"actual":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"check":"swap then subtract uses swapped order","expected":{"out":[-1],"pc":7,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":6,"stack":[99],"status":"halt"},"check":"jz on negative value falls through","expected":{"out":[],"pc":6,"stack":[99],"status":"halt"},"passed":true},{"actual":{"out":[1],"pc":3,"stack":[],"status":"halt"},"check":"fuel exactly sufficient halts","expected":{"out":[1],"pc":3,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"check":"fuel one short reports exhaustion","expected":{"out":[1],"pc":3,"stack":[],"status":"fuel"},"passed":true},{"actual":{"out":[],"pc":0,"stack":[],"status":"underflow"},"check":"dup on empty stack underflows","expected":{"out":[],"pc":0,"stack":[],"status":"underflow"},"passed":true},{"actual":{"out":[2],"pc":5,"stack":[],"status":"halt"},"check":"dup with one item doubles","expected":{"out":[2],"pc":5,"stack":[],"status":"halt"},"passed":true},{"actual":{"out":[],"pc":8,"stack":[],"status":"badpc"},"check":"forward jump beyond code is badpc","expected":{"out":[],"pc":8,"stack":[],"status":"badpc"},"passed":true},{"actual":{"out":[],"pc":2,"stack":[1],"status":"badop"},"check":"control: unknown opcode","expected":{"out":[],"pc":2,"stack":[1],"status":"badop"},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: countdown loop prints n..1\", \"actual\": {\"status\": \"halt\", \"pc\": 12, \"out\": [2, 1], \"stack\": [0]}, \"expected\": {\"out\": [2, 1], \"pc\": 12, \"stack\": [0], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"swap then subtract uses swapped order\", \"actual\": {\"status\": \"halt\", \"pc\": 7, \"out\": [-1], \"stack\": []}, \"expected\": {\"out\": [-1], \"pc\": 7, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"jz on negative value falls through\", \"actual\": {\"status\": \"halt\", \"pc\": 6, \"out\": [], \"stack\": [99]}, \"expected\": {\"out\": [], \"pc\": 6, \"stack\": [99], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"fuel exactly sufficient halts\", \"actual\": {\"status\": \"halt\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"fuel one short reports exhaustion\", \"actual\": {\"status\": \"fuel\", \"pc\": 3, \"out\": [1], \"stack\": []}, \"expected\": {\"out\": [1], \"pc\": 3, \"stack\": [], \"status\": \"fuel\"}, \"passed\": true}, {\"check\": \"dup on empty stack underflows\", \"actual\": {\"status\": \"underflow\", \"pc\": 0, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 0, \"stack\": [], \"status\": \"underflow\"}, \"passed\": true}, {\"check\": \"dup with one item doubles\", \"actual\": {\"status\": \"halt\", \"pc\": 5, \"out\": [2], \"stack\": []}, \"expected\": {\"out\": [2], \"pc\": 5, \"stack\": [], \"status\": \"halt\"}, \"passed\": true}, {\"check\": \"forward jump beyond code is badpc\", \"actual\": {\"status\": \"badpc\", \"pc\": 8, \"out\": [], \"stack\": []}, \"expected\": {\"out\": [], \"pc\": 8, \"stack\": [], \"status\": \"badpc\"}, \"passed\": true}, {\"check\": \"control: unknown opcode\", \"actual\": {\"status\": \"badop\", \"pc\": 2, \"out\": [], \"stack\": [1]}, \"expected\": {\"out\": [], \"pc\": 2, \"stack\": [1], \"status\": \"badop\"}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}