fix: align generated function grouping contract#13
Conversation
📝 WalkthroughWalkthroughThis PR refactors ChangesVirtual-to-Generated Worker Refactor
Documentation Updates
🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 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
🧹 Nitpick comments (2)
tests/rust_core.rs (1)
132-139: ⚡ Quick winConsider extracting duplicate note assertions into a helper function.
The same note assertion pattern appears in both the OpenAPI test (lines 132-139) and the new MCP test (lines 285-292). Extracting this into a helper function would improve maintainability and reduce duplication.
♻️ Proposed helper function
Add this helper at module level:
fn assert_conversion_notes_describe_engine_grouping( converted: &spec_to_worker::SpecToWorkerConversion, ) { assert!(converted .notes .iter() .any(|note| note.contains("normal iii functions backed by engine HTTP invocation"))); assert!(converted .notes .iter() .any(|note| note.contains("engine-runtime worker group; no worker process is started"))); }Then replace both assertion blocks with:
- assert!(converted - .notes - .iter() - .any(|note| note.contains("normal iii functions backed by engine HTTP invocation"))); - assert!(converted - .notes - .iter() - .any(|note| note.contains("engine-runtime worker group; no worker process is started"))); + assert_conversion_notes_describe_engine_grouping(&converted);Also applies to: 285-292
🤖 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 `@tests/rust_core.rs` around lines 132 - 139, Extract the duplicated note assertions into a module-level helper named assert_conversion_notes_describe_engine_grouping that accepts &spec_to_worker::SpecToWorkerConversion (the same type as converted) and performs both assert! checks for the two note substrings; add that function to the test module and replace the two duplicate assertion blocks in the OpenAPI and MCP tests (where they call converted.notes.iter().any(...)) with a single call to assert_conversion_notes_describe_engine_grouping(&converted).src/lib.rs (1)
332-403: 💤 Low valueConsider dropping the
modeparameter or promoting it to a constant.Both call sites pass the literal
"http_invocation"(lines 316 and 329), and the same string is duplicated inside this function asschema: "spec-to-worker.http-invocation.v1"(line 378) and insidespec_to_worker_metadataat line 569. Themodeargument is effectively dead today and the literal is repeated in three places.♻️ Suggested cleanup
+const HTTP_INVOCATION_MODE: &str = "http_invocation"; +const GENERATED_WORKER_SCHEMA: &str = "spec-to-worker.http-invocation.v1"; @@ -fn register_generated_worker( - iii: &iii_sdk::III, - spec: &SpecSource, - generated_functions: Vec<GeneratedHttpFunction>, - mode: &str, -) -> Result<SpecToWorkerConversion> { +fn register_generated_worker( + iii: &iii_sdk::III, + spec: &SpecSource, + generated_functions: Vec<GeneratedHttpFunction>, +) -> Result<SpecToWorkerConversion> { @@ - let manifest = GeneratedWorkerManifest { - schema: "spec-to-worker.http-invocation.v1".into(), + let manifest = GeneratedWorkerManifest { + schema: GENERATED_WORKER_SCHEMA.into(), @@ - mode: mode.into(), + mode: HTTP_INVOCATION_MODE.into(),Then update the two callers (and
spec_to_worker_metadata) to useHTTP_INVOCATION_MODE. Keepmodeas a parameter only if a non-HTTP mode is planned in the near term.🤖 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 `@src/lib.rs` around lines 332 - 403, The mode parameter is unused and duplicated as a literal; remove it or promote it to a constant: add a constant HTTP_INVOCATION_MODE (or similar) and replace all literal "http_invocation" call sites and uses (e.g., callers of register_generated_worker and spec_to_worker_metadata) to use that constant; update register_generated_worker signature to drop the mode parameter (or accept the new constant if you must keep the param), remove the duplicated literal occurrences inside register_generated_worker (and rely on the constant where needed), and adjust both callers and spec_to_worker_metadata to reference HTTP_INVOCATION_MODE so the string is centralized.
🤖 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 `@README.md`:
- Line 277: Update the user-facing product name in the README table entry:
replace the lowercase token `github mcp` with `GitHub mcp` so the row reading
"`github mcp` + `search_repos` | `github_mcp::search_repos`" becomes "`GitHub
mcp` + `search_repos` | `github_mcp::search_repos`", preserving the
`search_repos` and `github_mcp::search_repos` identifiers.
In `@tests/rust_core.rs`:
- Around line 281-284: The test indexes converted.manifest.functions without
ensuring it has elements; add a bounds check before accessing it (e.g., assert
that converted.manifest.functions is not empty or
assert_eq!(converted.manifest.functions.len(), expected) ) and then perform the
existing assertion on converted.manifest.functions[0].function_id to avoid a
potential panic in the test.
---
Nitpick comments:
In `@src/lib.rs`:
- Around line 332-403: The mode parameter is unused and duplicated as a literal;
remove it or promote it to a constant: add a constant HTTP_INVOCATION_MODE (or
similar) and replace all literal "http_invocation" call sites and uses (e.g.,
callers of register_generated_worker and spec_to_worker_metadata) to use that
constant; update register_generated_worker signature to drop the mode parameter
(or accept the new constant if you must keep the param), remove the duplicated
literal occurrences inside register_generated_worker (and rely on the constant
where needed), and adjust both callers and spec_to_worker_metadata to reference
HTTP_INVOCATION_MODE so the string is centralized.
In `@tests/rust_core.rs`:
- Around line 132-139: Extract the duplicated note assertions into a
module-level helper named assert_conversion_notes_describe_engine_grouping that
accepts &spec_to_worker::SpecToWorkerConversion (the same type as converted) and
performs both assert! checks for the two note substrings; add that function to
the test module and replace the two duplicate assertion blocks in the OpenAPI
and MCP tests (where they call converted.notes.iter().any(...)) with a single
call to assert_conversion_notes_describe_engine_grouping(&converted).
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a92eca4c-b6ac-4d62-96d9-3f839340645d
📒 Files selected for processing (4)
README.mddocs/research-note.mdsrc/lib.rstests/rust_core.rs
| | `xkcd live` + `get /{comicId}/info.0.json` | `xkcd_live::get_comicid_info_0_json` | | ||
| | `context7 stdio` + `query-docs` | `context7_stdio::query_docs` | | ||
| | `docs mcp` + `search-docs` | `docs_mcp::search_docs` | | ||
| | `github mcp` + `search_repos` | `github_mcp::search_repos` | |
There was a problem hiding this comment.
Capitalize product name consistently (“GitHub”).
At Line 277, use GitHub mcp instead of github mcp to match official naming in user-facing docs.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~277-~277: The official name of this software platform is spelled with a capital “H”.
Context: ...rch-docs|docs_mcp::search_docs| |github mcp+search_repos|github_mcp::se...
(GITHUB)
[uncategorized] ~277-~277: The official name of this software platform is spelled with a capital “H”.
Context: ...cs| |github mcp+search_repos|github_mcp::search_repos` | If a duplicate ID...
(GITHUB)
🤖 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 `@README.md` at line 277, Update the user-facing product name in the README
table entry: replace the lowercase token `github mcp` with `GitHub mcp` so the
row reading "`github mcp` + `search_repos` | `github_mcp::search_repos`" becomes
"`GitHub mcp` + `search_repos` | `github_mcp::search_repos`", preserving the
`search_repos` and `github_mcp::search_repos` identifiers.
| assert_eq!( | ||
| converted.manifest.functions[0].function_id, | ||
| "docs_mcp::search_docs" | ||
| ); |
There was a problem hiding this comment.
Add bounds check before indexing manifest.functions.
Direct array indexing without verifying the array is non-empty can panic if manifest.functions is empty. While the test expects successful conversion with at least one function, adding a guard improves test robustness.
✅ Proposed fix to add bounds check
+ assert!(!converted.manifest.functions.is_empty(), "Expected at least one function in manifest");
assert_eq!(
converted.manifest.functions[0].function_id,
"docs_mcp::search_docs"
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert_eq!( | |
| converted.manifest.functions[0].function_id, | |
| "docs_mcp::search_docs" | |
| ); | |
| assert!(!converted.manifest.functions.is_empty(), "Expected at least one function in manifest"); | |
| assert_eq!( | |
| converted.manifest.functions[0].function_id, | |
| "docs_mcp::search_docs" | |
| ); |
🤖 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 `@tests/rust_core.rs` around lines 281 - 284, The test indexes
converted.manifest.functions without ensuring it has elements; add a bounds
check before accessing it (e.g., assert that converted.manifest.functions is not
empty or assert_eq!(converted.manifest.functions.len(), expected) ) and then
perform the existing assertion on converted.manifest.functions[0].function_id to
avoid a potential panic in the test.
Summary
metadata.iii.generatedWorkerso converted OpenAPI/MCP sources appear as normal engine-runtime worker groupsValidation
cargo fmtcargo testcargo clippy --all-targets --all-features -- -D warningsPaired Engine PR
engine::workers::listgrouping and trusted local bridge routing.Summary by CodeRabbit
Release Notes
New Features
Documentation
Refactor