Commit Graph

74 Commits

Author SHA1 Message Date
fffbac9aac feat: MIR TypeOp/WeakRef/Barrier PoC implementation
- Add TypeOpKind, WeakRefOp, BarrierOp enums for unified instructions
- Implement TypeOp instruction combining TypeCheck/Cast
- Implement WeakRef instruction combining WeakNew/WeakLoad
- Implement Barrier instruction combining BarrierRead/BarrierWrite
- Update VM to handle new unified instructions
- Update MIR printer for new instruction formats
- Add feature flags mir_typeop_poc and mir_refbarrier_unify_poc
- Maintain backward compatibility with legacy instructions

This is Phase 8.5 MIR instruction diet PoC implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 19:27:02 +09:00
cc2a820af7 feat(plugin): Fix plugin BoxRef return and Box argument support
- Fixed deadlock in FileBox plugin copyFrom implementation (single lock)
- Added TLV Handle (tag=8) parsing in calls.rs for returned BoxRefs
- Improved plugin loader with config path consistency and detailed logging
- Fixed loader routing for proper Handle type_id/fini_method_id resolution
- Added detailed logging for TLV encoding/decoding in plugin_loader_v2

Test docs/examples/plugin_boxref_return.nyash now works correctly:
- cloneSelf() returns FileBox Handle properly
- copyFrom(Box) accepts plugin Box arguments
- Both FileBox instances close and fini correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 00:41:26 +09:00
86b9f7719b 🏗️ feat: Phase 9.78b準備 - インタープリター・VM統合アーキテクチャ設計
Phase 9.78b: Codexの天才的分析に基づくアーキテクチャ再設計準備

## 📋 実施内容
1. Codex分析結果のアーカイブ
   - 実装詳細共有 → モデル共有・実行時共有への転換提案
   - 8ステップの段階的実装計画

2. Phase 9.78a作業の保存
   - MIR生成でのNewBox命令統一(保持)
   - ScopeTracker基本実装(一時コメントアウト)
   - VM拡張の方向性(TODOコメント付き)

3. ビルドエラー修正
   - ScopeTrackerインポート問題を一時的に解決
   - ビルド成功(警告のみ)

