Skip to content

Add C, Python, and Node bindings for the Rust scan ABI - #115

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/scan-language-bindings-cdf8
Sep 2, 2026
Merged

Add C, Python, and Node bindings for the Rust scan ABI#115
cursor[bot] merged 2 commits into
mainfrom
cursor/scan-language-bindings-cdf8

Conversation

@byte271

@byte271 byte271 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Language bindings for the shared fuckmark-hidden-scan-v1 Rust ABI introduced in #114.

Stack: merge #112#113#114 → this. Base is cursor/wasm-scan-engine-cdf8.

What landed

  • C header: crates/fuckmark-scan/include/fuckmark_scan.h
  • Host cdylib build: crates/fuckmark-scan/build-native.sh
  • Tiny C example: crates/fuckmark-scan/examples/scan_cli.c
  • Optional Python ctypes loader: fuckmark.native_scan (uses FUCKMARK_SCAN_LIB or target/release/libfuckmark_scan.*)
  • Node package: bindings/node (@fuckmark/scan) wrapping the committed WASM module + JS fallback
  • Overview: bindings/README.md
  • CI WASM hidden-scan job also builds the host library and runs binding tests

Category ABI: * = all categories, empty string / [] = empty selection, otherwise comma-separated names.

Codex P2 follow-up (b76f013)

  • Python scan_text / clean_text detect lone UTF-16 surrogates and delegate to the Python reference scanner (UTF-8 ABI cannot carry them)
  • WASM wrapper normalizes the JS fallback result to the same index / truncated / highest_severity / source_length schema as a WASM scan
  • C example is linked with -rpath,$ORIGIN and written next to libfuckmark_scan.so

Package version stays 0.4.1. Frozen confirmation artifacts are unchanged.

Open in Web Open in Cursor 

Expose fuckmark-hidden-scan-v1 through a C header and host cdylib,
an optional Python ctypes loader, and a Node package that wraps the
committed WASM engine with the JS fallback.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@byte271
byte271 marked this pull request as ready for review September 2, 2026 02:45
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 78849de7-77c8-4831-aba1-f4bcdc4a974c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6050f182f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fuckmark/native_scan.py
lib = load_library()
if lib is None:
raise RuntimeError("native fuckmark-scan library is not available")
text_bytes = text.encode("utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve lone surrogates in the Python binding

When a valid Python str contains a lone UTF-16 surrogate, this strict UTF-8 encoding raises UnicodeEncodeError, so scan_text() cannot report the advertised surrogate category; clean_text() has the same failure at its corresponding encoding step. Detect these strings and delegate them to the Python reference implementation, as the Node binding already does, or otherwise provide a surrogate-preserving path.

Useful? React with 👍 / 👎.

Comment thread bindings/node/scan_wasm.js Outdated
Comment on lines +109 to +110
if (fallback && hasLoneSurrogate(source)) {
return fallback.scanText(source, categories, language);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize results returned by the surrogate fallback

For input containing a lone surrogate, this direct return exposes the fallback scanner's different result schema: findings omit index, while the result omits truncated, highest_severity, and source_length, all of which are returned for ordinary WASM-scanned input. Consumers therefore receive input-dependent object shapes and can fail specifically on the surrogate cases the fallback is intended to support; normalize the fallback result to the WASM wrapper's schema before returning it.

Useful? React with 👍 / 👎.

Comment thread bindings/README.md Outdated
cc -I crates/fuckmark-scan/include \
crates/fuckmark-scan/examples/scan_cli.c \
-L crates/fuckmark-scan/target/release -lfuckmark_scan \
-Wl,-rpath,\$ORIGIN/../../crates/fuckmark-scan/target/release \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point the C example's rpath at the built library

With the documented output path /tmp/fm-scan, $ORIGIN is /tmp, so this rpath resolves to /crates/fuckmark-scan/target/release rather than the repository's build directory. Running the very next command consequently fails to load libfuckmark_scan.so; use an absolute build path or place the executable where this $ORIGIN-relative path is valid.

Useful? React with 👍 / 👎.

Route lone UTF-16 surrogates through the Python scanner so the native
binding can report the surrogate category. Normalize the WASM JS
fallback result to the same schema, and link the C example next to
the built library with \$ORIGIN.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@cursor
cursor Bot changed the base branch from cursor/wasm-scan-engine-cdf8 to main September 2, 2026 03:12
@cursor
cursor Bot merged commit 157dcf5 into main Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants