rails-ai-context 5.9.1 → 5.11.0

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/README.md +5 -5
  5. data/docs/ARCHITECTURE.md +3 -3
  6. data/docs/CONFIGURATION.md +2 -2
  7. data/docs/FAQ.md +1 -1
  8. data/docs/GUIDE.md +9 -9
  9. data/docs/INTROSPECTORS.md +22 -4
  10. data/docs/TROUBLESHOOTING.md +1 -1
  11. data/docs/index.md +1 -1
  12. data/docs/superpowers/plans/2026-05-24-prism-ast-migration.md +1218 -0
  13. data/lib/generators/rails_ai_context/install/install_generator.rb +2 -1
  14. data/lib/rails_ai_context/configuration.rb +2 -1
  15. data/lib/rails_ai_context/introspector.rb +9 -1
  16. data/lib/rails_ai_context/introspectors/action_mailbox_introspector.rb +6 -7
  17. data/lib/rails_ai_context/introspectors/action_text_introspector.rb +4 -4
  18. data/lib/rails_ai_context/introspectors/active_storage_introspector.rb +15 -18
  19. data/lib/rails_ai_context/introspectors/active_support_introspector.rb +179 -0
  20. data/lib/rails_ai_context/introspectors/api_introspector.rb +22 -7
  21. data/lib/rails_ai_context/introspectors/asset_pipeline_introspector.rb +34 -3
  22. data/lib/rails_ai_context/introspectors/auth_introspector.rb +78 -44
  23. data/lib/rails_ai_context/introspectors/autoload_introspector.rb +135 -0
  24. data/lib/rails_ai_context/introspectors/component_introspector.rb +133 -52
  25. data/lib/rails_ai_context/introspectors/config_introspector.rb +37 -2
  26. data/lib/rails_ai_context/introspectors/connection_pool_introspector.rb +139 -0
  27. data/lib/rails_ai_context/introspectors/controller_introspector.rb +334 -158
  28. data/lib/rails_ai_context/introspectors/convention_introspector.rb +168 -34
  29. data/lib/rails_ai_context/introspectors/credentials_introspector.rb +137 -0
  30. data/lib/rails_ai_context/introspectors/devops_introspector.rb +63 -18
  31. data/lib/rails_ai_context/introspectors/engine_introspector.rb +4 -21
  32. data/lib/rails_ai_context/introspectors/env_introspector.rb +143 -0
  33. data/lib/rails_ai_context/introspectors/gem_introspector.rb +13 -22
  34. data/lib/rails_ai_context/introspectors/initializer_introspector.rb +113 -0
  35. data/lib/rails_ai_context/introspectors/job_introspector.rb +98 -20
  36. data/lib/rails_ai_context/introspectors/listeners/chained_call_listener.rb +26 -0
  37. data/lib/rails_ai_context/introspectors/listeners/env_access_listener.rb +62 -0
  38. data/lib/rails_ai_context/introspectors/listeners/gemfile_dsl_listener.rb +95 -0
  39. data/lib/rails_ai_context/introspectors/listeners/generic_macro_listener.rb +27 -0
  40. data/lib/rails_ai_context/introspectors/listeners/mailbox_routing_listener.rb +63 -0
  41. data/lib/rails_ai_context/introspectors/listeners/middleware_config_listener.rb +48 -0
  42. data/lib/rails_ai_context/introspectors/listeners/migration_dsl_listener.rb +161 -0
  43. data/lib/rails_ai_context/introspectors/listeners/mount_listener.rb +87 -0
  44. data/lib/rails_ai_context/introspectors/listeners/rake_task_dsl_listener.rb +145 -0
  45. data/lib/rails_ai_context/introspectors/listeners/schema_dsl_listener.rb +216 -0
  46. data/lib/rails_ai_context/introspectors/listeners/variant_call_listener.rb +13 -0
  47. data/lib/rails_ai_context/introspectors/middleware_introspector.rb +21 -6
  48. data/lib/rails_ai_context/introspectors/model_introspector.rb +30 -7
  49. data/lib/rails_ai_context/introspectors/multi_database_introspector.rb +35 -17
  50. data/lib/rails_ai_context/introspectors/observability_introspector.rb +208 -0
  51. data/lib/rails_ai_context/introspectors/performance_introspector.rb +29 -5
  52. data/lib/rails_ai_context/introspectors/rake_task_introspector.rb +46 -26
  53. data/lib/rails_ai_context/introspectors/schema_introspector.rb +314 -249
  54. data/lib/rails_ai_context/introspectors/security_introspector.rb +256 -0
  55. data/lib/rails_ai_context/introspectors/seeds_introspector.rb +29 -7
  56. data/lib/rails_ai_context/introspectors/source_introspector.rb +24 -10
  57. data/lib/rails_ai_context/introspectors/test_introspector.rb +11 -7
  58. data/lib/rails_ai_context/introspectors/turbo_introspector.rb +7 -4
  59. data/lib/rails_ai_context/introspectors/view_introspector.rb +24 -13
  60. data/lib/rails_ai_context/tools/base_tool.rb +1 -1
  61. data/lib/rails_ai_context/tools/validate.rb +72 -2
  62. data/lib/rails_ai_context/version.rb +1 -1
  63. data/server.json +2 -2
  64. metadata +21 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63fa43e2446217a8b226ba3fd59b0345c7e4fec6300acd0ab877354339187dac
