Skip to content

feat(orchestration): standing manager mailbox batches queued work founder-first - #239

Open
nullStack65 wants to merge 2 commits into
release/native-0.1.10from
clo-1303-standing-manager-mailbox
Open

nullStack65 wants to merge 2 commits into
release/native-0.1.10from
clo-1303-standing-manager-mailbox

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Problem

The standing manager threads (CEO, CTO, CoS and the other standing seats) work through their queue one message per turn, in arrival order. When a founder writes while ten agent reports are waiting, the founder waits behind all of them. This is Linear CLO-1303, the standing manager mailbox issue.

Behavior

On a thread with a standing persona (thread.standing set):

  1. One turn for the queue. The queued run that starts answers every other waiting plain-text agent message in the same turn. They go to the provider after the turn's own message in a <queued-messages> section, each labeled with its sender role. They are stored on the starting run as mailbox entries, and their own queued runs are cancelled. This is the same mechanism and precedent as the existing digest fold.
  2. Priority. The head is chosen founder first, then CEO, then the existing delivery order. A person typing is the founder. A message sent from the standing thread named CEO is the CEO. Everything else is an agent.
  3. Preemption. A founder message steers a turn it outranks (an agent or CEO turn). A CEO message steers only an agent-started turn. Agent messages never preempt. This only upgrades a queue to an active steer when the provider supports steering. It never interrupts and restarts a turn.
  4. Digests still never start a turn (unchanged).
  5. Slow manager turn flag. When a standing-thread run ends after more than 300 s, the server logs standing manager turn exceeded 300 seconds with thread, standing name, run, provider and seconds. It logs only; nothing else acts on it.

Non-standing threads are unchanged: the roles map is undefined and every new branch is skipped.

Port and conformance

StandingMailbox.planDequeue is a TypeScript port of plan_dequeue in closura-agent-config scripts/lane_event_routing.py (PR 1507, commit 40e39541c6). laneEventRouting.conformance.json is a byte-for-byte copy of that repository's config/lane-event-routing/conformance.json. The test pins its sha256, so drift fails CI. Every mailbox case (the ones with queued) is asserted on turns, batch, digest and preempt.

Deliberate deviations from the pure plan

  • Founder-typed messages are not folded into another message's turn. Each one keeps its own turn so it stays visible in the transcript. Several queued founder messages therefore take several turns, founder first.
  • Folded agent text reaches the provider but is not rendered as its own transcript bubble. This matches the existing digest fold.
  • Anything that is not plain agent text keeps its own turn: attachments, slash commands, notifications (PR-watch wakes included), delegated completions, structured-output asks, continuations, a different provider or model, or held, expired or non-next_turn delivery classes.

Queue-latency signal for t3_wake_audit.py

No new table. orchestration_v2_projection_runs already carries:

  • requested_at
  • $.startedAt
  • completed_at
  • provider
  • $.modelSelection.model
  • $.userMessageId, whose prefix is the wake source

A folded message's own run is cancelled without a start time. Its latency is in the starting run's new optional $.mailbox[] entries (messageId, runId, senderRole, requestedAt), which pair with that run's $.startedAt. The run is stored as payload JSON, so this needs no migration.

Related, not in this PR

  • Rule 5, routing PR-watch checks-passed and merged events to merge-queue code, belongs to sibling CLO-1302, the lane event routing issue. No t3code PR exists for it yet. This PR only keeps notification wakes out of the mailbox batch, so it does not overlap with CLO-1302.
  • Provider failover is CLO-1298, owned by the CTO. It is not implemented here.

No UI change.

Verification

  • vp test run src/orchestration-v2/StandingMailbox.test.ts (apps/server): 11 passed. This covers:
    • the conformance hash and every mailbox case
    • 7 queued messages becoming one turn with the founder first, both in the pure planner and on queued-run projections (fold order CEO, then agents)
    • typed-message and model-mismatch exclusion
    • sender role classification
    • the 300 s boundary
  • vp run typecheck (apps/server): 0 errors.
  • vp run check:changed origin/release/native-0.1.10:
    • format, lint, graphql and the 8 affected test files pass.
    • The remaining failures are all in files this PR does not touch, so they are already on the base:
      • knip: unused .github/scripts/set-*-version.cjs, plus unused exports in AgentOutputGate.ts, RemoteDelegation.ts and secretRedaction.ts.
      • web typecheck: Sidebar.logic.test.ts and botOrgTree.test.ts, which are standing-avatar type errors.
  • Not verified: a live standing thread on a fleet host, and the full CI suite (pending on this PR).

Prior art

Searched: t3code orchestration-v2 (digest fold, QueuedRunOrder, CommandPolicy delivery intent) and closura-agent-config scripts/lane_event_routing.py, 2026-11-27.

  • Existing digest fold (digestFold/carriesDigest): reused as the pattern and the cancellation path. It cannot carry actionable messages, so it was extended rather than replaced.
  • queuedRunsInDeliveryOrder: reused as the base order; the mailbox rank is a stable sort on top of it.
  • resolveDeliveryIntent "auto": reused for preemption. No new steering path.
  • Home plan_dequeue and its conformance JSON: ported, with the JSON vendored and hash-pinned rather than reimplemented.
  • External queue or priority libraries: not needed. The ordering is a three-level stable sort.

Deploy: fleet
Verify: on a standing thread, queue several agent messages and one typed message during a running turn. One turn should start with the typed message first and a <queued-messages> block. The queued runs should be cancelled, and $.mailbox should appear on the run in orchestration_v2_projection_runs.

🤖 Generated with Claude Code

…nder-first

Port plan_dequeue from closura-agent-config lane_event_routing.py (CLO-1303).
On standing threads the starting turn answers every waiting plain-text agent
message, the founder's message goes first and the CEO's second, founder and CEO
messages steer turns they outrank, and a manager turn longer than 300 s is
logged. The Home conformance JSON is vendored and hash-pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…t fixture (CLO-1303)

The "different model" case spread the plain `{ instanceId: "codex" }`
fixture over the run's model selection, so `instanceId` lost its
`ProviderInstanceId` brand and `effect-tsgo` rejected the runs array with
TS2322 at StandingMailbox.test.ts:158. Spread the run's own
`modelSelection` instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant