feat: per-job completion pub/sub channel for zero-poll waiting#103
Merged
Conversation
- Add publishJobDone() method that fires redis.PUBLISH to cca:job:done:{job_id}
and LPUSH to cca:job:done:{job_id}:queue after every terminal-state transition
- Guarantees PUBLISH fires AFTER persistJob: ioredis queues commands in order so
the SET from saveJob always precedes the PUBLISH on the same connection
- Add wait_for_job MCP tool that polls until job is terminal (done/failed/cancelled/
rejected/interrupted) with configurable timeout, returning status + score
- Update get_job_status and list_jobs descriptions to mention the pub/sub channel
and wait_for_job as the preferred waiting mechanisms over manual polling
- Add pub_sub_channel field to get_job_status response for discoverability
- Add 3 tests verifying PUBLISH and LPUSH fire on job completion with correct payload
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cca:job:done:{job_id}on every terminal-state transition (done, failed, cancelled, rejected) so external coordinators canSUBSCRIBEand get notified instantly instead of pollingcca:job:done:{job_id}:queueso the newwait_for_jobMCP tool can use BLPOP-style waiting without a dedicated subscriber connectionwait_for_jobMCP tool blocks until a job reaches a terminal state (or timeout) — far cheaper than callers pollingget_job_statusin a loopget_job_statusresponse includespub_sub_channelfield for discoverability; description mentions pub/sub as preferred waiting mechanismlist_jobs+get_job_statusdescriptions explicitly mention the patternKey design decisions
publishJobDonealways fires afterpersistJobvia ioredis command-queue ordering — theSETfromsaveJobis queued before thePUBLISH, so subscribers always see the final state when they query the job recordrun()finally block (done/failed), Docker finally block, approval timeout (rejected), doApprove catch (failed)typeof redis.lpush === 'function'so PUBLISH still works even if the queue path failsTest plan
npm testpasses — 280 pass, 12 pre-existing failures inmeta-agent.test.ts(unchanged)saveJobis called beforepublishJobDone🤖 Generated with Claude Code