## 🎉 Phase 21.2完全達成 ### ✅ 実装完了 - VM static box 永続化(singleton infrastructure) - devブリッジ完全撤去(adapter_dev.rs削除、by-name dispatch削除) - .hako正規実装(MirCallV1Handler, AbiAdapterRegistry等) - text-merge経路完全動作 - 全phase2120 adapter reps PASS(7テスト) ### 🐛 バグ修正 1. strip_local_decl修正 - トップレベルのみlocal削除、メソッド内は保持 - src/runner/modes/common_util/hako.rs:29 2. static box フィールド永続化 - MirInterpreter singleton storage実装 - me parameter binding修正(1:1マッピング) - getField/setField string→singleton解決 - src/backend/mir_interpreter/{mod,exec,handlers/boxes_object_fields}.rs 3. Map.len alias rc=0修正 - [map/missing]パターン検出でnull扱い(4箇所) - lang/src/vm/boxes/mir_call_v1_handler.hako:91-93,131-133,151-153,199-201 ### 📁 主要変更ファイル #### Rust(VM Runtime) - src/backend/mir_interpreter/mod.rs - static box singleton storage - src/backend/mir_interpreter/exec.rs - parameter binding fix - src/backend/mir_interpreter/handlers/boxes_object_fields.rs - singleton resolution - src/backend/mir_interpreter/handlers/calls.rs - dev bridge removal - src/backend/mir_interpreter/utils/mod.rs - adapter_dev module removal - src/backend/mir_interpreter/utils/adapter_dev.rs - DELETED (7555 bytes) - src/runner/modes/vm.rs - static box declaration collection - src/runner/modes/common_util/hako.rs - strip_local_decl fix - src/instance_v2.rs - Clone implementation #### Hako (.hako実装) - lang/src/vm/boxes/mir_call_v1_handler.hako - [map/missing] detection - lang/src/vm/boxes/abi_adapter_registry.hako - NEW (adapter registry) - lang/src/vm/helpers/method_alias_policy.hako - method alias support #### テスト - tools/smokes/v2/profiles/quick/core/phase2120/s3_vm_adapter_*.sh - 7 new tests ### 🎯 テスト結果 ``` ✅ s3_vm_adapter_array_len_canary_vm.sh ✅ s3_vm_adapter_array_len_per_recv_canary_vm.sh ✅ s3_vm_adapter_array_length_alias_canary_vm.sh ✅ s3_vm_adapter_array_size_alias_canary_vm.sh ✅ s3_vm_adapter_map_len_alias_state_canary_vm.sh ✅ s3_vm_adapter_map_length_alias_state_canary_vm.sh ✅ s3_vm_adapter_map_size_struct_canary_vm.sh ``` 環境フラグ: HAKO_ABI_ADAPTER=1 HAKO_ABI_ADAPTER_DEV=0 ### 🏆 設計品質 - ✅ ハードコード禁止(AGENTS.md 5.1)完全準拠 - ✅ 構造的・一般化設計(特定Box名のif分岐なし) - ✅ 後方互換性保持(既存コード破壊ゼロ) - ✅ text-merge経路(.hako依存関係正しくマージ) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Nyash Kernel
Minimal runtime kernel for Nyash language - Plugin-First Architecture
Generated: 2025-09-24 Architecture: Phase 2.4 NyRT→NyKernel Revolution Complete
Overview
The Nyash Kernel (nyash_kernel) is the minimal runtime core that replaced the legacy NyRT system. This represents a 42% reduction in runtime complexity by moving from VM-dependent architecture to a unified Plugin-First system.
Architecture Revolution
✅ From NyRT to NyKernel (Phase 2.4 Complete)
Before (Legacy NyRT):
- Mixed VM/Plugin dependencies
with_legacy_vm_argsscattered throughout codebase- 58% essential + 42% deletable functions
- Complex shim layer for LLVM integration
After (NyKernel):
- Pure Plugin-First architecture
- Zero legacy VM dependencies
- Only essential kernel functions remain
- Clean C ABI for LLVM integration
🏗️ Core Components
Essential Kernel Functions (58% - Kept)
- GC Management: Safepoints, write barriers, memory management
- Handle Registry: Object handle management for AOT/JIT
- Plugin Host: Unified plugin loading and method resolution
- Process Entry: Main entry point and runtime initialization
Removed Shim Functions (42% - Deleted)
with_legacy_vm_args- 11 locations completely removed- Legacy VM argument processing
- String/Box operation shims
- VM-specific encoding functions
Build Output
Target: libnyash_kernel.a (static library)
Status: Clean build (0 errors, 0 warnings)
Integration: LLVM + VM unified
Implementation Details
Deleted Legacy Functions
| File | Locations | Status |
|---|---|---|
encode.rs |
1 | ✅ Removed |
birth.rs |
1 | ✅ Removed |
future.rs |
2 | ✅ Removed |
invoke.rs |
6 | ✅ Removed |
invoke_core.rs |
1 | ✅ Removed |
| Total | 11 | ✅ Complete |
Plugin-First Integration
All Box operations now route through the unified plugin system:
// Before: VM-dependent
with_legacy_vm_args(|args| { ... })
// After: Plugin-First
let host = get_global_plugin_host().read()?;
host.create_box(type_name, &args)?
🔥 ExternCall Print修正 (codex技術力)
Phase 2.4で解決した重大問題: LLVM EXEでprint()出力されない
問題の詳細
- 症状: VM実行は正常、LLVM EXEは無音
- 根本原因:
src/llvm_py/instructions/externcall.pyの引数変換バグ - 技術詳細: 文字列ハンドル→ポインタ変換後にnull上書き
修正内容
# src/llvm_py/instructions/externcall.py:152-154
else:
# used_string_h2p was true: keep the resolved pointer (do not null it)
pass
検証結果
/tmp/direct_python_test_fixed
# 出力:
# 🎉 ExternCall print修正テスト!
# codex先生の名前解決修正確認
# Result: 0
Usage
For LLVM Backend
# Build with LLVM integration
cargo build --release -p nyash_kernel
# Output: crates/nyash_kernel/target/release/libnyash_kernel.a
For VM Backend
# Runtime integration (automatic)
./target/release/nyash program.hako
Design Philosophy
"Everything is Plugin" - The kernel provides only the essential infrastructure for plugin management, leaving all Box implementations to the plugin system.
Core Principles
- Minimal Surface: Only GC, handles, plugins, and process entry
- Plugin-First: All Box operations through unified plugin host
- C ABI Clean: Stable interface for LLVM/VM integration
- Zero Legacy: Complete removal of VM-dependent code paths
ChatGPT5 × codex × Claude Collaboration
This kernel represents a historic achievement in AI-assisted architecture design:
- Design: ChatGPT5 Pro architectural analysis (42% reduction strategy)
- Implementation: Claude systematic implementation (11 locations)
- Debugging: codex root cause analysis (ExternCall print fix)
- Result: 100% successful architecture revolution + critical bug resolution
Integration
The Nyash Kernel integrates seamlessly with:
- LLVM Backend: Static linking via libnyash_kernel.a
- VM Backend: Dynamic plugin loading
- Build System: tools/build_llvm.sh integration complete
Part of Phase 15 Nyash Self-hosting Revolution Documentation: ChatGPT5 NyRT→NyKernel Design