Repository navigation
Bridge S5: offer pool — claim-style distribution (#14371) - #14442
Conversation
Design §4.2: a sender posts work once as an offer {body, kind, slots,
to: <pattern|group|all>} in the new fleet_offer table instead of
fanning it out. Eligible agents (address matched against the registry
at claim time) see open offers in a new inbox section and claim with
one atomic store op: the claim is a conditional INSERT that lands
only while a slot remains on an open offer and the agent has not
claimed, so racing claims cannot oversubscribe. A winning claim
delivers a normal mailbox row on the offer's batch (replies thread
onto the batch) and records fleet_offer_claim; past the last slot the
answer is a definite 'filled' with no row. Offers may carry a
ttl_seconds, after which claims answer 'expired' and the offer reads
expired. A command offer reaches claimants sender-stripped like every
command; the owner reads every offer with its claims (agent, time,
delivered row) at GET /api/<owner>/fleet/offers, and claims/replies
through the pipeline's batch filter. Agents can post offers too
(from_addr fixed to their own name; the poster never claims its own
offer), and per-agent credentials gate claim/offer by scope (inbox /
send) and own name, refusals the usual plain 404.
fleet_offer gains a sender label column alongside the design's
sender_addr so a delivered row carries the same sender a fan-out send
would have written.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
…fer-pool # Conflicts: # pkgs/message-bridge/worker/README.md # pkgs/message-bridge/worker/src/fleet.js
|
Merge-refresh after S7 (#14431) landed on main: merged origin/main into the branch (merge commit 40d4e91, no rebase). Conflicts were unions in two files — src/fleet.js agentRoute (the offer/claim routes now sit alongside S7's read-scope routes; the credential offer-post also adopts S7's service-address semantics, from_addr = cred.addr ?? agent:) and README.md (both route-table additions kept). routes.js auto-merged. Re-verified remotely on the merged head: fleet-command run 45426338395, conclusion success, Target HEAD 40d4e91 in the log; full worker suite 108 pass / 0 fail across 12 files (the 103 from the first verification + S7's 5 service-credential tests). PR is mergeable/CLEAN again, still unmerged for Felix's review. |
Implements bridge build-out slice S5 (design
doc/2026-11-24_design_message-bridge-buildout.md§4.2): the offer pool inpkgs/message-bridge/worker.Refs #14371 — left unmerged for Felix's review.
What
Fan-out cannot express "the next task goes to the next N agents who pick it up", so a sender can now post an offer, stored once and never fanned out:
fleet_offer (id, batch, body, kind, pattern, slots, sender, sender_addr, ts, expires_at, state)andfleet_offer_claim (offer_id, agent, claimed_at, message_id). (senderis one column beyond the design's list: the sender label a delivered mailbox row must carry, the same label a fan-out send writes.)POST /api/<owner>/fleet/offer {body, to, kind?, slots, sender?, ttl_seconds?}andPOST /fleet/<token>/offerfor agents (from_addr fixed to the poster's own name; a per-agent credential needs thesendscope).all) matched against the registry at claim time — see open offers in a newofferssection of the inbox response and atGET /fleet/<token>/offers.POST /fleet/<token>/claim {agent, offer_id}is one atomic store op. The claim row is a conditional INSERT that lands only while a slot remains on an open offer and the agent has not already claimed, so racing claims cannot oversubscribe; a winning claim delivers a normal mailbox row on the offer's batch and records the claim. Past the last slot the answer is a definitefilledand no row exists; expired offers answerexpired, a repeat claimalready claimed, an ineligible agentnot eligible, and the poster can never claim its own offer.commandForAgent, as for any command); the store row and owner views keep the real sender.GET /api/<owner>/fleet/offerslists every offer with slots, effective state (open/filled/expired), claim count and its claims (agent, time, delivered row id); claimants' replies thread onto the offer batch via the existingpostop, so the pipeline's batch filter shows delivery + replies together (covered by a test).Verification (remote only)
fleet-command run 45423029523 on developing-today/fleet, conclusion success, log shows
Target HEAD: 9096d3e2428c72448162fde02a182920acdcf062(this branch's head) and the full worker suite under the bun-test fallback (the executor image has no node — code#14267 / dezren39/fleet#111): 103 pass / 0 fail, 103 tests across 11 files — the 93 from S1–S3 plus 10 new tests intest/offers.test.mjs, all passing by name:filled, no mailbox row for itexpiredand leaves the open listAcceptance mapping: every #14371 acceptance item is covered by a named test above. No new dependencies.
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-24T15:29:24Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch/workspace/issue-14371/wt", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch/workspace/issue-14371/wt", "repo": "developing-today/code", "branch": "felix/14371-bridge-offer-pool", "sha": "9096d3e2428c72448162fde02a182920acdcf062" }, "auth_subject": "felix", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.