Public: anyone can read this; the crew can change it.

Feature flags, part 3: each request's variant is counted, and Settings → Flags shows the A/B read-out for 7 and 30 days with one button to make the winner the default #2142

Parked opened this
Closed without merging

Settings → Flags now shows each flag's reads per variant for the last 7 and 30 days, with a button to make the winner the default. The flag and migration tests and tsc pass; I didn't run the full bun test, since the forge's check does that on push. What changed Counter: the issue says to batch "like usage today".

Notes

stopped parked by the crew deploy 47e06e3

opened this

Settings → Flags now shows each flag's reads per variant for the last 7 and 30 days, with a button to make the winner the default. The flag and migration tests and tsc pass; I didn't run the full bun test, since the forge's check does that on push.

What changed

  • Counter: the issue says to batch "like usage today". src/core/usage.ts is the agent-run ledger, though, and usage_count (#2077) has no writer. So I added a small table, flag_use, keyed by UTC day, flag and variant (on or off). Each flag() read bumps an in-memory counter, so a request runs no query. The counts are written in one transaction every 10 seconds and at shutdown (src/main.ts). A failed write keeps the counts for the next try.
  • Read-out: each flag row shows "Uses, 7 days" and "30 days" as on N · off M. They are summed from flag_use after a flush.
  • Make the winner the default: when one variant leads over 30 days, the row gets a "Make on/off the default" button.
    • It opens an issue on forgeRepo asking the crew to remove the losing path and the flag.
    • The flag is then set to {forge: winner} for everyone, so the user, role and percentage rules are cleared.
    • The issue is opened first, so a refusal leaves the flag as it was.
    • The code is in src/actions/flag_winner.ts and src/web/pages/flags.ts.
  • Tests (test/flags-settings.test.ts):
    • The read-out counts match the flag_use table for a fixture, covering both windows.
    • A read runs no query, and a failed flush keeps its counts.
    • The winner button opens the issue and the flag reads the winner.
    • An unknown flag opens no issue.
  • README: a paragraph on the counting and the button.

Left out

  • The counts are reads, not distinct people.
  • The button appears only when the 30-day counts differ, and it picks the leader by raw count with no significance test.
  • There is no terminal screen for the read-out.

Try it: as an admin, open /settings/flags and look under each declared flag. No flag is declared yet, so the page shows nothing until the first one arrives.

Closes #1829

commented

Parked by the crew: the check failed ("an outside agent finds the report path unaided > a stranger's MCP body is read to a hard limit, declared or chunked; a signed-in one is not") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs