Skip to content

compat: HTTPX 0.28.1 compatibility contract (Phase 0) - #3

Merged
dbowm91 merged 2 commits into
mainfrom
compat/phase-0-contract
Jul 21, 2026
Merged

dbowm91 merged 2 commits into
mainfrom
compat/phase-0-contract

Conversation

@dbowm91

@dbowm91 dbowm91 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Establish a pinned, executable, fail-closed definition of HTTPX compatibility before adding more compatibility code.

Summary

This implements the full Phase 0 compatibility contract as defined in plans/httpx-drop-in-phase-0-compatibility-contract.md:

  • Compatibility profile: Machine-readable profile in compat/httpx/0.28.1/ with 9 reviewed allowed differences
  • Manifest generators: Scripts to generate and compare public API manifests against HTTPX 0.28.1 golden reference
  • Required differential tests: 53 fail-closed compatibility tests in tests/compat/ that cannot be skipped in CI
  • Skip auditor: CI enforces no unexplained skips, xfails, or collection errors
  • CI job: New compat-httpx job added to required gate
  • Documentation: Corrected compatibility claims, added audit sections
  • Behavior fixtures: Deterministic test server with stable case IDs

Files changed (25)

New (15)

  • compat/httpx/0.28.1/ — profile, allowed-differences, requirements, README
  • crates/eggfetch-python/tests/compat/ — 6 test/config files
  • plans/httpx-drop-in-phase-0-status.md — implementation status
  • scripts/ — 4 new scripts (manifest generator, comparator, validator, claim linter)

Modified (10)

  • .github/workflows/ci.yml — added compat-httpx job to required gate
  • scripts/check_api_surface.py — fixed stale exception names
  • AGENTS.md, README.md — added compat test commands and HTTPX section
  • docs/ — corrected compatibility and migration docs

Test results

  • 860 Rust tests pass
  • 53 compat tests pass (0 skips, 0 xfails)
  • 53 existing Python response compat tests pass
  • 13 CI gate evaluator tests pass
  • Profile validation passes
  • API surface check passes
  • Compatibility claims lint passes

dbowm91 added 2 commits July 21, 2026 20:51
Establish a pinned, executable, fail-closed definition of HTTPX
compatibility before adding more compatibility code.

Track A - Compatibility profile:
- compat/httpx/0.28.1/profile.toml: machine-readable profile
- compat/httpx/0.28.1/allowed-differences.toml: 9 reviewed differences
- compat/httpx/0.28.1/requirements.txt: pinned dependencies
- scripts/validate_httpx_compat_profile.py: profile validator

Track B - Public API manifests:
- scripts/generate_httpx_api_manifest.py: manifest generator
- scripts/compare_httpx_api_manifest.py: manifest comparator
- scripts/check_compatibility_claims.py: doc claim linter

Track C - Mandatory differential tests:
- crates/eggfetch-python/tests/compat/test_httpx_required.py: 30 required tests
- crates/eggfetch-python/tests/compat/test_httpx_extras.py: optional extras
- crates/eggfetch-python/tests/compat/conftest.py: skip auditor
- crates/eggfetch-python/tests/compat/fixtures.py: behavior fixtures
- crates/eggfetch-python/tests/compat/test_behavior_cases.py: structured cases

Track D - Corrected documentation:
- docs/reference/compatibility.md: fixed pool timeout, added compat status
- docs/migration/from-httpx.md: added audit section

Track E - Behavior fixtures:
- BehaviorCase dataclass with stable IDs
- Deterministic test server with common HTTP patterns

Track F - CI and evidence:
- .github/workflows/ci.yml: added compat-httpx job
- scripts/evaluate_ci_gate_policy.json: added compat-httpx to required jobs
- plans/httpx-drop-in-phase-0-status.md: implementation status

Also updated:
- scripts/check_api_surface.py: fixed stale exception names
- AGENTS.md: added compat test commands
- README.md: added HTTPX compatibility section
- docs/architecture/build-ci.md: added compat-httpx job
- docs/architecture/testing-fuzzing.md: added compat test docs
- Remove || true from compare step so unexplained differences fail CI
- Normalize memory addresses in manifest generator for stable output
- Commit httpx 0.28.1 reference-api.json golden manifest
- Update status file to reflect these fixes
@dbowm91
dbowm91 merged commit 51ec9ac into main Jul 21, 2026
16 of 29 checks passed
@dbowm91
dbowm91 deleted the compat/phase-0-contract branch July 21, 2026 21:29
dbowm91 pushed a commit that referenced this pull request Aug 26, 2026
Core:
- retry: default backoff factor 0.5 -> 2.0 so delays grow between
  retries; docs aligned (audit #2)
- proxy: CONNECT target brackets IPv6 literals in authority-form (#3)
- proxy: effective_timeout() now measures remaining budget with a fresh
  Instant per phase, enforcing one monotonic request deadline across
  multi-phase proxy setup instead of a stale snapshot (#4)
- proxy: reject truncated status/header lines on EOF (#14); header-count
  limit checked before push, admitting exactly MAX (#19)
- pipeline: redirect drain uses the byte-bounded helper under the total
  deadline (no full-body buffering) and gains a time cap when no total
  is set; applies to the retry-path drain too (#10)
- pool: closed per-origin semaphore no longer bypasses both limits; the
  request stays bounded by the global permit (#18)
- http3: sender cache uses per-origin OnceCell cells so concurrent
  requests share one QUIC connection instead of racing get-then-insert
  and orphaning driver tasks (#15)

FFI:
- streaming: cancel/free publish on a watch channel that a parked next
  selects on, so a blocked reader wakes immediately even on idle streams
  (#5); allocation/poison failures set last_error before returning null
  (#11); state is Arc-shared so free during a parked next is safe (#12);
  next routes through runtime-aware blocking_send

Python bindings:
- network_stream: sync read/write acquire the OS mutex inside
  allow_threads so a contended lock never stalls other Python threads
  while holding the GIL (#9)

Compat facade (httpx):
- URL: schemeless inputs are kept as relative references instead of
  being prefixed with a fabricated http:// authority; join() performs
  RFC 3986 resolution; _redirect_url resolves Location via urljoin so
  relative (./b, ../baz) and protocol-relative (//host) redirects
  dispatch to the correct host (#1, #6, #7)
- Headers: get()/[] comma-join duplicate values like HTTPX (#8)
- Response: iter_bytes/aiter_bytes raise StreamClosed after close,
  matching iter_raw (#16)
- auth: callables returning neither Request nor iterable raise
  TypeError instead of silently sending unauthenticated requests (#17)

CLI:
- --file implies POST like curl -F (#13)
- NDJSON mode drops the embedded history array; hops are emitted once
  as their own records (#20)
- --retry-delay pins backoff factor to 1 for flat inter-retry delay

Tests updated/added for each behavior change. Note: this changes the
executable SHA, so the exact-SHA compat qualification ledger requires
restarting its freeze step per plans/httpx-parity-correction-status.md.
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