Coordinate agents

Require a person's approval

Hold a change to chosen paths until a person signs a yes for its exact checked candidate.

An approval check makes bay wait for a person before it merges a change to chosen paths. You list the paths in when_paths, such as billing/ or infra/. A change that touches them waits with APPROVAL_PENDING until an enrolled approver signs a yes. A change elsewhere merges without one.

An approval is a signed evidence record, not a comment or a button. It names the exact candidate that bay checked. It holds while the files under when_paths stay the same, so an unrelated merge does not ask again. Only a key in the registry's approver file can sign one that counts. bay is not a code-review tool. The approver decides how to review.

When to use approvals

  • Risky paths: billing, auth or infrastructure code needs a person's yes before it merges.
  • Many agents: agents merge most work alone, and a person signs off where it matters.
  • Named approvers: only the people a check lists may approve its paths.
  • Known failures: a person waives a failing check you mark waivable, named as a gap, never a pass.

Add an approval check

Add a [[check]] with kind = "approval" to .bay/policy.toml on main. Every approval check needs when_paths: use ["**"] to ask for an approval on every change. An approval check runs nothing, so it takes no command, adapter, expected_minimum or other run settings. It is never a post check. producers narrows which approvers may answer it. Every policy still needs a run check with expected_minimum above zero, unless it declares unchecked = true.

toml
[[check]]
id = "billing-approval"
environment = "people"
kind = "approval"                  # a person answers; bay runs nothing
when_paths = ["billing/"]          # the paths that need a yes
producers = ["alice"]              # optional: only these approvers count

Ask no yes for a comment change

An approval check can set logic_only = true. Then a covered path whose change touches only comments asks no yes. bay judges only a changed regular file in Rust, Python or TOML, never an added or removed one. It reads at most 64 such files and 8 MiB. Every other covered path asks a person as before. A comment that a tool reads, such as a doc comment or # noqa, counts as logic.

toml
[[check]]
id = "billing-approval"
environment = "people"
kind = "approval"
when_paths = ["billing/"]
logic_only = true                  # a change to comments only asks no yes

Enrol an approver

Approvals need the key registry. Without one, no approval counts, for merging, promotion or bay status. The first approver runs bay install --approver <name> in the project's clone, on their own machine. It makes their keys if they have none, as files with no passphrase. Then it enrols them and reads the registry back from the remote.

With no registry yet, it starts one only under [policy] signing = "approvals" on main. Under the default signing = "all", it refuses, because that mode also needs runner keys. Keys and the registry explains both modes. For each other approver, ask for the public key only, and run bay enrol approver <name> <key.pub>. An approver name is a short lower-case word, never also an agent, producer or reviewer name. On each other approver's machine, set bay.approverName and bay.approverKey in Git config.

sh
bay install --approver alice                   # the first approver, once; running it again is safe

bay enrol approver bob bob.pub                 # each other approver, where bay.registryKey is set

# on the approver's machine
git config bay.approverName bob
git config bay.approverKey ~/.ssh/bay-approver   # a hardware key, such as ed25519-sk, is best

See what waits for you

bay waiting lists the changes that wait for your approval, as the remote holds them. It lists only the checks that your bay.approverName may approve. Without bay.approverName, it lists every change that waits, with who can approve each. Each item in detail.waiting names the change, its intent and actor, the candidate commit and the paths to approve. diff.summary counts the files added, changed and removed, and the lines added and removed. With nothing waiting, it returns ok with an empty list.

sh
bay waiting

Approve a change

Review the candidate, then run bay approve <change> on your own machine. bay signs one approval record with your approver key for each check you may answer, and pushes it. It approves the exact candidate that bay waiting and bay status name, never a newer one.

bay reject <change> records a signed no instead. --why keeps your reason in the record. bay never approves for another name: the writer is always this machine's bay.approverName. bay status names the same command under operation.approval.approve.

sh
bay approve c7k2m4qa                                     # yes, for the candidate bay waiting names
bay reject c7k2m4qa --why "The refund rule is wrong"     # a signed no

Merge after the approval

Once every approval is in, the runner's next pass merges that same candidate. No one runs bay merge again, and checks that already passed on it do not run again. Without a runner, the author's bay merge --wait merges it. If main moved, bay builds a new candidate, and the approval holds while its files stay the same.

A no blocks the change with CHECK_FAILED, naming you. Its author repairs it and submits again. detail.lands_by names who merges it next: runner, here, author, or author_repairs after a no.

sh
bay merge --wait  # only without a runner

When an approval holds

An approval holds for later candidates of the same change, such as one built after main moved. It holds while every file under the check's when_paths is byte for byte the same. bay compares those files in the new candidate and in its base with what the approver saw. The merge names each approval it carried under detail.carried_approvals, with carried_from, the record that answered. When a covered file changed, bay status and APPROVAL_PENDING name the old approval under set_aside, with the paths. Set carry = false on the check to ask for an approval on every candidate.

toml
[[check]]
id = "billing-approval"
environment = "people"
kind = "approval"
when_paths = ["billing/"]
carry = false                      # ask again on every candidate

Cap the changes that wait for a yes

Set max_waiting_approvals in the [limits] table of .bay/policy.toml on main. While that many live changes wait with APPROVAL_PENDING, bay merge refuses WIP_LIMIT for a change that needs an approval. detail.review names how many wait, the max, the oldest change and its age_s. The cap never holds a change that needs no approval. bay counts the change records this clone holds, and reads the cap from main. bay status shows the same queue under detail.flow.waiting_approval.

toml
# .bay/policy.toml
[limits]
max_waiting_approvals = 5

How bay judges an approval

  • bay reads the approval check from the policy on main, like every check.
  • bay asks for an approval only once every other required check passed.
  • An approval counts under the policy that judges it, also for later candidates with unchanged files.
  • A change to the policy needs an approval under both policies. bay approve writes one for each.
  • Only an approval record answers an approval check, and an approval never answers a run check.
  • A no from any approver, or two approvers who disagree, rejects the change.

Waive a failed check

A waiver lets one failed check through on one candidate, on an enrolled approver's signed word. Mark the check waivable = true in .bay/policy.toml on main. bay reads it at the candidate's base. Under signing = "approvals", a change that repairs the policy may take a waiver for any check bay runs. The Configuration page explains a repair.

Only a check that bay runs before the merge takes a waiver. A post check never blocks a merge. An approval check with waivable = true makes the policy invalid: a person's yes answers it, never a waiver. Waivers need the key registry. Without one, no waiver counts, and bay approve --waive refuses.

toml
[[check]]
id = "tests"
environment = "local"
command = "scripts/bay-check"
adapter = ["scripts/bay-check"]
expected_minimum = 1
waivable = true                    # an enrolled approver may waive it on one candidate

Waive it

A change blocked on a waivable check with CHECK_FAILED, CHECK_FLAKY or CHECK_UNKNOWN shows up in bay waiting. Its item lists each such check under waivable, with its real verdict and waive, the command that waives it. Run that command on your own machine. Give your reason with --why. bay keeps it in the signed record.

bay signs one waiver record with your approver key, about that exact candidate, and pushes it. Then the change's author runs bay merge --wait, and that same candidate merges. No runner picks it up alone. If main moved first, bay builds a new candidate. When a waiver carries explains whether the waiver still counts.

sh
bay waiting                                                       # the waivable check, its verdict and the command
bay approve c7k2m4qa --waive tests --why "Runner out of disk; tracked in OPS-12"
bay merge --wait                                                  # the author, in the change's view

How a waiver counts

  • A waiver is never a pass. Its record's verdict is always unknown.
  • The merge names it in coverage_gaps with the check's real verdict, waived_by, why and record.
  • The result's say says the check did not pass and a person waived it.
  • A waiver covers one candidate. When a waiver carries names the one case it reaches another.
  • Only an enrolled approver's signed waiver counts, under either signing mode.
  • Promotion never counts a waiver. Promote main to other branches explains it.

When a waiver carries

A waiver carries to a rebuild of its change on a newer main, when the patch is the same. The policy's manifest must be the same, and the check must fail there the same way. The change must be checked on its own, so a waiver never carries to a batch. The checks the waived failure stopped run on the rebuild before it merges. When one of those fails, bay waiting asks the approver about that check only. The merge names the waiver in coverage_gaps, with carried_from, the candidate the approver waived.

What an approval cannot do

  • An unsigned yes never counts.
  • Without a key registry, no approval check can pass.
  • A key of any other class never signs an approval that counts.
  • On a host from bay host with a registry, the hook refuses such a record.
  • An approver key signs approval and waiver records only, never a check record or a review.
  • A quarantine sets an approval check aside, like any check.
  • bay never reviews the code.
  • It records who said yes to which tree.
  • It cannot tell the approver from an agent that reads the approver's key file and signs with it.
  • Keep the approver key on a hardware key, or under an account that runs no agents.
  • bay doctor's key-custody row turns red with KEY_EXPOSED when this account can read the key and runs agents.

Refusals

Each refusal is blocked and exits 10. The Results page lists what to do next for each one.

CodeMeaning
APPROVAL_PENDINGEvery other check passed, and an approval is still owed. detail.approval names the approvers, the candidate commit and tree, and approve, the command an approver runs. A check's set_aside names an earlier approval whose files changed, and those paths. Without a registry, its why says that no approval can count.
CHECK_FAILEDAn approver rejected the candidate. detail.checks names each approver who said no.
WIP_LIMITFrom bay merge: [limits] max_waiting_approvals changes already wait for a yes. detail.review names the oldest.

Limits

  • Record size: one record is at most 64 KiB of JSON.
  • Scope: one approval covers one change under one policy, while its files stay the same.