Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
node-version: 24.18.0
package-manager-cache: false

- name: Apply approved signing trust to the packaging checkout
run: node scripts/configure-release-signing.mjs "${RUNNER_TEMP}/release-allowed-signers" "${RELEASE_TAG}"

- name: Enable Corepack
run: corepack enable

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ in-memory tier and a durable storage-backed tier for expensive operations.

> [!IMPORTANT]
> Rate Limit is in early `0.x` development. Its public API is not stable.
> Current source is the **`0.3.0` candidate, not published**. Registry `0.2.0`
> Current source is the **`0.3.1` candidate, not published**. Registry `latest`
> remains `0.2.0`, which
> predates the merged [PR #8 hardening](https://github.com/pegma-dev/rate-limit/pull/8)
> and the new bounded maintenance helper. The first advertised `0.1.0`
> release was published from protected signed `v0.1.0` through
> trusted-publisher OIDC with provenance; the historical `0.0.0` name bootstrap
> remains separate under `bootstrap`. pegma.dev composes the durable tier in
> its production Identity worker; this candidate is not a new host deployment.

The source behavior below describes the `0.3.0` candidate. Adoption waits for
The source behavior below describes the `0.3.1` candidate. Adoption waits for
its reviewed publication and the host's explicit configuration/storage transition.

The signed `v0.3.0` tag and GitHub release are retained history: their
preparation failed before packing, produced no release artifact, and did not
publish npm bytes. `0.3.1` corrects the packing checkout's SSH trust configuration
without changing the reviewed limiter API. See the
[failed preparation and patch-release record](docs/RELEASING.md#failed-030-preparation-and-031-candidate).

## Two tiers, no pretending

The most damaging thing a rate limiter can do is misrepresent its consistency.
Expand Down
16 changes: 14 additions & 2 deletions docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@

**Stage:** Phases 1, 2, and 4 are complete; Phase 3 has its first production
consumer. Registry `@pegma/rate-limit@0.2.0` is published, and pegma.dev composes
the durable tier for its Identity surface. Current source is the **`0.3.0`
the durable tier for its Identity surface. Registry `latest` remains `0.2.0`.
Current source is the **`0.3.1`
candidate, not published**, retaining exact Storage Core `0.4.0`. Published
`0.2.0` predates the already-merged [PR #8 hardening](https://github.com/pegma-dev/rate-limit/pull/8)
for immutable policy descriptors, counter kind/configuration bindings, and
clock-skew grace. The candidate includes that hardening plus bounded global
maintenance. The public API remains unstable; source completion is not a
publication or host-adoption receipt.

Signed `v0.3.0` and its GitHub release remain immutable history. Their
preparation failed before packing because SSH trust was configured only in the
temporary verification repository, not the packing checkout. No release
artifact or npm `0.3.0` bytes were published. The `0.3.1` candidate corrects that
release configuration without changing the helper API; its own review, gates,
publication and registry verification remain required. See the
[failed-run receipt](RELEASING.md#failed-030-preparation-and-031-candidate).

The exact reviewed `0.0.0` package-name bootstrap remains published under
`bootstrap`. The first advertised `0.1.0` release was published from the
protected signed annotated `v0.1.0` tag by the GitHub release workflow through
Expand Down Expand Up @@ -187,7 +196,7 @@ collection over an injected Store). The memory tier must remain importable
without a Store — a host wanting only abuse-dampening should not construct
storage. TypeScript, vitest, the ecosystem's standard layout.

## `0.3.0` bounded-maintenance source candidate
## `0.3.1` bounded-maintenance source candidate

`sweepDurableWindowsPage` is a root/durable export over the existing
`rate-limit-windows` collection. One call makes one physical global scan page,
Expand Down Expand Up @@ -218,6 +227,9 @@ retrying from the previous cursor can repeat work. The
define the interface; current-head gates, review, exact publication, and host
adoption remain release work.

Host aliases for this helper must pin `0.3.1` only after its actual verified
registry publication. A signed tag or GitHub release alone is not publication.

Upgrading existing durable data is deliberate: use versioned policy names or
an isolated Store namespace, or coordinate a policy-store reset. Immutable
descriptors bind `limit` and `windowMs`; neither conflicting configuration nor
Expand Down
61 changes: 50 additions & 11 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,61 @@ exact integrity with npm. Only npm `E404` means `absent`; an existing different
artifact or another registry failure stops the ceremony.

Normal preparation authenticates the stable signed tag in a temporary bare
repository before checkout. The resulting artifact contains exactly two
repository before checkout. The packing checkout must also configure the same
approved SSH allowed-signers trust before the release tool independently checks
the signed tag; trust scoped to the temporary bare repository is not inherited.
The resulting artifact contains exactly two
regular files: the manifest and its named tarball. Consumer installation runs
in a separate job without publication authority. The environment-protected
OIDC job checks the tag again, downloads the sealed artifact outside a source
checkout, verifies the preparation manifest digest and both tarball digests,
and invokes npm from a fresh directory with empty configuration files and an
allowlisted environment. It never executes repository code.

## Failed `0.3.0` preparation and `0.3.1` candidate

As of 2026-11-08, npm `latest` remains `0.2.0`; current source is the unpublished
`0.3.1` candidate. Protected signed annotated
[`v0.3.0`](https://github.com/pegma-dev/rate-limit/releases/tag/v0.3.0), tag object
`9df80b019b8ed6e5b7fc0f5a8c7359ae4cae6486`, points to reviewed source
[`93c7a4207d493e10568b797bf7d5a402f446cc70`](https://github.com/pegma-dev/rate-limit/commit/93c7a4207d493e10568b797bf7d5a402f446cc70).
Its GitHub release triggered
[run `42501172611`](https://github.com/pegma-dev/rate-limit/actions/runs/42501172611),
whose [preparation job `128794037936`](https://github.com/pegma-dev/rate-limit/actions/runs/42501172611/job/128794037936)
failed before packing. There is no prepared manifest/tarball artifact from that
run and no npm `0.3.0` publication.

The temporary bare repository had the approved SSH allowed-signers trust, but
the separate packing checkout did not. The release tool's independent tag
verification therefore failed there. This was a checkout trust-configuration
failure, not evidence that the protected signed tag was invalid.

Preserve the `v0.3.0` tag object, source commit, GitHub release and failed-run
record. Never move or replace that tag, reuse its version for changed source,
or treat the failed preparation as publication. The correction uses a reviewed
`0.3.1` patch and a new protected signed `v0.3.1` release identity after merge.
It adds explicit trust to the packing checkout; the limiter/helper API and
behavior remain unchanged. The full Node 22/24 gates and exact-artifact release
checks still apply to the new source.

Only after `0.3.1` actually publishes and its original prepared bytes and
registry release are verified may a host pin it, including through an npm
alias. This does not migrate legacy `0.2.0` counters or change existing host
deployment state. No repeated bootstrap, token fallback or signature bypass is
part of this recovery.

## One-time `0.0.0` package-name bootstrap

**Complete; do not repeat.** The exact reviewed `0.0.0` artifact was published
under `bootstrap`, its signed annotated source tag points to the reviewed
`origin/main` commit, and npm trusted publishing is configured for
`pegma-dev/rate-limit`, `publish.yml`, and the `npm-publish` environment.

npm also assigned the default `latest` tag to `0.0.0`. The operator attempted
During bootstrap npm also assigned the default `latest` tag to `0.0.0`. The operator attempted
to remove it, but npm rejected the request with HTTP 400. The immutable
bootstrap remains exact and the `bootstrap` tag remains correct; publishing
`0.1.0` through the normal workflow will immediately move `latest` to the
first advertised version.
bootstrap remains exact and the `bootstrap` tag remains correct. The later
normal `0.1.0` publication moved `latest` to the first advertised version;
`latest` has since advanced to `0.2.0`.

The steps below are retained only as the ceremony's audit and recovery record.

Expand Down Expand Up @@ -122,7 +157,7 @@ npm dist-tag ls @pegma/rate-limit

`bootstrap` points to `0.0.0`. npm unexpectedly also made `latest` point to
`0.0.0` and rejected its removal with HTTP 400; do not retry destructive
registry changes. The `0.1.0` publication corrects the default tag.
registry changes. The later `0.1.0` publication corrected that default tag.

### 4. Configure trusted publishing

Expand All @@ -145,15 +180,17 @@ The workflow intentionally rejects `0.0.0`; its first permitted release is

## First advertised `0.1.0` release

This separate reviewed pull request must:
**Complete; historical ceremony.** The separate reviewed release pull request
was required to:

1. change `packages/rate-limit/package.json` from `0.0.0` to `0.1.0`;
2. regenerate `pnpm-lock.yaml` and verify its workspace importer pins `0.1.0`;
3. update README and plan status with the advertised release notes; and
4. pass the full gate and release pack smoke on Node 22 and 24.

After that pull request merges, create the protected signed annotated
`v0.1.0` tag on the exact `origin/main` commit and create the GitHub release:
After that pull request merged, the protected signed annotated `v0.1.0` tag
and GitHub release were created at the exact `origin/main` commit. These
commands are retained as the historical ceremony, not instructions to repeat it:

```sh
git fetch origin
Expand Down Expand Up @@ -205,5 +242,7 @@ pnpm run release:registry:check -- --manifest "${artifact_dir}/package-manifest.
npm dist-tag ls @pegma/rate-limit
```

The registry check must report `@pegma/rate-limit@0.1.0: exact`;
`latest` must point to `0.1.0`, while `bootstrap` remains at `0.0.0`.
For that ceremony the registry check had to report
`@pegma/rate-limit@0.1.0: exact`, with `latest` at `0.1.0` and `bootstrap` at
`0.0.0`. Current `latest` is `0.2.0`; do not retag an older release or repeat
the bootstrap to prepare the unpublished `0.3.1` candidate.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"release:pack": "node scripts/release-package.mjs pack",
"release:publish": "node scripts/release-package.mjs publish",
"release:registry:check": "node scripts/release-package.mjs registry-check",
"test": "pnpm run build && vitest run"
"test": "pnpm run build && vitest run && node --test scripts/configure-release-signing.test.mjs scripts/release-workflow-signing.test.mjs"
},
"devDependencies": {
"@azure/data-tables": "13.3.1",
Expand All @@ -31,6 +31,7 @@
"azurite": "3.36.0",
"prettier": "3.9.6",
"typescript": "7.0.2",
"vitest": "4.1.10"
"vitest": "4.1.10",
"yaml": "2.9.1"
}
}
16 changes: 14 additions & 2 deletions packages/rate-limit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Two explicitly named application rate-limit tiers:
abuse-critical operations.

> [!IMPORTANT]
> Current source is the **`0.3.0` candidate, not published**. Published `0.2.0`
> Current source is the **`0.3.1` candidate, not published**. Registry `latest`
> remains `0.2.0`, which
> predates the merged descriptor/configuration hardening and the bounded
> global sweep described here. `0.1.0` was the first advertised release, published through
> trusted-publisher OIDC with provenance. The exact reviewed `0.0.0`
Expand All @@ -20,6 +21,12 @@ The API and storage behavior below describe candidate source. Use an exact
published version only after its release verification and an explicit host
storage/configuration transition.

The signed `v0.3.0` tag and GitHub release exist, but preparation failed before
packing: no release artifact or npm `0.3.0` bytes were published. The `0.3.1`
candidate fixes release-checkout SSH trust, with the reviewed limiter API
unchanged. The immutable failure history and new patch identity are recorded in
[release operations](https://github.com/pegma-dev/rate-limit/blob/main/docs/RELEASING.md).

There is no default tier and no automatic upgrade. This package is application
abuse control, not DDoS protection, HTTP middleware, or billing metering.
Policy names and limiter keys must be primitive, non-blank strings. Whitespace
Expand Down Expand Up @@ -124,7 +131,7 @@ row. Checks against that malformed row still fail closed.
## Bounded global cleanup

The candidate adds this interface at the root and durable subpath, defined in
[the actual source](src/durable.ts):
[the actual source](https://github.com/pegma-dev/rate-limit/blob/main/packages/rate-limit/src/durable.ts):

```ts
export declare function sweepDurableWindowsPage(
Expand Down Expand Up @@ -198,6 +205,11 @@ reset; conflicting instances fail closed. Do not edit descriptors in place,
delete arbitrary malformed rows, or mistake the global sweep for a migration
of previously published `0.2.0` data.

A host adopting the new helper through an npm alias must wait for actual
`0.3.1` publication and registry verification before pinning that alias. Existing
`0.2.0` consumers and counters need their own deliberate migration; the new
release does not convert them automatically.

## License

MIT
2 changes: 1 addition & 1 deletion packages/rate-limit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/rate-limit",
"version": "0.3.0",
"version": "0.3.1",
"description": "Explicit per-instance sliding-window and shared durable fixed-window rate limiters.",
"license": "MIT",
"type": "module",
Expand Down
25 changes: 18 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading