Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 102 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,111 @@ jobs:
- name: Install and smoke-test wheel in a clean environment
run: python scripts/wheel_smoke.py --wheel-dir dist

compat-httpx:
name: HTTPX compatibility (py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Cache cargo registry and target
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-compat-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-compat-cargo-

- name: Create virtualenv
run: python -m venv .venv

- name: Install dependencies
run: |
source .venv/bin/activate
pip install -r compat/httpx/0.28.1/requirements.txt
pip install maturin pytest pytest-asyncio

- name: Verify httpx version
run: |
source .venv/bin/activate
python -c "import httpx; assert httpx.__version__ == '0.28.1', f'Expected 0.28.1, got {httpx.__version__}'"

- name: Build and install eggfetch
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
run: |
source .venv/bin/activate
maturin develop -m crates/eggfetch-python/Cargo.toml

- name: Validate compatibility profile
run: |
source .venv/bin/activate
python scripts/validate_httpx_compat_profile.py compat/httpx/0.28.1

- name: Run required compatibility tests
env:
EGGFETCH_COMPAT_REQUIRED: "1"
EGGFETCH_COMPAT_PROFILE: "httpx/0.28.1"
run: |
source .venv/bin/activate
pytest crates/eggfetch-python/tests/compat/ -v --strict-markers --timeout=30

- name: Generate eggfetch API manifest
run: |
source .venv/bin/activate
python scripts/generate_httpx_api_manifest.py --package eggfetch --output /tmp/eggfetch-manifest.json

- name: Generate reference API manifest
run: |
source .venv/bin/activate
python scripts/generate_httpx_api_manifest.py --package httpx --output /tmp/httpx-manifest.json

- name: Compare manifests
run: |
source .venv/bin/activate
python scripts/compare_httpx_api_manifest.py \
--reference /tmp/httpx-manifest.json \
--candidate /tmp/eggfetch-manifest.json \
--allowed compat/httpx/0.28.1/allowed-differences.toml

- name: Lint compatibility claims in docs
run: |
source .venv/bin/activate
python scripts/check_compatibility_claims.py \
docs/reference/compatibility.md \
docs/migration/from-httpx.md

- name: Upload compatibility reports
if: always()
uses: actions/upload-artifact@v4
with:
name: compat-reports-${{ matrix.python-version }}
path: |
/tmp/httpx-manifest.json
/tmp/eggfetch-manifest.json

# ──────────────────────────────────────────────────────────────────────
# Required CI Gate — fail-closed merge prerequisite
# ──────────────────────────────────────────────────────────────────────
required-gate:
name: Required CI Gate
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [rust-format, rust-lint, rust-msrv, rust-test, rust-doc, docs-syntax, docs-runtime, resource-monitor, python, wheel-smoke]
needs: [rust-format, rust-lint, rust-msrv, rust-test, rust-doc, docs-syntax, docs-runtime, resource-monitor, python, wheel-smoke, compat-httpx]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

Expand All @@ -277,6 +374,7 @@ jobs:
("resource-monitor", "${{ needs.resource-monitor.result }}"),
("python", "${{ needs.python.result }}"),
("wheel-smoke", "${{ needs.wheel-smoke.result }}"),
("compat-httpx", "${{ needs.compat-httpx.result }}"),
]

results = {}
Expand Down Expand Up @@ -305,8 +403,9 @@ jobs:
("Docs syntax", results["docs-syntax"]),
("Docs runtime", results["docs-runtime"]),
("Resource monitor", results["resource-monitor"]),
("Python tests (12)", results["python"]),
("Wheel smoke (3 OS)", results["wheel-smoke"]),
("Python tests (12)", results["python"]),
("Wheel smoke (3 OS)", results["wheel-smoke"]),
("HTTPX compat", results["compat-httpx"]),
]
for label, status in display:
fh.write(f"| {label} | {status} |\n")
Expand Down
17 changes: 17 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ cargo check -p eggfetch-core --all-features
cd crates/eggfetch-python && maturin develop
python -m pytest -p pytest_asyncio

# HTTPX compatibility tests (requires httpx==0.28.1)
pip install -r compat/httpx/0.28.1/requirements.txt
EGGFETCH_COMPAT_REQUIRED=1 pytest crates/eggfetch-python/tests/compat/ -v --strict-markers

# Validate compatibility profile
python scripts/validate_httpx_compat_profile.py compat/httpx/0.28.1

# Generate and compare API manifests
python scripts/generate_httpx_api_manifest.py --package httpx --output /tmp/httpx.json
python scripts/generate_httpx_api_manifest.py --package eggfetch --output /tmp/eggfetch.json
python scripts/compare_httpx_api_manifest.py \
--reference /tmp/httpx.json \
--candidate /tmp/eggfetch.json \
--allowed compat/httpx/0.28.1/allowed-differences.toml

