GCWing / GCWing/OpenBitFun

[Bug]: dead_code warning for fork_session_for_plugin in feature-less core test builds

Đã đóng Phù hợp với người mới
#2,570 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
2.3k
Fork
231
Merge trung bình
2 giờ 49 phút
Pull request đã merge (30 ngày)
589

Mô tả

## Summary

The upstream CI logs for `main` report a dead-code warning for `fork_session_for_plugin` in bitfun-core. Evidence from GitHub Actions run [33035362609](https://github.com/GCWing/BitFun/actions/runs/33035362609) — job "CLI Tests (ubuntu-latest)" and "CLI Tests (macos-15)" (also present in runs 33050974141 and 33047041028):

- `warning: function fork_session_for_plugin is never used` --> `src/crates/assembly/core/src/product_runtime.rs:614:21`

Cross-checking the crate: the only consumer of `CoreProductAgentRuntime::fork_session_for_plugin` is the plugin host HTTP routes implementation (`plugin_host_http_routes_impl.rs`), which is compiled under the `opencode-plugin-host` feature gate in the crate's `lib.rs`. Test builds that do not enable that feature — notably the sdk-host test compilation unit used by the CLI Tests jobs — therefore see a function with zero callers and report it as dead code.

## Root Cause Analysis

- The function is plugin-host-only by construction, but its declaration is unconditional. The crate's feature gate already scopes its sole consumer; the declaration itself was not scoped, so any build without `opencode-plugin-host` (including the sdk-host test unit on ubuntu/macos) flags it as `dead_code`. The warning is structural: every full CI run with the ubuntu/macos test units reproduces it.

## Proposed Fix

Gate the function with `#[cfg(feature = "opencode-plugin-host")]` at its declaration in `product_runtime.rs`, so:

- feature-less test builds (sdk-host test unit) stop emitting the dead-code warning;
- the plugin-host build keeps the function available for its single consumer.

No `#[allow(dead_code)]` suppression is involved.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu tại src/crates/assembly/core/src/product_runtime.rs:614 và so sánh khai báo với feature gate opencode-plugin-host trong lib.rs của crate. Kiểm tra nơi sử dụng duy nhất trong plugin_host_http_routes_impl.rs, sau đó xác minh rằng các bản build kiểm thử sdk-host không có feature აღარ còn báo cảnh báo dead_code, trong khi các bản build plugin-host vẫn giữ lại hàm.

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

Đánh giá

Công nghệ
rust
Lĩnh vực
build-system, testing-qa
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
88/100

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.