Repository navigation
obs-hotkey: swap hotkey-combination background-id query to safe Rust (Refs #5288) - #5325
Merged
Merged
Conversation
…Refs #5288) Tier 1 mirrors every assertion of the unchanged test_hotkey_combination_background_id.c against the safe query. Tier 3 runs the extracted original and the shim on one recording fixture through the new real-named lock, callback-slot, unlock and dstr_free adapters, with six mutants. background_query_parity drops its same-named fake getter and drives the real getter on that fixture instead. The safe query is a stub that returns None: soldr cargo test -p obs-data --test obs-tests-core -- hotkey::combination_background_id hotkey::background_query test result: FAILED. 4 passed; 6 failed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(Refs #5288) obs_hotkey_combination_get_background_id now comes from obs-hotkey in the hybrid libobs. Safe Rust takes the existing hotkey mutex, captures the backend's shortcut_id callback, releases the lock and only then calls the saved callback once with the combination by value. A failed lock returns NULL with no field read; a missing callback or a false result frees the partial dstr and returns NULL; a true result transfers id.array unchanged. The mutex, callback slot and dstr_free stay in C behind private adapters. The original wrapper moves to libobs.ported-hotkey-combination-background-id, which gives it its static lock pair through the existing seam. soldr cargo test -p obs-data --test obs-tests-core -- hotkey::combination_background_id hotkey::background_query test result: ok. 10 passed; 0 failed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Ci-Attestation: {"at":1795141142,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":94,"stamp":"dae2b56ee79163274b0b3f9c597495bf","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141142,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":94,"stamp":"64dadec6784a44b6b04a04b11175fd85","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141142,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":94,"stamp":"63eeff4d6503b5e0bf71081f3a916378","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141142,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":94,"stamp":"c553f39cc407a25f59f79cfded9542f1","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"general/all/client-lint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"1fa72d8b2329b0c0b960fb2a4d389559","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141142,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":94,"stamp":"b95bfa8d10cb18f27474db7d9f9fbdd6","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"3c29b023b1aba9c71d4e0d240f4c4c1c","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"68a93310b322d57de61f713576074ed6","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"4f4833965661898ec04cee56eda48f90","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"f1f22e63a4ab31a5588cc91a64694afd","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"923ab93b6ee188ec99c42df526f4e6ad","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"460214df84df78bd764d87b4708876c7","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"ae4245f056e3477a35e8ca9de2e728f6","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"15552ab23b2a9cabf588eaf83ff11702","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"5b7d41956b8148dd31022c9284f24005","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"d5cff465fef4180d3508352bf042e701","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"45496753a706a23275e544311d4afbfc","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141047,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"8237acc3dd2eeb6c241b8077be33f3e8eaf869884058d8f0c801ef7659da4329","lane":"client-lint","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":63,"stamp":"d8452b7d0f552c98d074c51d561c234b","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Ci-Attestation: {"at":1795141366,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"b2087d1d1f640d75467108e499b87897e52d9b8d8227fb8a6f2907a94f11b2af","lane":"client-test-x86_64-unknown-linux-gnu","parents":["1bcf2a898d96a1c7bfdfe065d38e814718bcd829"],"secs":224,"stamp":"0969529f982fd5c9af60ff84a18ee586","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d","v":1,"via":"run"} Client-Checks: {"checks":{"base":"869cc329a4d9053ba424088d01b05b6bb695bcad","coverage":"all-tracked-applicable-files","diff":["ci/test_hotkey_register_extraction.py","libobs/build/libobs.core+.h.c","libobs/build/libobs.ported-hotkey-combination-background-id+.h.c","libobs/build/ported-source-sets/hotkey-combination-background-id.json","libobs/cmake/rust-exports.d/obs-hotkey-combination_background_id.txt","libobs/obs-hotkey-combination-background-id-fields.c.h","libobs/obs-hotkey-combination-background-id-lock.c.h","libobs/obs-hotkey-combination-background-id.c.h","libobs/obs-hotkey.c.h","libobs/obs-hotkeys-background-status-changed.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_hotkey_combination_background_id_swap_is_registered.rs","rust/obs-build/tests/native/registration/headless_characterizations_expected.json","rust/obs-build/tests/native/registration/portal_output_expected.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_background_enum.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_background_press.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_background_trigger.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_binding_press_steps.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_getters_characterization.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_load.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_pair_steps.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_press_steps.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_hotkey_unregister_entry.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_portal_shortcuts.json","rust/obs-build/tests/native/registration/rust-static/cases/hotkey-control/test_wayland_hotkeys.json","rust/obs-c-oracle/oracle/hotkey_combination_background_id.c","rust/obs-hotkey/src/combination_background_id.rs","rust/obs-hotkey/src/ffi/combination_background_id.rs","rust/obs-hotkey/src/ffi/mod.rs","rust/obs-hotkey/src/lib.rs","rust/obs-hotkey/tests/hotkey/background_query_parity.rs","rust/obs-hotkey/tests/hotkey/combination_background_id.rs","rust/obs-hotkey/tests/hotkey/combination_background_id_parity.rs","rust/obs-hotkey/tests/hotkey/main.rs","test/cmocka/build/test-graph.json","test/cmocka/test_hotkeys_background_status_changed.c","test/cmocka/tests.d/test_hotkeys_background_status_changed.cmake"],"head":"987b89c46ed3aaeab67f31cf67cf5eb924acd716","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"9e9e205e8e89c2f6ff36b305ea2f3965453462c9ae322234adc4a6cb87791544","tree":"dba1e45a032bf9008dd396ae7ad361ca60dc3f4d"}}
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #5288.
Swap only
obs_hotkey_combination_get_background_idintoobs-hotkey. Safe Rust takes the existing hotkey mutex, reads the backend'sshortcut_idcallback while holding it, releases the lock and only then calls the saved callback, exactly once, with the combination by value and an empty dstr. A failed lock returns NULL with no field read. A missing callback or a false result frees the partial dstr and returns NULL. A true result handsid.arrayto the caller unchanged, including NULL and an allocated empty string, so the caller'sbfreealways matches the callback's allocator. The mutex, the callback slot anddstr_freestay in C behind four private adapters (libobs/obs-hotkey-combination-background-id-fields.c.h, in the core group). The original wrapper moves to thelibobs.ported-hotkey-combination-background-idgroup, which builds the C reference only. There it gets its staticlock/unlockpair from the existing hotkey seam (obs-hotkey-combination-background-id-lock.c.h). The extracted file only changes its comment, so the unchanged C test and the standalone hotkey fixtures still compile it as before.The hazard the issue names:
background_query_parity.rsdefined a same-named fake of this getter. Now that the real getter is defined in the same crate, the fake is gone. That test drives the real getter on the shared recording fixture instead. The status fake (obs_hotkeys_get_background_state) stays until the background-state swap (#5259) lands.Tests:
test_hotkey_combination_background_id.c(from libobs: characterize and extract hotkey combination background id (Refs #5275) #5287) against the safe core: the nine cases for each of the three combinations, the L/R/U/C/F traces, the counters, exact ownership transfer, NULL on callback success, and reentry.dstr/obs_key_combination_t/callback-slot layout, edge cases and proptest.Evidence
RED (
1bcf2a898, the safe core is a stub that returns None):GREEN (
4e1699e9c, on3b8563940):The change has no user-visible effect, so it adds no features-ledger line. Native Windows/macOS execution is not claimed.
🤖 Generated with Claude Code