Repository navigation
test(ffi): fail-closed Rustler/libproven ABI symbol contract with planted controls #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
de5ee81
ead5185
fe46aba
254bd07
e1a8778
597e440
9c95a13
788daff
60b636f
8f75c7f
e757802
59301c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ on: | |
| - 'scripts/build-header-refc.sh' | ||
| - 'scripts/test-refc-staging.sh' | ||
| - '.github/workflows/ffi-full-integration.yml' | ||
| - 'bindings/elixir/native/proven_nif/src/lib.rs' | ||
| - 'scripts/check-native-nif-exports.sh' | ||
| - 'tests/check-native-nif-exports.sh' | ||
| - 'tests/check-refc-staging.sh' | ||
| pull_request: | ||
| paths: | ||
| - 'src/**' | ||
|
|
@@ -25,11 +29,32 @@ on: | |
| - 'scripts/build-header-refc.sh' | ||
| - 'scripts/test-refc-staging.sh' | ||
| - '.github/workflows/ffi-full-integration.yml' | ||
| - 'bindings/elixir/native/proven_nif/src/lib.rs' | ||
| - 'scripts/check-native-nif-exports.sh' | ||
| - 'tests/check-native-nif-exports.sh' | ||
| - 'tests/check-refc-staging.sh' | ||
| workflow_dispatch: | ||
| concurrency: | ||
| group: ffi-full-integration-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| nif-abi-symbol-controls: | ||
| name: Native ABI symbol validator (planted controls only) | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Checkout proven | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Execute real positive and negative controls | ||
| # This proves the validator detects missing exports. It does NOT | ||
| # imply any real libproven artifact was built or validated. | ||
| run: bash tests/check-native-nif-exports.sh | ||
| - name: RefC staging regression controls | ||
| # Planted empty/stale compiler outputs must not become fake evidence. | ||
| run: bash tests/check-refc-staging.sh | ||
|
|
||
| idris-refc-zig: | ||
| name: Idris -> RefC -> Zig | ||
| runs-on: ubuntu-22.04 | ||
|
|
@@ -39,6 +64,53 @@ jobs: | |
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Check language-bridges credential | ||
| id: bridge-token | ||
| env: | ||
| LANGUAGE_BRIDGES_TOKEN: ${{ secrets.LANGUAGE_BRIDGES_TOKEN }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "$LANGUAGE_BRIDGES_TOKEN" ]; then | ||
| echo "available=false" >> "$GITHUB_OUTPUT" | ||
| echo "::error title=Full FFI not run::LANGUAGE_BRIDGES_TOKEN is absent; genuine Idris2/RefC/Zig integration cannot be verified." | ||
| echo "PROVEN_FFI_CLASS=not_run:missing_private_dependency" | ||
| exit 2 | ||
| fi | ||
| echo "available=true" >> "$GITHUB_OUTPUT" | ||
| - name: Checkout language-bridges | ||
| if: steps.bridge-token.outputs.available == 'true' | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
| with: | ||
| repository: nextgen-languages/language-bridges | ||
| path: nextgen-languages/language-bridges | ||
| token: ${{ secrets.LANGUAGE_BRIDGES_TOKEN }} | ||
| persist-credentials: false | ||
| - name: Install Idris 2 dependencies | ||
| if: steps.bridge-token.outputs.available == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| sudo apt-get update | ||
| sudo apt-get install -y chezscheme libgmp-dev | ||
| - name: Cache Idris 2 | ||
| if: steps.bridge-token.outputs.available == 'true' | ||
| id: cache-idris2 | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: | | ||
| ~/.idris2 | ||
| ~/idris2-${{ env.IDRIS2_VERSION }} | ||
| key: idris2-refc-${{ env.IDRIS2_VERSION }}-${{ runner.os }} | ||
| - name: Install Idris 2 | ||
| if: steps.bridge-token.outputs.available == 'true' && steps.cache-idris2.outputs.cache-hit != 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| git clone --depth 1 --branch v${{ env.IDRIS2_VERSION }} https://github.com/idris-lang/Idris2.git ~/idris2-${{ env.IDRIS2_VERSION }} | ||
| cd ~/idris2-${{ env.IDRIS2_VERSION }} | ||
|
Comment on lines
+107
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| make bootstrap SCHEME=chezscheme | ||
| make install | ||
| - name: Add Idris 2 to PATH | ||
| if: steps.bridge-token.outputs.available == 'true' | ||
| run: echo "$HOME/.idris2/bin" >> "$GITHUB_PATH" | ||
| - name: Setup Zig | ||
| uses: mlugg/setup-zig@e7d1537c378b83b8049f65dda471d87a2f7b2df2 # v1 | ||
| with: | ||
|
|
@@ -54,22 +126,24 @@ jobs: | |
| set -euo pipefail | ||
| source build/refc/sdk.env | ||
| cd ffi/zig | ||
| zig build --summary all \ | ||
| -Didris-refc="$REFC_OUTPUT_DIR" \ | ||
| -Didris-refc-runtime="$IDRIS2_REFC_RUNTIME" \ | ||
| -Didris-c-support="$IDRIS2_C_SUPPORT" \ | ||
| -Didris-support-lib="$IDRIS2_SUPPORT_LIB" 2>&1 | tee ../../build/refc/zig-build.log | ||
| zig build test --summary all \ | ||
| -Didris-refc="$REFC_OUTPUT_DIR" \ | ||
| -Didris-refc-runtime="$IDRIS2_REFC_RUNTIME" \ | ||
| -Didris-c-support="$IDRIS2_C_SUPPORT" \ | ||
| -Didris-support-lib="$IDRIS2_SUPPORT_LIB" 2>&1 | tee ../../build/refc/zig-tests.log | ||
| test -s zig-out/lib/libproven.a | ||
| - name: Reject stale output and misleading compiler success | ||
| run: bash scripts/test-refc-staging.sh | ||
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| if: always() | ||
| with: | ||
| name: full-refc-build-evidence | ||
| path: build/refc/ | ||
| if-no-files-found: error | ||
| zig build \ | ||
| -Didris-refc="$GITHUB_WORKSPACE/build/refc" \ | ||
| -Didris-refc-runtime="$REFC_RUNTIME" \ | ||
| -Didris-c-support="$C_SUPPORT" \ | ||
| -Didris-support-lib="$SUPPORT_LIB" | ||
|
Comment on lines
+131
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the checked Useful? React with 👍 / 👎. |
||
| zig build test \ | ||
| -Didris-refc="$GITHUB_WORKSPACE/build/refc" \ | ||
| -Didris-refc-runtime="$REFC_RUNTIME" \ | ||
| -Didris-c-support="$C_SUPPORT" \ | ||
| -Didris-support-lib="$SUPPORT_LIB" | ||
| ls -la zig-out/lib/libproven.* | ||
| - name: Verify the genuine built artifact exports every Rustler NIF symbol | ||
| if: steps.bridge-token.outputs.available == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| artifact="$GITHUB_WORKSPACE/ffi/zig/zig-out/lib/libproven.a" | ||
| if [ ! -f "$artifact" ]; then | ||
| echo "::error::Missing actual libproven.a, not a successful integration." | ||
| exit 1 | ||
| fi | ||
| bash scripts/check-native-nif-exports.sh "$artifact" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // SPDX-License-Identifier: CC-BY-SA-4.0 | ||
| // SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell | ||
| = Native libproven / Rustler ABI boundary | ||
|
|
||
| This repository currently has a *broken consumer boundary*, not a missing | ||
| search directory alone. `bindings/elixir/native/proven_nif/src/lib.rs` | ||
| declares 66 `proven_*` C ABI functions. The current | ||
| `ffi/zig/src/main.zig` exports 17 `proven_*` functions and does not | ||
| define most of the required functions, such as `proven_math_div`. | ||
| The shared name `proven_init` also has incompatible return types: | ||
| Rust declares `i32` while Zig returns an optional `*Handle`. | ||
| These are source observations, not a verified inventory of any | ||
| generated Idris2 RefC C output. | ||
|
|
||
| == Actual Idris2 RefC package scope | ||
|
|
||
| On 2026-11-15 an isolated checkout ran `idris2 --build proven-ffi.ipkg` | ||
| and `idris2 --codegen refc --build proven-ffi.ipkg` using Idris2 | ||
| 0.8.0. Both compiled successfully. The package currently lists | ||
| `Proven.Core`, `Proven.SafeUrl.Parser`, | ||
| `Proven.FFI.SafeUrl` and `Proven.FFI.Main`; compilation also loads | ||
| the imported SafeUrl/Query modules. `Proven.FFI.Main` references | ||
| *SafeUrl only*. This package does not presently include an Idris2 FFI | ||
|
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reviewed Useful? React with 👍 / 👎. |
||
| implementation for the Rustler NIF's math, crypto, string and other | ||
| API families. A successfully generated `proven-ffi.c` is **not** a | ||
| complete 66-function Idris-backed ABI. | ||
|
|
||
| The existing `scripts/build-refc.sh` also previously scanned | ||
| `build/exec` and its parent `build` (double-counting the same | ||
| source), and could report success even when the compiler produced no | ||
| C. It now requires at least one *fresh* generated C source, deduplicates | ||
| the scan, and replaces stale staged sources. The five fake-compiler | ||
| controls in `tests/check-refc-staging.sh` exercise empty, stale, | ||
| fresh and failed generation, while an independent live Idris2/RefC | ||
| build has confirmed one generated source file. Neither fixture | ||
| testing nor one generated C source proves complete ABI parity. | ||
|
|
||
| == A mandatory precondition, not a substitute for proof | ||
|
|
||
| Run `bash scripts/check-native-nif-exports.sh /path/to/libproven.so` | ||
| *after* the authentic Idris2 -> RefC -> Zig library build. | ||
| For a static library, pass `libproven.a` instead. | ||
|
|
||
| The checker extracts required C symbols from the Rust `extern "C"` block | ||
| and confirms that the compiled library *defines* all of them. Missing | ||
| names cause exit 1; missing tools/inputs or unreadable artifacts cause | ||
| exit 2 (NOT RUN); only a complete symbol list gives exit 0. | ||
|
|
||
| The script expressly **does not verify ABI types, memory ownership, | ||
| verified Idris2 provenance, dynamic dependencies, or behavioural | ||
| semantics**. Its positive controls are fixture libraries, not | ||
| `libproven` evidence. Type/layout compatibility must additionally be | ||
| checked against an authoritative C header, with compiled calls and | ||
| negative fixtures, before declaring the full interface safe. | ||
| Actual runtime behaviour must be exercised from Elixir and Rust. | ||
|
|
||
| == Required upstream repairs | ||
|
|
||
| . Resolve the currently private `nextgen-languages/language-bridges` | ||
| dependency with correctly scoped credentials or a reviewed vendor pin. | ||
| . Produce genuine Idris2 RefC code, with pinned compiler/runtime inputs, | ||
| and include the required ABI implementation in the Zig linker. | ||
| . Agree whether the consumer links a static or shared `libproven`. | ||
| The Zig build currently emits a static target while Rust explicitly | ||
| requests `dylib=proven`. | ||
| . Repair all 66 function contracts, including `proven_init` return | ||
| type and correct ownership of returned buffers. | ||
| . Check exported symbols on *the exact artifact to be consumed*; run | ||
| typed calls against it and the real Elixir/Rustler integration. | ||
| . Publish immutable, attestable artifact provenance and a pinned, | ||
| reproducible consumer configuration. Never silently substitute | ||
| `build_standalone.zig`, which builds a narrower pure Zig ABI. | ||
|
|
||
| == Positive and negative gate controls | ||
|
|
||
| `bash tests/check-native-nif-exports.sh` runs six isolated cases: | ||
| a defined shared and static fixture, deliberately missing symbols, | ||
| missing input, an empty contract, and a corrupt binary. These tests | ||
| establish only that the name-presence gate fails closed; they do | ||
| not certify this repository's actual `libproven` ABI. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fork pull requests and other runs without repository secrets, this unconditional exit prevents the real Idris/RefC/Zig integration from running even though the checked
proven-ffi.ipkgdepends only oncontrib, the subsequent build commands never reference the checked-out bridge directory, anddocs/ffi-ci-build.adocexplicitly records that the unused private dependency was removed. RequiringLANGUAGE_BRIDGES_TOKENtherefore turns an otherwise self-contained build into a permanent failure for those contexts.Useful? React with 👍 / 👎.