Keep requests for a session that takes them with basecamp connect next
馃 Drafted by Claude Code for review.
Why
A connector session sometimes never hears a request it should get
(card).
The basecamp-connect skill watches the connector's stdout with a Claude Code
Monitor armed persistent: true. Claude Code no longer has persistent, so
every watch now expires and has to be re-armed. A re-armed watch replays the
whole output file, and the session has to remember which requests it already
handled. The usual fix, a grep -v skip list, holds the newest request back
until the next one arrives, because the grep Claude Code's Bash runs is an
embedded ugrep whose -v waits for the following line. Today's skill sends
these sessions to --orchestrator instead.
This replaces #902, a skill-side watcher, with the connector keeping requests
until a session takes them.
What changes
Connector (opt-in). basecamp connect -P <p> --session-queue keeps each
trusted request in its ledger as session_pending, instead of printing its
request line. Stdout prints {"type":"queued","event_id":N,"recording_id":M}
in place of the request line; the intake and verdict lines continue as before.
Three commands read and close the queue over a socket in the profile's state
directory:
basecamp connect next [--wait] [--except <ids>]prints every eligible
request line, byte for byte the line plainbasecamp connectprints for the
same record.--waitblocks until there is one. Reading writes nothing.basecamp connect pending [<id>]shows what is waiting, and what is
withheld and why.basecamp connect ack <id>closes a request the session has taken on.
A request is handed over only while the running connector would still hand
it over:
- no hold, and not tagged for review by one
- served projects readable
- served, inside
--project, or a Ping the run hears - its own people still stand where they did when it was admitted: the
performer, the requester and the author whose words were trusted. That
covers whether each is the operator, allowlisted, an allowed agent or in
the Ping, plus the trust mode, whether the project is served, and the one
setting the trigger turns on. It's recorded with each verdict.
So someone removed from a Ping or the allowlist since is not answered. Adding
a colleague, changing an agent cap or serving another project holds nothing
back. A withheld request becomes eligible
again by itself when the condition clears, and stays until it is acked or
discarded (discard now accepts one).
Without the flag, nothing changes: the stdout bytes, status and the runner
are as before. The flag is refused with --shadow and with anything that
starts the runner.
Skill. basecamp-connect checks basecamp connect --help for
--session-queue.
With it, the session:
- starts the connector with the flag
- runs one background
basecamp connect next --wait, whose exit wakes it - checks each request with
pending <id>before acting on it - acks right after a worker launches, or after its own reply or refusal
- after a compaction, or in a new session, settles anything unacked with
pending - if the connector dies, runs doctor and starts it again once in the same
mode - if a crashed session left its queue connector running, asks the person
whether another session still works from it, and otherwise takes it over
A request waiting on the person, such as a repo choice, stays unacked.
Without the flag (an older CLI), the skill does exactly what it does today:
the Monitor flow where the Monitor takes persistent, otherwise
--orchestrator. Restarts keep the mode the session started in.
Hooks and the runner. The compaction notice names the waiter only when
this session's own connector started with the queue. Every other session gets
today's text, byte for byte. The orchestrator's mapping says the queue
commands are not its to run.
Compatibility
| CLI | Skill | Result |
|---|---|---|
| older | older | unchanged |
| this | older | unchanged (the queue is off without the flag) |
| older | this | today's flow (Monitor, or --orchestrator) |
| this | this | the session queue |
- Other starts say what waits. A start without
--session-queuenever
hands these requests over, so it logs how many wait for a session. - Migration 17. This is ledger migration 17. A basecamp older than this
refuses a ledger this one has opened, as it refuses any newer schema.
After upgrading,basecamp connect statusasks for the connector to start
once before it reads the ledger, as it does after every migration. - Exit codes.
nextandpendingexit 0 when they answer, 1 on a usage
error, 11 when no connector for the profile runs the queue, 12 when the
connector stopped before answering, and 130/143 on a signal.
Known limits
- A pre-existing gap stays. If the connector crashes while acknowledging
a burst of requests, and restarts more than a minute after the request was
made, that request is dropped. Every mode already has this gap, and the
queue doesn't widen it. - No membership re-check. Removing a person from a Basecamp project while
their request waits does not withhold it. Revoking them inconnect.json
does. - One acting session per profile. Delivery to the session is
at-least-once. The skill settles a repeat against its workers or the reply
thread, and asks the person when it can't tell.
Verification
-
bin/cigreen. -
Real binaries, against an isolated local bc3 (this branch and main side
by side): 23 of 24 checks pass. The 24th isstatuson a ledger an older
build wrote, which refuses until the connector starts once, as main does
after every migration; it passes after that start.next --waitreturned
1.18 to 2.21 s after the mention was created (median 1.33 s, 10 of 10). -
Live Claude Code sessions (2.1.332, interactive), running the skill
against local bc3:Case Result Idle 75 min with the waiter armed, then /compact, then the connector killed4 of 4 requests started a turn within 0.011 s of being queued; each was replied to once and acked Claude Code killed right after the waiter woke it, before any tool call 3 of 3 settled by a fresh session with pending: replied to once, ackedThis skill with main's CLI 3 of 3 took today's route; the queue was never used Main's skill with this CLI 3 of 3 behaved as main does; the compaction notice was main's, byte for byte Those runs found three gaps, now fixed in the skill: it asked before
restarting a killed connector; it had no path for a connector a crashed
session left running; and one session stopped its connector with a
pattern match that also stopped other sessions' connectors. A second live
run (on 99ccc7ba) checked each fix, 2 of 2 each: a killed connector was
restarted without asking, a crashed session's connector was taken over
after one question with no second connector started, and a stop left a
look-alike connector running. Since then, after review, a takeover stops
the left-behind connector and starts the session's own, so the session
can stop it later; that step was not run live. -
--orchestrator, live against local bc3, this branch beside main:- Claude workers: 2 of 2 requests answered once on each build; the second request on the thread went to the same worker.
- Codex worker: 1 of 1 answered once.
- Connector killed after the handoff and restarted: the request was repeated and answered once, on both builds.
- Output lines, runner state and ledger outcomes matched; the orchestrator never ran the queue commands.
-
Skill eval cases were added; their graders were checked against
hand-written traces (8 of 8 correct pass, 54 of 54 wrong fail). The model
run is this PR's Skill Evals job.