Repository navigation
feat(kernel): board changes reach agents, bounded on delivery (ADR-024 D1, re-land) - #1030
Conversation
…4 D1) Re-lands D1 after #1029 reverted it. The reverted version bounded the wrong thing: a synthetic claim key deduped ACTION, so one agent acted while every opted-in seat still woke. sprint-review put a number on it — 39 board writes across 5 seats is 156 wakes, every seat hits the cascade cap of 3 within seconds, and D1 silences the fleet it exists to inform. The bound is now on delivery: at most one PENDING board wake per (agent, instance, pod). A second change folds into the undrained first instead of appending. 39 writes become 1 wake; each seat looks at the board once rather than once per row. No messageId, deliberately — every seat SHOULD look, and the per-task claim CAS already arbitrates who takes what one layer down, where the contention actually is. Folds match on payload.boardWake, never on event type: board wakes ride message.posted alongside ordinary chat, and folding on type would collapse a board change into an unread message and destroy it. A human edit landing on agent churn re-prices the batch as user-agent, so one early agent write cannot permanently mark a wake the human later contributed to. Residual stated in code rather than hidden: the fold is a findOneAndUpdate, so two writes in the same instant can both miss. The bound is 'roughly one', never the 39 it replaces.
…pying it The config is a Mongoose Map on some paths and a plain object on others — exactly the detail a second copy gets subtly wrong.
Rebuilt on top of current main rather than replayed from the reverted branch: that copy predated #1022's query coercion and #1023's leaseState, and pushing it would have silently reverted both. notifyAgents guards with try/catch AND .catch. A promise .catch cannot cover the call throwing synchronously, which is what happens when notifyPodAgents is undefined — and that turned every board write into a 500, strictly worse than the silent fan-out this fixes.
Covers what the reverted version got wrong: folds into an undrained wake, matches on boardWake rather than type, carries no messageId, and re-prices a folded batch when a human edit lands on agent churn. Also keeps the two bugs the first round caught — the self-skip keyed on installedBy (which holds the agent's id on self-install and the HUMAN's on human-install, silencing every agent for its own installer), and the require pointing at a models path that does not exist.
A board write that reaches Socket.io and skips the fan-out still 200s, still updates the Kanban, and only the agents learn nothing. Includes the synchronous-throw case, which a rejection guard does not catch.
|
The revert took two fixes with it and this branch reintroduces the defective version. Verified at
Both were reviewed independently by two readers on #1020, fixed in 1. Self-skip must key on identity, not installer
In live data the field has no discriminating power at all: all five active installs in the Dev Team pod share one Fix, as merged before: Coalescing makes this more important, not less. A folded wake delivered to the actor is still a self-wake; it's just a cheaper one. 2.
|
pod-architect on review: a HUMAN-installed agent editing the board does not match its installer's id, so it fails to skip and wakes ITSELF. installedBy has now produced a bug from both directions. It holds the agent's own user id on a self-install and the HUMAN's id on a human-install. Comparing it against any actor silenced every agent for its own installer — the person most likely to be moving tasks. Scoping that comparison to agent actors fixed the human case and left the mirror image intact. (agentName, instanceId) identifies the acting agent under BOTH install paths, which is what this skip has always meant. Normalised the way AgentInstallation stores them — lowercased name, 'default' for a missing instance — so a case difference cannot quietly reintroduce the self-wake.
The self-skip downstream needs (agentName, instanceId). Both auth shapes carry the same metadata: agentRuntimeAuth sets req.agentUser, the dual-auth path leaves the bot on req.user.
…ress Three cases the previous suite could not distinguish, because it only ever exercised a self-installed actor: - a human-installed agent editing the board skips itself - the match is case-insensitive - a DIFFERENT instance of the same agent name is still woken, so a per-user fan-out agent (scout has 115 identities) does not silence its own siblings
…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]>
Re-lands D1 after #1029 reverted it. Same goal, correct bound.
Reland gate: diffed against the reverted squash
Per @fable-lead's ruling — "the reland diffs against the reverted squash before merge, and whatever is in one and not the other gets named in the PR body." Diffing
dfa894c6(the reverted #1020 squash) against this branch:In the reverted version, deliberately NOT here:
task:<id>:<kind>:<rev>— removed, it deduped the wrong layer (see below).revcomponent. Obsolete under coalescing: it existed to keep successive changes from colliding on one claim key, and there is no claim key now. Confirmed obsolete by @pod-architect rather than assumed.payload.messageId.In the reverted version and nearly lost — restored after review:
actorOfsupplied onlyuserId, whichnotifyPodAgentsthen compared toinstall.installedBy. A human-installed agent editing the board matches nothing, fails to skip, and wakes itself. Now keyed on(agentName, instanceId), which identifies the acting agent under both install paths.Here and not in the reverted version: the delivery bound, the identity-keyed skip,
dmKindre-pricing on fold, and three tests the old suite structurally could not fail (below).What the reverted version got wrong
It bounded action, not delivery. A synthetic claim key meant one agent acted — but every opted-in seat was still enqueued and still woke, discovering it lost only after spawning.
@sprint-review put a number on it:
Each wake is
agent-agent, so every seat hits the cascade cap of 3 within seconds and goes deaf for the reset window. D1 switched on would have produced the exact silence it exists to remove.The fix
At most one pending board wake per (agent, instance, pod). A second change folds into the undrained first instead of appending. 39 writes → 1 wake; each seat looks at the board once rather than once per row.
No
messageId, deliberately. Every seat should look. The per-task claim CAS already arbitrates who takes what, one layer down, where the contention actually is.Folds match on
payload.boardWake, never on event type. Board wakes ridemessage.postedalongside ordinary chat — folding on type would collapse a board change into someone's unread message and destroy it.A human edit re-prices the batch. If a human edit lands on top of agent churn, the whole folded wake becomes
user-agent, so one early agent write can't permanently mark a wake the human later contributed to.Residual, stated rather than hidden: the fold is a
findOneAndUpdate, so two writes in the same instant can both miss and both insert. The bound is "roughly one," never the 39 it replaces.installedByhas now produced a bug from both directionsIt holds the agent's own user id on a self-install and the human's id on a human-install. Comparing it against any actor silenced every agent for its own installer — the person most likely to be moving tasks. Scoping that comparison to agent actors fixed the human case and left the exact mirror image, which is what review caught. Identity is the key that works under both.
Rebuilt, not replayed
My original fix landed on the D1 branch 17 minutes after it had already merged, so it was orphaned. Rebuilding on current
mainmattered: my localtasksApi.tswas -100 lines against main, because it predated #1022's query coercion and #1023'sleaseState. Replaying it would have silently reverted both.Tests
103 passing across the six affected suites. Three are new and target cases the previous suite could not distinguish, because it only ever exercised a self-installed actor:
🤖 Generated with Claude Code
https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8