AI協調開発研究ドキュメントの完成と Phase 10.9-β 進捗
【AI協調開発研究】 - AI二重化モデルの学術論文draft完成(workshop_paper_draft.md) - 「隠れた危機」分析とbirthの原則哲学化 - TyEnv「唯一の真実」協調会話を保存・研究資料に統合 - papers管理構造の整備(wip/under-review/published分離) 【Phase 10.9-β HostCall進捗】 - JitConfigBox: relax_numeric フラグ追加(i64→f64コアーション制御) - HostcallRegistryBox: 署名検証・白黒リスト・コアーション対応 - JitHostcallRegistryBox: Nyash側レジストリ操作API - Lower統合: env直読 → jit::config::current() 参照に統一 - 数値緩和設定: NYASH_JIT_HOSTCALL_RELAX_NUMERIC/Config.set_flag 【検証サンプル拡充】 - math.sin/cos/abs/min/max 関数スタイル(examples/jit_math_function_style_*.nyash) - 境界ケース: 署名不一致・コアーション許可・mutating拒否サンプル - E2E実証: String.length→allow, Array.push→fallback, math関数の署名一致観測 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -33,6 +33,7 @@ impl JitConfigBox {
|
||||
"native_bool" => cfg.native_bool = on,
|
||||
"bool_abi" | "native_bool_abi" => cfg.native_bool_abi = on,
|
||||
"ret_b1" | "ret_bool_b1" => cfg.ret_bool_b1 = on,
|
||||
"relax_numeric" | "hostcall_relax_numeric" => cfg.relax_numeric = on,
|
||||
_ => return Err(RuntimeError::InvalidOperation { message: format!("Unknown flag: {}", name) }),
|
||||
}
|
||||
Ok(Box::new(VoidBox::new()))
|
||||
@ -51,6 +52,7 @@ impl JitConfigBox {
|
||||
"native_bool" => cfg.native_bool,
|
||||
"bool_abi" | "native_bool_abi" => cfg.native_bool_abi,
|
||||
"ret_b1" | "ret_bool_b1" => cfg.ret_bool_b1,
|
||||
"relax_numeric" | "hostcall_relax_numeric" => cfg.relax_numeric,
|
||||
_ => return Err(RuntimeError::InvalidOperation { message: format!("Unknown flag: {}", name) }),
|
||||
};
|
||||
Ok(Box::new(BoolBox::new(b)))
|
||||
@ -80,6 +82,7 @@ impl JitConfigBox {
|
||||
"native_bool": cfg.native_bool,
|
||||
"native_bool_abi": cfg.native_bool_abi,
|
||||
"ret_bool_b1": cfg.ret_bool_b1,
|
||||
"relax_numeric": cfg.relax_numeric,
|
||||
});
|
||||
Box::new(StringBox::new(val.to_string()))
|
||||
}
|
||||
@ -98,6 +101,7 @@ impl JitConfigBox {
|
||||
if let Some(b) = v.get("native_bool").and_then(|x| x.as_bool()) { cfg.native_bool = b; }
|
||||
if let Some(b) = v.get("native_bool_abi").and_then(|x| x.as_bool()) { cfg.native_bool_abi = b; }
|
||||
if let Some(b) = v.get("ret_bool_b1").and_then(|x| x.as_bool()) { cfg.ret_bool_b1 = b; }
|
||||
if let Some(b) = v.get("relax_numeric").and_then(|x| x.as_bool()) { cfg.relax_numeric = b; }
|
||||
Ok(Box::new(VoidBox::new()))
|
||||
}
|
||||
pub fn apply(&self) -> Box<dyn NyashBox> {
|
||||
@ -111,9 +115,9 @@ impl JitConfigBox {
|
||||
pub fn summary(&self) -> Box<dyn NyashBox> {
|
||||
let cfg = self.config.read().unwrap();
|
||||
let s = format!(
|
||||
"exec={} stats={} json={} dump={} thr={:?} phi_min={} hostcall={} hdbg={} f64={} bool={}",
|
||||
"exec={} stats={} json={} dump={} thr={:?} phi_min={} hostcall={} hdbg={} f64={} bool={} relax_numeric={}",
|
||||
cfg.exec, cfg.stats, cfg.stats_json, cfg.dump, cfg.threshold,
|
||||
cfg.phi_min, cfg.hostcall, cfg.handle_debug, cfg.native_f64, cfg.native_bool
|
||||
cfg.phi_min, cfg.hostcall, cfg.handle_debug, cfg.native_f64, cfg.native_bool, cfg.relax_numeric
|
||||
);
|
||||
Box::new(StringBox::new(s))
|
||||
}
|
||||
|
||||
37
src/boxes/jit_hostcall_registry_box.rs
Normal file
37
src/boxes/jit_hostcall_registry_box.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use crate::box_trait::{NyashBox, StringBox, BoolBox, VoidBox, BoxCore, BoxBase};
|
||||
use std::any::Any;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct JitHostcallRegistryBox { base: BoxBase }
|
||||
|
||||
impl JitHostcallRegistryBox { pub fn new() -> Self { Self { base: BoxBase::new() } } }
|
||||
|
||||
impl BoxCore for JitHostcallRegistryBox {
|
||||
fn box_id(&self) -> u64 { self.base.id }
|
||||
fn parent_type_id(&self) -> Option<std::any::TypeId> { self.base.parent_type_id }
|
||||
fn fmt_box(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "JitHostcallRegistryBox") }
|
||||
fn as_any(&self) -> &dyn Any { self }
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any { self }
|
||||
}
|
||||
|
||||
impl NyashBox for JitHostcallRegistryBox {
|
||||
fn to_string_box(&self) -> StringBox {
|
||||
let (ro, mu) = crate::jit::hostcall_registry::snapshot();
|
||||
let payload = serde_json::json!({ "readonly": ro, "mutating": mu });
|
||||
StringBox::new(payload.to_string())
|
||||
}
|
||||
fn equals(&self, other: &dyn NyashBox) -> BoolBox { BoolBox::new(other.as_any().is::<JitHostcallRegistryBox>()) }
|
||||
fn type_name(&self) -> &'static str { "JitHostcallRegistryBox" }
|
||||
fn clone_box(&self) -> Box<dyn NyashBox> { Box::new(Self { base: self.base.clone() }) }
|
||||
fn share_box(&self) -> Box<dyn NyashBox> { self.clone_box() }
|
||||
}
|
||||
|
||||
impl JitHostcallRegistryBox {
|
||||
pub fn add_readonly(&self, sym: &str) -> Box<dyn NyashBox> { crate::jit::hostcall_registry::add_readonly(sym); Box::new(VoidBox::new()) }
|
||||
pub fn add_mutating(&self, sym: &str) -> Box<dyn NyashBox> { crate::jit::hostcall_registry::add_mutating(sym); Box::new(VoidBox::new()) }
|
||||
pub fn set_from_csv(&self, ro_csv: &str, mu_csv: &str) -> Box<dyn NyashBox> { crate::jit::hostcall_registry::set_from_csv(ro_csv, mu_csv); Box::new(VoidBox::new()) }
|
||||
pub fn add_signature(&self, sym: &str, args_csv: &str, ret_str: &str) -> Box<dyn NyashBox> {
|
||||
let ok = crate::jit::hostcall_registry::set_signature_csv(sym, args_csv, ret_str);
|
||||
if ok { Box::new(VoidBox::new()) } else { Box::new(StringBox::new("Invalid signature")) }
|
||||
}
|
||||
}
|
||||
@ -78,6 +78,7 @@ pub mod jit_config_box;
|
||||
pub mod jit_stats_box;
|
||||
pub mod jit_policy_box;
|
||||
pub mod jit_events_box;
|
||||
pub mod jit_hostcall_registry_box;
|
||||
|
||||
// Web専用Box群(ブラウザ環境でのみ利用可能)
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@ -112,6 +113,7 @@ pub use jit_config_box::JitConfigBox;
|
||||
pub use jit_stats_box::JitStatsBox;
|
||||
pub use jit_policy_box::JitPolicyBox;
|
||||
pub use jit_events_box::JitEventsBox;
|
||||
pub use jit_hostcall_registry_box::JitHostcallRegistryBox;
|
||||
|
||||
// EguiBoxの再エクスポート(非WASM環境のみ)
|
||||
#[cfg(all(feature = "gui", not(target_arch = "wasm32")))]
|
||||
|
||||
Reference in New Issue
Block a user