Checks
Checks review a step's output and send the step back to its member with their findings, so the quest goes on to the next step only once every check approves.
Send a step back until its checks approve
When a step's turn ends, its checks start in parallel, each member's check in a session of its own. A check has name, member, and an optional prompt, as a step has, or name and run for a script. Without prompt, a check is sent the output of the step it checks. A member's check answers whether it approves and lists findings, each with a priority from P0 to P3:
When every check approves, the next step starts. The findings of a check that approves are shown and not sent back.
When a check asks for changes, the step's session is resumed with the answer of each check that asked:
textThese checks asked for changes. Fix each finding, or say why you will not fix it, then report what you changed. ## security {"approved":false,"findings":[{"message":"src/list.rs:42 prints the table even with --json","priority":1}],"notes":""}When the step's turn ends again, the checks that asked for changes run again, each in its own session. A check that approved runs again only with
rerun = "always"(run checks in order).After
max-retriessend-backs, 3 by default, a check that still asks for changes fails the quest. Withmax-retries = 0, the first request fails it:text[implement / security] changes requested P1 src/list.rs:42 prints the table even with --json error: the checks of step implement did not approve: security security asked for: P1 src/list.rs:42 prints the table even with --json The work stays in /home/me/app, and `pandra quest resume 78536b9b10f0` carries the quest on from where it stopped; `pandra guild ps -a` lists its sessions as change 78536b9b10f0.
A check's member must run on a harness that can enforce a schema, which Pi cannot; otherwise the quest fails before it starts. Checks run in parallel in the same directory, so they are meant to read: set the permission-mode of a check's agent to read-only to stop its writes, apart from the exceptions each harness keeps.
Give a check a schema of its own
A member's check can answer in a JSON Schema of its own, given with output-schema, to return more, such as the rule a finding breaks or how to fix it:
[[steps.checks]]
name = "review"
member = "reviewer"
output-schema = "schemas/review.json"{
"type": "object",
"additionalProperties": false,
"required": ["approved", "findings"],
"properties": {
"approved": {"type": "boolean"},
"findings": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["priority", "message", "rule", "fix"],
"properties": {
"priority": {"type": "integer", "enum": [0, 1, 2, 3]},
"message": {"type": "string"},
"rule": {"type": "string", "description": "the rule the work breaks"},
"fix": {"type": "string", "description": "how to fix it"}
}
}
}
}
}Pandra reads approved and each finding's priority and message, so the schema must keep them as above, written out rather than through $ref or allOf. A schema without them fails the quest before anything starts and names each missing keyword. The step that is sent back reads the check's whole answer, every field included.
To read the answers after the quest, pandra quest inspect --json --history lists in history every turn of each step and check, with a check's structured answer in answer.data. The findings of a check that approved are there too, although no step was sent back for them. This command prints how to fix each finding of the review check, one line for each of its turns that answered:
pandra quest inspect --json --history d95c83b21810 | jq -c '.history[] | select(.step == "review" and .answer != null) | .answer.data.findings | map(.fix)'["Reject a negative --limit with an error instead of listing nothing"]
[]Run checks in order
A check can wait for other checks of its step with needs, and run after every send-back with rerun = "always". Here the reviewers read only code whose tests pass, and the tests run again after every fix:
[[steps.checks]]
name = "tests"
run = "cargo test"
rerun = "always"
[[steps.checks]]
name = "code"
member = "reviewer"
needs = ["tests"]
[[steps.checks]]
name = "security"
member = "security-reviewer"
needs = ["tests"]tests starts alone, and code and security start together once it approves. When security asks for changes and code approves, the step is sent back; after the fix, tests runs, then security, and code does not run again. A check whose needed check asks for changes does not start, and when the quest fails, its error names that check as one that never started.