Skip to content

refactor(typeshed): deserialize FunctionSig directly, delete three mirrors - #143

Merged
sims1253 merged 9 commits into
mainfrom
refactor/typeshed-sig-consolidation
Sep 1, 2026
Merged

sims1253 merged 9 commits into
mainfrom
refactor/typeshed-sig-consolidation

Conversation

@sims1253

Copy link
Copy Markdown
Owner

Summary

FunctionSig now deserializes itself. A #[serde(rename = "return")] on return_ 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

  • FunctionSig gained #[serde(rename = "return")] and #[serde(deny_unknown_fields)]. It is now the only signature shape.
  • Deleted the _fwd module and its _FunctionSig mirror.
  • RawS3Method shrank to generic, class, and a flattened FunctionSig. Its deny_unknown_fields stays load-bearing: under flatten, serde ignores that attribute on the flattened struct, so the outer attribute is what rejects an unknown field.
  • Deleted both field-by-field transcription blocks in parse_typeshed_with_order. Insertion is direct. Function order handling is unchanged.
  • JsonLength's literal whitelist moved to a documented JsonLength::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.
  • New tests: unknown fields rejected on signatures and on S3 entries, S3 dispatch keys split from the signature, and every base signature round-trips through JSON with the return key.

Public API is unchanged. FunctionSig, its fields, and its methods keep their names and visibility. ry-checker, ry-cli, and ry-lsp compile 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 base and 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-typeshed
  • cargo clippy -p ry-typeshed --all-targets -- -D warnings
  • cargo 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

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 14 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 99e2a1d5-f81b-4bd8-9c40-9b24c5e8c76e

📥 Commits

Reviewing files that changed from the base of the PR and between 196850f and c6e6ffd.

📒 Files selected for processing (1)
  • crates/ry-typeshed/src/lib.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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.

  • FunctionSig deserializes itself: #[serde(rename = "return")] and #[serde(deny_unknown_fields)] on the struct replace the _fwd::_FunctionSig mirror, the duplicated 17-field RawS3Method body, and both transcription loops in parse_typeshed_with_order — insertion is now direct, and the shape exists once.
  • RawS3Method flattened to generic/class + FunctionSig: the doc comment's load-bearing claim is accurate. Verified by mutation under the pinned serde (1.0.228): removing the outer deny_unknown_fields makes an unknown S3 field silently absorbed (serde ignores that attribute on the flattened struct), while removing FunctionSig's own attribute breaks only direct-signature rejection — each attribute is required on its own path, exactly as documented.
  • JsonLength::KNOWN hoisted 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 serializes FunctionSig/Typeshed outside the new test — so it is a latent round-trippability improvement, not a format break.

Pullfrog  | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253
sims1253 deleted the branch main August 31, 2026 21:00
@sims1253 sims1253 closed this Aug 31, 2026
@sims1253 sims1253 reopened this Aug 31, 2026
@sims1253
sims1253 changed the base branch from cleanup/small-crates-dead-code to main August 31, 2026 21:25
@sims1253
sims1253 merged commit 4bb6fb9 into main Sep 1, 2026
16 checks passed
@sims1253
sims1253 deleted the refactor/typeshed-sig-consolidation branch September 1, 2026 15:17
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.

1 participant