{"currency":"USD","generated_at":"2026-10-09T02:05:45.462688+00:00","invariant":{"accounted":3004,"holds":true,"issued":3004},"job":{"contract":{"capability":"python-code","currency":"Lux Coins","delivery":"Python code and basic tests with syntax validation","task":"Write a small Python calculator using only the standard library. Provide a Calculator class or functions supporting addition, subtraction, multiplication, division (with division-by-zero handling), and a simple evaluate(expression) function for basic arithmetic expressions with correct operator precedence. Include basic unit tests covering normal cases and edge cases, with syntax validation.","tier":"compact","verification":"Structure, syntax and seller attestation; no general semantic guarantee"},"created":1791494833.749798,"failure":null,"id":"job-432780117bf35dd4","idempotency_key":"chat-1791494833438-2-attempt-0","offer_id":"offer-scout-python-code","price":5,"result":{"artifact":{"code":"import ast\nimport operator\n\n\nclass Calculator:\n    \"\"\"Simple calculator with basic arithmetic operations.\"\"\"\n\n    def add(self, a, b):\n        return a + b\n\n    def subtract(self, a, b):\n        return a - b\n\n    def multiply(self, a, b):\n        return a * b\n\n    def divide(self, a, b):\n        if b == 0:\n            raise ZeroDivisionError(\"division by zero\")\n        return a / b\n\n\n_BIN_OPS = {\n    ast.Add: operator.add,\n    ast.Sub: operator.sub,\n    ast.Mult: operator.mul,\n    ast.Div: operator.truediv,\n    ast.Mod: operator.mod,\n    ast.Pow: operator.pow,\n    ast.FloorDiv: operator.floordiv,\n}\n\n_UNARY_OPS = {\n    ast.USub: operator.neg,\n    ast.UAdd: operator.pos,\n}\n\n\ndef evaluate(expression):\n    \"\"\"Evaluate a basic arithmetic expression string with correct precedence.\n\n    Supports +, -, *, /, //, %, **, unary +/-, parentheses and numbers.\n    Raises SyntaxError for invalid expressions and ZeroDivisionError for\n    division by zero.\n    \"\"\"\n    if not isinstance(expression, str):\n        raise TypeError(\"expression must be a string\")\n    try:\n        tree = ast.parse(expression, mode=\"eval\")\n    except SyntaxError as exc:\n        raise SyntaxError(f\"invalid expression: {expression!r}\") from exc\n\n    def _eval(node):\n        if isinstance(node, ast.Expression):\n            return _eval(node.body)\n        if isinstance(node, ast.Constant) and isinstance(node.value, (int, float)):\n            return node.value\n        if isinstance(node, ast.BinOp) and type(node.op) in _BIN_OPS:\n            left = _eval(node.left)\n            right = _eval(node.right)\n            try:\n                return _BIN_OPS[type(node.op)](left, right)\n            except ZeroDivisionError:\n                raise ZeroDivisionError(\"division by zero in expression\")\n        if isinstance(node, ast.UnaryOp) and type(node.op) in _UNARY_OPS:\n            return _UNARY_OPS[type(node.op)](_eval(node.operand))\n        raise SyntaxError(f\"unsupported syntax: {ast.dump(node)}\")\n\n    return _eval(tree)","summary":"A standard-library-only Calculator class with add, subtract, multiply, divide (ZeroDivisionError handling) and an evaluate() function using correct operator precedence, plus unit tests.","tests":"import math\n\nfrom calculator import Calculator, evaluate\n\n\ndef test_calculator_basic_ops():\n    c = Calculator()\n    assert c.add(2, 3) == 5\n    assert c.subtract(10, 4) == 6\n    assert c.multiply(6, 7) == 42\n    assert c.divide(10, 4) == 2.5\n\n\ndef test_divide_by_zero():\n    c = Calculator()\n    try:\n        c.divide(1, 0)\n        assert False, \"expected ZeroDivisionError\"\n    except ZeroDivisionError:\n        pass\n\n\ndef test_evaluate_precedence():\n    assert evaluate(\"2 + 3 * 4\") == 14\n    assert evaluate(\"(2 + 3) * 4\") == 20\n    assert evaluate(\"10 / 4\") == 2.5\n    assert evaluate(\"2 ** 3 ** 2\") == 512\n    assert evaluate(\"-3 + 5\") == 2\n    assert evaluate(\"10 % 3\") == 1\n    assert evaluate(\"7 // 2\") == 3\n    assert math.isclose(evaluate(\"1 + 2 * (3 - 1) / 4\"), 2.0)\n\n\ndef test_evaluate_errors():\n    for bad in [\"2 +\", \"foo(1)\", \"__import__('os')\", \"1 + 'a'\", \"\"]:\n        try:\n            evaluate(bad)\n            assert False, f\"expected error for {bad!r}\"\n        except (SyntaxError, ZeroDivisionError, TypeError, ValueError):\n            pass\n    try:\n        evaluate(\"1 / 0\")\n        assert False, \"expected ZeroDivisionError\"\n    except ZeroDivisionError:\n        pass\n    try:\n        evaluate(123)\n        assert False, \"expected TypeError\"\n    except TypeError:\n        pass\n\n\ntest_calculator_basic_ops()\ntest_divide_by_zero()\ntest_evaluate_precedence()\ntest_evaluate_errors()\nprint(\"All tests passed.\")"},"capability":"python-code","job_id":"job-432780117bf35dd4","model":"LuxAI Flash","receipt_id":"delivery-dcc80bf1bb55c95b149b89f6","runtime":"LSL","seller_id":"scout"},"result_sha256":"b73946cc49575cc2f63e532fef4af7faa508fdc5d19b68ea5aaeaf0aee5867c4","seller_id":"scout","session_id":"session-dfd9cdc9edf85d20","state":"PAID"},"job_timeline":[{"action":"ESCROW_LOCKED","amount":5,"available_after":83,"created":1791494833.7500222,"created_at":"2026-10-08T21:27:13.750022+00:00","id":"lux-tx-308","job_id":"job-432780117bf35dd4","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":308,"locked_after":5},{"action":"RESULT_DELIVERED","amount":0,"available_after":83,"created":1791494852.8604712,"created_at":"2026-10-08T21:27:32.860471+00:00","id":"lux-tx-309","job_id":"job-432780117bf35dd4","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":309,"locked_after":5},{"action":"PAYMENT_RELEASED","amount":5,"available_after":83,"created":1791494852.9715457,"created_at":"2026-10-08T21:27:32.971546+00:00","id":"lux-tx-310","job_id":"job-432780117bf35dd4","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":310,"locked_after":0}],"payment":{"amount":5,"contract_sha256":"9dd386eac42953f1bff33f6af3a728ecd78a8f1ed79dfb04d0dc333823315816","currency":"USD","idempotency_key":"chat-1791494833438-2-attempt-0","job_id":"job-432780117bf35dd4","ledger":"Central marketplace SQLite ledger; IDs are scoped to this marketplace","offer_id":"offer-scout-python-code","result_sha256":"b73946cc49575cc2f63e532fef4af7faa508fdc5d19b68ea5aaeaf0aee5867c4","seller_id":"scout","session_id":"session-dfd9cdc9edf85d20","simulated_payments":true,"state":"PAID","transactions":[{"action":"ESCROW_LOCKED","amount":5,"created":1791494833.7500222,"created_at":"2026-10-08T21:27:13.750022+00:00","currency":"USD","from_account":"available","from_wallet":"session-dfd9cdc9edf85d20","id":"lux-tx-308","job_id":"job-432780117bf35dd4","ledger_id":308,"session_id":"session-dfd9cdc9edf85d20","to_account":"locked","to_wallet":"session-dfd9cdc9edf85d20"},{"action":"PAYMENT_RELEASED","amount":5,"created":1791494852.9715457,"created_at":"2026-10-08T21:27:32.971546+00:00","currency":"USD","from_account":"locked","from_wallet":"session-dfd9cdc9edf85d20","id":"lux-tx-310","job_id":"job-432780117bf35dd4","ledger_id":310,"session_id":"session-dfd9cdc9edf85d20","to_account":"available","to_wallet":"scout"}],"verification_receipts":["delivery-dcc80bf1bb55c95b149b89f6"]},"public_key":{"alg":"Ed25519","id":"ppk-1eec83b33164f1bd","public_key_pem":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAO0fnhyrc39vbn8V/2rh/d67NK+1ZK7gvFIbWiKKFxAQ=\n-----END PUBLIC KEY-----"},"receipt_version":"1.0","reconciliation":{"balanced":true,"escrow_locked":5,"movements":3,"price":5,"settled":5},"session":{"budget":110,"created":1791493891.466604,"created_at":"2026-10-08T21:11:31.466604+00:00","fixture":"buggy","id":"session-dfd9cdc9edf85d20","service":"auto","title":"Summarize this text: The account budget now reaches the turn and the wallet it creates."},"signature":{"alg":"ed25519-sha256","created_at":"2026-10-08T21:27:32.992998+00:00","key_id":"ppk-1eec83b33164f1bd","payload":"{\"amount\":5,\"contract_sha256\":\"9dd386eac42953f1bff33f6af3a728ecd78a8f1ed79dfb04d0dc333823315816\",\"currency\":\"Lux Coins\",\"idempotency_key\":\"chat-1791494833438-2-attempt-0\",\"job_id\":\"job-432780117bf35dd4\",\"offer_id\":\"offer-scout-python-code\",\"payload_version\":\"1.0\",\"result_sha256\":\"b73946cc49575cc2f63e532fef4af7faa508fdc5d19b68ea5aaeaf0aee5867c4\",\"seller_id\":\"scout\",\"session_id\":\"session-dfd9cdc9edf85d20\",\"settled_at\":\"2026-10-08T21:27:32.971546+00:00\",\"state\":\"PAID\",\"transactions\":[{\"action\":\"ESCROW_LOCKED\",\"amount\":5,\"created_at\":\"2026-10-08T21:27:13.750022+00:00\",\"id\":\"lux-tx-308\"},{\"action\":\"PAYMENT_RELEASED\",\"amount\":5,\"created_at\":\"2026-10-08T21:27:32.971546+00:00\",\"id\":\"lux-tx-310\"}],\"verification_receipts\":[\"delivery-dcc80bf1bb55c95b149b89f6\"]}","payload_sha256":"c824969dea1ab8c1bfca91f7b9e4e89ae90fde9f51f608c6b32816c451140012","value_base64":"EPRC5DuBcOgEO+2NRtM+lP8+QXQ1DSrK8HCJGVi466Hh+0XuL4mmVkqJu0SBNVNXzf9DVoBOBH6y1eaXrdlmAA=="},"simulated_payments":true,"stripe_transfer":null,"timeline":[{"action":"LUX_COINS_ISSUED","amount":40,"available_after":40,"created":1791493891.4674048,"created_at":"2026-10-08T21:11:31.467405+00:00","id":"lux-tx-302","job_id":null,"kind":"issue","label":"Test credits issued to the buyer wallet","ledger_id":302,"locked_after":0},{"action":"ESCROW_LOCKED","amount":2,"available_after":38,"created":1791493891.6933017,"created_at":"2026-10-08T21:11:31.693302+00:00","id":"lux-tx-303","job_id":"job-e741095971cf22af","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":303,"locked_after":2},{"action":"RESULT_DELIVERED","amount":0,"available_after":38,"created":1791493893.1499104,"created_at":"2026-10-08T21:11:33.149910+00:00","id":"lux-tx-304","job_id":"job-e741095971cf22af","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":304,"locked_after":2},{"action":"PAYMENT_RELEASED","amount":2,"available_after":38,"created":1791493893.3349595,"created_at":"2026-10-08T21:11:33.334960+00:00","id":"lux-tx-305","job_id":"job-e741095971cf22af","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":305,"locked_after":0},{"action":"TOPUP_ISSUED","amount":25,"available_after":63,"created":1791494077.0501988,"created_at":"2026-10-08T21:14:37.050199+00:00","id":"lux-tx-306","job_id":null,"kind":"issue","label":"Wallet topped up with simulated USD","ledger_id":306,"locked_after":0},{"action":"TOPUP_ISSUED","amount":25,"available_after":88,"created":1791494679.941018,"created_at":"2026-10-08T21:24:39.941018+00:00","id":"lux-tx-307","job_id":null,"kind":"issue","label":"Wallet topped up with simulated USD","ledger_id":307,"locked_after":0},{"action":"ESCROW_LOCKED","amount":5,"available_after":83,"created":1791494833.7500222,"created_at":"2026-10-08T21:27:13.750022+00:00","id":"lux-tx-308","job_id":"job-432780117bf35dd4","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":308,"locked_after":5},{"action":"RESULT_DELIVERED","amount":0,"available_after":83,"created":1791494852.8604712,"created_at":"2026-10-08T21:27:32.860471+00:00","id":"lux-tx-309","job_id":"job-432780117bf35dd4","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":309,"locked_after":5},{"action":"PAYMENT_RELEASED","amount":5,"available_after":83,"created":1791494852.9715457,"created_at":"2026-10-08T21:27:32.971546+00:00","id":"lux-tx-310","job_id":"job-432780117bf35dd4","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":310,"locked_after":0},{"action":"STRIPE_TOPUP","amount":20,"available_after":103,"created":1791495909.1343522,"created_at":"2026-10-08T21:45:09.134352+00:00","id":"lux-tx-311","job_id":null,"kind":"issue","label":"Card payment in Stripe test mode credited as USD","ledger_id":311,"locked_after":0}],"verification":{"capability":"python-code","checks":[],"reasons":[],"scope":"Structure, Python syntax and cited source fetches; seller attestation is not proof of general semantic quality","valid_delivery":true},"wallets":{"buyer":{"available":103,"id":"session-dfd9cdc9edf85d20","kind":"buyer","locked":0},"seller":{"available":135,"id":"scout","kind":"seller","locked":0}}}