Skip to content

feat(registry): add labeler key rotation - #1938

Merged
ascorbic merged 1 commit into
feat/plugin-registry-labelling-servicefrom
feat/labeler-13-key-rotation
Jul 11, 2026
Merged

ascorbic merged 1 commit into
feat/plugin-registry-labelling-servicefrom
feat/labeler-13-key-rotation

Conversation

@ascorbic

@ascorbic ascorbic commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Adds the persistence and service layer for routine signing-key rotation to the registry labeler. Issuance pauses across the DID update boundary, activation uses compare-and-swap state, historical labels are lazily re-signed without changing their creation timestamps, and rotation status and alerts are available to the later authenticated operator surface.

It also resolves the v1 identity strategy: discovery uses the base #atproto_labeler DID service plus the EmDash policy document, without an app.bsky.labeler.service/self declaration. Standard moderation reports return an explicit NotSupported response and are never persisted.

The production signing runtime and HTTP wiring remain part of W3.1, which provisions the DID, Secrets Store key binding, startup key validation, and policy endpoint. Subscription backfill may retain old-key signatures as explicitly permitted by the AT Protocol key-rotation guidance; labels issued after activation use the active key.

Part of #1909 and RFC #694.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

Admin i18n is not applicable because this changes only the labeler Worker and design documents. A changeset is not applicable because @emdash-cms/labeler is private. This is an implementation slice of the approved registry labeler design tracked by RFC #694 and umbrella PR #1909.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenCode with GPT-5.6-sol

Screenshots / test output

  • pnpm build
  • pnpm typecheck
  • pnpm lint:json reports 0 diagnostics
  • pnpm --filter @emdash-cms/labeler test passes 23 workerd/D1 tests
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 248dd3d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 1,601 lines across 14 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 248dd3d Jul 11 2026, 06:48 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-do 248dd3d Jul 11 2026, 06:49 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 248dd3d Jul 11 2026, 06:46 AM

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying key-rotation state machine is well-considered and the migration correctly captures the CAS-style pause/activate semantics. However, this slice does not actually wire the new behavior to the public HTTP surface, so the headline features from the PR description and spec are not reachable yet.

The biggest gap is that queryLabels is implemented to lazily re-sign stale labels only when it receives a VersionedLabelSigner, but apps/labeler/src/index.ts calls it with only env.DB and the request. The worker also has no signing-key binding in wrangler.jsonc/config.ts, so the public endpoint cannot perform the re-signing the spec calls for. Instead, public queries for pre-rotation labels will return 503.

A related gap is the WebSocket subscription stream: it reads issued_labels rows straight through without re-signing, so subscribers will receive labels signed with retired keys after a rotation.

Finally, the PR says operators can inspect rotation status and alerts, but index.ts exposes no route for getSigningStatus / listSigningAlerts.

I treat this as a comment rather than request-changes because the target branch is the umbrella feature branch and the missing pieces may be intentionally deferred to a follow-up slice — but the HTTP wiring should be completed before this feature is considered functional.

I also noted the PR template checklist item for an approved Discussion is not filled in; acceptable for a feature-branch slice, but should be present before merge to main.


Findings

  • [needs fixing] apps/labeler/src/index.ts:24

    The public queryLabels route is called without a VersionedLabelSigner, so the lazy re-signing logic added in query-labels.ts is never reachable from HTTP. After a key rotation, public reads for labels signed with the previous key will hit the RESIGN_CONFIGURATION_MISMATCH path and return 503 instead of re-signing the label. The spec calls for stale labels to be re-signed lazily on query, so the route either needs a signer constructed from the worker's signing key (which also requires a new env/secret binding) or the re-sign flow should be moved to an internal/admin path with explicit authorization.

  • [needs fixing] apps/labeler/src/subscribe-labels.ts:209

    The subscription labelsAfter() query serves rows from issued_labels directly through rowToLabel() without re-signing stale signatures. After a rotation, subscribers will receive labels signed with the retired key, which will fail verification against the current DID document. The same signing-rotation re-signing logic used for queryLabels needs to be available here too — either by re-signing on read or by ensuring only current-key signatures are broadcast.

  • [suggestion] apps/labeler/src/index.ts:22

    The PR description says operators can inspect rotation status and alerts, and signing-rotation.ts exports getSigningStatus and listSigningAlerts, but index.ts does not expose any route for them. Consider adding an authenticated operator endpoint (for example under a separate admin path or as a dedicated XRPC method) so operators can actually observe rotation state and alerts.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond overlap and removed review/needs-review No maintainer or bot review yet labels Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic

Copy link
Copy Markdown
Member Author

Thanks. I checked these against the workstream boundaries and updated the PR description to make the scope explicit.

  • Public query re-signing: confirmed intentionally deferred to W3.1. This slice provides and verifies the VersionedLabelSigner path, but W3.1 owns the production DID resolution, Secrets Store key binding, startup key validation, and Worker wiring. Calling the route without that runtime fails closed with 503 after rotation rather than serving a signature that cannot be validated.
  • Subscription replay: no change needed. Labels issued after activation use the active key. Only retained backfill can carry old-key signatures, and the AT Protocol Labels specification explicitly says older labels in the event-stream backfill period may have invalid signatures during rotation and that this is acceptable.
  • Status and alerts: the typed service functions are implemented here; exposing them over HTTP requires the authenticated operator surface tracked later in the umbrella workstream. Adding an unauthenticated endpoint here would be incorrect.

The approved design is tracked by RFC #694 and umbrella PR #1909. The labeler app is private, so the changeset warning is expected.

@ascorbic
ascorbic merged commit 0e2f097 into feat/plugin-registry-labelling-service Jul 11, 2026
10 checks passed
@ascorbic
ascorbic deleted the feat/labeler-13-key-rotation branch July 11, 2026 06:57
@ascorbic ascorbic mentioned this pull request Jul 11, 2026
60 of 81 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed review/awaiting-author Reviewed; waiting on the author to respond size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant