easy_talk 3.2.0 → 3.3.1

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -43
  3. data/CHANGELOG.md +105 -0
  4. data/README.md +510 -2018
  5. data/docs/json_schema_compliance.md +140 -26
  6. data/docs/primitive-schema-rfc.md +894 -0
  7. data/examples/ruby_llm/Gemfile +12 -0
  8. data/examples/ruby_llm/structured_output.rb +47 -0
  9. data/examples/ruby_llm/tools_integration.rb +49 -0
  10. data/lib/easy_talk/builders/base_builder.rb +2 -1
  11. data/lib/easy_talk/builders/boolean_builder.rb +2 -1
  12. data/lib/easy_talk/builders/collection_helpers.rb +4 -0
  13. data/lib/easy_talk/builders/composition_builder.rb +7 -2
  14. data/lib/easy_talk/builders/integer_builder.rb +2 -1
  15. data/lib/easy_talk/builders/null_builder.rb +4 -1
  16. data/lib/easy_talk/builders/number_builder.rb +4 -1
  17. data/lib/easy_talk/builders/object_builder.rb +64 -3
  18. data/lib/easy_talk/builders/registry.rb +15 -1
  19. data/lib/easy_talk/builders/string_builder.rb +3 -1
  20. data/lib/easy_talk/builders/temporal_builder.rb +7 -0
  21. data/lib/easy_talk/builders/tuple_builder.rb +89 -0
  22. data/lib/easy_talk/builders/typed_array_builder.rb +4 -2
  23. data/lib/easy_talk/builders/union_builder.rb +5 -1
  24. data/lib/easy_talk/configuration.rb +17 -2
  25. data/lib/easy_talk/errors.rb +1 -0
  26. data/lib/easy_talk/errors_helper.rb +3 -0
  27. data/lib/easy_talk/extensions/ruby_llm_compatibility.rb +58 -0
  28. data/lib/easy_talk/json_schema_equality.rb +46 -0
  29. data/lib/easy_talk/keywords.rb +0 -1
  30. data/lib/easy_talk/model.rb +42 -1
  31. data/lib/easy_talk/model_helper.rb +4 -0
  32. data/lib/easy_talk/naming_strategies.rb +4 -0
  33. data/lib/easy_talk/property.rb +7 -0
  34. data/lib/easy_talk/ref_helper.rb +6 -0
  35. data/lib/easy_talk/schema.rb +1 -0
  36. data/lib/easy_talk/schema_definition.rb +52 -6
  37. data/lib/easy_talk/schema_methods.rb +36 -5
  38. data/lib/easy_talk/sorbet_extension.rb +1 -0
  39. data/lib/easy_talk/type_introspection.rb +45 -1
  40. data/lib/easy_talk/types/tuple.rb +77 -0
  41. data/lib/easy_talk/validation_adapters/active_model_adapter.rb +350 -62
  42. data/lib/easy_talk/validation_adapters/active_model_schema_validation.rb +106 -0
  43. data/lib/easy_talk/validation_adapters/base.rb +12 -0
  44. data/lib/easy_talk/validation_adapters/none_adapter.rb +9 -0
  45. data/lib/easy_talk/validation_builder.rb +1 -0
  46. data/lib/easy_talk/version.rb +1 -1
  47. data/lib/easy_talk.rb +1 -0
  48. metadata +17 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b77760f0bdffbb877509e133194733d397db6e5963b1484543791169db5dc840
4
- data.tar.gz: 6e805469940229543c059952dc2311dd9acf7ea89ff45fde8b49b3e4d38dd85d
3
+ metadata.gz: f1b72ef842cb6e49f4cbc0d1eab096e737f26c118e715170c35e791ceb28a0cd
4
+ data.tar.gz: 800ce6db8a8d0607589250fb76a0834bc1372de11617f2746abad2c00496bc77
5
5
  SHA512:
6
- metadata.gz: 5bf66646040995f9de8341e2a4e6ea63ae0c462a0f08f28779244e8eceff958e574042450a9a39cc2ef485e13d6c418e5f71296d6d8cc7e958339f432e84c572
7
- data.tar.gz: 4c26c3bee7751682535f154efef1c4adb86cea08be6c6f09f9ebe08d6a2fde5604d71db884aa7f0de91787118f5bbb719028f8071ec4166ba69af7ad0d9b4ff1
6
+ metadata.gz: 1cb143e9d16027929bcaf119cdcc12254fd4324f2f902a493be7a55095cfce1f8d721bd44c5233fb5ef62cde19aab3017f6fdc78cb66c57ab670a304293b6fb0
7
+ data.tar.gz: 2968e2ab36843d8237759d9b7528cbe9a72388123b677b8c8117c27192c51d50f577df884a0a96d9cc7e308f2119e2485bcbf0b13bb5742675fb5cd1338ae31a
data/.rubocop.yml CHANGED
@@ -1,7 +1,3 @@
1
- plugins:
2
- - rubocop-rspec
3
- - rubocop-rake
4
-
5
1
  AllCops:
