Skip to content

Prepare community lexicon records from a listing, without publishing - #65

Open
dame-is wants to merge 1 commit into
ATProtocol-Community:mainfrom
dame-is:claude/atstore-lexicon-migration-sbf9lo
Open

dame-is wants to merge 1 commit into
ATProtocol-Community:mainfrom
dame-is:claude/atstore-lexicon-migration-sbf9lo

Conversation

@dame-is

@dame-is dame-is commented Nov 14, 2026

Copy link
Copy Markdown

Work prompted from rainshare.dev

Part of #7. This adds the first piece of the move to the community.lexicon.app schemas: a read-only conversion from a fyi.atstore.listing.detail record to community.lexicon.app.entry or community.lexicon.app.profile. Nothing calls it yet. It doesn't publish, and it doesn't touch the database, Tap, login or the UI.

This came from Rainshare: https://rainshare.dev/seed/byarielm.fyi/3n2cbhm3kqp2m. An AI agent (Claude Code) did the work for Dame and wrote this description, so "I" below is the agent.

What it does

convertListingToCommunityApp(listing, format, { imageAlt }) in src/lib/atproto/community-app-record.ts takes a listing and a format ("app.entry" or "app.profile") and returns one of:

  • { ok: true, record, unmapped } when the listing fits the community schema as it stands
  • { ok: false, problems, unmapped } when it doesn't, with every blocking problem found

Each problem has a stable code, a sourcePath, a targetPath and a message. Length, count and size problems also carry actual and allowed:

{
  "code": "too_many_graphemes",
  "sourcePath": "description",
  "targetPath": "longDescription",
  "message": "The description has 4001 characters; the limit is 4000.",
  "actual": 4001,
  "allowed": 4000
}

The codes are missing_required_field, missing_image_alt, too_many_graphemes, too_many_bytes, too_many_items, image_too_large, invalid_image, invalid_uri, invalid_did and invalid_datetime.

Listing Community record
name name
tagline description
description longDescription
externalUrl links[0], with the website role
links the rest of links, with type mapped to a role where one exists
icon, heroImage, screenshots images, in that order, with the icon, hero and screenshot purposes
appTags tags
productAccountDid profileDid (entry only)
createdAt, updatedAt createdAt, updatedAt

unmapped lists what has no place in the community record and stays on the listing: slug, categorySlug, migratedFromAtUri, game, link types with no community role (blog, community, donate, license), and productAccountDid when the format is a profile. None of it blocks conversion.

The two formats differ in one field the conversion writes. An entry carries profileDid. A profile is published from the app's own account, so it has no such field. Entries also have langs in the schema, which a listing has nothing to fill.

Text is never trimmed or truncated. The listing is not modified, and the record shares no objects with it.

Judgment calls

These are the places where the request left room, so they are the ones to check.

  • Alt text comes from the caller. The community schema requires alt on every image and a listing stores none, so without alt text every listing is blocked by missing_image_alt, starting with its icon. The function takes alt text as imageAlt and never makes any up. If you would rather add alt fields to fyi.atstore.listing.detail and read them from the record, that is a small change here.
  • A blank name or blank alt text counts as missing. The schema accepts an empty string for both.
  • The — tagline is not copied. listing-record.ts and Tap ingest write — when a listing has no tagline. The conversion leaves description out in that case and says so in unmapped.
  • contact links get the support role. The schema describes that role as "Support, help, or contact page."
  • Image blobs are written in JSON form ($type, ref.$link, mimeType, size). A legacy blob has no size to check against the 2,000,000-byte limit, so it is reported as invalid_image.
  • The limits are constants in the module, read from the schemas at commit 47d55d9 (6 October 2026) of tangled.org/lexicon.community/lexicons. I didn't copy the schema files into lexicons/, because that folder is what pnpm atproto:publish-lexicons publishes.

I haven't looked at live listings, which is out of scope here. From the schemas alone, the limits that tighten most are the long description (20,000 bytes on a listing, 4,000 characters in the community record), hero images and screenshots (12 MB down to 2 MB) and tags (64 down to 10).

How I checked it

  • pnpm run format:check, lint, typecheck, test and build all pass locally. The suite is 212 tests, 65 of them new.
  • The new tests cover both formats, each mapped field, every limit at its value and one past it (characters and bytes separately), all problems returned together, unmapped information not blocking, and the listing left untouched. The fixture is frozen all the way down, so a write to it would throw.
  • I broke the conversion 15 ways (limits off by one, two fields swapped, shared objects, a write to the input, stopping at the first problem) and the tests failed each time.
  • Outside this PR, I ran the converter's output through @atproto/lexicon 0.6.2 loaded with the schema files from tangled. Records at each limit passed and records one past each limit failed, for both formats. That validator doesn't enforce blob size or type, so the 2,000,000-byte and image/* checks rest on my reading of defs.json.

What's left for #7

  • An audit of live listings using this conversion
  • A comparison with community records that already exist
  • A way for owners to add alt text and fix blocked listings
  • Publishing, which includes re-uploading image blobs when a profile is published from a different repo than the listing
  • Reviews, which the issue expects to follow profiles

🤖 Generated with Claude Code

https://claude.ai/code/session_017yeQBcxFaoaDjfVwZ1vgvi

Adds convertListingToCommunityApp, a read-only conversion from a
fyi.atstore.listing.detail record to community.lexicon.app.entry or
community.lexicon.app.profile. It returns the proposed record when the
listing fits the community schema. Otherwise it returns every blocking
problem at once, each with a stable code, source and target paths, a
message, and actual and allowed lengths where they apply.

Information with no community equivalent (slug, categories, the earlier
record and game links, link types without a community role) is listed
without blocking. Image alt text comes from the caller, since a listing
holds none and the community schema requires it.

Nothing calls this yet. Limits come from the schemas at
tangled.org/lexicon.community/lexicons, commit 47d55d9.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017yeQBcxFaoaDjfVwZ1vgvi

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants