Research-Stack/4-Infrastructure/infra/ene-rds
Brandon Schneider ef7b0849d5 fix(adversarial-review): resolve 35 critical coding bugs across 8 subsystems
Security & correctness fixes from full adversarial review:

Lean (7 fixes):
- FixedPoint.lean: guard false theorem with n > 0 precondition
- QFactor.lean: remove double-scaling error in energy decrease
- AVMIsa/Step.lean: implement addSatQ16/subSatQ16 primitives
- BraidEigensolid.lean: fix crossStep second output argument swap
- SSMS.lean: complete ACI preservation proof (with rounding caveat)
- HouseholderQR.lean: add n > 0 precondition to spectral theorem

Verilog (7 fixes):
- q16_lut_core.v: fix multiply shift (16 → 32 bits)
- q16_lut_top.v: fix valid bit (0 → 1)
- cff_accelerator.v: fix SHA-256 padding (len < 448 check)
- research_stack_top.v: fix trigger aliasing (unique counters)
- Blitter6502OISC_small.v: fix address width (15 → 16 bits)
- spatial_hash_bram.v: add OOB write guard
- tmr_oepi_safety_fsm.v: fix double-increment race

WGSL (6 fixes):
- shaders.wgsl: atomicAdd for concurrent writes
- frustration_qubo.wgsl: double-buffer + CAS loop
- braid_fft.wgsl: workgroupBarrier synchronization
- burgers_scar_filter.wgsl: atomic E_bins array

Rust (9 fixes):
- thermodynamic.rs: Arc::from_raw → Arc::clone (double-free)
- thermodynamic.rs: Box::into_raw → Box (leak)
- tools/src/lib.rs: shell injection → shlex.quote
- ene-node/src/lib.rs: LRU caps, constant-time HMAC, peer caps

Python (6 fixes):
- similarity/__init__.py: pickle.load → RestrictedUnpickler
- AI-Feynman: torch.load → weights_only=True (14 calls)
- fetch_arxiv.py, fetch_s2.py: eval → ast.literal_eval
- topology.py: os.system → shutil.copy2
- SSH pipe: os.system → base64 pipe

Build: lake build 3572 jobs, 0 errors
2026-05-31 23:38:03 -05:00
..
crates fix(adversarial-review): resolve 35 critical coding bugs across 8 subsystems 2026-05-31 23:38:03 -05:00
systemd Stabilize ENE API and context shim 2026-05-25 21:06:46 -05:00
Cargo.lock Stabilize ENE API and context shim 2026-05-25 21:06:46 -05:00
Cargo.toml Stabilize ENE API and context shim 2026-05-25 21:06:46 -05:00
README.md Expand ene-rds Rust workspace and refine devcontainer 2026-05-19 07:52:39 +00:00

ENE RDS — Rust workspace replacing the Python RDS stack

Workspace structure

Crate Purpose Replaces
ene-rds-core Shared PostgreSQL client, DSN builder, vec_to_pgtext, receipts ene_rds_* base connection logic
ene-rds-wiki Wiki CRUD + full-text search + revision tracking ene_rds_wiki_layer.py
ene-rds-ephemeral EphemeralNode thermal zones, tasks, receipts, scars, metrics ene_rds_ephemeral_node.py
ene-rds-chat Chat session ingestion, keyword/semantic search ene_rds_chat_log.py
ene-api Axum HTTP server mounting all surfaces on :3000 ene_chat_api.py + FastAPI
ene-sync Polls opencode.db SQLite → upserts into RDS chat tables ene_claw_sync.py

Build

cd 4-Infrastructure/infra/ene-rds
cargo build --release

Run

Initialize schema only

export RDS_PASSWORD=...
./target/release/ene-sync init-schema

One-shot sync

./target/release/ene-sync sync --embed

Watch mode (polls every 60s)

./target/release/ene-sync watch --interval 60 --embed

API server

./target/release/ene-api
# → http://0.0.0.0:3000/health
# → http://0.0.0.0:3000/sessions
# → http://0.0.0.0:3000/search?q=thermal+zone
# → http://0.0.0.0:3000/wiki/search?q=compression
# → http://0.0.0.0:3000/ephemeral/nodes?zone=hot

Environment variables

Variable Default Purpose
RDS_HOST database-1.cluster-c9i0w8eu8fnv.us-east-2.rds.amazonaws.com PostgreSQL host
RDS_PORT 5432 PostgreSQL port
RDS_USER postgres PostgreSQL user
RDS_PASSWORD Password or IAM token
RDS_DB postgres Database name
OLLAMA_HOST http://localhost:11434 Ollama embedding endpoint
OLLAMA_EMBED_MODEL nomic-embed-text Embedding model

What changed from Python

  • No psycopg2 / boto3 runtime dependency — single static binary
  • tokio-postgres with with-serde_json-1 feature for native JSONB support
  • pgvector vectors passed as '[0.1,0.2,...]'::vector text format
  • Ollama embeddings via reqwest instead of requests
  • SQLite source via rusqlite with bundled bindings
  • Axum replaces FastAPI for the API server

Python bridge (optional)

The standalone bridge_wrapper.py still exists for calling legacy Python modules that have not been ported. The Rust surfaces do not depend on it.