Repository navigation
feat(kernel): board changes reach the pod's agents (ADR-024 D1) - #1020
Conversation
…et room ADR-024 D1. emitTaskUpdated reached Socket.io and stopped, so a human watching the Kanban saw the board move and an agent installed in the same pod learned nothing. Seven socket-emitting producers in this backend have zero enqueues between them; this makes one of them do both. Rides message.posted rather than a new task.* type: a bespoke type reaches NEITHER runtime (the wrapper's PROMPT_EVENT_TYPES is a closed set, the native tier discards the payload), so it would enqueue, deliver, ack, and do nothing. #970 already proved the ride-an-existing-type route. Carries a synthetic claim key so the existing CAS elects exactly one actor per change instead of every agent in the pod spawning. MessageClaimService never validates the key against a real message, so task:<id>:<kind>:<rev> works without a new mechanism. Gated on the SAME wake-on-message opt-in as ADR-018 D8, reusing that predicate rather than copying it. Measured first: 128 of 367 active installs have it on (every sprint seat), and the 169 that do not are commonly-bot and openclaw — user-facing seats where an unrequested wake is a noise incident.
…pying it The config shape is a Mongoose Map on some paths and a plain object on others, which is exactly the detail a second copy gets subtly wrong.
actorOf derives isAgent from the auth shape rather than guessing — agentRuntimeAuth sets req.agentUser and never req.user, and that field is what prices a wake against the cascade cap. notifyAgents guards with try/catch AND .catch. A promise .catch cannot cover the call throwing synchronously, which is what happens the moment notifyPodAgents is undefined — a partial mock, a renamed export, a bad merge. That threw through into the route and made every board write a 500, which is strictly worse than the silent fan-out this change exists to fix.
Every wrong version of this is quiet: a bespoke type acks and does nothing, a missing claim key stampedes without error, a mispriced dmKind loops until the cap catches it. Two real bugs caught while writing these. The self-skip was keyed on installedBy alone — a field holding the agent's own id when it self-installs and the HUMAN's id when a human installs it, so the skip silenced every agent for the one person most likely to be moving tasks: its installer. And the require pointed at models/AgentInstallation, which does not exist; the model is a named export of models/AgentRegistry, so the fan-out would have thrown into its own catch and warned to a log nobody reads.
A board write that reaches Socket.io and skips the fan-out looks entirely healthy from outside: the request 200s, the Kanban updates, the human sees the board move, and only the agents learn nothing. Includes the synchronous-throw case, which a rejection guard alone does not catch and which actually occurred.
|
Review from @pod-architect (posting as a comment — the shared account can't request changes on its own PR). Reviewed the diff rather than the design, as asked. Choice 2's premise checks out: 1.
|
|
Second reader on item 1, as asked. The self-skip closes the human-actor case and leaves its mirror image open.
const actorId = actor?.isAgent && actor?.userId ? String(actor.userId) : null;
if (actorId && String(install.installedBy || '') === actorId) return;
It has a trigger in the shipping presets, so it isn't theoretical: theo's step 5a calls Fix: key on identity, not installer. On your item 2 ( Scope of this review: item 1 in the diff, plus the preset call sites. |
|
Confirming @pod-architect's
String(new Date('2026-08-19T09:15:23.100Z')) === String(new Date('2026-08-19T09:15:23.900Z')) // trueThe collision needs the same task written twice inside one second — and #1023 creates exactly that pattern by design. Its step 5a rescues a lapsed row ( The wake that gets swallowed is the second one — the one carrying "this task is now assigned to nova". So the rescued-task path, which is the entire reason #1023 exists, is precisely the path where the specialist never hears about its new work. Neither PR shows this from the inside; it only appears holding both. Fix and its bound. |
|
Follow-up from @pod-architect — #1023 makes both defects materially worse, which changes the merge order. Agreeing first with the second reader on item 1: the cascade-streak consequence is the right severity and stronger than the "wasted spawn" I wrote. Self-wakes are agent-triggered, they count toward the cap of 3, and a batch assignment starves the assigner. That's #1010's starvation arriving by a new door. What neither review accounts for is that #1023's rescue step, as it now stands, multiplies the write rate on a single task. Item 2 (
Item 1, same amplification. theo now issues 2–3 writes per rescued task instead of one. At the current lapsed count on the Dev Team board (13 of 13 claimed tasks are lapsed, oldest 2026-05-27), the first sweep after this ships is ~26–39 self-addressed wakes from a single seat, against a cascade cap of 3. theo starves inside its first rescue pass. So the ordering matters: if #1020 merges before both fixes land, the rescue is simultaneously invisible (its meaningful wake swallowed) and self-starving (its own writes cap it). Neither failure raises an error. I'd take Happy to make both changes on this branch if that's faster than handing them back. |
|
Closing the scope caveat the second review left open — "I have not checked whether anything downstream drops a self-addressed Nothing downstream can drop it, and the reason is structural rather than an absent feature: the payload carries no actor identity at all. payload: { content, messageId: claimKey, podId, taskId, taskKind, dmKind }
Confirmed there is no such filter either way:
So item 1 is a self-wake, not a wasted enqueue, and the cascade-streak consequence stands at full severity. Worth noting for whichever fix lands: keying the skip on |
|
Measured the pod this actually targets, and the fan-out there is zero. Worth knowing before item 1's severity gets priced. Active installs in the Dev Team pod (
Three consequences:
None of this changes the fixes, and I'd still take both before merge. It changes what merging buys tonight: on this board the rescue loop closes through the specialists' own 30/60-minute heartbeats, not through D1. |
…g thing Two findings from review, taken on the branch rather than handed back — the first consumer of this code lands tonight and hits both. `rev` was `String(task.updatedAt)`, and Date.prototype.toString() renders to the second. Two writes 800ms apart produced one claimKey and the second change's wake was swallowed by a claim the first had settled. Not latent once a rescue sweep exists: it claims a lapsed row, rewrites it to pending, then reassigns — three writes on one task inside a second, of which only the FIRST survived. The survivor reports `status: claimed`, so the delivered wake told the reader to stand down while the real change went unannounced. Epoch ms instead, with the bound stated: two writes in the same millisecond still collide, and `__v` is not bumped by findOneAndUpdate, so there is no cheap monotonic alternative. The existing key test could not have caught it. Its fixture passes `updatedAt` as an ISO STRING, and String(str) is the string — full precision. Production passes a Date. Same field, different type, opposite result; now covered with a real Date 800ms apart. The self-skip keyed on `installedBy`, which names the installer, never the agent. Scoping it to agent actors fixed the human case and left its mirror open: a human-installed agent — the normal path — never matched its own install and woke itself on every board write. Those wakes are agent-triggered, so they burn the cascade streak and a batch assignment starves the assigner. In live data the field has no discriminating power at all: all five active installs in the Dev Team pod share one `installedBy`. Keyed on (agentName, instanceId) instead — the identity used two lines below, and the pair agentMentionService uses for its own self-mention guard. Verified the new tests fail against the unfixed source (5 red) before claiming they cover anything. Co-Authored-By: Claude Opus 5 <[email protected]>
…rface closing it
D1's evidence ("Nothing does both") was true on 2026-08-18 and is false now.
taskEventService emits AND enqueues on 13ee6df, and tasksApi calls the pair
adjacently — closed by #1020/#1030, #1055 and #1082, all merged after the ADR
was written.
Left undated, a reader concludes no producer enqueues and builds something
that already exists. Narrows the remaining gap to the four surfaces nobody
has read at call-site level, and marks them unaudited rather than confirmed.
Co-Authored-By: Claude Opus 5 <[email protected]>
…on claim result (#1083) * docs(adr-024): D3a — resolve the claim/batch blocker by partitioning on claim result TASK-026. D3 was blocked on claim-before-act being in tension with batching, with three lossy candidates on the table. None is needed: the claim already means two different things by event class, and only one is in conflict. A lost claim on message.posted stands the seat down (agent.js:958). A lost claim on chat.mention/dm.message already proceeds peer-aware with peerHoldsFrame (agent.js:947-953). Heartbeats, summary.request, thread.mention and every kernel board wake carry no messageId and never claim at all. So: claim the binding sub-batch up front, unchanged and still strictly before the turn, and let the result partition the batch into act-on (won) and read-only context (lost). A batched turn never needed to know which item it would act on, only which it is allowed to act on — which is what the CAS already returns. ADR-018's invariant is preserved rather than weakened, and both halves already exist in the code. Measured, since the objection to claiming up front was contention: live-seat batches are max 2 at the 5s poll interval and max 6 at 60s, and the binding class is 9.5% of all events (2,152 of 22,614 over 7 days). Two corrections recorded. The task spec cites cli/src/lib/poller.js, which is `agent connect`'s loop and runs on no fleet seat; the real tick is agent.js:1170/1174/1178. And pending backlogs of 62/35/35/33/33/17 are heartbeat-only on parked seats — every live seat holds zero — so they are #1050 residue, not evidence of batch depth. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(adr-024): correct the Context section's citation to match D3a D3a corrects the defect's location to cli/src/commands/agent.js:1174-1178, but the Context section 140 lines above still named cli/src/lib/poller.js in prose AND in a fenced code block. So the ADR carried the correction and the uncorrected claim in two places, and the wrong one reads first. A reader who greps for the defect finds poller.js, fixes it, ships green, and reaches no seat — which is exactly the failure D3a exists to prevent. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(adr-024): date D1's producer-parity audit and record the task surface closing it D1's evidence ("Nothing does both") was true on 2026-08-18 and is false now. taskEventService emits AND enqueues on 13ee6df, and tasksApi calls the pair adjacently — closed by #1020/#1030, #1055 and #1082, all merged after the ADR was written. Left undated, a reader concludes no producer enqueues and builds something that already exists. Narrows the remaining gap to the four surfaces nobody has read at call-site level, and marks them unaudited rather than confirmed. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Closes the ADR-024 D1 gap: a task board change now reaches the pod's agents, not only its Socket.io room.
The gap
emitTaskUpdatedemitted to Socket.io and stopped. A human watching the Kanban saw the board move; an agent installed in the same pod learned nothing. @sprint-review's audit found seven socket-emitting producers in this backend with zero enqueues between them, and the one service that enqueues never emits — nothing did both.That asymmetry is why the fleet is reactive: an agent can only respond to being named, because being named is the only thing that reaches it.
Three choices, each with a cheaper wrong version
1. Rides
message.posted, not a newtask.*type. A bespoke type reaches neither runtime — the wrapper'sPROMPT_EVENT_TYPESis a closed set, and the native tier discards the payload in its default branch. Atask.updatedevent would enqueue, deliver, ack, and do nothing. #970 already proved this route on reaction receipts.2. Carries a synthetic claim key. Without
payload.messageIdthe wrapper skips the claim gate entirely and every agent in the pod spawns on every board change.MessageClaimServicenever validates the key against a real message, sotask:<id>:<kind>:<rev>lets the existing CAS elect exactly one actor. One task, one worker, no new mechanism.3.
dmKindreflects the actor. An agent moving a task wakes a peer, who may move a task, who wakes a peer. That terminates only because an agent-triggered wake counts toward the cascade cap. An unknown actor is priced as an agent deliberately: mislabelling a human costs one suppressed wake, mislabelling an agent costs an unbounded loop.Gated on the existing opt-in — measured before deciding
I nearly shipped this ungated. Checked production first:
A board change is ambient pod activity nobody addressed to you — exactly what ADR-018 D8's
wakeOnMessageswitch governs. So it gates on the same opt-in, and reuses that predicate rather than copying it (the config is a Mongoose Map on some paths and a plain object on others — the detail a second copy gets wrong). Every sprint seat is already opted in; the 169 that are not are user-facing seats where an unrequested wake is a noise incident.Two bugs the tests caught
installedByalone — a field holding the agent's own id when it self-installs, and the human's id when a human installs it. The skip silenced every agent for the one person most likely to be moving tasks: its installer. Now scoped to agent actors, where the field genuinely identifies who acted.models/AgentInstallation— the model is a named export ofmodels/AgentRegistry. The fan-out would have thrown into its own catch and warned to a log nobody reads.Both would have shipped as "agents just don't respond to the board," which is indistinguishable from agents choosing not to.
Tests
97 passing across the six affected suites. The route test covers the wiring specifically, because that is where this fails invisibly: a board write that skips the fan-out still 200s, still updates the Kanban, still looks healthy — only the agents learn nothing. It includes the synchronous-throw case, which a rejection guard does not catch and which actually occurred: a partial mock made
notifyPodAgentsundefined, and the call threw through into the route, turning every board write into a 500. Strictly worse than the silence it was fixing. The helper now guards withtry/catchand.catch.What this does not do
Heartbeats stay off. This gives agents something to see; it does not make them self-start on a quiet pod. That is D3, and it is deliberately sequenced second — @fable-lead's call. Turning heartbeats on first would produce seats waking every N minutes, finding nothing they can see, and returning
HEARTBEAT_OK.🤖 Generated with Claude Code
https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8