Repository navigation
refactor(rate-limits): delete the slice's create limit, its binding and its settings - #166
Merged
Merged
Conversation
…nd its settings Step 5c-3c of moving off /api/_slice, the last piece of step 5c-3 (the owner's order was the core, then the adapters, then this, one PR each). The per-user create limit was applied by the slice's `create_work_item`, which #161 deleted. Nothing reads it now, and /api/v1 has its own per-key allowance. Deleted: - `CoreConfig.create_rate_limit` and `THRUST_CREATE_RATE_LIMIT`, in the native server and the Worker. - `CoreConfig.rate_window_secs` and `THRUST_RATE_WINDOW_SECS`, and the Worker's startup check of that window. Only the create limit's use-case read them (checked: no other reader in the workspace); /api/v1's window is the period in `THRUST_V1_RATE_LIMIT` and sign-in's is a constant of the core's config. - The `RL_CREATE` binding and its `[[ratelimits]]` block in wrangler.toml, wrangler.stage2.toml and wrangler.pg.stage.toml, and the Worker's `env.rate_limiter("RL_CREATE")`. - In thrust-adapters-cloudflare, `KeyClass::Create` and `CfRateLimiter.create`. A key that starts with `create:` is a key of no class now: an error, never a free pass. The tests list it, as three refused keys. - `Target::create_limit` (no caller) and `THRUST_EXPECT_CREATE_LIMIT`; `THRUST_WORKER_CREATE_LIMIT` and the create handling in scripts/worker-dev.sh; `RATE_LIMIT` in scripts/contract.sh; the create refusal in scripts/stage2-contract.sh. One option is retargeted, not deleted: `scripts/spike-0002-pg.sh deploy --create-limit N` is `--v1-limit N` and rewrites the `RL_V1` limit (marker `__V1_LIMIT__` on that line, default 60). The engine pass goes through /api/v1, so RL_V1 is the binding it needs raised on a deployed Worker; `--create-limit` raised one that the pass no longer touched. The infra, contract-suite and defect-matrix pages and G-26 say so. Operations: the Worker built from this commit and this commit's config are a pair. The code no longer asks for `RL_CREATE` and the config no longer declares it, so the previous Worker with this config would fail to start (it asks for a binding that is not there). Deploy them together. The two assertions that changed in thrust-adapters-cloudflare/tests/rate_limiter.rs are the class list (two classes, not three) and the setting name the period tests pass to `check_binding_period`, which was `THRUST_RATE_WINDOW_SECS` and is the name the Worker still passes (`the period of THRUST_V1_RATE_LIMIT`). Checked: native-memory main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4; worker-memory main 70 of 70; worker-cf main 70 of 70 and bindings 5 of 5, from a config with RL_SIGNIN and RL_V1 only; `cargo nextest run` 3860 of 3860 (6 fewer than before: the class tests have 2 classes where they had 3, and the 3 refused keys are added); doctests; clippy and rustfmt; `sh -n` of the four changed scripts under dash (an Ubuntu container). One test, thrust-api-v1's `parity_slugify_of_drawn_names_is_the_pins`, was reported "leaky" once in the full parallel run and passed clean in three solo runs; it is in a crate this change does not touch. Controls, temporary and reverted: - `create` mapped to a class again in `KeyClass::of`: the 3 refused-key cases fail, 127 others pass. - a Worker that asks for a binding its config lacks never comes up (wrangler: "Binding ... is undefined", exit 4), so the worker-cf cell catches a binding mismatch and its pass without RL_CREATE is evidence. - stage2-contract.sh refuses `THRUST_EXPECT_V1_LIMIT=1000000` (exit 2) and passes the guard at the default. - the spike script's `sed` on the staging template changes only the RL_V1 line (a dry run; nothing is deployed from here). - the dash check of the scripts fails a deliberately broken script. Not run: native-pg (CI runs it) and any deploy. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Main gained #163 (the stock app's OIDC routes, dark until a provider is configured): EXPECT_MAIN 70 became 73, and it changed scripts/contract.sh, docs/src/architecture/infra.md and docs/src/testing/status.md, which this branch edits too. The merge was clean, with no conflicts: #163's block in contract.sh (the e2e pass starts with no OIDC provider) is in a different place from the lines this branch removes, and its infra.md and status.md additions are separate paragraphs and a separate row. This branch adds and removes no contract test, so main's 73 is the count. Main reintroduced none of the names this branch deletes (searched the tree). Checked on the merged tree: native-memory main 73 of 73, sweeper 3 of 3, csrfoff 6 of 6; worker-cf main 73 of 73, started from a config with RL_SIGNIN and RL_V1 only; clippy clean on the workspace; `sh -n` of the four changed scripts under dash, with a broken-script control that fails. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r deletion Main gained #165, the deploy pipeline, while this branch's PR was open. The merge is clean as text, with no conflicts, and it adds no contract test (EXPECT_MAIN stays 73). It is not clean in meaning: the pipeline's template, renderer, workflow and action declare the `RL_CREATE` binding this branch deletes, and `test-deploy-template.sh` holds the template to the same bindings as wrangler.toml, so the template has to follow. That is the next commit. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ation The deploy pipeline (#165) declared the binding that this PR's earlier commit deletes from the Worker and the other configs: the template crates/thrust-worker/wrangler.deploy.toml had an `RL_CREATE` block with a `__RL_CREATE_ID__` marker, scripts/render-wrangler.sh filled it from `THRUST_RL_CREATE_ID`, and deploy.yml and the deploy-worker action passed that variable through. Left alone it fails CI: `test-deploy-template.sh` requires the template and wrangler.toml to bind the same things (`deploy_parity.py`), and the template would still have a binding wrangler.toml no longer has. My first push did not have #165 in it; the failure was found when main moved, by searching its tree for the names this PR deletes. Changed: - wrangler.deploy.toml: the `RL_CREATE` block and its marker go; the comment says the environment has two namespace ids, not three, and that there was a third. - render-wrangler.sh: the marker, the variable, the id list in the header and the self-test fixtures go, and the rule that the ids differ is about two ids now (its message says "the two"; the self-test's fragment "must differ from one another" still matches). The cases for `THRUST_RL_CREATE_ID` unset and empty and for the two equalities that involved it go with it (four cases). Two cases are added, as the control for the removal: a template that still has the retired `__RL_CREATE_ID__` marker is refused ("which this script does not know"), with or without `THRUST_RL_CREATE_ID` still in the environment, so a stale template cannot be rendered into a config that declares a binding the Worker does not use. - The deploy-worker action loses its `rl-create-id` input and its `THRUST_RL_CREATE_ID` env; deploy.yml loses the variable from its list of an environment's variables, from the dry run's environment and from both `rl-create-id:` inputs; test-deploy-worker.sh drops it from its good environment. - G-26 records this. Checked, under dash in an Ubuntu 24.04 container (CI's shell) on this tree and, as a baseline, on origin/main, with python3, jq and nc installed: every test of the `ci-scripts` job and both deploy guards (the renderer's `--self-test` and the workflow lint of deploy.yml and the action) pass on both. The renderer's self-test is 43 ok on this tree and 45 on main: four cases removed, two added. `scripts/check-placement.sh` passes. clippy and rustfmt are clean on the merged tree. Control: main's template against this wrangler.toml fails the parity check (exit 1: the template has `RL_CREATE`, wrangler.toml does not); the fixed template agrees. The `THRUST_RL_CREATE_ID` variable of the GitHub environments is unused now. It is harmless and deleting it is the owner's. A deploy of this commit renders a config with two rate-limit bindings and a Worker that asks for those two. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
Closed
aRustyDev
added a commit
that referenced
this pull request
Nov 15, 2026
…t the slugify test's defect (#182) #166's message reports `parity_slugify_of_drawn_names_is_the_pins` as "leaky" once in a full run. The test is pure: an `include_str!` fixture parsed per test, no thread, no process, no static, no shared path, so nothing in it can leak. nextest's `LEAK` (0.9.140, `leak-timeout` 200 ms by default since 0.9.108) is a pass whose stdout or stderr pipe is still open that long after the process exited, and a leak passes unless the profile asks for `result = "fail"`. Reproduced on 2026-11-15 on the Mac that saw it: 1 of 30 full `--profile ci --workspace` runs (20 plain, 10 with 18 busy loops on 18 cores) flagged one test, and it was `thrust-core::change_password ...::sign_ins_first_1_true` at 0.211 s, not a slugify test; 20 runs of `-p thrust-api-v1` alone under the same load flagged none (128,560 test runs, 1 leak). That test has one thread and spawns nothing, so another process held its pipe. CI's `hermetic` logs (Linux) hold no LEAK in 49 runs, which does not tell the platforms apart (about 1.4 expected at the Mac's rate; none has a probability near 1 in 4). The mechanism reproduces without any test of ours (`tools/fd-race`, std only): 16 threads spawn children with piped stdout, one in eight living 400 ms; on macOS 5 of 62,976 short children (3 runs) had their stdout held 100 ms or more after exiting, 406 to 408 ms at worst, the holder's lifetime; on Linux 0 of 41,984 (2 runs). On macOS std makes a pipe with `pipe()` then `fcntl(FD_CLOEXEC)`, and a child another thread spawns between the two keeps the write end across `exec`; Linux has `pipe2(O_CLOEXEC)`. What is not shown: that nextest's own spawn is what does it in a run (no `lsof` while a leak happened). As the owner chose for the case where the slugify leak is not found: no change to a test and none to `.config/nextest.toml` (a leak is a pass; `result = "fail"` would turn about 1 test run in 128,000 of an OS race into a red build; a longer `leak-timeout` is rule 3's timeout raised to get green). D-19 records it, so a LEAK on a Mac is read as noise about the run and one in CI as a finding. Refs: #58 Co-authored-by: Claude Sonnet 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 15, 2026
…ent, so there is nothing to delete (#180) G-26 ended with "the `THRUST_RL_CREATE_ID` variable of the GitHub environments is unused now, and deleting it is the owner's". It is not in any: read through the API (`gh api repos/aRustyDev/thrust/environments/<env>/variables` and `/secrets`) for `production`, `staging`, `production-do-lifecycle` and `staging-do-lifecycle`, and for the repository (`/actions/variables`, `/actions/secrets`), every list is empty, with admin permission on the repository. The infra repo has no `THRUST_RL` and declares no `github_actions_environment_variable`. In this repository only G-26 and `render-wrangler.sh`'s self-test (which exports it to show that it is ignored) name it; #166 removed the last reader. So the entry no longer leaves a chore to the owner, and says there is nothing to set when the environments are filled in. No GitHub setting was changed. Refs: #58 Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 5c-3c of moving off
/api/_slice, the last piece of step 5c-3 (the owner's order was the core #161, the adapters #164, then this). The per-user create limit was applied by the slice'screate_work_item, which #161 deleted. Nothing reads it now, and/api/v1has its own per-key allowance.What goes
CoreConfig.create_rate_limitandTHRUST_CREATE_RATE_LIMIT, in the native server and the Worker.CoreConfig.rate_window_secsandTHRUST_RATE_WINDOW_SECS, and the Worker's startup check of that window. Only the create limit's use-case read them (no other reader in the workspace);/api/v1's window is the period inTHRUST_V1_RATE_LIMITand sign-in's is a constant.RL_CREATEbinding and its[[ratelimits]]block inwrangler.toml,wrangler.stage2.tomlandwrangler.pg.stage.toml, and the Worker'senv.rate_limiter("RL_CREATE").thrust-adapters-cloudflare,KeyClass::CreateandCfRateLimiter.create. A key that starts withcreate:is a key of no class now: an error, never a free pass. The tests list it as three refused keys.Target::create_limit(no caller) andTHRUST_EXPECT_CREATE_LIMIT;THRUST_WORKER_CREATE_LIMITand the create handling inscripts/worker-dev.sh;RATE_LIMITinscripts/contract.sh; the create refusal inscripts/stage2-contract.sh.The deploy pipeline (#165) declared the binding too
#165 landed while this PR was open. It merged cleanly as text, but its template
wrangler.deploy.toml, its rendererscripts/render-wrangler.sh(the__RL_CREATE_ID__marker, the variable, the rule that the ids differ),deploy.ymland thedeploy-workeraction (anrl-create-idinput) all declare or pass the binding this PR deletes, andtest-deploy-template.shholds the template to the same bindings aswrangler.toml. Left alone it would fail CI. They are changed in the last commit:RL_CREATEblock and marker go from the template; the renderer's id list, fixtures and distinctness rule are about two ids; the action losesrl-create-idanddeploy.ymlthe variable.THRUST_RL_CREATE_ID(unset, empty, and the two equalities) and gains two, as the control for the removal: a template that still has the retired marker is refused, with or withoutTHRUST_RL_CREATE_IDin the environment. 45 ok on main, 43 ok here.wrangler.tomlfailsdeploy_parity.py(exit 1, namingRL_CREATE); the fixed template agrees.THRUST_RL_CREATE_IDvariable of the GitHub environments is unused now. It is harmless, and deleting it is yours.One option is retargeted, not deleted
scripts/spike-0002-pg.sh deploy --create-limit Nis now--v1-limit Nand rewrites theRL_V1limit (marker__V1_LIMIT__on that line, default 60). The engine pass goes through/api/v1, soRL_V1is the binding it needs raised on a deployed Worker;--create-limitraised one that the pass no longer touched. A dry run of itssedon the template changes only that line. Nothing is deployed from here, so the option itself has not been run against Cloudflare.Operations: deploy the Worker and its config together
The code no longer asks for
RL_CREATEand the config no longer declares it, so the two are a pair. The previous Worker with this config would fail to start (it asks for a binding that is not there; see the control below). A deploy of this commit is consistent.Docs
G-26 records the deploy part too.
docs/src/architecture/infra.md(the diagram, the bindings table, the rate-limit notes, the stage-2 description, the namespace ids and the environment table),contract-suite.md,defect-matrix.mdand G-26 indocs/src/testing/status.md, whose "Not done" clause is now only the slice routes with no Plane counterpart and thenSLICE_PREFIX. ADR 0033 and the plans keep the old names: they are history.Verification
On the merged tree (main gained #163, so
EXPECT_MAINis 73, and then #165; this PR adds and removes no contract test):RL_SIGNINandRL_V1only (its log names noRL_CREATE). Before the merge, also worker-cf bindings 5 of 5.cargo nextest run3860 of 3860 (6 fewer than before: the Cloudflare class tests have 2 classes where they had 3, and the 3 refused keys are added); the doctests;cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --all --checkclean.ci-scriptsjob's tests and the deploy guards (the renderer's--self-test, the workflow lint ofdeploy.ymland the action) underdashin an Ubuntu 24.04 container, with python3, jq and nc, on this tree and on main as a baseline: all pass on both.scripts/check-placement.shpasses.sh -nof the four changed scripts underdash(an Ubuntu container, where/bin/shisdash, as in CI), with a deliberately broken script that must fail the check, and does.Controls (temporary, reverted):
createmapped to a class again inKeyClass::of: the 3 refused-key cases fail, 127 others pass.RL_CREATEis evidence. (That message is not theexit=4flake's.)stage2-contract.shrefusesTHRUST_EXPECT_V1_LIMIT=1000000(exit 2) and passes the guard at the default.One test,
parity_slugify_of_drawn_names_is_the_pinsinthrust-api-v1, was reported "leaky" once in the full parallel run and passed clean in three solo runs; it is in a crate this PR does not touch.Not run locally: native-pg (CI runs it) and any deploy.
Part of #58; this PR does not close it.
🤖 Generated with Claude Code