6
2
  NewCops: enable
7
3
  TargetRubyVersion: 3.2
@@ -33,6 +29,8 @@ Style/StringLiterals:
33
29
 
34
30
  Metrics/ClassLength:
35
31
  Max: 240
32
+ Exclude:
33
+ - lib/easy_talk/validation_adapters/active_model_adapter.rb
36
34
 
37
35
  Metrics/MethodLength:
38
36
  Max: 60
@@ -55,6 +53,7 @@ Metrics/BlockNesting:
55
53
  Metrics/BlockLength:
56
54
  Exclude:
57
55
  - spec/**/*
56
+ - easy_talk.gemspec
58
57
 
59
58
  Layout/EndAlignment:
60
59
  Enabled: false
@@ -70,45 +69,6 @@ Lint/EmptyBlock:
70
69
  Exclude:
71
70
  - spec/**/*
72
71
 
73
- RSpec/DescribeClass:
74
- Enabled: false
75
-
76
- RSpec/LeakyConstantDeclaration:
77
- Enabled: false
78
-
79
- RSpec/RemoveConst:
80
- Enabled: false
81
-
82
- RSpec/BeforeAfterAll:
83
- Enabled: false
84
-
85
- RSpec/NestedGroups:
86
- Max: 4
87
-
88
- RSpec/RepeatedDescription:
89
- Enabled: false
90
-
91
- RSpec/PendingWithoutReason:
92
- Enabled: false
93
-
94
- RSpec/MultipleDescribes:
95
- Enabled: false
96
-
97
- RSpec/ContextWording:
98
- Enabled: false
99
-
100
- RSpec/MultipleMemoizedHelpers:
101
- Max: 10
102
-
103
- RSpec/ExampleLength:
104
- Max: 40
105
-
106
- RSpec/MultipleExpectations:
107
- Max: 10
108
-
109
- RSpec/SpecFilePathFormat:
110
- Enabled: false
111
-
112
72
  Lint/DuplicateBranch:
113
73
  Enabled: false
114
74
 
@@ -118,3 +78,15 @@ Gemspec/DevelopmentDependencies:
118
78
  Naming/PredicateMethod:
119
79
  Exclude:
120
80
  - spec/support/schema_validation_matcher.rb
