fix(mcp): range-check NDC arguments on the wire value before narrowing to f32

Đang mở
#419 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cristim đang làm issue này rồi.

Từ ngày 9/11/2026.

  • #427 của @cristim — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Read src/mcp/features/selection.rs, src/viewport/rect_pick.rs, and .project-docs/mcp.md, then check the linked pull request #427 for work already underway. First settle whether the range contract applies to the f64 wire value or the f32 value; done means documenting that decision and adding consistent tool descriptions and tests for every affected argument.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area/mcp effort/s impact/few priority/p3 severity/low triaged type/bug urgency/eventually

Problem

Raised by a CodeRabbit review of #404 and checked against the code. MCP tools that take normalised screen coordinates deserialise them as [f32; 2] (for example select_in_rect, src/mcp/features/selection.rs). serde rounds a value such as 1.00000001 to 1.0 before the range check (NdcRect::new in src/viewport/rect_pick.rs), so a value that is 1e-8 out of range is accepted as the boundary instead of returning invalid_params. The accepted rectangle is the same as the boundary, so the effect is negligible, but the contract says out-of-range values are refused.

This is the f32 convention across the MCP surface, so fixing it for one tool alone would be inconsistent.

Change

  • Decide whether the range contract is on the f64 wire value or the f32 value, and document it in .project-docs/mcp.md.
  • If the wire value: parse these fields as f64, check the range, then narrow, in one shared helper used by every tool with NDC or screen-fraction arguments; add a test with 1.00000001 for each.
  • If the f32 value: state that in the tool descriptions and the docs, and pin it with a test so it is a decision and not an accident.

Related: #404, #390.

Ngôn ngữ chính
Rust
Star
4
Fork
2
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
225

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cristim/AztecCraft

Tất cả issue của cristim/AztecCraft

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.