← Back to Pull requests

Add Rust adapters for core node components #10

Open
Copilot opened this pull request with 233 lines diff across 8 files
View on GitHub
Copilot Copilot commented on Oct 13, 2026 04:55 UTC
Author

Introduce a Rust-first validation path and pure Rust adapters for the project’s core node component kinds, without restoring Deno CI.

  • Component adapters: Add typed wrappers for all 23 registered core node kinds, including shared identity, active state, and transform defaults.

  • Rust tooling: Add a Cargo workspace and replace the Deno workflow/config with Rust formatting, Clippy, and test checks.

  • Example:

  •   let mesh = MeshNode::new("mesh-1");
      assert_eq!(mesh.kind(), "mesh");
      

    <!-- gk-ai-analysis-start:03e7199d3e1e69f730bdd1a4e1b53e81c633455b -->
    <!-- gk-ai-analysis-data:eyJzdW1tYXJ5IjoiSW50cm9kdWNlIHB1cmUgUnVzdCBhZGFwdGVycyBmb3IgY29yZSBub2RlIGNvbXBvbmVudHMgYW5kIHJlcGxhY2UgdGhlIERlbm8gQ0kgd29ya2Zsb3cgd2l0aCBhIFJ1c3Qgd29ya3NwYWNlIGFuZCB2YWxpZGF0aW9uIHBpcGVsaW5lLiIsImtleUluc2lnaHRzIjpbeyJ0aXRsZSI6IlJ1c3QgTm9kZSBBZGFwdGVycyIsImRlc2NyaXB0aW9uIjoiQWRkZWQgYSBuZXcgUnVzdCBjcmF0ZSBgaHlwZXJmeS1jb21wb25lbnRzYCB3aGljaCBkZWZpbmVzIGdlbmVyaWMgbm9kZSB3cmFwcGVycywgZGVmYXVsdCB0cmFuc2Zvcm1zLCBhbmQgemVyby1zaXplZCBjb21wb25lbnQgbWFya2VycyBmb3IgMjMgY29yZSBub2RlIGtpbmRzLiIsInNldmVyaXR5IjoibWVkaXVtIiwiZmlsZVBhdGgiOiJydXN0L2NvbXBvbmVudHMvc3JjL2xpYi5ycyIsImxpbmVTdGFydCI6NSwibGluZUVuZCI6NDd9LHsidGl0bGUiOiJDb21wb25lbnQgUmVnaXN0cnkgTWFjcm8iLCJkZXNjcmlwdGlvbiI6IkltcGxlbWVudGVkIGEgZGVjbGFyYXRpdmUgbWFjcm8gYGRlZmluZV9jb21wb25lbnRzIWAgdG8gdW5pZm9ybWx5IGdlbmVyYXRlIGNvcmUgbm9kZSBjb21wb25lbnQgbWFya2Vycywgd3JhcHBlciB0eXBlIGFsaWFzZXMsIGFuZCBhIGNvbnN0YW50IGFycmF5IG9mIGFsbCBjb21wb25lbnQga2luZHMuIiwic2V2ZXJpdHkiOiJsb3ciLCJmaWxlUGF0aCI6InJ1c3QvY29tcG9uZW50cy9zcmMvbGliLnJzIiwibGluZVN0YXJ0Ijo0OSwibGluZUVuZCI6ODl9LHsidGl0bGUiOiJDSSBXb3JrZmxvdyBNaWdyYXRpb24iLCJkZXNjcmlwdGlvbiI6IlJlbW92ZWQgdGhlIGV4aXN0aW5nIERlbm8gQ0kgd29ya2Zsb3cgYW5kIGludHJvZHVjZWQgYSBzdGFuZGFyZCBSdXN0IEdpdEh1YiBBY3Rpb25zIHdvcmtmbG93IHRvIHJ1biBgY2FyZ28gZm10YCwgYGNsaXBweWAsIGFuZCB0ZXN0cy4iLCJzZXZlcml0eSI6ImxvdyIsImZpbGVQYXRoIjoiLmdpdGh1Yi93b3JrZmxvd3MvcnVzdC55bWwiLCJsaW5lU3RhcnQiOjEsImxpbmVFbmQiOjI3fV0sImlzc3VlcyI6W10sInN1Z2dlc3Rpb25zIjpbXSwic2VjdXJpdHkiOltdfQ== -->
    <!-- gk-ai-analysis-end:03e7199d3e1e69f730bdd1a4e1b53e81c633455b -->

    <!-- gitkraken-review-badge-begin -->
    ---
    ![Open with GitKraken](<https://gitkraken.dev/review/github/Hyperfy1/hyperfy/pull/10?source=pr_review_chip>)
    <!-- gitkraken-review-badge-end -->

    Diff: 233 lines (+182 / -51) across 8 files Reviewer: tjkilgore93-stack Review duration: 54312m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.58) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.58 · 233 lines diff across 8 files
    0.58
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.64 · 4 substantive comment(s)
    0.64
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    70%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.326
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    12 items
    vercel[bot] vercel[bot] commented on Oct 13, 2026 04:55 UTC
    Bot

    [vc]: #jvgx2Vm/nSI4AquUeRhDkALEnz6/y0u6YPTyRts59As=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJoeXBlcmZ5IiwicHJvamVjdElkIjoicHJqX2ZJVUFwd0ZaeHVNVUlJQmdtWWZrdFNJQUJVRXciLCJyb290RGlyZWN0b3J5IjoiJDovL2h5cGVyZnk6Ly8kIiwibGl2ZUZlZWRiYWNrIjp7InJlc29sdmVkIjowLCJ1bnJlc29sdmVkIjowLCJ0b3RhbCI6MCwibGluayI6IiJ9LCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vaHlwZXJmeWEvaHlwZXJmeS83UXhGQVBRNnoxREp5OVZuVFlBRTVueXI3bjU1IiwicHJldmlld1VybCI6IiIsIm5leHRDb21taXRTdGF0dXMiOiJGQUlMRUQifV19
    The latest updates on your projects. Learn more about Vercel for GitHub.

    | Project | Deployment | Actions | Updated |
    | :--- | :----- | :------ | :------ |
    | <a href="https://vercel.com/hyperfya/hyperfy"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_fIUApwFZxuMUIIBgmYfktSIABUEw&teamId=team_eYOro5HQoHZ4jG6A3dTBtPNo&s=32" width="16" height="16" align="middle" alt="" /></sup></a> hyperfy | !Error Error | | <relative-time datetime="2026-10-13T04:58:52.752Z">Oct 13, 2026 4:58am UTC</relative-time> |

    Copilot Copilot commented on code on Oct 13, 2026 07:29 UTC
    Code Review
    .github/workflows/rust.yml:1
    @@ -0,0 +1,27 @@
    +name: Rust
    +
    +on:
    +  push:
    +    branches: ["main"]
    +  pull_request:
    +    branches: ["main"]
    +
    +permissions:
    +  contents: read
    +
    +jobs:
    +  validate:
    +    runs-on: ubuntu-latest
    +    steps:
    +      - name: Checkout repository
    +        uses: actions/checkout@v4
    +      - name: Install stable Rust
    +        run: |
    +          rustup toolchain install stable --profile minimal --component clippy --component rustfmt
    +          rustup default stable
    +      - name: Check formatting
    +        run: cargo fmt --all -- --check
    +      - name: Run Clippy
    +        run: cargo clippy --workspace --all-targets -- -D warnings
    +      - name: Run tests
    +        run: cargo test --workspace

    The replacement CI now validates only the new Rust crate, so the production JavaScript lint and test suite no longer runs in any workflow. In particular, npm test covers build/hosting entitlement and duplicate reward-claim behavior (test/monetization-progression.test.js:33-61,124-132); Rust tests cannot catch regressions there. Keep the Cargo checks, but install Node dependencies and run the existing npm run lint and npm test scripts as part of PR validation.

    Copilot Copilot commented on code on Oct 13, 2026 07:29 UTC
    Code Review
    rust/components/src/lib.rs:1
    @@ -0,0 +1,137 @@
    +//! Pure Rust adapters for the core node component identities and shared node data.
    +
    +use std::marker::PhantomData;
    +
    +pub trait Component {
    +    const KIND: &'static str;
    +}
    +
    +#[derive(Clone, Debug, PartialEq)]
    +pub struct NodeTransform {
    +    pub position: [f64; 3],
    +    pub rotation: [f64; 4],
    +    pub scale: [f64; 3],
    +}
    +
    +impl Default for NodeTransform {
    +    fn default() -> Self {
    +        Self {
    +            position: [0.0; 3],
    +            rotation: [0.0, 0.0, 0.0, 1.0],
    +            scale: [1.0; 3],
    +        }
    +    }

    This four-number identity value is a quaternion, but the core node contract names it quaternion; rotation is a separate Euler value (src/core/nodes/Node.js:61-77,411-420). Calling this field rotation makes the adapter incompatible with the shared node shape and can cause consumers to map [x, y, z, w] to the Euler API. Rename it to quaternion, or model Euler rotation separately if that is the intended representation.

    Copilot Copilot commented on code on Oct 13, 2026 07:29 UTC
    Code Review
    rust/components/src/lib.rs:1
    @@ -0,0 +1,137 @@
    +//! Pure Rust adapters for the core node component identities and shared node data.
    +
    +use std::marker::PhantomData;
    +
    +pub trait Component {
    +    const KIND: &'static str;
    +}
    +
    +#[derive(Clone, Debug, PartialEq)]
    +pub struct NodeTransform {
    +    pub position: [f64; 3],
    +    pub rotation: [f64; 4],
    +    pub scale: [f64; 3],
    +}
    +
    +impl Default for NodeTransform {
    +    fn default() -> Self {
    +        Self {
    +            position: [0.0; 3],
    +            rotation: [0.0, 0.0, 0.0, 1.0],
    +            scale: [1.0; 3],
    +        }
    +    }
    +}
    +
    +#[derive(Clone, Debug, PartialEq)]
    +pub struct NodeWrapper<C: Component> {
    +    pub id: String,
    +    pub active: bool,
    +    pub transform: NodeTransform,
    +    component: PhantomData<C>,
    +}
    +
    +impl<C: Component> NodeWrapper<C> {
    +    pub fn new(id: impl Into<String>) -> Self {
    +        Self {
    +            id: id.into(),
    +            active: true,
    +            transform: NodeTransform::default(),
    +            component: PhantomData,
    +        }
    +    }
    +
    +    pub fn kind(&self) -> &'static str {
    +        C::KIND
    +    }
    +}
    +
    +macro_rules! define_components {
    +    ($($marker:ident => $wrapper:ident => $kind:literal),+ $(,)?) => {
    +        $(
    +            #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
    +            pub struct $marker;
    +
    +            impl Component for $marker {
    +                const KIND: &'static str = $kind;
    +            }
    +
    +            pub type $wrapper = NodeWrapper<$marker>;
    +        )+
    +
    +        pub const COMPONENT_KINDS: &[&str] = &[$(<$marker as Component>::KIND),+];
    +    };
    +}
    +
    +define_components! {
    +    Group => GroupNode => "group",
    +    Mesh => MeshNode => "mesh",
    +    SkinnedMesh => SkinnedMeshNode => "skinnedmesh",
    +    Lod => LodNode => "lod",
    +    Audio => AudioNode => "audio",
    +    Video => VideoNode => "video",
    +    Image => ImageNode => "image",
    +    Snap => SnapNode => "snap",
    +    Prim => PrimNode => "prim",
    +    Avatar => AvatarNode => "avatar",
    +    Action => ActionNode => "action",
    +    Anchor => AnchorNode => "anchor",
    +    Nametag => NametagNode => "nametag",
    +    Particles => ParticlesNode => "particles",
    +    Sky => SkyNode => "sky",
    +    Ui => UiNode => "ui",
    +    UiView => UiViewNode => "uiview",
    +    UiText => UiTextNode => "uitext",
    +    UiImage => UiImageNode => "uiimage",
    +    Controller => ControllerNode => "controller",
    +    RigidBody => RigidBodyNode => "rigidbody",
    +    Collider => ColliderNode => "collider",
    +    Joint => JointNode => "joint",
    +}
    +
    +#[cfg(test)]
    +mod tests {
    +    use super::*;
    +
    +    #[test]
    +    fn wrapper_uses_core_node_defaults_and_component_kind() {
    +        let node = MeshNode::new("mesh-1");
    +
    +        assert_eq!(node.id, "mesh-1");
    +        assert!(node.active);
    +        assert_eq!(node.kind(), "mesh");
    +        assert_eq!(node.transform, NodeTransform::default());
    +    }
    +
    +    #[test]
    +    fn registry_matches_all_core_node_component_kinds() {
    +        assert_eq!(
    +            COMPONENT_KINDS,
    +            &[

    This test repeats the Rust macro's literals rather than checking the production registry in src/core/nodes/index.js, so JavaScript and Rust can drift while the assertion remains green. The test name therefore overstates the validation it provides; derive both registries from a shared manifest or compare this list against the actual core registry.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 13, 2026 07:29 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟡 Changes recommended

    JavaScript validation is removed from CI, and the Rust transform API mislabels quaternion data as rotation.

    <details open>
    <summary><strong>3 open findings</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Restore JavaScript lint and test coverage in CI · New

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Use quaternion field name for quaternion values · New

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Validate Rust registry against the production core registry · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Adds a Rust workspace with typed adapters for the 23 core node kinds and Rust-focused CI validation.

    Changes:

  • Adds shared Rust node wrappers, transforms, registry, and tests.

  • Adds Cargo workspace metadata and Rust CI checks.

  • Removes Deno configuration/CI and ignores Rust build output.
  • | File | Description |
    | ---- | ----------- |
    | rust/​components/​src/​lib.rs | Defines component adapters and tests. |
    | rust/​components/​Cargo.toml | Configures the components crate. |
    | Cargo.toml | Defines the Cargo workspace. |
    | Cargo.lock | Locks workspace packages. |
    | .github/​workflows/​rust.yml | Adds Rust CI validation. |
    | .github/​workflows/​deno.yml | Removes Deno CI. |
    | deno.json | Removes Deno lint configuration. |
    | .gitignore | Ignores Cargo build output. |
    </details>

    🧠 Review effort: Balanced

    ---

    💡 <a href="/Hyperfy1/hyperfy/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    tjkilgore93-stack tjkilgore93-stack approved these changes on Oct 13, 2026 07:58 UTC
    Approved Reviewer

    Approved these changes.

    tjkilgore93-stack tjkilgore93-stack approved these changes on Oct 14, 2026 07:59 UTC
    Approved Reviewer

    Approved these changes.

    tjkilgore93-stack tjkilgore93-stack approved these changes on Oct 15, 2026 22:38 UTC
    Approved Reviewer

    Approved these changes.

    tjkilgore93-stack tjkilgore93-stack approved these changes on Oct 15, 2026 22:39 UTC
    Approved Reviewer

    Approved these changes.

    tjkilgore93-stack tjkilgore93-stack approved these changes on Oct 15, 2026 22:39 UTC
    Approved Reviewer

    Approved these changes.

    tjkilgore93-stack tjkilgore93-stack approved these changes on Nov 11, 2026 04:14 UTC
    Approved Reviewer

    Approved these changes.

    Assignees
    Copilot Copilot
    Labels
    risk: low confidence: 70.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57.9% (MEDIUM) · Higher = larger blast radius
    57.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 70.6% · Lower = rushed or shallow review
    70.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17% · Safe to merge
    17%