-
Notifications
You must be signed in to change notification settings - Fork 1
docs: add rustdoc comments to all public items #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Comment |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
| /// async fn main() { | ||
| /// let intent = Intent::new("Optimize this").unwrap(); | ||
| /// // Requires GEMINI_API_KEY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Suggestion: Modify functions to accept a client
// In src/agents/optimizer.rs
pub async fn optimizer(client: &impl CompletionClient, prompt: Intent) -> Result<Artifact> {
// client is now passed in, not created here
let prompt_officer = client.agent(MODEL).build();
// ...
}
// In tests, you can now use a mock client:
// let mock_client = MockCompletionClient::new();
// let artifact = optimizer(&mock_client, intent).await.unwrap();I've spotted several TODO (UNTESTABLE) comments across the new test suites (e.g., in optimizer.rs, deconstructor.rs, and lib.rs). The common root cause is that components create their own Client instance internally (e.g., Client::new(...) or Client::from_env()), which makes mocking for tests impossible. To resolve this and make the core logic testable, I recommend applying dependency injection. You could create the Client once at a higher level (like in main.rs or RigScribe) and pass it as an argument to the functions and tools that need it. This change would significantly improve the project's test coverage and long-term maintainability.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
|
|
||
| Ok(()) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears an extra closing brace } was accidentally added at the end of the main function. The provided diff indicates that the original closing brace remains as context, and a new one is added on the following line. This will result in a syntax error due to an unexpected token (...}}) and cause the build to fail.
To resolve this, the extraneous brace added in this change should be removed. You can verify the syntax error by running cargo check on the modified code.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| .preamble( | ||
| " | ||
| Role: Senior Solution Architect\n\ | ||
| "\n Role: Senior Solution Architect\n\ | ||
| Task: Extract constraints and risks and main goal of given request\n\ | ||
| Output: A short bullet list, no prose | ||
| ", | ||
| Output: A short bullet list, no prose\n ", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.preamble(concat!(
"
Role: Senior Solution Architect
",
"Task: Extract constraints and risks and main goal of given request
",
"Output: A short bullet list, no prose"
))The reformatting of the preamble string has unintentionally added significant leading and trailing whitespace. While it might seem like a minor formatting change, this alters the actual prompt sent to the language model, which can lead to unexpected or degraded responses because prompts are sensitive to formatting. This change could alter the agent's instructions.
To ensure predictable behavior, it's best to define prompts so they don't include incidental whitespace from the source code's formatting. The proposed change removes the extra spaces while preserving the intended multi-line structure of the prompt.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| /// ``` | ||
| /// use rigscribe::Artifact; | ||
| /// | ||
| /// let artifact = Artifact::new("You are a helpful assistant.", "Agent-007"); | ||
| /// assert_eq!(artifact.system_prompt, "You are a helpful assistant."); | ||
| /// assert_eq!(artifact.signed_by, "Agent-007"); | ||
| /// ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ```
/// use rigscribe::types::Artifact;
///
/// let artifact = Artifact::new("You are a helpful assistant.", "Agent-007");
/// assert_eq!(artifact.system_prompt, "You are a helpful assistant.");
/// assert_eq!(artifact.signed_by, "Agent-007");
/// ```
The doc test for Artifact::new uses an incorrect import path, which will cause cargo test to fail.
Why it's an issue: Doc tests are compiled as if they are external consumers of your library. The use path must match the public API structure. Since Artifact is defined in src/types/artifact.rs, its public path is likely rigscribe::types::Artifact, not rigscribe::Artifact. The current code will lead to a compilation error because the compiler won't find Artifact at the crate's root.
How to validate: You can confirm this by running cargo test locally. You should see an "unresolved import" error for this specific doc test.
Suggested fix: Update the use statement to reflect the correct module path.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| /// assert_eq!(intent.text, "Create a Python script"); | ||
| /// | ||
| /// let err = Intent::new(" ").unwrap_err(); | ||
| /// assert!(format!("{}", err).contains("Invalid request")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert!(format!("{}", err).contains("Request is empty"));The documentation example for Intent::new contains an incorrect assertion that will cause it to fail. The function returns an error with the message "Request is empty", but the example code asserts that the error message contains "Invalid request".
This discrepancy means the example code will panic if a developer runs it, which can be confusing and misleading. Documentation examples should always be correct and runnable to serve as a reliable reference.
To validate this, you can run the documentation tests via cargo test --doc, which will show the failure.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Pull Request: Add Auto-Generated Documentation
Summary
//!) to all modules across the codebaseModules Documented
src/lib.rs- Main library crate documentation with usage examplesrc/error.rs- Error handling module with error type descriptionssrc/utilities.rs- Utility functions for env vars and artifact I/Osrc/agents/mod.rs- Agents module overviewsrc/agents/optimizer.rs- Optimizer agent workflow documentationsrc/tools/mod.rs- Tools module with available tools listsrc/tools/deconstructor.rs- Deconstructor tool documentationsrc/tools/prompt_reviewer.rs- Prompt reviewer tool documentationsrc/tools/web_searcher.rs- Web searcher tool documentationsrc/types/mod.rs- Types module re-exportssrc/types/artifact.rs- Artifact struct documentationsrc/types/pipeline.rs- Pipeline types (Intent, Specification, Webquery)src/types/config.rs- Configuration and model settingssrc/types/common.rs- Common types (ScopeId)Note
All documentation in this PR is auto-generated by Gemini.
This pull request primarily focuses on improving the documentation and testability of the
rigscribecrate.Key changes include:
rustdoccomments to all public items, including structs, enums, functions, type aliases, and constants across the entire codebase. These comments provide descriptions, usage examples, argument explanations, return values, and error conditions, significantly enhancing API clarity and developer experience.#[cfg(test)]modules and unit tests for various components, such as:StreamingError,ScribeError) formatting.Artifact,ScopeId,RigScribeConfig,Intent,Specification,Webquery) for creation, serialization, deserialization, and equality.require_env,save_artifacts,read_artifact) including edge cases.Deconstructor,PromptReviewer,WebSearcher).TODO (UNTESTABLE)comments in test modules for functions that currently cannot be unit tested without significant refactoring for dependency injection or mocking of external API calls (e.g.,multi_turn_prompt,optimizer, toolcallmethods).These changes collectively contribute to a more robust, well-documented, and testable codebase.