Skip to content

acpmux: send --supersede KEY replaces your prompt still queued under KEY - #23733

Merged
teamleaderleo merged 7 commits into
feat-cmux-nextfrom
lane-host/acpmux-supersede
Oct 22, 2026
Merged

teamleaderleo merged 7 commits into
feat-cmux-nextfrom
lane-host/acpmux-supersede

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

acpmux send --supersede KEY: a prompt replaces the same sender's prompts still waiting in the queue under the same KEY.

  • session/prompt takes _meta.acpmux.supersede (a non-empty string of at most 256 bytes; anything else is refused with supersede.invalid).
  • A replaced prompt leaves the queue the way an unsent agent message does (remove_queued):
    • its session/prompt answers withdrawn;
    • its queue_removed record says reason: "superseded" and supersededBy;
    • a restart never runs it. The key is kept on the queued record, so a prompt restored after a restart can still be replaced.
  • Only a prompt that still waits is replaced. One whose turn started, or one being sent into the running turn, stays.
  • "Same sender" is the queue's own notion of it (digest.rs agent_sender): an agent's name (--from, or the session the connection runs in), or the person.
  • The new prompt's acceptance carries replaced (a count) and replacedPromptIds.
    • acpmux send prints replaced N queued under queued/steered.
    • --json adds replaced and replacedPromptIds.
    • Without --supersede the output is unchanged.
  • An edit of a waiting prompt drops its key, as it drops its provenance: the person rewrote it.

Why

acpmux prompts queue behind running turns, often 3 to 6 deep, so a lane reads a correction after the order it corrects. That is how one of today's tasks bounced between ci-speed and machine-mesh three times.

Tests

Written first:

  • d898558 adds the tests.
  • 9358193 makes the tests count a prompt that went in with an agent-message turn as run, which also makes the "never ran" checks stricter.
  • a661042 is the implementation.

tests/hub_integration/prompt_supersede.rs (end to end through the protocol handler with the fake agent):

  • a same-key prompt is replaced and never runs, and its wait answers withdrawn;
  • another sender's prompt, another key's prompt and an unkeyed prompt stay queued;
  • a running turn under the key is never replaced;
  • a prompt queued before a restart is still replaced;
  • a bad key is refused.

Unit tests in cli/output.rs:

  • through a real unix socket, queue_prompt with a key replaces the earlier prompt, and sent_lines prints replaced N queued;
  • the key goes in _meta.

Results on cmux16:

  • Before the implementation, all 5 integration tests failed (the acceptance had no replaced, and a bad key ran).
  • At the implementation:
    • cargo test -p acpmux: every binary is ok, including 518 unit and 362 hub_integration tests.
    • cargo clippy -p acpmux --all-targets -- -D warnings is clean.
    • cargo fmt --check passes after 4a3e141.

No overlap with acpmux-unify's open PRs: #23027 and #23598 don't touch the queue or the prompt path.

Agent session: cosmic-gray

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Adds acpmux send --supersede KEY so a correction replaces the same sender's prompts still queued under KEY instead of being read after the order it corrects.

Behavior

  • Replaced prompts leave the queue like withdrawn ones: their session/prompt answers withdrawn, the queue_removed record says reason: "superseded" and supersededBy, and a restart never runs them; a key survives a restart, so a restored prompt can still be replaced.
  • Only prompts still waiting are replaced; one whose turn started stays. Replacement happens only where the new prompt is committed — under the queue lock that puts it in, when its turn starts at once, or when it is steered in — so a prompt refused while the chat moves replaces nothing and two sends under one key can't both stay.
  • "Same sender" follows the queue's own notion (agent name via --from, or the session the connection runs in); a forwarded keyed prompt names that session to the peer. Editing a waiting prompt drops its key.
  • _meta.acpmux.supersede must be a non-empty string of at most 256 bytes; anything else is refused with supersede.invalid.
  • acpmux send prints replaced N queued (replaced ? queued from a daemon that predates the key); --json adds replaced and replacedPromptIds. Without --supersede the output is unchanged.

Written for commit 3f27bc1. Summary will update on new commits.

View guided diff Turn on auto-fix

teamleaderleo and others added 4 commits October 21, 2026 13:45
…d under KEY

