Skip to content

Contributor transport: resumable, verified index bundle downloads and a claims client - #197

Open
Deicyde wants to merge 1 commit into
mainfrom
claude/contrib-transport
Open

Deicyde wants to merge 1 commit into
mainfrom
claude/contrib-transport

Conversation

@Deicyde

@Deicyde Deicyde commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

The client side of #195 (token-gated index downloads) and #196 (the claims API): one standard-library module, scripts/articles/contrib_transport.py, beside submission_transport.py. It needs neither PR to merge, since its tests run against a loopback stand-in server, but it does nothing useful until they ship.

What it does.

  • call() makes one JSON request to a path on a fixed allowlist (the package, claim and bundle routes and the intake body route; no query strings). It carries the token in a header, never follows a redirect, and keeps the token out of every error. A refusal raises Refusal with the server's status and code. A 429 is waited out only when Retry-After is at most 300 s, and at most three times; a daily quota is not slept on.
  • download() fetches one file of known size and sha256. It resumes a cut transfer from <file>.part with Range and If-Range (64 MiB a request), re-hashes an existing part first, starts again if the server sends the whole file, and refuses more bytes than expected. The file is moved into place only once its size and sha256 match: staging hard-links index files into every task directory, so a file truncated in place would corrupt them all.
  • fetch_bundle() and contrib_transport.py fetch-bundle <manifest sha256> [--cache] [--skip names/] [--execute] read the bundle's MANIFEST.json, check it hashes to the name it was asked for and lists only plain paths, then download what the cache lacks. MANIFEST.json is written last, so its presence means the bundle is whole. Without --execute only the manifest is read, and the answer says what would download and which libraries restrict use.
  • The token comes from WIKILEAN_AGENT_TOKEN, never argv.

Not here. run_package.py --claims, publish_package.py --api and collect_results.py --api build on this in the next PR. A loopback test against the real Worker routes comes with them, once #195 and #196 are on main.

Release. Release-neutral (scripts/).

Checks. Worker, Python and browser CI green at the head commit: https://github.com/Deicyde/WikiLean/actions/runs/43474668219 (scripts/articles/test_contrib_transport.py, 14 tests, in scripts/ci-python.sh).

… a claims client

scripts/articles/contrib_transport.py talks to the Worker's token-gated index
downloads and claims API over a fixed path allowlist, never follows a redirect
and keeps the token out of every error. A download resumes with Range and
If-Range and lands only once its size and sha256 match; fetch-bundle fills a
cache from a bundle's MANIFEST.json, reading only the manifest without
--execute.
@Deicyde
Deicyde marked this pull request as ready for review November 13, 2026 20:01
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