4
- data.tar.gz: 0d12192067351b3e28e1ae8ba16792be31a8e340e356b4b261249345a2295fa3
3
+ metadata.gz: 21293efcd236f2ea0b04dd95564369f21e071a0373e71343caa740db9a2eb9f1
4
+ data.tar.gz: 0b9487187d0af78dc5e3fdd02f6f0910a132c69d306d0472ee98174baa9773d4
5
5
  SHA512:
6
- metadata.gz: 6d3f4378d84b890464cdda8c550195430987c05970b892184bda610fb727f7614d943b46141e4b3f7b39642503deacf71b76fca933923aada849e1c39f887fef
7
- data.tar.gz: 4632cbf34995fb74922c19f89988d7bd4a5dfb3cdac98ab78e8ab3d08bac11f84c3cab0df68364b46740c133fdda22bd7311400dd5381d857b611cb4de2fe6e7
6
+ metadata.gz: '016190a6a753c61f7363a7ad61855c153ef2a9c0d98e2ffb95dd164a1c1310deb9a8963b9afed5ff2c12d12644a93470d2d1d38bb510ddda69579e77f8941755'
7
+ data.tar.gz: 730deb817f8800b7468d4dd09e0af68c1a1429e4475c19e05eefc77d1e2728a246e2e4e2ba04249685de7a9b70c6248742773225d75df2b13d5e2fcd73694307
data/CHANGELOG.md CHANGED
@@ -5,6 +5,95 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.11.0] — 2026-05-24
9
+
10
+ ### Changed — Prism AST migration: all introspectors now use structural code extraction
11
+
12
+ Every introspector that scans `.rb` files has been migrated from regex-based pattern matching to Prism AST-based structural extraction. This is a zero-regression internal refactor -- all introspector outputs are verified identical via side-by-side comparison, 2257 unit tests, 119 E2E tests, and live validation against a production-scale Rails 8.1 app (39/39 introspectors, 41/41 tool invocations, 0 failures).
13
+
14
+ **What changed internally:**
15
+
16
+ - **`SourceIntrospector.walk(path, listener_map)`** -- new generic API that accepts any combination of listener classes or Proc factories, enabling ad-hoc AST extraction without modifying the core dispatcher. Supports both `Class` values (instantiated via `.new`) and `-> { Instance }` lambdas for configurable listeners.
17
+ - **11 new listener classes** for patterns beyond the original 7 model-level listeners:
18
+ - `GenericMacroListener` -- configurable no-receiver call detector (handles most Rails DSL patterns including `self.method` calls)
19
+ - `ChainedCallListener` -- method calls with receivers (`.variant()`, `.includes()`, `.create()`)
20
+ - `VariantCallListener` -- ActiveStorage variant detection
21
+ - `MailboxRoutingListener` -- ActionMailbox routing + lifecycle callbacks
22
+ - `MiddlewareConfigListener` -- `config.middleware.use/insert_before/insert_after/unshift`
23
+ - `EnvAccessListener` -- `ENV["KEY"]` / `ENV.fetch("KEY")` with block-default detection
24
+ - `MountListener` -- `mount Engine, at: "/path"` (both keyword and hash-rocket syntax)
25
+ - `RakeTaskDslListener` -- `namespace`/`desc`/`task` with deps and args (handles string + symbol deps)
26
+ - `GemfileDslListener` -- `gem`/`group`/`source` with group-scope tracking
27
+ - `SchemaDslListener` -- `create_table`/`t.type`/`t.index`/`add_foreign_key`/`create_enum`/`check_constraint`
28
+ - `MigrationDslListener` -- `create_table`/`add_column`/`add_index`/`rename_column`/`add_reference` and 6 more actions
29
+ - **28 introspectors converted**: ActiveStorage, ActionText, ActionMailbox, Middleware, ActiveSupport, Auth, Security, Controller (all 9 regex blocks including strong params, filters, rescue_from, rate_limit, respond_to, turbo_stream), Convention, Turbo, MultiDatabase, Performance, Job, Model, Component, View, Api, AssetPipeline, DevOps, Env, Gem, RakeTask, Engine, Seeds, Test, Schema, Config.
30
+ - **181 regex patterns intentionally remain** in categories where Prism cannot help: non-Ruby files (JS/TS/ERB/Haml -- 78), keyword/content matching (22), config assignments (15), runtime SQL/YAML (25), and complex partial patterns (41).
31
+
32
+ **What didn't change:**
33
+
34
+ - All introspector output formats are identical. No consumer-facing API changes.
35
+ - All 39 MCP tools work exactly as before.
36
+ - Runtime reflection paths (ActiveRecord, Rails config, I18n, etc.) are untouched.
37
+ - Non-Ruby file scanning (YAML, JSON, ERB, JS, Procfile, Dockerfile, Gemfile.lock) is untouched.
38
+
39
+ **Why this matters:**
40
+
41
+ - Regex scanning matches patterns in comments, strings, and dead code. AST extraction only matches actual code structure -- fewer false positives.
42
+ - Multi-line declarations that broke regex (e.g., `devise` with 9 modules across 3 lines, `before_action` with complex `only:`/`except:` constraints) are now parsed correctly by Prism.
43
+ - The `AstCache` provides thread-safe LRU caching of parse results, so repeated walks of the same file are free.
44
+ - New listeners are composable -- introspectors mix and match listeners via `SourceIntrospector.walk(path, { key: Listener })` without coupling.
45
+
46
+ ### Fixed
47
+
48
+ - Avoid false-positive route helper warnings when `rails_validate` sees locally defined Ruby methods ending in `_path` or `_url` (#83, thanks @curi).
49
+ - Preserve newline-separated staged file names in the generated pre-commit validation hook (#83).
50
+
51
+ ### Tests
52
+
53
+ - 2257 unit examples (up from 2154), 0 failures
54
+ - 119 E2E examples, 0 failures
55
+ - 47 edge-case tests for controller, auth, and security AST conversions
56
+ - 10 listener edge-case tests (block-syntax ENV defaults, string rake deps, insert-with-index middleware, hash-rocket mounts, complex gem lines)
57
+ - Side-by-side regression comparison: all 39 introspector outputs verified identical between old regex and new AST code
58
+
59
+ ## [5.10.0] — 2026-04-20
60
+
61
+ ### Added — 8 new introspectors closing RAILS_NERVOUS_SYSTEM.md gaps
62
+
63
+ An audit against [`RAILS_NERVOUS_SYSTEM.md`](RAILS_NERVOUS_SYSTEM.md) identified 9 framework sections where introspection was missing or partial. This release ships the 8 introspectors needed to close them (the 9th — §11 Query interface — was already covered by `:conventions` via `load_async` / `.async_*` scanning). All are wired into `PRESETS[:full]`. The gem now exposes **39 introspectors** (up from 31).
64
+
65
+ - **`InitializerIntrospector` (`:initializers`, §2).** Enumerates `Rails.application.initializers` — every initializer's name, owner, declared `before:` / `after:` ordering edges, and the `source_location` of its block. Also summarizes each `config/initializers/*.rb` file (initializer count + the top `config.*` setters it touches) so AI can jump straight to user-owned boot code.
66
+ - **`AutoloadIntrospector` (`:autoload`, §3).** Zeitwerk presence, both `Rails.autoloaders.main` and `.once` with their collapsed dirs + ignored paths + root dirs, raw `autoload_paths` / `autoload_once_paths` / `eager_load_paths`, the resolved `eager_load` boolean, plus custom inflection rules extracted from `config/initializers/*.rb` (`inflect.acronym` / `.plural` / `.singular` / `.irregular` / `.uncountable` / `.human`). Paths are root-relative.
67
+ - **`ConnectionPoolIntrospector` (`:connection_pool`, §10).** Per-database adapter config: `pool`, `checkout_timeout`, `idle_timeout`, `reaping_frequency`, `prepared_statements`, `advisory_locks`, replica flag, role, connection-handler pool counts per role (`:writing` / `:reading`), and automatic shard selector detection (Rails 7.1+ `ActiveRecord::Middleware::ShardSelector`). Complements `:database_stats` (which only returns row counts).
68
+ - **`ActiveSupportIntrospector` (`:active_support`, §17).** Covers ActiveSupport runtime surface other introspectors leave untouched: Concerns in `app/**/concerns/` (with `ActiveSupport::Concern` / `included do` / `class_methods do` flags), `Rails.application.deprecators` registry keys, MessageEncryptor + MessageVerifier usage scan across `lib/` + `app/`, TaggedLogging configuration (`config.log_tags` + initializer-based `ActiveSupport::TaggedLogging.new`), active on-load hooks, and cache-store options.
69
+ - **`CredentialsIntrospector` (`:credentials`, §30).** Default `config/credentials.yml.enc` + every per-env `config/credentials/<env>.yml.enc`, master-key source resolution (`env:RAILS_MASTER_KEY` / `file:config/master.key` / `missing`), `config.require_master_key` flag, arbitrary encrypted configs (`config/<name>.yml.enc` pairs), and top-level credential **key names only** — decrypted hash is inspected for `.keys` and nothing more. A regression spec asserts no known credential value appears in the output.
70
+ - **`SecurityIntrospector` (`:security`, §32).** Framework-level security controls `auth_introspector` doesn't cover: `config.force_ssl`, SSL options (HSTS `expires` / `subdomains` / `preload`, `redirect`, `secure_cookies`), `config.hosts` + `host_authorization` options, `ContentSecurityPolicy` directives (including `report_only`), `PermissionsPolicy` directives, CSRF config (`protect_from_forgery` declaration, `per_form_csrf_tokens`, `forgery_protection_origin_check`), cookie session options (`:key`, `:secure`, `:httponly`, `:same_site`, `:domain`, `:path`, `:expire_after`), and Rails 7.2+ `allow_browser` calls per controller.
71
+ - **`ObservabilityIntrospector` (`:observability`, §34 + §38).** `ActiveSupport::LogSubscriber.log_subscribers` catalog (class + namespace), full `ActiveSupport::Notifications` subscriber registry walked via `@string_subscribers` / `@other_subscribers` / legacy `@subscribers` (handles Rails 7.0/7.1/8.x variants — grouped by pattern with subscriber count + sample class name), `ActionDispatch::ServerTiming` middleware detection + `config.server_timing` flag, Rails 8.1 `event_reporter` availability, log level + tags + `colorize_logging`, and a static catalog of 60+ canonical Rails event names across 10 subsystems (`action_controller`, `action_view`, `active_record`, `active_job`, `action_mailer`, `action_mailbox`, `action_cable`, `active_support`, `active_storage`, `railties`).
72
+ - **`EnvIntrospector` (`:env`, §36).** Curated catalog of 30+ Rails-related ENV vars (core, server, bundler, assets, boot, secrets, database, cache, deploy, platform, observability, testing) partitioned into `set` / `unset`. Safe vars (`RAILS_ENV`, `RAILS_MAX_THREADS`, `PORT`, etc.) return their value. Sensitive vars (`SECRET_KEY_BASE`, `RAILS_MASTER_KEY`, `DATABASE_URL`, `REDIS_URL`, `KAMAL_REGISTRY_PASSWORD`, etc.) return `redacted: true` only — the value never leaves the process. Also scans `config/`/`app/`/`lib/` for app-specific `ENV["X"]` / `ENV.fetch("X")` references beyond the catalog.
73
+
74
+ ### Why these specifically
75
+
76
+ Each corresponds to a `RAILS_NERVOUS_SYSTEM.md` section the audit flagged as uncovered. Partial-coverage sections (§2 filenames, §3 Zeitwerk presence, §17 CurrentAttributes, §27 Solid Trifecta, §30 boolean, §32 CORS/CSP/force_ssl, §34 N+1 anti-patterns, §36 puma/procfile) are preserved — the new introspectors complement rather than replace existing ones.
77
+
78
+ ### Preset wiring
79
+
80
+ All 8 are in `PRESETS[:full]`. None are in `PRESETS[:standard]` — they're framework-runtime data most valuable in `full` mode where comprehensive context outranks boot speed. `config.introspectors.size` for `:full` is now `39` (from `31`). The configuration spec was updated accordingly.
81
+
82
+ ### Tests
83
+
84
+ Every new introspector ships with a unit spec under `spec/lib/rails_ai_context/introspectors/*_introspector_spec.rb`, plus an orchestrator-level assertion in `spec/lib/rails_ai_context/introspector_spec.rb` that all 8 keys land in the context hash, plus a real-Rails-app e2e spec at `spec/e2e/nervous_system_introspectors_spec.rb` (8 examples, run via `E2E=1`). Specs assert shape guarantees, error absence, category-specific invariants, and the `CredentialsIntrospector` / `EnvIntrospector` specs include explicit sentinel-value leak assertions (a secret is injected, then the output hash is searched for the sentinel string). The full non-e2e suite runs **2154 examples, 0 failures**.
85
+
86
+ ### Fixed — post-review hardening
87
+
88
+ Three parallel code reviews (security/data-leak, Rails-version correctness, CLAUDE.md invariant compliance) surfaced the following issues, all addressed in this release:
89
+
90
+ - **`ObservabilityIntrospector#detect_event_reporter` crashed on Rails 8.1.** The original code called `reporter.tagged` without a block to read "registered tags". `ActiveSupport::EventReporter#tagged` delegates unconditionally to `TagStack#with_tags(&block)` which `yield`s — a blockless call raises `LocalJumpError`. The outer `rescue` caught it and returned `{ available: false }`, which silently misreported Rails 8.1 apps as lacking the event reporter and dropped the `subscriber_count` too. The `entry[:tags]` line was removed; `tagged` is stack-scoped context, not an introspectable keyspace. `subscriber_count` is still reported.
91
+ - **`ObservabilityIntrospector#extract_subscribers_from_notifier` had dead code.** A "legacy `@subscribers` (array)" fallback claimed to support Rails 7.0, but Rails 7.0 already used `@string_subscribers` + `@other_subscribers`. The flat `@subscribers` ivar hasn't existed since Rails ≤ 5.x, so the branch was unreachable across the entire 7.1 / 7.2 / 8.0 CI matrix. Removed. Also: the `subscriber_raw_pattern` helper now unwraps `ActiveSupport::Notifications::Fanout::Subscribers::Matcher` one level deep so Regexp-pattern subscribers surface as `"pattern.source"` instead of `"#<…::Matcher:0x…>"`.
92
+ - **`CredentialsIntrospector` leaked paths via `e.message`.** Both the top-level `rescue` and `inspect_default_credentials`'s rescue returned `{ error: e.message }` in the output hash. OS-level errors (`Errno::EACCES`, `Errno::ENOENT`) and OpenSSL decryption failures include absolute paths with the OS username in their message — credentials-adjacent data that shouldn't leave the process. Both rescues now return `{ error: "…failed", exception_class: e.class.name }`; `e.message` stays in the `ENV["DEBUG"]`-gated stderr log where it's fine. New regression specs inject a `Errno::EACCES` with a path containing `/Users/alice/secret/master.key` and assert neither `"/Users/alice"` nor `"alice/secret"` appears anywhere in the output.
93
+ - **`EnvIntrospector` classified `BUNDLE_PATH` and `BUNDLE_GEMFILE` as safe-to-return.** Both are absolute filesystem paths that usually contain the OS username (e.g. `/Users/alice/.bundle`). Flipped to `safe: false` so only presence is reported, matching the treatment of other path-containing vars (`DATABASE_URL`, `REDIS_URL`, etc.).
94
+ - **`ActiveSupportIntrospector` + `EnvIntrospector` had non-deterministic directory walks.** Both called `Dir.glob(...).first(2000)` to cap traversal on large monorepos, but `Dir.glob` ordering is filesystem-dependent, so the selected 2000-file slice could differ run-to-run. Both now call `Dir.glob(...).sort.first(2000)`, matching the `.sort` already used by the other new introspectors.
95
+ - **Spec-coverage gaps on ivar-derived paths.** The reviewers flagged that three silently-failing paths had no assertions: initializer `:source` capture (via `@block.source_location`), connection_pool `:pool_config` shape, and the `@other_subscribers` Regexp-pattern branch in the Fanout walk. All three now have targeted assertions — a silent drift if any of these ivars is renamed upstream will now fail CI.
96
+
8
97
  ## [5.9.1] — 2026-04-20
9
98
 
10
99
  ### Fixed — `GetConcern` missed plural concern names (#78)
data/CONTRIBUTING.md CHANGED
@@ -19,7 +19,7 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
19
19
  ```
20
20
  lib/rails_ai_context/
21
21
  ├── cli/ # CLI tool runner (tool_runner.rb) — executes MCP tools from rake/Thor
22
- ├── introspectors/ # 31 introspectors (schema, models, routes, etc.)
22
+ ├── introspectors/ # 39 introspectors (schema, models, routes, etc.)
23
23
  ├── tools/ # 38 MCP tools with detail levels and pagination
24
24
  ├── serializers/ # Per-assistant formatters + shared ToolGuideHelper
25
25
  ├── server.rb # MCP server setup (stdio + HTTP)
data/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
  <br>
22
22
  [![Ruby](https://img.shields.io/badge/Ruby-3.2%20%7C%203.3%20%7C%203.4-CC342D)](https://github.com/crisnahine/rails-ai-context)
23
23
  [![Rails](https://img.shields.io/badge/Rails-7.1%20%7C%207.2%20%7C%208.0-CC0000)](https://github.com/crisnahine/rails-ai-context)
24
- [![Tests](https://img.shields.io/badge/Tests-2078%20passing-brightgreen)](https://github.com/crisnahine/rails-ai-context/actions)
24
+ [![Tests](https://img.shields.io/badge/Tests-2257%20passing-brightgreen)](https://github.com/crisnahine/rails-ai-context/actions)
25
25
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
26
26
 
27
27
  </div>
@@ -397,7 +397,7 @@ Enabled by default. Disable with `config.anti_hallucination_rules = false` if yo
397
397
 
398
398
  ```mermaid
399
399
  graph TD
400
- A["Your Rails App\nmodels + schema + routes + controllers + views + jobs"] -->|"31 introspectors"| B
400
+ A["Your Rails App\nmodels + schema + routes + controllers + views + jobs"] -->|"39 introspectors"| B
401
401
 
402
402
  B["rails-ai-context\nPrism AST parsing · Cached · Confidence-tagged\nVFS: rails-ai-context:// URIs introspected fresh"]
403
403
 
@@ -459,7 +459,7 @@ Both paths ask which AI tools you use (Claude Code, Cursor, GitHub Copilot, Open
459
459
  | **[Configuration](docs/CONFIGURATION.md)** | 40+ config options with defaults |
460
460
  | **[AI Tool Setup](docs/SETUP.md)** | Claude, Cursor, Copilot, OpenCode, Codex |
461
461
  | **[Architecture](docs/ARCHITECTURE.md)** | System design and internals |
462
- | **[Introspectors](docs/INTROSPECTORS.md)** | All 31 introspectors and AST engine |
462
+ | **[Introspectors](docs/INTROSPECTORS.md)** | All 39 introspectors and AST engine |
463
463
  | **[Security](docs/SECURITY.md)** | 4-layer SQL safety and file blocking |
464
464
  | **[CLI Reference](docs/CLI.md)** | Commands and argument syntax |
465
465
  | **[Standalone](docs/STANDALONE.md)** | Use without Gemfile entry |
@@ -508,7 +508,7 @@ if defined?(RailsAiContext)
508
508
  RailsAiContext.configure do |config|
509
509
  config.ai_tools = %i[claude cursor] # Which AI tools to generate for
510
510
  config.tool_mode = :mcp # :mcp (default) or :cli
511
- config.preset = :full # :full (31 introspectors) or :standard (17)
511
+ config.preset = :full # :full (39 introspectors) or :standard (17)
512
512
  end
513
513
  end
514
514
  ```
@@ -543,7 +543,7 @@ end
543
543
  ## About
544
544
 
545
545
  Built by a Rails developer with 10+ years of production experience.<br>
546
- 2078 tests + 100-example e2e harness. 38 tools. 5 resource templates. 31 introspectors. Standalone or in-Gemfile.<br>
546
+ 2154 tests + 100-example e2e harness. 38 tools. 5 resource templates. 39 introspectors. Standalone or in-Gemfile.<br>
547
547
  MIT licensed. [Contributions welcome.](CONTRIBUTING.md)
548
548
 
549
549
  <br>
data/docs/ARCHITECTURE.md CHANGED
@@ -18,7 +18,7 @@ graph TD
18
18
  A["models + schema + routes + controllers + views + jobs + config"]
19
19
  end
20
20
 
21
- A -->|"31 introspectors"| gem
21
+ A -->|"39 introspectors"| gem
22
22
 
23
23
  subgraph gem["rails-ai-context"]
24
24
  direction TB
@@ -26,7 +26,7 @@ graph TD
26
26
  subgraph engine["Introspection Engine"]
27
27
  direction LR
28
28
  I["Introspectors\n31 modules\nPresets\nCached"]
29
- AST["AST Engine\nPrism\n7 listeners\nConfidence tags"]
29
+ AST["AST Engine\nPrism\n20 listeners\nConfidence tags"]
30
30
  H["Hydration Layer\nSchema hints\ninjected into\ntool responses"]
31
31
  end
32
32
 
@@ -101,7 +101,7 @@ flowchart LR
101
101
 
102
102
  ### Introspectors (`lib/rails_ai_context/introspectors/`)
103
103
 
104
- 31 modules that extract structured data from your Rails app. Each introspector:
104
+ 39 modules that extract structured data from your Rails app. Each introspector:
105
105
 
106
106
  - Returns a Hash (never raises — wraps errors in `{ error: msg }`)
107
107
  - Is registered in `INTROSPECTOR_MAP` with a symbol key
@@ -56,7 +56,7 @@ preset: full
56
56
 
57
57
  | Option | Type | Default | Description |
58
58
  |:-------|:-----|:--------|:------------|
59
- | `preset` | Symbol | `:full` | `:full` (31 introspectors) or `:standard` (17 introspectors) |
59
+ | `preset` | Symbol | `:full` | `:full` (39 introspectors) or `:standard` (17 introspectors) |
60
60
  | `context_mode` | Symbol | `:compact` | `:compact` (context files capped at ~150 lines) or `:full` (no line cap) |
61
61
  | `introspectors` | Array of symbols | (from preset) | Override the introspector list directly |
62
62
  | `generate_root_files` | Boolean | `true` | Set `false` to generate split rules only, no root CLAUDE.md/AGENTS.md |
@@ -155,7 +155,7 @@ preset: full
155
155
 
156
156
  ## Presets
157
157
 
158
- ### `:full` (default) — 31 introspectors
158
+ ### `:full` (default) — 39 introspectors
159
159
 
160
160
  All available introspectors. Best for comprehensive context.
161
161
 
data/docs/FAQ.md CHANGED
@@ -99,7 +99,7 @@ PostgreSQL, MySQL, and SQLite. Each gets database-specific safety mechanisms (re
99
99
 
100
100
  ### What's the difference between `:full` and `:standard` preset?
101
101
 
102
- - **`:full`** (default) — 31 introspectors. Comprehensive context for every aspect of your app.
102
+ - **`:full`** (default) — 39 introspectors. Comprehensive context for every aspect of your app.
103
103
  - **`:standard`** — 17 introspectors. Faster, covers the essentials (schema, models, routes, controllers, tests, etc.).
104
104
 
105
105
  ### What's `:compact` vs `:full` context mode?
data/docs/GUIDE.md CHANGED
@@ -24,7 +24,7 @@
24
24
  | [Configuration](CONFIGURATION.md) | Every config option |
25
25
  | [AI Tool Setup](SETUP.md) | Per-editor setup |
26
26
  | [Architecture](ARCHITECTURE.md) | System design and internals |
27
- | [Introspectors](INTROSPECTORS.md) | All 31 introspectors |
27
+ | [Introspectors](INTROSPECTORS.md) | All 39 introspectors |
28
28
  | [Security](SECURITY.md) | Security model and SQL safety |
29
29
  | [CLI Reference](CLI.md) | All commands and argument syntax |
30
30
  | [Standalone Mode](STANDALONE.md) | Use without Gemfile |
@@ -1192,7 +1192,7 @@ if defined?(RailsAiContext)
1192
1192
  RailsAiContext.configure do |config|
1193
1193
  # --- Introspectors ---
1194
1194
 
1195
- # Presets: :full (31 introspectors, default) or :standard (17)
1195
+ # Presets: :full (39 introspectors, default) or :standard (17)
1196
1196
  config.preset = :full
1197
1197
 
1198
1198
  # Cherry-pick on top of a preset
@@ -1311,7 +1311,7 @@ end
1311
1311
  | Option | Type | Default | Description |
1312
1312
  |--------|------|---------|-------------|
1313
1313
  | `preset` | Symbol | `:full` | Introspector preset (`:full` or `:standard`) |
1314
- | `introspectors` | Array | 31 (full preset) | Which introspectors to run |
1314
+ | `introspectors` | Array | 39 (full preset) | Which introspectors to run |
1315
1315
  | `context_mode` | Symbol | `:compact` | `:compact` or `:full` |
1316
1316
  | `claude_max_lines` | Integer | `150` | Max lines for CLAUDE.md in compact mode |
1317
1317
  | `max_tool_response_chars` | Integer | `200_000` | Safety cap for MCP tool responses |
@@ -1398,7 +1398,7 @@ Core Rails structure only. Use `config.preset = :standard` for a lighter footpri
1398
1398
  | `performance` | N+1 query risks, missing counter_cache, missing FK indexes, Model.all anti-patterns, eager load candidates. |
1399
1399
  | `i18n` | Default locale, available locales, locale files with key counts, backend class, parse errors. |
1400
1400
 
1401
- ### Full preset (31 introspectors) — default
1401
+ ### Full preset (39 introspectors) — default
1402
1402
 
1403
1403
  Includes all standard introspectors plus:
1404
1404
 
@@ -1534,11 +1534,11 @@ OpenCode uses **per-directory lazy-loading**: when the agent reads a file, it wa
1534
1534
 
1535
1535
  | Setup | Coverage | Notes |
1536
1536
  |-------|----------|-------|
1537
- | Rails full-stack (ERB + Hotwire) | 31/31 | All introspectors relevant |
1538
- | Rails + Inertia.js (React/Vue) | ~25/31 | Views/Turbo partially useful, backend fully covered |
1539
- | Rails API + React/Next.js SPA | ~23/31 | Schema, models, routes, API, auth, jobs — all covered |
1540
- | Rails API + mobile app | ~23/31 | Same as SPA — backend introspection is identical |
1541
- | Rails engine (mountable gem) | ~18/31 | Core introspectors (schema, models, routes, gems) work |
1537
+ | Rails full-stack (ERB + Hotwire) | 39/39 | All introspectors relevant |
1538
+ | Rails + Inertia.js (React/Vue) | ~33/39 | Views/Turbo partially useful, backend fully covered |
1539
+ | Rails API + React/Next.js SPA | ~31/39 | Schema, models, routes, API, auth, jobs — all covered |
1540
+ | Rails API + mobile app | ~31/39 | Same as SPA — backend introspection is identical |
1541
+ | Rails engine (mountable gem) | ~26/39 | Core introspectors (schema, models, routes, gems) work |
1542
1542
 
1543
1543
  Frontend introspectors (views, Turbo, Stimulus, assets) degrade gracefully — they report nothing when those features aren't present.
1544
1544
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Introspectors
4
4
 
5
- **31 modules that extract structured data from your Rails application.**
5
+ **39 modules that extract structured data from your Rails application.**
6
6
 
7
7
  [Architecture](ARCHITECTURE.md) · [Configuration](CONFIGURATION.md) · [Tools Reference](TOOLS.md) · [Security](SECURITY.md)
8
8
 
@@ -21,7 +21,7 @@ Each introspector:
21
21
 
22
22
  ## Presets
23
23
 
24
- ### `:full` (default) — all 31 introspectors
24
+ ### `:full` (default) — all 39 introspectors
25
25
 
26
26
  Best for comprehensive AI context. Covers every aspect of your app.
27
27
 
@@ -49,13 +49,16 @@ graph LR
49
49
  S16["performance"] ~~~ S17["i18n"]
50
50
  end
51
51
 
52
- subgraph full_only["Full Preset adds +14"]
52
+ subgraph full_only["Full Preset adds +22"]
53
53
  direction TB
54
54
  F1["views"] ~~~ F2["database_stats"] ~~~ F3["api"]
55
55
  F4["active_storage"] ~~~ F5["action_text"] ~~~ F6["action_mailbox"]
56
56
  F7["rake_tasks"] ~~~ F8["assets"] ~~~ F9["devops"]
57
57
  F10["seeds"] ~~~ F11["middleware"] ~~~ F12["engines"]
58
58
  F13["multi_database"] ~~~ F14["frontend_frameworks"]
59
+ F15["initializers"] ~~~ F16["autoload"] ~~~ F17["connection_pool"]
60
+ F18["active_support"] ~~~ F19["credentials"] ~~~ F20["security"]
61
+ F21["observability"] ~~~ F22["env"]
59
62
  end
60
63
 
61
64
  standard --> full_only
@@ -74,7 +77,7 @@ end
74
77
 
75
78
  ---
76
79
 
77
- ## All 31 introspectors
80
+ ## All 39 introspectors
78
81
 
79
82
  ### Core
80
83
 
@@ -148,6 +151,21 @@ end
148
151
  | TestIntrospector | `:tests` | Test framework, file counts, coverage hints |
149
152
  | PerformanceIntrospector | `:performance` | N+1 risks, missing indexes, counter_cache hints |
150
153
 
154
+ ### Runtime & Framework Internals
155
+
156
+ These introspectors map directly onto [`RAILS_NERVOUS_SYSTEM.md`](../RAILS_NERVOUS_SYSTEM.md) sections and capture framework-level surface that `:config`, `:auth`, and `:middleware` don't.
157
+
158
+ | Introspector | Key | Nervous-system § | What it extracts |
159
+ |:-------------|:----|:---|:-----------------|
160
+ | InitializerIntrospector | `:initializers` | §2 | `Rails.application.initializers` graph: name, owner, `before:`/`after:` edges, block `source_location`, per-file `config/initializers/*.rb` summary |
161
+ | AutoloadIntrospector | `:autoload` | §3 | Zeitwerk presence, autoloaders (`:main` / `:once`) with collapsed + ignored dirs, `autoload_paths`, `eager_load_paths`, custom inflections (`acronym`, `plural`, `singular`, `irregular`) |
162
+ | ConnectionPoolIntrospector | `:connection_pool` | §10 | Per-database adapter config: pool size, `checkout_timeout`, `reaping_frequency`, `prepared_statements`, `advisory_locks`, replica flag, connection-handler roles, automatic shard selector detection |
163
+ | ActiveSupportIntrospector | `:active_support` | §17 | Concerns in `app/**/concerns/` (ActiveSupport::Concern flags, `included do`/`class_methods do` blocks), deprecators registry, MessageEncryptor/Verifier usage, TaggedLogging config, common on-load hooks, cache store options |
164
+ | CredentialsIntrospector | `:credentials` | §30 | Default + per-env encrypted files, master-key source (`env:RAILS_MASTER_KEY` vs `file:config/master.key` vs missing), `require_master_key` flag, arbitrary encrypted configs (`config/*.yml.enc`), top-level key **names only** (never values) |
165
+ | SecurityIntrospector | `:security` | §32 | `force_ssl`, SSL options (HSTS `expires`/`subdomains`/`preload`), `host_authorization` hosts, ContentSecurityPolicy directives + `report_only`, PermissionsPolicy directives, CSRF config (`protect_from_forgery`, `per_form_csrf_tokens`, `origin_check`), cookie session options, Rails 7.2+ `allow_browser` usage |
166
+ | ObservabilityIntrospector | `:observability` | §34 + §38 | `ActiveSupport::LogSubscriber.log_subscribers` catalog, AS::Notifications subscriber registry (pattern + count + sample class), `ActionDispatch::ServerTiming` middleware detection, Rails 8.1 `event_reporter` availability, log level + tags, canonical Rails event-name catalog (10 subsystems) |
167
+ | EnvIntrospector | `:env` | §36 | Catalog of 30+ Rails-related ENV vars partitioned into `set` / `unset`; safe vars (`RAILS_ENV`, `RAILS_MAX_THREADS`, etc.) return values, sensitive vars (`SECRET_KEY_BASE`, `DATABASE_URL`, `RAILS_MASTER_KEY`, etc.) return `redacted: true` only; scans `config/`/`app/`/`lib/` for app-specific `ENV["X"]` references |
168
+
151
169
  ---
152
170
 
153
171
  ## AST-based introspection
@@ -247,7 +247,7 @@ Without it, the tool reports "not installed" but the gem works fine otherwise.
247
247
 
248
248
  ### "Introspection is slow"
249
249
 
250
- 1. Use `:standard` preset (17 introspectors vs 31)
250
+ 1. Use `:standard` preset (17 introspectors vs 39)
251
251
  2. Increase cache TTL: `config.cache_ttl = 300`
252
252
  3. Check schema file size: `rails ai:doctor` warns if too large
253
253
  4. Check view count: many views slow down view introspection
data/docs/index.md CHANGED
@@ -25,7 +25,7 @@ Works with Claude Code, Cursor, GitHub Copilot, OpenCode, and Codex CLI.
25
25
  | **[Tools Reference](TOOLS.md)** | All 38 tools with every parameter |
26
26
  | **[Configuration](CONFIGURATION.md)** | 40+ config options with defaults |
27
27
  | **[CLI Reference](CLI.md)** | Commands and argument syntax |
28
- | **[Introspectors](INTROSPECTORS.md)** | All 31 introspectors and AST engine |
28
+ | **[Introspectors](INTROSPECTORS.md)** | All 39 introspectors and AST engine |
29
29
 
30
30
  ## Learn
31
31