Skip to content

Check the mode before starting and shut down when run returns - #164

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/check-mode-before-startup
Nov 11, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/check-mode-before-startup

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Interakt#main now picks the user with the new static Interakt.createUser(args, out) before the application is constructed, so a missing or unsupported mode prints its message and returns without loading data, starting the time, auto-save or usage reporting services, or sending a startup event.
  • The new Interakt#start(user) runs onStartup, run and then shutdownApplication, so when run returns (end of input, or player mode with no test world) the data is saved, usage reporting is closed and the process exits instead of being kept alive by the non-daemon auto-save thread.
  • The constructor Javadoc now points at start instead of main.

Notes

Test plan

  • mvn -B clean test: 206 tests run, 0 failures, 0 errors.
  • Four tests were added to InteraktTest: each supported mode (case-insensitive) gives the right user, an unsupported mode and a missing mode each print their message and give null, and start runs startup, then the session, then shutdown when input ends.
  • With the Interakt.java change stashed, InteraktTest fails (compile errors on the missing createUser/start); with it restored, all 6 tests pass.

Closes #159

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

An unsupported mode used to load the data and start the time, auto-save
and usage reporting services before being rejected, leaving a process
that never exited. The mode is now checked before the application is
constructed, and start() shuts the application down once run returns
(end of input, or player mode without a test world).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against gh pr diff 164, the local mvn -B clean test run and the PR's CI run):

  • Scope: PASS. Only Interakt.java (main split into createUser + start, one Javadoc pointer) and InteraktTest.java change, and both are needed for An unsupported mode argument starts the simulation and the process never exits #159.
  • Tests-new: PASS. createUser is covered for console, player (upper case), an unsupported mode and a missing mode. start is covered for startup, then run, then shutdown when input ends.
  • Tests-fix: PASS, with a caveat. With Interakt.java stashed, InteraktTest fails, but only at compile time (cannot find symbol at lines 45/46/54/62) because the tests target the new API. That shows the tests depend on the change. It does not show that the old main was wrong, because that path cannot be driven from a test without real startup (it would load data and send a usage event). The ordering guarantee is structural: main returns before new Interakt() when createUser gives null.
  • Sibling structure: PASS. No new files. The new methods carry Javadoc like their neighbours.
  • Sibling renames: PASS. Nothing was renamed.
  • Docs: PASS. README.md lists the modes (unchanged) and does not describe what happens on a bad mode or at end of input. HelpCommand and getCommands() are not touched.
  • Issue resolution: PASS. Both halves of An unsupported mode argument starts the simulation and the process never exits #159 are covered: the mode is checked before startup, and the application shuts down when run returns.
  • Local build+test run: PASS. mvn -B clean test ran 206 tests with 0 failures and 0 errors. The CI build-and-deploy job passed in 21s, including the console smoke run.
  • No stale mvn claim / No singleton reintroduction / Help-commands parity / License header: PASS / PASS / N/A / N/A. No build docs, PersistentData access, commands or new files are touched.

Observations:

  • src/main/java/dansapps/interakt/Interakt.java:325: start now calls shutdownApplication, which ends with System.exit(0). Only main calls start, so nothing that embeds the class gets the exit unexpectedly. BrowserMain reaches it only if CheerpJ's stdin ends.
  • The player-mode path without a test world still adds the actor to persistent data before the world lookup fails. The shutdown save now persists it right away, where before the next auto-save would have. This is recorded in the PR body as out of scope.

The change is ready to merge on the green local and CI runs.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 91920b5 into main Nov 11, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/check-mode-before-startup branch November 11, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unsupported mode argument starts the simulation and the process never exits

1 participant