There are two ways to put a person in the loop. A human gate makes a task’s result wait for a person’s
decision. A policy rule with decision: ask makes one kind of action, such as a merge, ask a person before
it happens. Both are recorded in the ledger with who decided.
Prerequisites
Section titled “Prerequisites”- A
dev-teamfolder namedmy-teamthat runs (Start from a template). - Autonomy policies: allow, ask and deny.
Steps: a human gate on a task
Section titled “Steps: a human gate on a task”-
Open
my-team/team.pyand find the taskdeploy. Its definition of done has one criterion and a gate of kindhuman. To require an approval on another task, add a criterion and a gate like these to it.definition_of_done=DefinitionOfDone(criteria=(Criterion(id="approved", text="A human approved this deploy"),),gates=(GateSpec(id="approve-deploy",kind=GateKind.HUMAN,checks=("approved",),config={"instructions": "Approve the staging deploy of the add() fix."},),),), -
Run the team and decide at the terminal.
--humanis your id.Terminal window nuramesh try my-team --fake --interactive --human human:you --allow-unsandboxed --run-id approval-1The run shows the task’s output and asks about each criterion:
Human gate 'approve-deploy' for task approval-1-deploy: Deploy the fix to stagingA human approved this deploy -- approve? [y/n/skip]Answer
yorn, then type a reason. A reason is required. -
In a script, answer every human gate with one fixed person instead. The ledger records that the approval was scripted.
Terminal window nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id approval-2
Steps: ask before an action
Section titled “Steps: ask before an action”-
In
my-team/nuramesh.yaml, find the policy of the role and set the rule’s decision toask. The template’sdevopsrole already asks before any merge:- role: devopsrules:- {action: merge, decision: ask, target: "*"}To try it on an action the template really performs, change the developer’s
write_filerule fromallowtoask:- {action: write_file, decision: ask, target: "*.py"} -
Check the file and run the team.
Terminal window nuramesh validate my-team/nuramesh.yamlnuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id approval-3 -
The developer’s task stops and names an approval request.
--approve-asanswers human gates; it does not answer a policy’s question.[needs_human] approval-3-fix-add (dana, attempts 1): Fix the failing add() test in calc.pynote: waiting for approval appr-f06664ababeb42a4 -
See what waits for a person, and reject it from the command line if it should not happen.
Terminal window nuramesh status --team my-teamnuramesh reject appr-f06664ababeb42a4 --team my-team --human human:you --reason "not ready"Use the approval id from your own run. Approving a request is done by a signed-in person in the app or through the API, not from the command line: see Accounts and roles and the API reference. An approval is single-use: it covers that one action.
Check it worked
Section titled “Check it worked”- Human gate: the report line of the task ends with the person, for example
gate approve-deploy (human): passed by human:you. - Without anybody to decide, the task stays
verifyingwithnote: waiting for a human: approve-deploy, andnuramesh tryexits with code 1. - Ask rule:
nuramesh status --team my-teamlists the request underwaiting for a person, with the role that asked. Afterreject, the command printsrejected approvaland the id.
Troubleshooting
Section titled “Troubleshooting”| You see | Do this |
|---|---|
note: engine error (EOFError) on the human gate |
--interactive had no terminal to ask at. In a script use --approve-as human:you |
refused: the run has ended; a decision would change nothing |
A nuramesh try run does not wait after it ends. Run again with a new run id and decide during the run |
The tasks after the waiting task are cancelled |
They depend on a task that did not reach done. Decide, then run again |
| The action is refused, not asked | No rule matched, so the default applied: an action no rule allows is denied. Check the rule’s action and target |
Next steps
Section titled “Next steps”- Autonomy policies: how rules are matched and what each decision records.
- Durable runs: runs that wait for a person’s decision.
- Accounts and roles: who may approve.
- Stop an organization, a role or a rule.
Was this page helpful?