rust-idempotent-workflows
Use when designing, implementing, testing, or debugging Rust service workflows that must be safe under retries, duplicate requests, crashes, concurrent submissions, background workers, queues, email/payment/notification side effects, idempotency keys, transaction isolation, or save-and-replay API behavior.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- rust-idempotent-workflows
- license
- MIT
- metadata
- { "tags": "rust,idempotency,retries,background-jobs,concurrency", "version": "0.1.0", "category": "Rust", "displayName": "Rust Idempotent Workflows" }
- description
- Use when designing, implementing, testing, or debugging Rust service workflows that must be safe under retries, duplicate requests, crashes, concurrent submissions, background workers, queues, email/payment/notification side effects, idempotency keys, transaction isolation, or save-and-replay API behavior.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 4
- 参考文档agents/openai.yaml194 B
- 参考文档references/background-workers.md1.3 KB
- 参考文档references/concurrency.md1.2 KB
- 参考文档references/idempotency.md1.3 KB
03 SKILL.md 正文
Rust Idempotent Workflows
Use this skill to make Rust workflows reliable when clients retry, workers crash, requests race, and external side effects cannot be rolled back.
Core Workflow
- Write the failure story before writing code. List what happens if the process crashes after each database write and after each external side effect.
- Identify the idempotency boundary: HTTP endpoint, command handler, queue job, webhook, or external callback.
- Choose the idempotency strategy:
- Natural idempotency from a unique business key.
- Client-provided idempotency key with save-and-replay.
- Server-generated deduplication key.
- Outbox or queue table for side effects.
- Put state transitions and idempotency records in the same transaction when they must agree.
- Make duplicate concurrent requests deterministic. Use unique constraints, locks, serializable transactions, or explicit conflict handling.
- Treat external side effects as at-least-once unless the provider guarantees more. Store enough state to retry or reconcile.
- Add tests for duplicate requests, retry after timeout, concurrent requests, crash windows when practical, and worker retry behavior.
Idempotency Key Rules
Read references/idempotency.md before adding idempotency keys or save-and-
replay behavior.
- Bind the key to the authenticated user or tenant.
- Store a hash of the request payload when replaying responses.
- Return the original response for exact replays.
- Reject reuse of the same key with a different payload.
- Expire records only after product and provider retry windows have passed.
Background Work Rules
Read references/background-workers.md when adding queue tables, polling
workers, retries, or external side effects.
- Commit durable intent before sending external effects.
- Use
pending,in_progress,succeeded, andfailedstates deliberately. - Keep retry counts, next-attempt timestamps, and last error summaries.
- Make workers safe to run in multiple processes.
Concurrency Rules
Read references/concurrency.md when duplicate requests, locks, isolation
levels, or unique constraints are part of the fix.
Use the database as the source of truth for deduplication when multiple app instances can process the same workflow.
Reference Files
references/idempotency.md: idempotency keys, save-and-replay, and request payload binding.references/background-workers.md: queue tables, worker loops, retry boundaries, and outbox behavior.references/concurrency.md: lock choices, transaction isolation, and duplicate request tests.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.