skills/hoare-1978-csp/SKILL.md
Foundational theory for process-oriented concurrency through synchronous message-passing, applicable to multi-agent coordination and parallel decomposition
npx skillsauth add curiositech/windags-skills hoare-1978-cspInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Description: Foundational theory for process-oriented concurrency through synchronous message-passing Activation triggers: Multi-agent coordination protocols, parallel task decomposition, deadlock debugging, coordination failures
IF task has clear data transformations (input → process → output)
THEN decompose by data flow (each transformation = process)
└── Linear dependencies → pipeline topology
└── Independent branches → parallel processes
└── Convergence points → guarded input selection
IF components need frequent fine-grained data sharing
THEN consider shared-memory model instead
└── Use CSP for coarse-grained coordination only
IF coordination requirements unclear
THEN map all component interactions first
└── Draw communication graph before coding
IF request-response pattern needed
THEN client outputs request, inputs reply
server inputs request, outputs reply
└── Symmetric protocol prevents deadlock
IF streaming data flow
THEN producer: *[output!data]
consumer: *[input?data → process(data)]
└── Termination via channel closure
IF multiple clients, one server
THEN server uses guarded selection:
*[client1?req → handle1(req)
[]client2?req → handle2(req)]
└── Built-in fairness via arbitrary choice
IF communication graph has cycles
THEN prove resource ordering OR redesign topology
└── Cycles require careful justification
IF topology is DAG (no cycles)
THEN deadlock impossible, proceed with design
IF bidirectional communication needed
THEN alternate input/output carefully
└── Never have both processes waiting for same direction
IF pipeline topology
THEN source terminates first → propagates downstream
└── Each stage: *[input?x → process(x)]
IF tree/graph topology
THEN design explicit join points for synchronization
└── Avoid premature termination breaking chains
IF long-running services
THEN use external termination signals
└── CSP suitable for bounded-lifetime tasks
ps shows processes blocked; communication graph has cycles*[input?x → process(x)] only stops when input closesScenario: Auction system where auctioneer coordinates bidder agents
AUCTIONEER =
*[bidder1?bid(amount) → record(1, amount); announce!newbid(1, amount)
[]bidder2?bid(amount) → record(2, amount); announce!newbid(2, amount)
[]bidder3?bid(amount) → record(3, amount); announce!newbid(3, amount)
[]timer?timeout → announce!closed; winner!result
]
BIDDER(id) =
*[announce?newbid(bidder, amount) →
[amount < maxprice → auctioneer!bid(amount + increment)
[]amount >= maxprice → skip
]
[]winner?result → celebrate
]
Decision walkthrough:
Novice mistake: Making bidders poll for auction state instead of using announcements Expert insight: Guards encode bidding strategy (amount < maxprice), selection handles concurrency
Scenario: Data processing pipeline with validation stage that can reject items
// BROKEN VERSION (deadlock prone)
PRODUCER = *[pipeline!item(data)]
VALIDATOR = *[pipeline?item(data) →
[valid(data) → consumer!clean(data)
[]¬valid(data) → skip // PROBLEM: consumer waits forever
]]
CONSUMER = *[validator?clean(data) → process(data)]
Failure analysis:
// FIXED VERSION
VALIDATOR = *[pipeline?item(data) →
[valid(data) → consumer!clean(data)
[]¬valid(data) → consumer!error(data) // Always send something
]]
CONSUMER = *[validator?clean(data) → process(data)
[]validator?error(data) → log_error(data) // Handle both cases
]
Key decisions made:
Don't use CSP for:
Delegate instead:
concurrent-data-structures skillevent-sourcing or reactive-streams skillslock-free-algorithms skilltask-scheduling skilldistributed-consensus skill for cross-network coordinationCSP sweet spot: Medium-grained coordination between independent processes with clear communication boundaries and well-defined protocols.
data-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.