Skip to content

Commit 8131ca3

Browse files
committed
test: consume indexed JSON in the openkal cross matrix
1 parent 3341ae5 commit 8131ca3

10 files changed

Lines changed: 127 additions & 4 deletions

‎.agents/docs/2026-10-08-llvm-2313-linux-aarch64-ecosystem-part2-design.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,20 @@ ARM64 原生门在 286 中复用已解析的依赖和缓存,构建并运行同
637637
线程源码。发布后的 CN SubOS 门执行相同原生检查,并将线程交叉
638638
产物交给三个目标系统运行。此补充属于验收要求,跨平台通过结果
639639
另由执行记录陈述。
640+
641+
### 14.5 2026-10-08 代表性索引库交叉验收补充
642+
643+
第 14.3 节第 5 项的交叉路径以 `nlohmann.json@3.12.0` 为代表库。
644+
现有托管线程应用增加真实 `nlohmann.json` 模块依赖,验证 JSON 的
645+
序列化、解析、字面量及 ordered_json 键序。模块由实际 mcpp-index
646+
配方和经哈希核对的上游源码生成,未以测试内的模拟模块替代。
647+
648+
四宿主构建分别记录 mcpp-index 提交,并在目标运行门比较来源;
649+
应用仍按三个目标构建且由对应系统运行。原生 ARM64 与发布后的
650+
CN SubOS 使用实际索引 checkout 供应同一依赖。库行为与 TLS/
651+
线程行为各有独立成功行,目标门要求两者均出现。
652+
653+
原生 GNU 门中的 cjson、sqlite3、fmtlib.fmt、nlohmann.json 四成员
654+
继续保留。其结果不扩展为四库均可在所有 openkal 目标运行;本轮
655+
代表性库交叉声明仅覆盖上述 JSON 模块。其他库所需的平台接口、
656+
文件锁、网络或 TLS provider 按其能力契约另行验证。

‎.agents/docs/2026-10-08-llvm-2313-part2-execution-and-dependencies.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,30 @@ helper 在 Windows 的 Bash 环境中先用 `cygpath -u` 规范输出路径,
400400
按 PATH 查找。运行时目录由 `cd` 与 `pwd` 获取。该更正不改变
401401
引擎、线程源码或 GNU 单测发现,其 Windows 实际验证仍由随后 CI
402402
承担。
403+
404+
## 18. 2026-10-08 代表性索引库交叉覆盖补充
405+
406+
生态复核确认第 14.3 节第 5 项尚有缺口:四个真实索引成员在
407+
原生 GNU 上通过,不能证明代表性库的 openkal 交叉路径。现有
408+
托管应用增加真实 `nlohmann.json@3.12.0` 模块和行为检查,复用
409+
既有构建与目标运行 job。四宿主记录实际 mcpp-index 提交,目标
410+
门同时检查 JSON 与线程成功行。原生门及正式 CN SubOS 使用实际
411+
索引 checkout 供应同一库,原有上游 same-source 示例保留。
412+
413+
本地使用 mcpp-index 提交 `5fc151e0abed68788d9fa7b47e6e3ccb50607706`
414+
与 openkal-llvm-runtime 提交 `b4198d346cf0682c95dc0e51b5c32b096843ee83`,
415+
真实 JSON 模块与应用构建成功。原生应用实际运行 JSON 序列化、
416+
解析、字面量、键序及 TLS/线程检查,286 的静态闭包与双成功行
417+
检查通过。macOS ARM64 与 Windows x64 交叉编译链接分别在
418+
10.70 秒与 7.08 秒完成,其产物架构及 OS 依赖闭包通过检查;
419+
这两份产物的目标系统运行仍须后续 CI 验证。
420+
421+
本地线程应用源码模板 SHA256 为
422+
`cc93548236b09d1d6ea388753782069fc847642b98678c2db94b74c4054c6a6b`。
423+
该记录区分第三方模块的实际消费与仅构建 openkal/标准库的旧样例,
424+
不声明未经此门验证的其他库交叉兼容性。
425+
426+
新增库补充提交前,路径修正提交 `3341ae5e` 的 Windows openkal
427+
job `113112389601` 已成功,实际完成原有样例与线程应用的三个
428+
目标构建,验证第 17 节原生 Windows 路径规范化更正。该 job 使用
429+
新增 JSON 行为检查之前的线程源码,不替代本节新增库的最终 CI。

