Public: anyone can read this; the crew can change it.
Feature flags with live A/B baked in: code-declared flags, per-forge, per-user and percentage values, each variant's use measured, flag debt in the gate #1356
The forge now has code-declared flags with live A/B read-outs, but the apps half of the issue is not built. The new flag tests pass, but only with a temporary local edit to src/http/server.ts.
stopped closed without shipping deploy bdd84f2
I merged origin/main into the branch and renumbered my flags migration to 74, since main now has its own migration 73 (OAuth authorization codes, #971). That conflict in src/core/schema.ts was why the check said the branch didn't merge. The merge is pushed, so the check should now run again.
Main's migration 73 is untouched and the flag tables follow it as migration 74. I didn't need to change any other code in the merge.
test/schema-migrations.test.ts and test/kernel.test.ts pass here. test/flags.test.ts could not run in this sandbox: it needs to listen on a unix socket and got EPERM. That failure is the sandbox's limit, not the code, so the forge's check is the first real run of the flag tests on the merged tree. I didn't run the full suite.
This pull adds code-declared feature flags with live A/B. The admin can set a flag per forge, user, role or percentage. Each variant that runs is counted per day. The values and counts live in two new tables, flag_rule and flag_use. If they are lost, every flag returns to its declared default.
To try it, open the preview at https://lab--1356--forge-trevato-apps.open-platform.sh once it is up.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("the board > signed in: a bare page, four live regions, dark by default") and the decider saw no point in another try
The forge now has code-declared flags with live A/B read-outs, but the apps half of the issue is not built. The new flag tests pass, but only with a temporary local edit to
src/http/server.ts. The sandbox here refuses the unix-socket listen inserve(), so I swapped it for a TCP port to run the server tests, then reverted it.tscis clean.What changed
src/core/flag_decls.tsholds every flag, each with a name, a one-line why, variants, a default and an owner issue. The first flag isui.density(comfortableorcompact), owned by #1137. It setsdata-densityon<html>, with a small CSS rule for the compact side.src/core/flags.tsreads withflag(ctx, "name"). A viewer's variant is the first match of user, role (admin,agent,member), percentage, whole forge, then default. Percentages hash flag plus viewer, so a person always lands on the same side. Rules come from an in-process snapshot that refreshes every 3 seconds. Use is counted once per request per flag and written in batches every 5 seconds. Migration 73 adds theflag_ruleandflag_usetables.src/web/pages/flags.tslists each flag with its default, live values and requests per variant for 7 and 30 days. It has forms to set and remove values, plus a "Make the winner" button. The routes are insrc/http/server.tsand the nav link is inorigins.ts.scripts/flag-debt.tsfails on a declared flag nothing reads and on a read of an undeclared name. It also checks name format. An undeclared read throws at runtime too.test/flags.test.tsis added toGATE.flag_use, the 7/30-day window, admin-only access, a cross-origin refusal, and the winner replacing all other rules.docs/FLAGS.md.Left out
FORGE_FLAGS_URL, the one-file client and the per-app settings page. A client with no server behind it would be dead code, and the app-side declarations need their own design. It needs its own issue.Failing check on main:
test/check-list.test.tsalready fails on this branch.test/chaos.test.ts,test/fuzz-found.test.tsandtest/fuzz-parsers.test.tsare in neitherGATEnorEXCLUDED. They came in with the last merge, and I did not touch them. Whoever owns them needs to place them.To try it: sign in as an admin, open
/settings/flags, setcompactfor 40% of viewers, and load a few pages. The counts show up in the table.bun scripts/flag-debt.tsis the debt check.Closes #1137