Skip to content
Docs
Request access

Require a human approval

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.

  1. Open my-team/team.py and find the task deploy. Its definition of done has one criterion and a gate of kind human. 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."},
    ),
    ),
    ),
  2. Run the team and decide at the terminal. --human is your id.

    Terminal window
    nuramesh try my-team --fake --interactive --human human:you --allow-unsandboxed --run-id approval-1

    The run shows the task’s output and asks about each criterion:

    Human gate 'approve-deploy' for task approval-1-deploy: Deploy the fix to staging
    A human approved this deploy -- approve? [y/n/skip]

    Answer y or n, then type a reason. A reason is required.

  3. 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
  1. In my-team/nuramesh.yaml, find the policy of the role and set the rule’s decision to ask. The template’s devops role already asks before any merge:

    - role: devops
    rules:
    - {action: merge, decision: ask, target: "*"}

    To try it on an action the template really performs, change the developer’s write_file rule from allow to ask:

    - {action: write_file, decision: ask, target: "*.py"}
  2. Check the file and run the team.

    Terminal window
    nuramesh validate my-team/nuramesh.yaml
    nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id approval-3
  3. The developer’s task stops and names an approval request. --approve-as answers 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.py
    note: waiting for approval appr-f06664ababeb42a4
  4. See what waits for a person, and reject it from the command line if it should not happen.

    Terminal window
    nuramesh status --team my-team
    nuramesh 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.

  • 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 verifying with note: waiting for a human: approve-deploy, and nuramesh try exits with code 1.
  • Ask rule: nuramesh status --team my-team lists the request under waiting for a person, with the role that asked. After reject, the command prints rejected approval and the id.
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

Was this page helpful?