‎.github/tools/check_openkal_hosted_threads.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
# Build a hosted companion beside an existing runtime checkout/cache. Running
33
# the resulting binary belongs to the target runner, which needs no toolchain.
4+
# MCPP_OPENKAL_INDEX optionally selects the actual nlohmann recipe checkout.
45
set -euo pipefail
56
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
67
echo "usage: $0 RUNTIME_CHECKOUT TARGET [OUTPUT_BINARY_PATH_FILE]" >&2
@@ -34,6 +35,23 @@ fixture="$runtime_root/examples/mcpp-hosted-threads"
3435
mkdir -p "$fixture/src"
3536
cp "$repo_root/tests/fixtures/openkal-hosted-threads/mcpp.toml" "$fixture/mcpp.toml"
3637
cp "$repo_root/tests/fixtures/openkal-hosted-threads/src/main.cpp.in" "$fixture/src/main.cpp"
38+
if [ -n "${MCPP_OPENKAL_INDEX:-}" ]; then
39+
index_path="$MCPP_OPENKAL_INDEX"
40+
manifest_path="$fixture/mcpp.toml"
41+
if command -v cygpath >/dev/null 2>&1; then
42+
index_path=$(cygpath -m "$index_path")
43+
manifest_path=$(cygpath -m "$manifest_path")
44+
fi
45+
python3 - "$manifest_path" "$index_path" <<'PYINDEX'
46+
import json, os, pathlib, sys
47+
manifest = pathlib.Path(sys.argv[1]).resolve()
48+
index = pathlib.Path(sys.argv[2]).resolve()
49+
assert (index / "pkgs/n/nlohmann.json.lua").is_file(), index
50+
relative = os.path.relpath(index, manifest.parent)
51+
with manifest.open("a") as output:
52+
output.write("\n[indices]\nnlohmann = { path = " + json.dumps(relative) + " }\n")
53+
PYINDEX
54+
fi
3755
cd "$fixture"
3856
"$mcpp_bin" build --target "$target" --toolchain "$llvm_toolchain"
3957
binaries=()

‎.github/tools/check_published_arm64_cn_ecosystem.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ grep -q "Hello from $project!" "$work/deployed.log"
7676
cd "$work"
7777
git clone --depth 1 --branch "v$version" https://github.com/mcpp-community/mcpp mcpp-source
7878
git -C mcpp-source rev-parse HEAD | tee "$work/mcpp-source-sha.txt"
79+
git clone --depth 1 https://github.com/mcpp-community/mcpp-index index-source
80+
git -C index-source rev-parse HEAD | tee "$work/index-source-sha.txt"
81+
export MCPP_OPENKAL_INDEX="$work/index-source"
7982
cd mcpp-source
8083
bash tests/e2e/286_the_openkal_stack_still_builds.sh | tee "$work/openkal-native.log"
8184
! grep -q 'SKIP' "$work/openkal-native.log"
8285
grep -qF 'OK: the openkal stack builds, links statically and runs' "$work/openkal-native.log"
8386
grep -qxF 'openkal hosted threads: isolation, destructors and concurrent unwind ok' "$work/openkal-native.log"
87+
grep -qxF 'openkal indexed JSON: dump, parse, literals and ordered_json ok' "$work/openkal-native.log"
8488
cd "$work"
85-
git clone --depth 1 https://github.com/mcpp-community/mcpp-index index-source
86-
git -C index-source rev-parse HEAD | tee "$work/index-source-sha.txt"
8789
export CN_PROBE_MCPP="$MCPP" CN_PROBE_TARGET="$native" CN_PROBE_WORK="$work"
8890
cat > "$work/llvm-consumer" <<'ADAPTER'
8991
#!/usr/bin/env bash
@@ -113,6 +115,7 @@ cd "$work/openkal-source/examples/same-source"
113115
readobj="$MCPP_HOME/registry/data/xpkgs/xim-x-llvm/23.1.3/bin/llvm-readobj"
114116
[[ -x "$readobj" ]] || { echo 'LLVM readobj unavailable'; exit 1; }
115117
mkdir -p "$work/cross"
118+
cp "$work/index-source-sha.txt" "$work/cross/index-source-sha.txt"
116119
sha256sum "$work/mcpp-source/tests/fixtures/openkal-hosted-threads/src/main.cpp.in" | cut -d ' ' -f 1 > "$work/cross/threads-source-sha256.txt"
117120
for target in x86_64-linux-gnu aarch64-macos x86_64-windows-gnu; do
118121
rm -rf target

