Schemata for nostr devs

Automating nostrability
Schemata for nostr devs

TLDR

Nostrability is no longer a manual issue tracker, although that still exists, and now has a web UI.

There are now multiple dev solutions across dozens of languages that prevent broken interop in schemata, schemata-codegen, and sherlock.

From issues to schemata

Nostrability started out as a manual issue tracker in January 2024. The initial objective was to track broken stuff that are not limited to a single app.

This was and is needed as nostr apps have the unique property of potentially affecting other nostr apps with bugs.

Later nostrability added positive trackers - i.e. which apps (claim to) support which thing/NIP/kind (e.g. calendar events positive interop tracker).

image Nostrability interactive web UI is here.

While there was success manually tracking, and sometimes resolving things, the manual approach is a slog, and is tough to scale.

The vision was to work towards automation. Thanks to agents, nostrability has taken a few successful steps in this direction.

Nostrability took on schemata, an approach piloted by sandwich in a step towards automating interopability checks, and preventing broken stuff being shipped by nostr apps.

Schemata utilizes industry json-schema approach, which maps well to nostr’s string-y tuple-y specifications in kinds. Paired with a validator, the schemata approach can be applied to a dev’s CI pipeline. The idea is that by fully validating JSON blobs against the respective kind (example schema.yaml for kind-10002 relay list) schemata definition, broken stuff is caught in CI before code is shipped to production, preventing nostr apps from sending misformed blobs to live relays.

The schemata approach is applied today in nostr.watch, synvya, and nostria.

What’s the today coverage of nostr kinds, NIPs etc?

Today schemata carries 179 event kind schemas across 65 NIPs, 154 tag schemas, 13 protocol messages, and 310 sample events (228 valid, 82 invalid).

Is schemata only javascript?

No!

While the canonical scehmata definition is in JS, schemata has been extended to a dozen other languages in:

  1. schemata-rs & schemata-rs-validator
  2. schemata-go & schemata-go-validator
  3. schemata-py & schemata-py-validator
  4. schemata-kt & schemata-kt-validator
  5. schemata-java & schemata-java-validator
  6. schemata-swift-validator (schemas & validator bundled together due to swift language idiocyncracies)
  7. schemata-dart & schemata-validator-dart
  8. schemata-php & schemata-validator-php
  9. schemata-csharp & schemata-validator-csharp
  10. schemata-cpp & schemata-validator-cpp
  11. schemata-ruby & schemata-validator-ruby
  12. schemata-c & schemata-validator-c (and a custom extended for nostr devs/nostrability jsonc-daccord schema library)

Using some super basement nerd language that is not covered by the above schemas and validators? Create an issue in nostrability/schemata github asking for additonal language support.

Can schemata be applied outside CI?

Some nostr devs have expressed feedback and interest that the schemata JSON validator approach may not be suited to their setup.

I have created a nostr specific code generator that eliminates the need for JSON validation. I didn’t just custom build this for custom building sake - all existing code generator’s failed on nostr’s / schemata’s schemas due to the specific tag tuple structure.

Schemata-codegen allows you to just validate stuff in production in your app’s native language, and lists specifically where a failure occurs in build/compile. Schemata-codegen also supports IDE autocomplete, and can be applied in runtime.

Sherlock

Sherlock automates the tracking of broken stuff across nostr, by periodically digesting events live on relays, and assessing their broken-ness against the schemata definitions. The Sherlock dashboard today shows about 10%-15% broken events on nostr. Please note I have not validated this yet, and that there are very possibly false positives (i.e. stuff that is marked as invalid that shouldn’t be there).

image

Many nostr apps are attributed via nip-89 client tags, and many events are currently unattributed. More on Sherlock’s deductions to follow.

Nostr devs needs

Nostrability exists to serve nostr devs. Write me, or create issues in nostrability repos if you have a nostr dev problem that nostrability might help with.

Thank you

By applying the other stuff above to your app, you are helping work towards nostr interop at scale.

Appreciate all the builders on nostr, and the support shown since January 2024 to nostrability.


No comments yet.