Skip to content

feat: add Python PyO3 bindings (Phase 3) - #8

Merged
mostafa merged 3 commits into
mainfrom
feat/python-bindings
May 9, 2026
Merged

mostafa merged 3 commits into
mainfrom
feat/python-bindings

Conversation

@mostafa

@mostafa mostafa commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Native Python extension via PyO3/maturin exposing the full ressrf-core API (Policy, PolicyBuilder, CIDR, UriValidator, CloudProvider)
  • Pythonic wrapper layer: Policy.external_only(cloud=["aws"]), fluent PolicyBuilder, RessrfBlockedError with structured .reason dict
  • Protocol modules: TCP (safe_getaddrinfo, create_connection), HTTP (httpx SafeTransport, requests SafeAdapter), SSH (safe_ssh_connect via paramiko)
  • Audit: AuditSink Protocol (PEP 544), AuditFunc callback adapter, MultiSink, DiscardSink (no built-in logger implementations)
  • Optional extras: ressrf[httpx], ressrf[requests], ressrf[ssh], ressrf[all]
  • Cross-language conformance tests against shared tests/vectors/*.json (same vectors as Rust and Go)
  • CI: multi-OS pytest, ruff format/lint, ty type checking via uv

Test plan

  • maturin develop builds the native extension successfully
  • pytest passes 40 tests (6 skipped for optional protocol deps)
  • ruff format --check and ruff check report zero issues
  • ty check passes with zero diagnostics
  • Conformance vectors (CIDR, policy decisions, URL validation) match Rust/Go behavior
  • CI workflow runs on ubuntu/macos/windows

mostafa added 3 commits May 9, 2026 22:01
Native extension via PyO3/maturin exposing the full ressrf-core API:
- CorePolicy, CorePolicyBuilder, CoreUriValidator in Rust
- Pythonic Policy wrapper with preset factories and fluent builder
- AuditSink Protocol (PEP 544) + AuditFunc callback adapter
- RessrfBlockedError with structured .reason dict
- Protocol modules: tcp, http (httpx/requests), ssh (paramiko)
- Optional extras: ressrf[httpx], ressrf[requests], ressrf[ssh]
- Cross-language conformance tests against shared JSON vectors
- Type stubs (_core.pyi) and py.typed marker for PEP 561
- Tooling: ruff (format+lint), ty (type checking), uv (env)
@mostafa
mostafa merged commit 089ce9e into main May 9, 2026
18 checks passed
@mostafa
mostafa deleted the feat/python-bindings branch May 9, 2026 20:15
gonzaloserrano added a commit that referenced this pull request May 27, 2026
A 601-line hand-styled HTML comparison page that lived in
go-native/ressrf/docs/ as porting-decision rationale during the
native-port standalone repo's life. It was imported as-is when the
port moved into this monorepo.

Two problems with keeping it:
  - It's in the package's docs/ directory, so pkg.go.dev and any
    repo browser sees a 601-line page about an unrelated upstream
    PR alongside the legitimate how-it-works walkthrough.
  - "PR #25" will close or merge; after that the comparison becomes
    orphan-context nobody will know is safe to delete.

The comparison's purpose was to justify the port. The port has
happened (merged into timescale/ressrf as the go-native binding);
future readers wanting "why a native port?" can read the
integration PR's description rather than a 601-line HTML page in
docs/. git history preserves the file for anyone who needs it.

No inbound references confirmed via grep across *.md / *.go / *.html
/ *.yml.

Addresses td-code-review finding #8.
gonzaloserrano added a commit that referenced this pull request May 27, 2026
A 601-line hand-styled HTML comparison page that lived in
go-native/ressrf/docs/ as porting-decision rationale during the
native-port standalone repo's life. It was imported as-is when the
port moved into this monorepo.

Two problems with keeping it:
  - It's in the package's docs/ directory, so pkg.go.dev and any
    repo browser sees a 601-line page about an unrelated upstream
    PR alongside the legitimate how-it-works walkthrough.
  - "PR #25" will close or merge; after that the comparison becomes
    orphan-context nobody will know is safe to delete.

The comparison's purpose was to justify the port. The port has
happened (merged into timescale/ressrf as the go-native binding);
future readers wanting "why a native port?" can read the
integration PR's description rather than a 601-line HTML page in
docs/. git history preserves the file for anyone who needs it.

No inbound references confirmed via grep across *.md / *.go / *.html
/ *.yml.

Addresses td-code-review finding #8.
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.

1 participant