rails_ai_admin 0.4.1 → 0.5.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -0
  3. data/README.md +4 -9
  4. data/SECURITY.md +1 -1
  5. data/app/assets/builds/rails_ai_admin.js +5 -5
  6. data/app/controllers/rails_ai_admin/application_controller.rb +19 -6
  7. data/app/controllers/rails_ai_admin/assistant_controller.rb +20 -7
  8. data/app/controllers/rails_ai_admin/audit_controller.rb +5 -1
  9. data/app/controllers/rails_ai_admin/bulk_changes_controller.rb +26 -6
  10. data/app/controllers/rails_ai_admin/dashboard_controller.rb +3 -2
  11. data/app/controllers/rails_ai_admin/deleted_records_controller.rb +12 -4
  12. data/app/controllers/rails_ai_admin/files_controller.rb +16 -4
  13. data/app/controllers/rails_ai_admin/mcp_controller.rb +30 -4
  14. data/app/controllers/rails_ai_admin/mcp_tokens_controller.rb +4 -2
  15. data/app/controllers/rails_ai_admin/operations_controller.rb +5 -2
  16. data/app/controllers/rails_ai_admin/resources_controller.rb +44 -5
  17. data/app/controllers/rails_ai_admin/selections_controller.rb +41 -5
  18. data/app/helpers/rails_ai_admin/assistant_helper.rb +3 -1
  19. data/app/helpers/rails_ai_admin/fields_helper.rb +36 -7
  20. data/app/helpers/rails_ai_admin/history_helper.rb +1 -1
  21. data/app/views/layouts/rails_ai_admin/application.html.erb +1 -0
  22. data/app/views/layouts/rails_ai_admin/frame.html.erb +1 -1
  23. data/app/views/layouts/rails_ai_admin/status.html.erb +2 -2
  24. data/app/views/rails_ai_admin/assistant/_transcript.html.erb +5 -1
  25. data/app/views/rails_ai_admin/audit/index.html.erb +1 -1
  26. data/app/views/rails_ai_admin/deleted_records/index.html.erb +3 -2
  27. data/app/views/rails_ai_admin/fields/_input.html.erb +2 -1
  28. data/app/views/rails_ai_admin/selections/confirm_destroy.html.erb +1 -0
  29. data/config/locales/en.yml +2 -0
  30. data/db/assistant_migrate/20261103000001_create_rails_ai_admin_assistant.rb +1 -0
  31. data/db/migrate/20261122000001_add_missing_indexes_to_rails_ai_admin_tables.rb +12 -0
  32. data/lib/generators/rails_ai_admin/assistant/assistant_generator.rb +4 -1
  33. data/lib/generators/rails_ai_admin/assistant/templates/admin_assistant.rb +6 -0
  34. data/lib/generators/rails_ai_admin/assistant/templates/assistant_eval.yml +25 -0
  35. data/lib/generators/rails_ai_admin/install/templates/admin_context_devise.rb.tt +2 -1
  36. data/lib/generators/rails_ai_admin/install/templates/admin_context_rails.rb.tt +5 -2
  37. data/lib/rails_ai_admin/assistant/budget.rb +4 -2
  38. data/lib/rails_ai_admin/assistant/coordinator.rb +18 -4
  39. data/lib/rails_ai_admin/assistant/evaluation.rb +124 -0
  40. data/lib/rails_ai_admin/assistant/records.rb +2 -1
  41. data/lib/rails_ai_admin/assistant/retention.rb +12 -1
  42. data/lib/rails_ai_admin/assistant/runtime.rb +49 -1
  43. data/lib/rails_ai_admin/assistant/tools.rb +58 -18
  44. data/lib/rails_ai_admin/assistant.rb +1 -0
  45. data/lib/rails_ai_admin/authorization/access.rb +34 -23
  46. data/lib/rails_ai_admin/authorization/pundit_adapter.rb +6 -3
  47. data/lib/rails_ai_admin/collections/dispatcher.rb +3 -3
  48. data/lib/rails_ai_admin/collections/queries.rb +1 -1
  49. data/lib/rails_ai_admin/configuration.rb +39 -8
  50. data/lib/rails_ai_admin/doctor.rb +44 -9
  51. data/lib/rails_ai_admin/field.rb +37 -22
  52. data/lib/rails_ai_admin/fields/association.rb +27 -10
  53. data/lib/rails_ai_admin/fields/type.rb +1 -1
  54. data/lib/rails_ai_admin/forms/plan.rb +4 -2
  55. data/lib/rails_ai_admin/input_schema.rb +4 -4
  56. data/lib/rails_ai_admin/integrations/propose_operation.rb +18 -4
  57. data/lib/rails_ai_admin/integrations/tool_views.rb +29 -3
  58. data/lib/rails_ai_admin/mcp.rb +23 -13
  59. data/lib/rails_ai_admin/navigation/list_state.rb +3 -3
  60. data/lib/rails_ai_admin/navigation/saved_views.rb +6 -5
  61. data/lib/rails_ai_admin/operations/restore.rb +25 -4
  62. data/lib/rails_ai_admin/operations/runner.rb +51 -15
  63. data/lib/rails_ai_admin/outbox/dispatcher.rb +6 -2
  64. data/lib/rails_ai_admin/presentation/association_panel.rb +6 -6
  65. data/lib/rails_ai_admin/presentation/audit_log.rb +8 -3
  66. data/lib/rails_ai_admin/presentation/csv_export.rb +21 -8
  67. data/lib/rails_ai_admin/presentation/csv_import.rb +9 -1
  68. data/lib/rails_ai_admin/presentation/dashboard.rb +5 -2
  69. data/lib/rails_ai_admin/presentation/history.rb +1 -1
  70. data/lib/rails_ai_admin/prune.rb +16 -5
  71. data/lib/rails_ai_admin/queries/list.rb +138 -38
  72. data/lib/rails_ai_admin/record_version.rb +1 -1
  73. data/lib/rails_ai_admin/registry.rb +5 -0
  74. data/lib/rails_ai_admin/request_log_filter.rb +4 -2
  75. data/lib/rails_ai_admin/resource.rb +4 -0
  76. data/lib/rails_ai_admin/schema_suggestions.rb +13 -5
  77. data/lib/rails_ai_admin/templates/catalog.rb +4 -2
  78. data/lib/rails_ai_admin/templates/inspector.rb +6 -2
  79. data/lib/rails_ai_admin/templates/safe_paths.rb +2 -1
  80. data/lib/rails_ai_admin/version.rb +1 -1
  81. data/lib/rails_ai_admin/work.rb +1 -1
  82. data/lib/rails_ai_admin.rb +10 -6
  83. data/lib/tasks/rails_ai_admin.rake +20 -0
  84. metadata +25 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c498b7dfc10fb07cbacdaa580aa6dea008785ee683ee3e4fb2a506bbff1c839
4
- data.tar.gz: fee836a7c37ef1f4c2690071a62aadca84869790868db6ae24d28c12cd2055ed
3
+ metadata.gz: 1048026639656d2abbb66035b0e4eb7f61af3c1e13a9c1a410ddd999e0bb278f
4
+ data.tar.gz: 3eef016ef843b10035659e41bfdcbdd62186f9aca418f168320f85979dfb0025
5
5
  SHA512:
6
- metadata.gz: 28d40a74126638471aa5084ee4be218fe2c9309feaea5c1f9eff36b5844c1521ee7f566abf9cd8133c71fd7d8e6b8beb2095fbdd8efe46a3327d1d9bba9843bf
7
- data.tar.gz: caa4e83b7e3fc521b58791b9820ef0248fa60cde540262077f97a23fc551dca6a38584cde74c1b86f1fc0fbd36af5288c69f481d930e1bd694e3c941d122af28
6
+ metadata.gz: 50f07590db991d7c6e38106a092e9dd0e4fd52e74d8f2f2ac62cb32a81ece9c2a6ee8b3fb0a136e0dc925482729ccee255a58e323576469fef35be348a505393
7
+ data.tar.gz: 85628d7724070553b9041d6d8f69620c8699a6ef3865044821f1bfb0a061793b81610b9dad2430b2148f8feafa2bb0f1f54b801dce9e9fb5b3e2e42f785e24c5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 (2026-11-22)
4
+
5
+ This Public Preview adds operator notes, fallback models, prompt caching,
6
+ calendar-period totals and an assistant evaluation task. Existing hosts need
7
+ the new index migration and should check their layout and bulk delete overrides.
8
+ See the [upgrade guide](https://rails-ai-admin.wangyaodi.com/upgrading/).
9
+
10
+ - A new engine migration indexes queued batch items, work deadlines, runs by selection and audit event, and the audit log by resource. Copy it with `bin/rails generate rails_ai_admin:install --skip`, then run `bin/rails db:migrate`.
11
+ - A bulk delete confirmation carries a signed list of the records it showed. If the records that can be deleted change before submission, nothing is deleted and the page reports a conflict. An override of `selections/confirm_destroy.html.erb` moves to contract 3 and must submit the `review_signature` field.
12
+ - The Pundit adapter grants an action only when the policy method returns exactly `true`, and never through a method that Ruby's `Object` defines. A policy that returns another truthy value now denies.
13
+ - `searchable:` takes `false`, `true`, `:prefix`, `:contains` or `:exact`, on text, textarea, email, url, enum, select and belongs_to fields only. Other declarations raise `ConfigurationError` at boot.
14
+ - Restoring a soft-deleted record runs its model validations. A record that no longer validates stays deleted, and the page reports a conflict.
15
+ - A Work handler's `lease_duration` must be longer than its `max_duration`.
16
+ - The assistant and MCP resolve reference labels, and search or sort through a reference, only for target resources that also grant `assistant?`. MCP tokens work only while their owner has the assistant on at least one resource. Proposals for disabled operations are refused, and a turn that hit the step limit can no longer be retried.
17
+ - Association panels and the deleted-records page leave out records the person may not show, instead of listing their labels. The audit log names an actor in its filter only when that actor appears in the visible log.
18
+ - Request logs filter the `Authorization` and `Cookie` headers. MCP reads at most its body limit before parsing and never parses an unauthenticated body. Files are served only for fields visible on the show or list page, with `frame-ancestors 'none'`. Rich text renders through a fixed tag allowlist, whatever the host's sanitizer settings. A rejected form never sends a password back to the browser. CSV export also escapes formulas that follow leading spaces.
19
+ - Models versioned only by `lock_version` now advance their version when an edit changes only files, rich text or a list, so a concurrent form conflicts. On PostgreSQL, locked lookups no longer combine `FOR UPDATE` with a policy's outer join, and a malformed key in a filter is refused instead of raising. The dashboard trend leaves out future dates, and `Time` values are no longer converted to UTC in place.
20
+
21
+ - `bin/rails rails_ai_admin:assistant:eval` asks the questions in
22
+ `config/rails_ai_admin/assistant_eval.yml` as one person, through the real
23
+ model, grants and operator notes, and checks the tools called, the answer
24
+ text and, with reference answers, the meaning. It exits with status 1 on a
25
+ failure. It is built on `RubyLLM::Evaluation`; the assistant generator writes
26
+ a starter file.
27
+ - The assistant asks the provider to cache its instructions and tool
28
+ definitions, which every request repeats. Anthropic models, directly or
29
+ through OpenRouter, bill them at the cache-read price after the first
30
+ request; the spend line shows tokens read from the cache. Set
31
+ `config.assistant_prompt_caching = false` for a compatible server that
32
+ rejects unknown fields.
33
+ - The assistant adapter may define `instructions(context:)` to explain the
34
+ business to the model. The text follows the admin's own rules as a second
35
+ system message on every turn, is never saved, and grants nothing.
36
+ - `config.assistant_fallback_models` lists up to three models RubyLLM tries
37
+ when the assistant model is rate limited, overloaded or unreachable. The
38
+ doctor names them.
39
+ - `aggregate_records` groups by calendar period: pass a date or datetime field
40
+ the person may filter by as `group_by`, with `period` set to `day`, `week`,
41
+ `month` or `year`. Periods run oldest first in the person's time zone,
42
+ include periods without records, and stop at the latest 25.
43
+ `describe_resource` lists these fields as `group_by_period`. The offline demo
44
+ answers `sum orders total by week of delivery_on`.
45
+ - The default layout loads Trix in its head whenever a resource has a
46
+ `rich_text` field. Opening an editor through a Turbo visit no longer shows
47
+ the link dialog open, with Trix styles refused by the page's style policy.
48
+ Layout overrides move to contract 5. Add `<%= admin_rich_text_assets %>` to
49
+ an overridden layout's head; until then, Trix keeps loading beside each editor.
50
+ - `bin/demo` follows the supported RubyLLM range instead of pinning 2.2.0, so
51
+ the demo runs the release the checkout was tested with.
52
+ - On a Rails version with `forgery_protection_verification_strategy` (Rails
53
+ main, 8.2.0.alpha), engine controllers use `:header_or_legacy_token` whatever
54
+ the host's default. Rails 8.2's `:header_only` accepts a plain-HTTP request
55
+ without `Sec-Fetch-Site`; the admin asks such a request for its token.
56
+ - The field input partial compiles through Herb, which `load_defaults 8.2`
57
+ uses for HTML templates: `case` and its first `when` are separate tags.
58
+ - The OpenRouter recordings were made again on 2026-11-22 with RubyLLM 2.2.3
59
+ and prompt caching on, adding active customers per month and operator notes
60
+ on `anthropic/claude-haiku-5.5`. The recorded evaluation passes 26 of 27
61
+ questions. Fallbacks and the evaluation task are tested against a scripted
62
+ provider only.
63
+ - A scheduled CI workflow runs the suite against Rails main on SQLite and
64
+ PostgreSQL (`gemfiles/rails_main.gemfile`). It warns early and does not
65
+ block releases; Rails 8.2 is not supported yet.
66
+
3
67
  ## 0.4.1 (2026-11-18)
4
68
 
5
69
  This Public Preview patch fixes bulk reviews, joined lists, CSV imports and
data/README.md CHANGED
@@ -4,7 +4,7 @@ Rails AI Admin is a self-hosted admin engine for Rails. Give your team an admin
4
4
  for the models you choose, then add a RubyLLM-powered assistant that can answer
5
5
  questions about records and prepare changes for review.
6
6
 
7
- **0.4.1 Public Preview** · [Documentation](https://rails-ai-admin.wangyaodi.com/) ·
7
+ **0.5.0 Public Preview** · [Documentation](https://rails-ai-admin.wangyaodi.com/) ·
8
8
  [Quickstart](https://rails-ai-admin.wangyaodi.com/quickstart/) ·
9
9
  [RubyGems](https://rubygems.org/gems/rails_ai_admin)
10
10
 
@@ -56,7 +56,7 @@ sources and more detail. Data as of November 2026.
56
56
  Add the gem to your Gemfile and run `bundle install`:
57
57
 
58
58
  ```ruby
59
- gem "rails_ai_admin", "~> 0.4.1"
59
+ gem "rails_ai_admin", "~> 0.5.0"
60
60
  ```
61
61
 
62
62
  Requires Ruby 3.3+ and Rails 8.1.4.1+ (below 8.2). Rails 7 and 8.0 are not supported. See the [installation guide](https://rails-ai-admin.wangyaodi.com/getting-started/)
@@ -85,14 +85,9 @@ From a clone of this repository:
85
85
 
86
86
  ```sh
87
87
  bundle install
88
- bin/demo --assistant
88
+ bin/demo
89
89
  ```
90
90
 
91
- Open `http://127.0.0.1:3917/login`, choose **Sign in as Admin**, then select
92
- **Assistant → New conversation**. Try `search articles for upgrading`, followed
93
- by `set articles 1 title to Hello` to see a change review. The demo uses seeded
94
- data and an offline model; `bin/demo --openrouter` uses real models with an
95
- `OPENROUTER_API_KEY` from your environment. Follow the [demo walkthrough](https://rails-ai-admin.wangyaodi.com/demo/)
96
- for more examples.
91
+ Open `http://127.0.0.1:3917/login` and choose **Sign in as Admin**. Explore the dashboard and Articles, then ask the offline **Assistant** `set articles 1 title to Hello`. Review and confirm the change, then find it in **Audit log**. No API key is needed. Follow the [demo walkthrough](https://rails-ai-admin.wangyaodi.com/next/demo/) to try CSV, bulk reviews, permissions and MCP in the same demo.
97
92
 
98
93
  [MIT License](LICENSE) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)
data/SECURITY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Security policy
2
2
 
3
- 0.4.1 is the current Public Preview. Review the limitations in CHANGELOG.md and deploy
3
+ 0.5.0 is the current Public Preview. Review the limitations in CHANGELOG.md and deploy
4
4
  behind your host application's authentication and network controls. Verify
5
5
  tenant scopes and action and field grants before granting access.
6
6