Skip to content

Improve castlog report fidelity - #2560

Merged
lexicalunit merged 1 commit into
mainfrom
castlog-report-fidelity
Aug 30, 2026
Merged

Improve castlog report fidelity#2560
lexicalunit merged 1 commit into
mainfrom
castlog-report-fidelity

Conversation

@lexicalunit

Copy link
Copy Markdown
Owner

Context

Castlog reported seeing games where every player xid is null and no winner is set. The root cause of the null xids is on the Convoke side (see the companion PR in commander-online), but investigating turned up three real problems on this side of the wire.

Changes

Forward the SpellBot game id to castlog. report_match sends the request body through verbatim, and the game id only ever arrives in the URL path. So castlog had no way to tell a re-report of a match it already has from a brand new match — a single game legitimately produces several reports (the automatic match-end one, a later winner finalization, the post-game modal). The id is injected into the outbound body rather than trusted from the reporter's payload, since we know it authoritatively.

Don't forward a report that lost the stale-write guard. set_metadata returned True whenever the game existed, whether or not the write applied — conflating "stored" with "accepted and ignored as stale". The endpoint then called castlog unconditionally, so a delayed or out-of-order report we had just rejected locally still got pushed to castlog. It now returns which of the three outcomes happened (APPLIED / STALE / MISSING) and the forward is skipped on STALE.

Accumulate links across reports instead of replacing them. Each writer only knows about its own trackers — Convoke reports mythic_track, SpellBot writes back castlog — so a later report that simply omits a link would drop it from the game detail page. The merge happens inside the existing conditional UPDATE so the compare-and-set stays atomic. Everything outside links is still last-write-wins.

Testing

uv run pytest -n3 — 1708 passed. Three new cases cover the stale-report forward being skipped, the game id reaching castlog, and links accumulating across reports.

🤖 Generated with Claude Code

Three fixes to the post-game report path that feeds castlog.gg:

- Forward the SpellBot game id to castlog. The game id only ever arrives in the
  URL, so castlog had no way to tell a re-report of a match it already had from a
  brand new match. It is added to the outbound body rather than trusted from the
  reporter's payload.
- Don't forward a report that lost the stale-write guard. `set_metadata` now
  returns which of the three outcomes happened instead of a bool that conflated
  "stored" with "ignored as stale", so a delayed report we rejected locally no
  longer regresses castlog.
- Accumulate `links` across reports instead of replacing them. Each writer only
  knows about its own trackers -- Convoke reports `mythic_track`, SpellBot writes
  back `castlog` -- so a later report that simply omits a link must not drop it
  from the game detail page. The merge happens inside the existing conditional
  UPDATE so the compare-and-set stays atomic.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4239f37) to head (cc6c460).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2560   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          290       290           
  Lines        23508     23558   +50     
  Branches       955       957    +2     
=========================================
+ Hits         23508     23558   +50     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lexicalunit
lexicalunit merged commit 10c9406 into main Aug 30, 2026
15 checks passed
@lexicalunit
lexicalunit deleted the castlog-report-fidelity branch August 30, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant