Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

ci(workflow): add adversarial proof workflow for epic 8089

Steven Enamakel1bae9dfe228e
diff --git a/.github/workflows/epic-8089-devices-proof.yml b/.github/workflows/epic-8089-devices-proof.yml
new file mode 100644
index 0000000000..ece3934019
--- /dev/null
+++ b/.github/workflows/epic-8089-devices-proof.yml
@@ -0,0 +1,411 @@
+name: Epic 8089 Approval adversarial proof
+
+on:
+ push:
+ branches:
+ - epic-8089-228-devices-proof
+
+permissions:
+ actions: read
+ contents: read
+ packages: read
+
+env:
+ GH_TOKEN: ${{ github.token }}
+ CARGO_INCREMENTAL: "0"
+ CARGO_BUILD_JOBS: "1"
+ CARGO_PROFILE_DEV_DEBUG: line-tables-only
+ RUSTFLAGS: "-C link-arg=-fuse-ld=mold"
+ RUST_MIN_STACK: "33554432"
+
+concurrency:
+ group: approval-proof-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ devices-controller-proof:
+ if: github.repository == 'senamakel/openhuman'
+ name: Approval ${{ matrix.case }} contract proof
+ runs-on: ubuntu-22.04
+ timeout-minutes: 90
+ container:
+ image: ghcr.io/tinyhumansai/openhuman_ci:latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - case: baseline
+ expected_tree: 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ expected_schema_blob: 23221abbcf6e0a5180d5aa0f4973cec0b70736e8
+ expected_runtime_exit: 0
+ - case: schema-optional-removed
+ expected_tree: 37a0d66d3c9c5e64bc154ddbf60d2eed6d195f4b
+ expected_schema_blob: 3f5bb94102ccde9c8c23c9b5c8306a6d87ae99d4
+ expected_runtime_exit: 101
+ - case: schema-required-weakened
+ expected_tree: f95ab6a36df3c817dc803fd7c403b383dfd9a7eb
+ expected_schema_blob: 0e8c9793346289900dcfded4fd0468a57fd706f4
+ expected_runtime_exit: 101
+ - case: parser-wiring
+ expected_tree: 32a1ec5a193269e1f54717083bf00a70c5f4163e
+ expected_schema_blob: 63947647f9b95069da3c661b7573064da8515d0f
+ expected_runtime_exit: 101
+ steps:
+ - name: Free disk space on the hosted container
+ run: |
+ rm -rf /__t/* || true
+ df -h /__w || true
+
+ - name: Checkout the frozen Approval source and recursive pins
+ uses: actions/checkout@v7
+ with:
+ ref: 65d733aa2f8ebceba02fcee5b07258298d56973f
+ fetch-depth: 0
+ persist-credentials: false
+ submodules: recursive
+
+ - name: Trust container checkout and submodules
+ run: bash scripts/ci/trust-checkout.sh
+
+ - name: Install Rust 1.96.1
+ uses: dtolnay/[email protected]
+
+ - name: Assert frozen source and recursive pins
+ shell: bash
+ run: |
+ set -euo pipefail
+ test "$(git rev-parse HEAD)" = 65d733aa2f8ebceba02fcee5b07258298d56973f
+ test "$(git rev-parse HEAD^{tree})" = 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ test "$(git rev-parse HEAD:crates/openhuman-core/src/security/approval/schemas.rs)" = 23221abbcf6e0a5180d5aa0f4973cec0b70736e8
+ test -z "$(git status --porcelain=v1 --untracked-files=all)"
+ submodules="$(git submodule status --recursive)"
+ if grep -Eq '^[+-U]' <<< "$submodules"; then
+ printf '%s\n' "$submodules"
+ echo "recursive submodules are not at their recorded pins"
+ exit 1
+ fi
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+
+ - name: Cache Rust build artifacts
+ uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: . -> target
+ cache-on-failure: true
+ key: devices-proof
+
+ - name: Start fresh proof evidence after cache restore
+ shell: bash
+ env:
+ APPROVAL_PROOF_CASE: ${{ matrix.case }}
+ run: |
+ set -euo pipefail
+ rm -rf -- target/approval-proof
+ mkdir -p target/approval-proof
+ {
+ printf 'case=%s\n' "$APPROVAL_PROOF_CASE"
+ printf 'workflow_ref=%s\n' "$GITHUB_WORKFLOW_REF"
+ printf 'workflow_sha=%s\n' "$GITHUB_SHA"
+ printf 'workflow_repository=%s\n' "$GITHUB_REPOSITORY"
+ } > target/approval-proof/run-context.txt
+
+ - name: Apply exactly the selected mutation
+ if: matrix.case != 'baseline'
+ shell: bash
+ env:
+ APPROVAL_PROOF_CASE: ${{ matrix.case }}
+ run: |
+ set -euo pipefail
+ python3 - <<'PY'
+ import os
+ from pathlib import Path
+
+ path = Path("crates/openhuman-core/src/security/approval/schemas.rs")
+ source = path.read_text()
+ case = os.environ["APPROVAL_PROOF_CASE"]
+ if case == "schema-optional-removed":
+ old = ' inputs: vec![FieldSchema {\n name: "agent_id",\n ty: TypeSchema::Option(Box::new(TypeSchema::String)),\n comment: "Only the requests this embedded agent parked. Omit to list every request.",\n required: false,\n }],\n'
+ new = ' inputs: vec![],\n'
+ elif case == "schema-required-weakened":
+ old = ' name: "request_id",\n ty: TypeSchema::String,\n comment: "Identifier of the pending approval to decide.",\n required: true,'
+ new = ' name: "request_id",\n ty: TypeSchema::String,\n comment: "Identifier of the pending approval to decide.",\n required: false,'
+ elif case == "parser-wiring":
+ old = ' parse_list_pending,\n run_list_pending,'
+ new = ' |_params: Map<String, Value>| -> Result<Option<String>, String> {\n Err("mutation parser failure".to_owned())\n },\n run_list_pending,'
+ else:
+ raise SystemExit(f"unrecognized Approval proof case: {case}")
+ if source.count(old) != 1:
+ raise SystemExit(f"expected one exact mutation anchor; found {source.count(old)}")
+ path.write_text(source.replace(old, new, 1))
+ PY
+
+ - name: Freeze mutation patch and verify complete source tree
+ shell: bash
+ env:
+ EXPECTED_TREE: ${{ matrix.expected_tree }}
+ EXPECTED_SCHEMA_BLOB: ${{ matrix.expected_schema_blob }}
+ APPROVAL_PROOF_CASE: ${{ matrix.case }}
+ run: |
+ set -euo pipefail
+ source=crates/openhuman-core/src/security/approval/schemas.rs
+ evidence=target/approval-proof
+ test "$(git rev-parse HEAD)" = 65d733aa2f8ebceba02fcee5b07258298d56973f
+ test "$(git rev-parse HEAD^{tree})" = 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ test "$(git rev-parse HEAD:$source)" = 23221abbcf6e0a5180d5aa0f4973cec0b70736e8
+ if [ "$APPROVAL_PROOF_CASE" = baseline ]; then
+ test -z "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)"
+ else
+ test "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)" = " M $source"
+ fi
+ git submodule status --recursive > "$evidence/submodules-before-build.txt"
+ if grep -Eq '^[+-U]' "$evidence/submodules-before-build.txt"; then
+ cat "$evidence/submodules-before-build.txt"
+ echo "recursive submodules are not at their recorded pins"
+ exit 1
+ fi
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+ if [ "$APPROVAL_PROOF_CASE" != baseline ]; then
+ git add -- "$source"
+ fi
+ actual_tree="$(git write-tree)"
+ actual_blob="$(git rev-parse :"$source")"
+ test "$actual_tree" = "$EXPECTED_TREE"
+ test "$actual_blob" = "$EXPECTED_SCHEMA_BLOB"
+ mkdir -p target/build-tmp target/debug/proof-binaries
+ git diff --cached --binary 65d733aa2f8ebceba02fcee5b07258298d56973f -- "$source" > "$evidence/mutation.patch"
+ git diff --cached 65d733aa2f8ebceba02fcee5b07258298d56973f -- "$source" > "$evidence/mutation.diff"
+ sha256sum "$evidence/mutation.patch" > "$evidence/mutation.patch.sha256"
+ {
+ printf 'case=%s\n' "$APPROVAL_PROOF_CASE"
+ printf 'source_head=65d733aa2f8ebceba02fcee5b07258298d56973f\n'
+ printf 'baseline_tree=12a5f5db7fae5ee6e5e89e285fbdaf19279484e7\n'
+ printf 'workflow_ref=%s\n' "$GITHUB_WORKFLOW_REF"
+ printf 'workflow_sha=%s\n' "$GITHUB_SHA"
+ printf 'workflow_repository=%s\n' "$GITHUB_REPOSITORY"
+ printf 'source_tree=%s\n' "$actual_tree"
+ printf 'schemas_blob=%s\n' "$actual_blob"
+ cat "$evidence/mutation.patch.sha256"
+ printf 'features=default,voice,inference\n'
+ printf 'rustc_version=%s\n' "$(rustc --version)"
+ printf 'cargo_version=%s\n' "$(cargo --version)"
+ printf 'host_mem_available_kib=%s\n' "$(awk '/MemAvailable/ {print $2}' /proc/meminfo)"
+ printf 'build_filesystem=%s\n' "$(df -Pk . | tail -n 1)"
+ } > "$evidence/receipt.txt"
+ git submodule status --recursive > "$evidence/submodules-before-build.txt"
+ if grep -Eq '^[+-U]' "$evidence/submodules-before-build.txt"; then
+ cat "$evidence/submodules-before-build.txt"
+ echo "recursive submodules are not at their recorded pins"
+ exit 1
+ fi
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+
+ - name: Compile the core lib-test binary once
+ shell: bash
+ env:
+ EXPECTED_TREE: ${{ matrix.expected_tree }}
+ EXPECTED_SCHEMA_BLOB: ${{ matrix.expected_schema_blob }}
+ APPROVAL_PROOF_CASE: ${{ matrix.case }}
+ run: |
+ set -euo pipefail
+ mkdir -p target/build-tmp target/approval-proof target/debug/proof-binaries
+ evidence=target/approval-proof
+ export TMPDIR="$GITHUB_WORKSPACE/target/build-tmp"
+ source=crates/openhuman-core/src/security/approval/schemas.rs
+ test "$(git rev-parse HEAD)" = 65d733aa2f8ebceba02fcee5b07258298d56973f
+ test "$(git write-tree)" = "$EXPECTED_TREE"
+ test "$(git rev-parse :"$source")" = "$EXPECTED_SCHEMA_BLOB"
+ git diff --exit-code --ignore-submodules=none
+ if [ "$APPROVAL_PROOF_CASE" = baseline ]; then
+ test -z "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)"
+ else
+ test "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)" = "M $source"
+ fi
+ git submodule status --recursive > "$evidence/submodules-before-build.txt"
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+
+ build_json="$evidence/build.jsonl"
+ build_stderr="$evidence/build.stderr"
+ build_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+ build_epoch="$(date +%s)"
+ set +e
+ bash scripts/ci-cancel-aware.sh cargo test -p openhuman --locked --lib --features voice,inference --no-run --message-format=json > "$build_json" 2> "$build_stderr"
+ build_exit=$?
+ set -e
+ build_ended="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+ build_elapsed=$(($(date +%s) - build_epoch))
+ printf 'build_started_utc=%s\nbuild_ended_utc=%s\nbuild_elapsed_seconds=%s\nbuild_exit=%s\n' "$build_started" "$build_ended" "$build_elapsed" "$build_exit" >> "$evidence/receipt.txt"
+ if [ "$build_exit" -ne 0 ]; then
+ cat "$build_stderr"
+ exit "$build_exit"
+ fi
+
+ test "$(git rev-parse HEAD^{tree})" = 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ test "$(git write-tree)" = "$EXPECTED_TREE"
+ test "$(git rev-parse :"$source")" = "$EXPECTED_SCHEMA_BLOB"
+ git diff --exit-code --ignore-submodules=none
+ if [ "$APPROVAL_PROOF_CASE" = baseline ]; then
+ test -z "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)"
+ else
+ test "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)" = "M $source"
+ fi
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+ git submodule status --recursive > "$evidence/submodules-after-build.txt"
+ cmp "$evidence/submodules-before-build.txt" "$evidence/submodules-after-build.txt"
+
+ python3 - "$build_json" "$evidence/test-binary-path" "$evidence/compiler-fresh.txt" <<'PY'
+ import json
+ import sys
+
+ artifacts = []
+ fresh_values = []
+ with open(sys.argv[1], encoding="utf-8") as stream:
+ for line in stream:
+ try:
+ message = json.loads(line)
+ except json.JSONDecodeError:
+ continue
+ target = message.get("target", {})
+ executable = message.get("executable")
+ if (
+ message.get("reason") == "compiler-artifact"
+ and target.get("name") == "openhuman_core"
+ and target.get("test") is True
+ and executable
+ ):
+ artifacts.append(executable)
+ fresh_values.append(str(message.get("fresh", "unknown")))
+ if len(artifacts) != 1:
+ raise SystemExit(f"expected exactly one openhuman lib-test binary, got {artifacts!r}")
+ with open(sys.argv[2], "w", encoding="utf-8") as stream:
+ stream.write(artifacts[0] + "\n")
+ with open(sys.argv[3], "w", encoding="utf-8") as stream:
+ stream.write("\n".join(fresh_values) + "\n")
+ PY
+ source_binary="$(cat "$evidence/test-binary-path")"
+ binary=target/debug/proof-binaries/approval-${{ matrix.case }}
+ cp "$source_binary" "$binary"
+ sha256sum "$binary" > "$evidence/test-binary.sha256"
+ "$binary" --list > "$evidence/test-list.txt"
+ sha256sum "$evidence/test-list.txt" > "$evidence/test-list.sha256"
+ raw_filter=core::all::bound_controller_tests::approval_controller_tests::raw_approval_security_registry_matches_its_independent_contract
+ grep -Fxq "$raw_filter: test" "$evidence/test-list.txt"
+ {
+ printf 'compiler_artifact_fresh='; paste -sd, "$evidence/compiler-fresh.txt"
+ printf 'immutable_binary=%s\n' "$binary"
+ cat "$evidence/test-binary.sha256"
+ cat "$evidence/test-list.sha256"
+ } >> "$evidence/receipt.txt"
+
+ - name: Run exact raw registry and parser-control tests
+ shell: bash
+ env:
+ EXPECTED_RUNTIME_EXIT: ${{ matrix.expected_runtime_exit }}
+ APPROVAL_PROOF_CASE: ${{ matrix.case }}
+ run: |
+ set -euo pipefail
+ evidence=target/approval-proof
+ binary=target/debug/proof-binaries/approval-${{ matrix.case }}
+ raw_filter=core::all::bound_controller_tests::approval_controller_tests::raw_approval_security_registry_matches_its_independent_contract
+ raw_log="$evidence/raw-contract.log"
+ printf 'raw_filter=%s\nraw_command=%s %s --exact --test-threads=1\nexpected_raw_exit=%s\n' "$raw_filter" "$binary" "$raw_filter" "$EXPECTED_RUNTIME_EXIT" >> "$evidence/receipt.txt"
+ raw_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+ set +e
+ "$binary" "$raw_filter" --exact --test-threads=1 > "$raw_log" 2>&1
+ raw_exit=$?
+ set -e
+ raw_ended="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+ printf 'raw_started_utc=%s\nraw_ended_utc=%s\nraw_exit=%s\n' "$raw_started" "$raw_ended" "$raw_exit" >> "$evidence/receipt.txt"
+ if [ "$raw_exit" -ne "$EXPECTED_RUNTIME_EXIT" ]; then
+ cat "$raw_log"
+ echo "unexpected raw contract exit: $raw_exit"
+ exit 1
+ fi
+ case "$APPROVAL_PROOF_CASE" in
+ baseline)
+ grep -Fq 'test result: ok. 1 passed; 0 failed;' "$raw_log"
+ ;;
+ schema-optional-removed)
+ grep -Fq 'approval.list_pending optional inputs mismatch' "$raw_log"
+ grep -Fq 'test result: FAILED. 0 passed; 1 failed;' "$raw_log"
+ ;;
+ schema-required-weakened)
+ grep -Fq 'approval.decide required inputs mismatch' "$raw_log"
+ grep -Fq 'test result: FAILED. 0 passed; 1 failed;' "$raw_log"
+ ;;
+ parser-wiring)
+ grep -Fq 'approval.list_pending bound decoder rejects example 0: mutation parser failure' "$raw_log"
+ grep -Fq 'test result: FAILED. 0 passed; 1 failed;' "$raw_log"
+ ;;
+ esac
+ cat "$raw_log"
+
+ if [ "$APPROVAL_PROOF_CASE" = parser-wiring ]; then
+ control_filter=security::approval::schemas::tests::list_pending_parser_trims_optional_agent_and_ignores_extras
+ control_log="$evidence/direct-parser-control.log"
+ printf 'direct_parser_control_filter=%s\n' "$control_filter" >> "$evidence/receipt.txt"
+ set +e
+ "$binary" "$control_filter" --exact --test-threads=1 > "$control_log" 2>&1
+ control_exit=$?
+ set -e
+ printf 'direct_parser_control_exit=%s\n' "$control_exit" >> "$evidence/receipt.txt"
+ test "$control_exit" -eq 0
+ grep -Fq 'test result: ok. 1 passed; 0 failed;' "$control_log"
+ fi
+
+ - name: Upload matching test binary
+ if: success()
+ uses: actions/upload-artifact@v7
+ with:
+ name: approval-proof-${{ matrix.case }}-binary
+ path: target/debug/proof-binaries/approval-${{ matrix.case }}
+ if-no-files-found: error
+ retention-days: 1
+ compression-level: 1
+
+ - name: Run the Rust layout and storage schema gates on the baseline
+ if: matrix.case == 'baseline'
+ shell: bash
+ run: |
+ set -euo pipefail
+ evidence=target/approval-proof
+ mkdir -p target/build-tmp
+ export TMPDIR="$GITHUB_WORKSPACE/target/build-tmp"
+ schema="$evidence/storage-schema.json"
+ schema_stderr="$evidence/storage-schema.stderr"
+ set +e
+ bash scripts/ci-cancel-aware.sh cargo run --locked -p openhuman-cli --example storage_schema_dump --features web3 > "$schema" 2> "$schema_stderr"
+ schema_exit=$?
+ set -e
+ printf 'storage_schema_exit=%s\n' "$schema_exit" >> "$evidence/receipt.txt"
+ if [ "$schema_exit" -ne 0 ]; then
+ cat "$schema_stderr"
+ exit "$schema_exit"
+ fi
+ layout_log="$evidence/rust-layout.log"
+ set +e
+ bash scripts/ci-cancel-aware.sh pnpm rust:layout > "$layout_log" 2>&1
+ layout_exit=$?
+ set -e
+ printf 'rust_layout_exit=%s\n' "$layout_exit" >> "$evidence/receipt.txt"
+ if [ "$layout_exit" -ne 0 ]; then
+ cat "$layout_log"
+ exit "$layout_exit"
+ fi
+ node scripts/ci/check-storage-schema.mjs --schema "$schema" > "$evidence/storage-schema-check.log" 2>&1
+ test "$(git rev-parse HEAD^{tree})" = 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ test "$(git write-tree)" = 12a5f5db7fae5ee6e5e89e285fbdaf19279484e7
+ test "$(git rev-parse HEAD:crates/openhuman-core/src/security/approval/schemas.rs)" = 23221abbcf6e0a5180d5aa0f4973cec0b70736e8
+ git diff --exit-code --ignore-submodules=none
+ test -z "$(git status --porcelain=v1 --untracked-files=all --ignore-submodules=none)"
+ git submodule foreach --quiet --recursive 'test -z "$(git status --porcelain=v1 --untracked-files=all)"'
+ git submodule status --recursive > "$evidence/submodules-after-layout.txt"
+ cmp "$evidence/submodules-before-build.txt" "$evidence/submodules-after-layout.txt"
+
+ - name: Upload proof receipts and logs
+ if: always()
+ uses: actions/upload-artifact@v7
+ with:
+ name: approval-proof-${{ matrix.case }}
+ path: target/approval-proof/
+ if-no-files-found: error
+ retention-days: 30
+