81
+
82
+ Naming/BlockForwarding:
83
+ Enabled: false
84
+
85
+ Lint/UnusedMethodArgument:
86
+ AllowUnusedKeywordArguments: true
87
+ Exclude:
88
+ - lib/easy_talk/configuration.rb
89
+ - lib/easy_talk/schema_definition.rb
90
+
91
+ Style/DefWithParentheses:
92
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,108 @@
1
+ ## [3.3.1] - 2026-02-03
2
+
3
+ ### Added
4
+
5
+ - **RubyLLM Compatibility Extension**: Seamless integration between EasyTalk models and RubyLLM's tool and structured output features (#122)
6
+ - New `RubyLLMCompatibility` module adds class method `to_json_schema` for `with_schema` support
7
+ - New `RubyLLMToolOverrides` module for classes inheriting from `RubyLLM::Tool`
8
+ - Overrides `description` and `params_schema` methods to use EasyTalk schema definitions
9
+ - Automatically included when using `EasyTalk::Model`
10
+ - Tools inherit from `RubyLLM::Tool` directly, gaining full access to features like `halt`, `call`, `provider_params`
11
+ - New example files: `examples/ruby_llm/tools_integration.rb`, `examples/ruby_llm/structured_output.rb`
12
+
13
+ ### Changed
14
+
15
+ - **Documentation**: Updated README with improved examples and documentation
16
+
17
+ ## [3.3.0] - 2026-01-12
18
+
19
+ ### Added
20
+
21
+ - **Schema Objects in additionalProperties**: Extended `additionalProperties` to support type constraints and schema objects (#160)
22
+ - New syntax: `additional_properties Integer, minimum: 0, maximum: 100`
23
+ - Three supported forms: boolean, type class, or type with constraints
24
+ - Generates full JSON Schema for additional properties validation
25
+ - New methods: `ObjectBuilder#process_additional_properties`, `ObjectBuilder#build_additional_properties_schema`
26
+ - Fully backwards compatible with existing boolean usage
27
+
28
+ - **External $ref Support via $id**: Enhanced schema referencing with external URI support (#158)
29
+ - New configuration options:
30
+ - `base_schema_uri` - Base URI for auto-generating $id values
31
+ - `auto_generate_ids` - Enable automatic $id generation (default: false)
32
+ - `prefer_external_refs` - Use external URI in $ref when model has $id (default: false)
33
+ - Three-level schema ID resolution: explicit per-model → auto-generated → global
34
+ - Dynamic $ref templates conditionally use external URIs or local `#/$defs/ModelName` format
35
+ - Supports composition types (T::OneOf, T::AnyOf, T::AllOf) with external refs
36
+
37
+ - **T::Tuple Type for Positional Array Validation**: New tuple type for JSON Schema tuple support (#154, #155)
38
+ - New syntax: `property :coords, T::Tuple[Float, Float]`
39
+ - Generates JSON Schema with `items` as array of schemas
40
+ - Supports `additional_items: false`, `true`, or a type constraint
41
+ - Combines with array constraints: `min_items`, `max_items`, `unique_items`
42
+ - ActiveModel validation for runtime type checking at each position
43
+ - New files: `lib/easy_talk/types/tuple.rb`, `lib/easy_talk/builders/tuple_builder.rb`
44
+
45
+ - **Object-Level JSON Schema Keywords**: Support for schema-wide object constraints (#148, #151)
46
+ - New keywords: `patternProperties`, `minProperties`, `maxProperties`, `dependencies`, `dependentRequired`
47
+ - ActiveModel validators for object-level constraints via `ActiveModelSchemaValidation` module
48
+ - Auto-defined `count_present_properties` private method on model classes
49
+ - Thread-safe validator application with double-checked locking
50
+
51
+ ### Changed
52
+
53
+ - **Format Validation Enhancements**: Improved format validation accuracy and security (#157, #156, #144)
54
+ - **Scope Fix**: Format and pattern validations now only apply to string values (per JSON Schema spec)
55
+ - **URI/URL Validation**: Uses `URI.parse()` with `.absolute?` check instead of regex
56
+ - **Parsing-Based Validators**: Date, DateTime, and Time formats now use parsing instead of regex
57
+ - **Email Validation**: Replaced ReDoS-vulnerable regex with simple linear-time pattern
58
+ - New validation methods: `apply_uri_format_validation`, `apply_date_format_validation`, `apply_datetime_format_validation`, `apply_time_format_validation`
59
+
60
+ - **JSON Schema Equality for uniqueItems**: Implements correct JSON Schema equality semantics for array uniqueness (#152)
61
+ - Objects with same keys/values in different order are equal
62
+ - Numbers are mathematically equal (1 == 1.0)
63
+ - Type matters for non-numbers (true != 1, false != 0)
64
+ - New module: `EasyTalk::JsonSchemaEquality` with `normalize()` and `duplicates?()` methods
65
+ - MAX_DEPTH = 100 limit to prevent SystemStackError on deeply nested structures
66
+
67
+ - **Array Presence Validation**: Required array properties now properly reject nil values (#140)
68
+ - New method: `apply_array_presence_validation()` for array-specific nil checks
69
+ - Rejects nil but allows empty arrays `[]`
70
+ - Aligns with JSON Schema spec: 'optional' means property can be omitted, not that nil is accepted
71
+
72
+ ### Fixed
73
+
74
+ - **Default Additional Properties Configuration**: Fixed `default_additional_properties` config option being ignored (#142)
75
+ - Both `ObjectBuilder` and `SchemaDefinition` now use configured default
76
+ - Added schema hash duplication to prevent mutation side effects
77
+
78
+ - **Property Name Validation**: Fixed validation incorrectly applying to JSON output name (`:as` constraint) instead of Ruby property name (#143)
79
+ - `validate_property_name()` now validates Ruby name only
80
+ - Allows using `:as` for JSON-LD (@type, @id), JSON Schema ($id, $ref), and other special JSON keys
81
+
82
+ - **Method Redefinition Warning**: Fixed "method redefined" warning for `:property` keyword (#153)
83
+ - Removed `:property` from `KEYWORDS` constant since it has dedicated implementation
84
+
85
+ ### Internal
86
+
87
+ - **Type Introspection Improvements**: Enhanced type checking capabilities (#156)
88
+ - New helper methods: `array_type?()`, `boolean_union_type?()`, extracted `boolean_type?()`
89
+ - Improved encapsulation and testability
90
+
91
+ - **ValidationContext Decoupling**: Refactored validation adapter internals (#150)
92
+ - New plain data class `ValidationContext` for pre-computed validation values
93
+ - Replaces `__send__` usage with direct value passing
94
+ - Improved encapsulation and testability
95
+
96
+ - **Code Coverage Integration**: Added SimpleCov and Codecov for test coverage tracking
97
+ - Local HTML reports via SimpleCov
98
+ - CI badge reporting via Codecov
99
+ - Coverage uploads on Ruby 3.4.7 builds only
100
+
101
+ - **Test Infrastructure**: Comprehensive test expansion (~1800 lines of new tests)
102
+ - New test files: `external_ref_spec.rb`, `additional_properties_schema_spec.rb`, `tuple_validation_spec.rb`, `json_schema_equality_spec.rb`
103
+ - Enhanced builder test coverage
104
+ - Improved JSON Schema compliance testing
105
+
1
106
  ## [3.2.0] - 2025-12-28
2
107
 
3
108
  ### Added