‎.github/workflows/ci-aarch64-fresh-install.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,12 @@ jobs:
388388
MCPP_E2E_EXPECT_ARCH: aarch64
389389
run: |
390390
set -euo pipefail
391+
export MCPP_OPENKAL_INDEX="$GITHUB_WORKSPACE/_native-mcpp-index"
391392
bash tests/e2e/286_the_openkal_stack_still_builds.sh 2>&1 | tee "$RUNNER_TEMP/native-llvm-arm64/openkal.log"
392393
! grep -q '^SKIP:' "$RUNNER_TEMP/native-llvm-arm64/openkal.log"
393394
grep -qF 'OK: the openkal stack builds, links statically and runs' "$RUNNER_TEMP/native-llvm-arm64/openkal.log"
394395
grep -qxF 'openkal hosted threads: isolation, destructors and concurrent unwind ok' "$RUNNER_TEMP/native-llvm-arm64/openkal.log"
396+
grep -qxF 'openkal indexed JSON: dump, parse, literals and ordered_json ok' "$RUNNER_TEMP/native-llvm-arm64/openkal.log"
395397
- uses: actions/upload-artifact@v4
396398
if: always()
397399
with:

‎.github/workflows/ci-arm64-published-cn.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
sha256sum -c SHA256SUMS
9292
grep -Eq '^[0-9a-f]{40}$' source-sha.txt
9393
grep -Eq '^[0-9a-f]{40}$' engine-release-sha.txt
94+
grep -Eq '^[0-9a-f]{40}$' index-source-sha.txt
9495
grep -Eq '^[0-9a-f]{64}$' threads-source-sha256.txt
9596
chmod +x "$TARGET_FILE"
9697
if [ "$TARGET_SYSTEM" = macos ]; then
@@ -113,6 +114,7 @@ jobs:
113114
"./$threads_file" > threads.log 2>&1
114115
cat threads.log
115116
grep -qxF 'openkal hosted threads: isolation, destructors and concurrent unwind ok' threads.log
117+
grep -qxF 'openkal indexed JSON: dump, parse, literals and ordered_json ok' threads.log
116118
- uses: actions/upload-artifact@v4
117119
if: always()
118120
with:

