tx

tx block

Add blocking dependencies between tasks

Purpose

tx block creates a dependency between two tasks. The blocked task cannot be ready until the blocker is marked done.

tx enforces two rules to maintain consistency:

  1. No self-blocking: A task cannot block itself
  2. No cycles: A->B->C->A chains are not allowed

Usage

# Add a blocker: blocker-id must complete before task-id can start
tx block <task-id> <blocker-id> [options]

# Remove a blocker
tx unblock <task-id> <blocker-id>

Arguments

ArgumentRequiredDescription
<task-id>YesThe task that will be blocked
<blocker-id>YesThe task that blocks it

Options

OptionDescription
--jsonOutput as JSON
--helpShow help

Examples

# tx-def456 blocks tx-abc123
tx block tx-abc123 tx-def456

# Add multiple blockers to a single task
tx block tx-feature tx-design
tx block tx-feature tx-api
tx block tx-feature tx-tests

# Remove a blocker
tx unblock tx-abc123 tx-def456
import { TxClient } from '@jamesaphoenix/tx-agent-sdk'

const tx = new TxClient({ apiUrl: 'http://localhost:3456' })

// Add blocker: blockerId must complete before id can start
const task = await tx.tasks.block('tx-abc123', 'tx-def456')

// Remove blocker
const task = await tx.tasks.unblock('tx-abc123', 'tx-def456')

tx_block

Add a blocking dependency between two tasks.

{
  "tool": "tx_block",
  "arguments": {
    "taskId": "tx-abc123",
    "blockerId": "tx-def456"
  }
}

tx_unblock

Remove a blocking dependency.

{
  "tool": "tx_unblock",
  "arguments": {
    "taskId": "tx-abc123",
    "blockerId": "tx-def456"
  }
}

Add a blocker

POST /api/tasks/:id/block
Content-Type: application/json

{
  "blockerId": "tx-def456"
}

Remove a blocker

DELETE /api/tasks/:id/block/:blockerId

Example

# Add blocker
curl -X POST http://localhost:3456/api/tasks/tx-abc123/block \
  -H "Content-Type: application/json" \
  -d '{"blockerId": "tx-def456"}'

# Remove blocker
curl -X DELETE http://localhost:3456/api/tasks/tx-abc123/block/tx-def456

Output

Text Output

Dependency added: tx-def456 now blocks tx-abc123

Task tx-abc123:
  Status: blocked
  Blocked by: tx-def456

JSON Output

{
  "task": {
    "id": "tx-abc123",
    "title": "Implement login page",
    "status": "blocked",
    "blockedBy": ["tx-def456"],
    "blocks": [],
    "children": [],
    "isReady": false
  }
}

Cycle Detection

tx uses BFS (Breadth-First Search) to detect cycles at insert time:

# This would create a cycle and will be rejected
tx block tx-a tx-b
tx block tx-b tx-c
tx block tx-c tx-a  # Error: Would create cycle A->B->C->A

Error output:

Error: Cannot add dependency - would create cycle: tx-a -> tx-b -> tx-c -> tx-a

Dependency Visualization

Use tx tree to visualize task dependencies:

tx tree tx-feature

tx-feature (blocked)
├── tx-design (done) ✓
├── tx-api (active)
└── tx-tests (blocked)
    └── tx-unit (ready)

Agent Workflow

#!/bin/bash
# Decompose a task into subtasks with dependencies

# Create main task
MAIN=$(tx add "Build user profile page" --json | jq -r '.id')

# Create subtasks
API=$(tx add "Create profile API endpoint" --parent "$MAIN" --json | jq -r '.id')
UI=$(tx add "Build profile UI component" --parent "$MAIN" --json | jq -r '.id')
TEST=$(tx add "Write integration tests" --parent "$MAIN" --json | jq -r '.id')

# Set dependencies: UI depends on API, tests depend on both
tx block "$UI" "$API"
tx block "$TEST" "$API"
tx block "$TEST" "$UI"
  • tx unblock - Remove a blocking dependency
  • tx ready - List tasks with no blockers
  • tx done - Complete a task and unblock dependents

On this page