## 📚 作成ドキュメント
- architecture-redesign-proposal.md - Codexの設計提案
- phase_9_78b_interpreter_architecture_refactoring.md - 実装計画
- codex-analysis/* - 分析結果アーカイブ

## 🎯 次のステップ
Phase 9.78b Step 1: BoxDeclarationをcore::modelへ移動
2025-08-20 17:58:51 +09:00
c11b68af90 📝 docs: Phase 9.78a実装箇所詳細分析追加
## 🔍 実装箇所の詳細分析
- MIR生成部分: build_new_expression()でRefNew→NewBox修正
- VM実行部分: 主要な修正箇所(BoxFactory統合、スコープ管理)
- 共有コンポーネント: BoxFactory、InstanceBoxをVMでも使用

## 📋 CURRENT_TASK.md更新
- Phase 9.78a VM統一Box処理の実装ステップ詳細化
- Step 1-5の具体的な実装内容を明記
- 関連ドキュメントへのリンク追加

次はStep 1のMIR生成修正から実装開始!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 16:08:22 +09:00
59cae9fe2a 📚 docs: VM Plugin System統合の完全設計
Phase 9.78a: VM統一Box処理アーキテクチャ

## 🎯 解決した問題
- ユーザー定義Box未対応 → BoxFactory統合で解決
- birth/finiライフサイクル欠落 → ScopeTracker実装で解決
- メソッド呼び出しハードコード → 統一ディスパッチで解決

## 📚 作成したドキュメント
- Phase 9.78a VM Plugin Integration計画書
- Phase 9.78a 深層分析(インタープリター比較)
- VM Plugin Integration仕様書(統一アーキテクチャ)

## 🌟 統一設計の核心
Everything is Box + 統一ライフサイクル
- すべてのBox型(ビルトイン/ユーザー定義/プラグイン)が同じ扱い
- birth → 使用 → fini の一貫性
- シンプルで保守しやすい実装

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 15:58:28 +09:00
3e8b75f4de fix: Kilo/CHIP-8アプリエラー修正 - toInteger, substring, レガシーBox削除
## 修正内容
1. **toIntegerメソッド実装** (#125)
   - StringBoxにtoInteger()メソッド追加
   - box_trait::IntegerBoxを返すよう統一(レガシーboxes::IntegerBox削除)

2. **substringメソッド実装**
   - StringBoxにsubstring(start, end)メソッド追加
   - Kiloエディタで必要な文字列操作を完全サポート

3. **レガシーコード削除**
   - src/boxes/mod.rsから重複StringBox/IntegerBox/BoolBoxエクスポート削除
   - 全てbox_trait実装に統一

4. **プラグインドキュメント整理**
   - 古い仕様書に「理想案・未実装」「将来構想」明記
   - 実装ベースの正確な仕様書作成
   - migration-guide.md追加

## テスト結果
-  Kiloエディタ: 完全動作確認("Enhanced Kilo Editor test complete")
-  toInteger()の乗算: 正常動作
-  substring(): 正常動作

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 14:13:47 +09:00
670615d1de feat: WASMビルド完全対応+finiシステム修正 🎉
## WASMビルド対応
- TimerBox、AudioBox等の問題のあるBoxをWASM環境では条件付きコンパイルで除外
- WebBox (WebDisplayBox, WebConsoleBox, WebCanvasBox) にas_anyメソッド追加
- プラグイン関連コードに#[cfg]ガードを追加
- web-sysフィーチャーを追加(Performance、MouseEvent等)
- projects/nyash-wasmのビルドが完全に通るように!

## finiシステム修正
- フィールド差し替え時の自動fini削除(Nyashの明示的哲学に従う)
- スコープ離脱時のみfini実行(meは除外)
- ドキュメント更新で正しいfiniルールを明記

## その他
- CLAUDE.mdにWASMビルド方法を追記(wasm-pack build --target web)
- 開発サーバー起動方法を記載(python3 -m http.server 8010)
- cargo testで全テスト成功を確認

これでNyashがブラウザで動作可能に!🐱

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 07:33:18 +09:00
9eb52982b5 fix: Phase 9.78e+: Fix birth constructor and builtin Box method inheritance
🌟 Major fixes:
- Fix birth constructor lookup (was searching for 'init/N', now 'birth/N')
- Fix builtin Box method inheritance via __builtin_content field
- Remove InstanceBox wrapping for builtin Boxes
- Update execute_builtin_birth_method to properly store builtin content
- Update method resolution to check __builtin_content for builtin methods

 All tests pass:
- Birth constructors work correctly
- User-to-user Box delegation works
- User-to-builtin Box delegation works (toString() properly inherited)
- Apps folder tested (chip8, kilo editor run successfully)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 02:19:59 +09:00
164f1079ec 🏆 LEGENDARY: birth構文革命+デリゲーション完全勝利!
🌟 **birth構文完全修復** - Everything is Boxの究極実現
- objects.rs 2箇所の重要修正: init → birth統一完了
- 引数付きコンストラクタ完全動作: birth(args) 
- 統一レジストリとの完全連携: InstanceBox統合 
- テスト結果: 🌟 TestBox誕生完全成功!

🔄 **デリゲーション透過完全成功** - 美しい継承システム実現
- box Child from Parent: デリゲーション宣言 
- from Parent.birth(args): 親コンストラクタ透過呼び出し 
- override + from Parent.method(): 完璧な継承階層 
- テスト結果: 親子デリゲーション完全動作確認!

🎮 **実用アプリ動作確認完了**
- CHIP-8エミュレーター: パース成功+実行開始 
- Kiloテキストエディター: birth構文で初期化成功 
- Proxyサーバー: デリゲーション機能動作確認 

🎯 **Phase 9.78e PLUS達成**
- instance_v2移行 100% 完了
- birth構文革命 100% 完了
- デリゲーション透過 100% 完了
- Everything is Box哲学完全実現

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:58:35 +09:00
94e646ebc4 feat: Phase 9.78e完全勝利!instance_v2移行100%成功
🎉 **InstanceBoxラップ演算子問題完全解決**
- unwrap_instanceヘルパー関数実装で型地獄回避
- 4つの演算子関数修正(add/sub/mul/div)
- StringBox + IntegerBox混在演算子完全動作

🚀 **Everything is Box哲学完全実現**
- 全Box型(ビルトイン、ユーザー定義、プラグイン)統一アーキテクチャ
- InstanceBoxによる完全統一ラッピング
- シンプルで保守可能な実装

 **全機能動作確認済み**
- Person/Employee作成・デリゲーション完全動作
- フィールドアクセス・メソッドオーバーライド成功
- 統一レジストリ完全統合

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:43:35 +09:00
e5e381aa83 feat: Implement Phase 9.78e instance_v2 migration with unified registry
Major achievements:
-  UserDefinedBoxFactory implementation with unified registry integration
-  Constructor execution for user-defined boxes (Person init working)
-  Import path fixes across interpreter modules
-  unwrap_instance helper function for InstanceBox operator support

Technical details:
- Modified UnifiedBoxRegistry to handle empty box_types() factories
- Implemented constructor execution in execute_new for InstanceBox
- Added unwrap_instance helper to handle InstanceBox wrapping in operators
- Updated CURRENT_TASK.md with detailed progress tracking

Next: Fix 4 operator functions to complete InstanceBox operator support

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 00:21:20 +09:00
5a50cf6415 feat(phase-9.78e): Complete instance_v2 migration - remove instance.rs entirely
🎉 Victory\! instance.rs (v1) has been completely removed\!

Changes:
- Delete src/instance.rs
- Remove 'pub mod instance;' from lib.rs and main.rs
- instance_v2 is now the only InstanceBox implementation
- Library builds successfully without instance.rs

Technical notes:
- Legacy compatibility layer remains in instance_v2 for smooth transition
- Type conversion TODOs remain (SharedNyashBox <-> NyashValue)
- Binary builds still have import path issues to fix later
- Basic functionality fully operational with instance_v2

🎯 Phase 9.78e complete: instance_v2への完全移行成功!
2025-08-19 22:45:47 +09:00
5582ad45c0 feat: Phase 9.78e complete - instance_v2 migration with legacy compatibility
- instance_v2 now includes legacy compatibility layer
- All interpreter code migrated to use instance_v2
- Added legacy field access methods (get_fields, set_field_legacy, etc.)
- Fixed type conversion issues (NyashValue vs SharedNyashBox)
- instance.rs still exists but no longer used in interpreter
- TODO: Remove instance.rs completely in next phase
- TODO: Implement proper SharedNyashBox -> NyashValue conversion

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 22:35:34 +09:00
3ae4ae8211 docs: Phase 9.78e動的メソッドディスパッチの状況と型変換問題、ラッパー戦略決定 2025-08-19 21:10:00 +09:00
03e4de6ad7 feat: Phase 9.78d完全達成 - InstanceBox統合 + type_name委譲実装成功
🎉 Phase 9.78d 主要マイルストーン達成!

主要成果:
 Rustスコープ問題完全解決 - use crate::instance_v2::InstanceBox;
 StringBox → InstanceBox統合完成 - BuiltinBoxFactory経由で成功
 type_name()委譲実装 - 内包Boxの型名を正しく返す修正完了
 基本機能完全動作 - 文字列作成・連結・基本操作すべて正常
 統一レジストリ確認 - 🏭 Unified registry created動作確認
 デバッグ情報改善 - type_name='StringBox'正確表示

技術的達成:
- InstanceBox::from_any_box()によるビルトインBox統合
- 内包Boxへの透過的type_name()委譲実装
- BuiltinBoxFactory経由での統一Box生成確立
- 全体Progress: 44% → 85%完了に大幅進展

次期課題:
⚠️ メソッド呼び出し統合 - str.type_name()等の動的ディスパッチ
🎯 Phase 9.78e - Gemini提案のcall_method設計実装予定

ファイル変更:
- src/instance_v2.rs: type_name()内包Box委譲実装
- src/box_factory/builtin.rs: InstanceBox統合実装
- docs/CURRENT_TASK.md: 進捗85%完了に更新
- local_tests/: Gemini設計相談ファイル追加

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 20:00:16 +09:00
5f1a50e4af feat: Phase 9.78d部分達成 - InstanceBox統合でBuiltinBox作成成功
🎯 Phase 9.78d: InstanceBox簡素化統一実装の主要マイルストーン達成

主要成果:
 Rustスコープ問題をシンプル解決 - `use crate::InstanceBox;`
 StringBox → InstanceBox統合完了 - BuiltinBoxFactory経由
 統一レジストリ経由での動的Box作成が動作
 基本機能テスト成功(文字列作成・連結)

技術詳細:
- BuiltinBoxFactory内でInstanceBox::from_any_box()による統合実装
- lib.rsのpub useを活用した最軽量import戦略
- 🏭 Unified registry created: StringBoxログで統合動作確認
- StringBox基本機能(連結演算子等)は正常動作

次の課題:
⚠️ メソッド呼び出し統合(str.type_name()等)は別途対応

ファイル変更:
- src/box_factory/builtin.rs: StringBoxのInstanceBox統合実装
- src/lib.rs: コメント整理
- docs/CURRENT_TASK.md: 進捗状況更新
- local_tests/: 統合動作テスト追加

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 19:48:35 +09:00
9f3a7c62f7 fix: Phase 9.78d重要修正 - 重複StringBox定義問題を解決
🐛 重大なレガシー問題修正:
- StringBox重複定義による文字列演算子破綻を修正
- operators.rs: 統一レジストリStringBoxに変更
- 全アプリケーションの文字列連結(+)演算子が復旧

🎯 Phase 9.78d InstanceBox簡素化実装:
- instance_v2.rs: 統一trait object設計
- from_any_box/from_declaration統一コンストラクタ
- レガシーfiniシステム簡素化対応

📋 ドキュメント更新:
- CURRENT_TASK.md: レガシー問題詳細記録
- 今後の対策・検証結果を文書化

🧪 検証結果:
 TinyProxy, KiloEditor等全アプリで文字列演算正常動作
 InstanceBox v2統一実装テスト成功

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 18:32:11 +09:00
c2af6c9987 docs: Add Phase 9.78 Unified BoxFactory Architecture design
- Add comprehensive design discussion with Gemini about unified BoxFactory
- Define Phase 9.78 implementation plan with 6 sub-phases (9.78a-f)
- Include clone_box/share_box semantics clarification and fixes
- Update CURRENT_TASK.md with specific misimplementation details
- Archive Gemini's deep technical analysis endorsing the approach

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 16:21:34 +09:00
519560b64b 🎉 FileBox v2 plugin system fully working with TLV encoding fix
Major achievements:
- Fixed TLV encoding format to match plugin expectations
  - Header: version(2 bytes) + argc(2 bytes)
  - Entry: tag(1) + reserved(1) + size(2) + data
- Removed duplicate implementation in method_dispatch.rs
- All FileBox methods working: open/read/write/close
- Successfully tested file I/O operations

This completes the v2 plugin system integration for FileBox.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 13:57:17 +09:00
5f6f946179 feat: 汎用プラグインBox生成システム実装とnyash.toml v2対応準備
- GenericPluginBoxを実装し、任意のプラグインBoxを動的に生成可能に
- FileBox決め打ちコードを削除(設計思想違反の解消)
- CURRENT_TASK.mdを更新し、nyash.toml v2対応の必要性を明確化
- 問題: プラグインテスターとNyash本体が古い単一Box型形式のまま

次のステップ:
1. nyash.tomlをv2形式(マルチBox型)に更新
2. プラグインテスターをv2対応に
3. Nyash本体のレジストリをv2対応に

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 03:48:44 +09:00
cc8553380c feat: Add multi-box plugin support (v2) with test implementation
- Extend plugin-tester to support multi-box plugins with v2 API
- Add nyash_plugin_get_box_count/get_box_info/get_type_id functions
- Create test multi-box plugin providing TestBoxA and TestBoxB
- Update plugin-system.md documentation for v2 format
- Add nyash.toml v2 specification for multi-box support
- Successfully tested multi-box plugin lifecycle and type resolution

This enables one plugin to provide multiple Box types, solving the
dependency issue where HTTPServerBox needs SocketBox.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 01:13:48 +09:00
840c1b85ef feat: Fix VM SSA loop execution with proper phi node handling
Fixed infinite loop issue in VM by addressing phi node caching problem.
The phi node was caching the initial value and returning it for all
subsequent iterations, preventing loop variable updates.

Changes:
- Created vm_phi.rs module to separate loop execution logic (similar to mir/loop_builder.rs)
- Disabled phi node caching to ensure correct value selection each iteration
- Added LoopExecutor to track block transitions and handle phi nodes properly
- Fixed VM to correctly track previous_block for phi input selection

The VM now correctly executes SSA-form loops with proper variable updates:
- Loop counter increments correctly
- Phi nodes select the right input based on control flow
- Test case now completes successfully (i=1,2,3,4)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 23:36:40 +09:00
5d1a140919 feat: Phase 9.75g-0 BID-FFI完了 + Phase 9.8準備
- BID-FFI基盤実装完了(プラグインシステム動作確認)
- Phase 8.6 VM性能改善完了(50.94倍高速化達成)
- Phase 9.78 LLVM PoC基盤完成
- Phase 9.8 BIDレジストリ準備(nyash.toml活用戦略)
- ビルドエラー修正、警告は後で対応

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 21:10:06 +09:00
d788bcbf79 docs: Update CURRENT_TASK.md with Phase 9.8 strategy shift to nyash.toml extension
- Discovered that nyash.toml already contains comprehensive type information
- Shifted strategy from new BID YAML files to extending existing nyash.toml
- Updated Phase 9.8 plan to integrate with Phase 9.9 permissions model
- Set goal: FileBox working on VM backend with permission controls
- Documented the revolutionary discovery that simplifies the entire approach

This change reflects the strategic decision to leverage existing infrastructure
rather than creating new file formats, making the system more maintainable.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 19:55:06 +09:00
f4988985a7 docs: Phase 9.78 LLVM PoC - AI大会議結果とCopilot実装ガイド作成
- AI大会議(Gemini/Codex)でLLVM実装戦略を策定
- inkwellクレート使用、Box型はptr型で表現、ランタイム委譲戦略
- Week 1: Hello World(return 42)の実装から開始
- 3週間で基本動作確認、目標10倍以上の性能向上
- Copilot用の詳細な実装ガイドとIssueテンプレート作成

Phase 8.6 VM性能改善(50.94倍高速化)完了を受けて、
次なる性能革命としてLLVMバックエンド実装を開始!

🚀 Ready to make Nyash fly with LLVM!
2025-08-18 17:51:31 +09:00
bfb2d648d5 feat(phase-9.75g-0): Complete BID-FFI Plugin System with enhanced plugin-tester
🎊 Phase 9.75g-0 COMPLETE - Revolutionary Plugin System Achievement\!

 Major Completions:
- plugin-tester type validation: nyash.toml integration & method signature verification
- Duplicate method name detection: Enforces Nyash no-overloading policy
- Comprehensive developer guide: 200+ line technical documentation
- Memory safety: HostVtable lifetime issues resolved with LazyLock
- Type information system: External nyash.toml configuration eliminates hardcoded conversions

🚀 Revolutionary Impact:
Nyash now supports dynamic Box type extension via plugins:
```nyash
local file = new FileBox()        // Plugin-provided
local db = new PostgreSQLBox()    // Future: Plugin-provided
local gpu = new CudaBox()         // Future: Plugin-provided
```

📊 Technical Achievements:
- plugin-tester: 4 comprehensive validation modes (check/lifecycle/io/typecheck)
- BID-FFI Protocol: Production-ready with valgrind-verified memory safety
- Type conversion: Automatic string→bytes mapping via nyash.toml
- Method validation: Prevents overloading conflicts in plugin development

🎯 Next Priority: Phase 8.6 VM Performance Improvement
Current issue: VM is 0.9x slower than interpreter (regression\!)
Target: 2x+ speedup for practical VM execution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 16:04:30 +09:00
c6c3c8e2f9 fix(bid-ffi): Fix HostVtable lifetime issue causing segfault
🚨 Critical memory safety fix:
- HostVtable was created on stack and destroyed after init
- Plugin stored reference to destroyed memory → NULL pointer access
- Changed to static LazyLock storage for lifetime safety

 Results:
- Segfault completely eliminated
- Plugin logging now works properly
- Type info system confirmed working
- Full E2E FileBox plugin operation successful

🔧 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 14:10:41 +09:00
16291630e2 docs: Update CURRENT_TASK.md to reflect Day 5 completion and Day 6 planning
##  Day 5 BID-FFI Complete Success
- Plugin method calling system fully implemented
- FileBox plugin write/read operations working end-to-end
- Test result: "READ=Hello from Nyash via plugin\!"  Success

## 🚨 Critical Design Issue Identified
Current implementation hardcodes method names (read/write/exists/close)
in execute_plugin_file_method(), violating BID-FFI dynamic principles.

## 🎯 Day 6 Action Plan
Focus: Dynamic method discovery from plugin metadata
- Replace hardcoded method dispatch with generic system
- Enable new plugin Box types without source code changes
- Achieve true BID-FFI dynamism with nyash.toml-only configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 11:46:11 +09:00
5caee18764 docs: Update CURRENT_TASK.md with BID-FFI integration test results
## Test Results Summary

###  Plugin System Foundation: Complete Success
- plugin-tester check: Full functionality verified (load/init/shutdown)
- plugin-tester io: File operations (write) working, read needs TLV fix
- Box name self-declaration working (FileBox ID:6, 6 methods)

###  Nyash Integration: Partial Success (Plugin Loading Confirmed)
- `🔌 BID plugin loaded: FileBox (instance_id=1)` ← Core success\!
- Parse and AST execution successful
- new FileBox(...) creation reached
- Segmentation fault in file operations (TLV encoding/decoding)

### 🎯 Codex Implementation Achievement (1 hour)
-  Complete plugin system foundation
-  Generic plugin-tester with diagnostic features
-  Nyash integration with plugin loading
- ⚠️ Remaining task: TLV encode/decode optimization

## Updated Task Status
- Nyash integration:  Implemented (codex), plugin loading confirmed
- PluginBox proxy: ⚠️ Implemented (codex), TLV refinement needed
- Next priority: TLV encode/decode optimization for read operations

This validates that the BID-FFI system foundation is working correctly,
with the main remaining work being TLV protocol optimization.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 11:12:15 +09:00
0441608db3 BID-FFI integration:\n- Add plugin-tester io subcommand and TLV helpers; E2E open/write/read/close\n- Implement FileBox plugin invoke (birth/open/read/write/close) with BID-1 two-pass\n- Add BID loader/registry/plugin_box modules; prefer plugin-backed FileBox in interpreter\n- Introduce PluginFileBox with minimal read/write/close dispatch\n- Update runner debug paths; add local simple tests\n- Docs: plugin-tester guide and FileBox Nyash↔BID mapping; CURRENT_TASK updated 2025-08-18 11:07:03 +09:00
03ecbd6bc2 docs: CURRENT_TASK.md更新 - BID-FFI基盤実装完了を反映
- Step 1-3完了を明記
  - FileBoxプラグイン実装済み(293KB .so)
  - nyash.toml設定ファイル作成済み
  - plugin-tester診断ツール完成

- 重要な設計原則の達成を記録
  - Box名非決め打ち(プラグインが宣言)
  - 汎用的設計
  - birth/finiライフサイクル実装

- Step 4(Nyashとの統合)の詳細計画を追加
  - src/bid/モジュール構成
  - 実装順序と各コンポーネントの役割

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 09:41:41 +09:00
f5e201037c docs: BID-FFI実装計画を段階的アプローチに更新
- Step 1: FileBoxプラグイン単体作成
- Step 2: nyash.toml設定ファイル作成
- Step 3: プラグインテスター/ローダー作成(診断機能付き)
- Step 4: Nyashとの統合

プラグイン開発者向けテストツールを独立して作成し、
成功部分を後でNyashに移植する戦略を採用

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 08:51:42 +09:00
bec0e9bc92 revert: 古いプラグインシステム実装前の状態に巻き戻し
- ソースコードをcommit 3f7d71fの状態に復元(古いプラグインシステム実装前)
- docsフォルダは最新の状態を維持(BID-FFI設計ドキュメント含む)
- nyashバイナリの基本動作確認済み
- BID-FFIシステムをクリーンに再実装する準備完了

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 08:34:19 +09:00
75868a5a96 feat(phase-9.75g-0): Implement BID-FFI Day 5 - FileBox plugin library and transparent switching (90% complete)
Day 5 achievements:
- Created independent FileBox plugin crate with C FFI exports
- Integrated plugin loading into Nyash interpreter startup
- Implemented transparent builtin/plugin Box switching via nyash.toml
- Successfully loaded plugin library (385KB .so) at runtime
- Confirmed PluginBox proxy creation for FileBox instances

Architecture changes:
- Added plugins/ directory with .gitignore for build artifacts
- Modified runner.rs to load plugins from nyash.toml on startup
- Updated objects.rs to use BoxFactoryRegistry for FileBox creation
- Fixed bid module visibility between lib.rs and main.rs

Remaining work (10%):
- Complete PluginBox proxy method implementations (toString, etc.)
- Test actual file operations through plugin interface
- Finalize error handling and edge cases

Build status: All tests passing, plugin loading confirmed
2025-08-18 00:33:01 +09:00
72b63546b0 feat(phase-9.75g-0): Add simple nyash.toml parser for plugin configuration
-  Simple TOML parser for [plugins] section
-  Maps Box names to plugin names (e.g., FileBox => filebox)
-  Handles comments and empty lines
-  Complete test coverage
- 🎯 Minimal implementation for transparent Box replacement!

Part of Day 4 FileBox plugin implementation (60% → 70%)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 22:05:47 +09:00
969f7e9db8 docs: Update CURRENT_TASK.md for Day 4 FileBox plugin progress (50%)
- Day 3 marked as 100% complete
- Day 4 FileBox plugin marked as 50% complete
- Updated timestamp to 22:00

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 21:18:29 +09:00
939c621b47 feat(phase-9.75g-0): Implement BID-FFI Day 4 - FileBox plugin (50% complete)
-  FileBox plugin design with open/read/write/close API
-  FileBoxRegistry for handle management
-  FileMode enum for file access modes
-  FileBoxPlugin implementation with BidHandle integration
-  Complete test suite for FileBox operations (1/1 passing)
- 🎯 Everything is Box philosophy applied to file operations!

Remaining tasks:
-  FileBox host integration (Nyash側からの呼び出し)
-  Plugin loading mechanism (動的ロード実装)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 21:09:32 +09:00
ea6cc1fe9e feat(phase-9.75g-0): Complete BID-FFI Day 3 - FutureBox integration
- Add FutureBox BID bridge implementation for async Box types
- Support FutureBox in box_to_bid_handle conversion
- Add comprehensive FutureBox BID round-trip test
- Update CURRENT_TASK.md to reflect Day 3 completion (100%)

Day 3 fully completed! All Box types (String/Integer/Future) now integrated with BID-FFI.
Everything is Box philosophy proven through unified handle management! 🎉

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 20:55:49 +09:00
53f20464b6 docs: Update CURRENT_TASK.md to reflect Day 2 completion
- Mark metadata API implementation as complete
- Add implementation details:
  - HostVtable for host function integration
  - Plugin metadata structures (NyashPluginInfo, NyashMethodInfo)
  - C FFI function signatures
  - Plugin lifecycle management
- Note test results: 7/7 tests passing

Day 2 objectives achieved! Ready for Day 3 existing Box integration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 19:02:51 +09:00
f5ee08f375 docs: Update CURRENT_TASK.md for Day 2 start - Metadata API implementation
Day 2 objectives:
- Implement HostVtable for host function integration
- Create plugin metadata structures (NyashPluginInfo, NyashMethodInfo)
- Define C FFI function signatures
- Establish plugin lifecycle management

BID-FFI implementation continues with host-plugin integration layer.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 18:53:34 +09:00
0522938f97 docs: Update CURRENT_TASK.md to reflect Day 1 completion
- Mark BID-1 foundation implementation as complete
- Add implementation details (src/bid/ module, TLV, types, errors)
- Note test results: 4/4 tests passing

Day 1 objectives achieved! Ready for Day 2 metadata API.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 18:33:19 +09:00
2b738196ca feat(phase-9.75g-0): Adopt ChatGPT final BID-FFI design and update specifications
- Update ffi-abi-specification.md to BID-1 Enhanced Edition
  - Add efficient Handle design (type_id + instance_id)
  - Define BID-1 TLV unified format for arguments/results
  - Add Plugin API with NyashHostVtable and metadata support
  - Include complete FileBox plugin example in C
  - Standardize error codes (NYB_SUCCESS, NYB_E_*)
  - Support 8-byte alignment and platform-dependent usize

- Add phase_9_75g_0_chatgpt_enhanced_final.md as the final design
  - Incorporates all ChatGPT-5 recommendations
  - Confirms 1-week implementation feasibility
  - Aligns with Everything is Box philosophy

- Update CURRENT_TASK.md to reflect Day 1 progress
  - Mark specification finalization as complete
  - Ready to start actual implementation

Everything is Box philosophy meets practical FFI/ABI design\!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 18:17:04 +09:00
75d09a89a8 feat(phase-9.75g-0): Start BID-FFI type-first implementation strategy
- Create comprehensive type definitions for all future features
- Adopt FFI ABI v0 compliance with platform-aware pointers (usize)
- Implement 8-byte alignment for cross-platform compatibility
- Design single entry point: nyash_plugin_invoke
- Target Linux x86-64 for initial implementation
- Use unimplemented!() for gradual feature addition

Key decisions from AI review:
- Pointer width: platform-dependent (not fixed 32-bit)
- Early addition of Option/Result types
- Clear ownership rules for strings/arrays
- Extensible BoxHeader with magic number

Phase 9.75g-0: Build it simple, make it work, then extend!
2025-08-17 17:31:46 +09:00
49d00f0a65 docs: Update CURRENT_TASK.md to reflect MIR 35→26 project completion
- Marked all phases as completed
- Added project statistics:
  - 9 instructions removed (25.7% reduction)
  - Completed in 1 day instead of 5 weeks
  - 95% success rate (RefNew display issue remains)
  - Code quality improved with unified architecture

This documents the successful completion of the MIR instruction reduction project.
2025-08-17 15:21:43 +09:00
2a762d94a1 docs(phase-5.4): Update documentation for MIR 26-instruction project
Phase 5.4 of MIR 35→26 reduction project:
- Create MIR 26-instruction specification document
- Update CURRENT_TASK.md with Phase 5 progress
- Update phase_8_5_mir_35_to_26_reduction.md with completion status
- Document amazing progress: 90% completion in 1 day vs 5 weeks estimate

Documentation updates:
- docs/説明書/reference/mir-26-specification.md: Complete specification
- docs/CURRENT_TASK.md: Phase 5-4 in progress
- docs/予定/native-plan/issues/phase_8_5_mir_35_to_26_reduction.md: Status updates

Next: Update test files to remove deprecated instructions
2025-08-17 14:21:49 +09:00
bb3f2e8032 feat: Complete Phase 3 of MIR 35→26 reduction - optimization pass migration
- Remove old instructions from VM/WASM backends (UnaryOp, Print, Load/Store, RefGet/RefSet)
- Add comprehensive MIR optimizer with Effect System based optimizations
- Implement dead code elimination, CSE, pure instruction reordering
- Add intrinsic function support in VM backend
- Update backends to use new BoxFieldLoad/Store and Call intrinsics

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 12:27:12 +09:00
2b2dcc5647 feat(phase-9.75f-1): Complete FileBox dynamic library implementation
- Implement C ABI plugin system with workspace configuration
- Create FileBox plugin with full read/write/exists/toString support
- Fix critical memory management issues (double free) with Arc
- Add comprehensive test suite for dynamic FileBox functionality
- Achieve 98% build time improvement for plugin (2.87s vs 2-3min)
- Maintain full backward compatibility with feature flags

FileBox now loads dynamically, drastically reducing build times while
maintaining all functionality. Next: Math/Time dynamic migration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 09:31:35 +09:00
349dba24b5 docs: Add Phase 9.75f Option C implementation plans
- Phase 9.75f-1: FileBox dynamic library (immediate)
- Phase 9.75f-2: Math/Time boxes dynamic (this week)
- Phase 9.75f-3: Core types experiment (future)
- Update CURRENT_TASK.md with Option C strategy
- Refine todo list for phased implementation
2025-08-17 04:06:42 +09:00
d396c0ed8c feat(phase-9.75f): ビルトインBox動的ライブラリ分離アーキテクチャ設計
- Gemini先生のアドバイスに基づく実装計画策定
- C ABI + libloading による安定した動的ライブラリ実装
- 段階的移行戦略:インタープリターExternCall → プラグイン化
- FFI-ABI file実装(stdlib方式)完了
- MIRビルダーにfile.read/write/exists追加
- ビルド時間2分→15秒、バイナリ15MB→2MBを目標
- docs/予定/native-plan/issues/phase_9_75f_dynamic_library_architecture.md作成
- CURRENT_TASK.md更新

次のステップ:
- インタープリターでExternCall直接実行実装
- 元のFileBox実装を探して置き換え
- プラグインアーキテクチャ基盤構築
2025-08-17 03:40:00 +09:00
a8e77f6411 docs: WASM Canvas研究とFFI-ABI実装戦略の追加
- CURRENT_TASK.mdにWASM研究メモセクション追加
- MIR→WAT→WASM実行フローの確認
- Canvas実装の3つの選択肢を文書化
  - CanvasBox実装(推奨)
  - グローバルcanvasオブジェクト
  - 標準ライブラリ拡張
- FFI-ABI仕様に基づくFileBox実装戦略を検討
- 純粋FFI-ABI方式でのfile.read/write実装計画策定
2025-08-17 02:54:05 +09:00