Skip to content

📝 CodeRabbit Chat: Implement requested code changes - #119

Open
coderabbitai[bot] wants to merge 6 commits into
mainfrom
coderabbitai/chat/e87ab32
Open

📝 CodeRabbit Chat: Implement requested code changes#119
coderabbitai[bot] wants to merge 6 commits into
mainfrom
coderabbitai/chat/e87ab32

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Code changes was requested by @leynos.

The following files were modified:

  • tests/canonical_storage/test_workflow_checkpoints.py

Summary by Sourcery

Tests:

  • Fix the workflow checkpoint test name typo and remove unused setup code in the canonical storage tests.

leynos and others added 6 commits May 29, 2026 16:39
Covers the case where IntegrityError fires and the conflicting
checkpoint cannot be recovered through get_by_idempotency_key. Uses
unittest.mock.AsyncMock to deterministically simulate the race so the
adapter's recovery_failures and latency metrics are exercised without
PostgreSQL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace explicit metrics list comparisons in both
test_checkpoint_store_records_checkpoint_metrics and
test_checkpoint_store_records_recovery_failure_metrics with syrupy
snapshot assertions, following the deterministic-fixture pattern from
test_generation_orchestration_snapshots.py. _RecordingMetrics gains an
as_snapshot helper that returns a stable dict-of-lists shape; the
deterministic _StepClock keeps latency values exact in the snapshot
without redaction.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Remove the parallel ChronoClockPort and _PerfCounterChronoClock from
episodic.qa.chrono and reuse MonotonicClockPort and PerfCounterClock
from episodic.observability instead. This eliminates the duplicate port
hierarchy and establishes a single canonical clock port for the
codebase.

Expose MonotonicClockPort from episodic.qa for external consumers that
previously imported ChronoClockPort, and update the developers' guide
and module docstrings to document MetricsPort and MonotonicClockPort as
the canonical observability ports, with BoundedMetricsPort retained as
a narrower structural subtype for feature-specific ports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the RecordingMetrics fake, the deterministic StepClock, and the
make_checkpoint fixture builder out of tests/canonical_storage/
test_workflow_checkpoints.py and into a new
_workflow_checkpoint_support module so the test file stays under the
project's 400-line module budget and remains focused on behaviour.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The .claude/ directory holds per-session runtime state created by the
local Claude Code harness (for example scheduled_tasks.lock). It is
not meant to be tracked in source control.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot requested a review from leynos May 29, 2026 17:02
@sourcery-ai

sourcery-ai Bot commented May 29, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Renames a test case for clarity and removes an unused variable in the workflow checkpoints tests to match requested review feedback.

File-Level Changes

Change Details Files
Improve clarity and cleanliness of a workflow checkpoints test case.
  • Rename the async test function so its name correctly describes the missing checkpoint scenario
  • Remove the unused factory variable assignment from the test to simplify the setup
tests/canonical_storage/test_workflow_checkpoints.py

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

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0896ffcb-f2f1-48c2-b773-885b19b44339

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The factory variable is still used in async with SqlAlchemyUnitOfWork(factory) as uow: but its assignment was removed, which will cause a NameError; either restore the casted assignment or update the context manager to use session_factory directly with appropriate typing.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `factory` variable is still used in `async with SqlAlchemyUnitOfWork(factory) as uow:` but its assignment was removed, which will cause a `NameError`; either restore the casted assignment or update the context manager to use `session_factory` directly with appropriate typing.

## Individual Comments

### Comment 1
<location path="tests/canonical_storage/test_workflow_checkpoints.py" line_range="62-68" />
<code_context>

 @pytest.mark.asyncio
-async def test_checkpoint_store_get_returns_none_for_missingmake_checkpoint(
+async def test_checkpoint_store_get_returns_none_for_missing_checkpoint(
     session_factory: object,
 ) -> None:
     """`get` should return None when the checkpoint does not exist."""
-    factory = typ.cast("async_sessionmaker[AsyncSession]", session_factory)
+

     async with SqlAlchemyUnitOfWork(factory) as uow:
         result = await uow.workflow_checkpoints.get(str(uuid.uuid4()))
</code_context>
<issue_to_address>
**issue (testing):** This test no longer defines `factory`, so it will fail before exercising the behaviour it’s meant to validate.

With `factory = typ.cast(...)` removed but `factory` still used in the `SqlAlchemyUnitOfWork` context manager, this test will raise a `NameError` and never exercise the `get` call or its assertion. Please reintroduce the `factory` initialization (or pass `session_factory` directly) so the test actually checks that `get` returns `None` for a missing checkpoint.
</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 on lines +62 to 68
async def test_checkpoint_store_get_returns_none_for_missing_checkpoint(
session_factory: object,
) -> None:
"""`get` should return None when the checkpoint does not exist."""
factory = typ.cast("async_sessionmaker[AsyncSession]", session_factory)


async with SqlAlchemyUnitOfWork(factory) as uow:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (testing): This test no longer defines factory, so it will fail before exercising the behaviour it’s meant to validate.

With factory = typ.cast(...) removed but factory still used in the SqlAlchemyUnitOfWork context manager, this test will raise a NameError and never exercise the get call or its assertion. Please reintroduce the factory initialization (or pass session_factory directly) so the test actually checks that get returns None for a missing checkpoint.

Base automatically changed from issue-115-metrics-port-consolidation-and-testing to main May 30, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant