duroxide
Copilot instructions221 starsChanged 3 months agoMITView on GitHub
A durable execution runtime for Rust. Key docs: docs/ORCHESTRATION-GUIDE.md, docs/provider-implementation-guide.md. NEVER commit or push without explicit user permission. Always ask before running git commit or git push. ALWAYS use nextest for running tests. This is mandatory - nextest provides faster execution and better output. Only fall back to cargo test if nextest is not available. Never use cargo test when cargo nt works. NEVER dismiss a failing test as a "pre-existing flake" and move on. Flaky tests block progress and…
- Commits and pushes
In this repository2 other files it gives its agents.
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
17 rules. About 0 are common, 7 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 7
NEVER commit or push without explicit user permission: Always ask before running git commit or git push.
- Very specific: line 19
Only fall back to cargo test if nextest is not available.
- Distinctive: line 25
When a failure is unrelated to current changes, state that explicitly — then offer to investigate the root cause and fix it.
- Distinctive: line 27
Do not hand-wave "timing" or "contention" as an explanation without proving the specific race condition.
- Very specific: line 69
Use ctx.schedule_timer() for orchestration delays, NOT activity sleep
- Very specific: line 86
All tests in tests/scenarios/single_thread.rs use #[tokio::test(flavor = "current_thread")]
- Very specific: line 87
Use RuntimeOptions { orchestration_concurrency: 1, worker_concurrency: 1, ..
- Distinctive: line 88
Never spawn blocking tasks that assume multi-threaded runtime
- Very specific: line 107
Use ./run-tests.sh before committing.
- Very specific: line 126
Add validation tests in src/provider_validation/
- Very specific: line 127
Add tests to tests/sqlite_provider_validations.rs
- Very specific: line 128
Update docs/provider-implementation-guide.md (signatures, pseudocode, semantics)
- Very specific: line 129
Update docs/provider-testing-guide.md (test count, new test category if needed)
- Distinctive: line 143
Never remove event variants - deprecate first
- Very specific: line 149
Use ErrorDetails enum for structured errors (Infrastructure/Configuration/Application)
- Distinctive: line 159
When adding features, consider if they warrant a scenario test based on real-world usage.
- Distinctive: line 165
Never duplicate the raw enqueue→fetch→ack pattern inline — use these helpers instead
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Duroxide AI Agent Instructions
A durable execution runtime for Rust. Key docs: docs/ORCHESTRATION-GUIDE.md, docs/provider-implementation-guide.md.
⚠️ CRITICAL: Git Operations
NEVER commit or push without explicit user permission. Always ask before running git commit or git push.
⚠️ CRITICAL: Test Execution
ALWAYS use nextest for running tests. This is mandatory - nextest provides faster execution and better output.
cargo nt # Run all tests (nextest alias)
cargo nt -E 'test(/pattern/)' # Filter tests by pattern
cargo nt --test specific_test_file # Run specific test fileOnly fall back to cargo test if nextest is not available. Never use cargo test when cargo nt works.
⚠️ CRITICAL: Flaky Tests
NEVER dismiss a failing test as a "pre-existing flake" and move on. Flaky tests block progress and must be investigated.
- When a failure is unrelated to current changes, state that explicitly — then offer to investigate the root cause and fix it.
- Always investigate deeply: trace the exact code path, build a plausible theory for the failure mechanism, and propose a concrete fix.
- Do not hand-wave "timing" or "contention" as an explanation without proving the specific race condition.
- A test that passes in isolation but fails under parallel execution has a real bug — either in the test (ordering assumptions, shared state) or in the runtime (contention handling).
Architecture Overview
Two-queue message-driven runtime:
- OrchestrationDispatcher (orchestrator queue): Processes workflow turns, durable timers, and external events
- WorkDispatcher (worker queue): Executes activities with automatic lock renewal for long-running work
Core types:
OrchestrationContext- Schedules work viaschedule_activity(),schedule_timer(),schedule_wait(),schedule_sub_orchestration()- all return futures you can.awaitdirectlyEvent/Action- Immutable history entries; providers only store, never generate IDsProvidertrait - Storage abstraction with peek-lock semantics (src/providers/mod.rs)
Critical Patterns
Awaiting schedule_ methods:*
// schedule_* methods return futures that can be awaited directly
let result = ctx.schedule_activity("Task", input).await?;
ctx.schedule_timer(Duration::from_secs(5)).await;
let event_data = ctx.schedule_wait("MyEvent").await;
let sub_result = ctx.schedule_sub_orchestration("Child", input).await?;Use ctx.join/select, NOT tokio::join/select:
// ✅ CORRECT - deterministic, history-ordered resolution
match ctx.select2(timer, activity).await {
Either2::First(()) => { /* timer won */ }
Either2::Second(result) => { /* activity won */ }
}
let results = ctx.join(vec![f1, f2, f3]).await;
// ❌ WRONG - non-deterministic, breaks replay
let (a, b) = tokio::join!(f1, f2); // NEVER use tokio::join in orchestrations!
tokio::select! { ... } // NEVER use tokio::select in orchestrations!Orchestrations vs Activities:
- Orchestrations: Deterministic coordination only (no I/O, no randomness, no time)
- Activities: Single-purpose execution (can do anything - DB, HTTP, sleep, poll)
- Use
ctx.schedule_timer()for orchestration delays, NOT activity sleep
Activity cancellation (cooperative):
// Activities check ctx.is_cancelled() or use tokio::select! with ctx.cancelled()
.register("LongTask", |ctx: ActivityContext, input: String| async move {
for item in items {
if ctx.is_cancelled() { return Err("Cancelled".into()); }
process(item).await;
}
Ok("done".into())
})Single-Threaded Runtime Support
Duroxide MUST work in single-threaded tokio runtime (e.g., pgrx PostgreSQL extensions with SPI calls).
- All tests in
tests/scenarios/single_thread.rsuse#[tokio::test(flavor = "current_thread")] - Use
RuntimeOptions { orchestration_concurrency: 1, worker_concurrency: 1, .. }(1x1 mode) - Never spawn blocking tasks that assume multi-threaded runtime
Build & Test Commands
cargo nt # ⚠️ PREFERRED: Run all tests with nextest (--all-features)
cargo nt -E 'test(/pattern/)' # Filter tests by pattern
cargo nt --test specific_test # Run specific test file
./run-tests.sh # ⚠️ COMPREHENSIVE: Two-pass (with + without feature flags)
./run-tests.sh -E 'test(/pattern/)' # Two-pass with filter
cargo build --all-targets # Build everything
cargo clippy --all-targets --all-features # Full lint check
cargo test --doc # Doctest validation (nextest doesn't run these)
cargo run --example hello_world # Run examplecargo nt runs nextest run --all-features (single pass). ./run-tests.sh adds a second pass
without features to catch behaviors hidden under --all-features — feature-gated code paths,
serde boundary enforcement (v2 event rejection), and conditional compilation differences.
Use ./run-tests.sh before committing.
Key Directories
src/runtime/dispatchers/- Orchestration and worker dispatcherssrc/providers/sqlite.rs- Reference provider implementationtests/scenarios/- Production pattern regression tests (add real-world patterns here)tests/e2e_samples.rs- Comprehensive usage examplesprompts/- AI task prompts (useduroxide-*.mdfor specific workflows)
Provider Implementation
Providers are pure storage - runtime owns all orchestration logic:
fetch_work_item()returns 4-tuple:(WorkItem, String, u32, ExecutionState)ack_work_item()takesOption<WorkItem>-Noneskips enqueueing completionrenew_work_item_lock()returnsExecutionStatefor cancellation support- See
docs/provider-implementation-guide.mdfor complete contract
When changing Provider trait:
- Add validation tests in
src/provider_validation/ - Add tests to
tests/sqlite_provider_validations.rs - Update
docs/provider-implementation-guide.md(signatures, pseudocode, semantics) - Update
docs/provider-testing-guide.md(test count, new test category if needed)
Determinism Rules
Orchestrations must be deterministic for replay:
- ✅ Use:
ctx.new_guid(),ctx.utcnow(), control flow,continue_as_new() - ❌ Avoid:
Uuid::new_v4(),SystemTime::now(),rand::random(),std::process::id(), direct I/O,tokio::join!/select!
Version Compatibility (Rolling Upgrades)
Users upgrade duroxide by rolling out new versions one node at a time. This means:
- Flag any change that would break mixed-version clusters (old runtime + new runtime)
- Event schema changes must be backward compatible (new fields optional, old fields preserved)
- Provider API changes need migration paths
- Never remove event variants - deprecate first
Error Handling
- Orchestrations return
Result<String, String> - Activities return
Result<String, String> - Use
ErrorDetailsenum for structured errors (Infrastructure/Configuration/Application) - Provider methods return
Result<_, ProviderError>with retryable classification
Scenario Tests
tests/scenarios/ captures real-world patterns discovered in production (toygres, duroxide-pg):
- Instance Actor Pattern: Long-running orchestration with
continue_as_new()for health monitoring - Continue-As-New Chains: Prevent unbounded history growth
- Single-Thread Mode: Validates pgrx/embedded use cases
When adding features, consider if they warrant a scenario test based on real-world usage.
Pre-seeded history: Tests that need history without a running runtime should use helpers in tests/common/mod.rs:
seed_history_turn()— enqueue→fetch→ack cycle in one call (builds one orchestrator turn)seed_instance_with_pinned_version()— creates an instance stamped with a specific duroxide versionmake_versioned_event()— creates an event with a customduroxide_versionstamp- Never duplicate the raw enqueue→fetch→ack pattern inline — use these helpers instead
AI Workflow Prompts
Reference prompts/duroxide-*.md for structured tasks:
duroxide-clean-warnings.md- Eliminate compiler/clippy warningsduroxide-update-docs-tests.md- Documentation and test updates with OTel auditduroxide-create-scenario-test.md- Convert patterns to regression testsduroxide-stress-test.md- Performance testing
Workflow Rules
- Never commit or push without explicit user permission. Always ask before running
git commitorgit push.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

