Document HIDAPI API usage contract for AI coding agents - #834
Merged
Conversation
Add a section describing the library lifecycle and the multi-threading rules HIDAPI expects of its callers, so AI agents review and generate code against the intended contract instead of reporting contract violations as library defects. Assisted-by: claude-code:claude-opus-5
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.
Adds a "HIDAPI API usage contract" section to
AGENTS.mddocumenting the library lifecycle (hid_initfirst,hid_exitlast and only after all devices are closed, neither ever concurrent with anything else) and the multi-threading rules from the Multi‐threading Notes wiki page, which remains the authoritative reference.It also states explicitly that a finding whose trigger requires violating that contract — e.g. calling
hid_exit()while other threads still use the API, or unsynchronized concurrent first-time initialization — is application misuse rather than a library defect, and must not be reported as a bug or "fixed" by adding synchronization. The intent is to stop AI reviewers and agents from repeatedly raising contract-violating scenarios as defects, and to keep generated example/test code within the supported usage.Related to: #788
Assisted-by: claude-code:claude-opus-5