Commit 696c495
fix(soundness): FFI octad ops fail loudly instead of reporting false success (#179)
## Summary
Closes five soundness holes found in a focused audit — places where the
FFI/validation reported success without delivering it.
The most serious: **`verisimiser_verify_provenance` returned `.ok`
("verified") without walking the hash chain**, so a *tampered*
provenance chain passed as verified. `record_provenance`,
`record_version`, and `enable_dimension` likewise validated their enums
and then silently no-op'd while returning `.ok`, so callers believed
data had been recorded / a dimension enabled when nothing happened. The
Idris2 ABI proofs (`HashChain`/`Version`/`Octad`) and the Rust `tier1`
library are sound; the gap was the un-wired Zig FFI layer claiming
success.
Per doctrine ("fail loudly, seal soundly — no silent green"), these now
return `.sidecar_unavailable` until the sidecar persistence is wired in
(that wiring is breadth, deferred). Argument-validation paths (null
handle → `.null_pointer`, invalid enum → `.invalid_param`) are
unchanged. No `Result` variant was added, so the ABI-FFI gate stays
green.
Also fixed: `validate_manifest` never called `effective_backend()`, so a
manifest with conflicting `[database].backend` and legacy `target-db`
passed validation and only failed later at generate time — now surfaced
up front as a failed `backend-unambiguous` check.
## Changes
- `src/interface/ffi/src/main.zig`: `verify_provenance` /
`record_provenance` / `record_version` / `enable_dimension` return
`.sidecar_unavailable` (with a clear error message) instead of a false
`.ok`.
- `src/manifest/mod.rs`: `validate_manifest` adds a
`backend-unambiguous` check that exercises `effective_backend()`.
## Testing
- Zig: added tests asserting each of the four ops does **not** return
`.ok` with a valid handle (and returns `.sidecar_unavailable`). Existing
null/invalid-enum tests unchanged. (`zig test` runs in the ABI-FFI
gate.)
- Rust: added `conflicting_backend_fails_validation`. Full suite green
under the CI toolchain (1.96.0): `cargo fmt --check`, `cargo clippy
--all-targets -- -D warnings`, `cargo test --locked --all-targets` (146
lib tests).
## RSR Quality Checklist
- [x] Tests pass
- [x] Formatted / linter clean
- [x] No banned language patterns
- [x] No banned functions (proofs untouched)
- [x] SPDX headers present on modified files
- [x] No secrets
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ce26ae4 commit 696c495
2 files changed
Lines changed: 121 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
303 | 305 | | |
304 | 306 | | |
305 | 307 | | |
| |||
319 | 321 | | |
320 | 322 | | |
321 | 323 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
| |||
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
371 | 375 | | |
372 | 376 | | |
373 | 377 | | |
| |||
614 | 618 | | |
615 | 619 | | |
616 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
375 | 412 | | |
376 | 413 | | |
377 | 414 | | |
| |||
960 | 997 | | |
961 | 998 | | |
962 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
963 | 1020 | | |
964 | 1021 | | |
965 | 1022 | | |
| |||
0 commit comments