On 1 December CogniPrep added a temporary programme: signed-in users can take a set of free tests on a sister product we also run, so that product gets real data from real people. The word in the commit title is "temporary", and the interesting engineering is everything that follows from taking that word seriously.

The removal instructions went into the very first commit, as a README in the folder. Here is what that looked like in practice, and where it leaks.

The shape

The feature lives in a top-level folder, beta-tests/, outside app/ and components/. It is 738 lines in total, counting a test file and an 11-line page under the dashboard route that just imports from it. The folder holds the page body, a server action, the client prompts, the API wrapper and a state.ts with the rules.

Everything the rest of the codebase knows about it is a call site, and every call site is marked. The marker is the literal string BETA-TESTS in a comment, on the import and on its one use:

import { BetaTestsBanner } from '@/beta-tests/client'; // BETA-TESTS ... {/* BETA-TESTS: under the upgrade card, never in front of it. */} 

A grep of app, components and lib finds exactly 11 of them in 7 files: the dashboard page and its exercises page, the account menu, the game completion screen, the privacy page, and the route's page and loading skeleton. That list is the whole blast radius of the feature. If it had been 40, I would have known before shipping rather than at removal.

One switch

state.ts exports BETA_TESTS_ENABLED = true, and the prompts go through shouldShowPrompt, a pure function that takes enabled as an input. The README's first removal step is to flip the constant and deploy, which hides the page, the prompts and the menu entry at once, with nothing deleted. That is the first removal step, and it is the one you want available at 2 a.m.

It is a constant in code rather than an environment variable: the README says only the secret comes from the environment. The cost is a deploy to flip it. The benefit is that the switch is in the diff, where a reviewer can see it.

No database

Nothing about a participant is stored in CogniPrep's database. The tests run on the other product, where a server action creates or looks up the user's invite on the server side only. Progress is read back from that invite's status.

The only local state is two localStorage keys, one for "dismissed" or "started" and one for the time of dismissal. Closing a prompt hides all of them for seven days, then they return; opening the tests hides them for good. That rule is shouldShowPrompt, and the test pins the boundary: six days stays hidden, seven days shows again.

The consequence is the sentence at the bottom of the README: "Nothing in CogniPrep's database was added, so there is nothing to migrate." Removal is a code change, not a data change.

The removal README

It is short and numbered:

  1. Set the constant to false and deploy.
  2. Delete the folder and the route.
  3. Remove the call sites, found with a grep for the marker.
  4. Remove the secret from the host and the local env file, and revoke the key.
  5. Move the account on the other product off its beta plan.

Step 3 is the one that works because of the marker. A reviewer does not have to remember that the account menu had a menu item, or that the game completion screen had a line under the results. The grep remembers.

The step it skips

The privacy page is one of the 11 marked sites, and it is the only one that is a promise to users, not a piece of UI. The paragraph says that if you take the tests, your email is passed to the other product to create your link. Removing it is a change to a legal document, and this site versions those: the current privacy version is a constant, and the device limit deletion showed what a policy change involves.

The README says to remove the call sites and does not say that this one needs a version bump and a new "last updated" date. The grep will find the paragraph and the person following the list will delete it and move on. That is a gap in the instructions, and now that I have written it down it can be fixed.

One smaller leak: the two localStorage keys stay in browsers that had them. They are inert, but nothing cleans them up.

See it

The feature is behind sign-in, so I will not pretend you can click through it. What is public is the promise:

  • /privacy has a paragraph beginning "BETA tests". Search the page for it.
  • The route is real but gated: curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" https://cogniprep.app/dashboard/beta-tests answers 307 and points at the login page.

What I would keep

Three habits, none of them clever. Put the whole feature in one folder. Mark every call site with the same string. Write the removal steps in the first commit, because that is the only moment you know exactly what you just wired in.