Repository navigation
fix: keep the reload readiness pipe private to the app and safe across restarts - #58
Merged
Merged
Conversation
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.
Depends on #57. This branch is stacked on #57's approved head (
5f38b63b). #57 itself is unchanged, and the only new commit here isa7f4ff94.Three QA follow-ups to the readiness pipe that #57 introduced.
1. The ready fd and env var leaked into processes the app spawns while booting
ruflet runmaps the pipe to fd 3 of the app child, which has no close-on-exec, and setsRUFLET_READY_FD. The harness took them only after loading the app, so anything the app started during load inherited the open pipe and saw the variable. Such a process could write "ready" early, and a reload would then kill the booting app. A probe confirmed this: a subprocess spawned during load reportedinherited env="7".Fix.
Runner#claim_ready_fdruns at the very start ofRunner#run, before the app script loads. It takes the fd, setsclose_on_exec = true, and deletesRUFLET_READY_FD.signal_readythen writes to that IO and closes it.2. Test for dropping a queued reload on "R"
#57 resets a reload queued during boot when the app is respawned. A new test now covers it: "r" during boot is queued, then "R", then the respawn. The test checks that the pending flag is cleared, and that no reload signal reaches the new app once it reports ready. A fresh "r" then reloads the restarted app (
L2).3. "r" between "R" and the respawn ended the key reader (pre-existing)
Once the app had reported ready, "R" left it marked ready. An "r" before the respawn sent USR1 to the reaped pid, got
ESRCH, and returned false, which endsstart_reload_input_thread. After that no key worked for the rest of the session.This reproduces on #57's head with
$SP/team/qa-logs/dev-wave4/r_after_restart_repro.rb:Fix. "R" now calls
mark_restarting, which marks the app not-ready and clears any queued reload under the readiness lock before it sends TERM. While a restart is pending, "r" prints "Restart in progress: the restarted app loads the current code", because the respawned process loads the current files anyway, and the key reader stays alive. The reload signal goes through onesend_reload_signalmethod, and the ready-watcher thread is kept inrun_state[:ready_thread], so tests can wait on events instead of time.Tests (deterministic, pipe/FIFO readiness only)
hot_reload_test.rb#test_processes_spawned_while_the_app_loads_do_not_inherit_the_ready_fd: the app script runs a real subprocess probe while loading. It must reportclosed env=nil, and the runner must still send its ready byte. This failed on fix: queue a hot reload requested while the app is still booting #57's head withinherited env="7".run_command_test.rb#test_restart_drops_a_reload_queued_during_boot(item 2).run_command_test.rb#test_r_between_restart_and_respawn_keeps_the_key_reader_alive(item 3). It checks that "r" returns true, prints the restart message, and sends no signal, and that "r" works again once the app is back.Both CLI tests use #57's FIFO-gated real-harness app and a signal-spy runner, and they wait on
ready_thread.joinand FIFO reads, with no sleeps. They error on #57's head, because the hooks don't exist there; the behavioural evidence is the repro above.Proof
flutter testloop and theruflet_coresuite loop ran alongside (1-minute load average 32–72). Log:hardening_proof.log.verify_pr.shwithRUBY_PKGS="ruflet_core ruflet ruflet_server": ruflet_core 145/145, ruflet 13/13 (166 runs), ruflet_server 11/11. PASS.QA follow-up 2