Skip to content

feat: migrate examples to the jobs model#16

Draft
0xgleb wants to merge 1 commit into
feat/jobs-eventsourced-reshapefrom
feat/jobs-examples-docs
Draft

feat: migrate examples to the jobs model#16
0xgleb wants to merge 1 commit into
feat/jobs-eventsourced-reshapefrom
feat/jobs-examples-docs

Conversation

@0xgleb

@0xgleb 0xgleb commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The example crates still implemented the removed EventSourced::Services API. They need to compile against the jobs-shaped EventSourced trait without bundling the prose documentation migration into the same PR.

Solution

  • Migrates examples/complex (order, inventory, reactors, main) to type Jobs = Nil, sync command handlers with JobQueue, and the updated builder/test harness calls.
  • Migrates examples/simple by moving the clock value into commands, removing the service clock machinery, and updating callers/tests.
  • Leaves README/SPEC/docs prose to the follow-up docs PR stacked above this one.

Closes RAI-945.

Summary by CodeRabbit

  • Documentation

    • Updated code examples to show commands now including explicit timestamps
  • Refactor

    • Command structure updated to require timestamp values in payloads

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@0xgleb, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 56 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6f95df35-6948-4c54-8b44-e993e00268e1

📥 Commits

Reviewing files that changed from the base of the PR and between 48ee433 and 1f2408b.

📒 Files selected for processing (2)
  • examples/simple/src/main.rs
  • examples/simple/src/support_ticket.rs

Walkthrough

This PR updates the SupportTicket example to pass explicit timestamps through command payloads. The Open, AwaitCustomer, and Close command variants now include an at field carrying the command timestamp, replacing earlier internal now() calls. The aggregate's initialize and transition methods emit events using these command-provided timestamps. Main and test code are updated to provide concrete timestamps.

Changes

Command timestamping in SupportTicket aggregate

Layer / File(s) Summary
Command contract and initialization
examples/simple/src/support_ticket.rs
SupportTicketCommand variants Open, AwaitCustomer, and Close now include at: chrono::DateTime<Utc> fields. The EventSourced::initialize method uses the timestamp from the Open command to create the Opened event.
Aggregate state transitions
examples/simple/src/support_ticket.rs
The EventSourced::transition method now emits AwaitingCustomer and Closed events using the command-provided at timestamp, while maintaining existing status-based error behavior for invalid state transitions.
Main example with timestamps
examples/simple/src/main.rs
Updated module-level documentation describes that commands carry their own timestamps and the SQLite generated column supports filtered queries. The main flow now provides chrono::Utc::now() timestamps when constructing Open, AwaitCustomer, and Close commands.
Test suite alignment
examples/simple/src/support_ticket.rs
All test cases constructing Open, AwaitCustomer, or Close commands are updated to include at: fixed_instant() in the command payloads, covering close behavior, store round-trips, projection filtering, and idempotency scenarios.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'feat: migrate examples to the jobs model' does not accurately describe the actual changes made, which focus on adding explicit timestamps to commands rather than a jobs model migration. Consider a more descriptive title like 'feat: add explicit timestamps to example commands' or similar that reflects the actual code modifications.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/jobs-examples-docs

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.

❤️ Share

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

0xgleb commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label add-to-gt-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@0xgleb 0xgleb self-assigned this Jun 5, 2026
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from f8d5519 to fa00224 Compare June 8, 2026 22:58
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch 2 times, most recently from 8eaa401 to 44f2524 Compare June 8, 2026 23:41
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from fa00224 to 910433d Compare June 8, 2026 23:41
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 44f2524 to d01d8ab Compare June 9, 2026 20:39
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 910433d to c5c503c Compare June 9, 2026 20:39
@0xgleb 0xgleb mentioned this pull request Jun 9, 2026
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from c5c503c to a755cb4 Compare June 9, 2026 21:22
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch 2 times, most recently from 0f27029 to 92844eb Compare June 9, 2026 23:24
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from a755cb4 to 207ae2c Compare June 9, 2026 23:24
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 92844eb to cff1565 Compare June 9, 2026 23:55
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 207ae2c to 7159bba Compare June 9, 2026 23:55
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from cff1565 to 3922ec6 Compare June 10, 2026 00:01
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 7159bba to 14d1da0 Compare June 10, 2026 00:01
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 14d1da0 to 177dc0c Compare June 10, 2026 01:18
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 3922ec6 to 7192363 Compare June 10, 2026 01:18
@0xgleb 0xgleb changed the title feat: migrate examples and docs to the jobs model feat: migrate examples to the jobs model Jun 10, 2026
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 8f4f05a to 7b0f794 Compare June 10, 2026 04:53
@0xgleb 0xgleb changed the base branch from graphite-base/16 to feat/jobs-eventsourced-reshape June 10, 2026 04:53
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 7b0f794 to 2e99de9 Compare June 10, 2026 04:55
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from e2743b6 to 64a435a Compare June 10, 2026 05:28
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 2e99de9 to 48ee433 Compare June 10, 2026 05:28

@findolor findolor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved.

@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 64a435a to f7b49c2 Compare June 10, 2026 17:39
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 48ee433 to 500ca31 Compare June 10, 2026 17:39
@graphite-app graphite-app Bot force-pushed the feat/jobs-eventsourced-reshape branch from f7b49c2 to a14c560 Compare June 10, 2026 19:19
@graphite-app graphite-app Bot force-pushed the feat/jobs-examples-docs branch from 500ca31 to d6cd320 Compare June 10, 2026 19:20
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from d6cd320 to a8f14b3 Compare June 12, 2026 19:45
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from a14c560 to 72cd628 Compare June 12, 2026 19:45
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from a8f14b3 to 4947d61 Compare June 12, 2026 21:16
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 72cd628 to 97bdb7d Compare June 12, 2026 21:16
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 4947d61 to 718b565 Compare June 12, 2026 21:55
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 97bdb7d to b77e4d4 Compare June 12, 2026 21:55
@graphite-app graphite-app Bot force-pushed the feat/jobs-eventsourced-reshape branch from b77e4d4 to eb01971 Compare June 15, 2026 19:29
@graphite-app graphite-app Bot force-pushed the feat/jobs-examples-docs branch from 718b565 to 8d31830 Compare June 15, 2026 19:30
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from 8d31830 to cdaabcd Compare June 26, 2026 20:28
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from eb01971 to 0894600 Compare June 26, 2026 20:28
@0xgleb 0xgleb force-pushed the feat/jobs-eventsourced-reshape branch from 0894600 to e14b622 Compare June 27, 2026 03:19
@0xgleb 0xgleb force-pushed the feat/jobs-examples-docs branch from cdaabcd to 1f2408b Compare June 27, 2026 03:19
@0xgleb 0xgleb marked this pull request as draft June 27, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants