Skip to content

obs-hotkey: port object-bound hotkey-pair registration to Rust (Refs #4797) - #5225

Merged
rdoupe merged 2 commits into
masterfrom
port/4797-hotkey-pair-register
Nov 19, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/4797-hotkey-pair-register

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #4797

Ports the four object-bound hotkey-pair registration entry points (obs_hotkey_pair_register_encoder, _output, _service, _source) from libobs/obs-hotkey-pair-register.c.h to obs-hotkey::pair_register.

What moved:

  • Safe core (rust/obs-hotkey/src/pair_register.rs): a NULL owner returns OBS_INVALID_HOTKEY_PAIR_ID before any owner field is read and without reaching the engine. Otherwise it reads the owner's fields, then makes one engine call with the owner itself as registerer.
  • FFI (src/ffi/pair_register.rs): the four exported symbols. No private structs are mirrored.
  • Private C adapter (libobs/obs-hotkey-pair-register-fields.c.h, live in libobs.core+):
    • Per-kind field adapters return the original weak-reference helper for that kind (obs_*_get_weak_*) and &owner->context from the real layouts.
    • obs_hotkey_pair_register_call forwards to the unchanged register_hotkey_pair_internal. That engine still does locking, calls the weak helper once per half, and handles partner IDs, saved bindings and teardown.
  • Build: the extracted C is now the reference-only group libobs.ported-hotkey-pair-register, registered through ported-source-sets/hotkey-pair-register.json. It is removed from modules.d/core.json and LIBOBS_SOURCES.json. The exports are listed in rust-exports.d/obs-hotkey-pair_register.txt.
  • Oracle: oracle.d/hotkey_pair_register.list plus oracle/hotkey_pair_register.c run the original wrappers and the production adapters over real owner layouts. A recording engine replaces register_hotkey_pair_internal and calls the weak helper twice, like the real one.
  • The rust/README.md port ledger has a new row.

Behavior is unchanged, characterized but not endorsed: private sources are still admitted, and NULL callbacks and data are accepted. There are no intentional differences. Tier 4 does not apply (this is not protocol code). No C test and no public header was changed. No plugins/obs-websocket pointer change.

Evidence

RED (f2b502e9d, Tier 1 mirror against a todo!() stub):

soldr cargo test -p obs-data --test obs-tests-core hotkey::pair_register
test hotkey::pair_register::test_hotkey_pair_register_null_owners ... FAILED
test hotkey::pair_register::test_hotkey_pair_register_object_registration ... FAILED
test hotkey::pair_register::test_hotkey_pair_register_private_source_and_null_callbacks ... FAILED
test hotkey::pair_register::engine_result_is_returned_unchanged_including_invalid ... FAILED
  panicked at rust/obs-hotkey/src/pair_register.rs:42:5: not yet implemented: port object-bound hotkey-pair registration
test result: FAILED. 0 passed; 4 failed

GREEN:

  • Tier 1 + Tier 3: soldr cargo test -p obs-data --test obs-tests-core hotkey::pair_register gives 7 passed; 0 failed.

    • The 4 Tier 1 tests mirror every assertion of test_hotkey_pair_register.c.
    • The 3 parity tests cover real-layout context offsets, exhaustive admission × full-width results, and a proptest over owner presence, all 8 NULL arguments and swapped callbacks.
  • Mutation check: I made two temporary mutations, and each one failed both parity tests (characterized_admission_and_full_width_results, wrappers_match_original_c):

    • (a) swapping data0/data1
    • (b) sending encoders through the output adapter

    The shrunk seed is checked in at tests/proptest-regressions/pair_register_parity.txt.

  • Native build contracts: soldr cargo test -p obs-studio-rust --test obs-tests-app native_build:: gives 318 passed, 0 failed.

  • Tier 2: OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'hotkey'

    • Exported symbols, C vs Rust: IDENTICAL (1769 symbols).
    • C reference ([OFF]): 1028/1028 passed, and the -R hotkey repeat passed 41/41, including test_hotkey_pair_register.
    • Hybrid ([ON]): 1028/1028 passed, and the -R hotkey repeat passed 41/41, including test_hotkey_pair_register.
  • Lint: ./lint gives == lane lint: ok. The local gate lint lane also passes after clang-format of the oracle file.

Test cost: new tests take at most 0.01 s per run (debug build, OBS_PARITY_CASES full and reduced). Peak RSS is 23 MB over 25 runs. The tests start no threads of their own.

🤖 Generated with Claude Code

Mirror every assertion of test_hotkey_pair_register.c in the existing
obs-tests-core hotkey module: NULL owners with and without a core, ID
consumption, metadata copies, partner IDs, per-half weak acquisition,
routed callbacks with distinct functions and data, saved bindings in the
right context, unregistration, owner teardown, private-source admission
and NULL callbacks/data. All four tests fail at the todo!() stub.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdoupe
rdoupe requested a review from zackees as a code owner November 19, 2026 10:55
…4797)

