mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-31 09:41:06 +00:00
* feat: emit logos_module_dispatch_async for concurrency:multi C++ modules The cdylib C-ABI exports gain an async dispatch entry (each call run on a worker thread, reply on completion) for universal + cdylib C++ modules. --concurrency multi flag in logos-cpp-generator. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: cpp-sdk concurrent-dispatch doctest (concurrency:"multi" showcase) A concurrency:multi C++ worker + a single driver firing concurrent calls, showing the multi worker overlaps them. The C++ cdylib generator needs NO change — its logos_module_dispatch is already safe to call concurrently; the worker pool lives in the Qt glue and the result is deferred via a sentinel + completion event. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: wire universal-cdylib modules() independent of the context latch A C++ interface:"universal" cdylib that calls another module via modules().<dep>... segfaulted on its FIRST cross-module call: the typed dependency surface (LogosModules) was wired inside lidlTryFireContext, which returns early when no persistence context was stored (g_ctxStored == false). When the daemon never delivers a context (observed: zero set_context calls for a context-less module), maybeSetLogosModules never ran, m_logosModulesPtr stayed null, and LogosModuleContext::modules() dereferenced null. modules() does not need the context — each dependency client bakes its target+origin at codegen time and creates its lp client lazily on first call. So wire it in its own context-independent once-latch (lidlEnsureModulesWired), called at the top of lidlTryFireContext before the context-gated early return, i.e. on the first dispatch / set_context / set_emit_callback. A module with deps but no stored context now has modules() wired before any handler runs. (Bump the concurrent-dispatch doctest's post-daemon-start sleep 3 -> 6 to match the rust spec's cold-start margin.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: green the universal-cdylib concurrent-dispatch doctest + wire into CI The driver/worker split a declarations-only impl header (so the cpp-generator's --header-to-lidl doesn't choke on inline std calls) from the impl body. That body was never compiled — metadata's nix.cmake.extra_sources is parsed but not consumed by the LogosModule.cmake the build actually uses — so the impl symbols (FanoutDriverModuleImpl::fanOut / ::peak) were UNDEFINED in the dylib and the plugin null-jumped (bl -> 0x0) on the first cross-module call. Pass the impl .cpp via logos_module()'s existing SOURCES argument so it's compiled and linked. With this the cpp universal-cdylib reaches worker peak overlap 4 end-to-end (a single-threaded driver fans out 4 async calls into a concurrency:"multi" worker and all four overlap), matching the Rust half. Wire the spec into doctests.yml so the workspace pipeline runs it. (Auto-wiring metadata.extra_sources — so the split pattern works without listing SOURCES by hand — needs the consumer added to the backend LogosModule.cmake copies in logos-plugin-core / logos-plugin-qt; tracked separately.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: bump logos-protocol to merged master (protocol#5) logos-protocol 9de4165 → 4ea32a3 (concurrent-dispatch handshake coalescing, now on master) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
99 lines
3.9 KiB
Bash
Executable File
99 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Execute the cpp-sdk doc-tests end-to-end and regenerate their Markdown.
|
|
#
|
|
# Specs run here:
|
|
# - cpp-sdk-module-runtime.test.yaml a real module (accounts) built and
|
|
# run through logoscore against this SDK
|
|
# - cpp-sdk-module-composition.test.yaml two modules built against this SDK,
|
|
# one calling the other over IPC
|
|
#
|
|
# The runner is the shared `doctest` CLI
|
|
# (https://github.com/logos-co/logos-doctest), invoked directly via its flake.
|
|
# `doctest run` executes every command in a temp directory and asserts on the
|
|
# output; `doctest generate` renders each spec to Markdown under outputs/;
|
|
# `doctest clean` strips build artifacts so only the generated docs remain.
|
|
#
|
|
# To run against a local logos-doctest checkout instead of the published flake,
|
|
# set DOCTEST, e.g.: DOCTEST="nix run path:../../logos-doctest --" ./run.sh
|
|
#
|
|
set -euo pipefail
|
|
|
|
# Run from this doctests/ directory regardless of where the script is invoked from.
|
|
cd "$(dirname "$0")"
|
|
|
|
# The doctest CLI. Override by exporting DOCTEST (space-separated command).
|
|
read -r -a DOCTEST <<< "${DOCTEST:-nix run github:logos-co/logos-doctest --}"
|
|
OUTPUT_DIR="./outputs"
|
|
SPECS=(
|
|
"cpp-sdk-module-runtime.test.yaml"
|
|
"cpp-sdk-module-composition.test.yaml"
|
|
"cpp-sdk-worker-thread-http.test.yaml"
|
|
"cpp-sdk-concurrent-dispatch.test.yaml"
|
|
"cpp-sdk-generator-roundtrip.test.yaml"
|
|
)
|
|
|
|
# Build the doc-tests against THIS repo's current commit rather than the latest
|
|
# published flake. Each spec overrides `logos-cpp-sdk` with
|
|
# `github:logos-co/logos-cpp-sdk{release}`, and the pin below makes {release}
|
|
# expand to $COMMIT — so every layer is built against exactly what's checked out
|
|
# here. Override by exporting COMMIT (e.g. a tag), or set COMMIT="" to fall back
|
|
# to latest master.
|
|
#
|
|
# Note: nix fetches the commit from the GitHub remote, so $COMMIT must be pushed
|
|
# to logos-co/logos-cpp-sdk. A local-only / uncommitted HEAD won't resolve;
|
|
# export COMMIT="" (or push first) in that case.
|
|
COMMIT="${COMMIT-$(git rev-parse HEAD)}"
|
|
RELEASE_FOR=()
|
|
if [ -n "${COMMIT}" ]; then
|
|
RELEASE_FOR=(--release-for "logos-cpp-sdk=${COMMIT}")
|
|
echo "==> Pinning logos-cpp-sdk to ${COMMIT}"
|
|
else
|
|
echo "==> COMMIT empty; building against latest logos-cpp-sdk master"
|
|
fi
|
|
|
|
echo "==> Clearing previous ${OUTPUT_DIR}/"
|
|
# A prior run copies module artifacts out of the read-only nix store, so the
|
|
# directories land read-only (r-x) too. `rm -rf` can't delete files inside a
|
|
# directory it can't write to, so restore write permission first.
|
|
if [ -e "${OUTPUT_DIR}" ]; then
|
|
chmod -R u+w "${OUTPUT_DIR}" 2>/dev/null || true
|
|
fi
|
|
rm -rf "${OUTPUT_DIR}"
|
|
mkdir -p "${OUTPUT_DIR}"
|
|
|
|
for SPEC in "${SPECS[@]}"; do
|
|
name="$(basename "${SPEC%.test.yaml}")"
|
|
# Each spec runs in its OWN workdir under outputs/. They must not share one:
|
|
# a standalone spec uses --output-dir directly as its working tree, and the
|
|
# runtime spec leaves read-only nix-store copies under modules/ that a second
|
|
# spec's `cp` into the same tree could not overwrite. The rendered .md is
|
|
# still written flat into outputs/ (matching the .gitignore keep rule).
|
|
spec_out="${OUTPUT_DIR}/${name}"
|
|
mkdir -p "${spec_out}"
|
|
|
|
echo "==> Running ${SPEC} into ${spec_out}/"
|
|
# ${RELEASE_FOR[@]+...} guards the expansion so an empty array doesn't trip
|
|
# `set -u` on older bash (e.g. macOS's stock 3.2).
|
|
"${DOCTEST[@]}" run "${SPEC}" \
|
|
--verbose \
|
|
--continue-on-fail \
|
|
${RELEASE_FOR[@]+"${RELEASE_FOR[@]}"} \
|
|
--output-dir "${spec_out}/"
|
|
|
|
echo "==> Generating ${OUTPUT_DIR}/${name}.md"
|
|
"${DOCTEST[@]}" generate "${SPEC}" \
|
|
${RELEASE_FOR[@]+"${RELEASE_FOR[@]}"} \
|
|
-o "${OUTPUT_DIR}/${name}.md"
|
|
done
|
|
|
|
if [ ! -d "${OUTPUT_DIR}" ]; then
|
|
echo "==> No ${OUTPUT_DIR}/ produced; nothing to clean."
|
|
exit 0
|
|
fi
|
|
|
|
echo "==> Cleaning build artifacts from ${OUTPUT_DIR}/"
|
|
"${DOCTEST[@]}" clean "${OUTPUT_DIR}" --verbose
|
|
|
|
echo "==> Done. Rendered docs are in ${OUTPUT_DIR}/"
|