Skip to content

queen: wire keyed_batch.wasm so the bee admission makes one queend choose per batch, not per issue #2043

Open

Description

@gHashTag

Problem

On 2026-10-17 the keyed-actors dispatch trial (TRIOS_QUEEN_DISPATCH=actors, build 42042a5) started 2 runners in 20 minutes. The round loop starts 18.5 in the same time, so the trial was reverted (evidence).

The cause is serial admission:

  • handRoundToBeeActors (queen-bee-actors-round.ts:216) readies about 826 candidates.
  • The single bee-admission actor then answers them one at a time with await deps.admit(ask.issue) (queen-bee-actors.ts:298).
  • Each of those is one queend choose call for one issue (round.choose(issue, ...) at queen-bee-actors-round.ts:152, which becomes kind:'choose', candidates:[issue] at queen-tick.ts:2267).
  • The loop asks queend once per round about the whole list (queen-batch-choose.ts).

Spec

gHashTag/t27#10051 adds specs/queen/keyed_batch.t27 (closes gHashTag/t27#10033). That card is the policy. This issue covers only the thin wiring that reads it, in the same way keyed_guard.wasm is wired today. No policy lives in TypeScript.

Wiring

  1. Vendor the card.
    • Copy keyed_batch.t27 into agent-server/specs/queen/.
    • Build queen/keyed_batch.wasm the way the other cards are built: t27c gen-c followed by zig 0.16.0 cc --target=wasm32-wasi -Oz -DNDEBUG -mexec-model=reactor, exporting the card's functions plus lane_free, admit_answer, wake_count and batch_quota.
    • The reproducible lab sha256 is 1ed6bcb13de9ff4c462ff6d0f8a1ba6e3c590d0235756f3aa4ce4bd8fcacfd8a (1187 bytes).
    • Pin both files in specs/PIN.
    • Load the wasm with loadCardWasm('queen/keyed_batch.wasm'), next to the guard card (queen-bee-actors.ts:112-118).
  2. Give the admission actor an open batch (group commit).
    • On each ready, ask the card joins_batch / answer_now. Asks that do not join are answered at once, as today.
    • When batch_goes_out is true (no choose in flight), take batch_take(open) asks and send them as ONE choose. Asks that arrive meanwhile wait for the next batch. There is no timer.
  3. Make deps.admit batch-shaped.
    • It takes a list of issues and returns one word per issue: PICK, LATER or NO (the card's word_of).
    • Behind it, make one queend choose with all the candidates, reusing readAnswer / planBatch from queen-batch-choose.ts.
    • Cap new lanes with the card's new_lane_quota. Kept asks (a restart on a lane the issue already holds) sit outside the quota.
  4. Answer each ask in order with batch_answer(kept, holds_lane, free, word), re-reading lane_free after every grant. batch_grants is the cross-check: a batch grants exactly its quota.
  5. Wake: replace the wake_count call (queen-bee-actors.ts:254) with batch_wake_count. A freed lane wakes every waiting issue into one batch instead of one issue per lane.
  6. Bound the calls.
    • askQueend (around queen-tick.ts:1330) spawns queend with no timeout. Give it the card's CHOOSE_BOUND_MS (12000).
    • Keep admitAfterMs (queen-bee-actors.ts:226, 30000 today) above twice that bound. The card's ask_bound_ok must hold.
  7. Treat a failed choose as a wait, not a refusal. A choose that throws or times out must become LATER via word_after_choose. Today .catch(() => false) turns it into a refusal.
  8. Measure.

Done when

Activity

  1. dmitrii-f-t27 commented on Oct 19, 2026

    @dmitrii-f-t27
    Collaborator

    Status: not executable here — trios agent-server TypeScript wiring is not public

    This trios issue wires keyed_batch.wasm into the bee admission flow (one queen choose per batch, not per issue). The wiring lives in the trios agent-server TypeScript (trios/agent-server/apps/server/src/agent/message-validation.ts and related files), per apps/trios-macos/docs/EXTERNAL-APP-INTEGRATION.md.

    Evidence it is not available here:

    1. gHashTag/trios clone (this repo, checked out main): no agent-server/ directory exists at any depth. Only main branch exists.
    2. gHashTag/BrowserOS dev branch: now holds only the browser extension (commit e0ca3e7, "docs: this fork holds the browser extension only (owner rule, 2026-10-08)"). The packages/browseros-agent tree that used to contain the agent server is gone.
    3. EXTERNAL-APP-INTEGRATION.md says the agent runtime "now lives at trios/agent-server/ and is the only copy" — but that copy is not in this public clone, so the file references a location that is not publicly accessible.

    What I can do: nothing on the agent-server side until the TypeScript sources are published somewhere I can read. The .t27 spec side (if any keyed_batch.t27 boundary exists in gHashTag/t27 issues) can still be ported in gHashTag/t27, but the TS wiring itself is blocked on publication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions