Skip to content

Add e2e test harness#36

Merged
leynos merged 2 commits intomainfrom
codex/implement-testing-harness-for-vk-pr-command
Jul 27, 2025
Merged

Add e2e test harness#36
leynos merged 2 commits intomainfrom
codex/implement-testing-harness-for-vk-pr-command

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 27, 2025

Summary

  • add --transcript option for debugging GraphQL traffic
  • record HTTP exchanges when the option is set
  • provide a CA bundle and transcript for the shared-actions repo
  • create a third-wheel based harness for mocked e2e testing

Testing

  • make fmt
  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_68862b6731488322994eef326da4204a

Summary by Sourcery

Enable recording of GraphQL HTTP traffic via a --transcript flag and set up a third-wheel–based end-to-end test harness with mocked network interactions and fixtures

New Features:

  • Add --transcript option to record and debug GraphQL HTTP exchanges to a file
  • Introduce an end-to-end test harness using third-wheel to mock and replay HTTP traffic

Enhancements:

  • Extend GraphQLClient to optionally write serialized request/response pairs to a transcript file
  • Propagate the global transcript argument through CLI commands and client initialization

Build:

  • Add dependencies for e2e testing: third-wheel, assert_cmd, tokio (full), serde_json, predicates

Tests:

  • Add e2e.rs test that starts a MITM proxy, replays recorded GraphQL fixtures, and asserts VK CLI behavior
  • Include CA certificate, key, and a JSON transcript fixture for the shared-actions e2e test

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 27, 2025

Summary by CodeRabbit

  • New Features
    • Added optional command-line support for recording HTTP request/response transcripts for debugging.
    • Introduced end-to-end tests using a mock server and network transcript playback to verify integration flows.
  • Bug Fixes
    • Improved error handling and robustness when parsing LCOV and Cobertura coverage files.
  • Tests
    • Expanded test coverage for edge cases in coverage parsing, including malformed and missing files.
    • Added comprehensive end-to-end integration tests for pull request commands.
  • Chores
    • Updated development dependencies for testing and development workflows.
    • Simplified and updated markdown linting configuration.

Walkthrough

Introduce a new optional transcript file argument to the CLI, enabling HTTP request/response logging in the GraphQL client. Update the main and command functions to support transcript logging. Add development dependencies for testing, a new end-to-end test with a mock server, and a fixture for test data. Adjust markdownlint configuration and enhance coverage script robustness with LCOV support and improved error handling.

Changes

File(s) Change Summary
.markdownlint-cli2.jsonc Simplify configuration: disable MD013, MD029, MD040 rules.
Cargo.toml Add dev-dependencies: assert_cmd, third-wheel, tokio (full), serde_json, predicates.
src/cli_args.rs Add transcript field to GlobalArgs and update merge method to support it.
src/main.rs Add transcript logging to GraphQLClient; update constructors and command execution to support transcript option.
tests/e2e.rs Introduce end-to-end test with mock HTTPS server and transcript-driven response replay.
tests/fixtures/pr42.json Add test fixture containing recorded transcript data for E2E test.
.github/actions/generate-coverage/scripts/run_rust.py, .../tests/test_scripts.py Add LCOV coverage parsing, error handling improvements, and new tests for edge cases.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant GraphQLClient
    participant TranscriptFile
    participant GitHubAPI

    User->>CLI: Run command with --transcript option
    CLI->>GraphQLClient: Create with transcript file path
    GraphQLClient->>TranscriptFile: Open and lock file (if provided)
    CLI->>GraphQLClient: Send GraphQL request
    GraphQLClient->>GitHubAPI: POST query
    GitHubAPI-->>GraphQLClient: Respond with JSON
    GraphQLClient->>TranscriptFile: Log request and response (if enabled)
    GraphQLClient-->>CLI: Return deserialised response
    CLI-->>User: Output result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Fix non_snake_case lint handling #29: Introduces the initial GlobalArgs struct and cli_args module, which this PR extends by adding the transcript field and updating its merge logic.

Poem

Logs now flow where once was none,
Each query’s tale, each answer spun.
With tests that mock and fixtures bright,
The transcript keeps our code in sight.
Markdown rules are trimmed with care,
Coverage scripts now error-aware—
Debugging’s joy is everywhere!

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/implement-testing-harness-for-vk-pr-command

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jul 27, 2025

Reviewer's Guide

This PR extends the CLI and GraphQL client to optionally record HTTP traffic for debugging via a new --transcript flag, adapts command handlers to accept and propagate that flag, and adds a third-wheel-based end-to-end test harness with recorded fixtures.

