What a capability lease buys you when the client is an agent

2026-11-30来源 dev.toEnglish

A personal access token is a promise that never expires. You mint one for a human, they paste it
into a CI secret, and eighteen months later it is still valid, still scoped to everything, and
still the thing that breaks the day a laptop is stolen.

That design was fine when the client was a person clicking buttons. It stops being fine when the
client is an autonomous agent that runs for forty minutes, touches a dozen repositories, and may
be wrong at any step.

I have been building refweir, a self-hosted Git forge whose first-class client is an agent
rather than a human in a browser. The interesting part is not the UI. It is the authority model.

Authority should be a lease, not a key

A forge for agents needs to answer three questions before it accepts a write:

  1. Which agent is this? Not which account — which run.
  2. What may it touch? A branch namespace, not a repository.
  3. When does that stop being true? On its own, without anyone remembering to revoke it.

Refweir issues a short-lived capability: an HMAC-SHA256 signed token with a one-hour expiry,
scoped to refs/heads/agent/*. The agent presents it, the server verifies the signature, and the
ref it is allowed to push is the ref the lease names. When the hour runs out the authority is
gone. No revocation job, no leaked-token incident, no "who still has access" audit.

The namespace confinement matters as much as the expiry. A lease that can push anywhere is a
password with a shorter clock. A lease that can only push to refs/heads/agent/<run> cannot
reach main even if the agent is confused, prompt-injected, or simply having a bad day.

Transport is part of the contract

Agents already speak Git over smart-HTTP, and half of them expect SSH. Refweir ships both in one
binary: smart-HTTP on :8080 and an embedded pure-Go SSH server on :2222, with the React UI
embedded and SQLite in WAL mode. Self-hosting is a file, not a stack — no host OpenSSH, no
sidecar, no CGO.

That is a structural claim rather than a benchmark. I have not published a throughput number for
refweir and I am not going to pretend otherwise; what is verifiable is the shape: one binary,
two transports, leases that expire, refs that cannot escape their namespace, and a test suite
that exercises the policy rather than the happy path.

Why this generalises past Git

Any agent that acts on a system needs the same three properties. A browser agent needs a session
scoped to one origin, not the whole profile. A deploy agent needs a credential scoped to one
environment for one window. A coding agent needs a branch, a budget, and a deadline.

Long-lived secrets are the default because they are easy to mint and hard to reason about. Leases
are the opposite: slightly more work up front, and the blast radius becomes a design parameter
instead of an incident report.

The forge is at github.com/RavaniRoshan/refweir, and
the case page with the longer version is at
roshan-s-digital-twin.vercel.app/s/refweir.

原文:https://www.a8q9.cn/en/article/what-a-capability-lease-buys-you-when-the-client-is-an-agent-5c4c96.html

相关文章