jonnysteedman683-wq/vorpal/hermes-bus-atomicity

Claude Code and agent skill by jonnysteedman683-wq/vorpal

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install jonnysteedman683-wq/vorpal/hermes-bus-atomicity

SKILL.md

The same SKILL.md was published earlier as jonnysteedman683-wq/vorpal/hermes-bus-atomicity.


name: hermes-bus-atomicity description: Filesystem bus atomicity, claim, and race-condition patterns. category: software-development

Hermes Bus Atomicity — Filesystem-Based Inter-Agent Messaging

Trigger

When building or auditing filesystem-based message buses with multi-consumer race conditions, claim-then-process patterns, or batch task commit semantics.

Core Invariants
InvariantRuleExit Code
G1A consumed packet is invisible to read()consume moves to processing/
G3Batch acked only when ALL tasks = PASSpartial → exit 3
G4Double-ack rejectedre-ack → exit 2
G5Atomic file moves via os.replace()temp file + atomic swap
Two-Layer Locking Pattern
python
_PROC_LOCK = threading.Lock() # in-process thread serialization
LOCK_RETRIES = 50
LOCK_BACKOFF_S = 0.01
def _acquire_claim_lock():
CLAIM_LOCK.parent.mkdir(parents=True, exist_ok=True)
_PROC_LOCK.acquire()
f = open(CLAIM_LOCK, "a+")
try:
# Layer 2: OS advisory lock (msvcrt on Windows, fcntl on Unix)
if msvcrt is not None:
for attempt in range(LOCK_RETRIES):
try:
msvcrt.locking(f.fileno(), msvcrt.LK_LOCK, 1)
break
except OSError:
if attempt == LOCK_RETRIES - 1: raise
time.sleep(LOCK_BACKOFF_S * (attempt + 1))
else:
import fcntl
fcntl.flock(f.fileno(), fcntl.LOCK_EX)
except BaseException:
f.close()
_PROC_LOCK.release()
raise
def _release():
try:
if msvcrt is not None:
msvcrt.locking(f.fileno(), msvcrt.LK_UNLCK, 1)
else:
fcntl.flock(f.fileno(), fcntl.LOCK_UN)
finally:
f.close()
_PROC_LOCK.release()
return _release
TOCTOU-Safe Consume Pattern
python
def consume(profile: str, packet_id: str) -> None:
# BUG: _locate() outside lock → TOCTOU race
# path = _locate(profile, packet_id) # RACE: file moves between here...
# release = _acquire_claim_lock()
# pkt = path.read_text() # ...and here
# FIX: lock BEFORE _locate
release = _acquire_claim_lock()
try:
path = _locate(profile, packet_id)
if path is None:
raise SystemExit(f"packet not found: {packet_id}")
pkt = json.loads(path.read_text(encoding="utf-8"))
if pkt.get("status") != "pending":
raise SystemExit(2) # already claimed/acked
# move to processing/ atomically
proc = inbox / "processing"
proc.mkdir(parents=True, exist_ok=True)
tmp = proc / f"{packet_id}.claiming"
with open(tmp, "w") as f:
json.dump(pkt, f)
os.replace(tmp, proc / f"{packet_id}.json")
path.unlink(missing_ok=True)
finally:
release()
Batch Task Commit (G3)
python
def ack(profile, packet_id):
release = _acquire_claim_lock()
try:
pkt = json.loads(path.read_text())
if pkt["status"] not in ("pending", "processing"):
raise SystemExit(2) # double-ack
tasks = pkt.get("payload", {}).get("tasks")
if isinstance(tasks, list) and tasks:
states = pkt.get("task_status") or []
done = [s for s in states if s == "PASS"]
if len(done) != len(tasks):
raise SystemExit(3) # partial batch
pkt["status"] = "acked"
path.write_text(json.dumps(pkt))
finally:
release()
Test Harness — bus_atomicity_test.py
python
# B1: claim-vs-read race — consumed packet invisible to read()
# B2: double-exec — N concurrent consumers, exactly 1 winner, rest get exit 2
# B3: no-double-ack — second ack() returns exit 2
# B4: batch partial — ack@0/3=3, ack@1/3=3, ack@3/3=0
Pattern Proved

Lock before locate. Always. The two-layer lock (thread mutex + OS advisory) serializes both same-process threads and cross-process cron jobs.

Security

  • Security scanPassed, 98 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jonnysteedman683-wq/vorpal/hermes-bus-atomicity/badge)](https://verified-skill.com/skills/jonnysteedman683-wq/vorpal/hermes-bus-atomicity)

Something wrong with this skill or its page? Tell us.