‎.github/workflows/openkal-cross.yml‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,13 @@ jobs:
251251
"$GITHUB_WORKSPACE/.github/tools/git_clone_retry.sh" \
252252
--quiet --depth 1 -b "$OPENKAL_BRANCH" \
253253
https://github.com/mcpplibs/openkal-llvm-runtime "$RUNNER_TEMP/okl"
254+
"$GITHUB_WORKSPACE/.github/tools/git_clone_retry.sh" \
255+
--quiet --depth 1 https://github.com/mcpp-community/mcpp-index "$RUNNER_TEMP/openkal-index"
256+
export MCPP_OPENKAL_INDEX="$RUNNER_TEMP/openkal-index"
254257
cd "$RUNNER_TEMP/okl/examples/same-source"
255258
mkdir -p "$RUNNER_TEMP/out"
256259
git -C "$RUNNER_TEMP/okl" rev-parse HEAD > "$RUNNER_TEMP/out/source-sha.txt"
260+
git -C "$MCPP_OPENKAL_INDEX" rev-parse HEAD > "$RUNNER_TEMP/out/index-source-sha.txt"
257261
echo "openkal-llvm-runtime source SHA: $(cat "$RUNNER_TEMP/out/source-sha.txt")"
258262
python3 - "$GITHUB_WORKSPACE/tests/fixtures/openkal-hosted-threads/src/main.cpp.in" "$RUNNER_TEMP/out/threads-source-sha256.txt" <<'PYHASH'
259263
import hashlib, pathlib, sys
@@ -459,6 +463,7 @@ jobs:
459463
fail=0
460464
source_sha=""
461465
threads_sha=""
466+
index_sha=""
462467
mkdir -p run-evidence
463468
for host in linux linux-aarch64 macos windows; do
464469
sha_file="art/openkal-built-on-$host/source-sha.txt"
@@ -474,6 +479,10 @@ jobs:
474479
echo "::error::$host built source $sha, expected $source_sha"; fail=1; continue
475480
fi
476481
echo "openkal-llvm-runtime source SHA: $sha"
482+
index_commit=$(tr -d '\r\n' < "art/openkal-built-on-$host/index-source-sha.txt")
483+
[[ "$index_commit" =~ ^[0-9a-f]{40}$ ]] || { echo '::error::invalid index source SHA'; exit 1; }
484+
if [ -z "$index_sha" ]; then index_sha="$index_commit"; fi
485+
[ "$index_commit" = "$index_sha" ] || { echo '::error::index sources differ'; exit 1; }
477486
probe_sha=$(tr -d '\r\n' < "art/openkal-built-on-$host/threads-source-sha256.txt")
478487
[[ "$probe_sha" =~ ^[0-9a-f]{64}$ ]] || { echo '::error::invalid hosted probe digest'; exit 1; }
479488
if [ -z "$threads_sha" ]; then threads_sha="$probe_sha"; fi
@@ -516,6 +525,7 @@ jobs:
516525
"./$threads_bin" > "run-evidence/$host.threads.log" 2>&1
517526
cat "run-evidence/$host.threads.log"
518527
grep -qxF 'openkal hosted threads: isolation, destructors and concurrent unwind ok' "run-evidence/$host.threads.log"
528+
grep -qxF 'openkal indexed JSON: dump, parse, literals and ordered_json ok' "run-evidence/$host.threads.log"
519529
done
520530
[ "$fail" = 0 ] || exit 1
521531
echo "four builds, one system, identical sources, exceptions and hosted TLS/threads"
@@ -722,6 +732,12 @@ jobs:
722732
with:
723733
host: linux-aarch64
724734

735+
- uses: actions/checkout@v4
736+
with:
737+
repository: mcpp-community/mcpp-index
738+
ref: main
739+
path: _openkal-native-index
740+
725741
- name: Native platform and graph stack
726742
env:
727743
MCPP_VENDORED_XLINGS: ${{ env.XLINGS_BIN }}
@@ -731,17 +747,22 @@ jobs:
731747
set -euo pipefail
732748
test "$(uname -m)" = aarch64
733749
export MCPP="$MCPP_FRESH"
750+
export MCPP_OPENKAL_INDEX="$GITHUB_WORKSPACE/_openkal-native-index"
751+
git -C "$MCPP_OPENKAL_INDEX" rev-parse HEAD | tee native-openkal-index-sha.txt
734752
"$MCPP" toolchain install llvm 23.1.3
735753
# The existing test builds real openkal-musl and LLVM runtime packages,
736754
# verifies every graph layer, checks static ELF closure and runs it.
737755
bash tests/e2e/286_the_openkal_stack_still_builds.sh 2>&1 | tee native-openkal.log
738756
grep -qF "ok native aarch64 ELF" native-openkal.log
739757
grep -qF "OK: the openkal stack builds, links statically and runs" native-openkal.log
740758
grep -qxF 'openkal hosted threads: isolation, destructors and concurrent unwind ok' native-openkal.log
759+
grep -qxF 'openkal indexed JSON: dump, parse, literals and ordered_json ok' native-openkal.log
741760
742761
- uses: actions/upload-artifact@v4
743762
if: always()
744763
with:
745764
name: openkal-native-arm64
746-
path: native-openkal.log
765+
path: |
766+
native-openkal.log
767+
native-openkal-index-sha.txt
747768
if-no-files-found: warn

