Files
RuView/harness/ruview-kernel/scripts/verify-artifacts.mjs
T
Claudeandclaude-flow 1938f0251f feat(npm): @ruvnet/ruview-kernel — WASM + napi-rs compute kernel with metaharness e2e (ADR-368)
Adds a portable RuView compute kernel for JavaScript, built from the Rust
source of truth and wired into the @ruvnet/ruview metaharness.

Rust
- v2/crates/ruview-kernel: bounded single-function JSON ABI
  (call(op, json) -> envelope) over the ADR-021 wifi-densepose-vitals
  pipeline: streaming sessions, batch analyze, deterministic SplitMix64
  synthetic CSI (SYNTHETIC), bounded session registry, strict input
  validation (deny_unknown_fields, width/finite/magnitude checks, size and
  count limits). wasm32-only zero-import C ABI (rvk_alloc/free/call).
- v2/crates/ruview-kernel-napi: napi-rs transport exposing only
  abiVersion()/call(); standalone workspace (excluded from v2) so napi never
  enters `cargo test --workspace`; panic=unwind + catch_unwind.

npm (harness/ruview-kernel, zero runtime deps)
- loadKernel({backend: wasm|napi|auto}); WASM default (no host authority),
  napi never silently falls back, auto reports fallbackReason.
- SHA256SUMS integrity verification; mismatch is always fatal; loader
  rejects any WASM module that imports host functions.
- Browser-safe ./wasm entry; CLI doctor/info/selftest/parity/synth/
  analyze/bench; build.mjs builds artifacts from source (no shell).
- Unit, security, and e2e tests (CLI round trip, cross-backend parity).

Metaharness
- New read-only tool ruview_kernel_selftest / `ruview kernel`: imports the
  fixed optional package, fails closed with kernel_not_installed; policy,
  claims, MCP policy, guidance capability, and manifest updated.

CI: .github/workflows/ruview-kernel-npm.yml builds both transports on
Linux/macOS/Windows, requires napi in tests, runs parity, verifies
artifacts, packs, and runs the cross-package e2e. No publish step.

Co-Authored-By: claude-flow <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_015H55jmprfz4oHWXSFbX5rf
2026-09-30 16:23:29 +00:00

45 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
// SPDX-License-Identifier: MIT
// Verify packaged kernel artifacts before pack/publish (ADR-368):
// checksums match, the WASM module imports nothing, and ABI versions agree.
import { existsSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { ABI_VERSION } from '../src/abi.js';
import { DEFAULT_WASM_PATH, PACKAGE_ROOT, loadKernel, readVerifiedArtifact } from '../src/index.js';
import { compileKernelModule } from '../src/wasm.js';
const requireWasm = process.argv.includes('--require-wasm');
const quiet = process.argv.includes('--quiet');
const report = { ok: true, wasm: null, native: [] };
const fail = (message) => { report.ok = false; (report.errors ||= []).push(message); };
if (existsSync(DEFAULT_WASM_PATH)) {
try {
const artifact = readVerifiedArtifact(DEFAULT_WASM_PATH);
if (artifact.integrity !== 'verified') fail('wasm/ruview_kernel.wasm has no SHA256SUMS entry');
compileKernelModule(artifact.bytes);
const kernel = loadKernel({ backend: 'wasm' });
if (kernel.info().abi !== ABI_VERSION) fail('WASM ABI mismatch');
report.wasm = { sha256: artifact.sha256, bytes: artifact.bytes.length, imports: 0 };
} catch (error) {
fail(`wasm: ${error.message}`);
}
} else if (requireWasm) {
fail('wasm/ruview_kernel.wasm is missing; run `npm run build:wasm`');
}
const nativeDir = join(PACKAGE_ROOT, 'native');
for (const name of existsSync(nativeDir) ? readdirSync(nativeDir).filter((n) => n.endsWith('.node')).sort() : []) {
try {
const artifact = readVerifiedArtifact(join(nativeDir, name));
if (artifact.integrity !== 'verified') fail(`native/${name} has no SHA256SUMS entry`);
report.native.push({ name, sha256: artifact.sha256 });
} catch (error) {
fail(`native/${name}: ${error.message}`);
}
}
if (!quiet || !report.ok) console.log(JSON.stringify(report, null, 2));
process.exit(report.ok ? 0 : 1);