Exit without stopping when there is nothing to stop - #23
Merged
Merged
Conversation
Calling exit() from the rejection of a failed start announced a second stop pair, so an application logging system_stop_succeeded reported one shutdown twice. The stop which follows a failed start had already reset the system, and exit() then ran a fresh stop which skipped every component and announced itself regardless. Both stops were doing what they were told, so one of them had to stay quiet. Making stop() silent on a stopped system would overrule the rule that an operation with nothing to do is announced like any other, which the system events feature asserts and which lets a listener on system_stop_succeeded see every stop however it was triggered. So exit() now checks whether there is anything to stop: no start in flight, no stop in flight or left failed, and no component started. When there is not, the process exits at once and no stop is announced. A stop which failed leaves components started, so an exit after it still retries the stop and reports its outcome in the code. The exiting scenarios gain a step which compares the whole event trace the program printed, since the existing step only checked that an event appeared and could not see a duplicate. Closes #22 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 801 810 +9
=========================================
+ Hits 801 810 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #22.
system.exit(code)called from the rejection of a failedstart()announced a second, empty stop pair. The stop which follows a failed start had already reset the system, so thestop()insideexitran a fresh stop which skipped every component and announced itself regardless.Behaviour
exit()on a system with nothing to stop exits at once and announces no stop. Nothing to stop means no start in flight, no stop in flight or left failed, and no component started: a system which never started, has already stopped, or whose start failed and the stop which followed has finished.stop()after a failed start is unchanged and still announces the empty pair, by the existing rule in system-events.md that an operation with nothing to do is announced like any other. The alternative, makingstop()silent on a stopped system, would have overruled that rule and the two-pair assertion in "Stopping a system which has already stopped".Found empirically
includes, so it could not see a duplicate. The exiting library gains a step which compares the whole event trace the child program printed as a table.exitwrapper returned nothing, which only surfaced once a behaviour replacedstart()and the program tried to chain on it.Tests
Four new child-process scenarios in test/features/exiting.md: three red before the fix with the duplicate pair visible in the diff, green after, and red again with the guard broken. 1357 steps pass, lint and typecheck clean.
🤖 Generated with Claude Code