Sequence diagram for GraphQLClient with transcript recording

sequenceDiagram
    participant CLI
    participant GraphQLClient
    participant HTTPServer
    participant TranscriptFile

    CLI->>GraphQLClient: new(token, transcript_path)
    GraphQLClient->>TranscriptFile: create(transcript_path) (if provided)
    CLI->>GraphQLClient: execute GraphQL query
    GraphQLClient->>HTTPServer: send HTTP request
    HTTPServer-->>GraphQLClient: HTTP response
    GraphQLClient->>TranscriptFile: write {request, response} (if transcript enabled)
    GraphQLClient-->>CLI: return parsed response
Loading

Class diagram for updated GraphQLClient and GlobalArgs

classDiagram
    class GraphQLClient {
        - reqwest::Client client
        - HeaderMap headers
        - String endpoint
        - Option<Arc<Mutex<File>>> transcript
        + new(token: &str, transcript: Option<PathBuf>)
        + with_endpoint(token: &str, endpoint: &str, transcript: Option<PathBuf>)
    }

    class GlobalArgs {
        + Option<String> repo
        + Option<PathBuf> transcript
        + merge_from(&mut self, other: GlobalArgs)
    }
Loading

File-Level Changes

Change Details Files
Introduce transcript logging in GraphQLClient
  • Add an optional transcript field holding an Arc<Mutex>
  • Extend new/with_endpoint to accept a transcript PathBuf and open the file
  • Capture response body text and write JSON lines of request/response to the transcript
  • Update error handling to read from the response text before deserialization
src/main.rs
Add global --transcript CLI flag and propagate it
  • Declare transcript: Option<PathBuf> in GlobalArgs and merge logic
  • Change run_pr/run_issue signatures to take &GlobalArgs
  • Pass global.transcript (and global.repo) into GraphQLClient and reference parsers
  • Update main to forward GlobalArgs into command runners
src/main.rs
src/cli_args.rs
Introduce third-wheel-based e2e test harness
  • Implement start_mock_server with a MITM proxy and dynamic handler
  • Load pre-recorded HTTP transcripts from fixtures for replay
  • Write an async e2e_pr_42 test that runs the CLI against the mock server
  • Include CA certificate, key, and JSON fixtures under tests/
tests/e2e.rs
tests/ca/cert.pem
tests/ca/key.pem
tests/fixtures/pr42.json
Add testing and proxy dependencies
  • Add assert_cmd, predicates, third-wheel, tokio, and serde_json to Cargo.toml
  • Ensure full async runtime features for e2e tests
Cargo.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Identified a Private Key, which may compromise cryptographic security and sensitive data encryption. (link)

General comments:

  • Avoid committing the CA private key (tests/ca/key.pem) to the repo; generate test certificates at runtime instead.
  • Make GraphQLClient::with_endpoint return a Result to propagate transcript file creation failures instead of panicking with expect.
  • Wrap the transcript file in a buffered writer and handle or log I/O errors on writes to avoid silently dropping entries.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Avoid committing the CA private key (tests/ca/key.pem) to the repo; generate test certificates at runtime instead.
- Make GraphQLClient::with_endpoint return a Result to propagate transcript file creation failures instead of panicking with expect.
- Wrap the transcript file in a buffered writer and handle or log I/O errors on writes to avoid silently dropping entries.

## Individual Comments

### Comment 1
<location> `src/main.rs:145` </location>
<code_context>