Prompts queue behind running turns, so a lane read a correction after the
order it corrected. session/prompt takes _meta.acpmux.supersede: the same
sender's prompts still waiting under that key leave the queue (queue_removed
reason superseded, supersededBy) and never run, across a restart too. A
prompt whose turn started or that is being sent into the running turn stays.
The acceptance carries replaced and replacedPromptIds; acpmux send prints
"replaced N queued" and --json passes both through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bfb-0a99-78c2-b078-ca1fc578ff04&host=cosmic-gray
@teamleaderleo teamleaderleo added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 21, 2026
@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 21, 2026 21:06 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review 3f27bc1: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr23733 -f ref=lane-host/acpmux-supersede -f platform=macos -f backend_mode=local

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by lane-host on cosmic-gray · session

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-nuc2w created for this PR by the cmux coordinator.

teamleaderleo and others added 2 commits October 21, 2026 14:27
The review found the removal ran before the checks that can still refuse
the new prompt: on a chat being moved the old order was withdrawn and the
correction refused. Now a queued prompt replaces inside enqueue, under the
queue lock that puts it in (after the moving and watched checks; two sends
under one key can no longer both stay), one that starts at once when its
turn starts, and a steer once it is recorded; the steer's fallback keeps
the key. A forwarded keyed prompt names its sender session to the peer.
The CLI says "replaced ?" when the daemon does not report a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bfb-0a99-78c2-b078-ca1fc578ff04&host=cosmic-gray
@cursor

cursor Bot commented Oct 21, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

@teamleaderleo
teamleaderleo temporarily deployed to cmux-tui-merge-tree October 21, 2026 22:20 — with GitHub Actions Inactive
@blacksmith-sh

blacksmith-sh Bot commented Oct 21, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test_the_repository_highlights_validate (main.DigestTests.test_the_repository_highl
ights_validate)/
test_the_repository_highlights_validate (main.DigestTests.test_the_repository_highl
ights_validate)
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

cmux-next guards / nightly-guards / workflow-guard-tests / release-notary is red on 13 of 19 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (independent subagent reviewer): SHIP at 3f27bc1

@teamleaderleo
teamleaderleo merged commit eeb26d8 into feat-cmux-next Oct 22, 2026
@teamleaderleo
teamleaderleo deleted the lane-host/acpmux-supersede branch October 22, 2026 00:15
@github-actions

Copy link
Copy Markdown
Contributor

Shipped in:

teamleaderleo added a commit that referenced this pull request Oct 23, 2026
…trust gate

Codex review of #23921:
- A daemon that stopped between the continuation's queued record and its
  queue_order restored it behind the queue; restore_queue now puts a
  daemon_restart continuation at the head (a later reorder still holds).
- The continuation hard-coded trustGate false; turn_started now records
  the cut turn's trust gate and the continuation carries it (a log from
  before that checks a web turn again).
- Images in the cut prompt or its steers were dropped; they are read back
  from attachments and sent again.

prompt_supersede's restart test (from #23733, newer than this PR) turns
restart continuation off: its until-cancel turn would otherwise run again
ahead of the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 23, 2026
The supersede-after-restart test waited for the replacement's answer
before resume_queues, so the restored continuation of the cut turn (ahead
of it in the queue, as Leo asked: it resumes what it interrupted) never
ran and the test deadlocked. Supersede itself was intact (replaced: 1).
Resume first, then wait; also check the cut turn went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 23, 2026
…trust gate

Codex review of #23921:
- A daemon that stopped between the continuation's queued record and its
  queue_order restored it behind the queue; restore_queue now puts a
  daemon_restart continuation at the head (a later reorder still holds).
- The continuation hard-coded trustGate false; turn_started now records
  the cut turn's trust gate and the continuation carries it (a log from
  before that checks a web turn again).
- Images in the cut prompt or its steers were dropped; they are read back
  from attachments and sent again.

prompt_supersede's restart test (from #23733, newer than this PR) turns
restart continuation off: its until-cancel turn would otherwise run again
ahead of the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 23, 2026
The supersede-after-restart test waited for the replacement's answer
before resume_queues, so the restored continuation of the cut turn (ahead
of it in the queue, as Leo asked: it resumes what it interrupted) never
ran and the test deadlocked. Supersede itself was intact (replaced: 1).
Resume first, then wait; also check the cut turn went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 26, 2026
…trust gate

Codex review of #23921:
- A daemon that stopped between the continuation's queued record and its
  queue_order restored it behind the queue; restore_queue now puts a
  daemon_restart continuation at the head (a later reorder still holds).
- The continuation hard-coded trustGate false; turn_started now records
  the cut turn's trust gate and the continuation carries it (a log from
  before that checks a web turn again).
- Images in the cut prompt or its steers were dropped; they are read back
  from attachments and sent again.

prompt_supersede's restart test (from #23733, newer than this PR) turns
restart continuation off: its until-cancel turn would otherwise run again
ahead of the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 26, 2026
The supersede-after-restart test waited for the replacement's answer
before resume_queues, so the restored continuation of the cut turn (ahead
of it in the queue, as Leo asked: it resumes what it interrupted) never
ran and the test deadlocked. Supersede itself was intact (replaced: 1).
Resume first, then wait; also check the cut turn went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 26, 2026
… queue behind it (#23921)

* acpmux: a turn a daemon restart cut off resumes first, from the restored queue

When the agent ended with the daemon, the new daemon settles the open turn
outcome_unknown and queues one continuation at the head of the chat's queue:
it quotes the cut turn's prompt and its steers, runs once across further
crashes (prompt id <P>~resume-<n>, logged before the turn_result), and is
recorded as auto_resume_scheduled reason daemon_restart.

Agent-Session: 01a15ca9-5ac5-7692-adfc-a3ae828256ca

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15ca9-5ac5-7692-adfc-a3ae828256ca&host=huge-blue

* acpmux: a restart's continuation keeps its place, its images and its trust gate

Codex review of #23921:
- A daemon that stopped between the continuation's queued record and its
  queue_order restored it behind the queue; restore_queue now puts a
  daemon_restart continuation at the head (a later reorder still holds).
- The continuation hard-coded trustGate false; turn_started now records
  the cut turn's trust gate and the continuation carries it (a log from
  before that checks a web turn again).
- Images in the cut prompt or its steers were dropped; they are read back
  from attachments and sent again.

prompt_supersede's restart test (from #23733, newer than this PR) turns
restart continuation off: its until-cancel turn would otherwise run again
ahead of the queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue

* acpmux: #23733's restart test keeps restart continuation on

The supersede-after-restart test waited for the replacement's answer
before resume_queues, so the restored continuation of the cut turn (ahead
of it in the queue, as Leo asked: it resumes what it interrupted) never
ran and the test deadlocked. Supersede itself was intact (replaced: 1).
Resume first, then wait; also check the cut turn went on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue

* acpmux: a Web-steered cut turn goes on as a Web turn, through the trust gate

Codex re-review of #23921: the continuation took control and trust gate
from turn_started alone, so a local turn a Web steer had raised
(turn_control) went on as local with no folder-trust check. It now
applies turn_control, and a Web continuation is always gated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a167e2-7b7b-7aa3-8fcb-5b845bd68fdb&host=huge-blue

* fix(acpmux): preserve remote floor across restart resume

Agent-Session: https://cmux.com/deeplink/agent?harness=codex&session=01a16a58-a83b-70e3-8bbf-e5aadf9068ed&host=huge-blue

* fix(acpmux): handle unrelated restart log records

Agent-Session: https://cmux.com/deeplink/agent?harness=codex&session=01a16a58-a83b-70e3-8bbf-e5aadf9068ed&host=huge-blue

* fix(acpmux): only apply restart floor to Web turns

Agent-Session: https://cmux.com/deeplink/agent?id=aid-0c2d4e9433f05cabbb99

* fix(acpmux): adapt restart recovery to current queue APIs

Agent-Session: https://cmux.com/deeplink/agent?id=aid-0c2d4e9433f05cabbb99

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Leo Li <t@e>

This branch was previously deployed

4 inactive deployments
ci-routing-agent — 3f27bc1e Deployed Oct 21, 2026 by github-actions[bot]
artifacts — 3f27bc1e Deployed Oct 21, 2026 by teamleaderleo
sentry-dsyms — 3f27bc1e Deployed Oct 21, 2026 by teamleaderleo
cmux-tui-merge-tree — 3f27bc1e Deployed Oct 21, 2026 by teamleaderleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant