Skip to content

Add ProcessRunner and GitCheckout services to NXCore (#387, step 5) - #460

Merged
v0lumehi merged 1 commit into
mainfrom
v0lumehi/process-runner
Nov 2, 2026
Merged

v0lumehi merged 1 commit into
mainfrom
v0lumehi/process-runner

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #458 (which is stacked on #456), retarget to main after they merge.

Part of #387, step 5.

Fix or feature

  • Fix
  • Feature

This is a refactor with no change in behavior, so neither box fits.

What and why

Step 5 of #387: the first two services. They start processes and touch the file system, have no @Published state, and each is a protocol with one real implementation, so a test passes in a fake. They live in NXCore (Foundation only, package access).

  • ProcessRunner is the place that starts a build process. Three primitives: capture (run to the end, keep stdout and stderr, optionally merged), stream (hand out lines) and start (return at once, output chunks and exit status in callbacks, optionally as leader of a process group). runQuiet, runOK, runCaptured and output are helpers over them. SystemProcessRunner is the real one.
  • ProcessGroups is the group tracking that was in BuildModel (inOwnGroup, track, untrack, endGroup, endAll, buildProcessesAlive) and the SIGTERM handler. The willTerminate notification is AppKit's, so BuildModel still registers it and calls ProcessGroups.endAll().
  • GitCheckout has clone, fetch plus behind count, pull, the automatic pull (main with no tracked changes only) and the adoption of a ZIP copy. SystemGitCheckout is the real one. GitRules holds the decisions that need no git (autoPullAllowed, zipCopyBranch, zipAdoption). The git binary lookup and the git environment moved there.
  • BuildModel takes a ProcessRunner and a GitCheckout in init, with the real ones as defaults. Clone, check, pull, auto pull, adoption, the build run, the tools of a stage, the archive step, openOnDevice, the nsz install and the engine sync go through them. BuildModel.runQuiet, runCaptured, gitBinary, gitEnv, inOwnGroup, track, untrack and endGroup are gone.
  • Toolchain (runOK, pythonVersion, dotnetRoot, developerDir, firstOutputLine, makeVenv), Diagnostics, OlderTools, Uninstall.gitOrigin, EngineLayout.runSync, the update staging (ditto) and the Xcode probe in LiveOnboardingDriver take a runner or a checkout as a parameter. The default is the real one, so no call site changed.
  • Behavior is the same, with these small differences in how a process is run: a captured run now drains stdout and stderr together (the old runOK left its pipes unread), xcode-select -p gets an empty stdin, and a stage's pipe handler is no longer cleared by hand on exit, because PipeReader detaches itself at end of output.
  • Tests: new ProcessRunnerTests (real runner against small system tools, the helpers and four Toolchain functions over a fake) and GitCheckoutTests (the git commands of every flow over a fake, plus the pure decisions) in NXCoreTests. New RepoFlowFakeTests drives the BuildModel repository flows with a fake GitCheckout. The pure-decision tests moved out of RepoAutoUpdateTests and RepoToolsTests into GitCheckoutTests. The others use the new names.
  • ContentView.swift shrinks from 2943 to 2763 lines. SourceSizeTests is lowered. frontend/ARCHITECTURE.md says where things stand.

What stays

These still start a Process themselves and move with the step that owns them.

  • AppSignature (codesign) and AppUpdate (ditto, xattr): step 6, with the AppUpdateStore. Release parsing stays in AppUpdate.swift as asked.
  • DeviceTools.run (devicectl with a timeout and input) and SaveTransfer: the device store.
  • ShellInstaller.run (a blocking read with start and end callbacks): the build store. BuildModel still hands it ProcessGroups through its callbacks.
  • EngineUpdater (ditto): the engine store.
  • The administrator prompt in LiveOnboardingDriver and the game start in LiveConsoleDriver.
  • The loose test hook BuildModel.xcrunPath and volumesRoot. ShellInstaller and DeviceTools run those tools themselves and the tests point them at a script, so they move with the device store. teamsProvider, chooseKeys, revealFolder and openApp are not process hooks and stay.
  • The unrelated detectDepsSync and its static helpers keep calling Toolchain with the real runner.

@LNPANDY, this one changes how the launcher is built, not how it works or looks.

Checked

  • Tests: cd frontend && swift test in full, 746 tests (69 in NXCoreTests, 677 in NX2AppleTests, 17 skipped as before). Four runs in total (three by hand and the pre-push hook run), all with 0 failures. The first run after I wrote the new tests had two failures of my own tests, GitCheckoutTests.testAFailedFetchStopsTheAdoptionAndRemovesTheGitFolderItMade (a temp folder name contained "checkout") and ProcessRunnerTests.testTheDirectoryIsTheOneGiven (/var against /private/var). Both are fixed. I ran python3 tools/engine.py sync first, so the tests that read engine/ pass.
  • Visual QA: not needed, no visible change.
  • Run on a device or Mac: not run by hand. I did not start the app. The real runner is tested against small system tools and the callers by the existing suite, including the real git flows (RepoAutoUpdateTests, RepoToolsTests) and the process group test.

Screenshots

None, no visible change.

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository
  • No change to the engine or a game profile
  • A change to a launcher view has before and after screenshots above: not needed, nothing visible changes
  • No keys, game files or data extracted from a game in the change or the attachments

@v0lumehi v0lumehi added this to the v1.0.2 milestone Nov 1, 2026
@v0lumehi v0lumehi added launcher The NX2Apple launcher app mac Mac labels Nov 1, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 1, 2026
@v0lumehi
v0lumehi added this pull request to stack #459 November 1, 2026 23:02
@v0lumehi
v0lumehi force-pushed the v0lumehi/process-runner branch from 8addb5a to 061a558 Compare November 2, 2026 12:47
ProcessRunner is the place that starts a process: capture, stream and start (with a process group). ProcessGroups moves the group tracking out of BuildModel. GitCheckout holds clone, fetch, pull, behind count, the automatic pull and the adoption of a ZIP copy, GitRules the pure decisions. BuildModel takes both in its initializer. Toolchain, Diagnostics, OlderTools, Uninstall and the update staging take a runner or a checkout as a parameter.
@v0lumehi
v0lumehi force-pushed the v0lumehi/process-runner branch from 061a558 to 1d58f23 Compare November 2, 2026 14:28
Base automatically changed from v0lumehi/core-pure-logic to main November 2, 2026 15:31
@v0lumehi
v0lumehi merged commit 4907e8e into main Nov 2, 2026
14 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/process-runner branch November 2, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation launcher The NX2Apple launcher app mac Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant