Repository navigation
test: CLI and page compatibility goldens (WP-00 H1) - #73
Merged
Merged
Conversation
Pin what a Ruflet developer gets today so the WP-00 refactors (R1-R4) can prove they change nothing and later features can prove they only add. test/compat_goldens_test.rb runs in the normal per-file loop and compares 160 committed goldens: - goldens/cli: for every invocation in test/compat/corpus.rb (every command in the docs' CLI reference and guides, every build target server-driven and --self, profiles, verbose and pass-through flags, rebuilds, flags that later packages will change, the Rails rake tasks) the flutter/dart/pod/git argv with cwd and env, attempted HTTP requests, exit status and output, and every file the CLI writes (build/client relative to the frozen template, exports, the ~/.ruflet template cache); - goldens/page: the register_client reply (initial page patch) for each fixture app. The CLI is the gem installed from this checkout (gemspec file lists) and runs unmodified in a fresh process per invocation, with only the process, network, clock and host-probe boundaries replaced; ruflet-template is vendored at e32c873 so template pushes never break this CI. Goldens are path- and version-normalized and identical on Ruby 3.4 and 4.0. `ruby test/compat/compat.rb --regenerate` rewrites them. No library code changes.
This was referenced Nov 8, 2026
AdamMusa
added a commit
that referenced
this pull request
Nov 8, 2026
Every build used to write lib/ruflet_bootstrap.g.dart into the Flutter client, which changed 60 H1 goldens and added an unused file to client dirs the developer owns (RUFLET_CLIENT_DIR, ./ruflet_client, templates/ruflet_flutter_template). The template entrypoints now declare both hook lists empty themselves between // --RUFLET_BOOTSTRAP_HOOKS_START-- and // --RUFLET_BOOTSTRAP_HOOKS_END-- (AdamMusa/ruflet-template#3), so they build with every gem, released ones included. write_client_bootstrap now: - writes and deletes nothing while no provider adds a hook and nothing under lib/ imports the generated file: every build today; - with hooks, writes them to lib/ruflet_bootstrap.g.dart, imports it from lib/main.self.dart and lib/main.server.dart and replaces the marked block with a pointer. An entrypoint without the block (every released template) gets a warning naming it, and is left alone; - keeps an imported file in step (empty lists without hooks), and removes a generated file nothing imports any more. A file it did not write is never removed; - validates every hook before touching any file, and reads lib/ as bytes, so a non-UTF-8 or unreadable file cannot fail a build. The 60 goldens go back to #73's, byte for byte: compat.rb checks 160/160 against them.
Add 65 goldens (225 in all) so every path the review found unpinned now changes a golden when it changes. The 160 existing goldens are unchanged. Corpus: - Rails: rake ruflet:install with and without a device, ruflet:update with each target, every ruflet:build target the docs list (aab, android, macos, windows, linux) plus case and an unknown target, an initializer without build metadata, rake --tasks, and the documented ruflet:web, which the Railtie does not define. - rails generate ruflet:install with --desktop, --web, --web --desktop and --client, on a fresh rails new app and on an installed one. - Long-form --verbose on build, install, debug, doctor and emulators; --flag=value forms; the appbundle alias; upper-case targets and commands. - The documented env vars: RUFLET_CONFIG and the ruflet.yml fallback, RUFLET_PORT, RUFLET_CLIENT_DIR (build, debug, run), RUFLET_FLUTTER_VERSION and .fvmrc, with and without FVM. - A fake GitHub release (lib/release_fixture.rb) for `network: "release"` entries, so ruflet update, an uncached run --web/--desktop, rake ruflet:update and the generator's --desktop pin the download, extract, manifest and cache-reuse paths instead of only the 503 failure. Harness: - tar, unzip and ditto run for real, like PlistBuddy; output a tool prints reaches the golden unless the CLI redirected it. - A file a stub wrote is reported when the CLI then changes or removes it. - The Ruflet version is masked in file paths as well as contents. - Golden names are checked for case-insensitive collisions. - lib/generator_stub stands in for railties; the test cross-checks every generator golden against the real railties where it is installed. - docs_coverage.rb maps each of the 84 invocations in the published docs (ruflet_site 05dde18) to its goldens; `compat.rb docs-check` re-extracts them from a docs checkout. - The sensitivity test also probes command_install/command_update through the rake tasks and the generator, and a CLI edit to a stub-written file. Still test-only: no library, workflow or gemspec changes.
The seeded cache's files were all overwritten by the release archives, so whether ruflet update --force (or a due update) wiped the cache first was invisible. A file no archive carries now shows up as deleted in the two re-download goldens; every other golden is unchanged.
After an Android build, rake ruflet:install[] stops before Flutter runs, so whether the task passes an empty --device was invisible: planting `argv += ["--device", device]` without the empty check left every golden identical. On a Mac, install without a device installs the iOS build, so a new entry builds iOS first; the planted change now shows as `flutter install -d ""` in its golden. The existing 225 goldens are unchanged (226 in all). The railties cross-check now runs only where railties 8.1 or later is installed, the line lib/generator_stub and the rails_new_app fixture follow; with an older railties it skips instead of comparing against a different generator line. The README says so.
…ts loud The release fixture built its archives lazily, on the first request, with Zlib::GzipWriter. When the child was interrupted mid-deflate (under load, while the CLI's spawned children exited), GzipWriter#write sometimes raised Zlib::BufError inside the request for releases/tags/prebuild-main. The CLI's release_by_tag rescues StandardError, so the harness error looked like CLI behavior: the request vanished from `## network` and the client came from compat-latest, changing run-main.rb--desktop-release about 1 run in 14. - lib/release_fixture.rb builds every archive once, when it is loaded and before the CLI runs, in plain Ruby: gzip with stored deflate blocks, stored zip entries and a table CRC-32. It no longer loads zlib, the frozen bytes are the same on every run, host and zlib version, and the extracted files (all that reaches a golden) are unchanged. - An exception in harness code (tool emulation, recorders, the fake network, the release fixture, the page driver) is now a harness fault: the child writes it to its result and exits 70 at once, before any CLI rescue runs, and lib/harness.rb raises HarnessFault instead of rendering a golden. A child that exits non-zero, or cannot write its result, fails the same way with the reason. test_harness_faults_fail_loudly injects the BufError and checks it; test_release_fixture_archives_are_fixed_and_valid checks the archives load without zlib, are frozen and deterministic, and list and extract correctly with /usr/bin/tar and /usr/bin/unzip. Also from the review: - A file a stub created during the step and the CLI then deleted was in neither snapshot, so it was never reported. render_files now visits every stub-written path the snapshot covers, and the sensitivity probe deletes the adaptive launcher icon and expects its `D` line. - RUFLET_IOS_TEAM_ID's effect is pinned: build ios --self and build macos --self on default_app (no team configured) with RUFLET_IOS_TEAM_ID. The iOS project gets DEVELOPMENT_TEAM = ENVTEAM42; on macOS today it is the iOS project's team that is set (the D6 baseline). - RUFLET_CONFIG's directory is pinned: config/alt.yaml names assets/icon.png and assets/splash.png, which exist only under config/, and config/services.yaml beside it adds camera. - Rails page goldens: five new page goldens drive the endpoint config/routes.rb mounts, Ruflet::Rails.native(<app file>), through a hijacked socket pair with real WebSocket frames. That is the LocalServer/ConnectionProtocol path a Rails server uses (register_client without a page patch, then page.update op patches), which the Ruflet::Server page goldens never ran. The 226 existing goldens are byte-identical; 8 goldens are added (234).
AdamMusa
added a commit
that referenced
this pull request
Nov 8, 2026
Keeps this branch stacked on ruflet#73 (WP-00 H1) as it stands now, so the H1 goldens this PR must leave unchanged are #73's current 226.
AdamMusa
added a commit
that referenced
this pull request
Nov 8, 2026
Keeps this branch stacked on ruflet#73 (WP-00 H1) as it stands now, so the H1 goldens this PR must leave unchanged are #73's current ones.
test_release_fixture_archives_are_fixed_and_valid already checked that release_fixture.rb builds its archives at load, frozen and without zlib, and that a second build in the same process gives the same bytes. It now also compares the SHA-256 of every archive built by an independent Ruby process with the ones the test process built, so the bytes cannot depend on anything that differs between runs. Goldens are unchanged (234).
The page child's header says an error in the driver is a harness fault, but only the driver's explicit checks raised one. An IOError or SystemCallError on the client end of the Rails endpoint's socket pair (EPIPE, a reset, a closed stream) was caught by the app's `rescue Exception` and rendered as the app's "error" status. Those socket calls now raise HarnessFault, so the golden fails with the fault and --regenerate cannot write it. test_harness_faults_fail_loudly closes the client socket before the register frame and checks the fault. Goldens are unchanged (234).
AdamMusa
added a commit
that referenced
this pull request
Nov 17, 2026
2 tasks
…raps The README said test_harness_faults_fail_loudly injects only the Zlib::BufError and that 'the page driver' is covered. The test also injects a closed client socket in the --rails-endpoint page driver, and only that driver's socket I/O is wrapped; the Ruflet::Server-mode FakeWS is not.
AdamMusa
added a commit
that referenced
this pull request
Nov 17, 2026
A full check rendered run-main.rb--port_9000 with `exit: 1` and `<uncaught> Errno::EPERM: Operation not permitted`, while the plant under test touched only `ruflet install`. The stand-in for the app child is /usr/bin/true, so it has exited by the time `ruflet run`'s ensure signals its process group. macOS usually answers that with ESRCH, which the CLI rescues. It sometimes answers EPERM instead, even after wait2 has reaped the leader: 8 parallel loops of spawn(pgroup) / wait2 / kill(-pid) gave 99 EPERM in 16,000 signals. The CLI child now records its stand-in pids. When the real kill raises EPERM and every target is a stand-in, it raises ESRCH, the result every golden records. Signals to any other pid are untouched. test_signals_to_exited_stand_ins_do_not_change_goldens forces EPERM for every signal to a stand-in and requires run-main.rb--port_9000 and run-main.rb--desktop-release to render unchanged. Without the translation, both render exit 1 with the uncaught EPERM. The README also no longer lists backticks among the wrapped calls, since backticks are only recorded. Goldens are unchanged (234).
AdamMusa
added a commit
that referenced
this pull request
Nov 17, 2026
AdamMusa
added a commit
that referenced
this pull request
Nov 18, 2026
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.
What
WP-00 H1: compatibility goldens for the CLI and the page runtime. The PR only adds tests.
packages/ruflet/test/compat_goldens_test.rbcompares the goldens in the normal per-file test loop. R1–R4 (#74–#77, stacked on this branch) must keep every golden byte-identical. A later change that alters a golden regenerates it and lists the change under "Behavior changes".234 goldens live in
packages/ruflet/test/compat/goldens/:cli/<fixture>/<invocation>.txt). Each one records, in order, everyflutter/dart/pod/git/fvm/mrbc/codesign/PlistBuddy/tar/unzipcommand with its cwd and env. It also records the HTTP requests, the exit status, stdout/stderr, and every file written:build/clientas a diff against the vendored template, exports, the~/.rufletcaches, and anything else in the sandbox.Ruflet::Serverreply toregister_client, which is whatruflet runserves.--rails-endpointgoldens. They driveRuflet::Rails.native, the endpointconfig/routes.rbmounts, over a hijacked socket with real WebSocket frames.The corpus covers:
--self;The fixtures are the default app from
ruflet new, 9 docs examples copied verbatim, a services/extensions app, and two Rails fixtures (ruflet_rails_demois not used). ruflet-template is vendored ate32c873, which is still itsmain.packages/ruflet/test/compat/README.mdexplains how an invocation runs and what is stubbed.Verified on head
c2efb09bEach row was run locally on this head (Ruby 4.0.5, railties 8.1.4.1), after
mainat095cbf55(#67) was merged in.git diff --name-only origin/main HEAD -- . ':!packages/ruflet/test'ruflet.gemspecspec.files(lib, assets, README, bin) ships no test files.git diff --name-status f8be03ca HEAD -- packages/ruflet/test/compat/goldensA, noMorD. The first commit's 160 goldens are unchanged.maincd packages/ruflet && ruby test/compat/compat.rb --jobs 8checked 234 goldens, exit 0ruby -Ilib -Itest test/compat_goldens_test.rbtest/*_test.rbof ruflet, ruflet_core, ruflet_server and ruflet_rails in its own process, withRUFLET_TEMPLATE_ROOTset to agit archiveof ruflet-templatee32c873ruflet_core/test/dsl_presented_controls_test.rb.ruby test/compat/compat.rb docs-check --docs <ruflet_site>/app/content/docsat ruflet_site158e8a4(itsmain) and05dde18packages/, then the full check runs (no--only).c6085a77. X1 is new. A control plant that re-addsextend RunCommandexits 0 with nothing changed.test_harness_faults_fail_loudlyandtest_release_fixture_archives_are_fixed_and_valid, inside the goldens test aboveZlib::BufErrorin the release fixture, and a closed client socket in the--rails-endpointdriver. It checks that each one fails the golden instead of being rendered.test_signals_to_exited_stand_ins_do_not_change_goldens, inside the goldens test abovecli_child.rb,run-main.rb--port_9000andrun-main.rb--desktop-releaserenderexit: 1with<uncaught> Errno::EPERM.stress.rb(a scratch script, not in this PR) renders the 19rungoldens 150 times each, 24 at a time, on this head and on92149f2bside by side (load average 191–204)92149f2b: 1 diff in 2,850 (cli/default_app/run.txt,exit: 1with<uncaught> Errno::EPERM).git merge-tree --write-tree origin/<branch> HEADfor #74–#77The 54 plants (each against all 234 goldens)
verify_android_generated_assetschecked itvalues-v31/styles.xml, which a stub wroteRUFLET_CONFIG,RUFLET_IOS_TEAM_IDapply_build_configresolves assets againstruflet.yaml's directory, ignoringRUFLET_CONFIGservices.yamlread from the project root instead of beside the configios_signing_teamno longer readsRUFLET_IOS_TEAM_IDRUFLET_CONFIGignored when loading the configruflet.ymlfallback renamedRUFLET_CLIENT_DIRignored bydebugRUFLET_FLUTTER_VERSIONread under another name.fvmrclooked up elsewhereRUFLET_PORTfrom the parent env overrides the chosen portRUFLET_CLIENT_CHANNELignoredRUFLET_CLIENT_UPDATE_INTERVALignoredcli.rbextendsRunCommandandUpdateCommandafterBuildCommandandExtraCommand(X1)FlutterSdk#extract_archiverenamed, soRunCommand#extract_archiverunstar -xzfrelease_by_tagnever asks for the rolling release--force/ a due update no longer wipes the cacheruflet:install/ruflet:update--devicezinstead of--devicecommand_update([target, "--force"])--device ""when no device is givencommand_update(the R2 registry entry point)ruflet:update[]usage line rewordedruflet:buildtargetsaabnormalized toapkandroidrejected as an unknown targetlinuxrejectedwindowsrejectedmacosrejected (anddesktop, which maps to it on a Mac)ruflet:web, generatorruflet:webtask--desktopbin/devexport changes/wsroute changes itsvia:--verbosedoctordrops its--verbosebranchinstalldrops its--verbosebranchbuilddrops its--verbosebranchemulatorsaccepts only-vdebugaccepts only-vinstalldrops the-dshort flag--device-idto Flutterappbundlealias and casebuild appbundleno longer accepted (flutter_build_command)bootstrapalias dropped--dart-definename changesrungains--device IDbackend_urlvalue gains a trailing slashregister_page_patchdropstitlebuild_page_patch_opsskipstitleCI on
c2efb09b: "Build Ruflet Client Prebuilds" (run 44167883562) passed every job on attempt 1. In its Verify job (macOS arm64, Ruby 3.4.5),compat_goldens_test.rbgave 242 runs, 542 assertions, 0 failures, 0 errors and 1 skip. The skip is the railties cross-check, because CI has no rails gem. "Test Ruflet Explorer Desktop Builds" passed on Linux and Windows in both the pull_request run (44167883573) and the push run (44167876298).Behavior changes
None. The PR only adds tests.
Harness fix: EPERM for an exited stand-in
What happened. A full check on
92149f2brenderedrun-main.rb--port_9000withexit: 1and<uncaught> Errno::EPERM: Operation not permitted, while the plant under test changed onlyruflet install. The stress row above reproduces it on92149f2band shows it gone on this head.Why.
ruflet runspawns its app child in its own process group, reaps it withwait2, and then signals the group in itsensure, rescuing onlyESRCH. The harness stands in for that child with/usr/bin/true, which exits at once. macOS usually answers a signal to the reaped group withESRCH, but sometimes answersEPERM. A probe that runs 8 parallel loops ofspawn(pgroup)/wait2/kill(-pid)got 99EPERMin 16,000 signals.The fix.
lib/cli_child.rbrecords its stand-in pids. When the realkillraisesEPERMand every target is a stand-in, it raisesESRCH, the result every golden records. Signals to any other pid are untouched. The goldens are unchanged.Findings the goldens pin (current behavior, deliberately not fixed here)
FlutterSdk, notRunCommand.cli.rbextendsRunCommandandUpdateCommandbeforeBuildCommandandExtraCommand, and both of those includeFlutterSdk. SoFlutterSdk#extract_archiveand#download_filewin:Ruflet::CLI.method(:extract_archive).ownerisFlutterSdk.tar -xfandunzip -oq, andRunCommand'star -xzfand macOSdittobranch never run.extendorder decides this. Movingextend RunCommandandextend UpdateCommandbelowextend BuildCommandandextend ExtraCommandmakesRunCommandthe owner of both methods. The release goldens catch it (plant X1: exit 1, 14 goldens changed; macOSunzip -oqbecomesditto -x -k, and webtar -xfbecomestar -xzf).extend RunCommandafter the existing lines changes nothing, becauseRunCommandis already among the ancestors (control plant: exit 0, 0 changed).cli.rb, must keep this order or list the change.ruflet runcan end with an uncaughtErrno::EPERMon macOS. After the app child exits, theensureincommand_runsignals the child's process group and rescues onlyESRCH. macOS sometimes answersEPERM(see the harness fix above), and thenruflet runexits 1. The harness hides this only for its own stand-ins. RescuingEPERMthere would be a CLI bug fix for a separate PR.HIGH_SAMPLING_RATE_SENSORS<uses-permission>line inAndroidManifest.xmlchanges (services_app/rebuild-apk-server-after-self). This is relevant to X4.GADApplicationIdentifieris removed even thoughadsis selected (services_app/build-ios). This is relevant to SVC-04.rake ruflet:build[apk|android|aab|ios]fails with "must define app.package_name, app.organization", because the config the initializer generates replaces the user'sruflet.yaml. This is the D6 Rails-merge baseline.rake ruflet:webis documented but not defined. It appears inrails_integration.md:99,rails_api_reference.md:220andrails_native_html.md:14at ruflet_site158e8a4. The golden pins rake's "Don't know how to build task 'ruflet:web'".RUFLET_IOS_TEAM_IDonbuild macos --selfwritesDEVELOPMENT_TEAM = ENVTEAM42into the iOS project. The macOS project, whose template sets noDEVELOPMENT_TEAM, is not edited. D6 adds an explicitmacos.team_id.ruflet installwithout a device assumes iOS on a Mac.ruflet installandrake ruflet:install[]fail with "Could not find built app outputs under ./build".rake ruflet:install[]runsflutter installwith no-d.install --device=IDis not parsed. It falls back to the iOS default (install--device_emulator-5554).rails_app/generate-ruflet_install).--client bogusstops it after the route step with "--client must be desktop or none", yet it exits 0.--webproduces the same output as no flag.RUFLET_FLUTTER_VERSIONwithout FVM on the host runsdart pub global activate fvmand requests Flutter's release list. It then fails with "Flutter is required forruflet buildand FVM bootstrap failed."biometrics/local_authfail on the pinned template with "selected Flutter extensions are missing: ruflet_local_auth". This is CRIT-04.build --release apkgives "Unsupported build target: --release".run --device,emulators --cold, and unknown flags onrun,updateanddebugraise an uncaughtOptionParser::InvalidOption.run -dmeans desktop, which D6 keeps.Limits
test_generator_stub_matches_railties) runs only where railties 8.1 or later is installed; it ran locally and passed.--rails-endpointgoldens call the mounted Rack endpoint directly. Rails routing and middleware are not booted.network: "release"run offline (every request gets 503), so the plainruflet updateforms pin the failure.