Skip to content

feat: add Pi and DSH plugins with message-driven Pi dispatch - #81

Open
reiase wants to merge 1 commit into
mainfrom
feat/pi-dsh-message-dispatch
Open

reiase wants to merge 1 commit into
mainfrom
feat/pi-dsh-message-dispatch

Conversation

@reiase

@reiase reiase commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Extend the companion launcher merged in #80 with native pulsing plugins for Pi coding agent and DeepSeek Harness (DSH), plus opt-in, bounded message-driven scheduling for Pi only.

pulsing -- pi
pulsing -- dsh web
pulsing --dispatch --dispatch-max-turns 8 -- pi

Native plugins

  • Automatically inject a Pi extension or invocation-only DSH Cordis overlay. Preserve profile/app arguments, normalize DSH's positional profile shorthand, and leave administrative subcommands alone.
  • Generate independently installable local packages with python -m pulsing.mailbox pi-plugin|dsh-plugin --output .... No npm publication, global installation or profile mutation is performed by the generator/wrapper.
  • Reuse the existing companion when present; standalone plugins automatically start one through the same Python launcher. Endpoint credentials cross an anonymous pipe, never a package/config file. Owned companions run outside the foreground process group and are released on shutdown.
  • Discover tool schemas from the existing MCP server. Read authoritative Pi session IDs or DSH execution-agent IDs on every call; missing identity fails closed rather than using a parent mailbox.
  • Preserve Pi reload/new-session behavior and concurrent SDK session isolation; DSH native tool restrictions remain effective. No model loop is bundled.

Message-driven Pi dispatch

  • Add process-local delivery edges and an identity-bound mail_wait API. Waiting happens in the MCP coroutine, not inside the serial mailbox actor. Snapshot/subscription races, cross-thread notifications, cancellation and waiter limits are handled without a broker or log-file watcher.
  • Wake idle Pi through its native custom-message/follow-up path. Busy agents coalesce pending mail instead of being steered/interrupted. Notifications contain IDs, not email bodies promoted to system instructions.
  • Default automatic inference off. Explicit --dispatch or /pulsing resume enables it; native permissions and approvals are unchanged.
  • Bound batches to 20 IDs, pending prefetch to 128 IDs and automatic attempts to 8 by default (configurable 1–64). Pause after cancellation, submission/connection failure, mailbox epoch change or budget exhaustion. No automatic retry of uncertain model/business effects.
  • Provide /pulsing status|pause|resume. Reload retains the volatile cursor, budget and pause state. Explicit resume rescans unread/read work; it does not steal processing leases or recover interrupted side effects.
  • Record adapter dispatch observations with dispatch/message IDs in actor logs and expose them through offline replay. These observations are not a transactional task ledger.
  • DSH/Codex retain mailbox communication; unsupported automatic-dispatch configurations are rejected explicitly.

Validation

  • PULSING_NATIVE_SDK_ROOT="$PWD/.pulsing/harness-dev" .venv/bin/pytest tests/python --ignore=tests/python/test_chaos.py -q: 715 passed, 16 skipped.
  • node --test tests/python/mailbox/dispatch.test.mjs tests/python/mailbox/native_bridge.test.mjs: 13 passed.
  • .venv/bin/ruff check python tests examples, scoped Python formatting, git diff --check, and changed-document relative-link checks: passed.
  • Maturin locked wheel build, installation into a separate target, installed-wheel plugin generation and npm pack --dry-run contents checks: passed.
  • Upstream compatibility checked with Pi 1.5.0 and DSH 0.2.2-rc.1. Real Pi SDK registration/reload/session replacement/concurrent sessions and the real DSH Cordis tool registry were exercised without paid inference.
  • The real Pi harness used deterministic, in-memory model events to read, claim and finish mail, then exercised cancellation-pausing and the actual /pulsing resume command. Zero external model requests or real API keys were used. This is a harness integration test, not a mathematical/model-quality benchmark.
  • Cross-companion Pi/DSH mail exchange and remote delivery while the receiver is awaiting mail were tested with real actors/MCP processes on one machine.
  • Optional SDK checks require PULSING_NATIVE_SDK_ROOT; the public docs give pinned local installation commands. CI does not invoke paid models. Local dependencies, profiles, credentials and private experimental artifacts are excluded.

Scope and limitations

  • Automatic scheduling is implemented for Pi only; this is Pi coding agent extension integration, not Pi Durable or a Rivet-compatible harness.
  • Mail and scheduling state remain in memory. No persistence/recovery, exactly-once business effects, full Task/Run/Acceptance ledger, deadline/token budget, lease renewal, artifact transfer or cross-node failover is introduced.
  • Per-session automatic-attempt limits are not a cost guarantee. A submitted notification does not mean work was accepted, completed or reviewed.
  • Native permissions are preserved; mail is untrusted data and cannot expand operator authority. This remains a trusted private-cluster prototype, not hostile-node authentication or a sandbox.
  • Physical multi-host networking and paid-model autonomous collaboration were not tested for this revision. Standalone lifecycle/signal handling targets the existing POSIX launcher.
  • Rust unit tests/Clippy and the documentation site build were not rerun locally; no Rust source changed. The full Python check above excludes the chaos test file.

Review entry points

  • python/pulsing/mailbox/signals.py and actors.py: delivery edges, cursors, bounded waits and observations.
  • python/pulsing/mailbox/plugins/dispatch.mjs and pi.mjs: bounded scheduler and native Pi lifecycle binding.
  • python/pulsing/mailbox/plugins/bridge.mjs, dsh.mjs, and native.py: shared transport, bootstrap and plugin packaging.
  • tests/python/mailbox/test_dispatch.py, dispatch.test.mjs, and dispatch_sdk_probe.mjs: concurrency, cancellation, limits and real harness execution.
  • docs/src/design/native-agent-plugins.md and docs/src/design/message-dispatch.md: installation, operator controls and guarantees.

Builds on #80.

await signals.wait("worker", "old", 0, 60)
pending.cancel()
with pytest.raises(asyncio.CancelledError):
await pending
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.62162% with 63 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
python/pulsing/mailbox/__main__.py 0.00% 18 Missing ⚠️
python/pulsing/cli/launch.py 0.00% 14 Missing ⚠️
python/pulsing/mailbox/companion.py 0.00% 13 Missing ⚠️
python/pulsing/mailbox/mcp.py 0.00% 6 Missing ⚠️
python/pulsing/mailbox/actors.py 89.74% 4 Missing ⚠️
python/pulsing/mailbox/signals.py 93.75% 4 Missing ⚠️
python/pulsing/mailbox/native.py 95.23% 3 Missing ⚠️
python/pulsing/mailbox/replay.py 80.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
python/pulsing/mailbox/replay.py 84.93% <80.00%> (ø)
python/pulsing/mailbox/native.py 95.23% <95.23%> (ø)
python/pulsing/mailbox/actors.py 89.66% <89.74%> (ø)
python/pulsing/mailbox/signals.py 93.75% <93.75%> (ø)
python/pulsing/mailbox/mcp.py 0.00% <0.00%> (ø)
python/pulsing/mailbox/companion.py 0.00% <0.00%> (ø)
python/pulsing/cli/launch.py 35.09% <0.00%> (ø)
python/pulsing/mailbox/__main__.py 0.00% <0.00%> (ø)

... and 78 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

3 participants