# Media Discussions SDK specification and roadmap

Draft · 4 December 2026

The first SDK lets a reader, curator, or independent app parse a canonical media reference, read a public subject, and resolve an external URL under an explicit publisher trust policy. All three work without an account. The initial domain is television series, seasons, and episodes. One album with two editions and one film with two cuts provide compatibility tests before publishing a shared cross-media contract. This document specifies a proposed SDK. The pilot HTTP API, including its docs-only and full-app deployment modes, remains documented separately. [Pilot reference](/docs) · [Agent guide](../agents.md) · [Public Lexicon index](../lexicons)

## First release API

Ship a small TypeScript wrapper over generated Lexicon bindings. Direct PDS and pilot HTTP reads have different provenance and coverage. Each adapter declares what it can verify. The app selects the provider, supplies trust and freshness policy for automatic resolution, and retains control of its source network access. No default AppView, OAuth session, account, relay, background poller, or index is required by the first release. [AT Protocol reading guide](https://atproto.com/guides/reading-data) · [TypeScript Lexicon SDK](https://github.com/bluesky-social/atproto/tree/main/packages/lex/lex)

Illustrative TypeScript. These names and signatures describe the proposed API.

```ts
type SubjectRef = {
  readonly uri: string
  readonly did: string
  readonly collection: string
  readonly rkey: string
}

type CatalogReader = {
  getSubject(ref: SubjectRef, options?: { signal?: AbortSignal }): Promise<SubjectResult>
  resolveUrl(url: string, options?: { signal?: AbortSignal }): Promise<Resolution>
}

declare function parseSubjectUri(input: string):
  | { status: "valid"; ref: SubjectRef }
  | { status: "invalid" }

declare function createCatalogReader(options: {
  provider: CatalogProvider
  mappingPolicy?: MappingPolicy
}): CatalogReader
```

| Operation | Behavior and result |
| --- | --- |
| `parseSubjectUri` | Pure. Use upstream identifier validation plus the media-specific address restrictions below. Return structural validity. Collection support and record existence are checked on read. |
| `getSubject` | Public read. `found` includes the canonical reference, media kind, validated display metadata and parents, publisher DID, CID, and retrieval time. Return a distinct `not-found`, `unsupported`, `invalid-record`, `candidate`, or `unavailable` otherwise. A `candidate` names its source and the verification still needed. |
| `resolveUrl` | Public read. Return `matched` with a verified subject and evidence, `ambiguous` with eligible competing claims, `candidate` with unverified evidence, `unresolved` for unsupported or unmatched input, or `unavailable` when required data cannot be checked. Only `matched` selects a subject. Preserve each assertion's original URL and the caller's input. |

Define `CatalogProvider` around two operations. A subject lookup returns a raw record and provenance, or its absence or availability status. A mapping lookup by normalized source key returns a bounded set of candidate claim records and a coverage status. Each verified record envelope carries the URI, publisher DID established from the repository, CID, observed time, and repository revision when available. An index or service response without record provenance remains a candidate. The adapter reports incomplete coverage or stale evidence explicitly. An unexpected provider error becomes `unavailable` with a typed reason and an optional safe retry hint. Cancellation is caller-controlled and never means missing data.

`MappingPolicy` is an explicit trust predicate over verified publisher DIDs and source keys plus a maximum evidence age. When omitted, a URL lookup can return candidates and unresolved results. A candidate requires verification or a trust decision before it can become a match. The SDK keeps schema and provider data separate from each app's mapping trust decisions and each source's discussion visibility. [Lexicon authority](https://atproto.com/specs/lexicon#authority-and-control) · [Repository and provenance](https://atproto.com/specs/repository) · [Sync and validity](https://atproto.com/specs/sync)

### Canonical reference and mapping behavior

- Public subjects use full `at://<did>/<collection>/<rkey>` record addresses. Reject handle-based or incomplete addresses, query strings, fragments, and Space addresses at this boundary. Preserve rkey case. A caller that accepts handles may use an AT Protocol identity resolver first and persist the resulting DID URI. Match the address collection and record `$type`. Infer neither ownership nor official status from a namespace, handle, or title. Never change the identity of an existing subject when display metadata or numbering changes. [AT URI syntax and usage](https://atproto.com/specs/at-uri-scheme) · [Record keys](https://atproto.com/specs/record-key)
- Validate schema and local invariants at the read boundary. Reject blank display titles, invalid optional calendar dates, and incompatible parent collections. When an episode has a season, fetch the current referenced season and verify it points to the episode's series. Resolve the series too. Cross-catalog parent links can be valid. An unavailable parent makes the hierarchy unavailable as a whole. Keep source numbering and publisher dates as metadata. Unknown optional fields survive any later read-modify-write operation. [Lexicon validation and evolution](https://atproto.com/specs/lexicon#lexicon-evolution) · [Pilot catalog schemas](../lexicons)
- URL normalization is pure and provider-specific. Start with the public pilot's BBC programme and iPlayer, IMDb title, Apple TV episode, and configured episode-page origins. Use supported HTTPS host and resource path patterns with exact host checks. Reject credentials and nondefault ports. Strip only provider-defined irrelevant URL components, keep the source URL verbatim for attribution, and include the origin in an episode-page key. Check that the claim's source, external ID, URL, and collection of the target all agree. Pass input URLs as data to the configured lookup endpoint or to local normalization rules. [Pilot resolver examples](../agents.md) · [HTTP conformance runner](../conformance/run.py)
- Group currently valid trusted claims by canonical subject URI. Agreeing duplicates select one subject and retain each claim. Two distinct eligible subjects yield `ambiguous`. A stale or unverifiable competing claim from a trusted source produces `unavailable` unless verified claims already establish ambiguity. Disclose the configured provider's coverage, and fail closed when the provider cannot answer within it. Store claim identity by record URI, replace it by revision as verified updates arrive, and retain deletions and account-state changes long enough to reject stale replays. Re-evaluate derived URL attachments after edits, deletion, staleness, or trust removal. Explicit subject references and their history retain their original target. [Repository revisions and sync](https://atproto.com/specs/sync) · [Pilot reference](/docs)

### Transport adapters

The first PDS adapter resolves the DID to its current PDS and uses typed public `com.atproto.repo.getRecord` operations. A mapping provider can use a bounded set of configured repositories or an index that supplies verifiable record pointers and freshness. The source record and its publisher remain the evidence. An optional pilot adapter reads `GET /api/episodes/{id}`, `GET /api/resolve?url=…`, and `GET /api/catalog` on an explicitly configured full-app origin. A route slug or manifest key is only a lookup hint. The pilot's `{mapping, episode}` response and candidate manifest alone cannot establish trusted publisher identity, completeness, or absence of a conflict. A demo episode with `uri: null` remains display data. The first SDK adds no XRPC service. If applications later need an interoperable discovery service, define query schemas then and generate the client and server bindings from those documents. [Agent guide](../agents.md) · [Repository record query](https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json) · [XRPC specification](https://atproto.com/specs/xrpc)

Use bounded time, redirects, response bytes, pagination, and fan-out with explicit timeout and cancellation behavior. A configured HTTPS endpoint or DID resolution may still encounter an unsafe network destination. Server adapters must use an SSRF-aware fetch policy for resolution and every redirect and endpoint connection. Browser adapters can use the pilot's CORS API where available and omit credentials. Public reads use no caller OAuth headers or cookies. Emit diagnostic status codes and request timings by default. Private subjects, request URLs, hashes, timestamps, tokens, and raw response bodies stay out of shared telemetry. [AT Protocol OAuth client guidance](https://atproto.com/guides/about-oauth) · [Spaces SDK server fetch guidance](https://github.com/bluesky-social/atproto/tree/main/packages/lex/lex-space#running-on-a-server)

## Binding generation and distribution

Author record contracts once in Lexicon JSON. Use `@atproto/lex` as build tooling. Track upstream schemas in a `lexicons.json` manifest with CIDs and an explicit local resolver for the draft namespace. Keep the reviewed input schemas available for offline reproducible code generation and generate TypeScript with `lex build --lib @atproto/lex-schema`. Use generated schemas for runtime validation and `@atproto/lex-client` for typed calls. Export generated schema definitions for advanced callers. Use `@atproto/lex-space` with those definitions for authorized Space operations after that stage passes. Keep authentication in the host app using the official OAuth client libraries and accept an existing session/agent only in an authorized entry point. [Upstream code generation and manifest conventions](https://github.com/bluesky-social/atproto/blob/main/CONTRIBUTING.md#working-with-lexicons) · [Published-library dependency guidance](https://github.com/bluesky-social/atproto/tree/main/packages/lex/lex) · [Official OAuth SDKs](https://atproto.com/guides/about-oauth)

| Dependency | Reproducible starting point |
| --- | --- |
| Build and public read | Pilot lock versions `@atproto/lex` 0.8.1, `@atproto/lex-client` 0.7.2, and `@atproto/lex-schema` 0.4.0. [Lex manifest](https://github.com/bluesky-social/atproto/blob/main/packages/lex/lex/package.json) · [Client manifest](https://github.com/bluesky-social/atproto/blob/main/packages/lex/lex-client/package.json) · [Schema manifest](https://github.com/bluesky-social/atproto/blob/main/packages/lex/lex-schema/package.json) |
| Optional future authorization | Pilot lock versions `@atproto/lex-space` 0.1.0 and `@atproto/oauth-client-node` 0.5.23. Upstream Node OAuth source reports 0.5.24 and browser OAuth source reports 0.5.21 as of this draft. Treat those as source snapshots. Confirm registry releases and test the selected combination before setting supported dependency ranges. [Space manifest](https://github.com/bluesky-social/atproto/blob/main/packages/lex/lex-space/package.json) · [Node OAuth manifest](https://github.com/bluesky-social/atproto/blob/main/packages/oauth/oauth-client-node/package.json) · [Browser OAuth manifest](https://github.com/bluesky-social/atproto/blob/main/packages/oauth/oauth-client-browser/package.json) |

Start with one MIT-licensed ESM package with TypeScript declarations. The proposal is a root entry point for public helpers and a `./lexicons` entry point for generated schemas. Reserve any authorized helpers for a separately imported entry point with its own runtime dependencies when justified. Initial supported target is Node.js ≥22.13, matching the pilot. Public helpers use platform-neutral primitives so the same package can later support a browser build after a clean-consumer smoke test. Start with a locally packed prerelease artifact. Publish package SemVer independently of the pilot application version. `lexicon: 1` is the wire schema format, and an adopted NSID is an independent compatibility commitment. Package a language-neutral fixture set and exact schema snapshot alongside its documentation. A Go reader using the official Indigo SDK follows the TypeScript reference once an independent implementation can pass the same fixtures. A Python client starts as an HTTP/fixture example using the existing Python conformance runner. Broader language bindings follow independent demand and passing compatibility tests. [AT Protocol TypeScript release guidance](https://atproto.com/blog/ts-sdk-upgrades) · [Go Indigo SDK](https://github.com/bluesky-social/indigo) · [AT Protocol interoperability fixture patterns](https://github.com/bluesky-social/atproto-interop-tests) · [SemVer](https://semver.org/)

## Authorization and later operations

| Operation | Capability and boundary |
| --- | --- |
| Public subject, mapping, and discussion reads | Anonymous reads under the configured provider's coverage and the current source visibility. Discussion discovery is a later stage. |
| Create or change a public catalog record, mapping claim, or reaction | Caller supplies an authenticated session and explicitly invokes a verb for the chosen record and operation. Request only those `repo` collection/action grants. Keep public repository operations in the upstream typed client until wrappers demonstrate a distinct need. |
| Read private watch state | Session belongs to the viewer and has `space:` access limited to that watch Space type, `authority=self`, `skey=self`, and `read_self`. Require an authenticated authority policy check. A deployment where the narrowly scoped client cannot establish the expected policy reports the feature unavailable. |
| Mark or clear private watch state | Explicit user action and `space:` grants for the needed watch collection `create`, `update`, or `delete` operations. Grant `manage=create` only to a flow that can explicitly bootstrap a missing personal watch Space. |
| Move a PDS or publish a Lexicon | Dedicated operator tooling with separate authorization. Core SDK readers and watch helpers need none of the associated account, Space migration, or namespace publication grants. |

Use official OAuth session handling for token refresh and DPoP. Route private watch reads and writes only through `SpaceClient` for the viewer's `com.danhon.atprotomedia.watchspace/self` while testing the existing alpha shape. Inspect the actual Space policy and require `com.atproto.personalspace.policy`. Require the viewer DID as both Space authority and repository owner. Match the full returned Space address, collection, subject, author, and key. Derive the key as lowercase hexadecimal SHA-256 of the canonical episode AT URI encoded as UTF-8. Exclude watch records from public readers and indexes even if an external app mispublishes one. [Official OAuth](https://atproto.com/guides/about-oauth) · [Space scope parameters](https://atproto.com/specs/permission#space) · [Typed Space client and policy manager](https://github.com/bluesky-social/atproto/tree/main/packages/lex/lex-space) · [Pilot watch reference](/docs#watch)

Proposed first watch semantics are `getWatch` returning `marked`, `unmarked`, or `unavailable`, with separate `markWatched` and `clearWatched` verbs. An authenticated `RecordNotFound` in a verified personal Space means `unmarked`. Treat ambiguous `SpaceNotFound`, permission denial, policy mismatch, revocation, unsupported host, and transport failures as unavailable. Supply one `watchedAt` timestamp per mark intent and reuse it for retries of that intent. After a timeout, read back before considering a retry. Treat a conflicting value or an uncertain clear as a conflict or unavailable and require fresh user intent before retrying. The current Space put/delete schemas lack a compare-and-swap field. Document last successful write semantics for concurrent clients, avoid automatic replay that could undo another client's clear, and never promise atomic conditional updates. Preserve existing values and unknown fields until their owner explicitly updates or clears them. [Space read schema](https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/space/getRecord.json) · [Space put schema](https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/space/putRecord.json) · [Space delete schema](https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/space/deleteRecord.json)

## Staged roadmap and release gates

| Stage | Deliverable | Evidence required to advance |
| --- | --- | --- |
| 0. Contract fixtures | Keep the existing alpha NSIDs and fixture URIs readable. Compare TitleGraph `series`, `season`, and `episode` against the two TV pilot fixtures. Define a proposed shared claim with `source`, `externalId`, original `url`, and `subjectUri`. Use fictional album work/standard/deluxe and film work/theatrical/director's-cut fixtures to test distinct subjects. | The existing fixtures can support the read-only SDK while the catalog choice remains open. Before a TitleGraph cutover, resolve its authority schemas, read a current episode plus both parents from a PDS, and round-trip the fixtures through an independent reader. Document special episodes, parent relationships, independently attributable mappings, and an old-URI preservation plan. Use the evidence to choose TitleGraph publication, a read adapter, or the pilot's catalog records. [TitleGraph catalog](https://github.com/titlegraph/standard/tree/main/lexicons/org/titlegraph/catalog) · [MusicBrainz release-group semantics](https://musicbrainz.org/doc/Release_Group) |
| 1. Read-only prerelease | Publish a local package artifact with strict references, typed public catalog reads, an explicit resolution policy, and compatibility fixtures. Use the pilot service as an optional adapter. | Run the docs-only and full-app public conformance profiles. Pass deterministic URI, hierarchy, normalization, provenance, trust, conflict, stale cache, deletion, and network-budget vectors offline. Test clean install of the packed artifact, deterministic generation, and one independent public reader against a published PDS record or fixture deployment. Verify network scope and browser credentials behavior before claiming browser support. [Conformance runner](../conformance/run.py) |
| 2. Discussion interoperability | Link to public discussions with typed source adapters. Test Frontpage first for link-led threads, then atmoBB for a persistent forum. Use Constellation to discover candidate backlinks and Semble to test portable curator selections. Consider a separate public read adapter once these tests prove demand. | A root URL attaches the discussion. A reply-only link attaches only that contribution unless separately curated. An inaccessible root never appears as context. Verify edits, removals, labels, deactivation, and Blacksky-Only restrictions across public lists, counts, previews, search, and metadata. Match the original source when displaying or following a link. Record source coverage and moderation behavior. A network candidate is not a public attachment until the source and curator policy allow it. [Frontpage](https://github.com/frontpagefyi/frontpage) · [atmoBB](https://github.com/keithk/atmoBB) · [Constellation](https://constellation.microcosm.blue/) · [Semble](https://github.com/cosmik-network/semble) · [Blacksky-Only posts](https://docs.blacksky.community/using-blacksky/posts-and-feed/blacksky-only-posts) |
| 3. Authorized watch experiment | Add the private Space operations behind a distinct import only after local fault-injection checks. Continue using the official repo client for any approved public posting. | Use approved test accounts on Bluesky-hosted and Blacksky-hosted PDSes. Two authorized clients independently reproduce the key and read, mark, and clear the same record. Test denied or revoked scope, wrong policy and author, host incompatibility, lost responses, interleaved writes, and guest absence. After an independently authorized migration and reauthorization, confirm both Space policy and data remain intact and the existing episode reference still resolves. [Spaces public beta](https://atproto.com/blog/the-spaces-public-beta-is-now-live) · [Migrating accounts](https://atproto.com/guides/account-migration) |
| 4. Public contract and additional languages | Publish only the stages whose evidence is recorded. Retain a small stable read API even if the write stage remains experimental. Add independent Go conformance before advertising multi-language support. Decide on any future shared mapping or discussion namespace with another implementer. | Apply the gates below to each proposed package release or namespace change. [Lexicon publication](https://atproto.com/guides/publishing-lexicons) · [Lexicon Community](https://lexicon.community/) · [AT Protocol interoperability tests](https://github.com/bluesky-social/atproto-interop-tests) |

### Conformance requirements

Ship fixtures as data with expected outcomes, coverage and provenance recorded, and a fixed clock. Minimum cases include handle alias or transfer, case-sensitive rkeys, wrong or unresolved parents, an edited episode whose references remain stable, BBC/IMDb/Apple aliases and hostile URL variants, duplicate and contested claims, stale/replayed deletions, and external IDs colliding across work and edition levels. Exercise valid and invalid third-party values, including Unicode grapheme limits and malformed dates, with both runtime and generated validators. Add scripted transport fixtures for denied, stale, unavailable, canceled, partial, and conflicting outcomes. Unknown optional fields must survive a write round trip by an older client. Run public HTTP smoke checks without test accounts and authorized write checks only with test accounts and separate approval. [Public conformance runner](../conformance/run.py) · [AT Protocol interop fixtures](https://github.com/bluesky-social/atproto-interop-tests)

Before any public package release, require a clean package consumer, repeatable schema generation, versioned compatibility notes, invalid-record handling, bounded public network access, and an independent public read. Before network publication of a Media Discussions Lexicon, audit existing schema resolution, on-network records, and third-party adoption. Preserve adopted NSIDs and persistent AT URIs. Give incompatible shape, meaning, or key changes a new NSID and test dual-read behavior without rewriting others' records. Before making any write path a supported API, require explicit scoped authorization, successful independent-client interoperability, privacy and concurrency evidence for its storage boundary, and deployable rollback or disable behavior. Publish the evidence and supported capabilities with the release. [Lexicon evolution](https://atproto.com/specs/lexicon#lexicon-evolution) · [Spaces access controls](https://atproto.com/guides/spaces) · [Pilot agent guide](../agents.md)
