Files
Donald Pinckney 44eba4e91c Add .NET SDK support to temporal-developer skill (#39)
* Add .NET reference files for temporal-developer skill

Created 11 .NET reference files covering: dotnet.md (overview/quick start),
patterns.md, determinism.md, determinism-protection.md, error-handling.md,
testing.md, versioning.md, observability.md, data-handling.md, gotchas.md,
and advanced-features.md. Follows Python/TypeScript patterns with .NET-specific
content for Task determinism, CancellationToken, dependency injection, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix .NET alignment issues from self-review

- dotnet.md: Reduce Determinism Rules section to brief cross-reference
  (was duplicating determinism.md content)
- patterns.md: Add ParentClosePolicy to Child Workflows example
- gotchas.md: Add missing "Heartbeat Timeout Too Short" subsection
- versioning.md: Add missing Key Concepts, Deployment Strategies,
  Query Filters, PINNED/AUTO_UPGRADE guidance, CLI examples
- advanced-features.md: Add worker-level heading for exception types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix .NET correctness issues from verification pass

- patterns.md: Fix cancellation pattern to use official
  TemporalException.IsCanceledException(e) with detached CancellationTokenSource
- advanced-features.md: Fix DI hosting example to use official
  AddHostedTemporalWorker(clientTargetHost:, clientNamespace:, taskQueue:) pattern

Verified against official SDK README, API docs, and temporal-docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Update supported language references to include .NET

- SKILL.md: Add "Temporal .NET" and "Temporal C#" trigger phrases,
  update overview to mention .NET, add .NET entry in getting started
- core/determinism.md: Add .NET entry in SDK Protection Mechanisms

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Edits to advanced features

* edits to determinism protection, and move the .editorconfig section

* missed one

* edit determinism.md

* edit error-handling.md

* edit gotchas.md

* edit patterns.md

* edit versioning.md

* edit observability.md

* fix metrics

* self-review round 1

* minor correctness fixed

* Update references/dotnet/patterns.md

Co-authored-by: Justin Anderson <44687433+jmaeagle99@users.noreply.github.com>

* address comments, clarify reference to earlier code snippet

* clarify that operations are forbidden IN WORKFLOWS

* cleanup workflow cancellation handling example

* add task token retrieval comment

* update .net requirements

* Fix propagation of workflow cancellation

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Justin Anderson <44687433+jmaeagle99@users.noreply.github.com>
2026-04-17 14:28:02 -04:00

2.0 KiB

Python SDK Determinism

Overview

The Python SDK runs workflows in a sandbox that provides automatic protection against many non-deterministic operations.

Why Determinism Matters: History Replay

Temporal provides durable execution through History Replay. When a Worker needs to restore workflow state (after a crash, cache eviction, or to continue after a long timer), it re-executes the workflow code from the beginning, which requires the workflow code to be deterministic.

Forbidden Operations in Workflows

The following are forbidden inside workflow code but are appropriate to use in activities.

  • Direct I/O (network, filesystem)
  • Threading operations
  • subprocess calls
  • Global mutable state modification
  • time.sleep() (use workflow.sleep(timedelta(...)))
  • and so on

Safe Builtin Alternatives to Common Non Deterministic Things

Forbidden Safe Alternative
datetime.now() workflow.now()
datetime.utcnow() workflow.now()
random.random() rng = workflow.random() ; rng.randint(1, 100)
uuid.uuid4() workflow.uuid4()
time.time() workflow.now().timestamp()

Testing Replay Compatibility

Use the Replayer class to verify your code changes are compatible with existing histories. See the Workflow Replay Testing section of references/python/testing.md.

Sandbox Behavior

The sandbox:

  • Isolates global state via exec compilation
  • Restricts non-deterministic library calls via proxy objects
  • Passes through standard library with restrictions

See more info at references/python/determinism-protection.md

Best Practices

  1. Use workflow.now() for all time operations
  2. Use workflow.random() for random values
  3. Use workflow.uuid4() for unique identifiers
  4. Pass through third-party libraries explicitly
  5. Test with replay to catch non-determinism
  6. Keep workflows focused on orchestration, delegate I/O to activities
  7. Use workflow.logger instead of print() for replay-safe logging