Skip to content

feat(cloudflare/ruleset): add Ruleset resource - #240

Merged
sam-goodwin merged 7 commits into
alchemy-run:mainfrom
agcty:codex/cloudflare-ruleset-resource
Jun 2, 2026
Merged

feat(cloudflare/ruleset): add Ruleset resource#240
sam-goodwin merged 7 commits into
alchemy-run:mainfrom
agcty:codex/cloudflare-ruleset-resource

Conversation

@agcty

@agcty agcty commented May 5, 2026

Copy link
Copy Markdown
Contributor

Adds a first-class Cloudflare Ruleset resource for zone phase entrypoints.

  • supports zone-scoped phase entrypoint ownership via rulesets.putPhas
  • accepts { zoneId }, zone ID strings, and hostname strings for zone selection
  • clears the owned phase entrypoint on destroy
  • adds a focused live test gated by CLOUDFLARE_TEST_RULESET_ZONE_ID
  • registers Ruleset in the Cloudflare provider collection

Depends on alchemy-run/distilled#257 for generated Rulesets phase path support.

Verification run:

  • bun vitest run packages/alchemy/test/Cloudflare/Ruleset/Ruleset.test.ts
  • bun tsc -b --pretty false
  • git diff --check

@agcty

agcty commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Verification update:

  • Focused test passes without live env: bun vitest run packages/alchemy/test/Cloudflare/Ruleset/Ruleset.test.ts (skipped as expected).
  • Typecheck passed: bun tsc -b --pretty false.
  • Live test is currently blocked by fix(cloudflare/rulesets): support phase entrypoint paths distilled#257. With the currently installed @distilled.cloud/cloudflare@0.16.7, the generated rulesets client calls /{accountOrZone}/{accountOrZoneId}/rulesets/phases/..., and Cloudflare returns No route for that URI. This is the exact path-generation bug fixed in the Distilled PR, so I am leaving this PR draft until that dependency is available here or otherwise linked for an end-to-end live run.

@agcty

agcty commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Marking this ready for review now. One dependency remains for full live-test verification: alchemy-run/distilled#257 needs to land or be otherwise consumed by this repo so the generated Rulesets client uses the correct phase-entrypoint path. The current implementation and focused tests are ready for review, and the live-test blocker is documented above.

@agcty
agcty marked this pull request as ready for review May 5, 2026 13:58
@agcty
agcty force-pushed the codex/cloudflare-ruleset-resource branch from 856d990 to 75823a2 Compare May 6, 2026 07:26
@sam-goodwin

Copy link
Copy Markdown
Contributor

@Mkassabov we need to figure out what we want to do for alchemy-run/distilled#257

SO we can get this merged. It's a high demand/high utility resource

@agcty
agcty force-pushed the codex/cloudflare-ruleset-resource branch from 75823a2 to 98f74c3 Compare May 12, 2026 08:33
@agcty

agcty commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Update: Distilled 0.19.1 is published now, so this branch has been rebased and updated to consume the scoped Rulesets operations from the released package (getPhasForZone / putPhasForZone).

Verified:

  • bun install --frozen-lockfile
  • bun tsc -b --pretty false
  • bun test packages/alchemy/test/Cloudflare/Ruleset/Ruleset.test.ts (skips without CLOUDFLARE_TEST_EMPTY_RULESET_ZONE_ID)

The previous live-test path issue is resolved by the new Distilled package. Full live create/update/delete still needs a Cloudflare token with Zone Rulesets read/write for the test zone; the earlier token reached the correct endpoint but Cloudflare returned Forbidden.

@sam-goodwin @Mkassabov

@agcty

agcty commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

pushing some fixes rn, testing with my own zone

@sam-goodwin

Copy link
Copy Markdown
Contributor

Thanks. Please make sure we have adequate regression tests for anything you find on your zone

@agcty

agcty commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

small dependency note from live testing: create/update/delete with a real Cloudflare token and sneef.xyz reached the scoped zone phase endpoint correctly with @distilled.cloud/cloudflare@0.19.1.

the remaining failure is after delete / emptying the entrypoint. Cloudflare returns 200 with a valid ruleset result but no rules key. Distilled currently decodes getPhas / putPhas as if rules is required, so the SDK turns that 200 into a schema parse error and Alchemy retries/times out.

opened alchemy-run/distilled#289 to fix that at the generated SDK layer. once released, this PR can stay idiomatic and just treat missing rules as an empty array instead of doing raw fetch / body parsing in Alchemy.

@agcty

agcty commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@sam-goodwin seems good to go now! one thing i noticed while working in both distilled and alchemy effect repos is that having two repos is slowing down agentic work quite a bit, might be worth exploring a single monorepo

@sam-goodwin

Copy link
Copy Markdown
Contributor

I am upstreaming the distilled change and then will merge into this PR

@agcty
agcty force-pushed the codex/cloudflare-ruleset-resource branch from 43e103a to 062e0f8 Compare May 18, 2026 18:16
@sam-goodwin
sam-goodwin force-pushed the codex/cloudflare-ruleset-resource branch from 4248955 to 5181557 Compare June 2, 2026 05:44
@sam-goodwin
sam-goodwin merged commit 93d1cde into alchemy-run:main Jun 2, 2026
1 of 3 checks passed
DavidJFelix pushed a commit to DavidJFelix/alchemy-effect that referenced this pull request Aug 7, 2026
Co-authored-by: Sam Goodwin <sam@alchemy.run>
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.

2 participants