Skip to content

dev: isolated C++ WFA2-lib FFI oracle for #102 (no-ship)#57

Merged
cjfields merged 2 commits into
mainfrom
dev/wfa-ffi-oracle
Jun 21, 2026
Merged

dev: isolated C++ WFA2-lib FFI oracle for #102 (no-ship)#57
cjfields merged 2 commits into
mainfrom
dev/wfa-ffi-oracle

Conversation

@cjfields

Copy link
Copy Markdown
Member

Summary

Follow-up to #56 (the WFA ends-free regression test + CI warnings, already merged). Adds the throwaway oracle under dev/wfa-ffi-oracle/ that the #56 work referenced, plus the actual run results.

These two commits were authored on the #56 branch after it merged, so they didn't ride that PR — this brings them to main on their own.

What it does

Builds the C++ WFA2-lib at a pinned commit (run.sh clones + builds) and runs our committed reproducers under DADA2 ends-free scoring (match +5) to answer: does upstream C++ fix the ends-free + nonzero-match suboptimality (WFA2-lib #102) that the pure-Rust port exhibits?

It is a test oracle only — nothing here ships. It's a standalone Cargo workspace + a C harness linked against the C++ static lib; neither is a dada2-rs dependency, so no C/C++ toolchain leaks into CI or releases.

Result (WFA2-lib bcf473a): #102 is partially fixed — 3/5 optimal

  • Mode 1 (free leading/trailing end-gap crediting, incl. the issue's own GCGG/CG) — fixed in C++.
  • Mode 2 (mismatch + free-end indel preferred over a higher-scoring interior gap) — still off by 1 upstream.
  • The pure-Rust port is not at parity with C++: it gives 247 on Mode 1 where C++ gives the optimal 255 — the same upstream fix the port lacks. So most of our divergence is port staleness (tractable), with Mode 2 the genuine residual.

Does not unlock WFA as the error-model backend (Mode 2 keeps it ≠ NW), so NW stays default. Full results table + interpretation in the README.

Test plan

  • cd dev/wfa-ffi-oracle && ./run.sh reproduces 3/5 (prints per-case PASS/FAIL + CIGAR).
  • Root cargo metadata lists only dada2-rs (oracle is fully isolated); root fmt/clippy/sync hooks unaffected.

🤖 Generated with Claude Code

cjfields and others added 2 commits June 20, 2026 21:45
Scaffold dev/wfa-ffi-oracle/ — a standalone Cargo project (own [workspace], so
the root build never touches it) that will test whether the *C++* WFA2-lib
returns the optimal ends-free alignment with match score != 0 (upstream #102),
which the pure-Rust port does not. FFI is used here ON PURPOSE but only as a
test oracle; nothing here is a dada2-rs dependency, so no C++ toolchain leaks
into CI or releases.

Hard-codes the two committed reproducers (leading-gap 255-vs-247 and the #102
GCGG/CG minimal). Currently a stub (no external dep) that compiles, prints the
known values, and documents the decision: PASS on every case => port the
match-aware ends-free termination into wfa2lib-rs::termination.rs; any FAIL =>
#102 is unfixed upstream and WFA stays experimental. Binding is left as a
documented TODO in the README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xes #102

Wire the oracle to the actual C++ WFA2-lib (oracle.c + run.sh, which clones and
builds WFA2-lib at a pinned commit) and record results. Verdict on bcf473a:
3/5 reproducers optimal. The leading/trailing free-end-gap fix (Mode 1, the
common case incl. the issue's own GCGG/CG) is present upstream, but Mode 2
(mismatch + free-end indel preferred over a higher-scoring interior gap)
persists — off by 1 on two near-end cases.

Notably the pure-Rust port (wfa2lib-rs @4cfeda8) is NOT at parity with C++: it
misses even the Mode 1 fix (gives 247 where C++ gives the optimal 255). So
porting C++'s ends-free termination would close the bulk (Mode 1) of our
divergence, but Mode 2 survives upstream — WFA stays non-identical to NW, so
option (c) stands (NW remains the error-model backend).

Keep the Rust binding stub as the optional pure-Rust-oracle skeleton.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cjfields

Copy link
Copy Markdown
Member Author

I strongly suspect the Rust port predates the more recent updates on WGA2-lib. The challenge will likely end up being whether the port can stay relatively in sync with the upstream changes, or if it would be better to use FFI and the C++ library.

@cjfields cjfields merged commit 20bfba8 into main Jun 21, 2026
7 checks passed
@cjfields cjfields deleted the dev/wfa-ffi-oracle branch June 21, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant