Repository navigation
refactor(typeshed): deserialize FunctionSig directly, delete three mirrors - #143
Conversation
|
Warning Review limit reachedNext included review available in 14 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the single-file refactor in crates/ry-typeshed/src/lib.rs (head 7fa764a), reproducing the description's verification locally: 30/30 ry-typeshed lib tests, 460/460 ry-checker lib tests, cargo check --workspace --all-targets, cargo fmt --check, cargo clippy -D warnings, plus mutation experiments on the flatten/deny_unknown_fields interaction.
FunctionSigdeserializes itself:#[serde(rename = "return")]and#[serde(deny_unknown_fields)]on the struct replace the_fwd::_FunctionSigmirror, the duplicated 17-fieldRawS3Methodbody, and both transcription loops inparse_typeshed_with_order— insertion is now direct, and the shape exists once.RawS3Methodflattened togeneric/class+FunctionSig: the doc comment's load-bearing claim is accurate. Verified by mutation under the pinned serde (1.0.228): removing the outerdeny_unknown_fieldsmakes an unknown S3 field silently absorbed (serde ignores that attribute on the flattened struct), while removingFunctionSig's own attribute breaks only direct-signature rejection — each attribute is required on its own path, exactly as documented.JsonLength::KNOWNhoisted to a documented associated const, backed by a new drift test that re-derives the literal set from the vendored stub data (base+ all package specs) and fails on mismatch.- New tests are real coverage, not theatre: the S3 and signature unknown-field rejection tests fail under the mutations above, and the round-trip test pins
"return"across all 2256 base signatures. - Serialized-key change (
return_→return) has no production consumer — nothing serializesFunctionSig/Typeshedoutside the new test — so it is a latent round-trippability improvement, not a format break.
openai-compatible/glm-5.3 | 𝕏
…-consolidation # Conflicts: # CHANGELOG.md

Summary
FunctionSignow deserializes itself. A#[serde(rename = "return")]onreturn_replaces the forward struct the reserved word was blamed for.The 17-field shape was written out four times. Adding a field meant four edits and a transcription step that could drop one. Now it is one edit.
Stacked on #139. Merge after it.
Changes
FunctionSiggained#[serde(rename = "return")]and#[serde(deny_unknown_fields)]. It is now the only signature shape._fwdmodule and its_FunctionSigmirror.RawS3Methodshrank togeneric,class, and a flattenedFunctionSig. Itsdeny_unknown_fieldsstays load-bearing: underflatten, serde ignores that attribute on the flattened struct, so the outer attribute is what rejects an unknown field.parse_typeshed_with_order. Insertion is direct. Function order handling is unchanged.JsonLength's literal whitelist moved to a documentedJsonLength::KNOWN. It mirrors the distinct numeric lengths in the vendored stubs, so a new length is a deliberate vocabulary change, not a silent parse failure. A test derives the set from the embedded data and fails on drift.returnkey.Public API is unchanged.
FunctionSig, its fields, and its methods keep their names and visibility.ry-checker,ry-cli, andry-lspcompile without edits.Verification
Parse equivalence was proven field by field against the vendored data, the input contract. A throwaway harness dumped every parsed value from
baseand all 31 packages before the change and after it: schema version, package, version, function order, globals, datasets, all 1463 function signatures, all 793 S3 signatures. The two dumps are byte-identical, 1199297 bytes each. The harness was deleted after the run.cargo fmt -p ry-typeshedcargo clippy -p ry-typeshed --all-targets -- -D warningscargo test -p ry-typeshed(30 passed)cargo test -p ry-checker(595 passed, 0 failed; includes oracle, semantic_lists, vendor_snapshot)cargo check -p ry-cli -p ry-lsp