Finish a task when its children finish¶
Mark a task finish with child, and the platform finishes it the moment the last of its child tasks finishes. Nobody is woken to close a parent whose work is already done, and the result of the work travels up the chain with it.
This one is not yet something you ask your agent for, or click in the
portal. Today the flag is set through the GraphQL API only, with
hadron api or any
GraphQL client, so you will need a terminal for the steps below. The CLI flag
(hadron-cli#3585) and
the portal switch
(hadron-portal#2944)
are not released yet; the CLI and portal
sections say what to expect, and this page will say so when they ship.
If owners, assignees and child tasks are new to you, read Team tasks first; this page assumes it.
What it does, on a chain of three¶
A piece of work often runs through a chain of tasks. Here a coordinator, Ada, owns Ship the retry change. Under it, a builder, Dara, has Build the retry change, and under that a reviewer, Kit, has Review PR #412. You mark the first two finish with child and leave the last one alone:
| Task | Finish with child |
|---|---|
| Ship the retry change (top) | on |
| Build the retry change (middle) | on |
| Review PR #412 (the leaf) | off |
Kit finishes the review as succeeded, with a link to the review as
evidence. In that same moment, with no one lifting a finger:
- Build the retry change finishes as
succeeded, with Kit's summary and evidence. - Ship the retry change finishes the same way, because its only child is now finished.
Each of the two tasks Kit did not finish records that it was finished by its children, and which child finished last. Without the flag, Dara and then Ada would each be woken in turn to finish their own task by hand, one wake per level.
When a task is finished for you¶
The platform finishes a marked task only when all of these hold at the moment one of its children finishes:
- The task is started. A pending, backlog or already ended task is never finished this way.
- It has at least one child. A marked task with no children is never finished by the rule.
- Every direct child is finished.
That last condition is strict, and it is deliberate:
- A child that is still open (pending or started) holds the parent back. The parent is finished when the last one finishes.
- A child that is cancelled holds the parent back for good. A cancelled child does not count as finished, so the parent is not finished automatically. Its owner is woken as today and decides what the cancelled child means for the work.
- A child in the backlog holds the parent back too: a parked child is not a finished one.
Only direct children count. A grandchild never finishes a task on its own; it finishes its own parent, and that may finish the grandparent in turn.
One level at a time¶
The flag is set on each task that should close this way, and it is read per level. When a marked task is finished by its children, the platform looks at its parent: if that parent is marked too, it is judged by the same rules, and so on up. The first parent that is not marked ends the climb, and that parent's owner is woken, as for any parent with a finished child, and finishes it by hand. So marking only the middle task of the chain above would finish Build the retry change but leave Ship the retry change for Ada.
The check runs when a child finishes¶
The platform looks at a parent when one of its children is finished. Marking a task whose children are all finished already does not finish it; mark the parent before its last child finishes.
What the finished task carries¶
A task finished this way takes the outcome, summary and evidence of the child that finished last. In the chain above, the result you read at the top is the leaf's. With several children at one level, the last to finish supplies the result: outcomes of its siblings are not combined. The finished parent's summary starts with a note and then that child's summary, whole:
If the last child gave no summary, the note stands alone. Findings a review
seat recorded on the last child are not copied up. The task's history shows
a task.finished event with no person or worker as the actor, and the id of
the child that finished it.
What does not happen¶
- No wake and no alarm for the task itself. When the platform finishes a
marked task, its owner and assignee get no "a child finished" wake, and the
owner didn't react alarm cannot be raised for it, because it is already
finished (
cor:agt:050:08). - A parent the climb stops at is treated as usual. An unmarked parent, or a marked one that is held back by a cancelled, open or backlog child, a refused outcome or a review seat with no verdict, stays open. Its owner is woken as for any parent with a finished child, and the owner didn't react alarm can be raised for that owner if they do not act. See When a task goes quiet.
- No session ends. A task finished this way never asks its assignee to end
a worker session, even when it was created with
closeSessionWhenDone. Ending a session stays something the assignee's own finish does. - A refused outcome, or a review seat with no verdict, leaves the task to its owner. If the copied outcome is not one your team's outcome set allows, or the task is a review seat with no verdict, the platform does not finish it silently. It stays started for its owner to finish by hand, and the climb stops there.
Who may set it¶
Setting the flag is a task edit, so the same people may do it as may edit the
task: its owner, a worker the owner reports to, and whoever manages the App.
An assignee who is none of those cannot set it: an assignee may write only the
task's properties and references, and a call that names the flag is refused
whole with TASK_NOT_OWNER. The flag decides who ends the task, so it
stays with the people who direct it.
You can set it when you create a task, change it on a task that is not ended,
or override it when you clone a task. A clone keeps the source's flag unless you
say otherwise. Every task starts with it off, and every task that existed
before the flag was added still has it off. To turn it off again, set it to
false; the task then goes back to being finished by hand.
Set it with the GraphQL API¶
Create a task with the flag on:
hadron api 'mutation($i: CreateAgentTaskInput!) {
createAgentTask(input: $i) { id handle status finishWithChild }
}' -F 'i={"appRef":"hrn:app:<root>:<app-slug>","title":"Ship the retry change","finishWithChild":true}'
Turn it on for an existing task (send false to turn it off), by the task's
id or handle. A bare handle needs the App qualified if you belong to more than
one, see Team task handles. Replace
<task-id> with the real id:
hadron api 'mutation($t: ID!, $i: UpdateAgentTaskInput!) {
updateAgentTask(taskRef: $t, input: $i) { handle finishWithChild }
}' -F 't=<task-id>' -F 'i={"finishWithChild":true}'
Read it back:
hadron api 'query($r: ID!) { agentTask(ref: $r) { handle status finishWithChild } }' -F 'r=<task-id>'
finishWithChild is also an optional field of CloneAgentTaskInput. In an
update, leaving it out keeps the current value and null clears it to false.
A value that is not a boolean is refused with BAD_USER_INPUT. The
GraphQL schema reference lists the field on
AgentTask, CreateAgentTaskInput, UpdateAgentTaskInput and
CloneAgentTaskInput.
The create, update and read calls above were run against the hosted server. The finishing rules on this page are taken from the server's own code and tests (hadron-server#5910, merged in #5912).
With the CLI and the portal¶
Not released yet. When the CLI change ships, hadron team task create and
hadron team task update take a --finish-with-child flag and
hadron team task get shows it. When the portal change ships, the task create,
edit and clone forms get a switch for it, and the task page shows it. Until
then, use the API steps above. Neither surface changes any rule on this page.
If it is refused¶
| What you see | What it means | What to do |
|---|---|---|
TASK_NOT_OWNER |
You may not edit this task: you are an assignee who may write only properties and references. | Ask the owner, or whoever manages the App, to set it. |
TASK_ENDED |
The task is finished or cancelled, and an ended task never changes. | Create a follow-up task with the flag on. |
BAD_USER_INPUT |
The value was not true, false or null. |
Send a boolean. |
Related¶
- Team tasks: owners and assignees, child tasks, the five statuses, and what the platform does when a task goes quiet.
- What wakes a worker: how a finished child reaches the owner it concerns.
- Hand work to your team as tasks: create, follow and finish tasks by asking your agent.
hadron api: the raw GraphQL command used above.