ADR 0019doc/{zh,en}/adr/0019-exclusive-resources.md

ADR 0019: Exclusive Resources Are Leases Held by Runs

Status: accepted by the owner, 2026-11-29 (B17).

Status: accepted by the owner, 2026-11-29 (B17).

Context

Some things a tool drives can serve one task at a time: a computer through the computer plugin's desktop agent, and a browser profile through agent-browser. Two runs moving the same mouse, or typing into the same browser, break each other. The plugin benchmark listed this as B17 and kept it inside plugins until a second scenario appeared; computer use is that scenario (research, section 8, decision 5). A plugin cannot release a resource reliably on its own: it does not see every way a run ends (cancellation, failure, a Host restart).

Decision

  1. The Host keeps the leases. internal/host/leases holds, per resource, the run that holds it and a deadline. A lease ends when the run ends or is cancelled (the Host's run-end path), when its deadline passes without a renewal, or when the Host restarts (the table lives in memory, because what it guards does not outlive the process either).
  2. Tools ask through plugin.LeaseHost. Hold(resource, ttl) takes or renews the calling run's lease, and fails with resource.busy while another run's lease is live; Release(resource) lets it go early. The run comes from the trusted call context only.
  3. Names are per instance. The Host prefixes every name with the calling instance, so two instances never share or block each other's resources.
  4. Deadlines are bounded. A lease lasts at most 30 minutes between renewals, so a run that stops using a resource without ending still lets it go.

Consequences

  • ◆One ToolHost interface, one in-memory package and a line in the run-end path; no database table, no migration, no configuration.
  • ◆The computer plugin holds device/<name> for each action (two minutes, renewed by every action); a second run gets device_busy. The browser plugin can use the same interface when it needs it.
  • ◆Leases do not survive a Host restart; a resource whose holder must survive a restart would need a durable table, which no scenario needs today.