Skip to content

feat(labeler): publisher contact resolution via aggregator binding (W10.4 slice A) - #2073

Merged
ascorbic merged 2 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-contact-resolution
Jul 16, 2026
Merged

ascorbic merged 2 commits into
feat/plugin-registry-labelling-servicefrom
feat/labeler-contact-resolution

Conversation

@ascorbic

Copy link
Copy Markdown
Member

What does this PR do?

Implements W10.4 slice A — publisher contact resolution for the labeler: given a package subject, resolve the email a takedown/warning notice would be offered to by walking three tiers in spec order and seeding the double-opt-in state row so slice C's confirm flow can proceed. Sending the mail is W10.5; this slice resolves and seeds only.

  • Resolver (apps/labeler/src/publisher-contact.ts): walks package security[] → package authors[] → publisher profile contact[] (preferring kind: security within the tier), returning the first entry carrying a non-empty email. url-only contacts are skipped, not treated as resolved. Reads go through the aggregator service binding with a fresh single read per tier and no caching. "No resolvable contact" is an expected terminal outcome, not an error; only a transport failure throws.
  • Seeding seam seedPublisherContact: hashes the resolved email via recipientHash, honors suppression (isSuppressed), then ensureContact (insert-if-absent). Never re-seeds a suppressed address or resets an already-confirmed contact. This is the unit W10.5's send path calls.
  • Tier-3 exposure: the publisher profile contact[] was already indexed in the aggregator (publishers.contact) but not exposed by any read, so this adds a minimal read-only getPublisher(did) XRPC query + publisherView definition, mirroring getPackage's label hydration and takedown redaction, plus a client method.

No notification trigger is wired yet (W10.5 owns it), so the resolver + seeding ship as a standalone, tested seam.

Part of the ratified plugin-registry labelling-service plan (W10.4). Targets the feat/plugin-registry-labelling-service integration branch, not main.

Privacy note (informational, not a gate): publisher/package contact emails are now also available as decoded JSON via getPublisher, a hair easier to scrape than the CBOR the aggregator already serves unredacted via com.atproto.sync.getRecord. This is no new disclosure — the publisher.profile is a signed public record already served verbatim by that endpoint, and getPackage exposes package security[] emails identically. In fact getPublisher is strictly more redaction-restrictive than sync.getRecord: it applies takedown enforcement (returns NotFound for a redacted publisher DID) where the raw record endpoint does not. The labeler's own reads send a blank atproto-accept-labelers header, so takedown-contact resolution still works on a redacted subject while public callers get normal redaction.

Plaintext email is held in memory only — hashed immediately, never persisted or logged (logs carry the public DID and an 8-char hash prefix).

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 (labeler, aggregator, registry-lexicons)
  • pnpm lint passes (0 diagnostics in changed files; ~40 pre-existing baseline unchanged)
  • pnpm test passes (labeler 667, aggregator 304, registry-lexicons 23)
  • pnpm format has been run (oxfmt on touched paths)
  • I have added/updated tests for my changes (tier walk, seeding, aggregator route, real-binding end-to-end)
  • User-visible strings in the admin UI are wrapped for translation — n/a, no admin UI strings (server/worker + lexicon only)
  • I have added a changeset (@emdash-cms/registry-lexicons minor; labeler + aggregator are private)
  • New features link to an approved Discussion — covered by the ratified W10.4 plan on the integration branch (maintainer-directed workstream)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8

Screenshots / test output

labeler:            34 files, 667 tests passed
aggregator:         14 files, 304 tests passed (incl. 8 getPublisher read-api tests)
registry-lexicons:   2 files,  23 tests passed
typecheck:          clean (labeler + aggregator + registry-lexicons)
lint:               0 diagnostics in changed files (40 baseline, unchanged)
oxfmt --check:      all touched files correctly formatted

ascorbic added 2 commits July 16, 2026 13:19
…10.4 slice A)

Resolve a package's takedown/notification email by walking three tiers in
spec order -- package security[], package authors[], then the publisher
profile contact[] (preferring kind:security within the tier) -- through the
aggregator service binding with a fresh single read per tier and no caching.
url-only contacts are skipped, not treated as resolved; "no resolvable
contact" is an expected terminal outcome, not an error, and only a transport
failure throws.

Seed the double-opt-in state row on resolution: hash the email via
recipientHash and ensureContact, honoring suppression so a victim named in
hostile metadata is never re-seeded into a fresh unconfirmed state, and never
resetting an already-confirmed contact. Plaintext email is held in memory only
-- hashed immediately, never persisted or logged (logs carry the public DID
and an 8-char hash prefix). Sending the confirmation mail is W10.5; this seam
resolves and seeds only.

