mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-08-10 14:30:34 +00:00
**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>
139 lines
5.8 KiB
Rust
139 lines
5.8 KiB
Rust
#![allow(dead_code)]
|
|
//! enhanced_swarm.rs — Enhanced integrated swarm stub.
|
|
//!
|
|
//! Port of enhanced_integrated_swarm.py (109 lines).
|
|
//!
|
|
//! The original Python module depended on `lean_unified_shim`, which has been
|
|
//! removed from the repository. This module provides the same public surface
|
|
//! but returns a structured manifest that callers can use to trigger the actual
|
|
//! `lake build` pipeline in `0-Core-Formalism/lean/Semantics/`.
|
|
|
|
use serde_json::{json, Value};
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// §1 EnhancedIntegratedSwarm
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
/// Swarm orchestrator stub.
|
|
///
|
|
/// `lean_unified_shim` has been removed; swarm analysis now delegates to the
|
|
/// Lean lake build pipeline directly. Call [`perform_deep_analysis`] to
|
|
/// obtain a manifest that downstream tooling can use to trigger `lake build`
|
|
/// in `0-Core-Formalism/lean/Semantics/`.
|
|
pub struct EnhancedIntegratedSwarm {
|
|
lean_path: String,
|
|
}
|
|
|
|
impl EnhancedIntegratedSwarm {
|
|
/// Construct a new swarm stub pointing at the given Lean source path.
|
|
///
|
|
/// `lean_path` should be the directory containing the Lean `lakefile.lean`
|
|
/// (e.g. `"0-Core-Formalism/lean/Semantics"`).
|
|
pub fn new(lean_path: &str) -> Self {
|
|
Self {
|
|
lean_path: lean_path.to_string(),
|
|
}
|
|
}
|
|
|
|
// ── §1.1 Deep analysis ──────────────────────────────────────────────────
|
|
|
|
/// Return a stub analysis manifest.
|
|
///
|
|
/// The manifest carries `status: "stub"` and a `note` explaining that
|
|
/// `lean_unified_shim` has been removed, together with a `lean_path` field
|
|
/// that downstream tools can use to invoke `lake build` directly.
|
|
///
|
|
/// When the shim is eventually replaced by a live Lean bridge, this method
|
|
/// will return real `domains`, `subdomains`, `tensor_types`, and `manifold`
|
|
/// data.
|
|
pub fn perform_deep_analysis(&self) -> Value {
|
|
// lean_unified_shim has been removed; swarm analysis now delegates
|
|
// to the Lean lake build pipeline directly. This stub returns a
|
|
// manifest that callers can use to trigger the actual lake build.
|
|
json!({
|
|
"status": "stub",
|
|
"note": "enhanced_swarm: lean_unified_shim removed; run `lake build` in 0-Core-Formalism/lean/Semantics for live analysis",
|
|
"lean_path": self.lean_path,
|
|
"domains": [],
|
|
"subdomains": [],
|
|
"tensor_types": [],
|
|
"manifold": {
|
|
"nodes": [],
|
|
"edges": [],
|
|
"topology": {}
|
|
},
|
|
"metadata": {
|
|
"total_domains": 0,
|
|
"total_subdomains": 0,
|
|
"total_tensor_types": 0,
|
|
"manifold_nodes": 0,
|
|
"manifold_edges": 0,
|
|
"manifold_dimension": 0
|
|
}
|
|
})
|
|
}
|
|
|
|
// ── §1.2 Pretty-print helper ────────────────────────────────────────────
|
|
|
|
/// Print `analysis` to stdout (or an error to stderr when `"error"` is
|
|
/// present in the root object).
|
|
pub fn print_analysis(&self, analysis: &Value) {
|
|
if let Some(err) = analysis.get("error") {
|
|
eprintln!("ERROR: {}", err);
|
|
return;
|
|
}
|
|
println!(
|
|
"{}",
|
|
serde_json::to_string_pretty(analysis).unwrap_or_default()
|
|
);
|
|
}
|
|
}
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// §2 Tests
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_stub_status() {
|
|
let swarm = EnhancedIntegratedSwarm::new("0-Core-Formalism/lean/Semantics");
|
|
let analysis = swarm.perform_deep_analysis();
|
|
assert_eq!(analysis["status"], "stub");
|
|
}
|
|
|
|
#[test]
|
|
fn test_lean_path_reflected() {
|
|
let path = "some/lean/path";
|
|
let swarm = EnhancedIntegratedSwarm::new(path);
|
|
let analysis = swarm.perform_deep_analysis();
|
|
assert_eq!(analysis["lean_path"], path);
|
|
}
|
|
|
|
#[test]
|
|
fn test_empty_collections() {
|
|
let swarm = EnhancedIntegratedSwarm::new(".");
|
|
let analysis = swarm.perform_deep_analysis();
|
|
assert!(analysis["domains"].as_array().unwrap().is_empty());
|
|
assert!(analysis["subdomains"].as_array().unwrap().is_empty());
|
|
assert!(analysis["tensor_types"].as_array().unwrap().is_empty());
|
|
assert_eq!(analysis["metadata"]["total_domains"], 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_print_analysis_error_branch() {
|
|
// Smoke-test: should not panic.
|
|
let swarm = EnhancedIntegratedSwarm::new(".");
|
|
let err_val = serde_json::json!({ "error": "something went wrong" });
|
|
swarm.print_analysis(&err_val); // prints to stderr, no panic
|
|
}
|
|
|
|
#[test]
|
|
fn test_print_analysis_ok_branch() {
|
|
let swarm = EnhancedIntegratedSwarm::new(".");
|
|
let analysis = swarm.perform_deep_analysis();
|
|
swarm.print_analysis(&analysis); // prints to stdout, no panic
|
|
}
|
|
}
|