Skip to content

Add idempotent dispatch submissions - #87

Merged
cirsteve merged 1 commit into
mainfrom
agent/idempotent-dispatch-submit
Aug 15, 2026
Merged

cirsteve merged 1 commit into
mainfrom
agent/idempotent-dispatch-submit

Conversation

@cirsteve

@cirsteve cirsteve commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add an optional idempotency key to Jig function dispatch
  • preserve the key across retries so Smithers can return the already accepted job
  • keep unkeyed callers fully backward compatible

Verification

  • 52 tests passed

Integration

Gecko PR #366 pins this commit and uses its deterministic DBOS operation identity as the submission key. Requires the companion Smithers idempotent-job-submission contract before production rollout.

Summary by CodeRabbit

  • New Features

    • Added optional idempotency keys to dispatch submissions and function execution.
    • Retrying a submission with the same key now prevents duplicate jobs and can recover the original result.
    • Documented idempotency keys for safer retry handling.
  • Bug Fixes

    • Improved recovery when a submission response is lost, allowing the accepted job to be found and polled successfully.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c3df1eb-446d-46b4-8a7c-354c285fdf56

📥 Commits

Reviewing files that changed from the base of the PR and between cf9c091 and 73a5385.

📒 Files selected for processing (2)
  • src/jig/dispatch/client.py
  • tests/test_dispatch_module.py

Included review availability: 1 review is currently available. Based on recent review activity, included reviews refill at 4 per hour.


📝 Walkthrough

Walkthrough

The dispatch client now accepts an optional idempotency_key. It includes the key in Smithers submissions and reuses it during response-loss retries. Tests cover keyed, unkeyed, and recovered dispatches.

Changes

Dispatch idempotency-key flow

Layer / File(s) Summary
Idempotency-key submission flow
src/jig/dispatch/client.py
run() accepts and forwards idempotency_key. _submit_and_poll() adds it to the Smithers payload when provided. Documentation describes retry deduplication.
Submission and recovery validation
tests/test_dispatch_module.py
Tests verify conditional payload inclusion and recovery after a lost submission response.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to 73a53

The new keyed retry path can recover an already accepted job, but it depends on the server replacing the callback destination atomically; otherwise the client may miss the callback and fail to complete or cancel the recovered job. The PR is mergeable with explicit owner awareness that the companion contract or polling fallback must be in place before production rollout.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant run
  participant _submit_and_poll
  participant Smithers
  Caller->>run: Provide idempotency_key
  run->>_submit_and_poll: Forward idempotency_key
  _submit_and_poll->>Smithers: Submit job with key
  Smithers-->>_submit_and_poll: Response or lost response
  _submit_and_poll->>Smithers: Retry with same key
  Smithers-->>_submit_and_poll: Return existing job
  _submit_and_poll->>Smithers: Poll job
  Smithers-->>Caller: Return result
Loading

Possibly related PRs

  • RankOneLabs/jig#19: Adds idempotency-key support to the dispatch client’s run and submission flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding idempotent dispatch submissions.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/idempotent-dispatch-submit

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

Copilot AI 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.

Pull request overview

Adds an optional idempotency key to function dispatch submissions so callers can safely retry after transient submission/response failures without creating duplicate smithers jobs, while keeping existing unkeyed callers backward compatible.

Changes:

  • Plumbs a new optional idempotency_key parameter through jig.dispatch.run() into the smithers submission JSON payload.
  • Documents the idempotency behavior in run()’s docstring.
  • Adds tests covering inclusion, omission (back-compat), and a retry-after-response-loss recovery path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_dispatch_module.py Adds coverage for keyed submissions, optional omission, and retry recovery behavior.
src/jig/dispatch/client.py Adds idempotency_key parameter and includes it in the smithers submission payload; documents behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cirsteve
cirsteve merged commit bbb7897 into main Aug 15, 2026
3 checks passed
@cirsteve
cirsteve deleted the agent/idempotent-dispatch-submit branch August 15, 2026 23:18
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.

2 participants