Tier 3 (the publisher profile contact[]) was already indexed in the aggregator
(publishers.contact) but not exposed by any read, so add a minimal
getPublisher XRPC query and publisherView definition, mirroring getPackage's
label hydration and takedown redaction. Add a getPublisher client method and
extend the test AGGREGATOR stub to serve realistic getPackage/getPublisher
views so the resolver is exercised end to end through the real binding.
Mirrors the getPackage symmetric test: a !takedown on the publisher
profile URI (not just the DID subject) redacts getPublisher to 404,
closing the coverage parity gap.
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1efcbe5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@emdash-cms/registry-lexicons Minor
@emdash-cms/admin Patch
@emdash-cms/plugin-cli Patch
@emdash-cms/registry-client Patch
@emdash-cms/registry-verification Patch
@emdash-cms/labeler Patch
emdash Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 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-cache 1efcbe5 Jul 16 2026, 12:40 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 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 1efcbe5 Jul 16 2026, 12:39 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 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 1efcbe5 Jul 16 2026, 12:39 PM

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 1,044 lines across 16 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.

@github-actions github-actions Bot added size/XL review/needs-review No maintainer or bot review yet cla: signed labels Jul 16, 2026

@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 the right slice-A seam for W10.4: it adds the minimal getPublisher read surface the labeler needs to reach tier-3 contacts and keeps the resolver + seeding self-contained and untriggered for W10.5. The approach is consistent with the existing aggregator read API (same label hydration, redaction, caching, and CID-fallback patterns as getPackage) and the contact hash/seeding conventions already in notification-contacts.ts.

What I checked:

  • Diff & changed files — read the full diff and the key new/changed files: apps/aggregator/src/routes/xrpc/getPublisher.ts, views.ts, router.ts, apps/labeler/src/publisher-contact.ts, aggregator-client.ts, apps/labeler/vitest.config.ts, the lexicon JSON, and the generated registry-lexicons types.
  • SQL safety — getPublisher follows the same safe pattern as getPackage: column names come from a module-constant list, only ?-bound values touch D1, and no user data reaches the SQL text. publishers.did is the primary key, so no extra index is needed.
  • Label enforcement / redaction — mirrors getPackage: profile URI + DID subjects are hydrated, !takedown from accepted redact: true sources turns into NotFound. The labeler binding explicitly sends a blank atproto-accept-labelers header so its own analysis isn't blinded, which matches the privacy rationale.
  • Schema alignment — PublisherRow / publisherColumns() / publisherView() read the same publishers columns the records consumer writes (display_name, description, url, contact, updated_at, signature_metadata, indexed_at). indexed_at was added to publishers by migration 0002_indexed_at.sql.
  • Contact resolution logic — tier 1 (security[]) → tier 2 (authors[] email) → tier 3 (publisher.profile.contact[], preferring kind: security), with url-only entries skipped and whitespace-only emails rejected. Tier 3 is still attempted if the package is missing, which is the correct fallback. Transport failures propagate rather than being masked as “no contact”.
  • Seeding integrity — suppression is checked before ensureContact (insert-if-absent as unconfirmed), so confirmed/declined rows and suppressed addresses are not reset. Plaintext email is only held in memory; the hash is what touches D1 and logs.
  • Tests — the PR adds hand-written unit tests for tier walking, suppression, confirmed-state preservation, and an end-to-end binding test via the vitest stub.
  • AGENTS.md conventions — no admin UI strings, no content-table locale filtering, no new content-table indexes needed; changeset covers the published registry-lexicons package only; aggregator and labeler are private apps.

No blocking or correctness issues identified. A few things I intentionally did not flag: the cid: "" fallback on malformed signature_metadata is the same existing behavior as getPackage/releaseView; the handle field in publisherView is optional and omitted because the publishers table doesn't store it yet; and seedPublisherContact returns seeded: true for an already-confirmed address, which is consistent with the documented contract that the send path then uses canSendConfirm/getContactState to decide whether a confirmation mail is actually needed.

Static review only — I did not run the test suite, linter, or builds.

@ascorbic
ascorbic merged commit 6baeb41 into feat/plugin-registry-labelling-service Jul 16, 2026
11 checks passed
@ascorbic
ascorbic deleted the feat/labeler-contact-resolution branch July 16, 2026 12:43
@github-actions github-actions Bot added review/approved Approved; no new commits since overlap and removed review/needs-review No maintainer or bot review yet labels Jul 16, 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 ascorbic mentioned this pull request Jul 16, 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/approved Approved; no new commits since size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant