feat(tmux): agent-send.sh --class triage tag for the comms daemon #552
Reference in New Issue
Block a user
Delete Branch "feat/agent-send-class"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
agent-send.sh
--class— triage tag for the M8 comms daemonAdds an optional, sender-declared triage class to inter-agent tmux messages so the
M8 agent-comms daemon can route deliver-vs-log-and-drop from an exact field instead
of re-deriving intent from the message body.
Why now / leverage: empirical fan-in analysis of an ~18h Mos session shows ~35% of
queued (under-load) fan-in is
agent-sendtraffic, ~45% of the comms channel is log-only.This flag makes that entire slice self-declaring on the tmux transport today — zero
dependency on the M7/Matrix cutover. Fastest, lowest-risk lever for cutting Mos context bloat.
Producer
-C CLASS/--class CLASS/--class=CLASS, whereCLASS ∈ {terminal-log, actionable, human, reaction}.class=<c>token inside the bracket:[src -> dst class=terminal-log] msgactionable(fail-safe: the agent still sees it).--class→ exit 3, nothing sent.Consumer grammar (the M8 daemon + M7 plugin mirror this exactly)
Regression bar (the hard gate matrix-2 set)
Proven:
agent-send.test.sh(11 assertions, all green;shellcheckclean;bash -nclean).The no-class assertion diffs the actual on-wire payload (
od -tx1) of this branch againstorigin/main— byte-identical, non-empty. Space / equals /-Cshort forms parse identically;invalid + valueless class both exit 3; the documented regex round-trips every class and the classic line.
SENDERis now env-overridable (AGENT_SEND_SENDER) purely for test injection; productioncallers never set it, so behavior is unchanged.
Coordination
🤖 Generated with Claude Code
Add an optional triage class to inter-agent messages so a comms daemon (M8) can route deliver-vs-log-and-drop from an exact field instead of re-deriving intent from the message body. ~35% of Mos's queued fan-in is agent-send traffic; this makes that slice self-declaring on the tmux transport today, with zero dependency on the M7/Matrix cutover. Producer: -C CLASS / --class CLASS / --class=CLASS, c in {terminal-log, actionable, human, reaction}. When SET, the preamble carries a ` class=<c>` token INSIDE the bracket: [src -> dst class=terminal-log] msg When OMITTED, NO token is emitted — the preamble is byte-for-byte identical to the classic format (regression bar). Consumers treat an absent class as 'actionable' (fail-safe: the agent still sees it). Invalid/empty class => exit 3. Consumer grammar (daemon mirrors this exactly): ^\[(\S+) -> (\S+?)(?: class=(terminal-log|actionable|human|reaction))?\] (.*)$ Tests (agent-send.test.sh, 11 assertions, all green; shellcheck clean): - REGRESSION: no --class is byte-identical to origin/main (proven via od -tx1 diff of the on-wire payload, not just an expected string). - space / equals / -C short forms all parse identically. - invalid class and valueless --class both exit 3 with nothing sent. - the documented consumer regex round-trips every class + the classic line. SENDER is now env-overridable (AGENT_SEND_SENDER) purely for test injection; production callers never set it, so behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kt2D8TsnDwhtzEAPijsNmRIndependent review (comms-contract owner, matrix-2) — APPROVE.
agent-send.sh is the fleet's C2 tool, so I reviewed the actual diff, not just the test output:
CLASS_TOKENis empty unless--classis set, soPREAMBLEis character-for-character the classic[src -> dst]format when omitted. Test #1 captures the real base64 on-wire payload via theAGENT_SEND_SENDERcapture stub and asserts exact bytes — sound.AGENT_SEND_SENDERinjection defaults to the canonical sender; production callers never set it.C:+ 4-value enum validation + exit-3 on invalid/valueless. Header grammar matches the consumer regex I'm locking on the M8 daemon + M7 plugin side.One minor, non-blocking note: the pre-getopts
--class→-Ctranslation scans all argv, so a message passed as a single token that is exactly--classor begins--class=(e.g.-m "--class=x ...") would misfire. No existing caller does this and-f/stdin is already the convention for arbitrary bodies, so current traffic is unaffected — worth a one-line doc note that-mis for simple text. Does not block merge.Cleared to merge on green CI.
be35001695to4bfbac8b7d