Repository navigation
Description
Context
#203 needs a guaranteed native clangd server. The llvm-vs-code-extensions.vscode-clangd extension is the language client; it does not guarantee that the native server is installed. clang-tool-chain-bins v0.4.6 now supplies clangd for all six FastLED desktop targets, and VS Code supports publishing platform-specific VSIX packages under one extension version.
This issue owns only native artifact ingestion, bundle discovery/probing, target-specific packaging, native validation, and publication. #203 remains responsible for installing the clangd/cpptools extensions, choosing exactly one language engine, writing clangd.path, generating editor metadata, and restarting language clients.
PR #183 must land first because it introduces the tracked vscode-plugin/ source used below.
Verified constraints
The implementation must use the package-local index from the pinned Python distribution, not a mutable remote index:
uvx --from clang-tool-chain-bins==0.4.6 clang-tool-chain-bins install clangd \
--component clang-extra \
--platform <win|linux|darwin> \
--arch <x86_64|arm64> \
--version <21.1.5|21.1.6> \
--home-dir <cache-dir>
The command prints exactly one JSON object. Use its install_path; do not reconstruct the install directory name (clang-extra is normalized to clang_extra internally). Accept only installed and already_installed status values and verify every returned identity field against the lock below.
The upstream clang-extra archive builder copies every sibling LLVM shared library, even when clangd does not load it. Copying the whole archive would produce unnecessarily large VSIX packages. Direct inspection established the following minimal runtime contract:
bin/clangd[.exe]
lib/clang/21/include/**
third_party/llvm/LICENSE.TXT
third_party/llvm/NOTICE.md
manifest.json
Do not copy lib/clang/21/lib, lib/*.so*, lib/*.dylib, bin/*.dll, or any other clang tool. Representative binary inspection found only operating-system dependencies:
- Windows x64 imports Windows system DLLs only.
- Linux x64 needs glibc, libm, libz, and the ELF loader only; it does not load
libLLVMorlibclang. - macOS ARM64 loads only
/usr/lib/libSystem,/usr/lib/libz, and/usr/lib/libc++.
The native matrix must enforce this contract for all six targets. A local Windows x64 minimal bundle passed clangd --check and compressed from 57.84 MiB to 18.36 MiB. A Linux x64 minimal bundle passed the same check in a clean Ubuntu 24.04 container with an empty PATH and compressed from 110.68 MiB to 29.26 MiB.
Primary references:
- VS Code platform packages: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#platform-specific-extensions
- Pinned tool index: https://github.com/zackees/clang-tool-chain-bins/blob/v0.4.6/clang_tool_chain_bins/_impl/data/tool-index.json
- Upstream archive builder: https://github.com/zackees/clang-tool-chain-bins/blob/v0.4.6/tools/create_clang_extra_archives.py
- Upstream native validator: https://github.com/zackees/clang-tool-chain-bins/blob/v0.4.6/tools/validate_clang_extra.py
Normative implementation specification
1. Commit the complete artifact lock
Create vscode-plugin/clangd-artifacts.json with this schema and initial data. These values come from the packaged v0.4.6 index and provenance sidecars; do not replace them with latest lookups.
{
"schema_version": 1,
"provider": {
"package": "clang-tool-chain-bins",
"package_version": "0.4.6",
"component": "clang-extra"
},
"targets": {
"win32-x64": {
"platform": "win",
"arch": "x86_64",
"llvm_version": "21.1.5",
"llvm_commit": "8e2cd28cd4ba46613a46467b0c91b1cabead26cd",
"provenance_method": "extracted",
"archive_filename": "clang-extra-21.1.5-win-x86_64.tar.zst",
"archive_sha256": "342b91b880a52c47223ac25a5a9652c56c6460fee93738ffd069b62ba07837c7",
"binary_path": "bin/clangd.exe",
"binary_size": 45101568,
"binary_sha256": "ceef318729b3e3f75925d3cadd232cc52a679b77112e3f2f883733d3b9348f7f",
"resource_include_path": "lib/clang/21/include"
},
"win32-arm64": {
"platform": "win",
"arch": "arm64",
"llvm_version": "21.1.5",
"llvm_commit": "8e2cd28cd4ba46613a46467b0c91b1cabead26cd",
"provenance_method": "extracted",
"archive_filename": "clang-extra-21.1.5-win-arm64.tar.zst",
"archive_sha256": "00f220603612c22a063159745e2834508b6278bcd575dbe8e1ddf4b4784c81ef",
"binary_path": "bin/clangd.exe",
"binary_size": 41637376,
"binary_sha256": "38534a0e6ad32512ef8f57ee640b8f30da19137c7deb43a25d7d1bb3488f7441",
"resource_include_path": "lib/clang/21/include"
},
"linux-x64": {
"platform": "linux",
"arch": "x86_64",
"llvm_version": "21.1.5",
"llvm_commit": "8e2cd28cd4ba46613a46467b0c91b1cabead26cd",
"provenance_method": "extracted",
"archive_filename": "clang-extra-21.1.5-linux-x86_64.tar.zst",
"archive_sha256": "e02a9fbf7e0ef2ae466ef90f7ac1fff03a165dfb707ddf3f4249e4be7360933e",
"binary_path": "bin/clangd",
"binary_size": 100539280,
"binary_sha256": "26a89213310f41bc4b63184726aa1f1995703aef69de1d00b41a562d7e6afe69",
"resource_include_path": "lib/clang/21/include"
},
"linux-arm64": {
"platform": "linux",
"arch": "arm64",
"llvm_version": "21.1.5",
"llvm_commit": "8e2cd28cd4ba46613a46467b0c91b1cabead26cd",
"provenance_method": "extracted",
"archive_filename": "clang-extra-21.1.5-linux-arm64.tar.zst",
"archive_sha256": "fa48034cf7e29879ee3f0d89925aa3ef6d5dc068fb5e4d0af32af8a92f0f5643",
"binary_path": "bin/clangd",
"binary_size": 95086552,
"binary_sha256": "5f450cf0a2f9fbb66aca2bd9bdc43fb75f1ff9eae208328e8bab1cfc0e7e7af8",
"resource_include_path": "lib/clang/21/include"
},
"darwin-x64": {
"platform": "darwin",
"arch": "x86_64",
"llvm_version": "21.1.6",
"llvm_commit": "a832a5222e489298337fbb5876f8dcaf072c5cca",
"provenance_method": "forge",
"archive_filename": "clang-extra-21.1.6-darwin-x86_64.tar.zst",
"archive_sha256": "9b87a73523cc9d9e9fb1781b552418fc48f4f77616f44d092a074d62a13c1934",
"binary_path": "bin/clangd",
"binary_size": 58535376,
"binary_sha256": "9f4ff95171aa35a0e89815eb1a22de0059dd6c52da15d3ba1a66a5d0dc9b64c3",
"resource_include_path": "lib/clang/21/include"
},
"darwin-arm64": {
"platform": "darwin",
"arch": "arm64",
"llvm_version": "21.1.6",
"llvm_commit": "a832a5222e489298337fbb5876f8dcaf072c5cca",
"provenance_method": "extracted",
"archive_filename": "clang-extra-21.1.6-darwin-arm64.tar.zst",
"archive_sha256": "a668593eada9da5222b4c9d40fb84f72772cf4db1e9ca1cc91d82b38ec73a7a0",
"binary_path": "bin/clangd",
"binary_size": 58428896,
"binary_sha256": "b03fb31978f7238229e29004f6f8a366d2009cbe9c2086d0d6abb5d7b297a88b",
"resource_include_path": "lib/clang/21/include"
}
}
}Lock validation must reject unknown keys, missing targets, duplicate (platform, arch) pairs, unsupported VS Code targets, non-hex hashes, non-positive sizes, absolute paths, and any path containing ...
2. Implement deterministic ingestion
Create vscode-plugin/scripts/ingest_clangd.py with this interface:
python scripts/ingest_clangd.py \
--target <six-target-name> \
--output resources/clangd \
--ctcb-home <cache-directory>
python scripts/ingest_clangd.py --clean --output resources/clangd
Algorithm:
- Load and strictly validate
clangd-artifacts.json. - Run the pinned
uvx --from clang-tool-chain-bins==<version>install command shown above. Set a hard download/install timeout and print the child output on failure. - Parse exactly one JSON object from stdout and compare
component,platform,arch,version,archive_sha256, and operation status with the lock. - Treat the returned
install_pathas untrusted input: resolve it, require that it exists, and never construct commands withshell=True. - Verify the source
clangdbyte size and SHA256 before copying anything. - Require
lib/clang/21/include/stddef.handstdint.has resource sentinels. - Stage into a temporary sibling directory, never directly into the final output.
- Copy only:
- the locked
binary_path; - the complete locked
resource_include_pathtree; vscode-plugin/third_party/llvm/LICENSE.TXT;vscode-plugin/third_party/llvm/NOTICE.md.
- the locked
- Set the staged Unix binary mode to
0755; do not alter header modes. - Generate
resources/clangd/manifest.jsonwith sorted keys and a trailing newline. It must containschema_version,target, LLVM version/commit, CTCB version/archive hash, binary relative path/size/hash, resource directory, and a sorted{path,size,sha256}entry for every staged file except the manifest itself. - Re-hash the completed staging tree, then atomically replace the old output directory.
- On every failure, delete only the temporary staging directory and leave any previously valid output untouched.
The script must not copy symlinks, device files, files outside the resolved install root, lib/clang/21/lib, sibling LLVM libraries, or other executables.
Commit vscode-plugin/third_party/llvm/LICENSE.TXT from the pinned LLVM tag and a NOTICE.md that lists both LLVM versions/commits, the six artifact origins, clang-tool-chain-bins as the distributor, and the Apache-2.0-with-LLVM-exception terms. The current CTCB archives do not contain these license files, so ingestion must fail if the committed copies are absent.
3. Add native/runtime and VSIX verifiers
Create:
vscode-plugin/scripts/verify_clangd_runtime.pyvscode-plugin/scripts/verify_vsix.pyvscode-plugin/test/fixtures/clangd/fixture.cppvscode-plugin/test/fixtures/clangd/compile_commands.json.in
verify_clangd_runtime.py --root resources/clangd --target <target> must:
- validate every manifest path, size, and SHA256;
- reject any file outside the exact payload allowlist;
- verify PE, ELF, or Mach-O architecture without executing a foreign-architecture binary;
- on the native target, run the absolute binary path with
PATHempty and a five-second timeout; - require
clangd --versionto report the locked LLVM version and expected target architecture; - render an absolute
compile_commands.jsonfrom the fixture template and runclangd --checkwith C++20,-target wasm32-wasi,-nostdinc++, and-fsyntax-only; - reject unresolved native dependencies;
- reject packaged LLVM dependencies:
- Windows: no imported DLL may resolve inside the bundle;
- Linux:
readelf -dmust not containlibLLVMorlibclang, andlddmust contain nonot foundresult; - macOS: every
otool -Ldependency must begin with/usr/lib/or/System/Library/; reject@rpath,@loader_path, and bundle-relative dylibs.
verify_vsix.py --vsix <file> --target <target|universal> must use Python zipfile and verify:
- the VSIX target and filename match;
extension/package.jsonhas the expected version and"extensionKind": ["workspace"];- a native VSIX has exactly one
extension/resources/clangd/manifest.jsonand its target matches; - the packaged file hashes equal the generated manifest;
- the only native executable is
bin/clangd[.exe]; - no path contains another clang tool,
lib/clang/21/lib,*.dll,*.so*, or*.dylib; - the universal VSIX contains no
extension/resources/clangd/path.
4. Add the TypeScript bundle API
Create vscode-plugin/src/clangdBundle.ts and export these stable shapes (additional diagnostic fields are allowed):
export type BundledClangdResult =
| { kind: 'ready'; path: string; target: string; version: string }
| { kind: 'unavailable'; reason: 'universal-package' | 'unsupported-host' }
| {
kind: 'invalid';
reason:
| 'manifest-missing'
| 'manifest-invalid'
| 'target-mismatch'
| 'binary-missing'
| 'binary-hash-mismatch'
| 'resource-dir-missing'
| 'not-executable'
| 'probe-timeout'
| 'probe-failed'
| 'version-mismatch';
message: string;
};
export interface FastLedExtensionApi {
resolveBundledClangd(): Promise<BundledClangdResult>;
}Resolver behavior:
- Map the extension-host
process.platform/process.archpair to one of the six VS Code targets. Onlyx64andarm64are accepted. - Locate
resources/clangd/manifest.jsonrelative toExtensionContext.extensionUri. - A missing manifest in the universal package is
unavailable, not an error. Determine that package type from a small build marker inpackage.jsonor a generated package metadata file; do not treat arbitrary corruption as universal fallback. - Validate the manifest schema and target before resolving paths. Reject traversal and require all resolved paths to remain below the bundle root.
- Verify binary size/SHA256 and resource sentinels. Full header-tree verification remains a CI/package responsibility.
- On Unix, check execute access; attempt one
chmod(0755)repair and recheck. - Probe with
child_process.execFile, never a shell:clangd --version, five-second timeout,windowsHide: true, and a bounded output buffer. - Require the locked LLVM version and expected platform/architecture in probe output.
- Return the absolute binary path. Do not search
PATH, download anything, modifyLD_LIBRARY_PATH/DYLD_LIBRARY_PATH, writeclangd.path, activate the clangd extension, or select a language engine in this issue.
Change activate() to return FastLedExtensionApi. #203 can call the same resolver internally. Add a FastLED: Show Bundled clangd Diagnostics command that logs target, version, path, and structured failure reason without dumping the environment.
Add this manifest field so remote SSH/WSL/Dev Container installations run beside the workspace and receive the package matching the remote extension host:
"extensionKind": ["workspace"]5. Make packaging stale-state-safe
Create vscode-plugin/scripts/package_extension.py:
python scripts/package_extension.py --target <six-target-name|universal> --out dist/
For a native target it must clean, ingest, verify, run npm run compile, package, inspect, and finally remove the generated staging directory. For universal it must clean the staging directory before packaging and prove the resulting VSIX contains no native payload. A failed build must not leave a target payload that a later universal build can accidentally package.
Pin @vscode/vsce in devDependencies and package-lock.json; invoke the local binary through npx --no-install vsce. Use Node 22 in CI. Output names are normative:
dist/fastled-wasm-<version>-win32-x64.vsix
dist/fastled-wasm-<version>-win32-arm64.vsix
dist/fastled-wasm-<version>-linux-x64.vsix
dist/fastled-wasm-<version>-linux-arm64.vsix
dist/fastled-wasm-<version>-darwin-x64.vsix
dist/fastled-wasm-<version>-darwin-arm64.vsix
dist/fastled-wasm-<version>-universal.vsix
Update ignores as follows:
.gitignore: ignore/resources/clangd/,/dist/, and local CTCB caches..vscodeignore: continue includingresources/clangd/**andthird_party/llvm/**, but exclude scripts, tests, fixtures, caches, and source maps.
6. Add tests and commands
Add Python unit tests under vscode-plugin/scripts/tests/ covering:
- the exact six-target lock and mapping;
- malformed locks and unsafe paths;
- installer JSON parsing and identity mismatch;
- hash/size mismatch;
- missing resource sentinels;
- copy allowlist and rejection of symlinks;
- atomic replacement and failure preservation;
- deterministic manifest ordering;
- universal cleanup after a native package;
- VSIX content/target/version validation.
Add TypeScript tests under vscode-plugin/src/test/ covering every BundledClangdResult variant, host mapping, traversal rejection, timeout/kill behavior, hash mismatch, chmod repair, and successful absolute-path probing. Use @vscode/test-electron for the installed-extension test.
Required local commands:
cd vscode-plugin
npm ci
npm run compile
uv run --no-project --with pytest pytest scripts/tests -q
python scripts/package_extension.py --target <native-host-target> --out dist/
python scripts/package_extension.py --target universal --out dist/
npm test
The Extension Development Host test must install the produced VSIX into a clean profile, remove system clangd from PATH, activate fastled.fastled-wasm, call the returned API, and assert that the ready path is inside the installed extension. The universal test must return unavailable/universal-package without a prompt or download.
7. Add CI and release workflows
Add .github/workflows/vscode-extension.yml for pull requests and pushes that touch vscode-plugin/** or the workflow itself. Use this native matrix:
| Target | Runner |
|---|---|
win32-x64 |
windows-2025 |
win32-arm64 |
windows-11-arm |
linux-x64 |
ubuntu-24.04 |
linux-arm64 |
ubuntu-24.04-arm |
darwin-x64 |
macos-15-intel |
darwin-arm64 |
macos-15 |
Each lane must use npm ci, package on the native runner, run all native verifier checks, install-test its VSIX, and upload the VSIX plus its manifest/SHA256/size report. Cache the CTCB home using a key containing the target and locked archive SHA. Build the universal VSIX on Ubuntu in a separate job. An aggregate job must download all artifacts and fail unless the exact seven filenames and one shared extension version are present.
Add .github/workflows/vscode-extension-release.yml, triggered only by vscode-v* tags. Require the tag suffix to equal vscode-plugin/package.json version exactly. Rebuild the seven packages from that tag SHA, rerun the aggregate verifier, generate SHA256 files and Sigstore attestations, attach everything to the GitHub release, and publish the same seven prebuilt VSIX files to the Marketplace. Never rebuild between GitHub Release upload and Marketplace publication. Use protected credentials/workload identity; no credential may appear in repository files or logs.
Implementation order
- Merge/rebase on PR [codex] track vscode extension #183.
- Add the lock, LLVM licensing files, ingestion script, and Python unit tests.
- Add runtime and VSIX verifiers; prove one local native target plus universal packaging.
- Add
clangdBundle.ts, activation API, diagnostics command, and TypeScript tests. - Add the six-target CI matrix and Extension Development Host tests.
- Add the tag-gated release workflow and documentation.
- Hand the ready-path API to feat(vscode): provide verified clangd and Microsoft C/C++ IntelliSense for WASM sketches #203; do not implement engine arbitration in this PR.
Expected files
vscode-plugin/clangd-artifacts.jsonvscode-plugin/third_party/llvm/LICENSE.TXTvscode-plugin/third_party/llvm/NOTICE.mdvscode-plugin/scripts/ingest_clangd.pyvscode-plugin/scripts/package_extension.pyvscode-plugin/scripts/verify_clangd_runtime.pyvscode-plugin/scripts/verify_vsix.pyvscode-plugin/scripts/tests/**vscode-plugin/src/clangdBundle.tsvscode-plugin/src/test/**vscode-plugin/test/fixtures/clangd/**vscode-plugin/package.jsonvscode-plugin/package-lock.jsonvscode-plugin/.gitignorevscode-plugin/.vscodeignorevscode-plugin/README.md.github/workflows/vscode-extension.yml.github/workflows/vscode-extension-release.yml
Acceptance criteria
- The committed lock contains exactly the six entries and pinned values above; ingestion never resolves
latestor a remote index. - Ingestion uses the returned CTCB
install_path, verifies identity/size/hashes, stages atomically, and copies onlyclangd, builtin headers, license/notice, and the generated manifest. - No native binary, generated payload, VSIX, or CTCB cache is committed to git.
- Every native payload contains no LLVM shared library, other clang executable, compiler runtime library, or
lib/clang/21/libfile. - Every target passes architecture inspection, dependency allowlist checks,
clangd --version, and the C++20/WASMclangd --checkfixture on its native runner with system clangd absent andPATHempty. - The runtime resolver is traversal-safe, bounded, shell-free, does not download, does not search
PATH, and returns the structured result contract above. -
activate()exposesFastLedExtensionApi, and a clean Extension Development Host resolves a path inside the installed target-specific extension. - The universal package contains no clangd payload and reports
unavailable/universal-packagewithout blocking activation. - Packaging a native target followed by universal cannot leak the previous target's staging tree.
- Six platform-specific VSIX files and one universal fallback are generated with the exact names above and a single package version.
- PR CI produces and verifies all seven artifacts; Windows ARM64 runs natively on
windows-11-arm, not under x64 emulation. - A
vscode-v<version>release builds once, verifies once, signs/attests, attaches, and publishes the same bytes to GitHub and the VS Code Marketplace. - LLVM license, version, commit, distribution method, and artifact provenance are present in every native VSIX.
- Python tests, TypeScript tests, Extension Development Host tests, VSIX inspection,
npm run compile,bash lint, and existing repository tests pass. - Documentation gives exact update, local reproduction, offline behavior, supported-target, universal-fallback, and troubleshooting commands.
Out of scope
- Installing or requiring
llvm-vs-code-extensions.vscode-clangdorms-vscode.cpptools. - Writing
clangd.pathor C/C++ settings. - Starting, stopping, or switching language engines.
- Generating
compile_commands.json,.clangd, orc_cpp_properties.json.
Those remain in #203 and consume the verified FastLedExtensionApi produced here.
Related issues
- feat(vscode): provide verified clangd and Microsoft C/C++ IntelliSense for WASM sketches #203 — IntelliSense metadata and one-engine-at-a-time arbitration.
- PR [codex] track vscode extension #183 — initial tracked VS Code extension source.
- feat(clang-extra): package clangd for every supported platform zackees/clang-tool-chain-bins#55 — native clangd for the original five targets.
- feat(clang-extra): publish native Windows ARM64 toolset zackees/clang-tool-chain-bins#73 — native Windows ARM64 clangd.
Activity