智能体
dev.to ·
@TECHDEV
Agent 审批会过期:用时间盒租约管理“可以运行”的授权
作者复盘一次部署审批在 40 分钟后才被执行、目录和代码已变化的经历,指出人类审批缺少过期时间、作用范围和凭证记录。其自建 leaseguard 将“同意”转为带签名、限时、限定目录的租约,例如 grant "npm run deploy" --for 10m。
AI推荐理由 提出 agent 审批“过期授权”问题,并给出 leaseguard 的时间盒、目录范围、签名租约方案,对 Agent 安全与权限设计有实际参考价值;但为个人项目自述,缺少实现细节与验证数据。
72
正文
I run coding agents the way most of us do now: it proposes, I approve, it executes.
Last week I caught something uncomfortable in my own workflow. I told an agent
"yes, run the deploy" — then got pulled into a meeting. Forty minutes later it
ran the deploy. Different directory. Code that had changed twice since I'd
looked at it.
I had approved the command at 10:00. I had not approved the command at 10:40.
But nobody wrote that down, so my yes quietly survived past its own relevance.
The pattern has a name: stale approvals
DZone recently ran a piece on authorization leases for agentic workflows, and it
clicked: the problem isn't that agents are disobedient. It's that our approvals
have no expiry date, no scope, and no receipt. A human approval is a moment in
time — but we hand it to the agent as if it were a permanent permission.
So I built the lease
leaseguard turns "yes" into a
signed, time-boxed, directory-scoped lease:
leaseguard grant "npm run deploy" --for 10m --note "hotfix for #42"
leaseguard run --lease $TOKEN -- npm run deploy
Enter fullscreen mode
Exit fullscreen mode
The gate checks: standing deny policy (deny always wins, even over a valid
lease) → lease signature → expiry → directory scope → command pattern. Then it
runs the command, passes through the exit code, and appends every decision to
a hash-chained ledger. leaseguard audit shows what ran, what was denied,
which approvals died quietly unused, and whether anyone tampered with the log.
One file, zero dependencies, Node 18+. The part I'm proudest of is what it
doesn't claim: it won't stop a determined adversary with your file
permissions, and it says so in the README. It stops stale approvals, accidents,
and casual misuse — which is the actual problem I had.
Try the demo: grant a 3-second lease, use it, watch it expire, then audit.
The stale approval dies quietly, and nothing runs on your old yes.