Sunset and purge runbooks omit `DEPLOYMENT_MODE`, which both depend on
The gap
docs/architecture/sunset.md lists this under Known gaps:
The runbooks do not mention
DEPLOYMENT_MODE, which the flag and therefore the purge script both depend on.
Why it matters
is_sunset_mode() returns false unless DEPLOYMENT_MODE=cloud and SUNSET_MODE is truthy. Both runbooks are written as though SUNSET_MODE were the whole switch, and one of them hands the operator a command that is wrong because of it.
The purge runbook's recovery instruction for running the script outside the usual host is SUNSET_MODE=1 python -m scripts.purge_hosted_accounts. In a shell without DEPLOYMENT_MODE=cloud that still refuses, and the runbook has already told the reader that a refusal here means the guard doing its job. So the operator reads a correct refusal as expected behaviour, sets the one variable the document names, gets the same refusal, and is out of instructions — on the day the deletion was promised for. The sunset runbook has the same hole in its "One variable, two places" table and its stage 1 check.
Where
plans/community-local/purge-runbook.md— the section "The flag the script checks", and theSUNSET_MODE=1 python -m scripts.purge_hosted_accountsline under it.plans/community-local/sunset-runbook.md— "One variable, two places", stage 0's stop condition and stage 1's/healthcheck, all of which assumeSUNSET_MODEalone decides.surfsense_backend/app/sunset.py—is_sunset_mode()is the behaviour both runbooks are describing. Read it before writing anything.surfsense_backend/.env.examplealready explains the pairing besideSUNSET_MODE, and ADR 0023 records that production setsDEPLOYMENT_MODE=cloud. Reuse that wording rather than writing a third version of it.
What done looks like
- Both runbooks say that the flag is two variables, not one, and that
DEPLOYMENT_MODE=cloudis the half that is already set on production and is easy to lose when working from a different shell, container or checkout. - The purge runbook's fallback command sets both variables, so following it literally works.
- The sunset runbook's stage 1 check tells the operator what to look at when
/healthstill reportssunset: falseafter the flag is set. - Stay inside the existing structure. These are stage-ordered operational documents with checks and stop conditions, not prose to rewrite.
- Delete the Known gaps line from
docs/architecture/sunset.mdin the same PR.
What not to change
Do not change is_sunset_mode() to drop the DEPLOYMENT_MODE requirement. It is the only thing standing between a self-hosted install with a copied .env and a purge script pointed at its database, and tests/unit/test_sunset_write_block.py asserts it in both directions. This issue is documentation only; the code is right and the documents are behind it.
How to verify
No test to write — this is docs. Read the script and the flag first, and confirm every command you leave in the runbook would actually succeed on a shell that has neither variable set.
python scripts/check_docs.py
Before you start
Read CONTRIBUTING.md, the sunset doc and ADR 0023. This is time-critical: the purge runbook is executed on 18 Oct 2026, and after it there is no second chance to have got the instructions right. Open your PR against dev, not main. Comment here to claim this.
Opened a PR against dev for this: https://github.com/MODSetter/SurfSense/pull/2021
The runbooks now treat the flag as SUNSET_MODE plus DEPLOYMENT_MODE=cloud, the purge fallback command sets both, and the known-gap line in docs/architecture/sunset.md is gone.
Fixed by #2125, merged into dev, by @ybai08.
Both runbooks in plans/community-local/ now describe the sunset flag as the two variables the code reads: is_sunset_mode() in surfsense_backend/app/sunset.py is true only with DEPLOYMENT_MODE=cloud and a truthy SUNSET_MODE, and the web redirect checks cloud mode too. The purge runbook's fallback is now export DEPLOYMENT_MODE=cloud SUNSET_MODE=1, which works in a shell where neither is set, and it warns that the script's refusal names only SUNSET_MODE. The sunset runbook gains a "Two variables, two places" section, a cloud-mode check in stage 0, and what to check when /health still reports sunset: false. The code is unchanged on purpose: requiring cloud mode is what keeps a self-hosted install with a copied .env out of reach of the purge.
The Known gaps line this issue quoted is deleted in the same PR. Closing by hand: GitHub only auto-closes on a merge to the default branch, and we merge through dev.