chore(deps): upgrade Effect to rc.115 and Alchemy to beta.78 #12326
Mergedjuliusmarmingemerged 2 commits into
main fromrefs/pull/12326/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- @@ -0,0 +71,21 @@71+export class Registry extends Cloudflare.Worker<Registry, {}>()("Worker") {}72+73+const RegistryLive = Registry.make(74+ Effect.gen(function* () {75+ const config = yield* RegistryConfig;76+ return {77+ ...config.worker,78+ main: import.meta.url,79+ env: {80+ [SETTINGS_ENV]: yield* Schema.encodeEffect(Settings)({81+ policy: config.policy,82+ aliases: config.aliases,83+ cron: config.cron,84+ github: { apiUrl: config.github.apiUrl },85+ }).pipe(Effect.orDie),86+ [APP_ID_ENV]: config.github.appId,87+ [PRIVATE_KEY_ENV]: config.github.privateKey,88+ },89+ };90+ }),91+ handler,@@ -0,0 +53,21 @@53+ );54+ const results = new Map(lookups);55+ const extended = yield* Effect.forEach(due, (row) => {56+ const known = row.linked_prs.flatMap((ref) => {57+ const result = results.get(ref);58+ return result === undefined ? [] : [result.closedAt];59+ });60+ // Open pull requests dominate; otherwise the latest close wins. A row61+ // whose pull requests could not all be checked is kept past the next62+ // sweep rather than left to expire: it is re-checked, never deleted,63+ // on GitHub's bad day.64+ const closes = known.filter((closedAt) => closedAt !== undefined);65+ const expiresAt =66+ closes.length < known.length67+ ? now + ttl68+ : known.length < row.linked_prs.length69+ ? Math.max(row.expires_at, now + Duration.toMillis(SWEEP_LOOKAHEAD))70+ : Math.max(...closes) + ttl;71+ return expiresAt === row.expires_at72+ ? Effect.succeed(false)73+ : Tags.setExpiry(row.package, row.tag, expiresAt).pipe(Effect.as(true));@@ -0,0 +91,21 @@91+The KV namespace caches what the Worker learns from GitHub, shared by every isolate: resolved runs for a minute, so the uploads that follow a publish do not repeat the lookup, and installation tokens until shortly before they expire, so one mint per repository serves about an hour. Everything in it is re-derivable, and a KV failure falls through to GitHub.92+93+`alchemy dev` runs the Worker locally with the bucket, database, and cache emulated; the GitHub calls still go to the real API.94+95+## HTTP API96+97+The contract lives in `@alchemy.run/pkg/Protocol` as an Effect `HttpApi`. The Worker implements it with `HttpApiBuilder`; the CLI calls it through `HttpApiClient`, so requests and typed errors are shared rather than duplicated.98+99+| Route | Purpose |100+| ----------------------------------------- | ---------------------------------------------------------------------------------------- |101+| `POST /api/publish` | Body `{ run, manifest }`. Answers `409 MissingTarballs` with what to upload, or the tags |102+| `PUT /api/tarballs/:name/:sha256?repo&runId&attempt` | Content-addressed upload, streamed into R2 with the hash verified by R2 |103+| `GET /api/health` | `{ ok: true }` |104+| `GET /<name>/<tag>` | 302 to the tarball the tag points at |105+| `GET /<name>/-/<sha256>.tgz` | The immutable tarball |106+107+`run` is `{ repo, runId, attempt }`. Errors are `BadRequest` (400), `Forbidden` (403), `RunNotInProgress` (409), `MissingTarballs` (409), `PackageTooLarge` (413), and `Upstream` (502) for GitHub failures.108+109+## Policy110+111+`repos` lists the repositories allowed to publish. A publication may contain any package; every package gets the commit, short commit, `branch:<name>`, and `pr:<number>` tags of the run that produced it, and nothing in the manifest can name a different commit. A package built from a submodule is therefore tagged with the publishing repository's commit; dependency links between tarballs use content URLs and do not involve commits at all.@@ -0,0 +71,21 @@71+export class Registry extends Cloudflare.Worker<Registry, {}>()("Worker") {}72+73+const RegistryLive = Registry.make(74+ Effect.gen(function* () {75+ const config = yield* RegistryConfig;76+ return {77+ ...config.worker,78+ main: import.meta.url,79+ env: {80+ [SETTINGS_ENV]: yield* Schema.encodeEffect(Settings)({81+ policy: config.policy,82+ aliases: config.aliases,83+ cron: config.cron,84+ github: { apiUrl: config.github.apiUrl },85+ }).pipe(Effect.orDie),86+ [APP_ID_ENV]: config.github.appId,87+ [PRIVATE_KEY_ENV]: config.github.privateKey,88+ },89+ };90+ }),91+ handler,@@ -0,0 +63,21 @@63+ // on GitHub's bad day.64+ const closes = known.filter((closedAt) => closedAt !== undefined);65+ const expiresAt =66+ closes.length < known.length67+ ? now + ttl68+ : known.length < row.linked_prs.length69+ ? Math.max(row.expires_at, now + Duration.toMillis(SWEEP_LOOKAHEAD))70+ : Math.max(...closes) + ttl;71+ return expiresAt === row.expires_at72+ ? Effect.succeed(false)73+ : Tags.setExpiry(row.package, row.tag, expiresAt).pipe(Effect.as(true));74+ }).pipe(Effect.map((changed) => changed.filter(Boolean).length));75+76+ const removed = yield* Tags.deleteExpired(now);77+ const referenced = yield* Tags.referencedTarballs();78+ const unreferenced = removed.filter(79+ ({ package: pkg, sha256 }) => !referenced.has(`${pkg}/${sha256}`),80+ );81+ yield* Effect.forEach(82+ unreferenced,83+ ({ package: pkg, sha256 }) => r2.delete(tarballKey(pkg, sha256)),@@ -0,0 +90,21 @@90+ "--init",91+ "--checkout",92+ "--",93+ "submodules/distilled",94+ ],95+ root,96+ );97+ if (previousHead !== undefined) isolateWorktreeConfig(mainRoot);98+ return;99+ }100+101+ // Initialize the primary checkout at its own pin first. Every linked checkout102+ // then gets an independent detached HEAD backed by that same object database.103+ bootstrap(mainRoot);104+ isolateWorktreeConfig(mainRoot);105+ const mainCheckout = resolve(mainRoot, "submodules/distilled");106+ ensureCommit(mainCheckout, pin);107+ // The destination was checked above: it is missing or empty. One --force108+ // replaces only its stale registration; Git still refuses locked worktrees109+ // (overriding a lock would require --force twice). Do not prune other entries.110+ git(["worktree", "add", "--force", "--detach", checkout, pin], mainCheckout);@@ -0,0 +77,21 @@77+ let output = "";78+ const killGroup = () => {79+ if (child.pid === undefined) return;80+ try {81+ process.kill(-child.pid, "SIGKILL");82+ } catch {83+ // The CLI and its process group have already exited.84+ }85+ };86+ const append = (chunk: Buffer) => {87+ const text = chunk.toString();88+ output += text;89+ if (process.env.DEBUG) process.stderr.write(text);90+ };91+ child.stdout.on("data", append);92+ child.stderr.on("data", append);93+ const timer = setTimeout(() => {94+ output += `\nTimed out after ${timeout / 1000}s waiting for alchemy ${name}.`;95+ killGroup();96+ }, timeout);97+ child.once("error", reject);@@ -0,0 +343,21 @@343+ // from a previous take.344+ await t.hide(async () => {345+ await t.run(346+ `export ALCHEMY_HOME=${JSON.stringify(demoHome)} PATH="${shimDir}:$PWD/node_modules/.bin:$PATH"`,347+ );348+ // The CLI falls back to plain output when it detects a coding agent349+ // (CURSOR_AGENT, CLAUDECODE, …) or CI in the environment, and drops350+ // colors under NO_COLOR; the demo is about the TUI, so force both on351+ // regardless of who launched tcut.352+ await t.run(353+ "unset CI CURSOR_AGENT CLAUDECODE CLAUDE_CODE NO_COLOR FORCE_COLOR; export ALCHEMY_TUI=1",354+ );355+ // tcut's pty has no TERM_PROGRAM, so terminal-capability detection356+ // assumes OSC 8 hyperlinks are unsupported and the CLI falls back to357+ // printing every URL in full after its label (the OAuth URL is ~1KB).358+ // Real terminals (Ghostty, iTerm2, kitty, …) render the link inline.359+ await t.run("export FORCE_HYPERLINK=1");360+ // A previous take may have left a live stack behind: tear it down with361+ // a temporary profile before the home is wiped for the on-camera setup.362+ await t.run(`${connectCloudflare("default")} --no-input`);363+ await t.run("alchemy destroy --yes --no-input >/dev/null 2>&1 || true");@@ -0,0 +34,21 @@34+ },35+ Effect.gen(function* () {36+ const visits = yield* Cloudflare.KV.ReadWriteNamespace(Visits);37+ const uploads = yield* Cloudflare.R2.ReadWriteBucket(Uploads);38+39+ return {40+ fetch: Effect.gen(function* () {41+ const request = yield* HttpServerRequest.HttpServerRequest;42+ const url = new URL(request.url, "http://internal");43+44+ if (url.pathname === "/favicon.ico") {45+ return HttpServerResponse.empty({ status: 404 });46+ }47+48+ if (url.pathname === "/upload") {49+ const body = yield* request.text;50+ yield* uploads.put("latest.txt", body).pipe(Effect.orDie);51+ return yield* HttpServerResponse.json({ stored: body.length });52+ }53+54+ const previous = yield* visits.get("count").pipe(Effect.orDie);@@ -0,0 +719,21 @@719+ await t.sleep("2.5s");720+ if ((await visitsApi.title()) !== visits.title) {721+ throw new Error("drift repair did not restore the namespace title");722+ }723+724+ // ── 5. Tear down ─────────────────────────────────────────────────────725+ await slide("Tear it down", "alchemy destroy");726+ await t.type("alchemy destroy");727+ await t.enter();728+ await t.wait(/Destroy\?/, { scope: "screen" });729+ await caption(730+ "destroy shows everything it is about to delete before asking",731+ );732+ await t.sleep("2.5s");733+ await t.type("y");734+ await caption("Deleting the Worker, the KV namespace and the R2 bucket");735+ await t.wait();736+ await t.expect(/Stack destroyed/, { scope: "scrollback" });737+ await caption("All gone — the account is back to where it started");738+ await t.sleep("2s");739+ } finally {
juliusmarminge merged thisd547e3b
juliusmarminge closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
9946541· PR result:09a9a6e· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.