-    fn with_endpoint(token: &str, endpoint: &str) -> Self {
+    fn with_endpoint(token: &str, endpoint: &str, transcript: Option<std::path::PathBuf>) -> Self {
+        let transcript = transcript.map(|p| {
+            std::fs::File::create(p)
+                .map(std::sync::Mutex::new)
+                .map(std::sync::Arc::new)
+                .expect("failed to create transcript")
+        });
         Self {
</code_context>

<issue_to_address>
Using expect here will panic on file creation failure.

Consider handling file creation errors gracefully—log a warning and continue without a transcript instead of panicking, to improve CLI robustness.
</issue_to_address>

### Comment 2
<location> `src/main.rs:181` </location>
<code_context>
+            context: ctx.clone(),
+            source: e,
+        })?;
+        if let Some(t) = &self.transcript {
+            use std::io::Write as _;
+            if let Ok(mut f) = t.lock() {
+                let _ = writeln!(
+                    f,
+                    "{}",
+                    serde_json::to_string(&json!({ "request": payload, "response": body }))
+                        .unwrap_or_default()
+                );
+            }
+        }
</code_context>

<issue_to_address>
Transcript writing errors are silently ignored.

Errors from writeln! and lock() are ignored, which could hinder debugging. Please log these errors or return a Result if transcript logging is important.
</issue_to_address>

### Comment 3
<location> `src/main.rs:192` </location>
<code_context>
+                );
+            }
+        }
+        let resp: GraphQlResponse<serde_json::Value> =
+            serde_json::from_str(&body).map_err(|e| VkError::BadResponseSerde(e.to_string()))?;

         if let Some(errs) = resp.errors {
</code_context>

<issue_to_address>
Deserialization errors are wrapped but not contextualized.

Consider including the response body or a snippet in VkError::BadResponseSerde to aid in debugging deserialization issues.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
        let resp: GraphQlResponse<serde_json::Value> =
            serde_json::from_str(&body).map_err(|e| VkError::BadResponseSerde(e.to_string()))?;
=======
        let resp: GraphQlResponse<serde_json::Value> =
            serde_json::from_str(&body).map_err(|e| {
                // Include a snippet of the response body for debugging
                let snippet = if body.len() > 500 {
                    format!("{}...", &body[..500])
                } else {
                    body.clone()
                };
                VkError::BadResponseSerde(format!(
                    "{} | response body snippet: {}",
                    e.to_string(),
                    snippet
                ))
            })?;
>>>>>>> REPLACE

</suggested_fix>

### Comment 4
<location> `src/main.rs:136` </location>
<code_context>
     client: reqwest::Client,
     headers: HeaderMap,
     endpoint: String,
+    transcript: Option<std::sync::Arc<std::sync::Mutex<std::fs::File>>>,
 }

</code_context>

<issue_to_address>
Consider simplifying the transcript handling by removing unnecessary Arc indirection, using a single Mutex, and reusing the existing serialized request string.

```markdown
You can collapse the heavy `Arc<Mutex<_>>` indirection into a single‐layer mutex (or even a `RefCell` if you never share across threads), and avoid double `serde_json::to_string` by reusing your existing `ctx`. For example, replacing

```rust
transcript: Option<Arc<Mutex<File>>>,
…
let transcript = transcript.map(|p| {
    File::create(p)
      .map(Mutex::new)
      .map(Arc::new)
      .expect("failed to create transcript")
});
```

with

```rust
use std::sync::Mutex; // or `std::cell::RefCell` if single‐threaded

struct GraphQLClient {
    …
    transcript: Option<Mutex<std::fs::File>>,
}

