rigortype 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -20
  3. data/data/core_overlay/numeric.rbs +33 -0
  4. data/data/core_overlay/pathname.rbs +25 -0
  5. data/data/core_overlay/string_scanner.rbs +28 -0
  6. data/data/gem_overlay/activesupport/core_ext.rbs +473 -0
  7. data/data/vendored_gem_sigs/ast/ast.rbs +130 -0
  8. data/data/vendored_gem_sigs/bcrypt/bcrypt.rbs +47 -0
  9. data/data/vendored_gem_sigs/bundler/bundler.rbs +238 -0
  10. data/data/vendored_gem_sigs/cgi/cgi_extras.rbs +34 -0
  11. data/data/vendored_gem_sigs/did_you_mean/did_you_mean_extras.rbs +34 -0
  12. data/data/vendored_gem_sigs/idn-ruby/idn.rbs +54 -0
  13. data/data/vendored_gem_sigs/mysql2/client.rbs +55 -0
  14. data/data/vendored_gem_sigs/mysql2/error.rbs +5 -0
  15. data/data/vendored_gem_sigs/mysql2/result.rbs +31 -0
  16. data/data/vendored_gem_sigs/mysql2/statement.rbs +5 -0
  17. data/data/vendored_gem_sigs/nokogiri/nokogiri.rbs +2332 -0
  18. data/data/vendored_gem_sigs/nokogiri/nokogiri_html5.rbs +47 -0
  19. data/data/vendored_gem_sigs/pg/pg.rbs +212 -0
  20. data/data/vendored_gem_sigs/prism/prism_supplement.rbs +44 -0
  21. data/data/vendored_gem_sigs/redis/errors.rbs +50 -0
  22. data/data/vendored_gem_sigs/redis/future.rbs +5 -0
  23. data/data/vendored_gem_sigs/redis/redis.rbs +348 -0
  24. data/data/vendored_gem_sigs/redis/redis_extras.rbs +130 -0
  25. data/data/vendored_gem_sigs/rubygems/rubygems_extras.rbs +226 -0
  26. data/docs/handbook/01-getting-started.md +311 -0
  27. data/docs/handbook/02-everyday-types.md +337 -0
  28. data/docs/handbook/03-narrowing.md +359 -0
  29. data/docs/handbook/04-tuples-and-shapes.md +321 -0
  30. data/docs/handbook/05-methods-and-blocks.md +339 -0
  31. data/docs/handbook/06-classes.md +305 -0
  32. data/docs/handbook/07-rbs-and-extended.md +427 -0
  33. data/docs/handbook/08-understanding-errors.md +373 -0
  34. data/docs/handbook/09-plugins.md +241 -0
  35. data/docs/handbook/10-sorbet.md +347 -0
  36. data/docs/handbook/11-sig-gen.md +312 -0
  37. data/docs/handbook/12-lightweight-hkt.md +333 -0
  38. data/docs/handbook/README.md +275 -0
  39. data/docs/handbook/appendix-elixir.md +370 -0
  40. data/docs/handbook/appendix-go.md +399 -0
  41. data/docs/handbook/appendix-java-csharp.md +470 -0
  42. data/docs/handbook/appendix-liskov.md +580 -0
  43. data/docs/handbook/appendix-mypy.md +370 -0
  44. data/docs/handbook/appendix-phpstan.md +338 -0
  45. data/docs/handbook/appendix-protocols-and-structural-typing.md +292 -0
  46. data/docs/handbook/appendix-rust.md +446 -0
  47. data/docs/handbook/appendix-steep.md +336 -0
  48. data/docs/handbook/appendix-type-theory.md +1662 -0
  49. data/docs/handbook/appendix-typeprof.md +416 -0
  50. data/docs/handbook/appendix-typescript.md +332 -0
  51. data/docs/install.md +189 -0
  52. data/docs/llms.txt +72 -0
  53. data/docs/manual/01-installation.md +342 -0
  54. data/docs/manual/02-cli-reference.md +557 -0
  55. data/docs/manual/03-configuration.md +152 -0
  56. data/docs/manual/04-diagnostics.md +206 -0
  57. data/docs/manual/05-inspecting-types.md +109 -0
  58. data/docs/manual/06-baseline.md +104 -0
  59. data/docs/manual/07-plugins.md +92 -0
  60. data/docs/manual/08-skills.md +143 -0
  61. data/docs/manual/09-editor-integration.md +245 -0
  62. data/docs/manual/10-mcp-server.md +532 -0
  63. data/docs/manual/11-ci.md +274 -0
  64. data/docs/manual/12-caching.md +116 -0
  65. data/docs/manual/13-troubleshooting.md +120 -0
  66. data/docs/manual/14-rails-quickstart.md +332 -0
  67. data/docs/manual/15-type-protection-coverage.md +204 -0
  68. data/docs/manual/16-rbs-extended-annotations.md +190 -0
  69. data/docs/manual/17-driving-improvement.md +160 -0
  70. data/docs/manual/README.md +87 -0
  71. data/docs/manual/ci-templates/README.md +58 -0
  72. data/docs/manual/plugins/README.md +86 -0
  73. data/docs/manual/plugins/rigor-actioncable.md +78 -0
  74. data/docs/manual/plugins/rigor-actionmailer.md +74 -0
  75. data/docs/manual/plugins/rigor-actionpack.md +80 -0
  76. data/docs/manual/plugins/rigor-activejob.md +58 -0
  77. data/docs/manual/plugins/rigor-activerecord.md +102 -0
  78. data/docs/manual/plugins/rigor-activestorage.md +74 -0
  79. data/docs/manual/plugins/rigor-activesupport-core-ext.md +86 -0
  80. data/docs/manual/plugins/rigor-devise.md +70 -0
  81. data/docs/manual/plugins/rigor-dry-schema.md +56 -0
  82. data/docs/manual/plugins/rigor-dry-struct.md +60 -0
  83. data/docs/manual/plugins/rigor-dry-types.md +59 -0
  84. data/docs/manual/plugins/rigor-dry-validation.md +62 -0
  85. data/docs/manual/plugins/rigor-factorybot.md +76 -0
  86. data/docs/manual/plugins/rigor-graphql.md +89 -0
  87. data/docs/manual/plugins/rigor-hanami.md +83 -0
  88. data/docs/manual/plugins/rigor-mangrove.md +73 -0
  89. data/docs/manual/plugins/rigor-minitest.md +86 -0
  90. data/docs/manual/plugins/rigor-pundit.md +72 -0
  91. data/docs/manual/plugins/rigor-rails-i18n.md +92 -0
  92. data/docs/manual/plugins/rigor-rails-routes.md +94 -0
  93. data/docs/manual/plugins/rigor-rails.md +44 -0
  94. data/docs/manual/plugins/rigor-rbs-inline.md +83 -0
  95. data/docs/manual/plugins/rigor-rspec-rails.md +72 -0
  96. data/docs/manual/plugins/rigor-rspec.md +86 -0
  97. data/docs/manual/plugins/rigor-shoulda-matchers.md +78 -0
  98. data/docs/manual/plugins/rigor-sidekiq.md +78 -0
  99. data/docs/manual/plugins/rigor-sinatra.md +61 -0
  100. data/docs/manual/plugins/rigor-sorbet.md +63 -0
  101. data/docs/manual/plugins/rigor-statesman.md +75 -0
  102. data/docs/manual/plugins/rigor-typescript-utility-types.md +71 -0
  103. data/exe/rigor +1 -1
  104. data/lib/rigor/analysis/incremental_session.rb +4 -2
  105. data/lib/rigor/analysis/run_stats.rb +13 -1
  106. data/lib/rigor/analysis/runner.rb +54 -12
  107. data/lib/rigor/cli/check_command.rb +26 -3
  108. data/lib/rigor/cli/coverage_command.rb +67 -92
  109. data/lib/rigor/cli/coverage_mutation.rb +149 -0
  110. data/lib/rigor/cli/docs_command.rb +248 -0
  111. data/lib/rigor/cli/fused_protection_renderer.rb +67 -0
  112. data/lib/rigor/cli/fused_protection_report.rb +76 -0
  113. data/lib/rigor/cli/skill_command.rb +103 -41
  114. data/lib/rigor/cli/skill_describe.rb +346 -0
  115. data/lib/rigor/cli.rb +25 -3
  116. data/lib/rigor/config_audit.rb +152 -0
  117. data/lib/rigor/configuration.rb +12 -0
  118. data/lib/rigor/environment/rbs_loader.rb +27 -0
  119. data/lib/rigor/environment.rb +49 -1
  120. data/lib/rigor/inference/method_dispatcher/constant_folding.rb +140 -38
  121. data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +37 -6
  122. data/lib/rigor/inference/scope_indexer.rb +87 -89
  123. data/lib/rigor/inference/statement_evaluator.rb +27 -0
  124. data/lib/rigor/plugin/isolation.rb +5 -5
  125. data/lib/rigor/plugin/loader.rb +4 -2
  126. data/lib/rigor/protection/diagnostic_oracle.rb +51 -0
  127. data/lib/rigor/protection/mutation_scanner.rb +98 -38
  128. data/lib/rigor/protection/mutator.rb +21 -0
  129. data/lib/rigor/protection/test_suite_oracle.rb +68 -0
  130. data/lib/rigor/signature_path_audit.rb +92 -0
  131. data/lib/rigor/version.rb +1 -1
  132. data/skills/rigor-ask/SKILL.md +172 -0
  133. data/skills/rigor-doctor/SKILL.md +87 -0
  134. data/skills/rigor-editor-setup/SKILL.md +114 -0
  135. data/skills/rigor-mcp-setup/SKILL.md +117 -0
  136. data/skills/rigor-monkeypatch-resolve/SKILL.md +79 -0
  137. data/skills/rigor-next-steps/SKILL.md +113 -0
  138. data/skills/rigor-plugin-tune/SKILL.md +79 -0
  139. data/skills/rigor-protection-uplift/SKILL.md +133 -0
  140. data/skills/rigor-rbs-setup/SKILL.md +128 -0
  141. data/skills/rigor-upgrade/SKILL.md +79 -0
  142. metadata +120 -1
