Skip to main content

handoff-fanout

Project-agnostic auto-handoff & parallel fan-out for AI coding sessions. 5-layer defense against orphan tasks, git index hijack, and stale handoffs.

CI License: MIT Python 3.11+

中文文档 / Chinese README

30-second demo


The problem

You're running an AI coding agent (Claude Code / Cursor / Aider) across multiple IDE tabs, often across multiple projects, on a single workstation. Four pain points show up:

# Symptom Root cause
1 A tab finishes its task; the next task never spawns. No standard handoff protocol — every project re-invents an ad-hoc baton.
2 git commit from Tab B silently sweeps in Tab A's git add. .git/index is a repo-shared file. Without a lock, add → commit is not atomic.
3 A session crashes mid-task; downstream sessions inherit a half-baked baseline. No durable "last good baseline" record + no orphan detector.
4 Want to split one task into N parallel sub-tasks but can't coordinate the merge. No fan-out/fan-in primitives that respect file ownership.

handoff-fanout is a small, zero-runtime-dependency Python toolkit that solves all four. It was extracted from a year-old production ERP project where these failures cost real hours, and it's been hardened by three documented commit-hijack incidents (now blocked at four independent layers).

What you get

  • handoff dump — atomically write a queue file describing the next task; the IDE auto-spawn helper picks it up and launches a new tab.
  • handoff dump --open-batch — fan-out: split one task into N sub-tasks, each with strict file_ownership boundaries; a fan-in tab consolidates results.
  • handoff watchdog — fail-safe scanner: triggers fan-in when the last sub-task finishes; flags orphan tabs (e.g. a tab spawned by launchd but whose batch dir got rm-ed under it).
  • handoff safe-commit — wraps git commit with cross-process flock + HANDOFF_EXPECTED_FILES invariant + pre-commit hook integration. No more hijack.
  • handoff heartbeat — fan-in tab heartbeat daemon, Amdahl-speedup metrics, and runtime calibration so your next batch's split decision is data-driven.
  • handoff git-guard — a PATH-injected git wrapper that physically blocks commit/push/rebase/cherry-pick/reset/revert/tag/am/format-patch/merge inside sub-task tabs. The fan-in tab is the only committer.

5-layer defense (the headline)

                ┌──────────────────────────────────────────────────┐
                │  Layer 1 — git-guard (PATH-injected git wrapper) │
                │  Sub-task tabs literally cannot run `git commit`.│
                └──────────────────────────────────────────────────┘
                                       │
                                       ▼
              ┌────────────────────────────────────────────────────┐
              │  Layer 2 — pre-commit hook (HANDOFF_EXPECTED_FILES)│
              │  Rejects commits whose staged set ≠ expected set.  │
              └────────────────────────────────────────────────────┘
                                       │
                                       ▼
          ┌─────────────────────────────────────────────────────────┐
          │  Layer 3 — safe-commit wrapper (flock + invariant)      │
          │  Cross-process lock on ~/.handoff/git-commit.lock.      │
          │  Verifies `git diff --cached --name-only` ⊆ expected.   │
          └─────────────────────────────────────────────────────────┘
                                       │
                                       ▼
       ┌────────────────────────────────────────────────────────────┐
       │  Layer 4 — atomic file primitives (queue / batch writes)   │
       │  atomic_create / write_with_fsync / acquire_dir_lock.      │
       │  No half-written queue files. No torn batch manifests.     │
       └────────────────────────────────────────────────────────────┘
                                       │
                                       ▼
      ┌──────────────────────────────────────────────────────────────┐
      │  Layer 5 — watchdog (orphan / stale / heartbeat scan)        │
      │  Runs from launchd/cron. Re-triggers fan-in if last-one-out  │
      │  silently dies. Marks orphan sub-task tabs BLOCKED.          │
      └──────────────────────────────────────────────────────────────┘

