feat: one agent per PC and tester: a new sign-in retires the PC's older agents #61

Merged
HumanBean merged 1 commit from HumanBean/Beanstalk:feat/one-agent-per-pc into main 2026-11-16 11:34:36 +00:00
Owner

Why

The same app can't run twice on one data folder: the per-home lock holds, and I checked the Linux one across processes. But every fresh setup, reinstall or second copy of the app registers a new agent, because a new PC name means a new agent. So one PC shows as several testers:

Tester Agents on one PC
Unity 3
Yeetbot90 3
gab9281 2

A copy still running keeps polling as its own agent. Yeetbot90's first agent was still checking in after the second one registered.

What changed

  • Agent: sends machine in its capabilities, MachineId. That's 16 hex digits of SHA-256 of beanstalk-machine: and the system's own id (Windows' MachineGuid, Linux's /etc/machine-id), so it says nothing else. It's null when the system has none.
  • Coordinator: a registration retires the same login's other agents for that PC (agents.retire_others). They're matched by machine id, or, for an app that sends none, by OS, CPU model, GPU name and RAM; an unknown CPU never matches. A retired agent:
    • gets retired_at and replaced_by, and token_hash becomes retired:<id>, so a copy still running is refused and stops;
    • has its leased job given back as a release, not a failure (scheduler.give_back);
    • leaves the Testers page, the live counts and the waiting reasons. Its own page and old reports stay.
  • Migration 0016 adds the columns and retires the duplicates already there: all but the newest of a tester's alike agents, unless one holds a job. A dry run on the live database, rolled back, retires 6 stale agents: Unity ×2, Yeetbot90 ×2, gab9281 ×1 and an old dev agent of mine.
  • docs/protocol.md describes machine and the rule.

Testing

  • Coordinator: 520 passed, 1 skipped. tests/test_one_agent_per_pc.py covers:
    • matching by id and by hardware;
    • a new sign-in retiring only the same PC's agent, so another PC of the tester's and another tester's agents stay;
    • the old token refused, its leased job back in the queue with no failure counted;
    • the same name signing in again being the same agent, as before;
    • the Testers page;
    • the migration, run twice.
  • Agent checks: 1866 passed, with 5 new ones for MachineId. dotnet build agent/App -c Release: 0 warnings.
## Why The same app can't run twice on one data folder: the per-home lock holds, and I checked the Linux one across processes. But every fresh setup, reinstall or second copy of the app registers a new agent, because a new PC name means a new agent. So one PC shows as several testers: | Tester | Agents on one PC | |---|---| | Unity | 3 | | Yeetbot90 | 3 | | gab9281 | 2 | A copy still running keeps polling as its own agent. Yeetbot90's first agent was still checking in after the second one registered. ## What changed - **Agent:** sends `machine` in its capabilities, `MachineId`. That's 16 hex digits of SHA-256 of `beanstalk-machine:` and the system's own id (Windows' MachineGuid, Linux's `/etc/machine-id`), so it says nothing else. It's null when the system has none. - **Coordinator:** a registration retires the same login's other agents for that PC (`agents.retire_others`). They're matched by machine id, or, for an app that sends none, by OS, CPU model, GPU name and RAM; an unknown CPU never matches. A retired agent: - gets `retired_at` and `replaced_by`, and `token_hash` becomes `retired:<id>`, so a copy still running is refused and stops; - has its leased job given back as a release, not a failure (`scheduler.give_back`); - leaves the Testers page, the live counts and the waiting reasons. Its own page and old reports stay. - **Migration 0016** adds the columns and retires the duplicates already there: all but the newest of a tester's alike agents, unless one holds a job. A dry run on the live database, rolled back, retires 6 stale agents: Unity ×2, Yeetbot90 ×2, gab9281 ×1 and an old dev agent of mine. - `docs/protocol.md` describes `machine` and the rule. ## Testing - Coordinator: 520 passed, 1 skipped. `tests/test_one_agent_per_pc.py` covers: - matching by id and by hardware; - a new sign-in retiring only the same PC's agent, so another PC of the tester's and another tester's agents stay; - the old token refused, its leased job back in the queue with no failure counted; - the same name signing in again being the same agent, as before; - the Testers page; - the migration, run twice. - Agent checks: 1866 passed, with 5 new ones for `MachineId`. `dotnet build agent/App -c Release`: 0 warnings.
feat: one agent per PC and tester: a new sign-in retires the PC's older agents
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 4s
CI / Workflow lint (actionlint) (pull_request) Successful in 4s
CI / Coordinator tests (pull_request) Has been cancelled
CI / Agent build and checks (pull_request) Has been cancelled
CI / Coordinator image (pull_request) Has been cancelled
c93b60d3e3
Each fresh setup or copy of the app registered a new agent, so one PC
showed as two or three testers (Unity, Yeetbot90, gab9281), and a copy
still running kept polling as its own agent. The app now sends a machine
id (SHA-256 of beanstalk-machine: and the system's MachineGuid or
/etc/machine-id, 16 hex digits). A registration retires the same login's
other agents for that PC, matched by machine id or, for an app that sends
none, by OS, CPU, GPU and RAM: their tokens stop working, their leased jobs
go back in the queue as a release, and they leave the testers' lists
(migration 0016, which also retires the duplicates already there).

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch feat/one-agent-per-pc 2026-11-16 11:34:36 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!61
No description provided.