Repository navigation
fix(j5): a delivery alarm tells its sender - #658
Conversation
When a delivery alarmed because its receiver couldn't be reached, nobody was told: only a peer server's refusal sent the sender a not-delivered notice. Every alarm now sends the sender that same notice, once, naming the receiver and what the last attempt failed with. An alarmed ask's Exchange stays open for the sender to withdraw, since the ask may still have arrived. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Jacksondr5
left a comment
There was a problem hiding this comment.
Review panel: Claude Opus 5.5 + GPT-6-Astra
Both reviewers checked these findings independently against the source at f5d96e3.
What holds: the notice is committed in the same transaction as the alarm (DeliveryWorker.ts recordFailure). Refusal and alarm are separate branches, the command id is stable per attempt, and alarmed rows are never re-driven. Peer removal skips a message whose notice id is already recorded. Keeping an alarmed ask's Exchange open is right: an alarm is uncertainty, not a decision by the receiver. It matches AC12, Fleet AC24 and the failed-delivery scenario, and SilenceDetector.dependencyNotice still reports accurately. The focused tests drive the real worker and ledger, and they pass.
1. A local alarm promises the message wasn't delivered, though it may have been
DeliveryWorker.ts:591 sets mayHaveArrived only when the receiver is on a peer server. So a local alarm's notice says "was not delivered" (deliveryNotices.ts:100). But a local steer can still land after the alarm: DeliveryTransport.ts:382 times out only the wait, and docs/user/j5-peer-messages.md already says a delayed acknowledgment may still arrive. A sender told "was not delivered" may repeat work that already landed. For a local ask, the same notice also says "if the ask did arrive, its reply still comes on it", which contradicts its first line. Suggest using the "may not have been delivered" wording for every alarm, which also removes a branch.
2. The docs promise that every alarm tells its sender, but a sender on a peer server is never told
docs/j5/product/a2a/index.md:74, AC12 (:129) and docs/j5/product/cross-device.md:46 say an alarmed message is reported to its sender. In cross-device, that sentence comes right after the one about the peer server's own delivery alarming there. But alarmNotices returns nothing when origin_environment_id is set (DeliveryWorker.ts:570-574). Concretely: A sends to B, gets B's receipt, and then B's local delivery alarms. Nobody is told on either server. The PR body discloses this, but the product definition and AC12 don't. We're not asking for machinery to cover it (a peer server only accepts Exchange-shaped platform notices, PeerInboundService.ts:266-283). Suggest stating the exception in both docs and AC12, for example "a sender on a peer server is not told". A small test pinning the exclusion would keep it deliberate.
Live test (two peered servers, Claude Haiku 5.5 and GPT-6-Luna)
- Remote stopped: a plain message and an ask from Local each alarmed after 3 attempts, and each gave exactly one notice. The ask's Exchange stayed open, and its notice named
j5_clear_own_ask. After a restart, the same two notices remained, and nothing was re-driven when Remote came back. - Refusals (recipient archived on a running Remote): one notice each. A fresh refused ask got one notice, and its Exchange closed.
- Peer removed after the alarms: no second not-delivered notice. The open alarmed ask got one separate exchange-dropped notice that closed it, which is correct new information.
- Not exercised live: a local delivery failure, an alarm on a message from a peer server, polling, and the platform-sender exclusions. Unit tests cover the local failure and a notice's own alarm.
Evidence:
- Plain message alarm: https://raw.githubusercontent.com/Jacksondr5/j5code/j5/evidence/pr-658/astra-plain-alarm-dcc33e19.png
- Ask alarm, Exchange still open: https://raw.githubusercontent.com/Jacksondr5/j5code/j5/evidence/pr-658/astra-open-ask-alarm-ef77ab57.png
- Refused ask: https://raw.githubusercontent.com/Jacksondr5/j5code/j5/evidence/pr-658/astra-refused-ask-e215c7ac.png
- Peer removal's exchange-dropped notice: https://raw.githubusercontent.com/Jacksondr5/j5code/j5/evidence/pr-658/astra-peer-removal-0738aa79.png
A local steer can land after its wait times out, so a local alarm no longer claims the message was not delivered. The a2a and cross-device definitions now state that a sender on a peer server is not told of an alarm on the receiving server after its receipt; a test pins that exclusion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re: panel review. Both findings are fixed in 1914773.
The PR description's live-testing section now carries the panel's results. — Claude Opus 5.5 (Claude Code) |
|
Re: CodeRabbit's Linked Issues warning, about a message from a peer server that alarms on its local delivery. This exception is deliberate, so I'm leaving the code as it is. The review panel asked for it in its review. A peer server accepts a platform notice only for an Exchange ( Instead, the a2a definition, AC12 and cross-device now state the exception, and a test checks that it sends no notice. — Claude Opus 5.5 (Claude Code) |
bryantderosier
left a comment
There was a problem hiding this comment.
Looks good to me. I couldn't break the core of it: the alarm and the notice go out in one transaction, the fixed notice ID means peer removal's alreadyTold check skips its own notice so the sender only hears about it once, and nothing can loop back into a notice. Couple of wording things inline that I'd fix before merging, but nothing blocking.
One test gap too. Nothing tests alarm-then-peer-removal end to end. PeerRemovalService.test.ts forces status='alarmed' with SQL, so no alarm notice ever gets written there. The checklist also says the platform-sender exclusions are covered, but on the alarm path only the lifecycle_notice channel case is. I'd either add one test that drives a direct peer to a real alarm, removes the peer, and checks for exactly one not-delivered notice, or soften that checklist line.
Ran DeliveryWorker, PeerOutbound and PeerRemovalService tests locally at 1914773, all 48 pass.
| readonly error: string; | ||
| }) => | ||
| `${ | ||
| input.serverName === undefined |
There was a problem hiding this comment.
This count can be off. Held-queue rechecks still bump attempts (recordFailure gets row.attempts + 1 either way). So if a receiver's queue is held for an hour, that's about 7–8 rechecks. Resume it, the next real attempt fails once, the alarm fires immediately, and the agent gets told "delivery failed 8 times". The early alarm was already there, but now we're telling an agent a wrong number. Easiest fix is probably just dropping the count ("delivery failed and won't be tried again"). The early alarm after a hold could be its own follow-up.
| `${ | ||
| input.serverName === undefined | ||
| ? `delivery failed ${input.attempts} times` | ||
| : `this server could not reach ${input.serverName} in ${input.attempts} attempts` |
There was a problem hiding this comment.
"could not reach" isn't always true here. This branch also catches cases where the peer did answer, like a 5xx, a protocol mismatch, or a 401. A 401 is the confusing one: if Home removed us, the sender reads "this server could not reach Home in 3 attempts… answered HTTP 401", when what actually happened is Home ended the peering. Maybe "delivery to Home failed" as neutral wording, and use peerCredentialRejectedReason for the 401?
| - **Two questions for the user.** The same agent asks the user "merge now or after the audit?" with urgency _soon_, and separately "may I delete the old branch?". Both appear as inbox items. The agent then learns something relevant to the first question and follows up on it by name; the follow-up appears under that item. The user answers each; each Exchange closes with the exact text delivered to the agent. (AC5, AC7, AC8, AC18) | ||
| - **A busy receiver.** An agent in Website Redesign sends a plain message to a peer whose turn is running a long shell command. The message queues; the peer's turn finishes normally; the message starts its next turn. The user, watching the peer, chooses to steer instead — the control says "Steer now" on this provider — and their text is injected into the running turn. (AC13, AC14) | ||
| - **A failed delivery.** An agent asks a peer that has been archived. The delivery fails, the alarm is attributed to the asker and shown on its Fleet page row; the asker withdraws its ask; the alarm remains a fact but no longer counts as a problem. (AC9, AC12) | ||
| - **A failed delivery.** An agent asks a peer that has been archived. The delivery fails, the alarm is attributed to the asker, told to it in a not-delivered notice, and shown on its Fleet page row; the asker withdraws its ask; the alarm remains a fact but no longer counts as a problem. (AC9, AC12) |
There was a problem hiding this comment.
Small one. An archived receiver doesn't actually alarm. deliveryUnavailable cancels the row, so no alarm and no notice. That was already wrong before this PR, but since this line now promises a notice, maybe swap the trigger for something that really alarms, like an agent on a peer server that's gone offline?
| : flat; | ||
| }; | ||
|
|
||
| /** Why a delivery alarmed, completing "… was not delivered: …". */ |
There was a problem hiding this comment.
nit: comment still says "… was not delivered", but every alarm reads "may not have been delivered" now.
Problem
When an A2A delivery alarmed because its receiver couldn't be reached, nobody was told. Only a peer server's refusal sent the sender a not-delivered notice. So a peer server that was sent to directly and never answered, and a local delivery that used up its attempts, both alarmed silently. The a2a definition calls an alarm "a visible fact attributed to the sender, never a silent loss".
Closes #260
What changed
recordFailureadds it in the same transaction that records the alarm:alarmNoticesinDeliveryWorker.ts. The reason names the receiver and quotes what the last attempt failed with, on one line and bounded, as peer text already is. For example:Your message to agent:…support on Home may not have been delivered: this server could not reach Home in 3 attempts, and it will not be tried again. The last attempt failed with: "Transport: connect ECONNREFUSED (POST https://home.example:3773/…)"Your message to agent:… may not have been delivered: delivery failed 3 times, and it will not be tried again. The last attempt failed with: "…"mayHaveArrived) for rows attempted directly.canBeNotified.link_mode = 'store') never alarm, and retry timing, re-driving and sweeps are untouched.An alarmed ask keeps its Exchange open
A refused ask is dropped, but an alarmed ask stays open. Its notice says so and gives the way out:
Exchange … is still open; if the ask did arrive, its reply still comes on it. To stop waiting, withdraw it with j5_clear_own_ask, then tell your person or send a new ask.The reasons:docs/user/j5-peer-messages.mdalready says can happen. If we dropped the Exchange, a real reply would arrive on a closed Exchange.dependencyNotice) only fires for an open ask to a human, and it tells a different party: the subject's own asker hears "awaiting the human (human-doesnt-know)". That stays true while the Exchange is open. Dropping it would turn that notice into the less accurate "turn ended without replying". The asker whose ask alarmed gets only the not-delivered notice. For an ask to an agent on a peer server, the subject's asker still hears "blocked on peer", which is still true.Docs: a2a's delivery paragraph, AC12 and the failed-delivery scenario are rewritten, and so is the delivery paragraph in cross-device. Each gets a History line.
Live testing
The review panel ran a live test on two peered servers, with Claude Haiku 5.5 and GPT-6-Luna, at f5d96e3. Verdict: pass. Full report and screenshots are in the panel's review.
j5_clear_own_ask. After a restart nothing was re-driven.Checklist
FORK.md(case text and file-table row) in this PR (none: J5-owned paths only)docs/j5/product/upstream.md(not applicable)AGENTS.md)j5_clear_own_ask, which already exists.docs/j5/product/and user docs rewritten where this changes themBuilt by Claude Opus 5.5 in Claude Code (J5 Code).
🤖 Generated with Claude Code