Skip to main content

Module sanitize

Module sanitize 

Source

Constants§

SUPERVISOR_HEADER_PREFIX
The opening of the Swarm Supervisor’s continuation header. Only srv writes it (supervisor_turn_message): neutralize_markers quotes [SUPERVISOR: inside every delivered body, so a jekt or a broadcast cannot start one.
SYSTEM_NOTE_MARKER
The marker every note of srv’s own starts with. The agent pane shows a turn that starts with it as an AgentMux note; a turn without it would take the style of a person’s message.
USER_MARK_HEAD
The head of the mark srv puts on what the person typed in an agent’s pane (or on a paired device, or clicked in the Kanban): [USER:FROM=user TS=<unix secs>] on its own line, then their words. The model reads it as the first line of a delivered message; the stored record and every view drop it (strip_user_mark). Only srv writes it, and only where the person is proven (MessageOrigin::as_model_text): neutralize_markers quotes [USER: inside every delivered body, so a jekt, a note or a bridge message cannot carry one. See docs/specs/SPEC_AGENT_INPUT_ORIGIN_MARKS_2026_11_24.md.

Functions§

broadcast_turn_message
The text an agent receives for one target of a Swarm broadcast: a one-line header, then the body.
delivery_how
How a delivery travelled and how far its sender was proven, for its audit line: the delivery tier (host, channel, lan or wan) and the marker’s TRUST= label, from the same function the marker is composed with.
device_turn_message
The text an agent receives for a message the user sent from a paired device: what they typed, as a plain user turn with no header (the record stored beside it says where it came from, viewer::origin). Escape sequences and invisible characters are dropped and marker delimiters quoted, as in every delivered body, so the text can’t pose as a jekt, a broadcast or a system note. The caller keeps it under MAX_MESSAGE_LENGTH, so nothing is cut.
format_injected_message
Format a message with optional source agent prefix.
is_sensitive_message
Returns true if the message body contains keywords indicating a sensitive operation.
jekt_origin
Where a jekt came from, as the record of it stores it (message_origin), from the same typed values the marker is composed from. Nothing is read from the body.
jekt_trust
How far a jekt’s sender is trusted: the marker’s TRUST= label, and the trust of the record’s origin (message_origin), from one function so the two cannot differ.
kanban_agent_message
The text another agent’s action on the Kanban (start, send back, answer, reassign) puts in the target agent’s input: [KANBAN:FROM=<agent> BY=agent] on its own line, then the text. The person’s own clicks carry the user mark instead. Only srv writes it: neutralize_markers quotes [KANBAN: inside every delivered body, and the text itself goes through it here.
neutralize_markers
The message body as it goes inside the block: marker delimiters quoted, so the body can’t close the real block or open one of its own. The body has already been through sanitize_message, which dropped invisible characters and carriage returns; this only replaces delimiters, so it can’t create text a content check didn’t see.
post_refusal_help
What a refusal adds for the word it names, so the poster knows how to get past it: “token” is let through when it is about usage.
post_refusal_reason
Why a text posted for others to read (a bulletin or a channel post) is refused as being about credentials or a destructive action, or None when it may be posted: the word or phrase that matched, as it stands in the text.
quote_in_jekt
One line of sender-controlled text that srv puts inside a jekt itself, outside the message body: a sent file’s name, or the sender’s name in the file list. Marker delimiters and attachment list tags are quoted, as in the body, so the text can’t close the block or open a list of its own.
quote_in_system_note
Text that goes inside one of srv’s own [AgentMux] system notes but was not written by srv: another agent’s claim note or topic, a file path, a branch or agent name. Sanitized like a delivered body, flattened to one line (every control character and line break becomes a space, runs of whitespace collapse), and with marker delimiters quoted, so it can neither start a line of its own nor open an [AgentMux] note, a jekt block or a broadcast header.
registrable_id
The id a name registers under: its route name, when that is a valid id. A name with ‘@’ keeps it (it is kept for forwarding a target across tiers), and no message could reach it here, so it doesn’t register (#4744).
route_name
The route name of a name arriving at the registry (a registration, an unregistration, a message’s target), None for a blank one. A fork’s display name “Loap #3” is “Loap-3” (REPORT_FORK_AGENT_ISOLATION_2026_10_12.md F3).
sanitize_message
Sanitize a message by removing dangerous escape sequences and control characters.
sanitize_text
Steps 1 to 5 of sanitize_message, with no length cap: for text kept whole (a task’s brief) where the caller applies its own limit.
strip_user_mark
text without a leading user mark: only the exact shape srv writes counts, so a lookalike stays as written.
supervisor_turn_message
The text an agent receives when the Swarm Supervisor continues it: a one-line header, then body, which the caller composes from fixed text and already-quoted judge text (backend::supervisor::message).
user_turn_message
The person’s words with the mark in front, as the model receives them.
validate_agent_id
Validate an agent ID.
validate_muxbus_url
Validate an AgentMux URL for SSRF protection.
wan_verdict
What srv’s check of a WAN sender’s instance came to, for jekt_trust: Some(true) when the check held and the request names the instance, Some(false) when a check was made and failed, None off the WAN tier or when nothing was checked.
with_system_note_marker
text as a system note: unchanged when it already starts with the marker, else with it in front. Every way srv puts a note of its own into an agent’s turn goes through this, so a caller that forgets the marker still cannot make automated text look like a person’s.
wrap_jekt_message
Wrap an injected message with a structured [JEKT:...] marker block.
wrap_jekt_message_full
wrap_jekt_message_with_files for a fire of this AgentMux’s own scheduler: the marker also names the job and who it runs for (JOB= and FOR=), from super::types::SchedulerFire, which srv set and no sender can.
wrap_jekt_message_with_files
wrap_jekt_message for a jekt that was sent with files (SPEC_JEKT_FILE_TRANSFER_2026_10_05.md §6.2): the marker gains FILES=<n delivered>, and srv’s own text for them (the <attached_files> list, or why there is none) follows the message inside the block. Only srv writes that list: the sender’s text has its list tags quoted ([neutralize_file_lists]), on every jekt.