Model knockout
Answers from several models in a knockout bracket judged by another model: open any match to compare both answers, their scores and why one won; once the final is settled the champion's route turns blue.
oxyn add model-knockoutJudge
Fix: a retried payment charges the customer twiceJudgingQuarterfinal · 1/7Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))Drops repeated provider webhooks by event id before they reach the ledger.
if seen(event.id) { return Ok(()) }rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Pick the best of many answers by pairwise judging: a judge model compares two answers at a time in a single-elimination bracket, and the champion's route through the rounds is the result.
When not to use
- An agent asks before it acts: use Approval Card instead.
- Several open requests in one card: use Approval pager instead.
- An agent's question in its own card above the composer: use Decision Card instead.
Installation
Model knockout is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add model-knockoutuse crate::oxyn::{ModelKnockout, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ModelKnockout, STATUS_INDICATOR_CSS};
Usage
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Examples
Live
Plays and loops: each match shimmers while the judge compares, the preferred answer moves on, the other fades but stays; at the end the winner's way lights up and a cup appears.
Judge
Fix: a retried payment charges the customer twiceJudgingQuarterfinal · 1/7Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))Drops repeated provider webhooks by event id before they reach the ledger.
if seen(event.id) { return Ok(()) }Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Judging
Quarterfinals decided, a semifinal being judged: its names shimmer and the panel says the judge is comparing.
Judge
Fix: a retried payment charges the customer twiceJudgingSemifinal · 5/7Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))Locks the order row while charging so a second attempt waits and then sees it paid.
SELECT … FROM orders WHERE id = $1 FOR UPDATECode
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Match open
A decided quarterfinal opened: both answers with their meta line, code and score, the Winner tag and the judge's reason.
Judge
Fix: a retried payment charges the customer twiceJudgingSemifinal · 6/7Locks the order row while charging so a second attempt waits and then sees it paid.
SELECT … FROM orders WHERE id = $1 FOR UPDATEStops the client after one retry; fewer doubles, but timeouts now fail the order.
retries: 1Judge's reasonBoth stop the double, but the cap turns slow networks into failed orders.
Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Not judged
A semifinal whose contenders aren't known yet: dashed empty slots, Not judged yet.
Judge
Fix: a retried payment charges the customer twiceJudgingQuarterfinal · 3/7Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Decided
The final decided: the winner's way in blue round after round, a cup in the final, and a Use button.
Judge
Fix: a retried payment charges the customer twiceIdempotency key winsDecided · 7/7Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))The checkout page mints a token once and the server refuses a reused one.
require_fresh(token)?Judge's reasonSmallest change that closes every path to a second charge, with full tests.
Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Four
Four contenders: semifinals and a final.
Judge
Fix: a retried payment charges the customer twiceIdempotency key winsDecided · 3/3Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))The checkout page mints a token once and the server refuses a reused one.
require_fresh(token)?Judge's reasonSmallest change that closes every path to a second charge, with full tests.
Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Narrow
When the rounds don't fit, each round becomes a list with one match a row and the answers stack.
Judge
Fix: a retried payment charges the customer twiceIdempotency key winsDecided · 7/7Every charge carries a key derived from the order; a retry with the same key returns the first result.
charge(order, key: hash(order.id, attempt_group))The checkout page mints a token once and the server refuses a reused one.
require_fresh(token)?Judge's reasonSmallest change that closes every path to a second charge, with full tests.
Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}Classic
Classic style: header band, framed answers panel, squarer slots.
Judge
Fix: a retried payment charges the customer twiceJudgingSemifinal · 6/7Locks the order row while charging so a second attempt waits and then sees it paid.
SELECT … FROM orders WHERE id = $1 FOR UPDATEStops the client after one retry; fewer doubles, but timeouts now fail the order.
retries: 1Judge's reasonBoth stop the double, but the cap turns slow networks into failed orders.
Code
rsx! {
ModelKnockout {
contenders: Some(answers.seeded()),
verdicts: Some(judge.verdicts()),
judge: "Opus 4.1",
now: clock.now(),
on_pick: move |id| apply(id),
}
}API reference
ModelKnockout
| Prop | Type | Default | Description |
|---|---|---|---|
contenders | Option<Vec<JbContender>> | Default::default() | Contenders in seed order (the demo's when `None`). |
verdicts | Option<Vec<JbVerdict>> | Default::default() | Verdicts so far (the demo's when `None`). |
live | bool | Default::default() | Demo: reveal the verdicts one by one and loop. |
judge | String | "Opus 4.1" | The judge model. |
task | String | "Fix: a retried payment charges the customer twice" | The task. |
open | Option<(usize, usize)> | Default::default() | The match whose answers are open from the start (round, match); the one being judged (or the final) when `None`. |
title | String | "Judge" | Heading. |
nowrequired | ClockMs | — | The clock. |
style | String | Default::default() | `clean`, `classic`, or empty to follow `data-cstyle`. |
on_pick | Option<EventHandler<String>> | Default::default() | Show a Use button on the decided final; called with the champion's id. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Match by match, then the answers and Use |
| →or← | Forward to the next-round match, or back to the first feeder |
| ↑or↓ | Previous and next match in the round |
| EnterorSpace | Opens or closes a match's answers |
| Escape | Back to the match being judged |
Accessibility
- Each match is a button named with both contenders and the result (or that it is being judged).
- The winner keeps full colour and its score; the loser fades and its outline turns dashed – never colour alone.
- Progress (round · decided/total) is a status region; reduced motion makes everything simply appear.
Responsive behaviour
- Rounds share the width with fixed slot heights; the elbows join each pair into the next round.
- Under 560 px each round is a list with one match a row and the two answers stack.
Edge cases (spec)
Rounds share the width with fixed slot heights. Under 560 px each round becomes its own list, a match per row, and the two answers stack.
Notes for AI
- Import
ModelKnockoutfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
ModelKnockoutElinoxyn_gpui. - Props to set first:
now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.