Research-Stack/4-Infrastructure/infra/embedded_surface/xen_alpine
Brandon Schneider c9ccc497f8 ene-session-sync: complete Python→Rust port; fix all 6 pre-existing test failures
**New Rust modules (batch 2 — 9 files)**
- src/deepseek_adapter.rs    — DeepSeek/Ollama chat + DeepSeekProver
- src/ene_cloud_credential_manager.rs — ENE cloud credential + node balancer (SQLite)
- src/enhanced_swarm.rs      — enhanced swarm stub
- src/gemma_integration.rs   — SQLite task queue for Gemma 4 model tasks
- src/hyperbolic_encoding.rs — Poincaré disk math, HyperbolicManifoldEncoder
- src/knowledge_ingestion.rs — WolframAlpha, OpenMath, nLab wiki adapters
- src/manifold_perception.rs — filesystem manifest scanner / topological report
- src/s3c_lean_review.rs     — CLI adapter submitting S3C.lean to Gemma4Integration
- src/search_adapter.rs      — Google (stub) + Brave search providers

All 9 wired into main.rs as mod declarations.

**Test fixes (6 pre-existing failures → 0)**
- s3c.rs: fix shell decomp width formula (a+b not a+b+1); correct test
  expectations for n=9 (b=7, not b=1); invariant a+b=2k+1 not 2k
- math.rs: fix test_avg_chain expected avg to 10/6 (all-pairs average,
  not just A→* paths)
- ene_core.rs: fix AES-GCM decrypt AAD mismatch in retrieve_sensitive_data —
  SELECT now fetches pkg column and passes it as AAD (matches store path)
- hyperbolic_encoding.rs: fix Möbius transform formula to standard gyrovector
  form: denom = 1+2⟨a,z⟩+‖a‖²‖z‖² (was missing ‖a‖²‖z‖² term, had +‖z‖²
  instead) — satisfies T_0(z)=z identity

**cargo test: 145 passed, 0 failed**

