Skip to content

dev → main (in progress): #220 injected completion notifications, #244 usage reads, #242 - #221

Draft
firstintent wants to merge 13 commits into
mainfrom
dev
Draft

firstintent wants to merge 13 commits into
mainfrom
dev

Conversation

@firstintent

Copy link
Copy Markdown
Owner

Draft dev→main PR for the current cycle, opened so CI (check.yml) runs on dev.

Includes:

Not ready to merge: no version bump yet, and the owner decides when to release.

🤖 Generated with Claude Code

randd1024 and others added 13 commits November 10, 2026 10:28
…age (#238)

The launch entry script exec'd `current_exe()`. Once an upgrade replaces
the daemon binary on disk, Linux reports that as `<path> (deleted)`, so
every session started on a cswap account (new, cold resume, or after an
IM /account switch) died with a bare "child exited" until the daemon was
restarted. The relay only runs while the daemon is spawning, so it now
execs `/proc/<pid>/exe`: the kernel keeps the running image executable
after the file is unlinked, and the relay reading the launch request is
the same version that wrote it. Other platforms keep `current_exe()`.

docs-local/issues/#238

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(#237)

The composer cleared its text and localStorage draft as soon as the send
handler returned, before the request settled. A failed launch on Home
(project/session start error) or a failed turn or schedule in a session
lost what the user had typed. Send handlers can now return a promise:
the text, attachments and stored draft stay until it confirms the
message landed; a rejection or `false` keeps them, and a second send
waits. Text typed while a send is in flight survives its success.

docs-local/issues/#237

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…only what failed (#239)

A Home launch that created a project and then failed to start the session
kept the new-project row open, so the retry created the project again:
the same directory got a second slug (`dexos-sdk2`) whose create rewrote
the first project's `.ccteam/state.json` (slug and owner). Nothing in the
shared creation path checked whether a directory already was a project,
so IM `/newproject` and `ccteam init --slug` could do the same, including
restamping the owner of a directory belonging to someone else.

- core: `create_project` refuses a directory already registered under
  another slug (`ProjectDirTaken`) before writing anything; paths compare
  canonically. Every entry point goes through it.
- web: `POST /projects` answers such a directory with the existing
  project (200) when the caller can see it, else 409 naming nothing. A
  satellite answers a directory it has with that project's slug and the
  daemon catalogs it once; import shares the same response helper.
- IM `/newproject` switches the chat into the existing project; another
  owner's directory is refused.
- `ccteam init` in a registered directory refreshes that project; a
  `--slug` naming another project is refused.
- SPA: the launch settles each step that succeeds (the created project is
  selected at once), so a retry redoes only what failed; a session whose
  first message failed opens with the prompt in its own draft; a
  directory that already is a project is used, and the user is told.

`post_project_auto_appends_on_duplicate_slug` asserted the old behaviour
(same slug on the SAME directory became `dup2`); its collision now uses a
different directory with the same name, which still appends.

docs-local/issues/#239

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ogin (#240)

cswap keeps one live credential copy per account: an account runs in its
own session profile while another account is the default login, and on the
default login once it becomes the default. ccteam pinned the profile
instead of the account, so once `cswap switch` / `cswap auto` made a pinned
session's account the default login:

- a session whose profile had been confirmed resumed with
  `--require-session`, which cswap refuses for the default account, and the
  relay refused any other profile path: the sid could not start until the
  default login moved away again;
- a process still resident in the session profile kept a second copy of
  the now-default credential, which is what makes `cswap switch` warn and
  lets one copy's token go stale once the server rotates it. The mirror
  case (a pinned process on a default login that moved to another account)
  silently spent that other account's quota.

Now the binding is the account and the profile is cswap's decision at each
launch:

- launches always run `cswap run <slot> --share-history`, never
  `--require-session`; the relay no longer compares the profile with the
  previous launch (`directory_identity` is gone). It still refuses to run
  as another account and to `--resume` where the transcript is not visible.
- the residency sweep releases a quiet pinned process whose account moved
  onto or off the default login (`session_evicted{reason:login_moved}`),
  whatever its idle clock says. The next message resumes the same sid in
  the profile cswap picks. The default login is read from Claude's own
  `oauthAccount` record; an unreadable one changes nothing, and a sid is
  released at most once per default login.

Sessions created on the default login keep following it, as before.

A process that is alive at the moment of the switch still makes cswap warn
(or refuse, if it already rotated the token), and `cswap auto` still skips
an account with a live session: both are cswap's own guards.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… account (#240)

`cswap auto` never switches onto an account while a Claude process lives in
that account's session profile (any `cswap run <account>` session), so with
several such sessions it can run out of accounts and stay on one at its
limit. scripts/cswap-auto.sh is a standalone POSIX sh wrapper to run instead
of `cswap auto`: it needs only cswap, calls nothing else, and works without
ccteam.

It leaves every decision to cswap. Each interval it runs `cswap auto --once`;
only when cswap wanted to switch but could use none of its candidates (exit
3, `no-viable-target`) does it ask cswap which account it would have picked
(`--dry-run`, which decides before the in-use check) and switch there with
the manual `cswap switch`, which goes ahead with a warning where auto steps
aside. A forced switch is rate-limited by a cooldown, and a switch cswap
refuses (the session already rotated the account's token) backs off.

The cost is cswap's own warning, kept and documented: after a forced switch
the account has two live credential copies and one may stop working. A
ccteam pinned session moves onto the default login by itself (the
login_moved release); a hand-started `cswap run` session has to be restarted
if it later fails to authenticate.

Also fixes a flaky test (#241): process_image_runs_after_the_binary_is_deleted
read /proc/<pid>/exe right after spawn, which can still name the parent's
image because a vfork parent is woken before the child's exec lands. It now
waits for the stand-in image first.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nning answer (#242)

A session kept ONE reply route and ONE "who asked" marker, and every
submission overwrote both the moment it was accepted. A delegation
completion that parked behind a human's running turn therefore pointed
the session at its owner route (a tenant project's web console) before
that turn had answered: the human's answer went to web only, was not
mirrored back (it was a human's turn), and the IM chat that asked never
saw it. Seen twice on s1593 in one afternoon.

The route now belongs to the turn being answered. A human's line still
re-addresses at once. An internal line (notification, A2A task)
re-addresses only a turn it STARTS; joined into a running turn it leaves
that turn's addressee (and the human's claim on its answer) alone, and
parked behind one its route waits under its execution-turn id until the
pump sees that turn open. One rule (`TurnOrigins::record` / `open`,
`address_submission`) shared by the locked and unlocked submit paths and
both directive paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wer (#244)

Since #234 every account-usage read (IM /status, MCP status usage, the
hook phase, GET /api/v1/usage) asked all live sessions of a vendor at
once. Claude answers get_usage from a snapshot its processes share for
only 60 s and otherwise reads /api/oauth/usage with the account's token,
so with the snapshot stale each read spent one request per live session
from that token's allowance (~30 an hour, shared with every claude
process and cswap). The default login ran out into 429s and cswap's view
of it froze; cswap's log shows the 429s jumping from 1-4 a day to 11-27 a
day once this shipped.

- Sessions are asked one at a time in capture order and the first answer
  ends the read; all asks still share #234's one-second deadline.
- A process's answer is reused for five minutes. Answers are kept per
  process (vendor, thread identity, start time), not per vendor, because
  sessions of one vendor can be on different cswap accounts and a status
  card reports its focus's own account. A resumed process asks afresh.
- Readers with no focus put a process with a recent answer first.
- A session release skips its usage capture when the process answered
  recently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k claude (#244)

The get_usage control request made claude read /api/oauth/usage whenever
its 60 s snapshot was stale. That endpoint allows each token about 30 reads
an hour, shared with every claude process on the account and with cswap,
and ccteam's reads helped spend the default login's allowance into 429s
that froze cswap's view of it.

Claude already receives the account's 5-hour and weekly windows in the
headers of every API response and prints their changes as rate_limit_event
lines on its stream-json output; ccteam was dropping them. The transport
now folds them into per-process windows (rate_limits.rs) and
account_usage() answers from those, asking claude nothing. A process that
has not run a turn reports nothing, and the gateway falls back to the
recorded observation. A window past its reset is left out.

The headers carry no subscription tier, no extra-credit balance, and name
only the opus/sonnet weekly windows, so those are no longer reported for
claude. get_usage, its parser and their tests are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…no request (#244)

GET /api/v1/vendors/quota read claude's windows by calling
/api/oauth/usage with the default login's token, the same small per-token
allowance claude's own processes and cswap share, which ccteam's reads
helped spend into 429s.

The claude row now takes its windows from ~/.ccteam/account-usage.json,
which the gateway records from claude's own rate-limit headers (021b7c5),
and its plan from the local credential file. A login without a recorded
observation that still holds reads unavailable. The claude probe kind is
renamed ClaudeRecordedUsage; the endpoint request builder and parser are
removed, and the HTTP-path unit tests use the codex probe instead. The
claude row is read fresh each time rather than through the five-minute
probe cache, since it is a local file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arking (#220)

A delegation completion notification was routed `TurnRouting::Notification`
and, on a busy Claude stream-json parent, parked in `deferred-input.json`
until the parent's running turn ended (then batched, #205). A planner that
stayed in one 6h40m turn therefore saw none of its hires' completions until
that turn was over. The premise for parking (#194: claude shows a mid-turn
stdin line twice, as a preview and again as the next prompt) no longer holds;
current transcripts show every mid-turn line read once as a `queued_command`.

Fix at the root: the gateway's default channel (`DEFAULT_ROUTING`, replacing
`routing_for_origin`) is `Inject` for every origin. A notification now takes
the same channel as a human's steer: it starts a turn on an idle parent and
joins the running turn on a busy one. Its origin stays `Internal`, so a
joined notification still does not re-address the running turn's reply
route (#242).

`TurnRouting::Notification` has no producer left and is deleted with
everything that existed only for it: the claude notification batch
(`take_deferred_batch`, `notification_batch_text`, the 50k budget, repeat
markers, `members`/`replayed`, `OnUnmirrorable::Notification`,
`RetainedInput::in_flight_members`), the write-ahead rollback that kept a
batch's membership stable, and the batch wording around the gateway's
parked-route cap. Explicit `routing:"queue"` tasks and mid-turn slash
commands keep the deferred path.

`DEFERRED_INPUT_SCHEMA` stays 3: a line is now `{turn_id, text}`, a subset of
the schema-3 shape, so a mirror left by the batching build is read with its
extra keys ignored and every parked line (task, slash command, notification,
prepared batch) replays once in FIFO order rather than being discarded.

Tests: a new integration test drives the real stream-json adapter through
the notifier door against a fake CLI and shows the notification read off
stdin mid-turn, joined to the running turn, with nothing parked (red before
this change). The #242 test now covers the injected notification; the
parked-route shape is kept with an explicit queued task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orchestration and mcp guides (en + cn) now say what happens: a completion
notification is injected into a busy parent's running turn and read at its
next tool boundary, or starts a turn on an idle one. The batch, park and
write-ahead-pause passages are gone, and the `routing` trade-off no longer
claims claude shows an injected line twice.

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

The replay expectation an injected line sets was cleared only by a turn
the vendor opened itself or by the stream closing. The current CLI reads
a mid-turn line once and never re-runs it, so after one injected
completion notification every later boundary of that parent reported
Replay: each held for the 30s grace, the session read `working`, and a
parent that is itself a child delayed its own receipts. The expectation
is now spent on the Replay boundary it held; a Pending boundary keeps it.

Docs: a line already injected lives in the CLI's input queue until the
next tool boundary, so a stop or crash before that boundary loses it
from the model's view even though the request counts as notified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A process in an account's cswap session profile is that account's
credential holder. While it lives `cswap auto` skips the account, and
once it has refreshed its token `cswap switch` onto the account refuses.
Pinned sessions stay resident for the idle window (250 minutes), so an
account in regular use was refused most of the time.

cswap tells nobody that a switch was wanted, so the account is handed
back on a clock: a pinned process quiet for `sessions.account_yield_secs`
(default 3600, 0 = never) is released and its session moved to the
default login, through the same path and checks as the user picking
"Default login". Nothing is given back mid-turn, while a decision is
pending or background work runs, or when the session's history could not
follow it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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