# Resource regression check
cargo build --release -p eggfetch-bench --bin resource_monitor
./target/release/resource_monitor
Expand Down Expand Up @@ -83,6 +98,8 @@ cargo test -p eggfetch-core --no-default-features --features http1,tls-rustls,pr
cargo test -p eggfetch-core --no-default-features --features http1,tls-rustls,http3
```

The HTTPX compatibility test suite lives in `crates/eggfetch-python/tests/compat/` and requires `httpx==0.28.1`. Run with `EGGFETCH_COMPAT_REQUIRED=1` for fail-closed behavior. The compatibility profile is in `compat/httpx/0.28.1/`.

CI matrix: Python 3.10-3.13 on Ubuntu, macOS, Windows. CI must install `pytest-asyncio` explicitly.

## Security
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ Note: HTTP/3 (QUIC) is now available as an experimental feature behind the `http

See [plans/ROADMAP.md](plans/ROADMAP.md) for the full roadmap and compatibility policy.

## HTTPX Compatibility

eggfetch targets HTTPX 0.28.1 compatibility in measured phases. Phase 0 establishes the compatibility contract:

- **Pinned reference**: `httpx==0.28.1` with a machine-readable compatibility profile in `compat/httpx/0.28.1/`
- **API manifest comparison**: Automated generators compare eggfetch's public API surface against HTTPX's golden manifest
- **Required differential tests**: Fail-closed compatibility tests that cannot be skipped in CI
- **Allowed differences**: Every intentional behavioral difference is documented, categorized, and linked to tests

Key differences from HTTPX:
- **Redirect default**: eggfetch does NOT follow redirects by default (HTTPX does)
- **Proxy env vars**: eggfetch does not read `HTTP_PROXY`/`HTTPS_PROXY` (HTTPX does)
- **Event hooks**: Not yet implemented (tracked as required-later)
- **WSGI/ASGI transports**: Not applicable (eggfetch is a network client)

See [`compat/httpx/0.28.1/`](compat/httpx/0.28.1/) for the full profile and [`docs/reference/compatibility.md`](docs/reference/compatibility.md) for the feature matrix.

## Target API Shapes

The Python API targets familiar requests/httpx patterns:
Expand Down
47 changes: 47 additions & 0 deletions compat/httpx/0.28.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# HTTPX 0.28.1 Compatibility Profile

This directory contains the machine-readable compatibility profile for
HTTPX 0.28.1 drop-in compatibility (Phase 0).

## Files

- `profile.toml` — Defines the reference package, supported surfaces, and categories
- `allowed-differences.toml` — Registry of reviewed, allowed behavioral differences
- `reference-api.json` — Golden manifest of HTTPX 0.28.1 public API (generated)

## Usage

Validate the profile:
```bash
python scripts/validate_httpx_compat_profile.py compat/httpx/0.28.1
```

Generate the reference manifest:
```bash
python scripts/generate_httpx_api_manifest.py --package httpx --output compat/httpx/0.28.1/reference-api.json
```

Generate the eggfetch manifest:
```bash
python scripts/generate_httpx_api_manifest.py --package eggfetch --output /tmp/eggfetch.json
```

Compare manifests:
```bash
python scripts/compare_httpx_api_manifest.py \
--reference compat/httpx/0.28.1/reference-api.json \
--candidate /tmp/eggfetch.json \
--allowed compat/httpx/0.28.1/allowed-differences.toml
```

## Categories

- `required-now` — Must match for current stage
- `required-later` — Accepted gap assigned to later roadmap phase
- `intentional-difference` — Reviewed and explicitly allowed
- `not-public` — Excluded from contract
- `not-applicable` — Reference feature cannot apply to current product stage

## Status

This profile targets HTTPX 0.28.1. The compatibility stage is **Phase 0**.
137 changes: 137 additions & 0 deletions compat/httpx/0.28.1/allowed-differences.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Allowed differences between HTTPX 0.28.1 and eggfetch
# Each entry must have a stable ID, category, and linked tests.

[[difference]]
id = "REDIRECT-DEFAULT-001"
category = "intentional-difference"
symbol = "httpx.Client(follow_redirects=...)"
behavior-case = "redirect-default"
reference-behavior = "HTTPX follows redirects by default (follow_redirects=True)"
eggfetch-behavior = "eggfetch does NOT follow redirects by default (follow_redirects=True required)"
rationale = "Security-first default; prevents accidental redirects to unexpected hosts"
compatibility-stage-impact = "phase-0"
security-improvement = true
migration-impact = "Users must add follow_redirects=True explicitly"
owner = "eggfetch-team"
review-milestone = "phase-0"
tests = ["test_differential.py::TestRedirectDefault", "test_differential.py::TestKnownDifferences::test_redirect_default_differs"]

[[difference]]
id = "PROXY-ENV-001"
category = "required-later"
symbol = "httpx.Client(proxy=...)"
behavior-case = "proxy-env-vars"
reference-behavior = "HTTPX reads HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars"
eggfetch-behavior = "eggfetch does not read proxy env vars; proxy= parameter is explicit only"
rationale = "Not yet implemented; tracked as roadmap item"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Users must pass proxy= explicitly"
owner = "eggfetch-team"
review-milestone = "phase-1"
tests = ["test_differential.py::TestKnownDifferences::test_proxy_config_differs"]

[[difference]]
id = "TIMEOUT-TUPLE-001"
category = "intentional-difference"
symbol = "httpx.Timeout(...)"
behavior-case = "timeout-api"
reference-behavior = "HTTPX accepts Timeout() with named phase parameters"
eggfetch-behavior = "eggfetch accepts Timeout() with named phase parameters (compatible)"
rationale = "API shape is compatible; requests tuple syntax is different"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Minimal; Timeout() API is compatible"
owner = "eggfetch-team"
review-milestone = "phase-0"
tests = ["test_differential.py::TestTimeout"]

[[difference]]
id = "EVENT-HOOKS-001"
category = "required-later"
symbol = "httpx.EventHooks / httpx.Client(event_hooks=...)"
behavior-case = "event-hooks"
reference-behavior = "HTTPX supports event_hooks={'request': [...], 'response': [...]}"
eggfetch-behavior = "eggfetch does not support event hooks"
rationale = "Not yet implemented; tracked as roadmap item"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Users needing event hooks must use other mechanisms"
owner = "eggfetch-team"
review-milestone = "phase-1"
tests = []

[[difference]]
id = "TRANSPORTS-001"
category = "required-later"
symbol = "httpx.ASGITransport / httpx.WSGITransport"
behavior-case = "in-process-transports"
reference-behavior = "HTTPX supports WSGI/ASGI in-process transports"
eggfetch-behavior = "eggfetch does not support in-process transports"
rationale = "eggfetch is a network client, not a testing tool"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Use a real test server instead"
owner = "eggfetch-team"
review-milestone = "phase-2"
tests = []

[[difference]]
id = "MOUNTS-001"
category = "required-later"
symbol = "httpx.Client(mounts=...)"
behavior-case = "per-host-transports"
reference-behavior = "HTTPX supports per-host transport mounts"
eggfetch-behavior = "eggfetch does not support per-host transport mounts"
rationale = "Not yet implemented; tracked as roadmap item"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Users needing per-host routing must handle externally"
owner = "eggfetch-team"
review-milestone = "phase-2"
tests = []

[[difference]]
id = "TRIO-ANYIO-001"
category = "not-applicable"
symbol = "httpx.AsyncClient(transport=...)"
behavior-case = "trio-anyio"
reference-behavior = "HTTPX supports Trio and AnyIO backends"
eggfetch-behavior = "eggfetch uses asyncio only"
rationale = "eggfetch is built on tokio (Rust); asyncio integration is the Python path"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "None for asyncio users"
owner = "eggfetch-team"
review-milestone = "phase-0"
tests = []

[[difference]]
id = "EXCEPTION-NAMES-001"
category = "intentional-difference"
symbol = "httpx.HTTPError / eggfetch.EggfetchError"
behavior-case = "exception-hierarchy"
reference-behavior = "HTTPX uses httpx.HTTPError as base exception"
eggfetch-behavior = "eggfetch uses EggfetchError as base exception"
rationale = "Different base exception name; subclass structure is compatible"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "Catch EggfetchError instead of HTTPError"
owner = "eggfetch-team"
review-milestone = "phase-0"
tests = ["test_response_compat.py"]

[[difference]]
id = "RAISE-FOR-STATUS-001"
category = "intentional-difference"
symbol = "httpx.Response.raise_for_status()"
behavior-case = "raise-for-status-return"
reference-behavior = "HTTPX Response.raise_for_status() returns the response"
eggfetch-behavior = "eggfetch Response.raise_for_status() returns the response"
rationale = "API is compatible; both return the response object"
compatibility-stage-impact = "phase-0"
security-improvement = false
migration-impact = "None"
owner = "eggfetch-team"
review-milestone = "phase-0"
tests = ["test_response_compat.py"]
Loading
Loading