mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-31 01:31:10 +00:00
* feat(generator): remove --provider-header (interface: "provider")
Every provider now goes through the module-impl C ABI, so the LOGOS_METHOD
dispatch path is gone: parseProviderHeader, generateProviderDispatch,
ParsedMethod and the joinDocLines helper only it used (~300 lines), plus the
test that covered it.
`toQVariantConversion` is NOT removed — it is shared with live emitters — and
its test stays.
The flag is REFUSED rather than dropped. Without that, `--provider-header x.h`
falls through to the plugin-path branch, which reads the flag itself as a
plugin path and reports "Plugin file does not exist: --provider-header" — a
missing-file error for what is really a retired mode. It now exits 2 with a
message pointing at interface: "universal".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(sdk): logos_host_services.h — the C++ veneer over the privileged surface
Phase C1. A Qt-free, header-only wrapper over the three trust-root lp_* calls
A3 added, so capability_module can become an ordinary universal module instead
of a hand-written Qt plugin reaching into TokenManager directly.
Deliberately FREE FUNCTIONS, not a LogosModuleContext seam as the plan
sketched. The grant is process-global per IMAGE (host binary and module cdylib
each link their own logos-protocol, so each has its own grant state and its own
TokenManager), so the gate lives in the caller's own image and there is nothing
per-instance to inject; a context seam would imply the privilege is a property
of one impl object, which it is not. It is also markedly cheaper: a seam would
need a new module-impl C ABI export plus lockstep changes in BOTH codegen paths
(the Qt provider glue and the cdylib wrapper).
constantTimeEquals lives here rather than in each caller: the natural spelling
(a == b) leaks the matching-prefix length through timing, and a trust root
comparing tokens with == is the exact bug this file exists to prevent. Ported
from capability_module's own implementation to std::string.
Two things the tests caught that reading had not:
* lp_inform_module_token_to takes SIX arguments (client, auth_token,
origin_module, module_name, token, timeout_ms), not the three I first wrote.
The wrapper now mirrors it exactly, with the protocol's own default-timeout
semantics documented.
* sdk_tests compiles against logos_headers alone, which carries no protocol
include path. It now resolves logos_protocol.h from LOGOS_PROTOCOL_ROOT,
accepting either the source layout (cpp/) or a package layout (include/) and
failing loudly on neither, rather than hard-coding the one in use today.
The suite deliberately does NOT link logos-protocol: the lp_*-calling wrappers
are `inline` and never ODR-used by these tests, so no protocol symbol is
referenced. That is itself the assertion — the veneer must not drag the
protocol library into a header-only consumer. A future test that calls one will
fail to LINK rather than silently pull it in.
Also documents a real gap found while writing it: lp_token_get performs NO
host-service check, so "token_registry" gates ENUMERATION only. The plan claims
that service covers `lp_token_get(any)`; it does not. Flagged at the call site
rather than papered over — if lookup should be gated, the gate belongs in
lp_token_get.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(generator): emit logos_module_grant_host_services in the cdylib exports
Completes the C1 codegen half. A3 declared this entry point in
logos_module_impl.h and documented that the grant MUST cross the C ABI, but the
generator never emitted it, so nothing could open a module's gates.
The body forwards to lp_grant_host_services in the MODULE's own image, which is
the entire point. Verified that premise on a real built module rather than
taking it from the header comment: test_basic_module_cpp_plugin.dylib DEFINES
25 lp_* symbols and imports zero — logos-protocol is statically linked into
each plugin, so the module's gate state really is its own, and a grant recorded
only in the host would leave lp_token_keys() returning null forever. That
failure is silent: null is indistinguishable from an empty token store.
Emitted unconditionally rather than behind a codegen flag. Which modules are
privileged is the host's decision — it pushes nothing to an ordinary module —
and lp_grant_host_services validates the names and fails closed, so a per-module
flag would only add a second place for declaration and capability to disagree.
The comment states the boundary honestly: this is a declaration-and-audit
mechanism, NOT a defence against a hostile module. The cdylib links
logos-protocol, so its own code can call lp_grant_host_services() directly and
self-grant. What the gate buys is that the privilege is explicit, greppable and
off by default. Isolation between modules rests on process separation, the auth
token, and the target's allowedCallers.
Three tests, one per property that could regress independently: the export
exists; its body actually forwards (a stub returning 0 would make every host
push look successful while both gates stayed shut); and it is emitted for an
ordinary module too, not only for privileged ones.
Confirmed in the built artifact: nm on a real universal module lists
_logos_module_grant_host_services alongside the other seven module-impl exports.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(generator): guard the grant export on the protocol MINOR that added it
The emitted logos_module_grant_host_services calls lp_grant_host_services,
which logos-protocol only gained at MINOR 3. A module built against an older
protocol therefore failed to compile in GENERATED code its author never wrote.
Found by giving logos-template-module a standard flake: its own lock resolves
protocol master, and the build died on `use of undeclared identifier`.
Guarded on LOGOS_PROTOCOL_VERSION_MINOR >= 3. A module built against 0.2 has no
grant entry point at all, which is the same fail-closed state as never being
granted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs: point logos_async_result.h at the one LogosModule.cmake
The comment named "logos-plugin-qt/cmake/LogosModule.cmake and its
module-builder twin". There is no twin any more: logos-plugin-qt's copy is
deleted and the file exists once, in logos-module-builder.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): rev-pin logos-protocol at c8bab12 (the trust-root surface)
logos_host_services.h is a veneer over lp_token_keys /
lp_inform_module_token_to / lp_grant_host_services, which landed on
logos-protocol's feat/per-client-token-store branch and are NOT on its
master — master is still LOGOS_PROTOCOL_VERSION_MINOR 2, so the `tests`
check could not compile against the previously locked 03842db.
Rev-pinned in the URL rather than left master-tracking, because
`nix flake update` cannot reach a commit that is not on the tracked
branch. Re-point at master once that branch merges.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor(generator): remove --module-dir, and the two dead files it documented
--module-dir walked a directory of BUILT plugins and generated one consumer
wrapper per dependency by dlopen'ing each and reading its QMetaObject. Every
wrapper now comes from a contract instead -- `--general-only` with one
`--dep <name>=<name>.lidl` per dependency -- which builds no dependency plugin
and, unlike introspection, works under cross-compilation.
It is REFUSED rather than ignored, mirroring --provider-header right below it.
Falling through to the dependency LISTING would have exited 0 having generated
nothing: the exact shape that lets a stale caller look green while shipping a
module with no typed API.
No nix build changes as a result -- the flag had no caller left in any of them,
so a store-path diff would be empty either way and would prove nothing. The
only observable difference is what the binary does when handed the flag, so
that is what the new `generator-cli` check asserts, by EXIT CODE:
OK: control - --metadata alone exits 0 and lists dependencies
OK: --module-dir exits non-zero (status=2)
OK: --module-dir fails with the removal diagnostic
OK: --general-only still emits the umbrella
The control matters: without it a non-zero exit could equally mean the binary
is broken. It runs against an EXISTING modules directory too, because the old
code only errored when that directory was missing.
Also deleted, both genuinely dead:
* cpp/compile.sh -- compiles logos_api.cpp, module_proxy.cpp, token_manager.cpp
and six headers, NONE of which exist in this repo any more (they moved to
logos-protocol / logos-qt-host in the host split). The script cannot run.
* docs/docs.md -- 789 lines with zero inbound references anywhere in the
workspace, documenting --module-dir and a cpp/ layout that is gone.
cpp-generator/compile.sh is KEPT: logos-module-builder's LogosModule.cmake:404
still invokes it (`add_custom_target(cpp_generator_build ...)`) on the
LOGOS_CPP_SDK_IS_SOURCE branch, and it builds into exactly the
LOGOS_DEPS_ROOT/build/cpp-generator path that file then reads.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor(generator): the umbrella emitter leaves legacy/, and gets its own mode
`cpp-generator/legacy/` held four things and only one was legacy. The shared
emitter library was misfiled there: `generator_lib.{h,cpp}` is already consumed
by the MODERN `experimental/lidl_gen_client.h` and by all 11 tests under
tests/generator/. `lidl_to_json.{h,cpp}` likewise. Both are now
`cpp-generator/`; `legacy/` is down to `main.cpp` + `legacy_main.h`.
The logos_sdk umbrella (`struct LogosModules`) is not legacy either — it is the
CURRENT typed-dependency surface. `LogosModuleContext::modules()` returns it,
so every universal module that calls a declared dependency goes through it, and
LogosModule.cmake runs `--general-only` for every module build. Yet the only
code that could emit it lived inside the directory the plan wants deleted.
So `cpp-generator/main.cpp` gains `--umbrella`, with `--general-only` routed to
the same implementation and dispatched before the fall-through to legacy_main.
The deps-driven emission needed no rewriting: `makeUmbrella{Header,Source}
FromDeps` were already in generator_lib, and legacy/main.cpp merely wrapped
them in file I/O. -352 lines from legacy/main.cpp (827 -> 475), including the
interface-wrapper helpers that only that branch used.
`--general-only` keeps working identically, because LogosModule.cmake and
logos-basecamp both call it. The alias is guarded on `--metadata`, since
`--general-only` was never a standalone mode — without metadata it fell through
and reported the flag as a missing plugin path, and it still does.
The scraping `writeUmbrellaHeader`/`writeUmbrellaSource` are untouched: they
belong to `generateFromPlugin`, the QPluginLoader introspection path, and die
with it.
Verified byte-identical, which is the whole claim of a relocation. An
adversarial pass built its own pre- and post-change binaries and diffed the
emitted `logos_sdk.{h,cpp}` across 12 real metadata.json files x {qt,lp} x
{--general-only,--umbrella}: 48/48 identical, stdout/stderr/exit included, with
a positive control (qt vs lp) confirming the harness can see a difference. Real
modules then built through logos-module-builder against both binaries with
`diff -r` empty, including the compiled plugin. 266/266 tests pass, and the
pre-change tree also reports 266, so no test was silently dropped.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(sdk): split the SDK by capability, and add the host façade
Host, module-consumer and module-provider are three distinct capabilities. The
SDK exposed them as one target, so a program linked all three regardless of
what it was. Each now gets its own INTERFACE target:
::common logos_json.h, logos_result.h
::consumer logos_lp_client.h, logos_async_result.h
::provider logos_module_context.h, logos_host_services.h
::host logos_host_core.h (new)
`logos_headers` stays as an umbrella over all four, so the ~70 existing
consumers are unaffected — logos_module_context.h alone has 66. Migrate to the
narrow targets when touching a repo; additive first, removal second.
NOTE the misnomer the split exposes: `logos_host_services.h` is MODULE-side
despite its name — it is the veneer a privileged module uses for services the
host granted it — so it belongs to ::provider, not ::host. Renaming it touches
9 files across 5 repos, so it is left for a change that can carry that cascade.
── logos_host_core.h ───────────────────────────────────────────────────────
`logos::host::LogosCore`, a plain RAII wrapper over liblogos' logos_core_* C
API, for the four programs that stand up a core (basecamp, logoscore-cli,
standalone-app, module-viewer). They currently open-code the same calls, and
basecamp had already grown a private wrapper for them.
It is deliberately an ORDINARY class — no codegen, no injection seam, no
void*. LogosModuleContext needs `_logosCoreSetContext_`, SFINAE `maybeSet*`
helpers and a void* round-trip because a module impl is user-authored but
FRAMEWORK-instantiated. A host is main(): it constructs this itself. For the
same reason there is no `modules()` here — the host holds its own LogosModules
from its own generated logos_sdk.h, so this header needs no generated type.
What it earns, each tied to a measured hazard:
* OWNERSHIP. liblogos allocates its char**/char* returns with new[], so
`delete[]` is correct and free() is undefined behaviour. That rule lived in
a comment in one repo's .cpp; it is now in one place.
* ORDERING. Three setters must precede logos_core_start(), stated only in
comments in logos_core.h. They are constructor arguments here, so the
illegal order is not expressible.
* SHAPE. logos_core_get_module_stats() takes no module name and returns one
blob for every module; stats(name) does that parse once.
The logos_core_* ABI is re-declared rather than included: logos-liblogos
depends on logos-cpp-sdk, so including its header would invert the graph. Every
host already hand-declares it; this makes it one declaration instead of four.
15 tests, 281/281 suite total. They define the extern "C" ABI themselves and
allocate exactly as liblogos does, so the ownership rules are exercised rather
than asserted; the ordering test records call order and pins start() as last.
Also fixes a real gap: nix/include.nix carries its own header list, separate
from cpp/CMakeLists.txt's install(FILES), so a new header silently did not ship
in the export layout.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(generator): a Qt-typed umbrella that needs no LogosAPI
Splits a consumer's TYPE SURFACE from its TRANSPORT. Until now the qt umbrella
was `explicit LogosModules(LogosAPI* api)` while the lp one was default-
constructible, so "Qt types" implicitly meant "has a LogosAPI" — and a cdylib
module, whose provider surface is the std logos_module_impl.h C ABI and which
holds no LogosAPI anywhere, could not have Qt-typed dependency wrappers at all.
Its generated glue emits `new LogosModules()` unconditionally
(lidl_gen_cdylib.cpp:693), so the combination did not merely misbehave, it did
not compile.
That was a codegen choice, not a law: the wrapper bodies already run over lp_*.
`--binding api|origin` selects it, defaulting to `api`. A second enum rather
than a third ApiStyle value, deliberately: ApiStyle names the type surface and
is switched on by six emitters (makeHeader/makeSource/returnTypeFor/
paramTypeFor/toWireFor/fromWireFor); a "Qt types, explicit origin" member would
force all six to answer a transport question whose honest answer is "same as
Qt" every time. ApiStyle::Lp ignores the new axis — lp is origin-bound by
construction — and that is asserted rather than assumed.
The emitted umbrella bakes metadata.json#name as the origin literal:
LogosModules() : test_fullapi_cpp(QStringLiteral("test_fullapi_qtproxy")) {}
FullApi bind_full_api(const QString& moduleName) {
return FullApi(QStringLiteral("test_fullapi_qtproxy"), moduleName); }
Origin is the CONSUMER's own name and target is the dep — origin first in both
bind_ overloads. This is the load-bearing property: LpBridge::forTarget derives
origin from `api->moduleName()`, and reusing it silently gives a consumer the
caller's identity, which has already preserved a privilege escalation once in
this tree. An empty metadata name is refused at the CLI (exit 6, naming the
file) and emits `#error` in the header: a module that cannot state its identity
must not compile, and must never be handed a blank or borrowed one.
Verified additive on 172 real metadata.json x 2 api-styles = 344 runs, all
producing output, byte-identical old binary vs new. Mutation control: swapping
bind_<iface>'s (origin, moduleName) to (moduleName, origin) fails the suite at
MakeUmbrellaTest.QtExplicitOriginStatesTheConsumersOwnNameEverywhere. 281 -> 286
tests.
Framing worth keeping: the origin is SELF-ASSERTED from the module's own
metadata and is not attested by the transport. That is not a regression —
`api->moduleName()` is equally process-stated — but "explicit origin" means the
module names itself, not that the host vouches for the name.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs(generator): stop pointing callers at a flag that no longer exists
--backend qt is deleted from logos-qt-generator, and this repo was still
signposting it. main.cpp's refusal said "Use it for --backend qt", and the usage
text advertised --lidl … --backend qt and --from-header … --backend qt. Those
now point at nothing — the exact failure the deletion removes, one repo over.
The refusal names the real replacement chain instead: --backend cdylib here,
then logos-qt-host-generator --backend cdylib for Qt-plugin packaging.
docs/project.md's "Provider Generation" section documented three emitters that
no longer exist; rewritten to state the seam and the two-step pipeline.
docs/spec.md's dataflow diagram showed <name>_qt_glue.h / <name>_dispatch.cpp as
outputs; the diagram is corrected and the sections describing that shape are
marked historical rather than deleted, because the onInit wiring they document
still applies to the cdylib glue.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor(cpp-generator): merge legacy/ into the generator, dropping its dead half
`legacy/` was never a library with an API surface. Two files, 475 lines, exactly
one exported symbol — `int legacy_main(int, char**)` — with every other
definition `static`, compiled INTO logos-cpp-generator and reached by fallthrough
at the end of main(). So there was nothing to keep separate: it is one mode of
this binary, and it now lives beside the others as plugin_introspect.{cpp,h}
behind `runPluginIntrospectMode()`, named for what it does.
Deleting it was never an option — that premise was checked and refused earlier.
`--general-only` alone has ~10 live callers across 7 repos including the central
module path (buildPlugin.nix:206,211, buildHeaders.nix:221,
LogosModule.cmake:423). The mode is load-bearing; only its packaging was wrong.
110 lines go with the move, all genuinely unreferenced:
* cppStringEscape — zero callers anywhere.
* writeUmbrellaHeader / writeUmbrellaSource and the `if (!moduleOnly)` block
that called them. This is the real prize: a SECOND, directory-SCRAPING
implementation of logos_sdk.{h,cpp}, unreachable in practice because
generate-module-headers.sh:60 always passes --module-only. generator_lib's
deps-driven makeUmbrella*FromDeps is now the only umbrella emitter, so the
two cannot drift.
* a dead `QJsonDocument doc(methods);` and its commented-out use.
With the block gone, `--module-only` suppresses nothing, so the parameter and
its plumbing go too. The FLAG stays tolerated rather than rejected, because
generate-module-headers.sh passes it unconditionally — a comment at the old
parse site says so.
Verified: #default builds, and both checks pass — `generator-cli` (which
exercises the CLI surface, including --general-only) and `tests`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(sdk): make the by-name call path a supported API
The dynamic (by-name) invoke path already existed and was already ungated at
every layer — lp_client_create / lp_invoke in the C ABI, logos::LpClient above
it, and the Qt client above that. Nothing checked a host service; there was no
gate to open. What was missing was the ERGONOMICS, which is what turned a
supported capability into something callers reached around the umbrella to get.
Three additive pieces, no gate touched:
1. LogosModuleContext::moduleName() — the module's own registry name, i.e. the
origin it authenticates as. The typed wrappers bake their origin in at
codegen time; a by-name call has to state one, and a wrong origin
authenticates as nobody and fails far from the call site. Set through a NEW
`_logosCoreSetModuleName_`, deliberately not a fourth parameter on
`_logosCoreSetContext_`: every generated provider calls that signature, so
widening it would break each one until regenerated, for a value the
generator knows statically. Set before the context, so moduleName() is live
inside onContextReady().
2. LogosModules::dynamic(target) on the origin-bound umbrella — the untyped
client, with the origin baked in exactly as the typed members' is, and
cached per target because LpClient owns a connection. The typed members over
metadata.json#dependencies stay the ordinary way to call another module;
this is for the cases whose target is a runtime value (a proxy, a router).
3. LpClient::getMethods() over the already-exported lp_get_methods. Invoke
without introspect is guessing — a caller that cannot ask what exists can
only hardcode, and a wrong guess fails at runtime like a typo.
Verified: #default builds, and both checks pass (tests, generator-cli).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(cdylib): shape-check [any]/{tstr:any} args, and fix the umbrella's includes
TWO fixes; the second is a regression I introduced two commits ago.
1. jsonArgToStd() returned the raw json for LogosList / LogosMap — "untyped JSON
passes through, as it always has". Arity was checked, type was not, so a
scalar reached a `[any]` parameter untouched. A proxy forwarding it through a
Qt-typed consumer then turned "notalist" into
["n","o","t","a","l","i","s","t"], because qvariant_cast reads a QString as a
sequential container — and the downstream provider saw a well-formed array
with nothing left to refuse. Now emits logos::jsonRequireArray /
jsonRequireObject; the throw lands in the dispatch's existing catch as
{"code":"dispatch_failed"}. Bare `any` stays raw, deliberately: it declares
nothing, so there is nothing to check it against.
Measured on the conformance matrix: closes all 8 failing cells (498/22/12/8
-> 500/18/12/2), and a whole-matrix per-cell diff shows exactly 14 status
changes, every one inside the two hostile cases. The other 518 cells are
byte-identical in status and value. The remaining 2 are the fix working — the
C++ cdylib provider now refuses the same input, which cases.json still pins
as lenient via expect_by_provider; that is a registry edit, and known.json's
Q1b already names this exact outcome as the intended fix.
2. The Lp umbrella emitted `logos::LpClient& dynamic(...)` and a
std::map<..., std::unique_ptr<logos::LpClient>> while <map>, <memory> and
logos_lp_client.h were conditional on interfaceNames. A module WITH
dependencies compiled by accident, because <dep>_api.h drags the header in
transitively. A module with NO dependencies and no interfaces includes
nothing else and failed outright with "no type named 'LpClient' in namespace
'logos'". test_fullapi_cpp is exactly that shape.
I shipped that in 1be71bb and did not catch it: I verified #default and both
checks, which are the SDK's own targets, not a dependency-free consumer of
its codegen. `.#logos-test-modules--test_fullapi_cpp` is the case that
exercises it and now builds.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ci: use logos-co/setup-nix-cache-action for Nix setup and caching
Replaces the per-repo installer + cachix pair with the shared action, which
installs Nix with the Logos Attic cache (cache.nix.logos.co) preconfigured and
publishes what the job builds — master to the public cache, every other ref to
ci.
Each converted job also gains
environment: ${{ github.ref == 'refs/heads/master' && 'public-cache' || '' }}
because ATTIC_TOKEN_PUBLIC only exists inside that environment. Without it the
secret resolves empty on master and publishing is silently skipped — the job
still passes, so the omission would not show up as a failure.
The action installs Nix itself on every runner, macOS included. That is a
deliberate reversal of the workaround these files carried: the comments here
said cachix/install-nix-action collides with the runner's pre-existing _nixbld
users (eDSRecordAlreadyExists), so DeterminateSystems' installer was used
instead. It no longer reproduces — logos-delivery-module has already been
converted the plain way and its `build-and-test (macos-latest)` leg passes.
Keeping the workaround would have meant a second installer plus a duplicated
substituter/key block in ten files, guarding against something two green runs
say does not happen. If it ever recurs it fails loudly at install, which is
recoverable; the silent-skip above is the failure mode worth engineering
against.
One property is deliberately NOT carried over: the old cachix step ran with
`continue-on-error: true` so a failed cache push could not fail a job whose
tests passed. The action exposes no equivalent, and adding one here would also
swallow genuine setup failures now that the same step installs Nix rather than
only publishing at the end.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): track logos-protocol master again
The rev pin on feat/per-client-token-store existed because the trust-root
surface it needed lived only on that branch while protocol master was still
LOGOS_PROTOCOL_VERSION_MINOR 2. Both comments here said to re-point once it
merged; it has (logos-protocol#59), and master is 0.4.0 — MINOR 4, carrying
lp_token_keys, lp_inform_module_token_to, lp_grant_host_services and
TokenManager::forIdentity / isolateIdentity.
That matters beyond compiling: the cdylib glue's grant forwarding is guarded on
MINOR >= 3, so a master pin taken too early would not have failed loudly — it
would have dropped the grant silently. The guard now opens.
Verified against master rather than assumed: #default builds and the checks pass
(cpp-sdk `tests`, plugin-qt `qt-host-generator`).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs: the generator has no legacy/ directory any more
This should have been part of the merge commit and was not. `docs/project.md`
still listed `legacy/` in the project tree, named `legacy_main()` as the
fallthrough target, and described `--api-style` as being threaded through
`legacy/main.cpp` → `generateFromPlugin` / `writeUmbrellaHeader` — a directory,
a function and two emitters that no longer exist. `docs/spec.md` still pointed
backwards-compatibility at `legacy_main()`.
Corrected to `plugin_introspect.{cpp,h}` / `runPluginIntrospectMode()`, with the
provenance kept rather than erased: the tree entry says what it was and why it
was never a library, because "there used to be a legacy generator" is the
question a reader will actually arrive with.
The umbrella line gets the deletion too — `writeUmbrellaHeader` /
`writeUmbrellaSource` were the second, directory-scraping implementation of
logos_sdk.{h,cpp}, and their absence is the point: `makeUmbrella*FromDeps` is
now the only umbrella emitter, so the two cannot drift.
Two nearby lines were stale independently of that move and are fixed with it:
* "the legacy emitters in tests/generator/" — those tests cover the SHARED
generator_lib emitters (test_make_header/source/umbrella, the type maps),
which are not legacy and never were.
* "consumer wrappers real modules get come from legacy/main.cpp →
generateInterfaceWrappers" — generateInterfaceWrappers is in main.cpp and
was already there, so that path was misattributed before this branch.
Every other use of "legacy" in these docs is left alone: `interface: "legacy"`,
legacy Qt types (QVariantMap / QVariantList / QStringList), legacy Q_INVOKABLE
modules and the legacy consumer path are all real things that still exist.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs: correct generator ownership after the Qt host split
Comments and docs across the repo still claimed this generator emits the Qt
plugin glue, and pointed `--backend qt` users at logos-qt-generator. Neither
is true: the Qt-plugin (provider) glue is emitted by logos-plugin-qt's
logos-qt-host-generator --backend cdylib, on top of the C ABI this tool emits
with --backend cdylib, and logos-qt-generator owns only `consumer` and `ui`
(it refuses the flag too).
Also corrects the LogosModuleContext header, whose comments described the
retired Qt provider path throughout — `<name>_events.cpp` marshalling into a
QVariantList and a provider `onInit` setting the context. The emitted file is
`<name>_events_cdylib.cpp`, it marshals into nlohmann::json, and the C-ABI
export TU installs the callback. The runtime path it named
(runtime_qt/host/module_initializer.cpp) no longer exists.
The only behaviour change is the text of three --backend/--from-header error
messages, which named the wrong tool. Nothing asserts on them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(generator): refuse --backend qt before validating --impl-class
The `backend == "qt"` refusal sat below the --impl-class / --impl-header
requirement checks, so `--backend qt` alone never reached it: it exited 1 with
"Error: --backend qt requires --impl-class <ClassName>", which reads as though
qt would work given one more flag. qt was removed; no flag rescues it.
Hoisted the refusal (and the unsupported-backend error) above those checks.
The cdylib branch returns on every path before this point, so the two checks
could only ever gate a backend that was about to be rejected anyway; they are
dropped rather than left unreachable.
`--backend qt` now exits 6 with the removal message, `--backend bogus` exits 1,
and cdylib is untouched. checks.generator-cli and checks.tests pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ci(doctests): skip the qt-api-events spec, which builds a provider module
This PR removes `logos-cpp-generator --provider-header`. The watcher fixture in
doctests/cpp-sdk-qt-api-events.test.yaml is `interface: "provider"`, so
logos-module-builder reaches "generating provider dispatch (qt_watcher_module)"
and the generator refuses:
Error: --provider-header was removed.
That one build failure cascades through the rest of the spec (install, load,
subscriptionAccepted, greetThrough, greetedCount, lastGreeted), which is the
whole of the red on both ubuntu-latest and macos-latest. notifier_module is
`interface: universal` and builds fine.
Skipped rather than rewritten. The replacement shape that keeps the Qt-typed
dependency wrappers without the retired provider dispatch is
`interface: universal` + `codegen.consumer_api_style: "qt"`, and
logos-module-builder master does not carry that key yet — while this spec pins
the builder to master. It arrives with the B4 stack.
The spec file is kept and annotated, not deleted, because it covers two things
nothing else does: the Qt-TYPED wrapper emission (separately generated code
from the lp path, so lp-path specs cannot catch a bug in it) and a subscription
made from onInit() before the dependency is reachable. Both are UNTESTED until
this is restored — a known, accepted gap recorded in the spec header and in the
workflow.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
757 lines
35 KiB
YAML
757 lines
35 KiB
YAML
# ─────────────────────────────────────────────────────────────────────────────
|
|
# SKIPPED — not run by .github/workflows/doctests.yml.
|
|
#
|
|
# The watcher fixture below is `interface: "provider"`. That path was removed
|
|
# from this SDK along with `logos-cpp-generator --provider-header`, so the
|
|
# fixture no longer builds: logos-module-builder reaches "generating provider
|
|
# dispatch (qt_watcher_module)" and the generator refuses. Every later step of
|
|
# this spec cascades from that one failure.
|
|
#
|
|
# It is kept, not deleted, because what it covers is not covered anywhere else:
|
|
# the Qt-TYPED dependency-wrapper emission (a bug in that path cannot be caught
|
|
# by the lp-path specs, which are separately generated code) and a subscription
|
|
# made from onInit(), before the dependency is reachable.
|
|
#
|
|
# TO RESTORE (B4): logos-module-builder master does not yet carry
|
|
# `codegen.consumer_api_style`, and this spec pins the builder to master. Once
|
|
# it does, rewrite the watcher as `"interface": "universal"` +
|
|
# `"codegen": {"consumer_api_style": "qt"}` — which keeps the Qt-typed wrappers
|
|
# without the retired provider dispatch — drop the LOGOS_PROVIDER/LOGOS_METHOD
|
|
# markers and the PROVIDER_HEADER prose, and re-add this file to both spec
|
|
# lists in .github/workflows/doctests.yml.
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
name: "A Qt-typed Consumer Subscribing to Another Module's Event"
|
|
output: cpp-sdk-qt-api-events.md
|
|
release: ""
|
|
|
|
intro: |
|
|
This SDK's code generator emits a dependency wrapper in **two type
|
|
surfaces**, and which one a module gets is decided by its `metadata.json`,
|
|
not by anything it writes:
|
|
|
|
| the module declares | generated `modules().<dep>` signatures | selected by |
|
|
|---|---|---|
|
|
| `"interface": "universal"` | `std::string`, `std::vector<uint8_t>`, … | `LOGOS_API_STYLE=lp` |
|
|
| `"interface": "provider"` — the Qt provider style | `QString`, `QVariantList`, … | `LOGOS_API_STYLE=qt`, the default |
|
|
|
|
The other doc-tests in this directory all take the first row. This one takes
|
|
the second, because the two surfaces are **separately generated code**: an
|
|
emission bug in the Qt path cannot be caught by any amount of coverage on the
|
|
lp path.
|
|
|
|
What it builds:
|
|
|
|
1. `notifier_module`, an ordinary `interface: universal` callee that emits a
|
|
`greeted` event.
|
|
2. `qt_watcher_module`, a **Qt provider-style** consumer (`LOGOS_PROVIDER` +
|
|
`LOGOS_METHOD`) that declares `notifier_module` as a dependency and
|
|
subscribes to `greeted` through the generated Qt-typed
|
|
`m_logos->notifier_module.onGreeted(...)`.
|
|
3. Both `.lgx` packages, built against the C++ SDK commit under test, loaded
|
|
together in `logoscore`, with the notifier made to fire and the watcher
|
|
asked what it received.
|
|
|
|
**Where the watcher subscribes is the point.** It subscribes from `onInit()`,
|
|
not from a method a test calls later. `onInit()` runs while the host has
|
|
spawned `notifier_module`'s process but before that process has called
|
|
`listen()` — the dependency is not reachable yet. That is the moment every
|
|
real C++ consumer subscribes, and it is the moment a wrapper that asks *"is
|
|
this module reachable right now?"* gets the answer *no* and gives up. A
|
|
subscription made there and delivered later is the whole assertion.
|
|
|
|
what_you_build: "Two modules — an `interface: universal` notifier and a Qt provider-style watcher — built against this SDK commit and run together in `logoscore`, with the watcher receiving an event it subscribed to before the notifier was reachable."
|
|
|
|
what_you_learn:
|
|
- How `metadata.json` selects between the Qt-typed and Qt-free dependency-wrapper surfaces
|
|
- How a Qt provider-style module is written — `LOGOS_PROVIDER`, `LOGOS_METHOD`, and a `PluginInterface` loader
|
|
- How to reach a dependency through `LogosModules` with Qt types (`QString`, not `std::string`)
|
|
- Why subscribing from `onInit()` is both the realistic shape and the demanding one
|
|
- How to load two modules in `logoscore` and prove an event crossed the process boundary
|
|
|
|
prerequisites:
|
|
- |
|
|
**Nix** with flakes enabled. Install from [nixos.org](https://nixos.org/download.html), then enable flakes:
|
|
|
|
```bash
|
|
mkdir -p ~/.config/nix
|
|
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
|
|
```
|
|
|
|
Verify: `nix flake --help >/dev/null 2>&1 && echo "Flakes enabled"`
|
|
- "**git** — nix flakes only see files tracked by git."
|
|
- "A Linux or macOS machine."
|
|
|
|
sections:
|
|
- title: "Create the callee: notifier_module"
|
|
step: true
|
|
text: |
|
|
Nothing about this module is Qt-aware or unusual — it is the same
|
|
`interface: universal` shape as every other callee in these doc-tests. It
|
|
is here to emit an event on demand.
|
|
steps:
|
|
- title: "metadata.json"
|
|
text: "`interface: universal` selects the pure-C++ pattern: you write one plain class and the builder generates the plugin glue."
|
|
file:
|
|
path: notifier_module/metadata.json
|
|
language: json
|
|
content: |
|
|
{
|
|
"name": "notifier_module",
|
|
"version": "1.0.0",
|
|
"type": "core",
|
|
"category": "general",
|
|
"description": "A callee module that emits an event other modules subscribe to",
|
|
"main": "notifier_module_plugin",
|
|
"interface": "universal",
|
|
"dependencies": [],
|
|
|
|
"nix": {
|
|
"packages": {
|
|
"build": [],
|
|
"runtime": []
|
|
},
|
|
"external_libraries": [],
|
|
"cmake": {
|
|
"find_packages": [],
|
|
"extra_sources": []
|
|
}
|
|
}
|
|
}
|
|
|
|
- title: "CMakeLists.txt"
|
|
text: "For a universal module you list only your plain C++ sources; the generated glue is compiled automatically."
|
|
file:
|
|
path: notifier_module/CMakeLists.txt
|
|
language: cmake
|
|
content: |
|
|
cmake_minimum_required(VERSION 3.14)
|
|
project(NotifierModulePlugin LANGUAGES CXX)
|
|
|
|
if(DEFINED ENV{LOGOS_MODULE_BUILDER_ROOT})
|
|
include($ENV{LOGOS_MODULE_BUILDER_ROOT}/cmake/LogosModule.cmake)
|
|
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/LogosModule.cmake")
|
|
include(cmake/LogosModule.cmake)
|
|
else()
|
|
message(FATAL_ERROR "LogosModule.cmake not found")
|
|
endif()
|
|
|
|
logos_module(
|
|
NAME notifier_module
|
|
SOURCES
|
|
src/notifier_module_impl.h
|
|
src/notifier_module_impl.cpp
|
|
)
|
|
|
|
- title: "flake.nix"
|
|
file:
|
|
path: notifier_module/flake.nix
|
|
language: nix
|
|
content: |
|
|
{
|
|
description = "Notifier core module - emits an event for the Qt-api doc-test";
|
|
|
|
inputs = {
|
|
logos-module-builder.url = "github:logos-co/logos-module-builder{release}";
|
|
};
|
|
|
|
outputs = inputs@{ logos-module-builder, ... }:
|
|
logos-module-builder.lib.mkLogosModule {
|
|
src = ./.;
|
|
configFile = ./metadata.json;
|
|
flakeInputs = inputs;
|
|
};
|
|
}
|
|
|
|
- title: "src/notifier_module_impl.h — the class"
|
|
text: |
|
|
The `logos_events:` block declares the event. The token expands to
|
|
`public` under a normal compile; the generator reads it and emits the
|
|
event body, plus a LIDL contract that consumers turn into a typed
|
|
subscriber.
|
|
file:
|
|
path: notifier_module/src/notifier_module_impl.h
|
|
language: cpp
|
|
content: |
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include <logos_module_context.h> // LogosModuleContext base + logos_events
|
|
|
|
// A callee module. It exists to emit `greeted` on demand, so a consumer
|
|
// can prove its subscription is live.
|
|
class NotifierModuleImpl : public LogosModuleContext {
|
|
public:
|
|
NotifierModuleImpl() = default;
|
|
~NotifierModuleImpl() = default;
|
|
|
|
/// Returns a greeting for the given name.
|
|
std::string greet(const std::string& name);
|
|
|
|
/// Greets the name and also emits a `greeted` event carrying it.
|
|
void greetNotify(const std::string& name);
|
|
|
|
logos_events:
|
|
/// Emitted by greetNotify() with the produced greeting string.
|
|
void greeted(const std::string& greeting);
|
|
};
|
|
|
|
- title: "src/notifier_module_impl.cpp — the implementation"
|
|
text: "Plain C++ — no Qt, no IPC plumbing. `greetNotify` fires the generated event."
|
|
file:
|
|
path: notifier_module/src/notifier_module_impl.cpp
|
|
language: cpp
|
|
content: |
|
|
#include "notifier_module_impl.h"
|
|
|
|
std::string NotifierModuleImpl::greet(const std::string& name)
|
|
{
|
|
return "Hello, " + name + "!";
|
|
}
|
|
|
|
void NotifierModuleImpl::greetNotify(const std::string& name)
|
|
{
|
|
// Emit the event declared in logos_events:. When loaded by a host
|
|
// this reaches every subscriber; constructed outside a host it is a
|
|
// safe no-op.
|
|
greeted("Hello, " + name + "!");
|
|
}
|
|
|
|
- title: "Create the Qt-typed consumer: qt_watcher_module"
|
|
step: true
|
|
text: |
|
|
This is the module the doc-test exists for. Two things make it Qt-typed,
|
|
and neither is a flag anyone passes by hand:
|
|
|
|
- **`"interface": "provider"`.** Only `universal` asks for the Qt-free
|
|
surface, so every other interface leaves `LOGOS_API_STYLE` at its default
|
|
of `qt`, which is what `LogosModule.cmake` forwards to the generator.
|
|
There is no `"interface": "qt"` to write.
|
|
- **It declares `notifier_module` as a dependency.** That is what makes the
|
|
builder emit a `notifier_module` accessor on `LogosModules` — with
|
|
`QString` in its signatures, and one `on<Event>` subscriber per event the
|
|
notifier declares.
|
|
steps:
|
|
- title: "metadata.json — no interface key, one dependency"
|
|
text: |
|
|
Compare with the notifier's: one word differs, and it decides the whole
|
|
type surface. `provider` is the hand-written Qt plugin style
|
|
(`LOGOS_PROVIDER` + `LOGOS_METHOD`); `universal` is the pure-C++ one.
|
|
Qt typing is not requested — it is what you get by not asking for the
|
|
Qt-free surface.
|
|
|
|
Leaving `interface` out entirely is **not** the same as writing
|
|
`provider`. An absent key means `legacy`, which runs no code generation
|
|
at all: the provider dispatch is never emitted and the build fails at
|
|
CMake's generate step.
|
|
file:
|
|
path: qt_watcher_module/metadata.json
|
|
language: json
|
|
content: |
|
|
{
|
|
"name": "qt_watcher_module",
|
|
"version": "1.0.0",
|
|
"type": "core",
|
|
"category": "general",
|
|
"description": "A Qt-typed consumer: subscribes to notifier_module's event from onInit()",
|
|
"main": "qt_watcher_module_plugin",
|
|
"interface": "provider",
|
|
"dependencies": ["notifier_module"],
|
|
|
|
"nix": {
|
|
"packages": {
|
|
"build": [],
|
|
"runtime": []
|
|
},
|
|
"external_libraries": [],
|
|
"cmake": {
|
|
"find_packages": [],
|
|
"extra_sources": []
|
|
}
|
|
}
|
|
}
|
|
|
|
- title: "CMakeLists.txt — PROVIDER_HEADER"
|
|
text: |
|
|
Only your own sources. The builder generates
|
|
`logos_provider_dispatch.cpp` — the table mapping an incoming IPC call
|
|
to one of the `LOGOS_METHOD`s — into `generated_code/`, and
|
|
`LogosModule.cmake` compiles everything it finds there.
|
|
|
|
Two things deliberately absent, both of which break this build:
|
|
|
|
- **No `logos_provider_dispatch.cpp` under `SOURCES`.** Named there it
|
|
resolves against the source directory, where a generated file does not
|
|
exist, and CMake fails at its generate step.
|
|
- **No `PROVIDER_HEADER` argument.** It exists for the non-Nix source
|
|
layout, where it adds a rule to run the generator. In a Nix build the
|
|
generator has already run (`"interface": "provider"` is what schedules
|
|
it), so passing it only re-adds the same file a second time and marks
|
|
it `GENERATED` — which puts it in front of AUTOMOC and produces a
|
|
ninja dependency cycle through the target's own autogen timestamp.
|
|
file:
|
|
path: qt_watcher_module/CMakeLists.txt
|
|
language: cmake
|
|
content: |
|
|
cmake_minimum_required(VERSION 3.14)
|
|
project(QtWatcherModulePlugin LANGUAGES CXX)
|
|
|
|
if(DEFINED ENV{LOGOS_MODULE_BUILDER_ROOT})
|
|
include($ENV{LOGOS_MODULE_BUILDER_ROOT}/cmake/LogosModule.cmake)
|
|
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/LogosModule.cmake")
|
|
include(cmake/LogosModule.cmake)
|
|
else()
|
|
message(FATAL_ERROR "LogosModule.cmake not found")
|
|
endif()
|
|
|
|
logos_module(
|
|
NAME qt_watcher_module
|
|
SOURCES
|
|
src/qt_watcher_module_loader.h
|
|
src/qt_watcher_module_impl.h
|
|
src/qt_watcher_module_impl.cpp
|
|
)
|
|
|
|
- title: "flake.nix — add the dependency input"
|
|
text: |
|
|
The input name **must match** the dependency name in `metadata.json`.
|
|
The `path:` value is a placeholder — we lock it to the real notifier
|
|
checkout in the build step with `--override-input` (Nix will not accept
|
|
a relative `../` path written directly into `flake.nix`).
|
|
file:
|
|
path: qt_watcher_module/flake.nix
|
|
language: nix
|
|
content: |
|
|
{
|
|
description = "Qt-typed consumer of notifier_module";
|
|
|
|
inputs = {
|
|
logos-module-builder.url = "github:logos-co/logos-module-builder{release}";
|
|
|
|
# The module this one depends on. Placeholder path — locked to the
|
|
# real checkout in the build step via --override-input.
|
|
notifier_module.url = "path:/path/to/your/notifier_module";
|
|
};
|
|
|
|
outputs = inputs@{ logos-module-builder, notifier_module, ... }:
|
|
logos-module-builder.lib.mkLogosModule {
|
|
src = ./.;
|
|
configFile = ./metadata.json;
|
|
flakeInputs = inputs;
|
|
};
|
|
}
|
|
|
|
- title: "src/qt_watcher_module_impl.h — the class"
|
|
text: |
|
|
`LOGOS_PROVIDER` declares the module identity; each `LOGOS_METHOD` is
|
|
exposed over IPC. Note the types: `QString`, not `std::string` — this
|
|
is the Qt surface on both the inbound side (what callers send) and the
|
|
outbound one (what the dependency wrapper takes).
|
|
file:
|
|
path: qt_watcher_module/src/qt_watcher_module_impl.h
|
|
language: cpp
|
|
content: |
|
|
#ifndef QT_WATCHER_MODULE_IMPL_H
|
|
#define QT_WATCHER_MODULE_IMPL_H
|
|
|
|
#include "logos_provider_object.h"
|
|
#include "logos_api.h"
|
|
#include "logos_sdk.h" // LogosModules — one Qt-typed accessor per dependency
|
|
#include "logos_types.h"
|
|
|
|
// A Qt-typed consumer of notifier_module.
|
|
//
|
|
// The point of this module is WHERE it subscribes: onInit() runs while
|
|
// the host has spawned notifier_module's process but before that
|
|
// process has called listen(), so the dependency is not reachable yet.
|
|
// That is the moment every real C++ consumer subscribes, and the moment
|
|
// a wrapper that probes for reachability gives up permanently.
|
|
class QtWatcherModuleImpl : public LogosProviderBase
|
|
{
|
|
LOGOS_PROVIDER(QtWatcherModuleImpl, "qt_watcher_module", "1.0.0")
|
|
|
|
protected:
|
|
void onInit(LogosAPI* api) override;
|
|
|
|
public:
|
|
/// A plain sync call through the generated Qt-typed wrapper.
|
|
LOGOS_METHOD QString greetThrough(const QString& name);
|
|
|
|
/// Whether the subscription made in onInit() was ACCEPTED. Accepted
|
|
/// is not the same as armed: it means the wrapper took the
|
|
/// subscription rather than refusing it because the module was
|
|
/// unreachable at that instant.
|
|
LOGOS_METHOD bool subscriptionAccepted();
|
|
|
|
/// The greeting carried by the last `greeted` event, or empty.
|
|
LOGOS_METHOD QString lastGreeted();
|
|
|
|
/// How many `greeted` events have arrived.
|
|
LOGOS_METHOD int greetedCount();
|
|
|
|
private:
|
|
LogosModules* m_logos = nullptr;
|
|
bool m_accepted = false;
|
|
QString m_lastGreeted;
|
|
int m_greetedCount = 0;
|
|
};
|
|
|
|
#endif // QT_WATCHER_MODULE_IMPL_H
|
|
|
|
- title: "src/qt_watcher_module_loader.h — the plugin entry point"
|
|
text: |
|
|
A provider-style module supplies its own loader: a small `QObject` that
|
|
Qt's plugin system instantiates, and which hands back the
|
|
implementation. `Q_PLUGIN_METADATA` embeds `metadata.json` into the
|
|
compiled plugin, which is how `lm` and the host read a module's
|
|
identity without loading it.
|
|
file:
|
|
path: qt_watcher_module/src/qt_watcher_module_loader.h
|
|
language: cpp
|
|
content: |
|
|
#ifndef QT_WATCHER_MODULE_LOADER_H
|
|
#define QT_WATCHER_MODULE_LOADER_H
|
|
|
|
#include <QObject>
|
|
#include "interface.h"
|
|
#include "logos_provider_object.h"
|
|
#include "qt_watcher_module_impl.h"
|
|
|
|
class QtWatcherModuleLoader : public QObject,
|
|
public PluginInterface,
|
|
public LogosProviderPlugin
|
|
{
|
|
Q_OBJECT
|
|
Q_PLUGIN_METADATA(IID LogosProviderPlugin_iid FILE "metadata.json")
|
|
Q_INTERFACES(PluginInterface LogosProviderPlugin)
|
|
|
|
public:
|
|
QString name() const override { return "qt_watcher_module"; }
|
|
QString version() const override { return "1.0.0"; }
|
|
LogosProviderObject* createProviderObject() override
|
|
{
|
|
return new QtWatcherModuleImpl();
|
|
}
|
|
};
|
|
|
|
#endif // QT_WATCHER_MODULE_LOADER_H
|
|
|
|
- title: "src/qt_watcher_module_impl.cpp — subscribing at init"
|
|
text: |
|
|
`onGreeted` is generated from the notifier's `logos_events:` block, one
|
|
accessor per event, named `on` + the capitalized event name. Its
|
|
callback carries the event's parameters already decoded into Qt types —
|
|
`const QString&`, not a `QVariantList` the author has to unpack.
|
|
|
|
It returns whether the subscription was **accepted**, which is
|
|
deliberately not the same question as "is it live now". A module that
|
|
has not finished starting is a perfectly good subscription target; it
|
|
just has not arrived yet.
|
|
file:
|
|
path: qt_watcher_module/src/qt_watcher_module_impl.cpp
|
|
language: cpp
|
|
content: |
|
|
#include "qt_watcher_module_impl.h"
|
|
|
|
#include <QDebug>
|
|
|
|
void QtWatcherModuleImpl::onInit(LogosAPI* api)
|
|
{
|
|
delete m_logos;
|
|
m_logos = new LogosModules(api);
|
|
|
|
// Subscribe HERE, at init, not from a method a test calls later.
|
|
// notifier_module's host process has been spawned but has almost
|
|
// certainly not called listen() yet, so this is the unreachable
|
|
// window. The generated accessor takes the subscription now and
|
|
// arms it when the module appears.
|
|
m_accepted = m_logos->notifier_module.onGreeted(
|
|
[this](const QString& greeting) {
|
|
m_lastGreeted = greeting;
|
|
++m_greetedCount;
|
|
qDebug() << "QtWatcherModuleImpl: greeted ->" << greeting;
|
|
});
|
|
|
|
qDebug() << "QtWatcherModuleImpl: subscription accepted =" << m_accepted;
|
|
}
|
|
|
|
QString QtWatcherModuleImpl::greetThrough(const QString& name)
|
|
{
|
|
if (!m_logos) return QString();
|
|
return m_logos->notifier_module.greet(name);
|
|
}
|
|
|
|
bool QtWatcherModuleImpl::subscriptionAccepted()
|
|
{
|
|
return m_accepted;
|
|
}
|
|
|
|
QString QtWatcherModuleImpl::lastGreeted()
|
|
{
|
|
return m_lastGreeted;
|
|
}
|
|
|
|
int QtWatcherModuleImpl::greetedCount()
|
|
{
|
|
return m_greetedCount;
|
|
}
|
|
|
|
- title: "Build both modules against this SDK"
|
|
step: true
|
|
text: |
|
|
Nix flakes only see files tracked by git, so initialise a repo in each
|
|
module first. Then build each `.lgx`, overriding `logos-cpp-sdk` to the
|
|
commit under test so the generated wrappers, the plugin glue, and the IPC
|
|
layer all come from this SDK.
|
|
|
|
> Each override URL carries a `{release}` placeholder the doc-test runner
|
|
> expands to a concrete ref: locally that is this `logos-cpp-sdk`
|
|
> checkout's `HEAD` (see `run.sh`); in CI it is the commit being tested.
|
|
> With no pin it falls back to latest `master`.
|
|
steps:
|
|
- title: "Initialise git repos"
|
|
run: |
|
|
(cd notifier_module && git init -q && git add -A)
|
|
(cd qt_watcher_module && git init -q && git add -A)
|
|
check_file: "notifier_module/.git/HEAD"
|
|
|
|
- title: "Build the notifier's .lgx against this SDK"
|
|
run: |
|
|
nix build 'path:./notifier_module#lgx' \
|
|
--override-input logos-module-builder 'github:logos-co/logos-module-builder{release}' \
|
|
--override-input logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
-o notifier-lgx
|
|
code_block: |
|
|
nix build 'path:./notifier_module#lgx' \
|
|
--override-input logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
-o notifier-lgx
|
|
post_text: "The notifier package is under `./notifier-lgx/`:"
|
|
extra_run:
|
|
run: "ls notifier-lgx/*.lgx"
|
|
|
|
- title: "Build the watcher's .lgx against this SDK"
|
|
text: |
|
|
The watcher pulls in `notifier_module` as a dependency, so we lock that
|
|
input to the local notifier checkout **and** override `logos-cpp-sdk`
|
|
in both builders — so the Qt-typed dependency wrapper the generator
|
|
emits, and both plugins, come from one consistent SDK.
|
|
run: |
|
|
nix build 'path:./qt_watcher_module#lgx' \
|
|
--override-input notifier_module 'path:./notifier_module' \
|
|
--override-input logos-module-builder 'github:logos-co/logos-module-builder{release}' \
|
|
--override-input logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input notifier_module/logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input notifier_module/logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
-o qt-watcher-lgx
|
|
code_block: |
|
|
nix build 'path:./qt_watcher_module#lgx' \
|
|
--override-input notifier_module 'path:./notifier_module' \
|
|
--override-input logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input notifier_module/logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input notifier_module/logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
-o qt-watcher-lgx
|
|
post_text: |
|
|
The watcher package is under `./qt-watcher-lgx/`. Reaching this line is
|
|
already a result: it means the Qt-typed `notifier_module_api.{h,cpp}`
|
|
was generated **and compiled**, which is a different body of emitted
|
|
code from the one every other spec in this directory exercises.
|
|
extra_run:
|
|
run: "ls qt-watcher-lgx/*.lgx"
|
|
|
|
- title: "Build the runtime and install both modules"
|
|
step: true
|
|
text: |
|
|
Build `logoscore` (against this SDK) and `lgpm`, then install both modules
|
|
into a `./modules` directory the daemon can scan.
|
|
steps:
|
|
- title: "Build logoscore against this SDK"
|
|
run: |
|
|
nix build 'github:logos-co/logos-logoscore-cli{release}' \
|
|
--override-input logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-liblogos/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input logos-liblogos/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-capability-module/logos-module-builder 'github:logos-co/logos-module-builder{release}' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk{release}' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-test-framework/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--out-link ./logos
|
|
code_block: |
|
|
nix build 'github:logos-co/logos-logoscore-cli' \
|
|
--override-input logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-liblogos/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input logos-liblogos/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-cpp-sdk 'github:logos-co/logos-cpp-sdk' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--override-input logos-capability-module/logos-module-builder/logos-test-framework/logos-qt-sdk/logos-lidl 'github:logos-co/logos-lidl' \
|
|
--out-link ./logos
|
|
check_file: "logos/bin/logoscore"
|
|
|
|
- title: "Build lgpm"
|
|
run: "nix build 'github:logos-co/logos-package-manager#cli' -o lgpm"
|
|
check_file: "lgpm/bin/lgpm"
|
|
|
|
- title: "Seed the modules directory with the capability module"
|
|
text: |
|
|
Loading a module goes through the host's capability layer, so the
|
|
modules directory needs the `capability_module` that ships with
|
|
`logoscore` (rebuilt against this SDK). Copy it across first.
|
|
run: |
|
|
mkdir -p modules
|
|
cp -RL ./logos/modules/. ./modules/
|
|
check_file: "modules/capability_module/manifest.json"
|
|
|
|
- title: "Install the notifier"
|
|
run: "./lgpm/bin/lgpm --modules-dir ./modules --allow-unsigned install --file notifier-lgx/*.lgx"
|
|
expect_contains:
|
|
- "Installed to:"
|
|
|
|
- title: "Install the watcher"
|
|
run: "./lgpm/bin/lgpm --modules-dir ./modules --allow-unsigned install --file qt-watcher-lgx/*.lgx"
|
|
expect_contains:
|
|
- "Installed to:"
|
|
|
|
- title: "Confirm both modules are installed"
|
|
run: "./lgpm/bin/lgpm --modules-dir ./modules list"
|
|
expect_contains:
|
|
- "notifier_module"
|
|
- "qt_watcher_module"
|
|
check_file: "modules/qt_watcher_module/manifest.json"
|
|
|
|
- title: "Load both modules and prove the event arrives"
|
|
step: true
|
|
text: |
|
|
Start `logoscore` in daemon mode (`-D`) so each module's process stays
|
|
alive between `call` commands — the subscription registered during the
|
|
watcher's `onInit()` has to still be there when a later call makes the
|
|
notifier fire.
|
|
steps:
|
|
- title: "Start the daemon"
|
|
run: "sh -c './logos/bin/logoscore -D -m ./modules > logs.txt 2>&1 &'"
|
|
code_block: "logoscore -D -m ./modules > logs.txt &"
|
|
|
|
- run: "sleep 3"
|
|
|
|
- title: "Load the notifier (the dependency first)"
|
|
run: "./logos/bin/logoscore load-module notifier_module"
|
|
code_block: "logoscore load-module notifier_module"
|
|
expect_contains:
|
|
- "notifier_module"
|
|
|
|
- title: "Load the watcher"
|
|
text: |
|
|
Loading it runs its `onInit()`, which is where the subscription is
|
|
made. Nothing here waits for the notifier to be reachable.
|
|
run: "./logos/bin/logoscore load-module qt_watcher_module"
|
|
code_block: "logoscore load-module qt_watcher_module"
|
|
expect_contains:
|
|
- "qt_watcher_module"
|
|
|
|
- title: "Confirm both report loaded"
|
|
run: "./logos/bin/logoscore status"
|
|
code_block: "logoscore status"
|
|
expect_contains:
|
|
- "notifier_module"
|
|
- "qt_watcher_module"
|
|
- '"status":"loaded"'
|
|
|
|
- title: "The subscription made at init was accepted"
|
|
text: |
|
|
`true` means the generated wrapper took the subscription instead of
|
|
refusing it. A wrapper that probes the dependency for reachability
|
|
before subscribing answers `false` here, permanently, because at
|
|
`onInit()` time the honest answer to that probe is *no*.
|
|
run: "./logos/bin/logoscore call qt_watcher_module subscriptionAccepted"
|
|
code_block: "logoscore call qt_watcher_module subscriptionAccepted"
|
|
expect_contains:
|
|
- '"result":true'
|
|
|
|
- title: "A Qt-typed sync call through the same wrapper"
|
|
text: |
|
|
`greetThrough` reaches `notifier_module.greet` through
|
|
`m_logos->notifier_module`, with `QString` on both ends. It confirms
|
|
the wrapper is wired up at all, so a silent event later cannot be
|
|
mistaken for a dead dependency.
|
|
run: "./logos/bin/logoscore call qt_watcher_module greetThrough Sync"
|
|
code_block: "logoscore call qt_watcher_module greetThrough Sync"
|
|
expect_contains:
|
|
- '"result":"Hello, Sync!"'
|
|
|
|
- title: "Nothing has been received yet"
|
|
text: "The notifier has not fired, so the watcher's state is still empty. This is the control: it makes the next step's result mean something."
|
|
run: "./logos/bin/logoscore call qt_watcher_module greetedCount"
|
|
code_block: "logoscore call qt_watcher_module greetedCount"
|
|
expect_contains:
|
|
- '"result":0'
|
|
|
|
- title: "Make the notifier fire"
|
|
text: "Called directly on the notifier — the watcher is not involved in triggering its own event."
|
|
run: "./logos/bin/logoscore call notifier_module greetNotify Qt"
|
|
code_block: "logoscore call notifier_module greetNotify Qt"
|
|
|
|
- run: "sleep 1"
|
|
|
|
- title: "The event crossed the boundary into the Qt-typed subscriber"
|
|
text: |
|
|
This is the assertion the whole spec exists for: a subscription made
|
|
before the dependency was reachable, through the Qt-typed generated
|
|
accessor, delivering a decoded `QString` to the callback.
|
|
run: "./logos/bin/logoscore call qt_watcher_module lastGreeted"
|
|
code_block: "logoscore call qt_watcher_module lastGreeted"
|
|
expect_contains:
|
|
- '"result":"Hello, Qt!"'
|
|
|
|
- title: "Exactly once"
|
|
text: "One emit, one delivery — a re-arming subscription that fired twice would be as wrong as one that never fired."
|
|
run: "./logos/bin/logoscore call qt_watcher_module greetedCount"
|
|
code_block: "logoscore call qt_watcher_module greetedCount"
|
|
expect_contains:
|
|
- '"result":1'
|
|
|
|
- title: "Stop the daemon"
|
|
run: "./logos/bin/logoscore stop"
|
|
code_block: "logoscore stop"
|
|
|
|
- run: "sleep 2"
|
|
|
|
- title: "Confirm the daemon has stopped"
|
|
run: "./logos/bin/logoscore status || true"
|
|
code_block: "logoscore status"
|
|
expect_contains:
|
|
- '"status":"not_running"'
|
|
|
|
- title: "Recap"
|
|
text: |
|
|
| What was proven | Where |
|
|
| --------------- | ----- |
|
|
| The Qt-typed wrapper is **emitted and compiles** | the watcher's `.lgx` built at all |
|
|
| A subscription made when the dependency is unreachable is **accepted** | `subscriptionAccepted` → `true` |
|
|
| The Qt-typed **sync** path works | `greetThrough Sync` → `"Hello, Sync!"` |
|
|
| Nothing arrives before the notifier fires | `greetedCount` → `0` |
|
|
| The event **arrives, decoded into a `QString`** | `lastGreeted` → `"Hello, Qt!"` |
|
|
| It arrives **exactly once** | `greetedCount` → `1` |
|
|
|
|
A green run here means something no other spec in this directory can mean.
|
|
The Qt-typed dependency wrapper is a **separately generated body of code**
|
|
from the `lp` one; the other five specs are all `interface: universal`, so
|
|
an emission bug on this path is invisible to every one of them. Here it was
|
|
generated, compiled, and executed.
|
|
|
|
The `onInit()` placement is what gives the event row teeth. That is the
|
|
shape real C++ consumers have — `wallet-ui`'s backend and the tutorial's
|
|
C++ UI backend both subscribe from a constructor or context hook, against a
|
|
dependency whose host process has been spawned and has not yet called
|
|
`listen()`. A wrapper that asked *"is this module reachable?"* before
|
|
subscribing would return `false` at that instant and never retry: the
|
|
subscription is lost silently, while method calls to the same module keep
|
|
working, because calls reach the replica by a path that never asks. Both
|
|
the `subscriptionAccepted` row and the `lastGreeted` row are needed to tell
|
|
that apart from a module that is simply quiet.
|