Skip to main content

Typed policy-bounded contracts for Keble asynchronous scraping.

Project description

Keble Scraper Contract

keble-scraper-contract is the framework-free request, lifecycle, artifact, proxy, callback, and operator identity boundary for Keble's asynchronous scraper. Generic callers can submit only GET/HEAD public-resource requests. The sole POST exception is the registered, typed Shopify Storefront GraphQL profile; callers cannot supply GraphQL text, mutations, arbitrary headers, or credentials.

All values are immutable Pydantic v2 models, reject undeclared fields, serialize with camel-case aliases, and expose bounded enums instead of arbitrary TTLs or transport flags.

ScrapeArtifactPin is the ordered retention-policy command for one stable artifact/owner identity. Its required positive retention_revision makes finite archive expiry, indefinite latest retention, replay, and out-of-order delivery distinguishable. A producer must increment that revision whenever it changes expires_at; reusing one revision for a different expiry is a contract conflict.

Version 0.3.0 releases that ordered retention contract together with the complete typed failure boundary. The new pin field is intentionally mandatory: an older producer cannot silently recreate indefinite paid-storage retention, and a delayed delivery cannot reverse a newer finite/indefinite policy. Shopify, Scraper API, and Data Infra therefore repin in the same release wave.

Version 0.2.0 replaces free-string attempt/job/callback failures with one discriminated contract:

  • ScrapeLocalFailure owns caller-auth, request-policy, runtime, capacity, and operator failures through a finite code/origin vocabulary;
  • ScrapeUpstreamFailure owns target-resource, paid-egress, and browser-provider failures with universal kind/disposition/action, exact capacity evidence, bounded native status/request identity, and optional retry time;
  • supplier payment is valid only for a paid supplier origin with reviewed documented-code or account-status evidence. A target 402, a rate limit, quarantine, or missing credential never implies payment;
  • attempts, terminal jobs, signed completion events, and HTTP errors use the same typed failure family. Success forbids failure evidence and every failed terminal state requires it.

The public wire uses ScrapeFailureEnvelope for non-success HTTP responses. The contract source/version guard compares src/ with the latest package-scoped annotated tag and rejects source drift under an existing version or metadata regression.

Side effects if changes:

  • scraper API, Shopify polling/callbacks, and frontend mappings must release in the same wave;
  • artifact-pin revisions and Shopify pin-outbox payloads must remain one coordinated wire contract;
  • Data Infra may adapt upstream failures but must not reinterpret local failures as provider payment.
uv run --package keble-scraper-contract pytest -q keble-scraper-contract/tests
npx --yes pyright .
uv run python keble-scraper-contract/src/keble_scraper_contract/release_guard.py
uv build --package keble-scraper-contract

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keble_scraper_contract-0.3.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keble_scraper_contract-0.3.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file keble_scraper_contract-0.3.0.tar.gz.

File metadata

  • Download URL: keble_scraper_contract-0.3.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for keble_scraper_contract-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b2e66e19622e71778c19f40f395df28868cfe5b020910a614ab92943e329c5eb
MD5 fd1f7cbcb6d7555ecbc2418fcafa75d1
BLAKE2b-256 5d3de5d71762ad19a60f4500a8ca0aa3f0e3e1189f1e02802af9a209dfffa3d7

See more details on using hashes here.

File details

Details for the file keble_scraper_contract-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: keble_scraper_contract-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for keble_scraper_contract-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 112884d8f4c892858ed03c31310c1695cf0af83e142231c5a7a8d992ad53bb41
MD5 4a0de1392882459b369c1e184021fae0
BLAKE2b-256 6c9aaadae57040560cde9ecca29a26e9f498168bc8ebc482ae583ab419203fb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page