Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexicon resolution #792

Merged
merged 13 commits into from
Jan 17, 2025
Merged

Lexicon resolution #792

merged 13 commits into from
Jan 17, 2025

Conversation

bnewbold
Copy link
Collaborator

@bnewbold bnewbold commented Nov 6, 2024

Adds a ResolveNSID method to identity.BaseDirectory. I think keeping DNS TXT resolution stuff together in the same package makes sense, even if this is a "lexicon" thing, not really an "identity" thing. Could consider renaming that method to ResolveLexiconNSID or similar, to clarify it is about NSIDs in the context of Lexicons, not "NSIDs in general" (though they are currently only defined in terms of Lexicons).

Adds a new ResolvingCatalog implementation of the lexicon.Catalog interface, which does resolution from the live network and adds to a local cache. Also lexicon.ResolveLexiconData low-level helper which goes from NSID to Lexicon record data.

@bnewbold bnewbold marked this pull request as draft November 7, 2024 21:34
@bnewbold bnewbold marked this pull request as ready for review December 24, 2024 00:44
@bnewbold bnewbold changed the title experimental lexicon resolution Lexicon resolution Dec 24, 2024
@bnewbold
Copy link
Collaborator Author

bnewbold commented Jan 7, 2025

This is ready for review/merge

@bnewbold bnewbold requested review from ericvolp12 and dholms January 7, 2025 07:11
ErrNSIDNotFound = fmt.Errorf("NSID not associated with a DID")
)

// Resolves an NSID to a DID, as used for Lexicon resolution (using "_lexicon" DNS TXT record)
Copy link
Contributor

Choose a reason for hiding this comment

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

no option for https://*/.well-known/atproto-lexicon ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope. we discussed/debated and decided against. I think there is some discussion in: bluesky-social/atproto#3074

return nil
}
slog.Debug("loading Lexicon schema file", "path", p)
f, err := os.Open(p)
Copy link
Contributor

Choose a reason for hiding this comment

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

os.Open() won't work for the LoadEmbedFS() case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, i'll add a test to cover that use-case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

think I got this fixed. thanks for the catch!

Comment on lines +22 to +26
baseDir := identity.BaseDirectory{}
did, err := baseDir.ResolveNSID(ctx, nsid)
if err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we use the BaseDirectory here and not the identity directory? I guess to avoid adding ResolveNSID as a required method on the directory interface for now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mind I see we suggest you use ResolvingCatalog anyhow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, basically putting that method on BaseDirectory to start. would probably make sense to add to caching and other implementations, and thus the interface, but doing baby steps.

Comment on lines +22 to +26
Directory: identity.DefaultDirectory(),
}
}

func (rc *ResolvingCatalog) Resolve(ref string) (*Schema, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this string be anything? Should it be a URL or something and should we validate that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is a "Lexicon reference", which is an NSID optionally followed by name-fragment. I'm planning to add a syntax parser for that identifier, but still hashing out the specification of the syntax (what we have written on atproto.com is probably too restrictive).

@bnewbold bnewbold merged commit ea9b321 into main Jan 17, 2025
8 checks passed
@bnewbold bnewbold deleted the bnewbold/lex-res branch January 17, 2025 20:27
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.

3 participants