feat(code-mode): drop Lab action support#74
Conversation
📝 WalkthroughWalkthroughThis PR completes the removal of Lab-action support from Code Mode, making it upstream-only. Tool ID parsing now rejects ChangesCode Mode Lab-Action Removal
Implementation Plan Documentation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/lab/src/dispatch/gateway/code_mode.rs`:
- Around line 1160-1180: The test code_search_returns_only_upstream_candidates
currently constructs CodeModeBroker with None so search short-circuits; update
the test to create and seed a real GatewayManager/pool and pass it into
CodeModeBroker::new instead of None (or otherwise ensure the broker is wired to
an upstream manager), call broker.search(...) as before, assert results is
non-empty, and add an assertion that at least one candidate.id
starts_with("upstream::") (while keeping the existing assertion that no id
starts_with("lab::")). Use the existing symbols CodeModeBroker::new,
broker.search, and the test function
code_search_returns_only_upstream_candidates to locate where to inject the
manager/pool setup.
In `@docs/superpowers/plans/2026-05-25-code-mode-v2-drop-lab-actions.md`:
- Line 19: The table row is broken by unescaped pipe characters in the inline
command text referencing CLI subcommands (gateway code search|schema|exec);
update the cell in the markdown so the pipes are escaped (e.g., replace | with
\|) or wrap the entire command text in a code span/backticks without raw |
characters, ensuring the reference to crates/lab/src/cli/gateway.rs and the CLI
subcommands (gateway code search, schema, exec) remains intact and the table
renders correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e0349e2d-3675-4444-9afe-1c9c5f9a851a
📒 Files selected for processing (5)
crates/lab/src/cli/gateway.rscrates/lab/src/dispatch/gateway/code_mode.rscrates/lab/src/main.rscrates/lab/src/mcp/server.rsdocs/superpowers/plans/2026-05-25-code-mode-v2-drop-lab-actions.md
| async fn code_search_returns_only_upstream_candidates() { | ||
| let registry = super::ToolRegistry::new(); | ||
| let broker = super::CodeModeBroker::new(®istry, None); | ||
|
|
||
| let err = broker | ||
| .schema( | ||
| "lab::gateway.danger", | ||
| super::CodeModeCaller::Scoped { | ||
| scopes: vec!["lab".to_string()], | ||
| subject: Some("subject-1".to_string()), | ||
| }, | ||
| super::CodeModeSurface::Mcp { | ||
| expose_builtin_services: true, | ||
| allow_destructive_actions: true, | ||
| }, | ||
| let results = broker | ||
| .search( | ||
| "movie.search", | ||
| 10, | ||
| super::CodeModeCaller::TrustedLocal, | ||
| super::CodeModeSurface::Cli, | ||
| ) | ||
| .await | ||
| .expect_err("schema for admin-only action must require admin scope"); | ||
| .expect("search ok"); | ||
|
|
||
| assert_eq!(err.kind(), "forbidden"); | ||
| for candidate in &results { | ||
| assert!( | ||
| !candidate.id.starts_with("lab::"), | ||
| "found lab:: candidate after drop: {}", | ||
| candidate.id | ||
| ); | ||
| } |
There was a problem hiding this comment.
Exercise the upstream search path in this regression test.
Lines 1161-1172 construct CodeModeBroker with None, so search() exits with Ok(Vec::new()) before any candidate filtering runs. This will stay green even if lab:: results leak back in once a GatewayManager is configured. Seed a manager/pool here and assert at least one returned id is upstream::....
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/lab/src/dispatch/gateway/code_mode.rs` around lines 1160 - 1180, The
test code_search_returns_only_upstream_candidates currently constructs
CodeModeBroker with None so search short-circuits; update the test to create and
seed a real GatewayManager/pool and pass it into CodeModeBroker::new instead of
None (or otherwise ensure the broker is wired to an upstream manager), call
broker.search(...) as before, assert results is non-empty, and add an assertion
that at least one candidate.id starts_with("upstream::") (while keeping the
existing assertion that no id starts_with("lab::")). Use the existing symbols
CodeModeBroker::new, broker.search, and the test function
code_search_returns_only_upstream_candidates to locate where to inject the
manager/pool setup.
| |---|---|---| | ||
| | `crates/lab/src/dispatch/gateway/code_mode.rs` | Code Mode broker, ID parsing, runner protocol, schema construction, TS bindings | Heavy delete + edit | | ||
| | `crates/lab/src/mcp/server.rs` | MCP tool registration + dispatch for `code_search`/`code_schema`/`code_execute` | Light edit | | ||
| | `crates/lab/src/cli/gateway.rs` | CLI Code Mode subcommands (`gateway code search|schema|exec`) | Light edit (if any `lab::` branches exist) | |
There was a problem hiding this comment.
Fix broken table row caused by unescaped pipe characters.
The inline command text includes | separators, which creates extra table cells and breaks rendering. Escape the pipes or wrap the whole cell content in backticks without raw | characters.
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 19-19: Table column count
Expected: 3; Actual: 5; Too many cells, extra data will be missing
(MD056, table-column-count)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/superpowers/plans/2026-05-25-code-mode-v2-drop-lab-actions.md` at line
19, The table row is broken by unescaped pipe characters in the inline command
text referencing CLI subcommands (gateway code search|schema|exec); update the
cell in the markdown so the pipes are escaped (e.g., replace | with \|) or wrap
the entire command text in a code span/backticks without raw | characters,
ensuring the reference to crates/lab/src/cli/gateway.rs and the CLI subcommands
(gateway code search, schema, exec) remains intact and the table renders
correctly.
Summary
lab::<service>.<action>ID support from Code Mode socode_search,code_schema, andcode_executeoperate on proxied upstream MCP tools only.lab::IDs with a structuredunknown_toolerror and points agents totool_executefor Lab actions.expose_builtin_services, and the Code Mode Lab-action authorization path while keeping upstream JSON Schema TypeScript bindings.Bead:
lab-elme3.1Test plan
cargo test -p labby --all-features code_mode -- --nocapturecargo test -p labby --all-features mcp::server -- --nocapturecargo test -p labby --all-features --test code_mode_runner -- --nocapturecargo check --manifest-path crates/lab/Cargo.toml --all-featurescargo fmt --all -- --checkcargo clippy --workspace --all-features -- -D warningscargo test -p labby --lib --all-features -- --test-threads=1cargo test --workspace --all-features -- --test-threads=1labby 0.17.4, verified/healthand/ready, confirmedcode_searchreturns upstream ids only, confirmedcode_schema id=lab::radarr.movie.searchreturnsunknown_toolguidance, and rancode_execute12-readonly plus chained fanout smokes successfully.Summary by cubic
Drops Lab action IDs from Code Mode and removes
code_schema. Code Mode now supports only upstream tools viacode_search(JS-sandbox catalog filtering) andcode_execute; anylab::ID returnsunknown_toolwith a hint to usetool_execute.Refactors
lab::ID parsing; onlyupstream::server::toolis supported.code_schema; docs and CLI help updated forcode_search+code_executeonly.code_searchruns constrained JS over an inlined catalog; 256KB soft cap and 512KB hard cap with stable pruning.CodeModeConfigcaps (max_response_bytes,max_response_tokens) and response envelope trimming.code_mode_timeoutandcode_mode_fuel_exhaustedmap to HTTP 504.code_mode_wasmviajavy+wasmtime; addedscripts/refresh-javy-plugin.sh.Mcp { allow_destructive_actions }; refreshed MCP descriptions.libclang-devfor Code Mode builds, lighter release image,cargo-deny/license updates, test fixes.Migration
tool_executefor Lab actions instead oflab::Code Mode IDs.tool_execute(name="radarr", arguments={action:"movie.search", params:{query:"Matrix"}}).code_searchto filter the upstream catalog, then pass returnedupstream::server::toolIDs tocode_execute. Remove anycode_schemacalls.Written for commit ac5a374. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Breaking Changes
Documentation