mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-08-10 19:40:35 +00:00
ene-session-sync: fix compile errors, add Cargo.lock, delete lean_unified_shim
- Add rusqlite::OptionalExtension import to ene_core.rs (fixes 3 .optional() errors) - Fix borrow conflict in compression.rs DeltaGclService::compress_manifest (split previous.is_some() out before mutable insert) - Fix serde_json Map::get type error in compression.rs (use .as_str()) - Fix tokio::process::Child moved-after-use in misc.rs (capture child.id() before wait_with_output consumes child; use system kill for timeout case) - Fix misc.rs S3CIterativeImprover field names (emit/j_score.total/handles.handle_a) - Fix wiki.rs stmt lifetime error (bind collect result to named variable) - Add Cargo.lock (new dep resolution for sha2, base64, hex, aes-gcm) - Delete lean_unified_shim.py (minimal SwarmAPISystem shim — replaced by Rust) Build: cargo build passes with 0 errors (8 dead-code warnings only). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e782d9f0fe
commit
d511cbe6c0
6 changed files with 2820 additions and 30 deletions
2793
4-Infrastructure/infra/ene-session-sync/Cargo.lock
generated
Normal file
2793
4-Infrastructure/infra/ene-session-sync/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -327,13 +327,17 @@ impl DeltaGclService {
|
||||||
manifest_id: &str,
|
manifest_id: &str,
|
||||||
use_delta: bool,
|
use_delta: bool,
|
||||||
) -> CompressionResult {
|
) -> CompressionResult {
|
||||||
let previous = if use_delta {
|
let (encoded, had_previous) = {
|
||||||
self.previous_manifests.get(manifest_id)
|
let previous = if use_delta {
|
||||||
} else {
|
self.previous_manifests.get(manifest_id)
|
||||||
None
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let had = previous.is_some();
|
||||||
|
let enc = delta_gcl_encode(manifest, previous);
|
||||||
|
(enc, had)
|
||||||
};
|
};
|
||||||
|
|
||||||
let encoded = delta_gcl_encode(manifest, previous);
|
|
||||||
let original_json = serde_json::to_string(manifest).unwrap_or_default();
|
let original_json = serde_json::to_string(manifest).unwrap_or_default();
|
||||||
let original_size = original_json.len();
|
let original_size = original_json.len();
|
||||||
let compressed_size = encoded.len();
|
let compressed_size = encoded.len();
|
||||||
|
|
@ -357,7 +361,7 @@ impl DeltaGclService {
|
||||||
original_size,
|
original_size,
|
||||||
compressed_size,
|
compressed_size,
|
||||||
reduction_percent: reduction,
|
reduction_percent: reduction,
|
||||||
use_delta: previous.is_some(),
|
use_delta: had_previous,
|
||||||
verified,
|
verified,
|
||||||
verification_error,
|
verification_error,
|
||||||
}
|
}
|
||||||
|
|
@ -486,7 +490,7 @@ impl AdaptiveDeltaGcl {
|
||||||
} else {
|
} else {
|
||||||
let changed = shared
|
let changed = shared
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|k| cur.get(*k) != prev.get(*k))
|
.filter(|k| cur.get(k.as_str()) != prev.get(k.as_str()))
|
||||||
.count();
|
.count();
|
||||||
changed as f64 / shared.len() as f64
|
changed as f64 / shared.len() as f64
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use base64::engine::general_purpose::STANDARD as B64;
|
use base64::engine::general_purpose::STANDARD as B64;
|
||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use rusqlite::{params, Connection};
|
use rusqlite::{params, Connection, OptionalExtension};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use sha2::{Digest, Sha256};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
use crate::s3c;
|
||||||
|
|
||||||
// ═════════════════════════════════════════════════════════════════════════════
|
// ═════════════════════════════════════════════════════════════════════════════
|
||||||
// §1 TiddlyWiki ENE Bridge
|
// §1 TiddlyWiki ENE Bridge
|
||||||
|
|
@ -510,6 +511,8 @@ impl ServoFetchAdapter {
|
||||||
};
|
};
|
||||||
|
|
||||||
let timeout = tokio::time::Duration::from_secs(task.timeout_secs.max(1));
|
let timeout = tokio::time::Duration::from_secs(task.timeout_secs.max(1));
|
||||||
|
// `wait_with_output` consumes child; capture id first for timeout handling.
|
||||||
|
let child_id = child.id();
|
||||||
let output = tokio::time::timeout(timeout, child.wait_with_output()).await;
|
let output = tokio::time::timeout(timeout, child.wait_with_output()).await;
|
||||||
|
|
||||||
let elapsed_ms = start.elapsed().as_millis() as u64;
|
let elapsed_ms = start.elapsed().as_millis() as u64;
|
||||||
|
|
@ -548,8 +551,12 @@ impl ServoFetchAdapter {
|
||||||
elapsed_ms,
|
elapsed_ms,
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Timeout — kill the child process best-effort.
|
// Timeout — best-effort kill via process id.
|
||||||
let _ = child.kill().await;
|
if let Some(pid) = child_id {
|
||||||
|
let _ = std::process::Command::new("kill")
|
||||||
|
.arg(pid.to_string())
|
||||||
|
.status();
|
||||||
|
}
|
||||||
WebResult {
|
WebResult {
|
||||||
task_id: task.task_id.clone(),
|
task_id: task.task_id.clone(),
|
||||||
success: false,
|
success: false,
|
||||||
|
|
@ -791,9 +798,9 @@ impl S3CIterativeImprover {
|
||||||
let (emission_ratio, avg_j_total, throat_ratio) = if total == 0 {
|
let (emission_ratio, avg_j_total, throat_ratio) = if total == 0 {
|
||||||
(0.0_f64, 0.0_f64, 0.0_f64)
|
(0.0_f64, 0.0_f64, 0.0_f64)
|
||||||
} else {
|
} else {
|
||||||
let emitted_count = states.iter().filter(|s| s.emitted).count();
|
let emitted_count = states.iter().filter(|s| s.emit).count();
|
||||||
let throat_count = states.iter().filter(|s| s.a == s.b).count();
|
let throat_count = states.iter().filter(|s| s.handles.handle_a == s.handles.handle_b).count();
|
||||||
let j_sum: f64 = states.iter().map(|s| s.j_total as f64).sum();
|
let j_sum: f64 = states.iter().map(|s| s.j_score.total as f64).sum();
|
||||||
|
|
||||||
(
|
(
|
||||||
emitted_count as f64 / total as f64,
|
emitted_count as f64 / total as f64,
|
||||||
|
|
|
||||||
|
|
@ -673,9 +673,10 @@ impl ENEWikiLayer {
|
||||||
let existing: Vec<String> = {
|
let existing: Vec<String> = {
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare("PRAGMA table_info(ene_wiki_revisions)")?;
|
.prepare("PRAGMA table_info(ene_wiki_revisions)")?;
|
||||||
stmt.query_map([], |row| row.get::<_, String>(1))?
|
let cols: Vec<String> = stmt.query_map([], |row| row.get::<_, String>(1))?
|
||||||
.filter_map(|r| r.ok())
|
.filter_map(|r| r.ok())
|
||||||
.collect()
|
.collect();
|
||||||
|
cols
|
||||||
};
|
};
|
||||||
for (col, decl) in &extra_cols {
|
for (col, decl) in &extra_cols {
|
||||||
if !existing.contains(&col.to_string()) {
|
if !existing.contains(&col.to_string()) {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
"""Minimal shim for attestation scripts."""
|
|
||||||
import sqlite3
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
DB_PATH = Path("/home/allaun/Documents/Research Stack/data/math_entities.db")
|
|
||||||
|
|
||||||
class SwarmAPISystem:
|
|
||||||
"""Provides sqlite3 connection to math_entities database."""
|
|
||||||
def __init__(self):
|
|
||||||
self.conn = None
|
|
||||||
try:
|
|
||||||
self.conn = sqlite3.connect(str(DB_PATH), check_same_thread=False)
|
|
||||||
self.conn.row_factory = sqlite3.Row
|
|
||||||
except Exception:
|
|
||||||
self.conn = None
|
|
||||||
Loading…
Add table
Reference in a new issue