docs/ci: selfhost bootstrap/exe-first workflows; add ny-llvmc scaffolding + JSON v0 schema validation; plan: unify to Nyash ABI v2 (no backwards compat)

This commit is contained in:
Selfhosting Dev
2025-09-17 20:33:19 +09:00
parent a5054a271b
commit 4ea3ca2685
56 changed files with 2275 additions and 1623 deletions

View File

@ -13,13 +13,16 @@ fi
echo "[bootstrap] c0 (rust) → c1 (ny) → c1' parity (JIT-only)" >&2
# c0: baseline run (rust path)
NYASH_DISABLE_PLUGINS=1 NYASH_CLI_VERBOSE=1 "$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c0.out
timeout -s KILL 20s env NYASH_DISABLE_PLUGINS=1 NYASH_CLI_VERBOSE=1 \
"$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c0.out
# c1: try Ny compiler path (flagged); tolerate fallback to rust path
NYASH_DISABLE_PLUGINS=1 NYASH_USE_NY_COMPILER=1 NYASH_CLI_VERBOSE=1 "$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c1.out || true
timeout -s KILL 20s env NYASH_DISABLE_PLUGINS=1 NYASH_USE_NY_COMPILER=1 NYASH_CLI_VERBOSE=1 \
"$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c1.out || true
# c1': re-run (simulated second pass)
NYASH_DISABLE_PLUGINS=1 NYASH_USE_NY_COMPILER=1 NYASH_CLI_VERBOSE=1 "$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c1p.out || true
timeout -s KILL 20s env NYASH_DISABLE_PLUGINS=1 NYASH_USE_NY_COMPILER=1 NYASH_CLI_VERBOSE=1 \
"$BIN" --backend vm "$ROOT_DIR/apps/examples/string_p0.nyash" > /tmp/nyash-c1p.out || true
H0=$(rg -n '^Result:\s*' /tmp/nyash-c0.out | sed 's/\s\+/ /g')
H1=$(rg -n '^Result:\s*' /tmp/nyash-c1.out | sed 's/\s\+/ /g' || true)

View File

@ -15,7 +15,10 @@ mkdir -p dist/nyash_compiler/tmp
echo 'return 1+2*3' > dist/nyash_compiler/tmp/sample_exe_smoke.nyash
echo "[3/4] Running parser EXE → JSON ..."
(cd dist/nyash_compiler && ./nyash_compiler tmp/sample_exe_smoke.nyash > sample.json)
(cd dist/nyash_compiler && timeout -s KILL 60s ./nyash_compiler tmp/sample_exe_smoke.nyash > sample.json)
echo "[3.5/4] Validating JSON schema ..."
python3 tools/validate_mir_json.py dist/nyash_compiler/sample.json
if ! head -n1 dist/nyash_compiler/sample.json | grep -q '"kind":"Program"'; then
echo "error: JSON does not look like a Program" >&2
@ -26,7 +29,7 @@ echo "[4/4] Executing via bridge (pipe) to verify semantics ..."
# Keep core minimal and deterministic
export NYASH_DISABLE_PLUGINS=1
set +e
cat dist/nyash_compiler/sample.json | ./target/release/nyash --ny-parser-pipe --backend vm >/dev/null
timeout -s KILL 60s bash -c 'cat dist/nyash_compiler/sample.json | ./target/release/nyash --ny-parser-pipe --backend vm >/dev/null'
RC=$?
set -e
if [[ "$RC" -ne 7 ]]; then
@ -36,4 +39,3 @@ fi
echo "✅ EXE-first smoke passed (parser EXE + bridge run)"
exit 0

View File

@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""
Validate a MIR JSON file against the Nyash JSON v0 schema.
Usage:
python3 tools/validate_mir_json.py <file.json> [--schema docs/reference/mir/json_v0.schema.json]
Requires the 'jsonschema' Python package. Install via:
python3 -m pip install jsonschema
"""
import argparse
import json
import sys
from pathlib import Path
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument('json_file', help='MIR JSON file path')
ap.add_argument('--schema', default='docs/reference/mir/json_v0.schema.json', help='Schema JSON path')
args = ap.parse_args()
try:
import jsonschema # type: ignore
except Exception:
print('[schema] error: Python package "jsonschema" not found.\n'
'Install with: python3 -m pip install jsonschema', file=sys.stderr)
return 2
try:
with open(args.json_file, 'r', encoding='utf-8') as f:
data = json.load(f)
except Exception as e:
print(f'[schema] error: failed to read JSON: {e}', file=sys.stderr)
return 3
try:
with open(args.schema, 'r', encoding='utf-8') as f:
schema = json.load(f)
except Exception as e:
print(f'[schema] error: failed to read schema: {e}', file=sys.stderr)
return 4
try:
jsonschema.validate(instance=data, schema=schema)
except jsonschema.ValidationError as e: # type: ignore
# Show human-friendly context
path = '/'.join([str(p) for p in e.path])
print(f'[schema] validation failed at $.{path}: {e.message}', file=sys.stderr)
return 5
print('[schema] validation OK')
return 0
if __name__ == '__main__':
sys.exit(main())