fix(update): the monitor is this workspace's exact command line; create/resume take the pane workspace's admission; refusal snapshots compare the registry by rows (Issue #72, review round 3)
- daemon.find_running matches `<bash> <reconcile.sh> --subscribe[ ...]` exactly instead of an unanchored, unescaped pgrep regex: another workspace's daemon (ws.a vs wsXa) or a process naming the path in an argument is no longer signalled by the update. update.sh re-checks which PIDs are still the monitor before SIGKILL. - create and resume (spawn path) take the update admission of every installed workspace at or above the pane cwd, not only the control root's (lib.sh mam_update_admit_at, lib_py.update target-workspaces --cwd); the ~/.local/bin wrapper child drops all of them. - tests: snapshot() skips the SQLite -wal/-shm and compares the DB by its rows (macOS keeps the sidecars and a read rewrites -shm); regression tests for the monitor match and for create/resume in another installed workspace (marker and lock wait); evidence line refs shifted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
454b77215f
commit
cf1b693e85
9 files changed
+209
-32
No files matched your search
@@ -230,6 +230,51 @@ def test_delegate_submit_waits_for_the_target_workspace_admission_lock(mam_sandb
|
||||
assert _no_job(mam_sandbox)
|
||||
|
||||
|
||||
def _start_in(sandbox, entry, b, env=None):
|
||||
"""create or resume (spawn path) of an agent whose pane cwd is B/sub."""
|
||||
if entry == "create":
|
||||
argv = ["bash", _script(sandbox, "multi-agent-mux-create/scripts/create_session.sh"),
|
||||
"--workspace", str(b / "sub"), "--agent", "claude", "--role", "creator",
|
||||
"--session", "gated-in-b", "--no-onboard"]
|
||||
else:
|
||||
_seed(sandbox, [dict(_row("gated-in-b", status="stopped", agent="agy"),
|
||||
pane={"cwd": str(b / "sub"), "cmd": "agy"})])
|
||||
argv = ["bash", _script(sandbox, "multi-agent-mux-resume/scripts/resume_session.sh"),
|
||||
"--workspace", str(b / "sub"), "--agent", "agy", "--session", "gated-in-b"]
|
||||
return _run(sandbox, argv, env=env, timeout=300)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entry", ["create", "resume"])
|
||||
def test_create_and_resume_take_the_pane_workspace_marker(mam_sandbox, mock_herdr, mock_agents, marker,
|
||||
other_ws, entry):
|
||||
"""An agent started in an installed workspace B other than the control root
|
||||
is one B's update counts, so B's marker refuses it too."""
|
||||
marker(True, other_ws)
|
||||
res = _start_in(mam_sandbox, entry, other_ws)
|
||||
assert res.returncode != 0, res.stdout + res.stderr
|
||||
assert "an update of %s is in progress" % other_ws in res.stderr, res.stdout + res.stderr
|
||||
assert json.loads(Path(mock_herdr).read_text())["agents"] == {}, "nothing was spawned"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entry", ["create", "resume"])
|
||||
def test_create_and_resume_wait_for_the_pane_workspace_admission_lock(mam_sandbox, mock_herdr, mock_agents,
|
||||
other_ws, entry):
|
||||
holder = subprocess.Popen([sys.executable, "-c", "import fcntl, sys, time\n"
|
||||
"f = open(sys.argv[1], 'a'); fcntl.flock(f, fcntl.LOCK_EX)\n"
|
||||
"print('locked', flush=True); time.sleep(120)",
|
||||
str(other_ws / ".mam" / "update-admission.lock")],
|
||||
stdout=subprocess.PIPE, text=True, start_new_session=True)
|
||||
try:
|
||||
assert holder.stdout.readline().strip() == "locked"
|
||||
res = _start_in(mam_sandbox, entry, other_ws, env={"MAM_UPDATE_ADMISSION_WAIT_S": "1"})
|
||||
finally:
|
||||
holder.kill()
|
||||
holder.wait()
|
||||
assert res.returncode != 0, res.stdout + res.stderr
|
||||
assert "an update of %s holds its admission lock" % other_ws in res.stderr, res.stdout + res.stderr
|
||||
assert json.loads(Path(mock_herdr).read_text())["agents"] == {}, "nothing was spawned"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("purge", [False, True])
|
||||
def test_stop_refuses_and_changes_nothing(mam_sandbox, mock_herdr, marker, purge):
|
||||
_seed(mam_sandbox, [_row("gated-stop")])
|
||||
|
||||
Reference in new issue
Block a user