Problem
`bindings-uniffi/src/lib.rs` has 260+ lines of wrapper code exposing `FaffWorkspace` to foreign consumers, but zero tests. No `#[cfg(test)]` module exists anywhere in the crate.
The binding currently relies entirely on faff-tui (the Go consumer) as its integration test. When something breaks at the FFI boundary, we find out from a broken Go build downstream — not from CI on this repo.
Coverage gap
Every exposed method in the UDL is untested at the binding layer:
- `FaffWorkspace` constructor (tokio runtime init, workspace init)
- `get_log` — date parsing, RFC3339 string conversion for time fields
- `start_session`, `stop_current_session`, `update_active_session`
- `update_session_at` (the one this is a follow-up for)
- Vocabulary queries: `get_roles`, `get_impacts`, `get_modes`, `get_subjects`, `get_trackers`, `get_session_hints`
- `recent_prototypes` — the binding-side dedup/ranking logic, which is NOT covered by core tests since it lives in the binding
Why this matters
- Error mapping is lossy. `anyhow::Error` → `FaffError::Other` via string matching. A behavior change in core's error messages can silently change the FFI error variant with no signal.
- Type conversions are manual. RFC3339 string round-trips, `Vec` sort order, `ProtoKey` dedup by tuple — all implemented by hand in lib.rs, zero coverage.
- Runtime ownership. The binding owns its tokio runtime (vs bindings-python's per-call creation). If that invariant changes, nothing catches it.
- `recent_prototypes` is binding-only logic. Walks logs, groups by tuple key, ranks by count + recency. ~60 lines of code, zero tests.
Suggested fix
Add a `#[cfg(test)]` module to `bindings-uniffi/src/lib.rs` with tests that:
- Use the same `MockStorage` + `create_test_workspace` pattern as core's tests
- Exercise each method's happy path + at least one error path
- Cover `recent_prototypes` dedup and ranking with hand-constructed logs
- Verify RFC3339 round-trip for `start` / `end` fields (parse → serialize matches)
- Assert error variant mapping (`FaffError::InvalidDate`, `NoActiveSession`, `Other`)
Target: ~15 tests, ~250 lines. Same volume as `bindings-python/tests/test_python_bindings.py` which covers the parallel PyO3 surface.
Related
- CI (`.github/workflows/ci.yml`) already runs `cargo test --workspace --all-features` which would pick up new tests in `bindings-uniffi` automatically. No CI changes needed.
- Parallel gap for `bindings-wasm` (1 smoke test only) tracked separately if desired.
Problem
`bindings-uniffi/src/lib.rs` has 260+ lines of wrapper code exposing `FaffWorkspace` to foreign consumers, but zero tests. No `#[cfg(test)]` module exists anywhere in the crate.
The binding currently relies entirely on faff-tui (the Go consumer) as its integration test. When something breaks at the FFI boundary, we find out from a broken Go build downstream — not from CI on this repo.
Coverage gap
Every exposed method in the UDL is untested at the binding layer:
Why this matters
Suggested fix
Add a `#[cfg(test)]` module to `bindings-uniffi/src/lib.rs` with tests that:
Target: ~15 tests, ~250 lines. Same volume as `bindings-python/tests/test_python_bindings.py` which covers the parallel PyO3 surface.
Related