Files
magpie/site/wrangler.jsonc
T
yetone 8f4469954e site: a Stable update feed, a release a week and an urgent one at once
ssharpcc on X reads every changelog before updating, for fear of a ban
when behind, and with many releases a day that is a lot of reading. This
is the feed side of Settings' Update channel: /api/latest?channel=stable.

How Stable is chosen (stableOf, from the release list, never by hand):
- as each week begins (Monday 00:00 UTC), the newest release that had
  been out three days by then (published <= Monday - 3 days);
- an urgent release is Stable as soon as it is out, until a weekly pick
  passes it.
A release is urgent when a line of its notes starts with
"**Urgent release:** <why>" (quoted or not). GitHub releases are not
marked pre-release for any of this.

GitHub's newest 100 releases are about a day of magpie, so a KV ledger
(LEDGER, usemagpie-ledger) keeps 45 days of {version, published, urgent}
and each day's notes, filled by a cron every 15 minutes: the API's first
page (the releases feed when the API says no, keeping the ledger's dates
and API notes), the pages after it while there is a hole, and on back to
21 days, at most four API asks a run, writing only what changed. A
ledger that can't be read is never written over. /api/notes reads a
range older than the newest 100 on from the ledger, so a Stable app's
week of notes comes as one list. Without a ledger reaching the week's
cut, the stable feed answers 503 (no-store) rather than guess. The
default feed, and any other channel value, is unchanged.

Run: node --test site/*.test.mjs (stable.test.mjs 14 new, every clock
held: weekStart, the cut to the second, a week held and moved on, urgent
before/after its time, unknown, the ledger's paging, hole, ask cap,
broken KV, API-limited feed fallback, notes past the 100 newest; the
existing worker and install tests 31 pass). wrangler deploy --dry-run
shows the LEDGER binding.
Broken by hand, each red: no soak, a rolling 3 days instead of the week,
urgent ignored, no ledger notes, a broken read taken as empty, the
feed's date or notes over the API's, notes bucketed by the feed's date,
no hole mending, no ask cap, the index always rewritten, the marker
matched mid-line.
Not tried: a real cron run before this deploy; the anonymous API's
60/hour limit under the cron's asks beyond reasoning (one ask a run once
the ledger is deep).

Requested by ssharpcc on X.
2026-10-26 21:08:00 +08:00

23 lines
867 B
JSON

// usemagpie.ai: the static site in public/, plus worker.js for the update
// feed and the download links. Deploy with `npx wrangler deploy` from here.
{
"name": "usemagpie",
"main": "worker.js",
"compatibility_date": "2026-09-01",
"assets": {
"directory": "./public",
"binding": "ASSETS",
// every request, so worker.js can send www.usemagpie.ai to usemagpie.ai
"run_worker_first": true
},
"routes": [
{ "pattern": "usemagpie.ai", "custom_domain": true },
{ "pattern": "www.usemagpie.ai", "custom_domain": true }
],
// the ledger of releases the Stable channel is chosen from (worker.js,
// "The Stable channel"), kept by the cron every quarter hour
"kv_namespaces": [{ "binding": "LEDGER", "id": "716b22ec7d4c496abb7b3dc085258fde" }],
"triggers": { "crons": ["*/15 * * * *"] },
"observability": { "enabled": true }
}