Repository navigation
fix(rql): a nullable tool parameter without a default is not required; screenshot-isolated's target is non-nullable - #1214
Merged
Conversation
…; screenshot-isolated's target is non-nullable RqlToolBinding computed required as !HasDefaultValue && !IsOptional && not Nullable<T>, so an NRT-annotated reference parameter (string?, GameObjectRef?) without a default was required in the Rql layer but optional in ReflectorNet's Json layer. Use ReflectorNet's MethodUtils.IsParameterNullable, the same rule as the Json layer (mirrors Godot-MCP#549). Nullability never adds "null" to a schema type. screenshot-isolated declared GameObjectRef? gameObjectRef without a default but rejects null, so it is now GameObjectRef: required in both layers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…layer test, accurate required-rule comment Skipped: one shared IsParameterRequired in ReflectorNet (cross-repo, needs a ReflectorNet release); moving ScreenshotIsolatedRequiresItsTarget to ScreenshotIsolatedTests (would duplicate the binding save/restore setup; this suite already checks screenshot-isolated's schema). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…torNet's schema shape), <none> placeholder so a null-to-"null" text bug shows, null! in ScreenshotNoGraphicsTests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Owner rule: a tool parameter declared nullable (NRT
T?orNullable<T>) without a default is not required. A non-nullable parameter without a default is required. A default or[Optional]makes a parameter not required. Nullability never adds"null"to a schematype: GitHub Copilot and Gemini turn type arrays into""/0/false/[]. This mirrors IvanMurzak/Godot-MCP#549.RqlToolBinding.Buildused to computerequiredas!HasDefaultValue && !IsOptional && Nullable.GetUnderlyingType(type) == null. That ignored NRT?on reference types, so astring?orGameObjectRef?without a default was required in the Rql layer but optional in ReflectorNet's Json layer. It now usescom.IvanMurzak.ReflectorNet.Utils.MethodUtils.IsParameterNullable(p)(ReflectorNet 5.6.1, through a using-alias), the check ReflectorNet'sJsonSchemaalso uses. An omitted or JSON-nullnullable argument still reaches the method asnull: McpPlugin binds an omitted key through ReflectorNet'sMethodWrapper(default, else null), andTryConvertmaps JSON null to null.typeis unchanged; nullability only removes the parameter fromrequired.Signature audit (every
[AiTool]method in the package andextensions/)extensions/defines no[AiTool]methods (they are RQL modules). The 29 tool methods incom.ivanmurzak.unity.mcpwere audited by script and checked again by a reviewer.Changed signature
screenshot-isolated(Editor/Scripts/API/Tool/Screenshot.Isolated.cs):GameObjectRef? gameObjectRef→GameObjectRef gameObjectRef. It had no default, and the body returned"[Error] gameObjectRef is required.". It is now required in both layers. In Rql it was already required, because the old rule ignored NRT. In Json, ReflectorNet treated it as optional. The null guard stays, since an explicit JSONnullcan still arrive.Remaining nullable parameters without a default: none. Every other
T?tool parameter has a default, so it was already optional and stays so. Examples:screenshot-camera'sGameObjectRef? cameraRef = null(falls back toCamera.main), andscreenshot-isolated'sbool? includeChildren = trueand other options.Tests (EditMode,
RqlToolBindingTests)New test tool
Optionals(string name, string? note, GameObjectRef? gameObjectRef, int? count, int times = 1):OnlyNonNullableParametersWithoutDefaultsAreRequired(Rql and Json):required == ["name"]. NRT reference without a default,Nullable<int>without a default and a defaulted parameter are not required; a non-nullable parameter without a default is required. The schema contains no"null".NullableParametersKeepTheirPlainRqlType: in RQL,note/gameObjectRefarestringandcountisinteger.OmittedOrNullNullableArgumentsReachTheMethodAsNull: omitted, explicit-null and given values (includingunity.find("Alpha")).ScreenshotIsolatedRequiresItsTarget(Rql and Json):required == ["gameObjectRef"].ScreenshotIsolatedTests/ScreenshotNoGraphicsTests: an explicitnull!where they pass null on purpose.Local verification in real Unity 2022.3.62f3, EditMode, filter
RqlToolBindingTests|ScreenshotIsolatedTests|ScreenshotNoGraphicsTests|RunToolRqlResultTests|ScreenshotImageResultTests|CSharpExecResultTests|ScreenshotCameraTests|ChainRecordTests:-toolDataLayer Rql: 68 passed, 0 failed, 12 skipped. The skipped tests need a graphics device under-nographics.-toolDataLayer Json: 67 passed, 0 failed, 12 skipped (same reason).Chain fixtures: not re-recorded, because they did not change. The fixtures are recorded in the Rql layer, where
screenshot-isolatedalready requiredgameObjectRef. A fresh in-process recording (-CHAIN_RECORD_OUT,battery.json) was run throughchain_fixture.py canonicalize, anddiffagainsttests/chain-fixtures/2022.3.62f3/tools.jsonlreports no differences (exit 0).Quality stages
simplify: added a sharedRequiredtest helper, split the RQL-only type checks out of the per-layer test, and corrected the wording of the required-rule comment. Skipped: a sharedIsParameterRequiredin ReflectorNet, which would be a cross-repo change needing a ReflectorNet release. The Rql layer also counts[Optional], which ReflectorNet's schema does not; no current tool uses[Optional]without a default.code review(report-only high fan-out): found no binding bugs. Fixed: a<none>test placeholder, so a null-to-"null"text bug would show;null!inScreenshotNoGraphicsTests(CS8625); type checks moved into an RQL-only test, because Json uses ReflectorNet's schema shape.🤖 Generated with Claude Code