Introduction

The plugin-based architecture of DeepSeek Harness allows agent behavior to be extended through configuration or code. When building long-running plans, one needs to handle resource contention, looping logic, concurrency control, and potential deadlocks. The yxie2/dsh-petrinet plugin introduces workflow-nets as an intermediate representation, modeling plans as tokens flowing through a net, thereby addressing these issues.

What This Is

This is a DeepSeek Harness workflow-net runtime plugin maintained by developer yxie2. It models long-term plans as states and drives execution by moving tokens through the net. The plugin provides resource-aware concurrency, native loops and fan-out, static soundness checks, and process mining based on its own event logs.

Core Features

  • Resource-aware concurrency: Define resources and their capacities declaratively (such as semaphores and mutexes), which are enforced automatically by unified net-driven rules.
  • Native loops and fan-out: Supports patterns such as retries, polling, and per-discovered-item execution without extra logic.
  • Static soundness checks: Before plan persistence, uses reachability analysis to detect deadlocks or plans that cannot complete, and rejects unsound plans.
  • Process mining: Uses execution logs to automatically analyze execution behavior and provide consistency reports and improvement suggestions.

Installation and Enablement

Install via the official plugin management command.

dsh plugin add @yxie2/petrinet

Typical Usage

The plugin provides multiple tool commands and DSL definitions.

1. Define a Plan

Use JSON DSL to define resources and flows. The model primarily writes the structure and does not directly generate arcs. Example:

{
  "resources": [{ "id": "A", "capacity": 1 }],
  "flow": { "parallel": [...] }
}

2. Validate Soundness

Use petri_plan before execution to check whether the plan is SOUND.

3. Analyze Deadlocks

Use petri_analyze to obtain concrete examples of deadlocked states.

4. Get Insights

Use petri_insights to view consistency analysis and resource capacity recommendations.

5. Reconstruct the Net

Use alphaMine to rediscover the net structure from observed behavior.

Suitable Scenarios and Notes

Suitable for scenarios requiring strict resource management and complex flow control. Note the following:

  • Token mechanism: Tokens are derived rather than stored; the system restores state by reconstructing session logs.
  • Two-phase model: Execution uses a lease/verification two-phase model, ensuring that execution results are subject to independent adjudication.
  • Dependency requirements: Peer dependencies are required: @deepseek-ai/cordis, @deepseek-ai/dsh-agent, @deepseek-ai/dsh-commands, @deepseek-ai/dsh-invariants, and @deepseek-ai/dsh-llm.
  • Exploration budget: Reachability analysis uses an exploration budget; if the budget is exceeded, it returns UNKNOWN rather than an optimistic SOUND.

Short Conclusion

This plugin provides DSH with a rigorous Petri Net-based execution model. Combined with static checks and process mining capabilities, it helps build more reliable long-cycle agent plans. View the directory page or the source code.