feat(delivery): per-identity watcher liveness in status#436
Open
Masashi-Ono0611 wants to merge 4 commits into
Open
feat(delivery): per-identity watcher liveness in status#436Masashi-Ono0611 wants to merge 4 commits into
Masashi-Ono0611 wants to merge 4 commits into
Conversation
Extend delivery.sh status for monitor-tool types (watch.sh ready-file path) so each registered identity reports alive/not-running with the same granularity as Codex bridge lines. Keeps the aggregate watch count for non-actas watchers; codex plug unchanged.
Rebuild monitor-tool watcher liveness in delivery.sh status on the shared ready-sentinel primitive from fujibee#372 (@u-ichi): - add scripts/receiver-live.sh (credit fujibee#372; composite instance-id fallback for today's watch.sh ready tokens plus optional --pid) - delivery status prints "Watcher: team/agent alive|not running" by calling receiver-live.sh per registered identity - codex bridge status path unchanged; aggregate watch count kept Tests cover composite tokens, explicit pid= form, missing/dead ready, and shared use from claude-code identities.
Address card-3 P1s from multi-model review: - receiver-live.sh probes watch.<token>.pid (the watcher), not the agent pid embedded in composite ready tokens, so a live agent with a dead watcher is no longer false-alive - delivery status falls back to scoped broad-watcher detection when an identity has no exclusive ready file (Claude Code SessionStart path), printing "no exclusive receiver (broad watcher alive, pid N)" instead of a hard not-running Credits fujibee#372 (@u-ichi) for the ready-path primitive.
1 task
…e no-ps Two P1s found by /review:self-multi-model (Codex + Fugu, independently converging on both), plus one P2 (Codex): - agmsg_delivery_find_broad_watcher_pid matched any watch.sh cmdline containing " <project> <type> " as a substring. An EXCLUSIVE watcher's argv (watch.sh <sid> <project> <type> <agent>) also contains that substring, so it could be misreported as "broad watcher coverage" for a completely different agent that actually has zero receivers. Now requires project/type to be the TRAILING tokens (no agent arg after them), which is true only for a genuinely broad invocation. - In Claude Code sandboxes where `ps` is unavailable, compat_get_cmdline returns empty, so both this function's and receiver-live.sh's mandatory argv checks rejected every live watcher — reporting "not running" even though watch.sh's own self-clean logic already has a documented fallback for exactly this environment. Both now skip argv validation and trust kill -0 alone when cmdline can't be inspected (falling back to "the sole live watcher, if unambiguous" for the broad-watcher scan, since it can't disambiguate across multiple untyped candidates without argv). - receiver-live.sh's pid-recycling defense only checked that the live pid's cmdline generically looked like watch.sh, not that it was watch.sh FOR THIS agent — a recycled pid landing on an unrelated watcher (different team/role) could false-alive. Now also requires the agent name as a trailing argument.
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
Extends
delivery.sh statusso monitor-tool agent types (watch.sh receive path) report per-identity receiver liveness at the same granularity as the existing Codex bridge lines.watch.<token>.pid(the watcher process, not the agent CLI pid embedded in composite instance ids) + cmdline matchACTIVE_NAME): no per-identity ready file — reportno exclusive receiver (broad watcher alive, pid N)instead of a falsenot runningwatch processes: N alive, M staleline kept; Codex plug unchangedExample output
Credits / related
receiver-live.shprimitive). This PR ships an extendedscripts/receiver-live.shthat probes the watcher pidfile rather than onlykill -0on a ready-file pid field, so status is accurate for exclusive actas watchers.claims.sh/ DB table) — orthogonal and left to that PR.Test plan
bats tests/test_delivery.bats -f 'delivery status'— green (includes exclusive alive, agent-alive/watcher-dead false-alive guard, broad coverage, not running)receiver-live.shdirect cases for missing ready / agent-only compositeNotes
watch.shpidfiles, not by writing ready files for them.Update (2026-07-19): additional review pass, three more fixes
A follow-up
/review:self-multi-modelpass (Codex + Fugu, independentlyconverging on two of these) found real gaps before this had any maintainer
eyes on it, now fixed in the latest commit:
watch.shcmdline containing" <project> <type> "as a substring. AnEXCLUSIVE watcher's argv (
watch.sh <sid> <project> <type> <agent>) alsocontains that substring, so it could misreport an exclusive watcher for a
DIFFERENT agent as "broad coverage" for an identity that actually has zero
receivers. Now requires project/type to be the trailing tokens (nothing
after them), true only for a genuinely broad invocation.
psis unavailable,compat_get_cmdlinereturns empty, so both thebroad-watcher scan's and
receiver-live.sh's mandatory argv checksrejected every live watcher — reporting "not running" even though
watch.sh's own self-clean logic already has a documented fallback forexactly this environment. Both now skip argv validation and trust
kill -0alone when cmdline can't be inspected (the broad-watcher scanfalls back to "the sole live watcher, if unambiguous," since it can't
disambiguate across multiple untyped candidates without argv).
receiver-live.shonly checkedthat a live pid's cmdline generically looked like
watch.sh, not that itwas
watch.shfor THIS agent — a recycled pid landing on an unrelatedwatcher (different team/role) could false-alive. Now also requires the
agent name as a trailing argument.
New regression tests added for all three (
tests/test_delivery.bats,including a mocked-
ps-failure harness reused from the existing pattern intest_team.bats). Full suite re-verified: 737/737 (this worktree's copy ofthe pre-existing
install: watch.sh self-cleans...flake did not reproduceon this run).