impl GraphQLClient {
    fn with_endpoint(
        token: &str,
        endpoint: &str,
        transcript: Option<std::path::PathBuf>,
    ) -> Self {
        let transcript = transcript.map(|p| {
            let f = std::fs::File::create(p).expect("failed to create transcript");
            Mutex::new(f)
        });
        …
        Self { …, transcript }
    }
```

and in your `run_query`:

```rust
// after you have `ctx` and `body`
if let Some(mu) = &self.transcript {
    let mut f = mu.lock().unwrap();
    // reuse `ctx` instead of serializing payload twice
    writeln!(
        f,
        "{}",
        serde_json::to_string(&json!({
            "request": ctx,
            "response": body
        }))
        .unwrap(),
    )
    .ok();
}
```

This:

1. Drops the `Arc` since you never clone the client.
2. Collapses to a single‐layer `Mutex`.
3. Reuses the `ctx` string you already have.
4. Removes several nested `map` calls in the constructor.
</issue_to_address>

## Security Issues

### Issue 1
<location> `tests/ca/key.pem:1` </location>

<issue_to_address>
**security (private-key):** Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.

*Source: gitleaks*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
Comment thread tests/ca/key.pem Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fa85d8 and 0ac18af.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • tests/ca/cert.pem is excluded by !**/*.pem
  • tests/ca/key.pem is excluded by !**/*.pem
📒 Files selected for processing (6)
  • .markdownlint-cli2.jsonc (1 hunks)
  • Cargo.toml (1 hunks)
  • src/cli_args.rs (2 hunks)
  • src/main.rs (7 hunks)
  • tests/e2e.rs (1 hunks)
  • tests/fixtures/pr42.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not use return in single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Prefer semantic error enums: Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Use eyre::Report for human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and to eyre only in the main main() entrypoint or top-level async task.
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.

Files:

  • src/cli_args.rs
  • tests/e2e.rs
  • src/main.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • src/cli_args.rs
  • tests/e2e.rs
  • src/main.rs
Cargo.toml

📄 CodeRabbit Inference Engine (AGENTS.md)

Cargo.toml: Use explicit version ranges in Cargo.toml and keep dependencies up-to-date.
Mandate caret requirements for all dependencies: All crate versions specified in Cargo.toml must use SemVer-compatible caret requirements (e.g., some-crate = "1.2.3").
Prohibit unstable version specifiers: The use of wildcard (*), or open-ended inequality (>=) version requirements are strictly forbidden in Cargo.toml. Tilde requirements (~) should only be used where a dependency must be locked to patch-level updates for a specific, documented reason.

Files:

  • Cargo.toml
🔇 Additional comments (14)
.markdownlint-cli2.jsonc (1)

5-7: LGTM - Configuration simplification aligns with development needs.

Disabling MD013, MD029, and MD040 entirely is a pragmatic approach that removes complexity whilst supporting the development and testing enhancements introduced in this PR.

src/cli_args.rs (2)

19-21: Well-implemented CLI argument addition.

The transcript option follows established patterns with proper type usage (Option<std::path::PathBuf>), clear documentation, and correct clap annotations.


33-35: Correct merge implementation for the new field.

The merge logic properly handles the Option type, maintaining consistency with existing field merging patterns.

Cargo.toml (1)

40-44: Appropriate dev dependencies for testing infrastructure.

The new dependencies support the e2e testing capabilities with proper caret version requirements. The tokio duplication with "full" features is correct for enabling additional testing capabilities without affecting production builds.

tests/e2e.rs (2)

18-41: Well-structured mock server setup with proper error handling.

The function correctly uses expect() over unwrap() and provides clear error context. The third-wheel integration is properly configured for HTTPS proxy testing.


56-78: Comprehensive e2e test with appropriate ignore attribute.

The test properly sets up environment variables, uses the binary through assert_cmd, and validates expected output. The ignore attribute correctly prevents the test from running without required fixtures.

src/main.rs (8)

136-136: Appropriate thread-safe transcript field design.

Using Arc<Mutex<File>> correctly provides thread safety for the optional transcript logging functionality.


140-141: Constructor properly propagates transcript parameter.

The method signature change maintains consistency with the existing pattern whilst enabling transcript functionality.


166-201: Transcript logging implementation with good error resilience.

The implementation correctly separates response reading from JSON parsing, writes structured transcript entries, and gracefully handles transcript write failures without affecting the main operation. The use of unwrap_or_default() for JSON serialisation provides appropriate fallback behaviour.


693-695: Function signature change properly integrates global configuration.

Accepting GlobalArgs reference enables access to both repo and transcript options whilst maintaining clean parameter passing.


704-704: Correct propagation of transcript option to GraphQL client.

The transcript parameter is properly extracted from global args and passed to the client constructor.


732-734: Consistent function signature update for issue command.

The changes maintain symmetry with the PR command implementation whilst enabling transcript functionality.


743-743: Proper integration of transcript functionality in issue handling.

The client instantiation correctly uses the global transcript configuration.


791-795: Main function correctly passes global args to command handlers.

The function calls properly pass the global args reference to enable transcript and repo configuration access.

Comment thread src/main.rs Outdated
Comment thread tests/e2e.rs
Comment thread tests/e2e.rs
Comment thread tests/fixtures/pr42.json
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
tests/e2e.rs (2)

1-1: Add mandatory module-level documentation.

Every module must begin with a //! doc comment explaining the module's purpose and utility as required by the coding guidelines.


67-78: Improve error handling in transcript loading.

The function uses unwrap_or("{}") which could mask JSON parsing errors. Use more explicit error handling for debugging.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac18af and d5d7de1.

📒 Files selected for processing (2)
  • src/main.rs (8 hunks)
  • tests/e2e.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not use return in single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Prefer semantic error enums: Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Use eyre::Report for human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and to eyre only in the main main() entrypoint or top-level async task.
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.

Files:

  • tests/e2e.rs
  • src/main.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • tests/e2e.rs
  • src/main.rs
🧬 Code Graph Analysis (1)
tests/e2e.rs (1)
src/main.rs (1)
  • new (142-144)
🔇 Additional comments (3)
src/main.rs (3)

95-96: LGTM! Error variant addition is appropriate.

The new Io variant properly handles file I/O errors that can occur during transcript operations.


146-164: Excellent error handling improvement!

The constructor now properly returns Result and propagates I/O errors instead of panicking with expect(). This addresses the previous review feedback effectively.


188-203: Good non-blocking transcript implementation.

The transcript logging correctly handles errors without interrupting the main flow. The warnings help with debugging transcript issues.

Comment thread src/main.rs
@leynos leynos merged commit cb7a97e into main Jul 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant