Skip to content

feat(registry): add labeler identity runtime - #1942

Merged
ascorbic merged 1 commit into
feat/plugin-registry-labelling-servicefrom
feat/labeler-14-identity-runtime
Jul 11, 2026
Merged

ascorbic merged 1 commit into
feat/plugin-registry-labelling-servicefrom
feat/labeler-14-identity-runtime

Conversation

@ascorbic

Copy link
Copy Markdown
Member

What does this PR do?

Implements W3.1 identity and signing runtime for the registry labeler:

  • Publishes a strict did:web document with the P-256 #atproto_label method and #atproto_labeler service.
  • Serves the canonical versioned moderation policy with bounded public caching and representation-derived ETags.
  • Wires a Secrets Store-compatible signing-key provider into lazy historical re-signing, with exact private/public key agreement validation.
  • Adds configuration validation for DID/service-origin agreement and canonical P-256 Multikeys.

Part of umbrella PR #1909. Remote resource provisioning and deployment remain deferred.

Type of change

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

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (targeted labeler and registry-moderation tests)
  • pnpm format has been run
  • I have added/updated tests for my changes
  • User-visible strings in the admin UI are wrapped for translation (not applicable: no admin UI)
  • I have added a changeset (not applicable: private app only; no published package changed)
  • New features link to an approved Discussion (not applicable: implementation of the ratified registry labeler spec tracked in Plugin registry labelling service #1909)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenCode with GPT-5.6 Sol; independently reviewed with the review agent

Screenshots / test output

Non-visual Worker change. Verified with:

  • pnpm build
  • pnpm typecheck
  • pnpm lint:json
  • pnpm --filter @emdash-cms/labeler test (27 tests)
  • pnpm --filter @emdash-cms/registry-moderation test (60 tests)
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f7e81b7

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

@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 f7e81b7 Jul 11 2026, 08:32 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-playground f7e81b7 Jul 11 2026, 08:32 AM

@github-actions github-actions Bot added size/L review/needs-review No maintainer or bot review yet labels Jul 11, 2026
@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-do f7e81b7 Jul 11 2026, 08:32 AM

@ascorbic
ascorbic merged commit 533c40e into feat/plugin-registry-labelling-service Jul 11, 2026
8 checks passed
@ascorbic
ascorbic deleted the feat/labeler-14-identity-runtime branch July 11, 2026 08:37
@ascorbic ascorbic mentioned this pull request Jul 11, 2026
60 of 81 tasks

@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.

This is a focused, well-scoped implementation of the W3.1 identity and signing runtime for the registry labeler. The approach is sound: it keeps the public identity material in environment bindings, validates did:web host/origin agreement and a canonical P-256 Multikey, serves the DID document and moderation policy from well-known endpoints, and wires the secret into lazy historical re-signing so stale labels are only materialized when actually queried. The runtime checks (key/public-key agreement, exact DID/service matching, lazy signer factory) line up with the stated goals.

I did not find logic bugs, security issues, or broken contracts in the implementation code. The diff is careful about error handling, avoids leaking configuration details, and the fixture relocation is internally consistent with the imports.

I do have two suggestions. One is a performance/reliability observation: the handler re-validates the public identity on every single request, including cheap read-only endpoints, and the concurrent re-signing test looks like it depends on an ordering that Promise.all does not guarantee. Both are straightforward to harden without changing the public behavior.

Nice work overall — I would not block merge on these, but both are worth addressing before this code is load-bearing in production.


Findings

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

    The fetch handler awaits getLabelerIdentityConfig(env) for every request, including GET /.well-known/did.json and GET /.well-known/emdash-labeler-policy.json. That function imports/de-exports the public Multikey and parses LABELER_SERVICE_URL, so this is a non-trivial amount of repeated work for static worker bindings.

    Because env is immutable for the lifetime of an invocation, the validated identity can be memoized per worker instance or at least resolved once and reused. Consider moving the validation behind the route switch, or caching the result keyed by the binding values, so identity errors are still surfaced but warm requests pay only once.

  • [suggestion] apps/labeler/test/service.test.ts:882-887

    This concurrent re-signing assertion depends on the direct queryLabels call committing its UPDATE before the SELF.fetch handler reads the same row. Both promises start together under Promise.all.

    If SELF.fetch reads first, it sees the stale signing_key_version = 'v1' row while the active signing state is 'v2', and its runtime signer (using the worker env private key PRIVATE_KEY) does not match the active public key. resignStaleLabels then records a RESIGN_CONFIGURATION_MISMATCH alert and throws, so response.status would be 503, not 200.

    The test may happen to pass deterministically with the current miniflare scheduling, but it is not guaranteed. Consider serializing a deterministic re-sign step (await queryLabels(..., signingRuntime)) and only then asserting on SELF.fetch(queryRequest()), or making the test explicitly exercise the race and assert a safe outcome rather than assuming a winner.

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Jul 11, 2026
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/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant