Skip to content

feat: manual country target for runs and sessions - #3

Merged
Timo972 merged 3 commits into
mainfrom
feat/manual-country-target
Aug 24, 2026
Merged

feat: manual country target for runs and sessions#3
Timo972 merged 3 commits into
mainfrom
feat/manual-country-target

Conversation

@Timo972

@Timo972 Timo972 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Sessions and variation runs can now declare a manual target country (ISO 3166-1 alpha-2) when the proxy config itself does not encode one — a dedicated gateway host or provider-side geo pinning otherwise leaves both the username parser and the run honor rate blind to the intended country.

  • Storage: new sampling_sessions.target_country column (goose migration, empty = unset). Runs propagate the value to every child session at creation; there is no separate run column.
  • Semantics: when set, the manual target overrides a country axis param or a username-encoded country. Set at creation only.
  • Honor rate: variantHonor falls back to the variant's target country, so runs without a {country} axis get a real honor rate and per-cell honor instead of "unknown". CellReport carries the effective target_country, and the run page labels such cells country=de · target US (manual) so a cell is never displayed as honored under a country its honor was not measured against.
  • API: optional target_country (^([A-Za-z]{2})?$, normalized to uppercase) on CreateSessionRequest / CreateRunRequest; echoed on Session, VariantSummary, and RunReport.cells[].
  • UI: optional "Target country" input in both creation dialogs; run header shows Target country US (manual); the session Targeting panel compares the manual target against observed egress and, on a conflict with a username country, shows DE (manual, overrides US).
  • Also hardens dominantCountry to bucket observed codes case-insensitively.

web/dist is regenerated and committed (embedded SPA).

Testing

  • TDD throughout: variation honor unit tests, Postgres integration roundtrip (migration + store + run children), API handler tests (validation, propagation, response shapes), vitest for the comparison module, targeting panel, both dialogs, and the run page.
  • make test, make test-race (with TEST_DATABASE_URL), make vet, make generate-check all pass.

🤖 Generated with Claude Code

Timo972 and others added 3 commits August 23, 2026 10:03
Sessions and variation runs can now declare a target country (ISO
3166-1 alpha-2) when the proxy config itself does not encode one — a
dedicated gateway host or provider-side geo pinning leaves both the
username parser and the run honor rate blind to the intended country.

The value is stored per session (runs propagate it to every child at
creation) and overrides a country axis param or username country token
when set. Run reports compute honor rate from it for runs without a
country axis, and the session Targeting panel compares it (marked
"manual") against the observed egress countries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Show the manual target country on the run page header so the honor
  rate is never measured against an invisible target.
- When a manual target contradicts a username-encoded country, the
  Targeting panel's requested column now names the overridden value
  ("DE (manual, overrides US)") instead of hiding it.
- Bucket observed country codes case-insensitively in dominantCountry
  so a mixed-case reputation code cannot split the vote.
- Widen the target_country spec pattern to ^([A-Za-z]{2})?$ — the
  server already treats an empty string as unset.
- Replace the hand-rolled byte-range check with a package-level regexp
  matching the spec, and collapse the optional-string response mapping
  into an optionalString helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-lands the run-page header line (Target country XX (manual)) that a
concurrent editor buffer reverted out of the previous commit, and
aligns per-cell presentation with the override semantics: CellReport
now carries the effective target_country, and the run page's cell
label appends 'target US (manual)' when the honor rate was measured
against a manual target rather than the cell's own country param.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Timo972
Timo972 merged commit c7b2c75 into main Aug 24, 2026
8 checks passed
@Timo972
Timo972 deleted the feat/manual-country-target branch August 24, 2026 08:04
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