Refine Nexus bridge schemas and typing#46
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refines the Unity Hierarchy Manager JSON schema into action-specific variants and tightens up the Python bridge’s internal typing, while adding tests to cover new routing/schema behaviors.
Changes:
- Reworked
unity_hierarchy_managerinputSchemafrom a single schema with anactionenum into aoneOfof action-specific variants (including aliases and stricter parameter requirements). - Introduced shared internal
TypedDict/type aliases for JSON-RPC payloads and updated routing/transport code to use them. - Added/extended unit tests to validate schema structure and routing behavior (including
set_sibling_indexand instance_id0handling).
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Editor/nexus_bridge/schemas.py | Converts hierarchy manager schema to oneOf variants and adds stronger internal typing for tool/resource definitions. |
| Editor/nexus_bridge/routing.py | Refactors helpers to use typed JSON-RPC payloads and adjusts transform/test-wait logic. |
| Editor/nexus_bridge/_types.py | Adds internal TypedDict/type aliases for JSON-RPC structures and bridge payloads. |
| Editor/nexus_bridge/_transport.py | Updates call_unity signatures/structures to use the shared types and structured error payloads. |
| Editor/tests/test_schemas.py | Adds tests asserting the new action-variant schema behavior for hierarchy manager. |
| Editor/tests/test_routing.py | Adds routing tests for set_sibling_index and transform application with instance_id 0. |
Files not reviewed (2)
- Editor/nexus_bridge/_types.py.meta: Generated file
- Editor/tests/test_schemas.py.meta: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request introduces a new private types module for the NexusUnity Python bridge and refactors the codebase to use these shared type definitions. It also significantly expands the input schema for the core Unity scene manager tool, providing more precise and structured validation for various GameObject operations. Additionally, the test suite for routing logic is expanded with new test cases to improve coverage and reliability.
Key changes include:
Type System Improvements
Added a new
_types.pymodule defining shared type aliases andTypedDictclasses for JSON-RPC requests, responses, errors, tool/resource definitions, and other payloads. All relevant modules now import and use these types for better type safety and clarity. [1] [2] [3] [4] [5]Refactored the
call_unityfunction and related code to use the new type definitions (JsonObject,JsonRpcRequest,JsonRpcResponse,JsonRpcError), improving error handling consistency and type correctness. [1] [2]Schema and Validation Enhancements
Overhauled the
inputSchemafor theunity_scene_managertool inschemas.pyto useoneOfwith detailed sub-schemas for each supported action (e.g., create, destroy, duplicate, rename, transform, set active, set parent, set sibling index), providing more granular input validation and documentation for tool consumers.Updated all static tool and resource definitions to use the new
ToolDefinitionandResourceDefinitiontypes, ensuring consistent schema typing. [1] [2]Test Suite Improvements