Skip to content

feat(batch): batch.onLocked — wait or fail instead of silently paying exact when another process owns the channel - #97

Merged
VickyXAI merged 1 commit into
mainfrom
feat/batch-on-locked
Oct 27, 2026
Merged

VickyXAI merged 1 commit into
mainfrom
feat/batch-on-locked

Conversation

@VickyXAI

Copy link
Copy Markdown
Contributor

Refs #96 (the docs and option half; multi-process channel sharing stays open there).

Problem

Batch pays in one process per wallet: the process that opens the channel holds the store's lock until it exits. Other processes on the wallet (worker pools, PM2/cluster, parallel benchmarks) paid exact, 1.5–2.5x the metered price, and the only sign was a channel_store_locked fallback event. Agent Money Bench hit it 3/3 times with 3 processes.

Change

  • New batch.onLocked: "exact" | "wait" | "throw", default "exact", so nothing changes unless you opt in.
    • "wait": one backoff event (channel_store_locked), then the lock is tried every 500 ms up to batch.lockWaitMs (default 60000). The call pays with batch once the owner exits; if the wait runs out it raises.
    • "throw": raises at once.
  • New BatchChannelLockedError (wallet, ownerPid, waitedMs). It is raised before anything is signed, with disposition "unpaid", so fallback models may move on. A process that lost its lock to another owner raises it too, unless onLocked is "exact".
  • README states the one-process-per-wallet rule and the workaround (one wallet per worker). The same goes in docs/solana-batch.md, CHANGELOG and CLAUDE.md.

Tests

Five new tests: throw (unpaid, only the challenge sent, no exact); wait then batch once the lock frees; wait running out (raises, never exact); the default stays exact; bad options are rejected. Full local CI: build, lint, tsc, 1083 passed / 12 skipped, router-core 0.

…hannel lock instead of paying exact

Refs #96. Batch pays in one process per wallet; other processes paid exact silently. onLocked: "exact" (default, unchanged) | "wait" (up to lockWaitMs, default 60 s) | "throw" (BatchChannelLockedError, unpaid, nothing signed). README now states the one-process-per-wallet rule.
@VickyXAI
VickyXAI merged commit 2c8af6f into main Oct 27, 2026
3 checks passed
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.

1 participant