diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..0ee7c91 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,27 @@ +{ + "permissions": { + "allow": [ + "Bash(mkdir:*)", + "Bash(bundle exec standardrb:*)", + "Bash(rake test:*)", + "Bash(ruby -Itest:*)", + "Bash(cat:*)", + "Bash(CI=1 bundle exec rake:*)", + "Bash(afplay:*)", + "Bash(ruby -Ilib:test -e:*)", + "Bash(open:*)", + "Bash(ruby -Ilib:test test/activerecord/test_null.rb -n \"/accesses attribute with symbol key/\" -v)", + "WebSearch", + "Bash(ruby -e:*)", + "Bash(CI=1 ruby:*)", + "Bash(bundle exec gem list:*)", + "Bash(CI=1 bundle exec ruby:*)", + "Bash(bundle exec ruby:*)", + "Bash(ruby test_no_db_access.rb:*)", + "Bash(bundle exec rake test:*)", + "Bash(git commit:*)" + ], + "deny": [], + "ask": [] + } +} diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..ded2440 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,108 @@ +# CLAUDE.md + +> Project instructions for AI assistants working on activerecord-null gem + +## Agent OS Documentation + +### Product Context +- **Mission & Vision:** @.agent-os/product/mission.md +- **Technical Architecture:** @.agent-os/product/tech-stack.md +- **Development Roadmap:** @.agent-os/product/roadmap.md +- **Decision History:** @.agent-os/product/decisions.md + +### Development Standards +- **Code Style:** @~/.agent-os/standards/code-style.md +- **Best Practices:** @~/.agent-os/standards/best-practices.md + +### Project Management +- **Active Specs:** @.agent-os/specs/ +- **Spec Planning:** Use `@~/.agent-os/instructions/create-spec.md` +- **Tasks Execution:** Use `@~/.agent-os/instructions/execute-tasks.md` + +## Workflow Instructions + +When asked to work on this codebase: + +1. **First**, check @.agent-os/product/roadmap.md for current priorities +2. **Then**, follow the appropriate instruction file: + - For new features: @~/.agent-os/instructions/create-spec.md + - For tasks execution: @~/.agent-os/instructions/execute-tasks.md +3. **Always**, adhere to the standards in the files listed above + +## Important Notes + +- Product-specific files in `.agent-os/product/` override any global standards +- User's specific instructions override (or amend) instructions found in `.agent-os/specs/...` +- Always adhere to established patterns, code style, and best practices documented above + +## Project-Specific Guidelines + +### This is a Ruby Gem Library + +This is NOT a Rails application - it's a library gem that extends ActiveRecord. Keep this context in mind: + +- No application hosting, database hosting, or asset hosting +- Focus is on library code quality, API design, and compatibility +- Tests use SQLite3 in-memory database +- Must maintain backward compatibility within major versions + +### Code Style Enforcement + +Before committing, ALWAYS run: +```bash +bundle exec standardrb --fix +``` + +All code must pass Standard linting. No exceptions. + +### Testing Requirements + +- Use Minitest (not RSpec) +- All new features must have comprehensive test coverage +- Run tests with: `rake test` (default rake task) +- Tests are in `test/` directory following Minitest conventions + +### Release Process + +This gem uses Reissue for release management: + +1. Use git trailers for changelog entries in commits +2. Run `rake build:checksum` to build gem and generate checksums +3. Run `rake release` to create git tag, push commits/tags, and push to RubyGems +4. Reissue automatically increments version and updates changelog + +**Never manually edit:** +- `lib/activerecord/null/version.rb` (managed by Reissue) +- `CHANGELOG.md` (generated from git trailers) + +### ActiveRecord Compatibility + +- Minimum ActiveRecord version: 7.0 +- Minimum Ruby version: 3.0.0 +- Test against multiple ActiveRecord versions if adding complex features +- Be mindful of ActiveRecord's reflection API and association internals + +### Design Philosophy + +From @.agent-os/product/decisions.md: + +1. **Drop-in Replacement:** Null objects should work anywhere real records work +2. **Singleton Pattern:** One null object instance per model class +3. **Zero Configuration:** Associations and attributes work automatically +4. **Simple API:** Creating null objects should be easy and obvious + +### Current Phase + +Per @.agent-os/product/roadmap.md, we are in **Phase 1: Edge Case Exploration** + +Focus areas: +- Finding and fixing edge cases +- Testing complex association scenarios +- Ensuring production-ready stability +- Documenting limitations and known issues + +When proposing new features, consider whether they: +1. Fix an edge case or bug +2. Improve compatibility with Rails ecosystem +3. Maintain API simplicity +4. Are backwards compatible diff --git a/lib/activerecord/null/mimic.rb b/lib/activerecord/null/mimic.rb index 7b619b4..897d649 100644 --- a/lib/activerecord/null/mimic.rb +++ b/lib/activerecord/null/mimic.rb @@ -14,7 +14,7 @@ def self.mimics(mimic_model_class) def self.mimic_model_class = @mimic_model_class - def self.table_name = @mimic_model_class.to_s.tableize + def self.table_name = @mimic_model_class.table_name def self.primary_key = @mimic_model_class.primary_key diff --git a/test/activerecord/test_void.rb b/test/activerecord/test_void.rb index af86c82..e7b1f68 100644 --- a/test/activerecord/test_void.rb +++ b/test/activerecord/test_void.rb @@ -229,8 +229,7 @@ def self.name describe "model integration" do it "respects table_name from parent model" do - # Note: Mimic module uses tableized class name, not parent's custom table_name - assert_equal "products", Product::Void.table_name + assert_equal Product.table_name, Product::Void.table_name end it "respects primary_key from parent model" do