json: add v2 JsonDoc/JsonNode plugin with runtime provider switch; vendored yyjson + FFI; loader resolve(name)->method_id; PyVM JSON shims; smokes + CI gate; disable MiniVmPrints fallbacks by default

- plugin_loader_v2: store per-Box resolve() from TypeBox FFI; add resolve_method_id() and use in invoke_instance_method
- plugin_loader_unified: resolve_method() falls back to loader’s resolve when TOML lacks method entries
- nyash.toml: register JsonDocBox/JsonNodeBox methods (birth/parse/root/error; kind/get/size/at/str/int/bool)
- plugins/nyash-json-plugin:
  * serde/yyjson provider switch via env NYASH_JSON_PROVIDER (default serde)
  * vendored yyjson (c/yyjson) + shim; parse/root/get/size/at/str/int/bool implemented for yyjson
  * TLV void returns aligned to tag=9
- PyVM: add minimal JsonDocBox/JsonNodeBox shims in ops_box.py (for dev path)
- tests/smokes: add jsonbox_{parse_ok,parse_err,nested,collect_prints}; wire two into min-gate CI
- tools: collect_prints_mixed now uses JSON-based app
- MiniVmPrints: move BinaryOp and fallback heuristics behind a dev toggle (default OFF)
- CURRENT_TASK.md: updated with provider policy and fallback stance
This commit is contained in:
Selfhosting Dev
2025-09-22 06:16:20 +09:00
parent 0f96f2297d
commit 27568eb4a6
25 changed files with 20816 additions and 60 deletions

View File

@ -94,16 +94,22 @@ impl PluginHost {
let box_conf = cfg
.get_box_config(lib_name, box_type, &toml_value)
.ok_or(BidError::InvalidType)?;
let m = box_conf
.methods
.get(method_name)
.ok_or(BidError::InvalidMethod)?;
// Prefer config mapping; fallback to loader's TypeBox resolve(name)
let (method_id, returns_result) = if let Some(m) = box_conf.methods.get(method_name) {
(m.method_id, m.returns_result)
} else {
let l = self.loader.read().unwrap();
let mid = l
.resolve_method_id(box_type, method_name)
.map_err(|_| BidError::InvalidMethod)?;
(mid, false)
};
Ok(MethodHandle {
lib: lib_name.to_string(),
box_type: box_type.to_string(),
type_id: box_conf.type_id,
method_id: m.method_id,
returns_result: m.returns_result,
method_id,
returns_result,
})
}