Created
July 25, 2026 06:08
-
-
Save copyleftdev/28ed6931c6174099b21db54846f72b65 to your computer and use it in GitHub Desktop.
Oddly Exact replay: reject unknown fields and refuse unbounded optimizer work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Replay the three requests that exposed contract and resource-boundary gaps in | |
| # Oddly Exact. Run from the agent-calc repository: | |
| # | |
| # cargo build --locked | |
| # bash oddly-exact-contract-challenge.sh | |
| calc_bin="${1:-target/debug/agent-calc}" | |
| expect_parse_rejection() { | |
| local request="$1" | |
| local expected_fragment="$2" | |
| local output | |
| local exit_status | |
| set +e | |
| output="$(printf '%s' "$request" | "$calc_bin" eval 2>&1)" | |
| exit_status=$? | |
| set -e | |
| if [[ "$exit_status" -ne 2 ]]; then | |
| printf 'expected exit 2, received %s\n%s\n' "$exit_status" "$output" >&2 | |
| return 1 | |
| fi | |
| if [[ "$output" != *"$expected_fragment"* ]]; then | |
| printf 'missing expected rejection: %s\n%s\n' "$expected_fragment" "$output" >&2 | |
| return 1 | |
| fi | |
| } | |
| expect_parse_rejection \ | |
| '{"expr":{"kind":"integer","value":"7"},"unexpected":true}' \ | |
| 'unknown field `unexpected`' | |
| expect_parse_rejection \ | |
| '{"expr":{"kind":"integer","value":"7","unexpected":true}}' \ | |
| 'unknown field `unexpected`' | |
| resource_response="$( | |
| printf '%s' \ | |
| '{"intent":"grid_search","objective":{"kind":"quadratic","a":1,"b":0,"c":0},"lower":-1,"upper":1,"resolution":1000000000}' | | |
| "$calc_bin" optimize | |
| )" | |
| if [[ "$resource_response" != *'"code": "resource_limit"'* ]] || | |
| [[ "$resource_response" != *'resolution must be <= 1000000'* ]]; then | |
| printf 'expected a typed resource-limit response\n%s\n' "$resource_response" >&2 | |
| exit 1 | |
| fi | |
| printf 'PASS: unknown fields rejected and excessive grid work refused\n' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment