Two small corrections found while checking 0.4-alpha's deploy. wrangler.jsonc claimed the slashless form redirects with a 301; measured against the live site it is a 307. The code is the host's choice rather than anything this repo sets, so the post-deploy check now says to confirm that it redirects at all — the property the site depends on — and records the observed code beside it rather than asserting one. Card 43 already describes the two test_boards_sync failures a team-mode checkout sees, and still describes them correctly; only its pointer into the test file had drifted — reload() sits at 598 now, not 481. config.py:53-69 is still exact. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4.6 KiB
43 — The suite reads the developer's own .env, so it passes or fails by whose machine it is on
Status: Backlog Priority: Medium — two tests fail on any team-mode checkout and pass in CI, which is the wrong way round for a suite people trust before pushing Type: Bug
tests/test_boards_sync.py asserts what bench does when nothing is
configured, by deleting the settings from the process environment. But
"nothing configured" in this project means "whatever manager/local/.env
says", so on a checkout that has turned team mode on — the setting the
tests are about — the assertion reads that file and fails. CI has no
.env, so it never sees it.
Context
manager/core/config.py:53-69—_load_env()readslocal/.envinto a dict and then doesvalues.update(os.environ). Process environment beats the file, and the file beats the defaults. That precedence is right and documented; what follows from it is not obvious.tests/test_boards_sync.py:598-613—TheGateImpliesCommitMoves.reload()popsBOARD_SYNCandBOARD_COMMIT_MOVESfromos.environand reloadsconfig, to stand for a machine that has set neither. Popping removes the only layer that was overridinglocal/.env, so the reload picks the file up instead of the defaults.- The two that fail this way:
test_both_are_off_by_defaultandtest_commit_moves_alone_stays_alone. On this repo's own checkout (BOARD_SYNC=1,BOARD_COMMIT_MOVES=1inmanager/local/.env) both fail; delete the file and both pass. - Not confined to those two: any test that reloads
configinherits whatever the developer's.envhappens to say. It is invisible today only because nothing else asserts a default. - The failure is the good direction of a bad property — a suite whose result depends on gitignored local state can as easily hide a real regression as invent a fake one.
Affected areas: manager/core/config.py and the config-reloading
tests, tests/test_boards_sync.py first.
What to build
- Give
configone documented way to be pointed at a different env file, and have the tests use it — an override read from the process environment (BOARD_ENV_FILE, say) that_load_env()honours instead ofLOCAL / ".env". It is the smallest change that makes every present and future config test hermetic rather than fixing two assertions. - Point the reloading tests at an empty file, so "nothing configured" means exactly that. A test that wants a setting sets it in the environment as it does now.
- Fail loudly if a test forgets. A shared helper — or
tests/__init__.py, which every run imports — that sets the override beforeconfigis first imported, so no individual test has to remember. Note that several test modules importconfigat module scope (tests/test_boards_sync.py:27), so wherever this lands it has to happen first. - Say it where it will be read. One line in the
_load_env()docstring: the process environment is the only layer above the file, so removing a variable does not reveal the default, it reveals the file.
Out of scope — tempting neighbours left alone:
- The precedence itself. Environment over file over default is right, and every adapter and hook depends on it.
- Making
.envreload at runtime, or watching it for changes. - The two assertions' content. They are correct about what bench should do; they are just being answered by the wrong source.
Acceptance
- Given
manager/local/.envwithBOARD_SYNC=1, when the full suite runs, then it passes — the state this checkout is in today, where it does not. - Given no
manager/local/.envat all, the suite still passes, exactly as it does in CI now. - Given a
.envthat setsBOARD_PORT,BOARD_AGENT_MODELor any other key, no test result changes. test_both_are_off_by_defaultfails if the defaults inconfig.pyare actually changed — the test still tests something.- Edge case: a test that deliberately wants a setting on still gets it from the process environment, and the override does not shadow that.
Notes
Worth checking while in there whether anything else reads
manager/local/.env during a test run — the adapters get it through
config.child_env(), and a test that launches one would inherit the same
surprise.
Risks — an override for the env file's path is a setting that changes
where settings come from. Keep it environment-only and undocumented in
.env.example: a key inside local/.env that redirects local/.env
would be a genuinely confusing thing to leave lying around.