fix: restart background agent on MONK_AGENT_LOCAL / plugin-version drift (closes #229) - #231
fix: restart background agent on MONK_AGENT_LOCAL / plugin-version drift (closes #229)#2310xConsole wants to merge 1 commit into
Conversation
…drift (closes monk-io#229) The launcher's healthy-agent fast path on Linux (background_process_configured) and Windows (Test-BackgroundStateConfigured) only diffed agent_path and the auth/autospin fields in the state file, while the macOS launchd path also gates on MONK_AGENT_LOCAL and MONK_PLUGIN_VERSION. Result: flipping the agent's local-mode switch or a plugin-only upgrade was silently ignored by the running agent on two of the four supported hosts. - Gate state-file reuse on local= and plugin_version= in both launchers - Persist both fields on every start (all start paths) - Extend tests/start-monk-agent-fastpath.sh: state fixtures use the new 7-field format; new Case 3 asserts restart + local=1 persistence on MONK_AGENT_LOCAL drift; existing Cases 1-2 (reuse, auth_url drift) unchanged and passing
|
Hi @monk-io team — this PR has been open and mergeable for ~26h; posting a concise recap to make review cheap. Bug (#229): when Reproduced: Fix (1 commit, mirrored in both launcher scripts):
CI-runnable test suite is included in the PR. Happy to adjust anything — thanks! |
|
Friendly bump — this fix has been open ~48h with green CI. It resolves the [Bug bounty] #229 class: state-file reuse in |
Closes #229
What this fixes
The launcher's "healthy agent" fast path restarts a running agent when its recorded configuration drifts. The macOS
launchd_configured()gate diffs the plist againstagent_path, auth fields, autospin URL,MONK_AGENT_LOCAL, andMONK_PLUGIN_VERSION— but:background_process_configured()diffed onlyagent_path,auth_url,auth_client_id,auth_audience,autospin_urlTest-BackgroundStateConfigured()had the same five-field list, andMONK_AGENT_LOCALappeared nowhere in the.ps1launcherSo on Linux and Windows:
MONK_AGENT_LOCALhad no effect until unrelated drift happened to force a restart — a user setting silently ignored;MONK_PLUGIN_VERSIONin telemetry/session metadata indefinitely.Change
local=andplugin_version=into the state file on every start (POSIX + PS1, all three mirrored copies:scripts/,plugins/monk/scripts/,.antigravity-plugin/scripts/)local=/plugin_version=(notagent_local=) to avoid any ambiguity in the strictgrep -Fxqline matchBehaviour for existing installs: an old 5-field state file mismatches once on the first run after upgrade, causing a single one-time restart — the same once-per-fill semantics the state-file design already uses for newly tracked fields.
Test evidence
tests/start-monk-agent-fastpath.sh(repo fixture, no network):local=+plugin_version=0.1.52)MONK_AUTH_URLdrift → restarted once, new URL persisted ✓ (unchanged behaviour)MONK_AGENT_LOCALflipped""→1→ restarted once,local=1persisted ✓Additional scenario verification (scratch harness, same fixtures):
tests/start-monk-agent-readiness-timeout.shalso passes (it enforces thescripts/↔plugins/monk/scripts/↔.antigravity-plugin/scripts/mirror, which is why all three copies are updated).