riffer 0.47.0 → 0.47.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63cc9b38354166dc44a162e7fb8cc168cf14e950d8cbbba582fb9710721c25a5
4
- data.tar.gz: 8a386abc38526d731d7253efbab2c8e2ab345da712762d605f469c5708ec5cca
3
+ metadata.gz: 4ac69c8c20b892c53242b0fb792aee2ee1ce5da1ab02b1c53536fa8d1c006f08
4
+ data.tar.gz: 0fa02ebc739e1968167e517a41d4f0a2cabff5a5845862ac78980d207638c6cd
5
5
  SHA512:
6
- metadata.gz: 9a36b54ef99b21ea74a8e215c3ba5abb70c2bf949e40bf15056209f9cc4875c62505406568fc5a258508d17735a5d92c360510a5092a4f158733feebd6f64fb4
7
- data.tar.gz: 69209c501af21331079d0e5374b4b41119619ddd81afa6debeb8e93da3955bb144370cb3c1b506411043de9544f070855c66ef62819d5affadc3d671410b906f
6
+ metadata.gz: 5c0363ce9dad27ccfc899d6c7f4e71123eaa9ae5ceec8e50387575f0642c7696f07de37cb987c45099aee999fe5ac39c8635f07f36efb784c3341bd8a4c6a6aa
7
+ data.tar.gz: 4b5d6209255a46d9abd52275021709740bf0e87676c20c3bd9240f12acddc7768a050391530970c2a2ed407dbdd27fb50a1b03e43caff8361ad6f28cc67884db
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.47.0"
2
+ ".": "0.47.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.47.1](https://github.com/janeapp/riffer/compare/riffer/v0.47.0...riffer/v0.47.1) (2026-09-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **params:** keep optional Hash params nullable in strict JSON Schema ([#433](https://github.com/janeapp/riffer/issues/433)) ([c7308fd](https://github.com/janeapp/riffer/commit/c7308fd15a3293877510e74c41662a68fac942df))
14
+ * **params:** raise for bare Hash and Array params under strict schemas ([#434](https://github.com/janeapp/riffer/issues/434)) ([174ad92](https://github.com/janeapp/riffer/commit/174ad92e7c765dc8833695ded9d2920f1ab27337))
15
+
8
16
  ## [0.47.0](https://github.com/janeapp/riffer/compare/riffer/v0.46.1...riffer/v0.47.0) (2026-09-11)
9
17
 
10
18
 
data/docs/AGENTS.md CHANGED
@@ -247,7 +247,7 @@ end
247
247
 
248
248
  #### Limitations
249
249
 
250
- Using both `of:` and a block raises `Riffer::ArgumentError`. Using `of:` with a non-primitive type (e.g. `of: Hash`) also raises `Riffer::ArgumentError`.
250
+ A `Hash` param requires a block, and an `Array` param requires a block or `of:`. Using both `of:` and a block raises `Riffer::ArgumentError`. Using `of:` with a non-primitive type (e.g. `of: Hash`) also raises `Riffer::ArgumentError`.
251
251
 
252
252
  Structured output is not compatible with streaming — calling `stream` on an agent with structured output configured raises `Riffer::ArgumentError`.
253
253
 
@@ -140,10 +140,14 @@ class Riffer::Params::Param
140
140
  # params are made nullable (<tt>["type", "null"]</tt>) so strict providers
141
141
  # distinguish absent from present; optional params with an +enum+ use +anyOf+
142
142
  # instead, since providers like Anthropic reject
143
- # <tt>{"type": ["string", "null"], "enum": [...]}</tt>.
143
+ # <tt>{"type": ["string", "null"], "enum": [...]}</tt>. Raises
144
+ # Riffer::ArgumentError when +strict+ and a Hash param has no block or an
145
+ # Array param has neither a block nor <tt>of:</tt>, since strict providers
146
+ # reject objects without +properties+ and arrays without +items+.
144
147
  #--
145
148
  #: (?strict: bool) -> Hash[Symbol, untyped]
146
149
  def to_json_schema(strict: false)
150
+ validate_strict_shape! if strict
147
151
  nullable = strict && !required
148
152
 
149
153
  if nullable && enum
@@ -168,9 +172,24 @@ class Riffer::Params::Param
168
172
  elsif self.type == Array && item_type
169
173
  schema[:items] = { type: TYPE_MAPPINGS[item_type] }
170
174
  elsif self.type == Hash && nested_params
171
- schema.merge!(nested_params.to_json_schema(strict: strict))
175
+ # The nested schema carries its own type: "object", which would clobber a nullable union.
176
+ schema.merge!(nested_params.to_json_schema(strict: strict).except(:type))
172
177
  end
173
178
 
174
179
  schema
175
180
  end
181
+
182
+ private
183
+
184
+ #--
185
+ #: () -> void
186
+ def validate_strict_shape!
187
+ if type == Hash && nested_params.nil?
188
+ raise Riffer::ArgumentError,
189
+ "#{name}: a Hash param requires a block defining its properties under strict schemas"
190
+ elsif type == Array && nested_params.nil? && item_type.nil?
191
+ raise Riffer::ArgumentError,
192
+ "#{name}: an Array param requires a block or of: defining its items under strict schemas"
193
+ end
194
+ end
176
195
  end
data/lib/riffer/params.rb CHANGED
@@ -128,6 +128,8 @@ class Riffer::Params
128
128
  # Converts all parameters to JSON Schema format. When +strict+ is true, every
129
129
  # property is listed in +required+ and optional ones are made nullable
130
130
  # instead, satisfying providers that enforce strict structured output schemas.
131
+ # Raises Riffer::ArgumentError when +strict+ and a Hash param (at any depth)
132
+ # has no block or an Array param has neither a block nor <tt>of:</tt>.
131
133
  #--
132
134
  #: (?strict: bool) -> Hash[Symbol, untyped]
133
135
  def to_json_schema(strict: false)
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Riffer
5
- VERSION = "0.47.0" #: String
5
+ VERSION = "0.47.1" #: String
6
6
  end
@@ -74,8 +74,17 @@ class Riffer::Params::Param
74
74
  # params are made nullable (<tt>["type", "null"]</tt>) so strict providers
75
75
  # distinguish absent from present; optional params with an +enum+ use +anyOf+
76
76
  # instead, since providers like Anthropic reject
77
- # <tt>{"type": ["string", "null"], "enum": [...]}</tt>.
77
+ # <tt>{"type": ["string", "null"], "enum": [...]}</tt>. Raises
78
+ # Riffer::ArgumentError when +strict+ and a Hash param has no block or an
79
+ # Array param has neither a block nor <tt>of:</tt>, since strict providers
80
+ # reject objects without +properties+ and arrays without +items+.
78
81
  # --
79
82
  # : (?strict: bool) -> Hash[Symbol, untyped]
80
83
  def to_json_schema: (?strict: bool) -> Hash[Symbol, untyped]
84
+
85
+ private
86
+
87
+ # --
88
+ # : () -> void
89
+ def validate_strict_shape!: () -> void
81
90
  end
@@ -54,6 +54,8 @@ class Riffer::Params
54
54
  # Converts all parameters to JSON Schema format. When +strict+ is true, every
55
55
  # property is listed in +required+ and optional ones are made nullable
56
56
  # instead, satisfying providers that enforce strict structured output schemas.
57
+ # Raises Riffer::ArgumentError when +strict+ and a Hash param (at any depth)
58
+ # has no block or an Array param has neither a block nor <tt>of:</tt>.
57
59
  # --
58
60
  # : (?strict: bool) -> Hash[Symbol, untyped]
59
61
  def to_json_schema: (?strict: bool) -> Hash[Symbol, untyped]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.47.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall