WP-139: Beta game-data hosting, Phase 1
Status: ✅ Done (2026-12-02). All eight acceptance criteria met on the TCL 65Q77K (§Result). Phase: 5 (polish & distribution). Depends on: WP-134 ✅ (the packages); WP-085 ✅ and WP-096 ✅ (the installer, its resume and its manifest, in the fork’s test builds). Plan: the private ewiki page Beta game data on Cloudflare R2 (§Access, Phase 1), merged 2026-12-02. Jeff approved Phase 1 the same day; that’s the answer to the ISO-free study’s §L.3 (a Worker gate, not presigned links or Access tokens). Companion EC: — (one session). Targets generation(s): Gen 1 packages; any format-1 package. Estimated effort: one day.
Goal
Host game-data packages for the TV app’s test builds on Cloudflare: a private R2 bucket, read only by a Worker that checks a per-tester key on every request. Prove it end to end on the TCL 65Q77K with no app change.
Scope
In:
- A private R2 bucket,
bbstudio-gamedata-packages, with nor2.devURL and no custom domain of its own. - A D1 database,
beta-testers:testers(SHA-256 of the key, name, statusactive/suspended/revoked, optional expiry) anddownloads(tester, object, bytes, status, time). - A Worker,
bbstudio-gamedata, onbeta-data.barefootbetters.com:GET /m/<key>returnsmanifests/beta.jsonwith eachurlrewritten to/p/<key>/<id>/<version>/<file>.GET /p/<key>/…streams the object. It sends R2’s strongETag, answersRangewith a206and the rightContent-Range, and answers anIf-Rangethat doesn’t match with a200and the whole object.- Any key that isn’t active, whether unknown, malformed or past its expiry,
gets an empty
404. The Worker’s own logs never hold a key.
- Admin scripts in PowerShell:
New-BetaTester,Set-BetaTester,Get-BetaDownloads. - Uploads: Beneath a Steel Sky (freeware, from
tv-test-packages), Showdown (showdown-en-aug20011), a test id with a deliberately wrong hash, andmanifests/beta.json.
The Worker and the scripts live in the private repo
(barefootbetters/scooby-engine-private, beta-data/). This repo keeps the
WP and the result.
Out:
- Phase 2: activation codes, device tokens, entitlements and the admin page.
- Phantom, which waits on the WP-087 closeout’s file-list recheck.
- Any tester outside the studio. Stage 3 waits on the licensing audit.
- App changes.
Acceptance criteria
These are the plan’s eight, run on the TCL with the test build:
- A known key loads the manifest and installs a package, and the app’s Verify passes.
- An unknown key, a malformed key and a bare
/m/each get an empty404, on both the manifest and a package URL. - Revoking a tester mid-download makes the next manifest load and the resume
request
404. A suspended tester restored toactiveworks again. - A package whose bytes don’t match its manifest SHA-256 is refused, and nothing is installed.
- A download cut off resumes: the app logs
HTTP 206and appends. Replacing the object between attempts gets a200toIf-Range, and the download starts over. - A failed update over the Worker leaves the installed version playable.
- No key shows up in the Worker’s log lines or in the app’s shared diagnostic log.
Get-BetaDownloadslists every download above with its tester, object and bytes.
Criteria 2 and 5’s headers are also checked with curl before the TV.
Pre-flight
- Account: the barefootbetters.com zone is on the Cloudflare account that
wrangler is logged in to, and no
bbstudio-gamedata-packagesbucket,beta-testersdatabase orbeta-datahostname exists yet. - Credentials: the Worker reads R2 through a binding, so it needs no R2
token. Uploads use the existing rclone
r2remote if its key can write the new bucket. If it can’t, they go throughwrangler. Neither puts a credential in the repo. - Reversible: each resource can be deleted on its own: the bucket, the database, the Worker and its custom domain.
- No game data leaves the account: the bucket is private, and the only key is Jeff’s own.
Result
Built and live:
- R2 bucket
bbstudio-gamedata-packages: private, with nor2.devURL. It replaced the first bucket,scooby-beta-packages, the same day at Jeff’s request: the objects were copied across with matching SHA-256s, the Worker was rebound, the checks below passed again, and the old bucket was deleted. - D1
beta-testers(05e7291d-…), with the schema applied. - Worker
bbstudio-gamedata(version299b3a3d) onbeta-data.barefootbetters.com, a custom domain, withworkers_devandpreview_urlsoff. It replaced the first Worker,scooby-beta-data, the same day: the old one was deleted, the new one deployed on the same domain, and the checks below passed again. - The code is on the private repo’s branch
claude/wp-139-beta-data(beta-data/).
Uploaded:
| Package | Object | Size |
|---|---|---|
BASS bass-cd 1.2 |
packages/bass-cd/1.2/bass-cd-1.2.zip |
69,377,781 B |
Showdown showdown-en-aug2001 1 |
packages/showdown-en-aug2001/1/showdown-en-aug2001-1.zip |
425,569,015 B |
neg-wrong-hash 1 (its manifest SHA-256 is one digit off) |
packages/neg-wrong-hash/1/neg-wrong-hash-1.zip |
199 B |
| The manifest | manifests/beta.json |
— |
One tester is active, jeff-tcl. Its first key was retired after the TV
run (see the key swap).
Showdown went up over the S3 API. At 425,569,015 B it’s over wrangler’s
300 MiB upload limit. Jeff created an R2 token scoped to this bucket (Object
Read & Write), and beta-data/tools/Set-R2Keys.ps1 saved its keys as User
env vars R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY. rclone then uploaded it
in 12 s, reading the keys from the environment. A full download through the
Worker took 22 s, and its SHA-256 matches the manifest. R2’s ETag for a
multipart upload, "2e5879bc…-82", is still strong, which is what
Resume.java needs (it refuses only W/). A range request on the last
bytes got 206.
HTTP checks with curl (criterion 2 and the headers criterion 5 relies
on), all as specified:
| Request | Answer |
|---|---|
| Manifest, good key (dashed, or lower case without dashes) | 200; each url is /p/<key>/<id>/<version>/<id>-<version>.zip |
Unknown key, malformed key, bare /m/, /, package with an unknown key, a missing object, a wrong file name |
404, 0 bytes |
| Whole package | 200, 69,377,781 B; SHA-256 matches the manifest; strong ETag "1d4401cd…" |
Range: bytes=1000-1999 |
206, Content-Range: bytes 1000-1999/69377781 |
Range with a matching If-Range (ETag or Last-Modified) |
206 |
Range with a stale If-Range |
200, the whole object |
Range past the end |
416, Content-Range: bytes */69377781 |
| Multi-range | 200, the whole object |
Tester suspended; active but expired; restored |
404; 404; 200 |
Criterion 7, Worker side: a wrangler tail taken during two requests
shows only the Worker’s lines, which are tester, object, range start, bytes
and status. The key appears only in Cloudflare’s own request metadata (the
URL), as the plan expected.
On the TV (2026-12-02, 19:23–19:37 Pacific)
The test build is com.barefootbetters.classics.debug 2026.4.1-wp138.1
(26041074) on the TCL 65Q77K (Android 14), driven over Windows adb. The
advanced mode was opened with its D-pad gesture, and its controls were tapped
by their uiautomator bounds. The manifest URL was written into the app’s
tv_packages preferences through run-as instead of typed. Before the run,
BASS 1.2.1, Showdown 1 and Phantom 1 were installed from WP-134’s gist
manifest; Showdown was removed (saves kept, 3 before and after) so it could
come back through the Worker.
| # | Criterion | What happened | |
|---|---|---|---|
| 1 | Known key installs, Verify passes | The manifest loaded (3 packages). Showdown 1 downloaded through the Worker, verified (SHA-256 e5b9bee7…), extracted 48 files, and was added as showdown-win. Verify: PASS, 48 of 48 files match (556,351,281 B) |
✅ |
| 2 | Unknown key gets an empty 404 | The app: Couldn’t load the manifest: HTTP 404 from beta-data.barefootbetters.com. The malformed-key, bare-/m/ and package-URL cases are in the curl table above |
✅ |
| 3 | Revoke mid-download; restore | With 167,815,598 B kept: revoked, the resume request (Range: bytes=167815598-) got 404, the part kept; the next manifest load 404. Suspended: manifest 404. Restored to active: manifest loaded, resume worked (row 5) |
✅ |
| 4 | Wrong SHA-256 refused | neg-wrong-hash downloaded (199 B) and was REFUSED: …d220 doesn’t match the manifest’s …d221. installed.json unchanged, staging empty |
✅ |
| 5 | Resume appends; a replaced object restarts | Cut at 167.8 MB (force-stop). The retry sent If-Range: "2e5879bc…-82" and got HTTP 206, Content-Range bytes 167815598-425569014/425569015 → APPEND. Cut again at 317.8 MB, then the object was re-uploaded with a 16 MiB part size (same bytes, ETag "899a6085…-26"). The retry got HTTP 200 → RESTART_WITH_BODY, fetched all 425,569,015 B, and installed (row 1) |
✅ |
| 6 | A failed update leaves the installed version playable | A temporary showdown-en-aug2001 2 (v1’s bytes, copied server-side; the manifest’s SHA-256 one digit off) offered Update to 2. All 425,569,015 B came through the Worker and were REFUSED; installed.json unchanged, v1’s folder untouched, staging empty. Launch showdown-win went to the game’s title screen. The v2 object and manifest entry were then removed |
✅ |
| 7 | No key in the app’s logs | Key matches, dashed or not: the shared diagnostic log (Share diagnostic log, saved to Android/data/…/files/; 65 lines) 0; store.log (707 lines) 0; scummvm.log 0. The store log names only the host. Logcat’s one match was AccessibilityNodeInfoDumper printing the URL field during this run’s own uiautomator dumps, not the app |
✅ |
| 8 | Get-BetaDownloads lists every download |
Every TV request from an active key is a row: the 6 manifest loads, neg-wrong-hash (199 B, 200), Showdown 1 from 0 (200), from 167,815,598 (206, 257,753,417 B), from 0 again (200), and Showdown 2 (200) |
✅ |
Noted:
bytesin the download log is the length each response declared, not what reached the TV: the first Showdown download, cut at 167.8 MB, is logged at its full 425,569,015 B.Get-BetaDownloadsnow says so.- Requests with a revoked, suspended, expired or unknown key get their
404and no row, because the Worker can’t tie them to an active tester. Phase 2’s admin page may want those attempts counted. Get-BetaDownloadsprinted D1’s UTC times as if they were local; it now labels them UTC.- While installing, the app keeps the package URL, key included, in its
private staging sidecar (
.zip.part.json) and in its preferences. Both are inside the app’s own storage and the sidecar goes when the install ends; neither is in the shared log. - Through the Worker, the TV pulled 425 MB in 26–28 s (≈15–16 MB/s) on its home network. Extracting took 132 s, because each file is synced.
The key swap
During the run, the session printed the staging sidecar, which holds the
first key, into its own transcript. Nothing was committed. After the run that
tester was renamed jeff-tcl-key1 and revoked (its download history stays),
a new jeff-tcl was issued, and the TV’s preferences were moved to the new
URL: the old key gets 404, the new key 200, and the TV loads the manifest
with it.