Each layer is independent. Defeating one is not enough — for a hijack to land, all four commit-path layers (1-4) must fail simultaneously.

Quickstart

pip install handoff-fanout

# Idempotent install: symlinks bin/ → ~/.local/bin, generates ~/.handoff/config.json,
# installs git hooks, optionally installs launchd plist (macOS).
curl -L https://raw.githubusercontent.com/rssprivacy-commits/handoff-fanout/main/install/install.sh | bash

# Dump the next task from your current project repo:
cd ~/Projects/my-repo
handoff dump \
    --task fix-bug-123 \
    --next "Fix the off-by-one in the discount calculation." \
    --status active \
    --tests "tests/test_discount.py"

A new file appears at ~/.handoff/my-repo/queue/fix-bug-123.md, the launchd watcher picks it up within one second, and a fresh IDE tab opens already pointed at your repo with that handoff loaded.

How it compares

handoff-fanout Celery Argo Workflows Temporal
Target environment One workstation, multiple IDE tabs Distributed service, many workers Kubernetes cluster Distributed service
Coordination unit An AI coding tab A Python function A pod A workflow function
State store Plain files under ~/.handoff/ Redis / RabbitMQ broker + result backend etcd + K8s objects Cassandra / MySQL + Temporal server
External dependencies None (zero-dep Python) Broker + (often) Redis result backend Full K8s cluster Temporal server + DB
Failure model Atomic file writes + file locks + watchdog Broker durability + ack semantics K8s controller reconciliation Event-sourced durable execution
Cross-process commit safety First-class (4 layers) Out of scope Out of scope Out of scope
Fan-out / fan-in Yes, with file-ownership boundaries Yes (canvas: group/chord/chain) Yes (DAG) Yes (child workflows)
Setup time pip install + install.sh Hours (broker, workers, monitoring) Days (cluster + manifests) Hours (server + workers)
Designed for AI coding-session orchestration Background-job queues CI/CD & ML pipelines Long-running business workflows

The right way to read this: handoff-fanout is not a competitor to Celery / Argo / Temporal — it occupies the corner of the design space those tools deliberately don't enter (one workstation, IDE-tab granularity, no broker, git-aware). If you need durable distributed workflow execution, pick one of those instead.

Documentation

Status

v0.1.0 — public extraction in progress. Source modules ported. Bilingual docs, installer, and CI matrix are part of the v1.0.0 milestone (this branch). The original implementation has been in daily production use since 2024-Q2 across an ERP project with 70+ DB tables and 250+ tests.

Once v1.0.0 ships, the ERP repo will migrate to a thin shim that delegates to this package.

License

MIT — see LICENSE.

Metadata

Release files for handoff-fanout 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for handoff-fanout 1.9.0
File Size Uploaded Provenance Actions
handoff_fanout-1.9.0.tar.gz 1.1 MB Without provenance Details for handoff_fanout-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for handoff-fanout 1.9.0
File Interpreter ABI Platform Actions
handoff_fanout-1.9.0-py3-none-any.whl Python 3 none any Details for handoff_fanout-1.9.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / handoff_fanout-1.9.0.tar.gz

Download URL handoff_fanout-1.9.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
66166ebff0fadf678a43dec7fd24d3ab0d384e721f36be0ab9267b27e95b2d66
BLAKE2b-256 checksum
How to use checksums
92d5a7af9086ddd3b2f62635e52b5b34b5e0d7fad5a3402f832aae0938af875b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / handoff_fanout-1.9.0-py3-none-any.whl

Download URL handoff_fanout-1.9.0-py3-none-any.whl
Size 110.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
366accc0c38a1b65541d3a8def97f8ddbf0a8fe1aa0e95a6c0b09b8012e7ae3f
BLAKE2b-256 checksum
How to use checksums
a60d4a65e932a9febdbe29d6f035f9ad089f1972038bc4e95a9048c005d91003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for handoff-fanout 1.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page