GCWing / GCWing/OpenBitFun

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

Offen Anfängerfreundlich
#2,570 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
2.2k
Forks
229
Ø Merge
2 Std. 46 Min.
Gemergte PRs (30 T.)
577

Beschreibung

## 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start at src/crates/assembly/core/src/product_runtime.rs:614 and compare the declaration with the opencode-plugin-host feature gate in the crate's lib.rs. Check the sole consumer in plugin_host_http_routes_impl.rs, then verify that feature-less sdk-host test builds no longer report the dead_code warning while plugin-host builds retain the function.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
build-system, testing-qa
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
88/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.