Skip to content

Best-of groups

A best-of group ties several execution tasks together under one group_id so they can be created and evaluated as a set. The only behavior the code actually implements is a cross-ring admission check on task creation. There is no per-strategy logic and no winner promotion — read the caveats below before you build on it.

Tasks carry an optional best_of_group describing their membership (src/db/adapter.ts:268-276):

interface BestOfGroup {
group_id: string;
index: number;
total: number;
kind?: "best_of" | "variants" | "shadow" | "race";
label?: string;
acceptance_hash: string;
group_spec_ref?: { kind: ResourceKind | string; id: string };
}

evaluateBestOfCreatePolicy runs on every tasks.create (src/best-of/policy.ts:94). A task with no group_id fast-returns { allowed: true }. For a group, it lists all members, collects their rings, and decides:

Condition Result
All members share one ring Allowed — single-ring groups skip the rest
Members span >1 ring, no group_spec_ref BEST_OF_GROUP_SPEC_REQUIRED
Caller lacks access to any member ring BEST_OF_GROUP_RING_ACCESS_DENIED
group_spec_ref not visible to caller BEST_OF_GROUP_SPEC_NOT_VISIBLE
Otherwise Allowed

The spec-ref visibility check resolves signal, workspace_item, workspace_revision, and artifact refs against the caller’s ring scope (policy.ts:40-72). Every decision — accept or reject — writes an audit event (auditDecision, policy.ts:74-92).