Repository navigation
feat(backend): restore the JIT kill switch as an authority over allowlist admission - #12388
Merged
Merged
Conversation
PR #12369 collapsed JIT admission to the exposure flag plus a code-owned allowlist, retiring jit-processing-kill-switch-v1 and hardcoding kill_switch=DISABLED so it could never block anyone -- including the allowlist. Product decision 17 requires a real operational kill switch that works even for the allowlist. PostHogJITFlagProvider now parses both jit-processing-v1 and jit-processing-kill-switch-v1 out of the single get_feature_variants response it already fetches (no second network call). The allowlist no longer skips the provider outright: it still bypasses the exposure flag, but a definitively ENABLED kill switch now revokes admission for everyone, including allowlisted UIDs. An UNKNOWN or absent kill switch never blocks by itself, so the allowlist's PostHog-down resilience and the non-allowlist fail-closed exposure-flag behavior are unchanged. The kill switch can only ever remove authority, never grant it. Co-Authored-By: Claude Fable 5 <[email protected]>
Git-on-my-level
force-pushed
the
feat/jit-kill-switch-restore
branch
from
August 29, 2026 15:45
db5ebf0 to
f7f3eba
Compare
Git-on-my-level
marked this pull request as ready for review
August 29, 2026 16:04
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.
What changed and why
PR #12369 collapsed JIT admission in
backend/utils/jit_rollout.pyto one exposure flag (jit-processing-v1) plus a code-owned two-UID allowlist that bypasses PostHog entirely. In doing so it retiredjit-processing-kill-switch-v1:_allowlisted_decisionand_effective_decisionhardcodedkill_switch=TriState.DISABLED, and the provider never read the kill flag at all. That left no way to stop JIT processing for the allowlisted UIDs if something went wrong with them specifically — the one thing an operational kill switch exists for.Ratified product policy (decision 17) requires a real, separate operational kill switch that works even for the allowlist. This restores it.
PostHogJITFlagProvideralready fetches every decided flag for a UID in oneget_feature_variantscall, so bothjit-processing-v1andjit-processing-kill-switch-v1are now parsed out of that same response — no second network call, same bounded executor/timeout/caching discipline as before. The allowlist no longer skips the provider outright: it still bypasses the exposure flag, but the kill switch is now consulted for allowlisted UIDs too, since it's the only thing that can revoke their admission.Review fixup: an earlier version of this PR read an absent kill-switch key as
UNKNOWN. PostHog's decide response omits a boolean flag entirely when it evaluates false for the distinct ID, so a 0%-rollout kill switch — its normal, healthy steady state — is legitimately absent from a well-formed response, not a presentfalse. Reading that asUNKNOWNwould have permanently downgraded every steady-state decision to the short negative-cache TTL (~4x the normal control-plane call rate) and reported a false "unknown" kill switch on the wire even though nothing was wrong. Fixed: when the response itself is well-formed, an absent kill key now reads asDISABLED.UNKNOWNstays reserved for a kill key that is present with a non-bool value, and for the existing whole-response failure paths (timeout/error/malformed mapping).Semantics
ENABLEDDISABLEDKILL_SWITCH_ENABLEDUNKNOWN(present, malformed) / provider downENABLEDROLLOUT_ENABLEDDISABLEDENABLEDROLLOUT_ENABLEDENABLEDENABLEDDISABLEDKILL_SWITCH_ENABLEDENABLEDUNKNOWN/DISABLED(incl. absent →DISABLED)ENABLEDROLLOUT_ENABLEDDISABLED/UNKNOWNENABLEDDISABLED/UNKNOWNThe kill switch can only ever remove authority, never grant it. An
UNKNOWNor absent kill switch never blocks by itself, so:Caching is unchanged in shape: a definitively known kill switch (
ENABLED, orDISABLED— including "absent from a well-formed response") caches for the normal decision TTL; anUNKNOWNkill switch (present-but-malformed, or a whole-response failure — like anUNKNOWNrollout) uses the existing short negative-cache window. No new cache layers, and steady-state (kill key simply unset) keeps the full TTL rather than being silently downgraded.The
JITRolloutDecision.kill_switchfield (already part of the wire shape the desktop DTO decodes) now reports the real observed state (ENABLED/DISABLED/UNKNOWN) instead of a hardcodedDISABLED— downstream consumers that already branch on it (routers/jit_ledger_snapshot.py's_disabled_snapshot,utils/retrieval/frame_request_authority.py) get correct behavior for free.Module docstring and the "retired admission keys" comment are updated: the kill switch is live authority again;
jit-processing-ledger-migration-v1anddaily-memory-sweep-v1remain retired.Tests
Extended
backend/tests/unit/test_jit_rollout.py(46 tests, all passing):ENABLED→permits_work=False, reasonKILL_SWITCH_ENABLEDpermits_work=True(resilience unchanged)UNKNOWN→permits_work=TrueENABLED+ killENABLED→FalseENABLED+ killUNKNOWN/DISABLED→TrueDISABLED/UNKNOWN→False(unchanged, existing test)resolve_jit_rollout_sync(the sweep/first-open path) inherits the same kill-switch authority as the async pathkill_switch=DISABLED, full cache TTL, both allowlisted and regular UIDs unaffected (test_kill_switch_absent_from_a_well_formed_response_means_disabled_and_full_cache_ttl)UNKNOWN, short cache TTL, still never blocks either UID class (test_kill_switch_present_but_malformed_stays_unknown_with_short_cache_ttl_and_never_blocks)test_posthog_provider_parses_only_the_exposure_flag→..._parses_the_exposure_and_kill_switch_flags,test_retired_flags_do_not_change_admission→ split intotest_ledger_migration_and_daily_sweep_flags_do_not_change_admission+test_kill_switch_flag_revokes_admission_even_when_rollout_is_enabled) to assert the new contract instead: the kill switch can only ever remove authority, never grant it.Verification run (from the worktree,
backend/)Also ran the directly-related consumer/mocking test files to check for regressions:
(An earlier run of this same set hit one pre-existing, order-dependent flake in
test_memories_archive_and_read_contracts.py, reproduced identically on unmodifiedorigin/main— unrelated to this change; it did not recur on this re-run.)Type check (focused, both touched files plus direct downstream readers of
decision.kill_switch):(All 5 warnings are pre-existing
reportUnknownVariableTypenotes unrelated to this diff — confirmed identical against unmodifiedorigin/main.)Format check:
The repo's pre-push gate also ran its own bounded backend-unit-test selection (auto-detected
test_jit_rollout.pyfrom the diff, 46 passed) and the optional formatters check on every push — both passed, including after the amended fixup commit (headf7f3ebad13).I did not attempt a full-repo
test.sh --allrun: the changed-file selector flagsutils/jit_rollout.pyas broad enough to warrant a full ~995-file run, but collecting that many files in one non-file-isolated pytest session segfaults on this machine — a pre-existing, documented hazard intest.shitself (native-library re-registration underxdist), unrelated to this change. The proper file-isolated full run is CI's job; the focused + directly-related test set above is what's practical to run locally in this environment.Diffstat