‎tests/e2e/286_the_openkal_stack_still_builds.sh‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,27 @@ default = "llvm@${LLVM_VERSION}"
4949
[dependencies]
5050
openkal-musl = "0.3.5"
5151
openkal-llvm-runtime = "0.1.3"
52+
nlohmann.json = "3.12.0"
5253
TOML
5354

55+
if [ -n "${MCPP_OPENKAL_INDEX:-}" ]; then
56+
index_path="$MCPP_OPENKAL_INDEX"
57+
manifest_path="$PWD/mcpp.toml"
58+
if command -v cygpath >/dev/null 2>&1; then
59+
index_path=$(cygpath -m "$index_path")
60+
manifest_path=$(cygpath -m "$manifest_path")
61+
fi
62+
python3 - "$manifest_path" "$index_path" <<'PYINDEX'
63+
import json, os, pathlib, sys
64+
manifest = pathlib.Path(sys.argv[1]).resolve()
65+
index = pathlib.Path(sys.argv[2]).resolve()
66+
assert (index / "pkgs/n/nlohmann.json.lua").is_file(), index
67+
relative = os.path.relpath(index, manifest.parent)
68+
with manifest.open("a") as output:
69+
output.write("\n[indices]\nnlohmann = { path = " + json.dumps(relative) + " }\n")
70+
PYINDEX
71+
fi
72+
5473
cat > src/main.cpp <<'CPP'
5574
#include <cstdio>
5675
#include <string>
@@ -160,7 +179,8 @@ if ! out="$("$bin" 2>&1)"; then
160179
echo "FAIL: the hosted threads companion did not run: $out"
161180
exit 1
162181
fi
163-
expected="openkal hosted threads: isolation, destructors and concurrent unwind ok"
182+
expected="openkal indexed JSON: dump, parse, literals and ordered_json ok
183+
openkal hosted threads: isolation, destructors and concurrent unwind ok"
164184
[ "$out" = "$expected" ] || { echo "FAIL: wrong hosted threads output: $out"; exit 1; }
165185
echo "$out"
166186

‎tests/fixtures/openkal-hosted-threads/mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ version = "0.1.0"
44

55
[dependencies]
66
openkal-llvm-runtime = { path = "../.." }
7+
nlohmann.json = "3.12.0"

‎tests/fixtures/openkal-hosted-threads/src/main.cpp.in‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import std;
2+
import nlohmann.json;
23

34
namespace {
45
std::atomic<unsigned> arrived{0};
@@ -40,6 +41,17 @@ void worker(unsigned bit) {
4041
}
4142

4243
int main() {
44+
using namespace nlohmann::literals;
45+
const auto value = R"({"answer":42,"items":[2,4,7]})"_json;
46+
const auto parsed = nlohmann::json::parse(value.dump());
47+
const auto ordered = nlohmann::ordered_json::parse(R"({"z":1,"a":2})");
48+
if (parsed != value || parsed["answer"].get<int>() != 42
49+
|| parsed["items"][2].get<int>() != 7
50+
|| ordered.dump() != R"({"z":1,"a":2})") {
51+
std::println("openkal indexed JSON: FAILED");
52+
return 1;
53+
}
54+
std::println("openkal indexed JSON: dump, parse, literals and ordered_json ok");
4355
local.value = 4;
4456
std::thread first(worker, 1);
4557
std::thread second(worker, 2);

0 commit comments

Comments
 (0)