feat(generators): a schema_tools generator that lists every column, commented out - #446
Merged
Conversation
…ommented out rails generate active_agent:schema_tools Reservation writes a starter ActiveAgent::SchemaTools class under app/agent_tools. It exposes nothing beyond id until a column is moved into filterable or returns; every column the model has is listed, commented out, with its type, so the allowlist is a review step rather than a blank page, and columns that look like secrets are left off the list. Reads go through <Model>Policy::Scope when it exists (--policy / --no-policy decide explicitly). This is #440's second option: the roster is still declared, once, but the declaration is no longer written from scratch. Also the first documentation of SchemaTools itself, in docs/actions/tools.md. Refs #440. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z
…erator # Conflicts: # CHANGELOG.md
…erator # Conflicts: # CHANGELOG.md
…erator # Conflicts: # CHANGELOG.md
…erator # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #440 — its option 2, the generator. Option 1 (discovery instead of a config array) shipped in 1.5.2; options 3 and 4 (deriving the allowlist) stay out, for the reason the issue gives: which columns an agent may see is a judgement about exposure, not a fact about the table.
writes
app/agent_tools/reservation_tools.rb:model Reservation,filterable :id,returns :id— nothing else is exposed until someone moves a column in.password,digest,token,secret,api_key,otp,encrypted,ssn) are left off the list and named as not to be added.scope_by_policywhenReservationPolicy::Scopeexists, otherwise a suggestedscopeblock that returnsnonefor a missing actor.--policy/--no-policydecide explicitly.ReservationToolsandreservationboth name the model; namespaces work (admin/reservation→Admin::ReservationToolsoverAdmin::Reservation).Also adds the first documentation of
SchemaToolsitself — the DSL, the three properties that make it safe to hand to a model, and the generator — as a section ofdocs/actions/tools.md. Until now the class was documented only in its own source.Testing
test/generators/active_agent/schema_tools_generator_test.rb: six cases (bare file, column suggestions with types, suffix and namespace, policy detection and the flag, a missing model, secret columns).bin/test test/generators/active_agent/*_test.rb test/schema_tools_test.rb— 65 runs, 282 assertions, 0 failures.bin/rubocopclean on the changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z