Skip to content

Add Sorbet spec adoption guardrails - #16505

Draft
JamieMagee wants to merge 2 commits into
mainfrom
jamiemagee/rspec-sorbet/foundation-policy
Draft

JamieMagee wants to merge 2 commits into
mainfrom
jamiemagee/rspec-sorbet/foundation-policy

Conversation

@JamieMagee

@JamieMagee JamieMagee commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What are you trying to accomplish?

Prevent Sorbet test coverage from regressing while spec trees are enrolled incrementally.

Add a Git-base ratchet that uses the pinned compiler's file table to compare effective spec inclusion and strictness. Report checked, false, and ignored files separately, with untyped usage from the full type check. Run typing checks on stacked PR bases as well as main, and document strict-target migration and reviewed exceptions.

Builds on the experimental RSpec rollout in #16469.

Anything you want to highlight for special attention from reviewers?

The ratchet analyzes a Git snapshot of the immediate PR base, rather than approximating Sorbet's ignore rules or trusting sigils in ignored directories. Existing excluded suites remain excluded. Checked files cannot be downgraded or re-excluded; new included non-strict files and changed/newly enrolled false files need a specific explanation and reference.

The new CLI has 14 integration regressions covering actual Git repositories and compiler inputs, including strictness overrides, stacked bases, missing bases, and spaced paths. Its signature-bearing let declarations have a scoped RSpec/ScatteredLet exception because moving declarations would detach their signatures.

No runtime type-validation handlers or production interfaces change.

The common CI image now explicitly copies the root CLI needed by these integration specs. This fixes the initial CI-only loading failure caused by that image's selected source copies.

How will you know you've accomplished your goal?

Validated inside Docker with the locked root bundle:

  • bundle exec srb tc — passed.
  • bundle exec tapioca gem --verify — passed; gem RBIs are up to date.
  • bundle exec rubocop script/sorbet-spec-ratchet common/spec/sorbet_spec_ratchet_spec.rb --format simple — passed, no offenses.
  • From common: bundle exec rspec -I spec spec/sorbet_spec_ratchet_spec.rb — passed, 14 examples.
  • BASE_REF=main bundle exec ruby script/sorbet-spec-ratchet — passed against the actual checkout.
  • bundle exec srb tc --track-untyped=everywhere --print=file-table-json:tmp/sorbet-file-table.json followed by bundle exec ruby script/sorbet-spec-ratchet --report tmp/sorbet-file-table.json — passed; checked/false/ignored counts distinguish effective coverage.
  • Edited workflow YAML parsing — passed.
  • docker build --quiet --file common/Dockerfile --tag dependabot-rspec-common:652b9b3a . and docker run --rm --init --env CI=true --workdir /home/dependabot/common dependabot-rspec-common:652b9b3a bundle exec rspec -I spec spec/sorbet_spec_ratchet_spec.rb --format progress — passed, all 14 examples in the actual CI image without full-checkout mounts.

At the dependent support layer, both bundle exec rspec -I spec spec --format progress from common and the rebuilt common image's exact ./script/ci-test command passed all 2,354 examples. Other ecosystem suites and the complete monorepo suite were not run locally.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:06
@JamieMagee
JamieMagee added this pull request to stack #16508 October 8, 2026 21:07

Copilot AI 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.

🟢 Approval recommended

The implementation matches the stated guardrails and includes comprehensive integration coverage for its key behaviors.

0 open findings

What changed in this PR

Adds CI guardrails to prevent regressions while incrementally enabling Sorbet checking for Ruby specs.

Changes:

  • Adds a Git-base ratchet for effective spec inclusion and strictness.
  • Reports checked, false, ignored, and untyped usage metrics.
  • Documents migration, exception, and validation requirements.
File Description
sorbet/​config Includes the ratchet in Sorbet checking.
script/​sorbet-spec-ratchet Implements comparison and reporting logic.
common/​spec/​sorbet_spec_ratchet_spec.rb Adds integration coverage for ratchet behavior.
.github/​workflows/​sorbet.yml Reports spec coverage from full type checks.
.github/​workflows/​check-sorbet-typing-mode.yml Enforces the ratchet on pull requests.
README.md Documents spec typing workflows.
.github/​instructions/​testing.instructions.md Adds spec-testing guidance.
.github/​instructions/​code-quality.instructions.md Defines RSpec migration requirements.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:55

Copilot AI 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.

🟡 Changes recommended

Renaming a checked spec into an ignored tree can bypass the new non-regression ratchet.

1 open finding

🧠 Review effort: Balanced

Comment on lines +123 to +124
def self.regressions(paths, base, contents, head)
paths.select { |path| spec_file?(path) }.filter_map do |path|
@emancu emancu mentioned this pull request Oct 9, 2026
5 tasks done

This branch has not been deployed

No deployments
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.

2 participants