Repository navigation
feat: warn when the template lacks a control, service or extension the app uses (CRIT-04b) - #80
Merged
Merged
Conversation
Adds test/template_surface_test.rb, red on this commit. An app using `form` against a template surface that predates it is warned, with the location of the call and the first ruflet-template revision that renders Form; --strict makes that an error. Against the new surface nothing is printed. A template without a surface file, or an unreadable one, is not checked. Services and bundled extensions are reported the same way. Usage counts only receiverless method calls (not comments, strings, symbols, locals, receiver calls or methods the app defines), a Rails app is read from app/views/ruflet, nothing outside a Ruflet project is read, and no app file is read when the template has everything. Adds nine H1 invocations, generated on this code: build, run and doctor on default_app with and without a main.rb that uses form, and with --strict. Today none of them warns; `build --strict` is forwarded to flutter build, and `run --strict` and `doctor --strict` are unknown flags.
…e app uses (CRIT-04b) build, run and doctor read the template's tool/conformance/ruflet_control_surface.json (the wire types it renders) and its ruflet_packages/ (the extensions it bundles). When the app calls a control or service the template does not render, or selects a bundled extension it does not ship, they print a warning on stderr naming it, the file and line of the first call, and the first ruflet-template revision that has it. Exit codes are unchanged. --strict (new on all three) makes it an error: build and run stop with exit 1 before preparing anything, doctor finishes its report and exits 1. Nothing is printed when the template has everything the app uses, and a template without a surface file (older templates) or an unreadable one is not checked. The check never raises and fetches nothing. The revisions come from packages/ruflet/lib/ruflet/cli/ template_surface_revisions.rb, generated by tools/template_surface_revisions.rb from this checkout's registries and a ruflet-template clone's history (--offline when only the registries changed). The ruflet gem does not depend on ruflet_core, so the CLI reads that table rather than the registries. A test fails when the table is stale. Usage is found with Ripper: receiverless method calls of the names the template lacks, minus methods the app defines. Files are read only when the template lacks something (about 1 ms on an app, 0.3 s on a 2,001-file one against an old template), from app/views/ruflet in a Rails app, and never outside a Ruflet project. H1: --strict appears in build, run and doctor help. The biometrics fixtures, whose build already fails because the pinned template has no ruflet_local_auth, now get the warning naming the revision first. The new form fixtures warn, and fail with --strict. Without form, --strict changes nothing.
This was referenced Nov 17, 2026
…ositives - Ruflet::CLI resolves download_file and extract_archive to FlutterSdk, as on main; TemplateSurfaceCheck is in no command module's ancestors. - Wire types are dated from 19ac4c9e, the first surface that lists what its renderers handle; Lottie, Picker, CodeEditor and the rest of what older surfaces leave out are not reported. - attr_reader, attr_accessor, let, let!, define_method, alias and the other definers define names; spec/ and test/ are not read. - doctor reads the config only when the template lacks a bundled package, and quietly. - Three H1 invocations, generated with main's lib (9f2ca79): an app with attr_reader :table plus spec/ and test/ files (build apk --self, run), and doctor with a ruflet.yaml that does not parse.
…lse positives - TemplateSurfaceCheck is called with the command object instead of being included in RunCommand, BuildCommand and ExtraCommand. Including it moved FlutterSdk below RunCommand in Ruflet::CLI's ancestors, so run --web and --desktop, update, rails ruflet:update_all and the Flutter SDK download ran RunCommand's download_file and extract_archive (tar -xzf, ditto). - tools/template_surface_revisions.rb dates wire types from 19ac4c9e (the first surface that lists what its renderers handle), so templates from 0c02f475 to 32cd174 are no longer told they lack Lottie, Rive, Picker and the other controls they render. Packages are still dated from 0c02f475, and the table lists all of them in EXTENSION_PACKAGES. - attr*, define_method, alias/alias_method, def_delegator(s), delegate, let/let!/subject, belongs_to/has_one, Struct.new and Data.define count as definitions; spec/ and test/ are not scanned. - doctor reads ruflet.yaml/services.yaml only when the template lacks a bundled package, with stderr silenced, so it prints nothing new for a config it cannot parse. - The warning says what a lacking template means for any of the three commands: an app built from it shows "Unknown control".
…parse The walk stops after 50,000 directory entries, so a large asset tree cannot slow build or run. Ripper is required the first time a file may call a name the template lacks, so loading the CLI costs what it did before the check.
Declared through OptionParser, --strict made -s, --s, --st and the other abbreviations OptionParser completes mean --strict; on main they are unknown flags (exit 64), as cli_commands_test pins. run now takes --strict out of argv before OptionParser runs, and Commands options gain exact: to declare such a flag; the registry tests leave exact options out of the switches they expect the parser to define.
…d gems `ruflet doctor --fix` refreshes only the cached template, but RUFLET_CLIENT_DIR, RUFLET_TEMPLATE_ROOT and a ruflet-template checkout beside ruflet take precedence over it. The advice now names that source. The project walk prunes RubyGems install directories (specifications/ and gems/), such as gems/ruby/3.4.0 after `bundle config set path gems`. Tests pin what the review found unguarded: run reads the script it was given from outside the project, MAX_FILES, MAX_FILE_BYTES, the root-prune guard, Rails detection needing config/application.rb, the recorded client revision, and doctor's lazy config. The wall-time assertion is replaced by a parse count.
run --web and --desktop open the client in RUFLET_CLIENT_DIR, and ruflet build uses it, so the surface check reads that client's surface instead of the installed template's. Tests pin the six review plants that survived: a relative RUFLET_CLIENT_DIR in the advice, line numbers compared as numbers, doctor reading ruflet.yml, the three-kind count wording, define_method with a quoted symbol, and the ruflet.yml marker.
The surface warning named the git HEAD two directories above the checked template. For a client in RUFLET_CLIENT_DIR that is the app's repository, not a template revision. A recorded .ruflet-template-revision still comes first, and the cached template and checkouts are unchanged. Also: a doctor exit-code test (--strict exits 1 only after flutter doctor succeeds), and two H1 goldens for run --web --strict with a RUFLET_CLIENT_DIR client that renders Form and one that lacks it.
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.
WP-00 CRIT-04(b).
#79 has merged.
main(f8058191) is merged in with merge commite77094e5, so the diff againstmainnow shows only this PR's files. The only conflict wasextra_command.rb: doctor now takes its exit code from #84'ssystem_exit_code, then applies--strict. Earlier merge commits:6f629781(#79's branch, before #79 merged),3199b905,88669d87,89d12dd6and781a20ed. This PR's own commits:4f7e5fa6,345aa123,b3edbfd6,f25783f9,58f7c9d0,383d776d,b82e3500,626a2420,ec23981eand3c748db5.Depends on AdamMusa/ruflet-template#2 (CRIT-04a, prepared and not merged, per D1). #2 is at
cd3b8aa0and containse793ccefandcdbc2aaf. The revisions table names those two commits, and they exist only on #2:ruby tools/template_surface_revisions.rb --template-repo ../ruflet-template --ref origin/main.ruflet doctor --fixcannot fetch yet.What
ruflet build,ruflet runandruflet doctorread two things from the Flutter template:tool/conformance/ruflet_control_surface.json, the wire types it renders;ruflet_packages/, the extension packages it bundles.They print a warning on stderr when the app calls a control or service the template lacks, or selects a bundled extension it lacks. The warning names the item, the file and line of its first call, and the first ruflet-template revision that has it:
The last line says where to get a newer template.
ruflet doctor --fixrefreshes only the cached template, and each of these takes precedence over it:RUFLET_CLIENT_DIR: "Update the client in RUFLET_CLIENT_DIR from the latest ruflet-template (ruflet doctor --fixdoes not change it)".RUFLET_TEMPLATE_ROOT: "Update the template in RUFLET_TEMPLATE_ROOT to the latest ruflet-template (…)".The revision in parentheses comes from the checked directory's
.ruflet-template-revisionfile. Without that file it is the installed template's revision: the cached one's, or a checkout's git HEAD. Any other directory, such as aRUFLET_CLIENT_DIRclient without that file, gets no revision.Behavior:
main.--strict, new on all three commands, makes it an error:buildexits 1 after it copies the template intobuild/client, before Flutter runs or the client is configured.runexits 1 before the server starts.doctorfinishes its report,flutter doctorincluded, then exits 1. Ifflutter doctorfails, doctor keeps that exit code.buildchecks the installed template thatbuild/clientis copied from. A customRUFLET_CLIENT_DIRis checked as its own template.runchecksRUFLET_CLIENT_DIRwhen it names a directory.run --weband--desktopopen that client, andbuilduses it. Otherwiserunchecks the installed template. Ruflet Explorer and the prebuilt clients are not built from it, so in that case the warning is about the template aruflet buildwould use.doctorchecks the installed template it reports.How usage is found.
form(...),form do,form key: 1and a bareform.def, that coversattr,attr_reader,attr_accessor,define_method,alias/alias_method,def_delegator(s),delegate,let/let!/subject,belongs_to/has_one,Struct.newandData.define, with symbol, quoted-symbol or string names.form_with) do not count.config/application.rbandapp/views/ruflet/): onlyapp/views/ruflet/**.main.rb,ruflet.yaml,ruflet.ymlorservices.yaml. The walk skipsbuild,vendor,node_modules,tmp,log,coverage,public,storage,spec,test, dot directories and RubyGems install directories. It reads at most 50,000 directory entries and 5,000 files, each at most 1 MB.runalso reads the script it was given, wherever it is.Extensions come from the same
extensions:/services:selection the build makes.doctorreadsruflet.yaml,ruflet.ymlorservices.yamlonly when the template lacks a bundled package, and it reads them with stderr silenced. Templatemainlacksruflet_local_auth, so todaydoctordoes read them.Minimum revisions. The
rufletgem does not depend onruflet_core, so the revisions come from a generated table,lib/ruflet/cli/template_surface_revisions.rb.tools/template_surface_revisions.rbbuilds it from this checkout's registries and the template's history, and has--offlineand--checkmodes. Wire types are dated from19ac4c9e, the first surface that lists every wire type its renderers handle. 33 wire types map toe793ccef, among them Form, NestedScrollView, the transitions, slivers, Table, Stepper and LocalAuthentication. Packages are dated from0c02f475.ruflet_local_authis atcdbc2aaf.Rework since the review of
626a2420mainis merged in, soflutter_tooling.rb,build_path_flags_test.rbandcli_child.rbnow equalmain's.run --strictchecked the installed template even withRUFLET_CLIENT_DIRset (ec23981e).runnow checks that client, asbuilddoes. The body's "Which template is checked" text is corrected to match. Two new H1 goldens cover it, both withRUFLET_CLIENT_DIRand with the installed template lacking Form:run main.rb --web --strictwith a client that renders Form: it serves, exit 0;<PROJECT>/my_clientand theRUFLET_CLIENT_DIRadvice, exit 1.RUFLET_CLIENT_DIRclient was given the app's git HEAD as its revision (3c748db5). Only the cached template and…/templates/ruflet_flutter_templatecheckouts get a git revision now.RUFLET_CLIENT_DIRin the advice;ruflet.yml;define_method(:"form");ruflet.ymlproject marker.--strict's exit 1.Behavior changes
Compared with
main(f8058191), exactly 24 H1 goldens differ because of this PR. All are additive, per D1 (warn by default):mainformagainst templatemain)services: [biometrics]against templatemain)build config error: selected Flutter extensions are missing: ruflet_local_auth, exit 1cdbc2aafbuild … --strict--strictforwarded toflutter build(Flutter 3.41.2:Could not find an option named "--strict", exit 64)run … --strict,doctor --strictinvalid option: --strict, exit 64build/run/doctor-h/--help,help build,--help build,run/doctor --bogus-flag--strictThe goldens:
build-apk--self-form,run-main.rb-form,doctor-form;build-{apk,ios}--self-biometrics;build-apk--self--strict[-form],build-apk--self--strict-form-explicit-template;run-main.rb--strict[-form],run-main.rb--web--strict-form-with-RUFLET_CLIENT_DIR[-lacking-Form];doctor--strict[-form];{build,run,doctor}--{h,help},help-build,empty/--help-build;run--bogus-flaganddoctor--bogus-flag.Tests (final head
3c748db5, Homebrew Ruby 4.0.5,GEM_HOMEunset)ruby test/compat/compat.rb --jobs 4checked 358 goldens with 0 failing, on Ruby 4.0.5 and on rbenv 3.4.5.main(f8058191).test/compatrun withmain's lib: "358 goldens, 24 failing", exactly the 24 above.main's owntest/compatrun with this head's lib: "343 goldens, 12 failing". Each of the 12 only adds lines: the warning, or the one--stricthelp line.packages/ruflettest file passes in its own process: 27 files, 892 runs, 0 failures, 0 errors. That includestest/template_surface_test.rb(50 tests) andcompat_goldens_test.rb(366 runs).template_surface_test.rb. So are 5 new plants on this round's code:run_rootignoresRUFLET_CLIENT_DIR;run_rootskips the directory-exists check;run_roottakes a blank value;--strict's exit 1.The unplanted copy passes.
tools/template_surface_revisions.rb --checkreports the table current in these cases:--offline;origin/main(8b085697) plus remove the hard coded icons #2 (cd3b8aa0);git merge-tree).With template
mainalone it reports the table stale, which is the documented dependency on remove the hard coded icons #2. Templatemain's surface file andruflet_packages/are unchanged frome32c873, which the H1 harness vendors.rubyblocks in ruflet_sitemain(556d737) against templatemain's surface. Each of the 19 calls one of the 33 wire types that templatemainlacks.3c748db5: every job passed, including Build Android and "Verify Ruflet Explorer" (Ruby 3.4.5:template_surface_test50 runs,compat_goldens_test366 runs). Publish was skipped.Not in this PR
<form>to a column, not to Form.--strictand the warning in ruflet_site'scli_reference.mdcome in a follow-up docs PR.git merge-treereports no conflict with any open PR (Test what every control and service method sends; fix unset values sent as {} and map stack overflows #87, Register extension packages inside the extensions list, not the import block #91, fix: send default alignment, padding and radius in shapes the renderer reads #100).