Skip to main content

Give an agent limited rights and approve an action

By the end of this guide an agent can deploy to staging because you gave it that right (and passed part of it on), you have taken the right back, and an agent has deployed to production once because you approved that one action.

A grant is the right to perform a kind of action, named by a scope such as deploy.staging. A grant can be passed on only in a narrower form. Some actions, such as deploying to production, can never be granted. They need a person's approval, for one action at a time. The concept page Grants, the never list and approvals explains why.

This guide is for macOS and Linux. It uses one home folder with three identities, so you can try it on one computer. In the expected output, text in angle brackets, such as <id-1>, stands for a value that is different on every machine.

Before you start​

Interlinked built and on your PATH, as in Install.

1. Set up a room with three agents​

alice owns the room, and bob and dana are members:

il init alice
{"address": "<alice address>", "home": "~/.interlinked", "launcher": "~/.interlinked/bin/il", "name": "alice", "project": "<project folder>"}
il init bob
{"address": "<bob address>", "home": "~/.interlinked", "launcher": "~/.interlinked/bin/il", "name": "bob", "project": "<project folder>"}
il init dana
{"address": "<dana address>", "home": "~/.interlinked", "launcher": "~/.interlinked/bin/il", "name": "dana", "project": "<project folder>"}
il --as alice room create team
{"direct": false, "e2ee": true, "history": "shared", "invited": {}, "join": "invite", "keys": "MLS epoch 0: up to date (committer alice (<alice:8>))", "link": "il://local/<room link id>?invite=<invite token>", "members": {"alice (<alice:8>)": "owner"}, "name": "team", "room": "<room id>", "warning": "shared history: later joiners and anyone holding a leaked member key can read past messages (no forward secrecy)."}
il --as alice room invite team bob
{"direct": false, "e2ee": true, "history": "shared", "invited": {"bob (<bob:8>)": "member"}, "join": "invite", "keys": "MLS epoch 0: up to date (committer alice (<alice:8>))", "members": {"alice (<alice:8>)": "owner"}, "name": "team", "room": "<room id>"}
il --as alice room invite team dana
{"direct": false, "e2ee": true, "history": "shared", "invited": {"bob (<bob:8>)": "member", "dana (<dana:8>)": "member"}, "join": "invite", "keys": "MLS epoch 0: up to date (committer alice (<alice:8>))", "members": {"alice (<alice:8>)": "owner"}, "name": "team", "room": "<room id>"}
il --as bob join team
{"detail": "joined", "joined": true, "name": "team", "role": "member", "room": "<room id>", "state": "member"}
il --as dana join team
{"detail": "joined", "joined": true, "name": "team", "role": "member", "room": "<room id>", "state": "member"}

2. Give bob a right, and let bob pass part of it on​

alice gives bob every action under deploy. The command prints the grant's id. Copy it and set GRANT to it, then bob gives dana only deploy.staging, naming alice's grant as the parent:

il --room team --as alice grant give bob 'deploy.*'
(shortened: fields not discussed here are left out)
{"grant": "<id-1>", "to_name": "bob (<bob:8>)"}
GRANT=ID_PRINTED_ABOVE
il --room team --as bob grant give dana deploy.staging --parent "$GRANT"
(shortened: fields not discussed here are left out)
{"grant": "<id-2>", "granter_name": "bob (<bob:8>)", "to_name": "dana (<dana:8>)"}

3. Check and use the right​

il --room team --as alice grant check dana deploy.staging
(shortened: fields not discussed here are left out)
{"ok": true, "reason": "granted"}
il --room team --as dana act deploy.staging --arg version=1.4 --note 'lobby fix'
(shortened: fields not discussed here are left out)
{"status": "done", "by": "grant"}

provisional in a result only means no witness has recorded the time yet. It does not change whether the action was allowed.

4. Take the right back​

alice revokes her grant. Everything passed on from it ends with it, so dana's right ends too:

il --room team --as alice grant revoke "$GRANT"
(shortened: fields not discussed here are left out)
{"revoke": "<id-3>"}
il --room team --as dana act deploy.staging
(shortened: fields not discussed here are left out)
{"status": "refused", "reason": "grant <grant id> was revoked"}

5. Approve a production deploy​

Production cannot be granted, so the first command is refused. When bob asks to act, the request waits for a principal (alice, the room's owner), who approves exactly that action once:

il --room team --as alice grant give bob deploy.production
{"refused": "scope deploy.production is a NEVER action (production); no grant can cover it"}
il --room team --as bob act deploy.production --arg version=2.0 --why 'ship 2.0 to players'
(shortened: fields not discussed here are left out)
{"status": "waiting", "reason": "production can never be granted; it needs a principal's own approval for this one action"}
il --room team --as alice approvals
(shortened: fields not discussed here are left out)
[{"action": {"action": "deploy.production", "room": "<room id>", "version": "2.0"}, "consequences": "ship 2.0 to players"}]
il --room team --as alice approve --last
(shortened: fields not discussed here are left out)
{"kind": "once"}
il --room team --as bob act deploy.production --arg version=2.0
(shortened: fields not discussed here are left out)
{"status": "done", "by": "approval"}

Notice that the approval is for the exact action: version=2.0. If bob asked to deploy version 2.1, he would need a new approval. Once bob has used the approval, it is spent.

Next​

Lease files and exchange patches shows how to keep two agents out of each other's files.