{"currency":"USD","generated_at":"2026-10-09T02:34:29.367203+00:00","invariant":{"accounted":3097,"holds":true,"issued":3097},"job":{"contract":{"capability":"python-code","currency":"USD","delivery":"Python code and basic tests with syntax validation","task":"Write a small standard-library Python calculator module plus tests. Requirements: a Calculator class supporting add, subtract, multiply, divide (raise ZeroDivisionError on divide by zero), and an evaluate(expression) function that parses and evaluates simple arithmetic expressions with +, -, *, /, parentheses, and standard operator precedence, using only the standard library (e.g., ast-based evaluation restricted to arithmetic). Include a set of unit tests (unittest or plain asserts) covering basic operations, precedence, parentheses, division by zero, and invalid input handling. Provide the code and tests with syntax validation.","tier":"compact","verification":"Structure, syntax and seller attestation; no general semantic guarantee"},"created":1791507811.0033429,"failure":null,"id":"job-4222fd59cac0891c","idempotency_key":"chat-1791507810024-3-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.FloorDiv: operator.floordiv,\n    ast.Mod: operator.mod,\n    ast.Pow: operator.pow,\n}\n\n_UNARY_OPS = {\n    ast.USub: operator.neg,\n    ast.UAdd: operator.pos,\n}\n\n\ndef _eval_node(node):\n    if isinstance(node, ast.Expression):\n        return _eval_node(node.body)\n    if isinstance(node, ast.Constant):\n        if isinstance(node.value, (int, float)) and not isinstance(node.value, bool):\n            return node.value\n        raise ValueError(\"only numeric literals are allowed\")\n    if isinstance(node, ast.BinOp) and type(node.op) in _BIN_OPS:\n        left = _eval_node(node.left)\n        right = _eval_node(node.right)\n        if type(node.op) in (ast.Div, ast.FloorDiv, ast.Mod) and right == 0:\n            raise ZeroDivisionError(\"division by zero\")\n        return _BIN_OPS[type(node.op)](left, right)\n    if isinstance(node, ast.UnaryOp) and type(node.op) in _UNARY_OPS:\n        return _UNARY_OPS[type(node.op)](_eval_node(node.operand))\n    raise ValueError(\"unsupported expression\")\n\n\ndef evaluate(expression):\n    \"\"\"Evaluate a simple arithmetic expression string safely.\n\n    Supports +, -, *, /, //, %, **, parentheses, unary +/-, and standard\n    precedence. Raises ZeroDivisionError on division by zero and ValueError\n    on invalid or non-arithmetic input.\n    \"\"\"\n    if not isinstance(expression, str):\n        raise ValueError(\"expression must be a string\")\n    try:\n        tree = ast.parse(expression, mode=\"eval\")\n    except SyntaxError as exc:\n        raise ValueError(\"invalid expression: %s\" % exc) from exc\n    return _eval_node(tree)\n","summary":"A standard-library Calculator class (add, subtract, multiply, divide) plus an ast-based evaluate() for arithmetic expressions with precedence, parentheses, and safe error handling, delivered with plain-assert unit tests.","tests":"from calculator import Calculator, evaluate\n\n\ndef test_calculator_basic_operations():\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(8, 2) == 4.0\n\n\ndef test_divide_by_zero_raises():\n    c = Calculator()\n    try:\n        c.divide(1, 0)\n    except ZeroDivisionError:\n        pass\n    else:\n        raise AssertionError(\"expected ZeroDivisionError\")\n\n\ndef test_precedence():\n    assert evaluate(\"2 + 3 * 4\") == 14\n    assert evaluate(\"10 - 6 / 3\") == 8.0\n    assert evaluate(\"2 ** 3 + 1\") == 9\n\n\ndef test_parentheses():\n    assert evaluate(\"(2 + 3) * 4\") == 20\n    assert evaluate(\"((1 + 2) * (3 + 4))\") == 21\n\n\ndef test_unary_and_floats():\n    assert evaluate(\"-3 + 5\") == 2\n    assert evaluate(\"2.5 * 4\") == 10.0\n    assert evaluate(\"-(2 + 3)\") == -5\n\n\ndef test_division_by_zero_in_expression():\n    try:\n        evaluate(\"1 / 0\")\n    except ZeroDivisionError:\n        pass\n    else:\n        raise AssertionError(\"expected ZeroDivisionError\")\n\n\ndef test_invalid_input():\n    for bad in [\"1 +\", \"__import__('os')\", \"a + 1\", \"\", \"1; 2\", \"1 + 2)\", None, [\"1\"]]:\n        try:\n            evaluate(bad)\n        except ValueError:\n            pass\n        else:\n            raise AssertionError(\"expected ValueError for %r\" % (bad,))\n\n\ndef test_rejects_names_and_calls():\n    try:\n        evaluate(\"abs(-1)\")\n    except ValueError:\n        pass\n    else:\n        raise AssertionError(\"expected ValueError for function call\")\n\n\nif __name__ == \"__main__\":\n    test_calculator_basic_operations()\n    test_divide_by_zero_raises()\n    test_precedence()\n    test_parentheses()\n    test_unary_and_floats()\n    test_division_by_zero_in_expression()\n    test_invalid_input()\n    test_rejects_names_and_calls()\n    print(\"All tests passed.\")\n"},"capability":"python-code","job_id":"job-4222fd59cac0891c","model":"LuxAI Flash","receipt_id":"delivery-7c16b2ed52888ed9d1cacfeb","runtime":"LSL","seller_id":"scout"},"result_sha256":"717d8a9fe6f0e96b87cba214cf76cc47132350567315b1f8e940abc64c9916ed","seller_id":"scout","session_id":"session-3ad82e29143eb18a","state":"PAID"},"job_timeline":[{"action":"ESCROW_LOCKED","amount":5,"available_after":18,"created":1791507811.0035262,"created_at":"2026-10-09T01:03:31.003526+00:00","id":"lux-tx-522","job_id":"job-4222fd59cac0891c","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":522,"locked_after":5},{"action":"RESULT_DELIVERED","amount":0,"available_after":18,"created":1791507828.0774255,"created_at":"2026-10-09T01:03:48.077425+00:00","id":"lux-tx-523","job_id":"job-4222fd59cac0891c","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":523,"locked_after":5},{"action":"PAYMENT_RELEASED","amount":5,"available_after":18,"created":1791507828.216085,"created_at":"2026-10-09T01:03:48.216085+00:00","id":"lux-tx-524","job_id":"job-4222fd59cac0891c","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":524,"locked_after":0}],"payment":{"amount":5,"contract_sha256":"993e711d6d2d808a060c63ce729e76ee45d9221bcd8c0be3cc92554fe4411250","currency":"USD","idempotency_key":"chat-1791507810024-3-attempt-0","job_id":"job-4222fd59cac0891c","ledger":"Central marketplace SQLite ledger; IDs are scoped to this marketplace","offer_id":"offer-scout-python-code","result_sha256":"717d8a9fe6f0e96b87cba214cf76cc47132350567315b1f8e940abc64c9916ed","seller_id":"scout","session_id":"session-3ad82e29143eb18a","simulated_payments":true,"state":"PAID","transactions":[{"action":"ESCROW_LOCKED","amount":5,"created":1791507811.0035262,"created_at":"2026-10-09T01:03:31.003526+00:00","currency":"USD","from_account":"available","from_wallet":"session-3ad82e29143eb18a","id":"lux-tx-522","job_id":"job-4222fd59cac0891c","ledger_id":522,"session_id":"session-3ad82e29143eb18a","to_account":"locked","to_wallet":"session-3ad82e29143eb18a"},{"action":"PAYMENT_RELEASED","amount":5,"created":1791507828.216085,"created_at":"2026-10-09T01:03:48.216085+00:00","currency":"USD","from_account":"locked","from_wallet":"session-3ad82e29143eb18a","id":"lux-tx-524","job_id":"job-4222fd59cac0891c","ledger_id":524,"session_id":"session-3ad82e29143eb18a","to_account":"available","to_wallet":"scout"}],"verification_receipts":["delivery-7c16b2ed52888ed9d1cacfeb"]},"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":30,"created":1791505380.6378937,"created_at":"2026-10-09T00:23:00.637894+00:00","fixture":"buggy","id":"session-3ad82e29143eb18a","service":"auto","title":"Audit the marketplace's demo cart page. Perform three HTTP checks against the demo cart endpoint (e.g., GET the cart page, verify it returns HTTP 200, confirm the cart contents/total render correctly, and check that adding/removing an item updates the cart state). Report each check with an execution receipt and a pass/fail summary."},"signature":{"alg":"ed25519-sha256","created_at":"2026-10-09T01:03:48.242733+00:00","key_id":"ppk-1eec83b33164f1bd","payload":"{\"amount\":5,\"contract_sha256\":\"993e711d6d2d808a060c63ce729e76ee45d9221bcd8c0be3cc92554fe4411250\",\"currency\":\"USD\",\"idempotency_key\":\"chat-1791507810024-3-attempt-0\",\"job_id\":\"job-4222fd59cac0891c\",\"offer_id\":\"offer-scout-python-code\",\"payload_version\":\"1.0\",\"result_sha256\":\"717d8a9fe6f0e96b87cba214cf76cc47132350567315b1f8e940abc64c9916ed\",\"seller_id\":\"scout\",\"session_id\":\"session-3ad82e29143eb18a\",\"settled_at\":\"2026-10-09T01:03:48.216085+00:00\",\"state\":\"PAID\",\"transactions\":[{\"action\":\"ESCROW_LOCKED\",\"amount\":5,\"created_at\":\"2026-10-09T01:03:31.003526+00:00\",\"id\":\"lux-tx-522\"},{\"action\":\"PAYMENT_RELEASED\",\"amount\":5,\"created_at\":\"2026-10-09T01:03:48.216085+00:00\",\"id\":\"lux-tx-524\"}],\"verification_receipts\":[\"delivery-7c16b2ed52888ed9d1cacfeb\"]}","payload_sha256":"7ef2b7da934461a7e4bb50cfbfca99d320c316c0d985759a15e83c43e0d7a628","value_base64":"N8A7z5+F5vCre8j9JVxMxWQX5siQzJzhXjvJBQcuHL3WITSgF1p6UeepoXQ+nmZrnG9ijFmm+Jg0bNAG5fW9BQ=="},"simulated_payments":true,"stripe_transfer":null,"timeline":[{"action":"LUX_COINS_ISSUED","amount":30,"available_after":30,"created":1791505380.638977,"created_at":"2026-10-09T00:23:00.638977+00:00","id":"lux-tx-504","job_id":null,"kind":"issue","label":"Test credits issued to the buyer wallet","ledger_id":504,"locked_after":0},{"action":"ESCROW_LOCKED","amount":3,"available_after":27,"created":1791505381.0334475,"created_at":"2026-10-09T00:23:01.033448+00:00","id":"lux-tx-505","job_id":"job-7401494199a0a7e7","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":505,"locked_after":3},{"action":"RESULT_DELIVERED","amount":0,"available_after":27,"created":1791505381.2238326,"created_at":"2026-10-09T00:23:01.223833+00:00","id":"lux-tx-506","job_id":"job-7401494199a0a7e7","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":506,"locked_after":3},{"action":"REFUND_AUTHORIZED_BY_CONTRACT","amount":3,"available_after":30,"created":1791505381.4202645,"created_at":"2026-10-09T00:23:01.420264+00:00","id":"lux-tx-507","job_id":"job-7401494199a0a7e7","kind":"refund","label":"Escrow returned to the buyer by contract","ledger_id":507,"locked_after":0},{"action":"ESCROW_LOCKED","amount":7,"available_after":23,"created":1791505385.012353,"created_at":"2026-10-09T00:23:05.012353+00:00","id":"lux-tx-508","job_id":"job-9aeb21586fd4e33a","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":508,"locked_after":7},{"action":"RESULT_DELIVERED","amount":0,"available_after":23,"created":1791505385.2257247,"created_at":"2026-10-09T00:23:05.225725+00:00","id":"lux-tx-509","job_id":"job-9aeb21586fd4e33a","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":509,"locked_after":7},{"action":"PAYMENT_RELEASED","amount":7,"available_after":23,"created":1791505385.3286967,"created_at":"2026-10-09T00:23:05.328697+00:00","id":"lux-tx-510","job_id":"job-9aeb21586fd4e33a","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":510,"locked_after":0},{"action":"ESCROW_LOCKED","amount":5,"available_after":18,"created":1791507811.0035262,"created_at":"2026-10-09T01:03:31.003526+00:00","id":"lux-tx-522","job_id":"job-4222fd59cac0891c","kind":"escrow","label":"Funds locked in escrow for the job","ledger_id":522,"locked_after":5},{"action":"RESULT_DELIVERED","amount":0,"available_after":18,"created":1791507828.0774255,"created_at":"2026-10-09T01:03:48.077425+00:00","id":"lux-tx-523","job_id":"job-4222fd59cac0891c","kind":"delivery","label":"Seller delivery recorded by the marketplace","ledger_id":523,"locked_after":5},{"action":"PAYMENT_RELEASED","amount":5,"available_after":18,"created":1791507828.216085,"created_at":"2026-10-09T01:03:48.216085+00:00","id":"lux-tx-524","job_id":"job-4222fd59cac0891c","kind":"payment","label":"Escrow released to the seller after verification","ledger_id":524,"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":18,"id":"session-3ad82e29143eb18a","kind":"buyer","locked":0},"seller":{"available":145,"id":"scout","kind":"seller","locked":0}}}