How it works
- A job that has
approve: truedoes not start. The controller holds it. - The controller starts the definition's
ask:, which is another job, and gives it the held jobs asinput.jobs. - The ask returns the names of the jobs it approves. Those jobs start, and the others fail with status
denied.
This is the same for a flow's stage, a statechart's state and an agent's tool.
Example
The flow starts one refund job for 20 and one for 900. The ask approves a refund of 100 or less.
# refunds.yaml
flow: refunds
ask: { script: ./ask.js }
stages:
refund:
each: [20, 900]
job:
script: ./refund.js
input: { amount: "${item}" }
approve: true
output: ${stages.refund.output}// ask.js
const small = input.jobs.filter(job => job.input.amount <= 100)
return { approve: small.map(job => job.name), note: "over 100" }// refund.js
return "refunded " + input.amount
corbie test refunds.yaml output: [{"item":20,"output":"refunded 20"},{"error":"the ask did not approve the job: over 100","item":900}]
The refund of 20 ran. The refund of 900 never started, and its error holds the ask's note.
The ask
input.jobsthe held jobs: [{ name, input, allow, script or machine }]
the result{ approve: [names of jobs], note }
An ask is any job.
a scriptapplies a rule, as ask.js does
a statechartwaits for a person, who answers with corbie run reply
an agenthas a model review the jobs
For an agent's tool, each held job has asked: { does, args, said }: what the tool does, the arguments the model gave and what the model said. For a tool from a list:, asked has entry and tool too: the entry's name and the tool's own, such as github and create_issue. For a tool of a set, and the list of an entry in one, it has set, the set's full name, such as platform.deploys. A call that is not approved goes back to the model as denied.
A machine with no ask: uses the ask of the machine above it. A job of an agent's set, and every machine below it, use the ask: of the set, or of the nearest set it is inside that has one.
A machine made while running has no ask of its own, and one that writes an ask: fails as it starts, saying so. Its held jobs go to the nearest ask: above it that was not made while running. With none, they fail with status denied.
Reference
- Definitions the ask in full, and
ask_about:, which holds a job by its permissions - Statechart a statechart that waits for a person's answer
- Agent an agent's tools