**Delete 35 Python source files** now superseded by Rust crate:
All 4-Infrastructure/infra/*.py and embedded_surface/server.py removed.

**Deploy scripts updated** to use rs-surface binary instead of Python:
- gcl_edge_in_place_upgrade.sh: CURRENT_SERVER → rs-surface binary; validate
  with test -x; smoke-test exec binary directly; rollback saves rs-surface
- xen_alpine/install_rs_surface_openrc.sh: SERVER_SRC → musl release binary;
  drop python3 from apk; install as rs-surface (not server.py)
- xen_alpine/run_qemu_alpine_surface.sh: default SURFACE_IMPL=rust; RUST_BIN
  var for musl binary; else-branch copies rs-surface; boot script exec binary
- recover_credential_server.sh: upload rs-surface binary; ExecStart → binary
  with RS_SURFACE_PORT=8444 (credential endpoint built into rs-surface /credentials)
- nixos-setup-cred-server.sh: same — ExecStart uses /opt/rs-surface/rs-surface

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-19 14:44:19 +00:00
..
.gitignore chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
install_rs_surface_openrc.sh ene-session-sync: complete Python→Rust port; fix all 6 pre-existing test failures 2026-05-19 14:44:19 +00:00
Makefile chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
README.md chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
rs-surface.openrc chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
rs_surface_nolibc.c chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
rs_surface_static.c chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
run_qemu_alpine_surface.sh ene-session-sync: complete Python→Rust port; fix all 6 pre-existing test failures 2026-05-19 14:44:19 +00:00
smoke_xen_alpine_surface.py chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00
xen-alpine-rs-surface.cfg chore: preserve working tree before secure wipe 2026-05-13 17:36:02 -05:00

Xen Alpine rs-surface

This is a minimal Alpine Linux carrier for the existing rs-surface embedded node API. It is meant for small Xen guests where the useful interface is:

  • serial console first: console=hvc0
  • OpenRC service: rs-surface
  • Python stdlib only at runtime
  • HTTP receipts: /health, /status, /metrics, /primitives
  • binary WebSocket frame lane: /ws

The guest does not need a full Research Stack checkout. The install script copies only server.py, one profile JSON file, and the OpenRC service.

Nanokernel Framing

The minimal path is a two-stage carrier:

Xen/QEMU hardware model
  -> Alpine Linux with VirtIO and serial drivers
  -> rs-surface OpenRC service
  -> bounded GCL/nanokernel primitive surface
  -> future signed layer0 image handoff

In this stage, Alpine is not the trusted architecture. It is the driver shim and rollback carrier. The current rs-surface process exposes the nanokernel-shaped contract: bounded operations, local state budget, serial-first recovery, health receipts, route decisions, snapshots, and explicit refusal of unimplemented recovery transitions.

The profile records a future layer0-gcl-nanokernel handoff, but keeps destructive_handoff_allowed=false and handoff=manual until a signed layer0 image, rollback boot entry, serial health pulse, and QEMU health probe all exist. That makes the nanokernel approach incremental rather than theatrical: first prove the carrier and receipt lane, then replace the Python carrier with the smaller layer0 runtime.

Files

  • xen-alpine-rs-surface.cfg: xl domain template.
  • install_rs_surface_openrc.sh: installs the interface inside Alpine.
  • rs-surface.openrc: OpenRC service file.
  • rs_surface_static.c: small static C surface for uClibc/musl/glibc-static.
  • rs_surface_nolibc.c: smaller x86_64 Linux syscall-only surface.
  • smoke_xen_alpine_surface.py: receipt-producing HTTP smoke check.
  • run_qemu_alpine_surface.sh: disposable QEMU boot smoke using Alpine netboot.
  • ../profiles/xen-alpine-surface.json: default local/recovery profile.

Alpine Guest Install

From a checked-out repo inside the Alpine guest:

cd "4-Infrastructure/infra/embedded_surface/xen_alpine"
doas ./install_rs_surface_openrc.sh
doas rc-service rs-surface start
python3 ./smoke_xen_alpine_surface.py --output /tmp/rs-surface-smoke.json

For a tiny copied payload, set SOURCE_ROOT to the directory containing server.py and profiles/xen-alpine-surface.json:

doas SOURCE_ROOT=/tmp/rs-surface ./install_rs_surface_openrc.sh

QEMU Smoke

The QEMU harness downloads Alpine latest-stable virt netboot assets, builds a small apkovl overlay containing rs-surface, boots Alpine under QEMU, and polls the forwarded health endpoint.

make -C 4-Infrastructure/infra/embedded_surface/xen_alpine qemu-smoke

For the stripped embedded path, build and boot the syscall-only static surface. This is the preferred reduction target for now because it has no libc, no dynamic linker, no Python runtime, no heap, and only a small Linux syscall surface:

make -C 4-Infrastructure/infra/embedded_surface/xen_alpine qemu-static-smoke

When a uClibc toolchain is available, the C surface can be built with:

make -C 4-Infrastructure/infra/embedded_surface/xen_alpine static \
  CC=x86_64-buildroot-linux-uclibc-gcc

Current local receipt from the no-libc path:

runtime=static-nolibc
surface_version=0.1-nolibc
text+data+bss=1627 bytes
stripped ELF=2.4K

Receipt and serial log are written under:

4-Infrastructure/infra/embedded_surface/xen_alpine/build/qemu-alpine/

Those files are ignored because they include downloaded kernel/initramfs/modloop assets and transient boot logs.

Xen Host Sketch

  1. Create a small Alpine guest disk, install linux-lts, openrc, python3, and ca-certificates.
  2. Ensure the guest kernel command line includes console=hvc0.
  3. Copy the tiny surface payload into the guest.
  4. Start the domain with an edited copy of xen-alpine-rs-surface.cfg.
  5. Attach serial console with xl console rs-alpine-surface.
  6. Verify from inside the guest:
rc-service rs-surface status
wget -qO- http://127.0.0.1:8080/health

Bind Modes

The default profile binds to localhost. For an exposed appliance, prefer a Tailscale address by editing the copied profile:

"api": {
  "plain_health_port": 8080,
  "websocket_port": 8080,
  "bind": "tailscale",
  "tailscale_ip": "100.x.y.z"
}

Public bind is supported by the server, but should be paired with an outer firewall or reverse proxy.