Skip to content

Keep detecting an agent whose binary the updater renamed aside - #45

Open
Mirr0ch1 wants to merge 1 commit into
RoversX:mainfrom
Mirr0ch1:fix/agent-status-updated-binary
Open

Mirr0ch1 wants to merge 1 commit into
RoversX:mainfrom
Mirr0ch1:fix/agent-status-updated-binary

Conversation

@Mirr0ch1

Copy link
Copy Markdown
Contributor

Observed live: an omp session that had run for hours silently lost its sidebar row and agent state after omp self-updated mid-session. The pane was still alive, its OSC title still carried the working spinner, and `cli agent list` no longer named it.

Root cause

Agent detection paths a leader's executable through `normalize_executable_path`, which was built for one update shape: replaced in place, where the name survives and Linux only adds `" (deleted)"`. omp's updater cannot write over a running executable, so it uses the second shape: rename aside to `omp....bak`, and the running process reports that path until it exits. Both consumers of the normalized path then fail:

  • identification (R1) — the basename `omp.1795438578597.2330537.0.bak` matches no manifest alias, so process identification dies;
  • the contract's liveness check (R2) — a record whose emitter was observed before the update holds the old path, and the next look sees the renamed one: a definite mismatch, so a still-live emitter reads as gone and the contract identity is dropped.

A pane riding only those two signals falls out of the registry entirely, and eviction is also what clears its OSC evidence, so the manifest's `π ` title rules -- which could have carried it -- never get a chance to run. The panes that kept their rows were the ones with luckier fallbacks at that moment (an active shell-command report, or a contract re-emitted after the update so it re-recorded the renamed path).

Fix

`normalize_executable_path` collapses a trailing `.(.)*.bak` update stamp after the deleted decoration, restoring the agent's real basename for both consumers. Guarded the other way: at least one digit group is required, and the surviving basename must still carry a letter, so a file genuinely named `foo.bak` and version-style launcher basenames (`1.2.3.bak`) keep their names.

Recovered live inputs are the first test cases, including the exact observed `/home/mirro/bin/omp.1795438578597.2330537.0.bak (deleted)`, and an end-to-end test runs the normalized path back through `proc_match::identify`.

Verification

`cargo test -p mux --lib`: 369 passed, 0 failed (3 new tests in `agent_status::identify`).

…ater

Detection assumed a self-updated binary was replaced in place, the shape
that keeps its name and only gains Linux's " (deleted)" decoration.
omp's updater cannot write over a running executable, so it renames it
aside -- omp.<mtime-ms>.<pid>.<attempt>.bak -- and every probe keeps
reporting the renamed path until the process exits. The basename then
reaches no manifest alias (R1 dead), and the contract's recorded leader
path stops matching the observed one, so a live emitter looks gone (R2
dead); a pane whose contract was retired by a shell tool's OSC 133;A and
that is not running a command right now (waiting on a background job)
falls out of the registry entirely, dropping its sidebar row and agent
state.

normalize_executable_path now collapses the trailing stamp as well, in
the same place and for the same two consumers: identification sees the
agent's real basename again, and leader-path equality stays true across
the update. A stamp must be dot-separated digit groups before a .bak,
and the surviving basename must still carry a letter, so foo.bak and
version-style launcher names keep theirs.

This branch has not been deployed

No deployments
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