Add js.sx bootstrapper docs page with G0 bug discovery writeup

Documents the self-hosting process for js.sx including the G0 bug
where Python's `if fn_expr` treated 0/False/"" as falsy, emitting
NIL instead of the correct value. Adds live verification page,
translation differences table, and nav entry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 01:44:02 +00:00
parent e6ca1a5f44
commit cad65bcdf1
6 changed files with 182 additions and 9 deletions

View File

@@ -459,6 +459,13 @@
:g0-lines g0-lines
:g0-bytes g0-bytes
:verification-status verification-status)
"self-hosting-js"
(~bootstrapper-self-hosting-js-content
:js-sx-source js-sx-source
:defines-matched defines-matched
:defines-total defines-total
:js-sx-lines js-sx-lines
:verification-status verification-status)
"python"
(~bootstrapper-py-content
:bootstrapper-source bootstrapper-source

View File

@@ -230,7 +230,7 @@ def _bootstrapper_data(target: str) -> dict:
"""
import os
if target not in ("javascript", "python", "self-hosting"):
if target not in ("javascript", "python", "self-hosting", "self-hosting-js"):
return {"bootstrapper-not-found": True}
ref_dir = os.path.join(os.path.dirname(__file__), "..", "..", "shared", "sx", "ref")
@@ -239,6 +239,8 @@ def _bootstrapper_data(target: str) -> dict:
if target == "self-hosting":
return _self_hosting_data(ref_dir)
if target == "self-hosting-js":
return _js_self_hosting_data(ref_dir)
if target == "javascript":
# Read bootstrapper source
@@ -353,6 +355,64 @@ def _self_hosting_data(ref_dir: str) -> dict:
}
def _js_self_hosting_data(ref_dir: str) -> dict:
"""Run js.sx live: load into evaluator, translate spec files, diff against G0."""
import os
from shared.sx.parser import parse_all
from shared.sx.types import Symbol
from shared.sx.evaluator import evaluate, make_env
from shared.sx.ref.bootstrap_js import extract_defines, JSEmitter
try:
js_sx_path = os.path.join(ref_dir, "js.sx")
with open(js_sx_path, encoding="utf-8") as f:
js_sx_source = f.read()
exprs = parse_all(js_sx_source)
env = make_env()
for expr in exprs:
evaluate(expr, env)
emitter = JSEmitter()
# All spec files
all_files = sorted(
f for f in os.listdir(ref_dir) if f.endswith(".sx")
)
total = 0
matched = 0
for filename in all_files:
filepath = os.path.join(ref_dir, filename)
with open(filepath, encoding="utf-8") as f:
src = f.read()
defines = extract_defines(src)
for name, expr in defines:
g0_stmt = emitter.emit_statement(expr)
env["_def_expr"] = expr
g1_stmt = evaluate(
[Symbol("js-statement"), Symbol("_def_expr")], env
)
total += 1
if g0_stmt.strip() == g1_stmt.strip():
matched += 1
status = "identical" if matched == total else "mismatch"
except Exception as e:
js_sx_source = f";; error loading js.sx: {e}"
matched, total = 0, 0
status = "error"
return {
"bootstrapper-not-found": None,
"js-sx-source": js_sx_source,
"defines-matched": str(matched),
"defines-total": str(total),
"js-sx-lines": str(len(js_sx_source.splitlines())),
"verification-status": status,
}
def _bundle_analyzer_data() -> dict:
"""Compute per-page component bundle analysis for the sx-docs app."""
from shared.sx.jinja_bridge import get_component_env