Repository navigation
Compile morph's UI layer as a static library - #1120
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…urce morph::morph is now add_library(morph STATIC) instead of an INTERFACE target. Include dirs, link libraries and compile definitions are PUBLIC, both header file sets are PUBLIC and still verified, and the install rule gains an ARCHIVE destination. GenerateExportHeader writes morph/export.hpp (MORPH_API) into the binary dir, shipped through its own FILE_SET so build and install both find it; MORPH_STATIC_DEFINE is PUBLIC. The package version file is no longer ARCH_INDEPENDENT, since the package now holds an archive. src/ui/library.cpp holds fragmentOf and routeOfFragment, moved out of route_history.hpp (declarations stay, marked MORPH_API). apply_warnings, apply_sanitizers and apply_coverage are applied to morph. Coverage machinery now sees src/ui: coverage.sh SOURCES, the Codecov framework component, and check_branch_coverage.py, which scores src/ui under the include/morph/ui floor (self-tests extended; the new case fails when the prefix handling is removed). check_install_export.sh's consumer now calls a function from the compiled archive. With library.cpp reduced to an empty namespace the consumer fails to link (undefined reference to morph::ui::fragmentOf), so the check proves compiled code is linked. Sanitizer consumer audit (clang, AF_SANITIZER=asan, linux-everything options): 54 executables link libmorph.a. Six had no -fsanitize at link: the four examples/vetted_hmac executables and the two lims_cross_module_effects probes. They linked only because no archive member of libmorph.a was pulled in; the first moved symbol they use would fail on __asan_init. They now call apply_sanitizers; the re-audit shows 54 of 54 instrumented. Examples, benches, fuzz and soak targets already carried an AF_SANITIZER block. morph_guard_probe_deps and the try_compile probes do not link morph::morph (they link its dependencies or only take its include directories), so they are unaffected. Docs and comments that called morph header-only now describe the compiled static library. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Every out-of-class `inline` member definition, every in-class member body of two or more lines, and the `detail` free functions move to the compiled library. Classes with a moved member, and the structs among them, carry MORPH_API. A free function that something outside the interpreter calls (tests, host.hpp, the inspector, the workspace) keeps its documented declaration in the header with MORPH_API. One nothing else calls moves into an unnamed namespace in the .cpp, together with the helper types and the named constants only moved bodies read. One-line accessors stay in the header so a hot reader keeps inlining. Templates and constexpr stay; kMaxInlineFileBytes is unchanged. tests/bench_interpreter.cpp (hidden, tag [.benchmark][interpreter]) mounts a ui/1 document with a 200-row table and times a state change; bench_mount never reaches the interpreter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Includes. The compiled bodies carry the includes only they need: the bridge, the forms engine, the wire envelope, the message and locale tables, the chart scale and the backend's mount layer. The header forward-declares what its declarations take by reference or pointer (bridge::Bridge, bridge::BindSharing, the wire bodies, the forms sessions, ChartRange, Mounted). ElementState's constructor and destructor move out of line, because it owns forms sessions, and its copy and move are deleted. BridgeDispatcher::Channel is defined in the .cpp. Screen::_mounted becomes a unique_ptr, so the header needs Mounted only declared. kMaxInlineFileBytes is spelled as its value, and the .cpp asserts it equals the wire envelope formula it came from. host.hpp, preference_sync.hpp, ui_interpreter_support.hpp, test_push_cache.cpp and test_ui_interpreter_commands.cpp relied on interpreter.hpp for an include and now name it. preference_sync.hpp only failed the standalone interface-header-set check, which is not part of the default build. check_install_export.sh's consumer also calls an interpreter function (detail::base64Size), so an archive without interpreter.cpp fails to link. clang-tidy. Moving a body makes every line of it lintable, so the .cpp gets the const-correctness, trailing-comma, redundant lambda parameter list and string-view-conversion fixes, NOLINT reasons where a body implements an interface (the InterpreterHost defaults, the recursive menu walks, the two long element builders), and ScreenCore::chartSeries becomes static. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The parser, the validator, the kind and key tables, and the loader's entry points (`loadDocument`, `loadDocumentText`, `nodeKinds`, `documentLookup`) move to the compiled library. The header keeps the document model, the key and kind vocabulary types the interpreter reads (`KeySpec`, `KindSpec`, their flags), `NameCategory`, `listed`, and documented MORPH_API declarations of `findKind`, `pageGeometryOf` and `regionGeometryOf`, which the interpreter calls. The parser, the validator and every table they read are in an unnamed namespace in the .cpp; nothing else uses them. Includes the header no longer needs are dropped: a TU that includes only document.hpp peaks at 446 MB of front-end memory, from 728 MB. The page `margins` reading is split out of `pageGeometryOf`, and the table regions carry a NOLINT for readability-trailing-comma beside the existing one for designated initializers, so clang-tidy is clean on the moved code. The branch-coverage allowlist entries for document.hpp now name src/ui/document.cpp. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The parser, the checker, the evaluator, the function table and the unit and date helpers move to the compiled library. `parseExpression`, `checkExpression`, `evaluate`, `functionNames`, `walk`, `readDateValue`, `runRecord`, `splitPath`, `typeAlong`, `numeric`, `convertUnit` and `unitDisplay` keep documented MORPH_API declarations: the document loader and the interpreter call them. `StaticEnvironment` carries MORPH_API, with `control` and `report` out of line. The evaluator's body lives in an unnamed namespace as `EvaluatorCore`. The interpreter drives an evaluator directly to group and order table rows, so `detail::Evaluator` is a handle over it with `eval`, `sortOrder`, `sortRows` and `sameRun`; `evaluate` uses the core without the handle's allocation. Includes the header no longer needs are dropped: a TU that includes only expression.hpp peaks at 417 MB of front-end memory, from 544 MB. The branch-coverage allowlist entries for expression.hpp now name src/ui/expression.cpp, and the install check's consumer loads a document and evaluates an expression so it links the moved code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
UiRegistry's and UiService's member bodies of two or more lines move to the compiled library, and both classes carry MORPH_API. The `detail` helpers (checkServable, checkEntry, DocumentActions, permitsAll) have no user outside the moved bodies, so they live in the .cpp's unnamed namespace. UiService's screenAdmits is declared in the header and defined in the .cpp, because it calls one of them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…ient.cpp The member bodies of two or more lines of MemoryBundleStore, VerifiedCache, UiClient and FileTransfer, and the free functions exchangeOver, evaluationValue, evaluatorOver and watcherOver, move to the compiled library. Their declarations keep their Doxygen blocks in the header and carry MORPH_API. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
DocumentScreenHost's and the nested screen classes' member bodies of two or more lines move to the compiled library, along with identityKey, sameIdentity and titleText, which keep documented declarations in the header because workspace_model.hpp, the tests and the header's own lambdas call them. ParamsEnv has no user outside the moved bodies and lives in the .cpp's unnamed namespace. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Workspace's member bodies of two or more lines move to the compiled library, and the class carries MORPH_API. One-line accessors stay in the header. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…s_model.cpp ShellPartsModel's member bodies of two or more lines move to the compiled library, along with shellText and shellLabels, which shell_parts_binding.hpp calls and so keep documented declarations. builtinShellText has no other user and lives in the .cpp's unnamed namespace. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
ShellFrame's member bodies of two or more lines move to the compiled library, and the class carries MORPH_API. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
TableWidget::setRealizedWindow, IViewBackend::createCustom and widthClassOf move to the compiled library; the widgets' one-line accessors stay in the header. TableWidget and IViewBackend carry MORPH_API. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Every `inline` function of the token and theme readers moves to the compiled library. The ones that tests, the Qt Quick and TUI renderers, the service or the interpreter call (colorOf, parseTokens, resolveTokens, parseThemeIndex, resolveTheme, checkTheme, themeValues, themeProblems, themeContrastProblems, unreadThemeTokens, iconGlyph, isIconName, isThemeIndex, and the detail numberOf, hexColor, channelOf, aliasOf, pixelsOf, shadowOf, familiesOf and the colour-maths helpers) keep documented declarations with MORPH_API. The readers, the checks and AliasResolver have no other user and live in the .cpp's unnamed namespace. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Explorer's member bodies of two or more lines and the free functions actionUses, actionFields, tryItScreenId, tryItDocument, schemasOf and tryItCatalog move to the compiled library. The scope walk and the text helpers have no other user and live in the .cpp's unnamed namespace. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Navigator's member bodies of two or more lines move to the compiled library, and the class carries MORPH_API. The one member template stays in the header. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…c's header-only claim theme.hpp no longer includes bundle.hpp and control_shape.hpp (884 MB alone, front end), and service.hpp drops the logger, wire, session, catalogue and shell-parts includes its remaining declarations do not use. The reload note in docs/spec/ui/service.md says the functions live in the morph library. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Const-correctness, redundant lambda parameter lists and trailing commas are applied, with the designated initialisers the trailing-comma fix-it mangled restored by hand; the check's empty-brace misfires, the menu walks' recursion and the interface-bound signatures carry NOLINT with their reason. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
A stray semicolon after the closing namespace brace in three .cpp files, and a second declaration of detail::weightOf in theme.hpp. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Placement of the suppressions that the move left behind (a theme NOLINTBEGIN without its END in either file), plus the findings the new translation units raise on their own: short names, nested conditionals, unchecked optionals, range loops and emplace. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The consumer already links a call into the interpreter, the document loader and the expression language; a registry that refuses a file of an unknown kind and builds a bundle proves the service's compiled half is exported as well. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The turn state, the shared state a turn's callbacks keep alive, and every service entry point move to the compiled library; the header keeps the class, its options and forward declarations of the private nested types. The header no longer includes the document, the bundle, the protocol, the screen tools or the logger, so a translation unit that names ChatService stops paying for them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Source only needed the alias for a model's schemas document, which now lives beside the other bundle types; the explorer pulls in the forms engine, which a translation unit that only names a source has no use for. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Yaraslaut
force-pushed
the
feat/compiled-ui-library
branch
from
November 15, 2026 09:49
e04db35 to
fd83fb7
Compare
Yaraslaut
marked this pull request as ready for review
November 15, 2026 10:04
…d code clang-format-22 flagged a doubled blank line in bundle.hpp and an over-long comment line in chat_service.cpp. clang-tidy-diff flagged three changed declarations: Handle's two bases both carry default bodies, so the multiple-inheritance check is suppressed with that reason; confirm's `no` parameter is too short and becomes `noLabel`; channelOf's declaration drops a top-level const. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
GCC 15 at -O3 reports -Walloc-zero inside libstdc++'s regex executor, and gcc-release treats warnings as errors. A small hand-written parser reads the same `role: "#digits"` lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The table names every module's actions, so its header pulled in all five authorization headers and through them every model: about 7.7 GB of GCC memory at -O0 -g in each screen test that includes lims_authorizer.hpp. The header now declares the lookups; the table and its includes live in app/src/declared_requirements.cpp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The model headers declare each model and action; the registrars compile once, in the model's source file, instead of in every translation unit that includes the header. The org authorization header no longer includes the org model. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
The model headers declare each model and action; the registrars compile once, in the model's source file, instead of in every translation unit that includes the header. The lab authorization header no longer includes the module's models, so a model header and its authorization header form no include cycle. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…aders The model headers declare each model and action; the registrars compile once, in the model's source file, instead of in every translation unit that includes the header. The billing authorization header no longer includes the module's models, so a model header and its authorization header form no include cycle. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…ders The model headers declare each model and action; the registrars compile once, in the model's source file, instead of in every translation unit that includes the header. The ledger authorization header no longer includes the module's models, so a model header and its authorization header form no include cycle. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…headers The model headers declare each model and action; the registrars compile once, in the model's source file, instead of in every translation unit that includes the header. The inventory authorization header no longer includes the module's models, so a model header and its authorization header form no include cycle. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…ation unit includes fewer models The shell test's probe bundles, its seeding of people and the approval inbox's lab and bundle move into translation units of their own, so the tests that drive the screen harness no longer include every module's models. The shell and screens tests are each split in two. The declared requirements table includes the models whose action ids it names, now that an authorization header no longer brings them in. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…world's helpers static The shell test's JSON scan added an int to a size_t; GCC's sign-conversion error stops the build. Two of the approval-inbox world's helpers use no member state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
Trailing commas, designated initializers, a longer identifier than `id`, const fixtures, no unused using-declarations, and the shell test's German menu lookup in a function of its own to keep signedIn under the cognitive-complexity threshold. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
…parses the page query
The collator's fold was one expression of thirty nested replace calls over
lower(). SQLite before 3.46 parses with a fixed 100-entry stack, and that
nesting overflows it ("parser stack overflow"): on the Ubuntu 24.04
runners (SQLite 3.45.1) every lims sample and ledger page with a text
filter or text sort failed. Each folded expression is now computed as a
column of a three-stage WITH chain, ten replace calls per stage, and the
filter and ordering name that column.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj
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.
morph::morphstops being header-only: it is now aSTATIClibrary, and the UI layer's non-template code lives insrc/ui/*.cpp. Every translation unit that includes a UI header used to recompile all of that code, which is what pushed single compiles past what a GitHub-hosted runner (16 GB, 4 CPUs) can hold.Design:
docs/superpowers/specs/2026-11-14-compiled-ui-library-design.md. Part of #1118. Part B, an optional shared build (MORPH_BUILD_SHARED), follows in its own PR.What moved
interpreter.hpp: 11,077 → 2,840 lines.document.hpp: 5,648 → 775 lines.expression.hpp: 3,184 → 620 lines.service,service_client,host,workspace,shell_frame,shell_parts_model,backend,theme,explorer,navigator. Most halved or better.ui/chat/service.hpp.client/source.hppno longer includesexplorer.hpp.Build plumbing
GenerateExportHeaderprovidesMORPH_API, which every moved declaration carries.src/ui.Peak compile memory (measured)
tests/test_ui_shell_parts.cpp, g++ -O3 (gcc-release)tests/test_ui_interpreter_commands.cpp, g++ -O3examples/lims/screens/tests/test_lims_ignition_screen.cpp, clang coverage#include <morph/ui/interpreter.hpp>alone, clang coverageThe lims figure misses the design's 2 GB goal. The remaining cost is in
core/remote.hppand in whatinterpreter.hppstill has to declare. The gcc-release goal (3.5 GB per UI test TU) is met.Interpreter benchmark (clang -O3,
[.benchmark][interpreter]), within noise:Verified locally, on the rebased head
clang
linux-everything: every target builds, including Qt, Qt Quick, TUI and the lims rungs. ctest passes 5712/5712, excludinglims|Stress|load|soak|fuzz; the lims suites pass 622/622 separately.gcc-debug: full build with no warnings, and ctest passes 4170/4170 with the same exclusion.
*_verify_interface_header_setstargets build, andscripts/check_install_export.shpasses.llvm-cov shows the moved files counted:
document.cppexpression.cpptheme.cppservice.cppThis is from a 4-file subset of the tests, not the whole suite.
Mutation controls: one moved function each in the interpreter, document, service and chat code was broken on purpose, and a test failed every time.
Not verified locally
readability-trailing-commain four moved files, and flags the same in untouched files.🤖 Generated with Claude Code
https://claude.ai/code/session_01No1Nzo5wbYPDDynGBphgqj