Skip to content

Comments

Proposal: Lexicon schema resolution lexicon#48

Draft
tom-sherman wants to merge 2 commits intolexicon-community:mainfrom
tom-sherman:package-manager-lexicon
Draft

Proposal: Lexicon schema resolution lexicon#48
tom-sherman wants to merge 2 commits intolexicon-community:mainfrom
tom-sherman:package-manager-lexicon

Conversation

@tom-sherman
Copy link
Member

@tom-sherman tom-sherman commented Mar 9, 2025

This lexicon is based off of the discussion in https://github.com/orgs/lexicon-community/discussions/42 and my experience with building lpm.

This lexicon (just a single procedure right now) defines an interface for an appview that would be used in lpm to form a package manager for lexicons. The goal is for it to be generic though so it could drive other package managers, registries, or schema-related tooling. (This also justifies me adding it to community.lexicon and not some lpm NSID 😅)

The AppView fills the problem space described in the lexicon resolution RFC:

For services which do dynamic resolution and validation, we think that making requests to aggregation/index services could be a better option instead of doing live resolution. Such services can act as CDNs, archives, and mediating services to resolve disputes or security issues in Lexicons.

License and Assignment

  • I assign all rights of this contribution to Lexicon Community as an open source contribution under the MIT license.

"properties": {
"refs": {
"type": "array",
"description": "List of schema refs (AT-URI with optional CID) to return hydrated views for.",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to encode this type of "at uri with optional cid" as a shared type as I think it's probably valuable in many use cases. Naming is hard tho, community.lexicon.meta.optionallyStrongRef? lol

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weakRef?

Copy link
Member Author

@tom-sherman tom-sherman Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be strong tho if the CID is included! Sometimes it's weak, sometimes it's strong

"cid": { "type": "string", "format": "cid" },
"record": { "type": "unknown" },
"indexedAt": { "type": "string", "format": "datetime" },
"dependencies": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency strong refs are returned so that a package manager could resolve a point-in-time snapshot of the lexicon tree. Discussion about that here.

The actual CID that the appview returns would be implementation specific and so could either return the CIDs at the time the parent was indexed, the latest CIDs regardless of parent CID that was requested, or something else.

"id": "community.lexicon.schema.getSchemas",
"defs": {
"main": {
"type": "procedure",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a query + parameters since it would be a non-modifying GET operation?

Screenshot 2025-03-09 at 6 05 51 PM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to leave a comment about this. It's not really possible to express the input as parameters without inventing some new string format that's like at://identity/nsid/rkey#cid or something.

I'd prefer not to do that invention here (it should be an atproto core spec) but also stuffing those kinds of strings into the query string would reduce the amount of lexicons this endpoint could return I think (because of URL length limits of many systems and tooling).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there needs to be any inventing here. Lexicon retrieval is more or less a getRecord which includes all 4 fields in the parameters

https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/getRecord.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint returns multiple lexicons, not a single one. It's closer in spirit to app.bsky.feed.getPosts than it is to getRecord.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's literally no way to encode a "list of at URIs with optional CIDs" without inventing a new string format.

@verdverm
Copy link

verdverm commented Mar 9, 2025

It can be helpful to note direct vs indirect dependencies.

I also wonder about what "modules" mean in ATProto, maybe beyond the scope here...? As things work today, each lexicon is an independent module, however we typically think of modules as a collection of related types versioned together. (Using "module" like Go (as a collection of packages), where as JS/TS use "package" for the same conceptual grouping)

@tom-sherman tom-sherman changed the title Proposal: Lexicon schema lexicon Proposal: Lexicon schema resolution lexicon Mar 9, 2025
@tom-sherman
Copy link
Member Author

It can be helpful to note direct vs indirect dependencies.

Clarified that, hopefully!

Not sure what you mean about modules, I'm not looking to add a new concept with this schema. It's really just a thin layer on top of the protocol (with caching and backlinks from an identity in the form of listLexicons)

@verdverm
Copy link

verdverm commented Mar 9, 2025

my comment about "modules" may be beyond the scope here. To clarify a bit, consider the situation where someone updates the record lexicon and the query lexicon associated with it. This is a single logical change, which we cannot group logically. It's like if today, every type and function in a TypeScript package was an independent dependency in the npm world.

w.r.t. this work, how do we know that related lexicon are aligned in the dependency list? Is that something that is not being worried about at this point?

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