Skip to main content

Module srv_stderr

Module srv_stderr 

Source
Expand description

The stderr line protocol agentmux-srv uses to talk to whichever process supervises it — the launcher in packaged builds and task dev (crates/launcher/src/srv_spawner.rs), or the CEF host in task dev:standalone (crates/cef/src/sidecar.rs).

srv formats these lines; both supervisors parse them. Putting the vocabulary here means one definition instead of three string literals that have to stay byte-identical by convention (the “keep in sync” pattern docs/reports/REPORT_DRY_AND_MODULARITY_AUDIT_2026_09_06.md §2 counts 334 instances of).

Every line is single-line and prefix-tagged. In startup order:

  • AGENTMUXSRV-MIGRATING migrations:<n> — in-process migrations are about to run; supervisors extend their ESTART deadline. (Still emitted and parsed with inline literals at the three sites above — not migrated to this module yet; only the new line below lives here.)
  • AGENTMUXSRV-MIGRATION-BEGIN id:<id> description:<text> / AGENTMUXSRV-MIGRATION-END id:<id> duration_ms:<n> — one pending migration is starting / has finished, inside the AGENTMUXSRV-MIGRATING window above. Before these existed, a slow migration was invisible past the initial count — the splash showed a bare, silently-running “Backend startup” clock with no indication anything unusual (a multi-minute migration) was happening inside it. See docs/reports/REPORT_SPLASH_SCREEN_ARCHITECTURE_RETHINK_2026_09_14.md §2.1. Only the launcher supervisor turns these into splash sub-rows (against the already-open backend stage — a migration is not a separate top-level stage, it happens entirely inside that one); the CEF-host sidecar has no splash to report to and simply logs them like any other stderr line, same as it already did for the unparsed line before this existed.
  • AGENTMUXSRV-MIGRATION-FAILED error:<text> — a migration failed and srv is about to exit 1 without emitting ESTART. Added by Phase 1 of docs/specs/SPEC_MIGRATION_SYSTEM_HARDENING_2026_08_03.md; before it, a failed migration was a warn! and srv booted anyway against a store in an unknown state.
  • AGENTMUXSRV-ESTART ... — ready. Parsed separately by each supervisor; unchanged.

Structs§

MigrationBegin
A parsed MIGRATION_BEGIN_PREFIX line.
MigrationEnd
A parsed MIGRATION_END_PREFIX line.

Constants§

MIGRATION_BEGIN_PREFIX
Prefix of the line srv writes to stderr just before applying one pending migration.
MIGRATION_END_PREFIX
Prefix of the line srv writes to stderr just after one migration applies successfully. (No -END line is written on failure — up() returning Err goes straight to AGENTMUXSRV-MIGRATION-FAILED and srv exits.)
MIGRATION_FAILED_PREFIX
Prefix of the line srv writes to stderr immediately before exiting 1 because run_pending_migrations failed. Supervisors match on this to fail fast with the real reason instead of waiting out the ESTART timeout.

Functions§

migration_begin_line
Migration ids (m.id(), e.g. "0020_agent_color_backfill") are a fixed, engineer-chosen identifier format with no spaces — never free text — so splitting id:<id> description:<text> on the first space is safe and exact, unlike description itself which is flattened via one_line.
migration_end_line
migration_failed_line
Format the failure line srv emits. The error text is flattened to a single line (the protocol is line-delimited; a multi-line SQLite error would otherwise split into one tagged line and several untagged ones).
parse_migration_begin_line
Parse a MIGRATION_BEGIN_PREFIX line. None for any other line, or a begin line missing the id: field it cannot be meaningfully split without.
parse_migration_end_line
Parse a MIGRATION_END_PREFIX line. None for any other line, a malformed one, or a non-numeric/missing duration_ms: field.
parse_migration_failed_line
Parse a stderr line. Returns the error message if this is a MIGRATION_FAILED_PREFIX line, None for any other line. Tolerates a missing error: field and never returns an empty message, so callers can put the result straight into a user-facing dialog.