atproto-lexgen does not understand "type": "space" Lexicon definitions #92
Labels
No labels
breaking-change
bug
documentation
duplicate
enhancement
good first issue
help wanted
performance
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Grandiras/ATProto.NET#92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A space type declaration is a Lexicon document whose
maindefinition has"type": "space"(seedocs/spaces.mdand #89). The generator does not know about it in either direction.JSON → C#.
CSharpEmitter.EmitDefs(tools/ATProtoNet.LexiconGenerator/CodeGen/CSharpEmitter.cs:97) switches ondef.Typeoverrecord/object/string/token/ …, andEmitPlan(CodeGen/EmitPlan.cs:116) does the same when collecting union sites. Neither has aspacecase, so a space-type Lexicon is silently skipped — it emits nothing and reports no error, which reads as "nothing to generate" rather than "this input is not supported".C# → JSON.
LexiconEmitter(CodeGen/LexiconEmitter.cs:140) hard-codesType = "record", so there is no way to declare a space type from C# at all.Diffing.
LexiconDiffer(CodeGen/LexiconDiffer.cs:120) special-casesrecordfor schema comparison. A space declaration'scollectionslist is the interesting thing to diff — adding a collection widens every barespace:grant of that type, since the default collection set is resolved at grant-evaluation time rather than frozen at consent, so it is exactly the kind of change a diff should call out.Suggested shape: emit a space declaration as a
SpaceTypeDeclarationconstant or a small partial class exposingKey,Name,LocalizedNames, andCollections— the model already exists inATProtoNet.Spaces. At minimum, the generator should fail loudly on an unsupportedmaindefinition type instead of producing an empty file.Filed by Claude while working on #89 (run).
🤖 On it — follow along in the action run; the reply will link the full session transcript.
📜 Live transcript — updating every ~5 minutes while the task runs.
Pushed
claude/issue-92. Here's what I did.atproto-lexgennow understands"type": "space"— in all three directionsJSON → C#.
CSharpEmittergained aspacecase. A space type is not a record — nothing is serialized against it — so it emits a static holder around the SDK'sSpaceTypeDeclarationrather than a class:key,name, andcollectionsarerequiredon that model, so a declaration missing one still emits code that compiles ("any", the raw NSID, an empty set) and aWARNnames the field substituted for.DefToClassNamegained aspacesuffix so the holder can't collide with a same-named object def.C# → JSON.
LexiconEmitterhard-codedType = "record". It now also scans for any public staticSpaceTypeDeclarationand takes the NSID from a siblingNsid(orSpaceType) constant — exactly the shape thecsharpcommand emits, so a declaration round-trips. It gained aWarningslist (surfaced asWARNby the CLI) for a declaration with no NSID to attribute it to, and for two types claiming the same definition, which previously clobbered silently.Diffing.
LexiconDiffercompares the declaration, with the collection list treated as the load-bearing part, per the reasoning in the issue:Key changes are breaking; name and localizations are not. Four new
ChangeKindvalues.Failing loudly. An unrecognized definition type is now a
WARNnaming the NSID and the type instead of an empty file. I scoped this to types outside the Lexicon vocabulary —query/procedure/subscriptionand the scalar defs stay silent, since those are legitimate input that deliberately emits no standalone C#, and warning on them would bury real diagnostics under hundreds of lines against any real schema set.EmitPlan's union-site switch needs nospacecase (a declaration's fields are scalars and NSID lists, so it hosts no union sites) — I left a comment there saying so, since the omission otherwise reads as the bug it was next to.Verification
src/ATProtoNetwithTreatWarningsAsErrors=true, built it clean, and ran it —ForumSpace.Declaration.GetName("es")→Foro AtmoBoards,AtProtoScopes.Space(ForumSpace.Nsid)→space:com.atmoboards.forum.atproto-lexgen lexiconreproduced the input document,name:langand all.docs/lexicon-codegen.md, the diff and type tables updated, a pointer fromdocs/spaces.md, CLI help text, and aCHANGELOG.mdentry under[Unreleased] / Added.No follow-up issues to file.
⏱ 12m 37s · 91 turns · tokens: 164.9k in / 52.4k out (+10536.2k cache-read)
📜 Full session transcript
→ Opened PR: #96