Repository navigation
Conversation
Add developer and operator documentation for the labeler service: README (overview, local dev, deploy checklist, config reference), docs/atproto.md (DIDs, did:web, the DID document, labels, signing, XRPC surface), docs/operating.md (console roles and workflows), and docs/moderation-model.md (label vocabulary and eligibility evaluation). Add a `keygen` script that generates a P-256 signing keypair in the exact formats the Worker validates on boot: the private key as unpadded base64url of the raw 32-byte scalar and the public key as a canonical P-256 Multikey. Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | e01a842 | Jul 14 2026, 06:57 AM |
There was a problem hiding this comment.
Approach judgment: This is a documentation + small tooling PR (four Markdown docs under apps/labeler/, plus a keygen script and its @atcute/multibase devDep). It's the right kind of change for this branch — documenting an already-merged labeler service and adding a keypair helper for the deploy workflow. No published package changes (@emdash-cms/labeler is private), so no changeset is needed; no admin-UI strings are touched, so the Lingui/RTL conventions don't apply. The approach is sound.
What I verified:
- keygen.mjs API usage —
P256PrivateKeyExportable.createKeypair(),exportPrivateKey("raw"),exportPublicKey("multikey"), andtoBase64Urlfrom@atcute/multibaseare exactly the APIs the aggregator tests (apps/aggregator/test/labels-consumer.test.ts,label-ingestor.test.ts, etc.) already use, so the imports are real and the formats are correct. - Private-key format —
toBase64Url(exportPrivateKey("raw"))produces canonical unpadded base64url of the 32-byte scalar, which is precisely whatimportPrivateScalarinpackages/registry-moderation/src/index.tsvalidates (BASE64URLregex, 32 bytes,toBase64Url(bytes) === value, scalar in range). Round-trips. - Public-key format —
exportPublicKey("multikey")is canonical, matchingvalidatePublicMultikeyinapps/labeler/src/config.ts(which re-exports and requires equality). The keygen output will pass boot-time config validation. - Docs vs. source — checked the DID-document shape and content-type (
identity.ts), the XRPC surface andcreateReport → NotSupported(index.ts),subscribeLabelscursor rules, the 300s policy cache, Cloudflare Access RS256/issuer/audience/exp verification and admin-inherits-reviewer (access-auth.ts), the emergency intent phrases (console-mutation-api.tsEMERGENCY_INTENT:CONFIRM TAKEDOWN/CONFIRM COMPROMISE/CONFIRM RETRACT),X-EmDash-Request: 1CSRF (mutation-guard.ts),whoami,NO_ACTIVE_LABEL → 404, the dead-letterstatus='new'single-flip resolve, and the automation kill-switch gating only ingestion (automation-state.ts). All match. - moderation-model.md — all 23 labels, categories, effects,
cidRules, issuance modes,policyVersion(2026-07-10.experimental.3), the override rule, and the precedence order match thefixtures/moderation-policy.jsonfixture and theevaluateReleaseModerationCoreevaluator exactly.
Headline conclusion: The docs are unusually accurate against the source. One substantive inaccuracy: the "validates on boot / fails the deploy / refuses to start" keypair-mismatch guarantee is repeated in three places but does not match the code — the private↔public-key match check is lazy (run only when a signer is constructed, i.e. on the first signing operation such as a discovery batch, a queryLabels re-sign, or a console mutation), not at boot or deploy time. wrangler deploy only enforces that the LABEL_SIGNING_PRIVATE_KEY secret exists; it does not check it matches the public key. An operator could deploy a mismatched pair and not learn of it until the first sign operation. Worth fixing the wording; not a code break, so comment rather than request_changes.
|
|
||
| ## Deploying | ||
|
|
||
| The Worker validates on boot that its signing keypair matches the public key published in its DID document, so a copy error fails the deploy rather than shipping a labeler whose signatures cannot be verified. Work through the checklist in order. |
There was a problem hiding this comment.
[needs fixing] This sentence (and the same claim repeated in docs/atproto.md:82 and scripts/keygen.mjs:11-12) states the Worker "validates on boot that its signing keypair matches the public key" and that a mismatch "fails the deploy" / the Worker "refuses to start." That does not match the code.
The keypair-match check lives in createLabelSigner (packages/registry-moderation/src/index.ts), which compares key.exportPublicKey("multikey") against the resolved #atproto_label key. It is only invoked via createRuntimeSigner, and the labeler calls that lazily — inside queryLabels (only when there are stale labels to re-sign), inside console mutations that sign, and inside createProductionDiscoveryDeps when a discovery batch is processed (discovery-consumer.ts:~511). Nothing runs it at module load, in a DO constructor, or in the scheduled handler. getLabelerIdentityConfig (run per request) validates only the public key's format/canonicity, not that the private key matches it. The only deploy-time guarantee is the unrelated required: ["LABEL_SIGNING_PRIVATE_KEY"] in wrangler.jsonc, which makes wrangler deploy refuse only if the secret is unset — not if it mismatches the public key.
So a freshly deployed Worker with a mismatched pair boots fine, serves /.well-known/did.json and the policy, and only throws when the first signing operation runs. The docs' safety guarantee ("a copy error fails the deploy rather than shipping a labeler whose signatures cannot be verified") is therefore overstated and could lead an operator to assume a successful deploy means the pair is consistent — exactly the scenario a key-rotation runbook needs to get right.
| The Worker validates on boot that its signing keypair matches the public key published in its DID document, so a copy error fails the deploy rather than shipping a labeler whose signatures cannot be verified. Work through the checklist in order. | |
| The Worker checks, when it first builds a signer (the first label it signs or re-signs — e.g. a discovery batch, a `queryLabels` re-sign, or a console mutation), that the configured private key derives the public key published in its DID document; a mismatch throws at that point. This is separate from the deploy-time required-secret check: `wrangler deploy` only refuses if `LABEL_SIGNING_PRIVATE_KEY` has not been set — it does not verify the pair matches, so confirm the values yourself when rotating. Work through the checklist in order. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | e01a842 | Jul 14 2026, 06:57 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | e01a842 | Jul 14 2026, 06:56 AM |
The keypair mismatch check runs lazily when the signer is first constructed (the first signing operation), not at boot or deploy. `wrangler deploy` only enforces that the private-key secret exists. Reword the README, atproto doc, and keygen comment so operators know a mismatched pair deploys cleanly and fails on the first sign, and to exercise a signing path after setting or rotating the key. Claude-Session: https://claude.ai/code/session_014rikrGMh25h1rJczUQyTMM
There was a problem hiding this comment.
Re-review. This is a documentation + small tooling PR for the (already-merged) labeler service: four Markdown files under apps/labeler/, a keygen script, and the @atcute/multibase devDep. The approach is sound — documenting existing behavior and adding a keypair helper for the deploy workflow; no published package changes (so no changeset), no admin-UI strings touched (so Lingui/RTL don't apply). Nothing here is a new feature needing an approved Discussion.
Prior finding — resolved. My previous review flagged a substantive inaccuracy: the "validates on boot / fails the deploy / refuses to start" keypair-mismatch guarantee was stated in three places but did not match the code — the private↔public match is checked lazily inside createLabelSigner (run only when a signer is constructed), not at boot or deploy. The author has corrected all three locations:
README.md(Deploying section): "The Worker checks that its signing keypair matches the public key … the first time it signs a label — not at deploy time.wrangler deployonly enforces that theLABEL_SIGNING_PRIVATE_KEYsecret exists, so a mismatched pair deploys cleanly and then fails on the first signing operation."docs/atproto.md(Signing): "The Worker checks that the configured private key derives the public key … when it constructs its signer — which happens lazily, on the first signing operation, not at boot or deploy."scripts/keygen.mjs(header comment): "The Worker verifies the pair the first time it signs (not at deploy), so a mismatch surfaces as a failed signing operation rather than at boot."
I re-verified the corrected wording against the source: createLabelSigner (packages/registry-moderation/src/index.ts) is the only place the keypair is matched (key.exportPublicKey("multikey") !== resolved.exportPublicKey("multikey")), and it's reached via createRuntimeSigner (signing-runtime.ts), which is called lazily — as a factory for queryLabels (index.ts), as createSigner: async () => … for console mutations, and inside createProductionDiscoveryDeps for discovery. So the lazy description is now accurate.
What else I verified (no regressions):
- keygen.mjs API usage —
P256PrivateKeyExportable.createKeypair(),exportPrivateKey("raw")wrapped withtoBase64Url, andexportPublicKey("multikey")are exactly whatapps/aggregator/test/label-ingestor.test.tsandlabels-consumer.test.tsuse; imports are real. - Catalog / lockfile —
@atcute/multibase(^1.2.0) and@atcute/crypto(^2.4.1) are both inpnpm-workspace.yaml's catalog, and@atcute/multibaseis added toapps/labeler/package.jsondevDeps with a matchingpnpm-lock.yamlentry. - Private-key format —
importPrivateScalarvalidatesBASE64URLregex, 32 bytes,toBase64Url(bytes) === value, and scalar-in-range; the keygen output satisfies this. - Public-key format —
validatePublicMultikeyinconfig.tsrequires canonical equality to the re-exported Multikey; the keygen output satisfies this. - wrangler.jsonc —
LABEL_SIGNING_PRIVATE_KEYis declared undersecrets.required, sowrangler deploydoes validate the secret exists (just not that it matches the public key) — consistent with the README's wording. - moderation-model.md —
policyVersion2026-07-10.experimental.3and the precedence array (manual-block → label-state-collision → assessment-error → assessment-pending → automated-block → missing-assessment-pass → eligible) matchfixtures/moderation-policy.json; the 23 labels and their effect/cidRule/issuer columns match the fixture (spot-checked!takedown,security-yanked,publisher-compromised,package-disputed,assessment-overridden).
Headline conclusion: The prior inaccuracy is fixed, the fix is accurate, and the rest of the docs/script remain correct against the source. No new findings. Clean to merge.
2881e37
into
feat/plugin-registry-labelling-service
What does this PR do?
Adds the labeler service's first documentation set, plus a
keygenhelper script.Four Markdown files under
apps/labeler/:README.md— overview, how the pieces fit together, local-dev scripts, a numbered deploy checklist (Access app + AUD tag → keypair → migrations → deploy), and a config reference table (vars vs secrets).docs/atproto.md— ATProto foundations for anyone consuming the labeler or working on it: decentralized identity and DIDs,did:webvsdid:plcand why a labeler picksdid:web, the actual DID-document shape served at/.well-known/did.json, the label and subject model, P-256 signing and boot-time key validation, the XRPC surface, Jetstream ingestion, and the end-to-end consumer trust chain.docs/operating.md— operator console guide: Cloudflare Access sign-in, the reviewer/admin capability split, and each workflow (review/issue/retract, rerun, false-positive override + override-retract, emergency ceremonies, the automation kill-switch, the dead-letter queue, and the audit log).docs/moderation-model.md— the full label vocabulary (all 23 labels with effect / subject / cidRule / issuer), the public policy URL and currentpolicyVersion, eligibility evaluation and its precedence order, the §10 rule, and the no-cascade rule.The
keygenscript (apps/labeler/scripts/keygen.mjs, wired aspnpm --filter @emdash-cms/labeler keygen) generates a P-256 signing keypair in the exact formats the Worker validates on boot: the private key as unpadded base64url of the raw 32-byte scalar (LABEL_SIGNING_PRIVATE_KEY) and the public key as a canonical P-256 Multikey (LABEL_SIGNING_PUBLIC_KEY). Verified: the private value round-trips to 32 bytes and reimporting it re-derives the same public Multikey. Adds@atcute/multibaseas a devDependency (the script needstoBase64Url).Every emdash-specific claim in the docs was checked against the merged source (
identity.ts,index.ts,xrpc-router.ts, the eligibility evaluator inregistry-moderation,wrangler.jsonc, and the policy fixture).Closes #
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
pnpm --filter @emdash-cms/labeler keygenprints the two values in the documented formats; the private key round-trips to 32 bytes and reimport re-derives the same public Multikey.Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
docs/labeler-operator-guide. Updated automatically when the playground redeploys.