Skip to content

feat(generators): a schema_tools generator that lists every column, commented out - #446

Merged
TonsOfFun merged 6 commits into
mainfrom
feat/schema-tools-generator
Sep 12, 2026
Merged

feat(generators): a schema_tools generator that lists every column, commented out#446
TonsOfFun merged 6 commits into
mainfrom
feat/schema-tools-generator

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

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.

bin/rails generate active_agent:schema_tools Reservation

writes app/agent_tools/reservation_tools.rb:

  • model Reservation, filterable :id, returns :id — nothing else is exposed until someone moves a column in.
  • Every column the model has, listed under each allowlist commented out, plus a typed column list, so choosing is editing one line rather than looking the schema up. Columns that look like secrets (password, digest, token, secret, api_key, otp, encrypted, ssn) are left off the list and named as not to be added.
  • scope_by_policy when ReservationPolicy::Scope exists, otherwise a suggested scope block that returns none for a missing actor. --policy / --no-policy decide explicitly.
  • A model that does not exist yet (or a database that is not set up) still gets a file, with placeholder suggestions.

ReservationTools and reservation both name the model; namespaces work (admin/reservationAdmin::ReservationTools over Admin::Reservation).

Also adds the first documentation of SchemaTools itself — the DSL, the three properties that make it safe to hand to a model, and the generator — as a section of docs/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/rubocop clean on the changed files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z

TonsOfFun and others added 6 commits September 12, 2026 12:06
…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
@TonsOfFun
TonsOfFun merged commit 418003d into main Sep 12, 2026
8 checks passed
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.

1 participant