obs_hotkey_pair_register_{encoder,output,service,source} now come from
obs-hotkey::pair_register. A NULL owner returns OBS_INVALID_HOTKEY_PAIR_ID
before any owner field is read. Otherwise the real-layout adapter
obs-hotkey-pair-register-fields.c.h supplies the kind's original weak-ref
helper and the owner's embedded context, and the narrow
obs_hotkey_pair_register_call forwards to the unchanged
register_hotkey_pair_internal, which keeps locking, per-half weak
acquisition, partner IDs, saved bindings and teardown.

The extracted C moves to the reference-only group
libobs.ported-hotkey-pair-register (ported-source-sets fragment), the
four symbols are listed in rust-exports.d, and the original wrappers are
the Tier 3 oracle (oracle.d fragment) against the public Rust ABI, with
a mutation-killing seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ci-Attestation: {"at":1795086070,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":93,"stamp":"49643928a25c54d97911882c11a1ea65","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795086070,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":93,"stamp":"0e9b96f360a1dfb89535a5b26fc9c5ff","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795086070,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":93,"stamp":"6d997ee4c37c24644a55bb19e7a69d31","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795086070,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":93,"stamp":"e59c4d6cb09f04a7cd537e4f088f1fff","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"general/all/client-lint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"9c8417a6f912404b9dc924b9725c5756","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795086070,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":93,"stamp":"4c08671522f206a3e52d2f670ff615c0","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"376c4b4ee48e7c7198283e285bde07ab","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"bccc9762c1d90ba1e76ed5383c85601b","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"a0ce2232cfef9d4354067f6debeb53f9","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"10d55fb6a80449e62f8cc4faa9092ea4","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"a80e8a6c146125d75a67220aa80f0bcb","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"9ce163080fc1482f11ae3297587bc1f6","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"6e2b0c47930ab0865c4df996451774ee","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"0c37f864042632e7036385411a1fc5ae","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"b43cf4d83e667c0f38de8255a814a19d","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"5af5bd7e176fca5344ced443dbe690f6","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"2e03693f46dec93e8b19795e5f5d9b51","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795085976,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"ef33fb1f23b70467e1a25447f347bd0950c9f47bfefacd583a81705aaf239646","lane":"client-lint","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":87,"stamp":"fdd507cf7ee8290b35b2926ba8b9c648","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}
Ci-Attestation: {"at":1795086280,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"fc3fd4cc977e087ded4681cbf1e26d21e7d6035d62d04e8e6790af5173f0c791","lane":"client-test-x86_64-unknown-linux-gnu","parents":["f2b502e9d92a2b87a1aa898ab4c8ab4a07cca5b5"],"secs":209,"stamp":"e772e575d8be3b16ee837dc1d1eec865","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"d8f5045f0882951a2806b9decaf82b97cac656b6","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core+.h.c","libobs/build/libobs.core-hotkey-pair-register+.h.c","libobs/build/libobs.ported-hotkey-pair-register+.h.c","libobs/build/modules.d/core.json","libobs/build/ported-source-sets/hotkey-pair-register.json","libobs/build/source-sets.d/LIBOBS_SOURCES.json","libobs/cmake/rust-exports.d/obs-hotkey-pair_register.txt","libobs/obs-hotkey-pair-register-fields.c.h","rust/README.md","rust/obs-c-oracle/oracle.d/hotkey_pair_register.list","rust/obs-c-oracle/oracle/hotkey_pair_register.c","rust/obs-hotkey/src/ffi/mod.rs","rust/obs-hotkey/src/ffi/pair_register.rs","rust/obs-hotkey/src/lib.rs","rust/obs-hotkey/src/pair_register.rs","rust/obs-hotkey/tests/hotkey/main.rs","rust/obs-hotkey/tests/hotkey/pair_register.rs","rust/obs-hotkey/tests/hotkey/pair_register_parity.rs","rust/obs-hotkey/tests/proptest-regressions/pair_register_parity.txt"],"head":"662c460482fe3043ed8d1df6cbefa278d85175b9","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":"10495b8fdcf3f0bf15fc3c668064e3099ab823290e40277b188ffab68dca83f8","tree":"1e3eba54ccebb3c4c2d2dee5605df1ebd34af994"}}
@rdoupe
rdoupe force-pushed the port/4797-hotkey-pair-register branch from d8fd8fb to 5a7d63e Compare November 19, 2026 11:05
@rdoupe
rdoupe enabled auto-merge November 19, 2026 11:05
@rdoupe
rdoupe added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit a75749e Nov 19, 2026
43 checks passed
@rdoupe
rdoupe deleted the port/4797-hotkey-pair-register branch November 19, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant