Files
Dario Gabriel LipicarandClaude Opus 5 f05ed5a899 fix(doctests): unpin logoscore-cli, and retire the archived accounts module
The macOS doc-test job has been red since 2026-08-21: every module call came
back {"__logos_rpc_status__":"unauthorized"}, preceded in the daemon log by
capability_module rejecting the CLI's own requestModule handshake. Linux was
green throughout.

NOT MODULE ROT. A freshly-built test_basic_module failed identically to
accounts_module. Bisected on one macOS box, one variable, same CLI, same module:

    liblogos 3893c833 (parent)   ->  "result":42
    liblogos b2a9a0ba (#182)     ->  unauthorized

MECHANISM, from `nm -mu` on the logoscore binary:

    pre-#182:  TokenManager::instance()  (from liblogos_core)
    at-#182:   TokenManager::instance()  (from liblogos_module_client)

#182 made liblogos_core export ZERO TokenManager symbols -- they moved to
liblogos_protocol. macOS two-level namespace then rebound the CLI's imports to
the next image still statically absorbing a copy, so the CLI wrote its token
into one singleton while the runtime authorized against another. ELF cannot
show this: flat namespace collapses every definition onto the first-loaded
image, so Linux held the invariant by accident.

THE PIN IS THE BUG, not the linkage. The shared-runtime split landed as one pin
SET -- logos-protocol 2e3344a, logos-plugin-qt 1aa3e31, logos-liblogos b2a9a0b
(#182), logoscore-cli 2312a3a. This spec pinned the CLI at b92ade06
(2026-06-10) and overrode only logos-liblogos, manufacturing exactly the
half-migrated pairing the set exists to prevent. That pin's own commit (050f2d3)
called it "Temporary -- drop when the chain PRs merge"; nobody did. Dropping the
rev is the fix. logoscore master had already shed the deprecated
logos-module-client in its #48, so nothing there needs changing.

WHY THIS READ AS ONE FLAKY STEP rather than a total auth outage: "Call a method"
asserted on the bare string '"result"', which the unauthorized envelope also
contains. Both calls now assert values -- '"result":"hello"' and '"result":42'.

ALSO RETIRED: logos-accounts-module was archived on 2026-07-22. Both specs now
drive test_basic_module from logos-test-modules, via the
`#modules.$SYSTEM.<name>.lgx` attribute path the logoscore-cli doc-tests already
use. The module-runtime spec no longer clones a repo at all, so it loses its git
prerequisite and one step.

VERIFIED on aarch64-darwin against 959d11d9 -- the exact commit CI failed on:
34 passed, 0 failed (was 34 passed, 1 failed of 35), and zero "rejecting
unauthorized call" lines in the daemon log.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 23:32:20 -03:00

101 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Execute the liblogos doc-tests end-to-end and regenerate their Markdown.
#
# Two specs run, each exercising THIS liblogos commit a different way:
# - liblogos-module-runtime.test.yaml — drives liblogos through the headless
# `logoscore` CLI frontend (build logoscore against this liblogos, install
# test_basic_module, start the daemon, call methods).
# - liblogos-as-a-library.test.yaml — embeds liblogos directly: builds
# liblogos_core from this commit, compiles a small C++ program that links it,
# installs modules with lgpm, and loads test_basic_module through the C API.
#
# 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 the same 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 to run. Each renders to outputs/<its `output:` filename>.md; its
# disposable run artifacts go in a per-spec subdir so the two don't collide.
SPECS=(
"liblogos-module-runtime.test.yaml"
"liblogos-as-a-library.test.yaml"
)
# Build the doc-test against THIS repo's current commit rather than the latest
# published flake. The spec overrides logoscore's `logos-liblogos` input with
# `github:logos-co/logos-liblogos{release}`, and the pin below makes {release}
# expand to $COMMIT — so the runtime 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-liblogos. 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-liblogos=${COMMIT}")
echo "==> Pinning logos-liblogos to ${COMMIT}"
else
echo "==> COMMIT empty; building against latest logos-liblogos 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}"
# Read the `output:` filename a spec renders to (e.g. "foo.md") from its YAML.
spec_output() {
sed -n 's/^output:[[:space:]]*//p' "$1" | head -n1 | tr -d '"'
}
for SPEC in "${SPECS[@]}"; do
STEM="${SPEC%.test.yaml}"
MD="$(spec_output "${SPEC}")"
: "${MD:=${STEM}.md}"
SPEC_OUT="${OUTPUT_DIR}/${STEM}"
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}/${MD}"
"${DOCTEST[@]}" generate "${SPEC}" \
${RELEASE_FOR[@]+"${RELEASE_FOR[@]}"} \
-o "${OUTPUT_DIR}/${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}/."