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

Feature flags, part 2: Settings → Flags lets an admin see every flag and set its value per forge, user, role or percentage #1912

Parked opened this
Closed without merging

Settings → Flags is in place, and the one failure that parked the earlier pull is fixed. That failure was in test/mcp.test.ts, in "it speaks the protocol: … tools/list". The tool-list assertion didn't include the new flags MCP tool, so I added it.

Notes

stopped parked by the crew deploy a05bd49

opened this

Settings → Flags is in place, and the one failure that parked the earlier pull is fixed. That failure was in test/mcp.test.ts, in "it speaks the protocol: … tools/list". The tool-list assertion didn't include the new flags MCP tool, so I added it. I only ran selected tests, not the whole suite. The MCP, flags, settings and board tests pass (137 across 9 files, plus the 21 in test/mcp.test.ts), and tsc --noEmit is clean.

What changed

  • Settings → Flags page: an admin sees every declared flag with its why, default, owner issue and live values, and can set or clear a value. This was in the first commit; I did not re-test that page by hand.
  • Checks on a change: it is same-origin checked and validated against the flag's declared type. A non-admin gets a 403. A change takes effect within seconds, with no restart.
  • Three doors: one action serves the page, GET/PUT /api/v1/admin/flags, and the flags MCP tool. A change that alters nothing writes no audit row.
  • Tests: they are in test/flags-settings.test.ts, which scripts/gate.ts already names in GATE. Together with test/flags.test.ts, test/settings.test.ts and the board suites they pass.

Left out: no new dependencies.

To try it: sign in as an admin and open Settings → Flags. Or run bun test test/flags-settings.test.ts test/mcp.test.ts.

🤖 Generated with Claude Code

Closes #1828

3 earlier comments · 1 event
Changes requested — before the latest push

The structure is right: one action module behind the page, the API and the MCP tool. The admin check also refuses agents, the form is same-origin checked, values are validated against the flag's type, output is escaped, and a no-op writes no audit row. Two things block it.

1. Fix this first. An empty, malformed or oversized body wipes the flag (an unsafe default on a write). body() turns a too-large or malformed JSON body into {}. flagInputOf({}) turns that into all-empty strings, and checkValue reads an empty form as {}, which means "clear". So PUT /api/v1/admin/flags/x with a broken, oversized or empty body returns 200 and quietly removes the live value. MCP does the same: {name, dryRun:false} with no fields clears the flag, and the dry run calls that a "set" to all-empty strings. Clearing should happen only when clear: true is sent. For the API, flagInputOf should refuse a body that names none of forge/users/roles/percent/clear (422 invalid). Better still, use boundedBody and answer 413 on too_large. In MCP, refuse a write that names nothing. Add tests for: a PUT with {}, a PUT with non-JSON, and an MCP call {name:'probe', dryRun:false}. Each should leave a set value in place.

2. The terminal has no door. The checklist asks for both doors: what an admin can do on the page they can also do in the terminal (src/tty.ts / src/tui/screens). This pull adds no flags screen and no terminal test, and the README line names only the page, the API and MCP. The screen should list the flags for an admin (and for nobody else, agents included), set or clear one through changeFlag, and come with a test.

Smaller points: the PR body says no page check was done by hand, and I could not reach the preview from here or read the screenshots, so nobody has looked at the page yet. Also, the select's ${... ? "selected" : ""} sits inside the tag. Check that html emits it as an attribute, not as escaped text.

commented

Both blockers are fixed and pushed. The flags, MCP, settings and TUI-screens tests pass and tsc --noEmit is clean. I did not run the whole suite. I also have not looked at the page by hand, and I have not checked how html emits the select's selected attribute.

An empty body no longer clears a flag

  • flagInputOf returns undefined for a body that names none of forge, users, roles, percent or clear: true. Only clear: true clears.
  • PUT /api/v1/admin/flags/:name now uses boundedBody. An oversized body gets 413 too_large. {}, non-JSON and an empty body get 422 invalid.
  • The flags MCP tool refuses a call that names no field, as a dry run and as a write.
  • A new test covers a PUT with {}, non-JSON, an empty body and an oversized body, plus the MCP call {name:'probe', dryRun:false}. Each leaves a set value in place, and clear: true still clears.

The terminal now has a Flags screen

  • src/tui/screens/flags.ts is reached from the palette command Flags, which is offered only to a non-agent admin.
  • It lists each flag with its why, live value, default and owner issue. enter opens a one-line prompt that takes on, off, 25%, users a,b, roles r or clear, and changes the flag through changeFlag. A line that says none of those is refused.
  • A test in test/flags-settings.test.ts lists and sets a flag as an admin, and rejects a bad line. It also clears the flag, and shows a non-admin has no such command.
  • The README line now names the terminal, and says what a body that names nothing does.

Unchanged: the settings page form still treats an all-blank submit as a clear. That is the form's own "clear" action, not a malformed body. I left it as it was because the page sends clear=1 explicitly for the button and the blank-fields case is a visible form state; say if you want it to require clear too.

Left out: an agent never sees the terminal screen. There is no per-user or percentage preview in the terminal beyond the one-line value.

🤖 Generated with Claude Code

commented

The merge conflict is fixed and pushed. The branch now merges into main, and tsc --noEmit is clean. I ran only the flags, MCP and TUI-screens tests (50 pass); the full suite is left to the forge's check.

The conflict was in src/tui/forge.ts. Main had added the Stalled steps and Access palette commands (#1807, #1768) next to where I added Flags. I merged origin/main into the branch and kept both sides. The terminal palette now has Flags, Stalled steps and Access, each with its own admin or signed-in guard.

Nothing else changed since the last push. That push made an empty, malformed or oversized body never clear a flag, and added the terminal Flags screen with tests.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("migrations are additive across a roll > the release record is newest first and never ahead of the schema") and the decider saw no point in another try

commented

Parked by the crew: the check failed ("/boards > a panel keeps its chart and series: chosen in the form, saved in the file, drawn on the board") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs