fix(bounty): refuse a stable torn leaderboard/reports pair - #206
Conversation
Consecutive equal pair-reads only prove each route was still. A feed that always serves leaderboard A beside reports B would pass that check. Require valid_count to match the valid reports before signing. Co-authored-by: Mathis <echobt@users.noreply.github.com>
A stable torn pair with matching valid_count still signs if the halves only agree on counts. When both routes carry revision/snapshot_id/etag (JSON or HTTP ETag), those tokens must be equal. Co-authored-by: Mathis <echobt@users.noreply.github.com>
Greptile SummaryThis change adds fail-closed reconciliation between bounty leaderboard and report snapshots before publishing an epoch. A coherent pair of responses can still be rejected when neither payload provides a shared publication token and the routes return different HTTP ETags: the emitter burns the epoch instead of signing and scoring the valid snapshot. This should be corrected before merge. Confidence Score: 4/5Not safe to merge until cross-route publication-token comparison stops treating independent HTTP ETags as a shared revision identifier. A focused end-to-end reproduction exercised coherent route payloads with distinct stable ETags and directly observed snapshot rejection followed by an epoch burn. Files Needing Attention: crates/bounty-challenge/src/backend.rs needs attention; crates/bounty-challenge/src/emit.rs propagates the resulting rejection into the burned-epoch outcome.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(bounty): mismatch envelope revision ..." | Re-trigger Greptile |
| (Some(a), Some(b)) => a == b, | ||
| _ => true, | ||
| } | ||
| } | ||
|
|
||
| /// JSON envelope `revision` / `snapshot_id`, else HTTP ETag. | ||
| fn publication_token(body: &str, etag: Option<String>) -> Option<String> { |
There was a problem hiding this comment.
Route-specific ETags reject coherent snapshots
publication_token falls back to each response's HTTP ETag, and publication_tokens_agree then requires the leaderboard and reports tokens to match exactly. ETags are opaque validators for an individual response representation, so coherent routes can legitimately use distinct stable ETags when neither JSON envelope provides a shared revision token. The snapshot is consequently treated as mismatched and the emitter burns the epoch instead of signing and scoring it. Compare only an explicitly shared publication revision across routes, or retain ETag provenance and avoid comparing ETags from different resources.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Artifacts
Focused loopback Axum validation source
- The exact temporary test source starts a loopback Axum backend with matching leaderboard/report data, no JSON publication tokens, and distinct ETag headers; it captures the reproducer setup and its takeaway.
Focused validation command output
- The executed focused cargo test exited 0 after proving the coherent ETag-divergent feed was rejected and the emitter burned the epoch; the takeaway is that the hypothesis reproduces end to end.
Complete bounty emitter integration-suite output
- The executed full emit_fail_closed integration suite exited 0 with 10 passing tests, including the focused reproducer; the takeaway is that the reproduction is compatible with the surrounding integration behavior.
- The captured diff shows the loopback ETag reproducer added only to the integration test file and no product-code edits; the takeaway is that production behavior was observed without changing product code.
Focused validation source capture
- The captured source log contains the exact focused loopback Axum reproducer used for validation; the takeaway is that the executed test setup is fully inspectable.
Focused loopback Axum validation source
- The exact temporary test source starts a loopback Axum backend with matching leaderboard/report data, no JSON publication tokens, and distinct ETag headers; it captures the reproducer setup and its takeaway.
Focused validation command output
- The executed focused cargo test exited 0 after proving the coherent ETag-divergent feed was rejected and the emitter burned the epoch; the takeaway is that the hypothesis reproduces end to end.
Summary
Follow-up to #204. Greptile P1: two consecutive equal pair-reads only prove each route was still. A backend that always serves leaderboard revision A beside reports revision B produces the same mixed composite twice and would have been signed.
Two Cortex-side pins, neither requiring a new backend endpoint:
/leaderboardvalid_countmust match thevalidrows on/reports(snapshot_halves_agree).revision/snapshot_id/etagin the JSON envelope, or HTTPETag), those tokens must be equal.A stable torn pair is
BackendError::Mismatchedand the emitter burns (coversEwithChallengeInternal). A moving feed that never holds still is stillInconsistent.relearn-evalstays unpinned;sha256:cbc4bbb8is not re-pinned.Greptile
@greptileai reviewFixes the P1 on #204 (
crates/bounty-challenge/src/backend.rs). T-Rex's stable torn harness (leaderboard Avalid_count=1, reports B) is themismatched_publication_tokenscase when the envelope carriesrevision.Test plan
cargo test -p bounty-challenge --test emit_fail_closedcargo clippy -p bounty-challenge --all-targets -- -D warningsfmt · clippy · test · deny · xtaskNaming
I did not rename
BASE_*environment variables, deployed host paths (/opt/base,/run/base, …), GHCRbaseintelligence/basepackage names, orbase-*-v1cryptographic domain tags.