emrg: red-line guard — tests never run the real auto-upgrade chain (rant 2026-08-21T10:35:57) - #908
Merged
Conversation
…ant 2026-08-21T10:35:57) A long-running pytest session (PID 72994, 21h) really executed the auto-upgrade chain in the background: real GitHub releases requests, real ~/.emrg/install/version.txt reads, and real emrg-upgrade session writes every 5 minutes — continuing across daemon restarts and even after 'emrg stop'. serve() unconditionally starts the 5-minute _upgrade_tick_loop with a default-enabled UpgradeManager. Fix (mirrors the stop_daemon red-line pattern): - tests/conftest.py: autouse _guard_upgrade_hermeticity fixture blocks every side-effect endpoint — upgrade-module httpx.AsyncClient raises (module-local, global httpx untouched), VERSION_FILE redirected to a per-test tmp path, EmrgServer._get_or_create_session for SESSION_ID 'emrg-upgrade' raises. Tests that legitimately exercise the chain stub these after the fixture as usual. - tests/test_ws_e2e.py: _boot_server forces the upgrade manager disabled (patches emrg.config.load_update_config) so booted test servers' tick loop is a no-op; restored in cleanup. - tests/test_upgrade.py: _run_upgrade_session runner test isolates the session factory; new test proves the guards are active by default. - MANIFESTO.md: 第四条附则三 codifies the permanent red line (same status as the stop_daemon red line, host 2026-08-21 10:35). - Agent.md: documented test count 985 -> 986.
argszero
commented
Aug 21, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle
Fresh review of the upgrade-chain red-line guard:
- conftest autouse
_guard_upgrade_hermeticityblocks all three side-effect endpoints: upgrade-module httpx.AsyncClient raises (module-local, global httpx untouched), VERSION_FILE redirected to per-test tmp, EmrgServer._get_or_create_session for 'emrg-upgrade' raises. _boot_serverforces the upgrade manager disabled via emrg.config.load_update_config patch (restored in cleanup) — booted test servers' 5-min tick loop becomes a no-op.- test_upgrade session-runner test isolates the session factory; new guard-verification test proves guards active by default.
- MANIFESTO 附则三 codifies the permanent red line; Agent.md count synced.
Verified locally: pytest 985 passed + 1 skipped (986 collected), import + CLI OK; CI test + test-windows both PASS.
argszero
commented
Aug 21, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle
Re-review (head 316455f unchanged since the 1st LGTM, MERGEABLE/CLEAN):
- Negative-state verification:
test_upgrade_chain_hermeticity_guardsconfirms the autouse fixture raises on a real upgrade-module httpx.AsyncClient and redirects VERSION_FILE away from the real install path. - Full local suite: pytest 985 passed + 1 skipped (986 collected), import + CLI OK.
- CI test + test-windows both PASS on the same head.
2/3 consecutive LGTMs.
argszero
commented
Aug 21, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle
3rd consecutive LGTM (cycles 1193, 1194, 1195). Fresh verification on head 316455f (unchanged):
- pytest 985 passed + 1 skipped (986 collected) on the PR branch
- import + CLI OK
- CI test + test-windows both PASS
- MERGEABLE/CLEAN
3/3 consecutive LGTMs — merging.
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 freeto 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
A long-running pytest session (PID 72994, 21h) was really executing the auto-upgrade chain in the background: real GitHub releases API requests, real
~/.emrg/install/version.txtreads, and realemrg-upgradesession writes (downgrade prompt, delay=1440, target=v0.2.57) every 5 minutes — continuing across daemon restarts and even afteremrg stopstopped all real processes (writes at 10:23:12 / 10:28:15 / 10:33:17 after the 10:22:56 stop).Root cause:
EmrgServer.serve()unconditionally starts the 5-minute_upgrade_tick_loop, which buildsUpgradeManager(load_update_config(), …)withenabled=Trueby default. Any test booting a real server over a long session lets the tick run the real chain.Changes
tests/conftest.py— new autouse_guard_upgrade_hermeticityfixture (mirrors the existing_guard_stop_daemon_hermeticityred-line pattern):httpx.AsyncClientinemrg.server.upgraderaisesAssertionErroron instantiation (module-local — the globalhttpxmodule is untouched).upgrade.VERSION_FILEis redirected to a per-test tmp path — the real~/.emrg/install/version.txtis never read/written.EmrgServer._get_or_create_sessionforSESSION_ID(emrg-upgrade) raises — no real upgrade session may be created/written.tests/test_ws_e2e.py—_boot_serverforces the upgrade manager disabled (patchesemrg.config.load_update_config→UpdateConfig(enabled=False)) so booted test servers' tick loop is a no-op; restored in cleanup. Coverstest_daemon_manager_e2e(reuses_boot_server).tests/test_upgrade.py— the daemon session-runner test now isolates the session factory (_get_or_create_session); newtest_upgrade_chain_hermeticity_guardsproves the guards are active by default.MANIFESTO.md— 第四条附则三 codifies the permanent red line (same status as the stop_daemon red line, host 2026-08-21 10:35).Agent.md— documented test count 985 → 986.Verification
uv run pytest tests/→ 985 passed + 1 skipped (986 collected) (was 984+1)uv run python -c "from emrg.client.app import run_client"→ OKuv run python -m emrg --help→ OK