@@ -0,0 +1,532 @@
1
+ # Rigor MCP Server — AI Agent Integration
2
+
3
+ `rigor mcp` is the Model Context Protocol (MCP) server bundled with the
4
+ `rigortype` gem. It exposes Rigor's analysis tools as JSON-RPC 2.0 tool
5
+ calls over a newline-delimited stdio stream, so AI coding assistants —
6
+ Claude Code, Cursor, Cline, VS Code Copilot Chat, and any other
7
+ MCP-aware agent — can call Rigor directly during a session.
8
+
9
+ ## MCP vs LSP — choosing the right integration
10
+
11
+ Both `rigor lsp` and `rigor mcp` expose the same underlying engine.
12
+ The difference is the consumer.
13
+
14
+ | | `rigor lsp` | `rigor mcp` |
15
+ |---|---|---|
16
+ | Protocol | Language Server Protocol | Model Context Protocol |
17
+ | Consumer | Your editor | An AI coding agent |
18
+ | Interaction | Continuous (push diagnostics on every save) | On-demand (agent calls a tool when it decides to) |
19
+ | Transport | stdio (TCP queued) | stdio (HTTP queued) |
20
+ | When to use | Editor integration | AI-assisted development |
21
+
22
+ Use `rigor lsp` to get inline diagnostics and hover in Neovim, VS Code,
23
+ Helix, or Emacs. Use `rigor mcp` to let an AI agent check types before
24
+ suggesting a refactor, look up the type at a cursor position, or triage
25
+ a project's diagnostic set as context for a code-review session.
26
+
27
+ There is no conflict in running both simultaneously.
28
+
29
+ ## Tools at a glance
30
+
31
+ | Tool | Underlying command | Returns |
32
+ |---|---|---|
33
+ | `rigor_check` | `rigor check --format json` | JSON diagnostic report |
34
+ | `rigor_type_of` | `rigor type-of --format json` | JSON type at `FILE:LINE:COL` |
35
+ | `rigor_triage` | `rigor triage --format json` | JSON distribution + class/method selectors + hotspots + hints |
36
+ | `rigor_annotate` | `rigor annotate --no-color` | Annotated Ruby source |
37
+ | `rigor_sig_gen` | `rigor sig-gen --print --format json` | JSON RBS skeleton candidates |
38
+ | `rigor_explain` | `rigor explain --format json` | JSON rule catalog entries |
39
+ | `rigor_coverage` | `rigor coverage --format json` | JSON precision-tier breakdown |
40
+
41
+ All tools are read-only. Write-side operations (`rigor init`,
42
+ `rigor baseline generate`, `rigor sig-gen --write`) are intentionally
43
+ excluded — modifying project files is the developer's call, not an
44
+ agent's tool call.
45
+
46
+ ## Prerequisites
47
+
48
+ The single prerequisite is **`rigor` on your `PATH`** — the same
49
+ executable `rigor check` and `rigor lsp` already use. Any install
50
+ channel in [Installing Rigor](01-installation.md) provides it; `mise`
51
+ is the recommended channel because its shims make `rigor` available to
52
+ processes (and AI agents) that do not inherit your shell environment.
53
+
54
+ Do **not** add `rigortype` to your project's `Gemfile`. Rigor is a
55
+ tool, not a library. See
56
+ [Installing Rigor § Recommended — a runtime version manager](01-installation.md#recommended--a-runtime-version-manager).
57
+
58
+ ## CLI
59
+
60
+ ```sh
61
+ rigor mcp [--transport=stdio] [--config=PATH]
62
+ ```
63
+
64
+ - `--transport=stdio` — default; only value accepted in v1. HTTP
65
+ transport is queued for v2.
66
+ - `--config=PATH` — session-level default config path. Individual tool
67
+ calls may supply their own `config` argument, which takes precedence.
68
+ Without either, `Configuration.discover` walks `.rigor.yml` /
69
+ `.rigor.dist.yml` from the working directory.
70
+
71
+ Exit codes: 0 (clean shutdown — stdin EOF), 64 (unknown
72
+ `--transport`).
73
+
74
+ ## Client wiring
75
+
76
+ ### Claude Desktop
77
+
78
+ Add an entry to `~/Library/Application Support/Claude/claude_desktop_config.json`
79
+ (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "rigor": {
85
+ "command": "rigor",
86
+ "args": ["mcp"]
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ Restart Claude Desktop. The `rigor_check`, `rigor_type_of`, and other
93
+ tools will appear in the model's tool palette. To pin the analysis to a
94
+ specific project config:
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "rigor": {
100
+ "command": "rigor",
101
+ "args": ["mcp", "--config=/path/to/project/.rigor.yml"]
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### Claude Code CLI
108
+
109
+ Claude Code reads MCP server definitions from its project-level
110
+ settings. Add to `.claude/settings.json` in your project root:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "rigor": {
116
+ "command": "rigor",
117
+ "args": ["mcp"]
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ Or register it globally in `~/.claude/settings.json` so it is
124
+ available in every project. Once registered, Claude Code can call
125
+ `rigor_check` on files it is about to edit, use `rigor_type_of` to
126
+ ground a suggestion, and run `rigor_triage` to understand a project's
127
+ diagnostic shape before proposing a cleanup plan.
128
+
129
+ ### Cursor
130
+
131
+ Add to `.cursor/mcp.json` (project root) or `~/.cursor/mcp.json`
132
+ (user-level):
133
+
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "rigor": {
138
+ "command": "rigor",
139
+ "args": ["mcp"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ Cursor's Composer will then offer Rigor tools alongside its built-in
146
+ capabilities. `rigor_check` is especially useful before a Composer
147
+ refactor — run it first so the agent knows the current diagnostic
148
+ baseline, then compare after.
149
+
150
+ ### Cline (VS Code extension)
151
+
152
+ Open the Cline panel → MCP Servers → Add Server → Custom, and fill in:
153
+
154
+ | Field | Value |
155
+ |---|---|
156
+ | Name | `rigor` |
157
+ | Command | `rigor` |
158
+ | Args | `["mcp"]` |
159
+
160
+ Or add directly to Cline's `cline_mcp_settings.json`:
161
+
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "rigor": {
166
+ "command": "rigor",
167
+ "args": ["mcp"]
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ ### Generic / custom MCP client
174
+
175
+ `rigor mcp` speaks the [MCP stdio transport](https://spec.modelcontextprotocol.io/specification/basic/transports/#stdio):
176
+ one JSON-RPC 2.0 message per line, `\n`-terminated, no
177
+ `Content-Length` framing. Any client that follows this convention
178
+ works. The initialization sequence:
179
+
180
+ ```
181
+ → {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}}}
182
+ ← {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"rigor","version":"0.2.1"}}}
183
+ → {"jsonrpc":"2.0","method":"notifications/initialized"}
184
+ → {"jsonrpc":"2.0","id":1,"method":"tools/list"}
185
+ ← {"jsonrpc":"2.0","id":1,"result":{"tools":[...]}}
186
+ ```
187
+
188
+ All messages except `notifications/*` require a response.
189
+ `notifications/*` carry no `id` and are silently consumed.
190
+
191
+ ## Tool reference
192
+
193
+ ### rigor_check
194
+
195
+ Analyze one or more Ruby files or directories for type errors,
196
+ undefined methods, arity mismatches, and nil-receiver risks.
197
+
198
+ **Input:**
199
+
200
+ | Argument | Type | Required | Default |
201
+ |---|---|---|---|
202
+ | `paths` | `string[]` | yes | — |
203
+ | `config` | `string` | no | session default |
204
+
205
+ **Returns:** JSON — the same structure as `rigor check --format json`.
206
+
207
+ ```json
208
+ {
209
+ "diagnostics": [
210
+ {
211
+ "path": "app/models/user.rb",
212
+ "line": 42,
213
+ "column": 5,
214
+ "rule": "call.undefined-method",
215
+ "severity": "error",
216
+ "message": "undefined method `naem` for String"
217
+ }
218
+ ]
219
+ }
220
+ ```
221
+
222
+ `isError` is `false` when the run completes normally, even if
223
+ diagnostics were found. `isError: true` signals a configuration or
224
+ runtime failure (bad path, unreadable config, etc.).
225
+
226
+ **Typical agent use:** call `rigor_check` on the files an agent is
227
+ about to edit, record the baseline, apply the edit, call again, diff
228
+ the two diagnostic arrays to see whether the change introduced or
229
+ resolved issues.
230
+
231
+ ---
232
+
233
+ ### rigor_type_of
234
+
235
+ Get the inferred type of the expression at a specific source location.
236
+
237
+ **Input:**
238
+
239
+ | Argument | Type | Required |
240
+ |---|---|---|
241
+ | `file` | `string` | yes |
242
+ | `line` | `integer` (1-based) | yes |
243
+ | `col` | `integer` (1-based) | yes |
244
+ | `config` | `string` | no |
245
+
246
+ **Returns:** JSON — the same as `rigor type-of --format json`.
247
+
248
+ ```json
249
+ {
250
+ "file": "lib/order.rb",
251
+ "line": 17,
252
+ "column": 10,
253
+ "node": "LocalVariableReadNode",
254
+ "type": "Integer | nil",
255
+ "erased": "Integer?"
256
+ }
257
+ ```
258
+
259
+ **Typical agent use:** ground a hover explanation ("what type is `x`
260
+ at this cursor position?") or validate a type assumption before
261
+ generating a signature.
262
+
263
+ ---
264
+
265
+ ### rigor_triage
266
+
267
+ Summarize a project's diagnostic stream: rule distribution,
268
+ class/method selectors, per-file hotspots, and heuristic hints for
269
+ the most common error clusters.
270
+
271
+ **Input:**
272
+
273
+ | Argument | Type | Required | Default |
274
+ |---|---|---|---|
275
+ | `paths` | `string[]` | no | configured paths |
276
+ | `top` | `integer` | no | `10` |
277
+ | `config` | `string` | no | session default |
278
+
279
+ **Returns:** JSON — the same as `rigor triage --format json`.
280
+
281
+ ```json
282
+ {
283
+ "summary": { "total": 488, "error": 480, "warning": 8, "info": 0 },
284
+ "distribution": [
285
+ { "rule": "call.possible-nil-receiver", "count": 212 }
286
+ ],
287
+ "selectors": [
288
+ { "receiver": "String", "method": "squish", "count": 31, "files": 12,
289
+ "rules": { "call.undefined-method": 31 } }
290
+ ],
291
+ "hotspots": [
292
+ { "file": "app/models/account.rb", "count": 38,
293
+ "by_rule": { "call.possible-nil-receiver": 30 } }
294
+ ],
295
+ "hints": [
296
+ { "id": "activesupport-core-ext", "confidence": "likely",
297
+ "diagnostic_count": 365, "summary": "...", "action": "..." }
298
+ ]
299
+ }
300
+ ```
301
+
302
+ The `selectors` array is the by-(class, method) axis: each row is a
303
+ dispatch target with its `count`, distinct-`files` spread, and
304
+ per-`rule` breakdown, keyed on a normalised receiver class — so an
305
+ agent answers "which method concentrates the diagnostics?" from
306
+ structured fields, never by parsing a `message`.
307
+
308
+ **Typical agent use:** run `rigor_triage` at the start of a code
309
+ review or cleanup session to understand the diagnostic landscape
310
+ before deciding which rules and files to focus on — sort `selectors`
311
+ by `count` for the highest-leverage class/method, or filter by
312
+ `files` to separate systemic clusters from one-off bugs.
313
+
314
+ ---
315
+
316
+ ### rigor_annotate
317
+
318
+ Return the given Ruby source file with each line's last-expression
319
+ type appended as a `#=>` comment. `def` header lines show
320
+ the method's inferred return type.
321
+
322
+ **Input:**
323
+
324
+ | Argument | Type | Required |
325
+ |---|---|---|
326
+ | `file` | `string` | yes |
327
+ | `config` | `string` | no |
328
+
329
+ **Returns:** Plain text (annotated Ruby source). Not JSON.
330
+
331
+ ```ruby
332
+ module Rigor
333
+ VERSION = "0.2.1" #=> "0.2.1"
334
+ end
335
+ ```
336
+
337
+ **Typical agent use:** understand how Rigor infers types through a
338
+ specific file without having to call `rigor_type_of` line by line.
339
+
340
+ ---
341
+
342
+ ### rigor_sig_gen
343
+
344
+ Generate RBS skeleton signatures inferred from Ruby source files.
345
+
346
+ **Input:**
347
+
348
+ | Argument | Type | Required | Default |
349
+ |---|---|---|---|
350
+ | `paths` | `string[]` | no | configured paths |
351
+ | `params` | `"untyped"` \| `"observed"` | no | `"untyped"` |
352
+ | `config` | `string` | no | session default |
353
+
354
+ `params: "observed"` harvests call-site argument types from `spec/`
355
+ (or a directory named via `--observe=PATH` in the underlying CLI).
356
+
357
+ **Returns:** JSON — the same as `rigor sig-gen --print --format json`.
358
+
359
+ ```json
360
+ {
361
+ "candidates": [
362
+ {
363
+ "class_name": "Order",
364
+ "method_name": "total",
365
+ "kind": "instance",
366
+ "classification": "new-method",
367
+ "rbs": "def total: () -> Integer"
368
+ }
369
+ ]
370
+ }
371
+ ```
372
+
373
+ Classifications: `new-file`, `new-method`, `tighter-return`,
374
+ `equivalent`, `skipped`.
375
+
376
+ **Typical agent use:** call `rigor_sig_gen` to see which methods have
377
+ precise enough returns to be worth writing into `sig/`, then generate
378
+ and insert the RBS. The agent should NOT write signatures
379
+ automatically — present the candidates for human review, then apply
380
+ confirmed entries via `rigor sig-gen --write`.
381
+
382
+ ---
383
+
384
+ ### rigor_explain
385
+
386
+ Look up the description of one or all Rigor diagnostic rules.
387
+
388
+ **Input:**
389
+
390
+ | Argument | Type | Required | Notes |
391
+ |---|---|---|---|
392
+ | `rule` | `string` | no | Omit to get the full catalog |
393
+
394
+ Accepted values: a canonical rule ID (`call.undefined-method`), a
395
+ legacy alias (`undefined-method`), or a family prefix (`call`, `flow`,
396
+ `assert`, `dump`, `def`).
397
+
398
+ **Returns:** JSON — an array of rule catalog entries.
399
+
400
+ ```json
401
+ [
402
+ {
403
+ "id": "call.undefined-method",
404
+ "summary": "Method not found on the inferred receiver type.",
405
+ "severity_authored": "error",
406
+ "since": "0.0.1",
407
+ "fires_when": ["..."],
408
+ "does_not_fire_when": ["..."],
409
+ "suppression": "# rigor:disable call.undefined-method"
410
+ }
411
+ ]
412
+ ```
413
+
414
+ **Typical agent use:** explain a diagnostic to the user, or look up
415
+ whether a rule fires in a specific situation before deciding whether a
416
+ finding is a real bug.
417
+
418
+ ---
419
+
420
+ ### rigor_coverage
421
+
422
+ Report type-precision coverage: the ratio of expressions Rigor types
423
+ as `Constant` / `Nominal` / shaped / refined (precise) versus
424
+ `Dynamic[top]` or `top` (opaque).
425
+
426
+ **Input:**
427
+
428
+ | Argument | Type | Required |
429
+ |---|---|---|
430
+ | `paths` | `string[]` | yes |
431
+ | `config` | `string` | no |
432
+
433
+ **Returns:** JSON — the same as `rigor coverage --format json`.
434
+
435
+ ```json
436
+ {
437
+ "summary": {
438
+ "files_processed": 12,
439
+ "expressions_typed": 3841,
440
+ "precision_ratio": 0.447
441
+ },
442
+ "tiers": {
443
+ "constant": 312, "nominal": 903, "shaped": 46,
444
+ "refined": 71, "bot": 381,
445
+ "dynamic_specific": 512, "dynamic_top": 1498, "top": 118
446
+ },
447
+ "files": [
448
+ {
449
+ "path": "lib/order.rb",
450
+ "expressions_typed": 214,
451
+ "precision_ratio": 0.612
452
+ }
453
+ ]
454
+ }
455
+ ```
456
+
457
+ **Typical agent use:** measure the impact of adding a fold rule or RBS
458
+ annotation — call `rigor_coverage` before and after, compare the
459
+ `precision_ratio` delta.
460
+
461
+ ---
462
+
463
+ ## Troubleshooting
464
+
465
+ **The MCP server starts but the client shows no tools.**
466
+
467
+ Run `rigor mcp` manually in a terminal and send the handshake:
468
+
469
+ ```sh
470
+ echo '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0"}}}' | rigor mcp
471
+ ```
472
+
473
+ You should get a JSON response. If you get nothing or a shell error,
474
+ `rigor` is not on your `PATH` — fix the install path first (see
475
+ [Installing Rigor](01-installation.md)).
476
+
477
+ **`rigor_check` / `rigor_triage` return an empty diagnostics array on a project that has errors.**
478
+
479
+ The tool uses `Configuration.discover` from the working directory the
480
+ MCP server was started in. If the client launches `rigor mcp` from a
481
+ home or temp directory, no `.rigor.yml` is found and the configured
482
+ paths default to the empty set. Mitigations:
483
+
484
+ - Pass `--config=/path/to/project/.rigor.yml` when launching:
485
+ `"args": ["mcp", "--config=/path/to/project/.rigor.yml"]`
486
+ - Or pass an absolute `paths` argument in the tool call:
487
+ `{ "name": "rigor_check", "arguments": { "paths": ["/path/to/project/lib"] } }`
488
+
489
+ **`rigor_type_of` reports `isError: true`.**
490
+
491
+ The file path must be the exact on-disk path readable from the server
492
+ process. Relative paths are resolved from the server's working
493
+ directory. Use absolute paths from AI agents to avoid ambiguity.
494
+
495
+ **Tool calls are slow on first call, fast afterward.**
496
+
497
+ The first call in a session cold-boots the Ruby `require` cache;
498
+ subsequent calls reuse it. Expected warm-path latency:
499
+
500
+ | Tool | Cold (first call) | Warm (subsequent calls) |
501
+ |---|---|---|
502
+ | `rigor_explain` | < 200 ms | < 5 ms |
503
+ | `rigor_type_of` | ~1.5 s | ~200 ms |
504
+ | `rigor_check` (small project) | ~2 s | ~500 ms |
505
+ | `rigor_triage` (small project) | ~2 s | ~700 ms |
506
+
507
+ Cold-start is dominated by RBS environment build. A `.rigor/cache`
508
+ warmed by a prior `rigor check` run reduces it significantly.
509
+
510
+ ## Status and roadmap
511
+
512
+ `rigor mcp` shipped in v0.1.10 with all seven tools and stdio
513
+ transport. Queued follow-ups are demand-driven:
514
+
515
+ - **HTTP transport** (slice 2) — `--transport=http` for CI / remote
516
+ agent use; a minimal Rack endpoint.
517
+ - **Across-call environment caching** (slice 3) — hold a warm
518
+ `Environment` + `Cache::Store` in the server between calls,
519
+ invalidated by an `mtime`-based check; reduces warm-path latency
520
+ to near-zero for repeated calls against the same project.
521
+ - **`rigor_check` buffer mode** — accept an in-memory source buffer
522
+ instead of (or alongside) a file path; mirrors the `--tmp-file` /
523
+ `--instead-of` editor-mode flags. Useful when an AI agent has
524
+ edited a file's content in-memory and wants to check the modified
525
+ version before writing it.
526
+ - **`rigor_baseline_generate` (write-side, gated)** — explicitly
527
+ opt-in write tool for agents operating with confirmed write
528
+ permissions. Deferred until there is a clear demand signal.
529
+
530
+ To request a queued feature or report an issue, open a GitHub issue
531
+ with: the MCP client + version, the Rigor version (`rigor version`),
532
+ and the JSON-RPC exchange that triggered the problem.