fix(validator): DEV_MODE=false enables the maintainer-filter bypass it should disable#1642
Open
RealDiligent wants to merge 1 commit into
Open
Conversation
The maintainer-filter bypass was gated on `not os.environ.get('DEV_MODE')`,
which tests for presence rather than value. Every non-empty string is truthy,
so DEV_MODE=false, DEV_MODE=0, DEV_MODE=off and DEV_MODE=no all *enable* the
bypass they are meant to disable, silently dropping the maintainer filter on
a production validator.
Parse DEV_MODE by value via `dev_mode_enabled()`, alongside STORE_DB_RESULTS
in the validator config module and following the same convention. DEV_MODE=1
and DEV_MODE=true keep working, so existing setups are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DEV_MODEgates the maintainer filters vianot os.environ.get('DEV_MODE'), which tests for presence rather than value. Every non-empty string is truthy in Python, so:.envlineDEV_MODE=1/DEV_MODE=trueDEV_MODE=falseDEV_MODE=0/off/noAn operator who writes
DEV_MODE=falseto turn the flag off gets the exact opposite:_maybe_add_prstops droppingOWNER/MEMBER/COLLABORATORPRs,_should_skip_merged_mirror_pr's defensive recheck stops firing, and_should_include_issuestops dropping maintainer-discovered issues. That validator then scores maintainer contributions the rest of the network rejects, and diverges from consensus on every miner it evaluates..env.examplemakes this a realistic keystroke rather than a hypothetical: it already shipsSTORE_DB_RESULTS=false, soKEY=falseis the idiom this project teaches its own operators. TodayDEV_MODEhas no working "off" value — the only way to disable it is to remove the line entirely.Root cause
os.environ.get('DEV_MODE')returns the string'false', andbool('false') is True. The check never looks at the value.Fix
Parse by value in
dev_mode_enabled(), placed next toSTORE_DB_RESULTSin the validator config module and following the convention already established there:It is read at call time rather than at import so per-process toggling (and the existing
monkeypatch.setenvtests) keep working.1/true/yes/onremain truthy, so existingDEV_MODE=1setups are unaffected; only the falsy spellings change, and they change to what they say.Why this is not the
#1067/#1069patternThose were closed — correctly — as hardening parsers against input the team itself controls (
master_repositories.jsonis maintainer-curated; the mirror API is gittensor-owned and emits real JSON booleans). This is a different source:DEV_MODEis operator-supplied, set by independent validator operators in their own.env, and the value that misfires is the one.env.exampletrains them to write. It is an operator-facing footgun in a flag that disables an anti-gaming filter, not defence against schema drift the team owns.Related Issues
None. Self-contained, self-evident fix; no linked issue filed.
Type of Change
Testing
Added
test_dev_mode_disabled_values_keep_maintainer_skip, parametrized over0,false,off,no,''and' ', asserting theOWNERPR is still dropped and only theCONTRIBUTORPR loads. It fails ontestand passes here.The existing
test_dev_mode_bypasses_maintainer_skip(DEV_MODE=1) still passes on both the PR and issue-discovery surfaces, pinning backward compatibility.Full suite: 970 passed, 0 failed, 0 skipped;
ruff check,ruff format --check,pyrightandvultureall clean.Checklist
No CLI surface is touched, so the before/after evidence rule does not apply.