Skip to content

codec: add adversarial coverage for optional codec edge paths#184

Merged
bbopen merged 1 commit intomainfrom
codex/48-adversarial-optional-codec-edge-cases
Feb 12, 2026
Merged

codec: add adversarial coverage for optional codec edge paths#184
bbopen merged 1 commit intomainfrom
codex/48-adversarial-optional-codec-edge-cases

Conversation

@bbopen
Copy link
Owner

@bbopen bbopen commented Feb 12, 2026

Summary

  • add adversarial fixture functions for optional codec edge cases in torch/scipy/sklearn
  • add guarded adversarial tests that only run when each optional dependency is available
  • assert explicit bridge-side error messages for:
    • non-contiguous torch tensors when TYWRAP_TORCH_ALLOW_COPY=0
    • scipy sparse matrices with complex dtype
    • sklearn estimators with non-JSON-serializable params

Testing

  • npx eslint test/adversarial_playground.test.ts
  • npm run typecheck
  • TYWRAP_ADVERSARIAL=1 npm test -- test/adversarial_playground.test.ts -t "non-contiguous tensors"
  • TYWRAP_ADVERSARIAL=1 npm test -- test/adversarial_playground.test.ts -t "complex sparse"
  • TYWRAP_ADVERSARIAL=1 npm test -- test/adversarial_playground.test.ts -t "sklearn non-serializable"

Closes #48

@bbopen bbopen added area:codec Area: codecs and serialization priority:p2 Priority P2 (medium) labels Feb 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Warning

Rate limit exceeded

@bbopen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b6c3065 and 9cf989e.

📒 Files selected for processing (2)
  • test/adversarial_playground.test.ts
  • test/fixtures/python/adversarial_module.py
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/48-adversarial-optional-codec-edge-cases

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 and usage tips.

@bbopen bbopen merged commit 5e5393a into main Feb 12, 2026
20 checks passed
@bbopen bbopen deleted the codex/48-adversarial-optional-codec-edge-cases branch February 12, 2026 01:20
Copy link

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

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: 9cf989e27f

ℹ️ 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".

pythonPath,
[
'-c',
`import importlib.util, sys; sys.exit(0 if importlib.util.find_spec(${JSON.stringify(moduleId)}) else 1)`,

Choose a reason for hiding this comment

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

P2 Badge Verify optional modules by importing them

The dependency guard uses importlib.util.find_spec(...), which only checks whether a module is discoverable on disk, not whether it can actually be imported. In environments where optional deps are partially installed or have missing native libraries (common for torch/scipy wheels), find_spec returns success, the test runs, and then the fixture raises a fallback "... is not available" error that fails these assertions. Switching this probe to an actual import <module> check would keep these tests correctly skipped when the dependency is present but unusable.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:codec Area: codecs and serialization priority:p2 Priority P2 (medium)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add adversarial coverage for optional codec edge cases

1 participant