Commit Graph

158 Commits

Author SHA1 Message Date
22212aa314 refactor: Major interpreter modularization and P2PBox enhancements
Major Interpreter Refactoring:
- Split core.rs (373 lines removed) into focused modules
- Split expressions/calls.rs (460 lines removed) into cleaner structure
- Added new modules: calls.rs, errors.rs, eval.rs, methods_dispatch.rs, state.rs
- Improved separation of concerns across interpreter components

P2PBox Enhancements:
- Added on_once() for one-time event handlers
- Added off() for handler deregistration
- Implemented handler flags with AtomicBool for thread-safe management
- Added loopback testing cache (last_from, last_intent_name)
- Improved Arc-based state sharing for transport and handlers

Plugin Loader Unification (In Progress):
- Created plugin_loader_unified.rs skeleton
- Created plugin_ffi_common.rs for shared FFI utilities
- Migration plan documented (2400 lines → 1100 lines target)

MIR & VM Improvements:
- Enhanced modularized MIR builder structure
- Added BoxCall dispatch improvements
- Better separation in builder modules

Documentation Updates:
- Added Phase 9.79a unified box dispatch plan
- Created plugin loader migration plan
- Updated CURRENT_TASK.md with latest progress

All tests passing (180 tests) - ready for next phase of refactoring

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 19:13:57 +09:00
bec61e38c5 ResultBox migration complete: remove legacy box_trait::ResultBox
- Delete deprecated ResultBox implementation from box_trait.rs
- All code paths use boxes::result::NyashResultBox (aka boxes::ResultBox)
- Tests remain green (179)
- Mark phase 9.78h acceptance: ResultBox移行完了 as done
2025-08-26 06:52:35 +09:00
bd6b0b1f8f Snapshots: add loop_nested_if golden and wire into CI check
- New: docs/status/golden/loop_nested_if.mir.txt
- Update: tools/ci_check_golden.sh to include nested-if loop case
- Source: local_tests/loop_nested_if_test.nyash
2025-08-26 06:44:13 +09:00
f1a4a78379 Docs: mark PoC features as deprecated (unified ops are default)
- mir_typeop_poc / mir_refbarrier_unify_poc are no-op now; Builder emits
  TypeOp/WeakRef/Barrier by default; Optimizer normalizes legacy ops.
- Update CURRENT_TASK and architecture/proposal docs accordingly.
2025-08-26 06:41:30 +09:00
378a2bc174 LoopBuilder: bind variable_map to Phi result on seal
- After inserting Phi at loop header, update variable_map so that
  subsequent uses (after the loop) refer to the Phi result instead of
  the latch/body value. This fixes dominance issues in verifier.
- Add tests: loop phi normalization and loop+nested-if phi; both pass.
2025-08-26 06:35:39 +09:00
391a095f4c Phase 9.78h: Stabilize MIR26 pipeline
- Add lib test to sync Core Instruction names with docs (INSTRUCTION_SET.md)
- Optimizer: Pass 0 normalizes legacy ops -> unified (TypeCheck/Cast->TypeOp,
  WeakNew/WeakLoad->WeakRef, BarrierRead/Write->Barrier)
- Optimizer: diagnostics for legacy ops; forbid via NYASH_OPT_DIAG_FORBID_LEGACY=1
- Runner: treat diagnostics (unlowered/legacy) as fatal when enabled
- Printer: unify legacy print style to TypeOp/WeakRef/Barrier
- Verifier: treat Phi inputs correctly (skip merge/dominance violations for Phi)
- Docs: update PHI_NORMALIZATION_PLAN; CURRENT_TASK: add risk note for op duplication
- Misc: PHI debugging/logs kept stable; snapshots still green
2025-08-26 06:30:01 +09:00
bf4b87526e phase(9.78h): stabilize MIR/VM pipeline
- Add MIR26 doc≡code sync test (tests/mir_instruction_set_sync.rs)
- Quiet snapshots; filter plugin/net logs; golden all green
- Delegate VM phi selection to LoopExecutor (borrow-safe)
- ResultBox migration: remove legacy box_trait::ResultBox paths
- VM BoxRef arithmetic fallbacks via toString().parse::<i64>()
- Bridge BoxCall(InstanceBox) to Class.method/arity in VM
- Fix Effects purity (READ -> readonly, not pure)
- Mark Catch as CONTROL to prevent DCE; Try/Catch test green
- Add env-gated debug logs (effects, verifier, mir-printer, trycatch, ref, bin)
- Update CURRENT_TASK with progress and next steps
2025-08-26 05:49:23 +09:00
1e735d7717 runner: split modes (mir/vm/llvm/bench) and extract plugin init; interpreter: split objects into ops/methods/fields; VM logs gated; Phi selection minimal fix; CURRENT_TASK updated; remove legacy backups 2025-08-26 04:34:14 +09:00
11c149ac2b docs(current): refresh reboot shortcuts, smoke cmds, and next steps after VM compare fix; add quick restart guide 2025-08-26 03:33:01 +09:00
fd2eb25eb9 vm(compare): fix BoxRef(IntegerBox) comparisons by upstream casts and fallbacks; unify IntegerBox (re-export); as_bool truthiness; NewBox primitive fastpath; phi minimal fallback; add temp debug logs for route tracing 2025-08-26 03:26:55 +09:00
5765953e5f docs(current): record VM and/or truthiness, unify IntegerBox (re-export), and note loop-compare fix plan 2025-08-26 02:39:52 +09:00
44305404e4 Update CURRENT_TASK: mark MIR26 consolidation confirmed; note loop builder stabilization, CLI core-ci guide/script, ResultBox stage-0; update last-updated date. Ready to reopen without stream issues. 2025-08-26 01:44:14 +09:00
9c94e88b86 ResultBox migration (stage 0): suppress legacy deprecation warnings in box_trait impls; keep dual handling in VM. Fix verifier Display for SuspiciousBarrierContext. Expose VM stats fields to vm_stats module. CLI core_ci guide and script in place. 2025-08-26 01:42:18 +09:00
7705508b99 9.78h mainline: add TypeOp mixed-case MIR snapshot and include in CI golden checks; VM module headers for AI-friendly navigation; CURRENT_TASK updated with refactor goals. 2025-08-26 01:09:17 +09:00
7ccd5420ac Docs/CurrentTask: add explicit refactor goals/milestones/steps. VM modules: add Purpose/Responsibilities/Key APIs/Typical Callers headers. Build+goldens green. 2025-08-26 01:07:23 +09:00
edadf67ca0 Refactor (structure): add vm_stats module; move BoxCall debug logger into vm_boxcall; add quick-reference/code-map.md for AI-friendly repo navigation. Keep behavior unchanged. 2025-08-26 00:58:57 +09:00
2a02eb7a52 Refactor (light): move VM value ops to backend/vm_values.rs; add backend/vm_boxcall.rs with call_box_method_impl and rewire call_unified_method. Update CURRENT_TASK for refactor start. 2025-08-26 00:48:09 +09:00
320fbf0955 Phase 9.78h: Expand MIR golden snapshots (extern_call, loop, boxcall); add extern_console_log test; update CI golden check. Report refactoring candidates >1000 lines. 2025-08-26 00:12:53 +09:00
f82ad5a84d Phase 9.78h: VM BinOp and/or short-circuit + BoxRef<Integer> arithmetic; add diagnostic hooks. Update CURRENT_TASK with progress and VM path-tracing TODO. Align docs: MIR26 canonical spec and phase docs. 2025-08-26 00:06:35 +09:00
b8e416fb03 refactor: MIR builder modularization complete - ready for handoff
- MIRビルダーのモジュール化完了(1,547行→6モジュール)
  - core.rs (205行): MirBuilder本体
  - expressions.rs (621行): 式変換処理
  - statements.rs (165行): 文変換処理
  - control_flow.rs (194行): 制御フロー
  - box_handlers.rs (73行): Box処理
- 現在builder_modularizedに退避(MIR命令構造変更により調整必要)
- フルビルド可能な状態を維持
- CURRENT_TASK.mdに引き継ぎポイント記載

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 19:33:07 +09:00
4caa07d865 docs: Update CURRENT_TASK.md after MIR builder refactoring completion
- Marked MIR builder modularization as completed
- Added completion dates and commit hashes
- Updated next priority tasks from copilot_issues.txt
- Cleaned up completed task descriptions
2025-08-25 19:09:29 +09:00
17adc4347d refactor: MIR builder - complete modularization (Phase 6-8)
- Phase 6: statements.rs (165 lines) - 6 functions
  - build_print_statement, build_block
  - build_local_statement, build_return_statement
  - build_throw_statement, build_nowait_statement

- Phase 7: control_flow.rs (194 lines) - 4 functions
  - build_if_statement, build_loop_statement
  - build_try_catch_statement, is_current_block_terminated

- Phase 8: box_handlers.rs (73 lines) - 2 functions
  - build_static_main_box, build_box_declaration

Total: 30 functions moved across 4 modules
Original builder.rs reduced from 1547 lines
Build verified successfully
2025-08-25 18:43:45 +09:00
4b984d937b refactor: MIR builder - extract expressions module (Phase 3-5)
- Moved all expression-related functions to expressions.rs (621 lines)
- Includes: build_expression, build_literal, binary/unary ops
- Added missing functions for build_expression completeness:
  - build_assignment, build_field_assignment
  - build_new_expression, build_await_expression
- expressions.rs now contains 16 functions total
- Build verified successfully
2025-08-25 18:15:23 +09:00
cff58dbc0a refactor: MIR Builder Phase 1 - モジュール分割準備完了
【Phase 1完了内容】
- src/mir/builder/ ディレクトリ構造作成
- MirBuilder コア機能を core.rs に分離(8関数実装済み)
- 責務別モジュール準備(expressions/statements/control_flow/box_handlers)
- ビルド確認: 新構造でコンパイル正常完了

【技術詳細】
- MirBuilder本体 + emit_instruction/emit_type_check等コア機能
- プレースホルダー実装でビルド安全性確保
- CURRENT_TASK.md更新(Phase 1完了状況記録)
- 49関数/1547行の段階的分割準備

【次のPhase】
- Phase 2: 実際の関数移動(expressions.rs最優先)
- 慎重アプローチ: デッドコード削除は後回し

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 17:49:21 +09:00
c6d3b954d5 feat: Add dual-mode design doc and VM/MIR improvements
- Add comprehensive dual-mode design document (script vs application mode)
- Update phase 9.8 documentation with implementation progress
- Enhance VM with improved error handling and debugging
- Add MIR verification improvements
- Add test cases for MIR/VM POC

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 02:52:11 +09:00
0aef8d49a7 Phase 2: TypeOp変換の一本化(Optimizer安全ネット削除)\nPhase 3: 可視化/スナップショット基盤(--mir-verbose-effects, snapshot/compare/ci_check)\nDocs: Phase 1/2 完了マーク・利用方法追記 2025-08-24 01:58:41 +09:00
3c3dc86be0 feat: MIR builder TypeOp lowering for is/as methods and isType/asType functions
- Add early TypeOp lowering in build_expression for method-style is()/as()
- Add early TypeOp lowering in build_expression for function-style isType()/asType()
- Add special handling in build_print_statement for print(isType/asType(...))
- Fix MIR optimizer borrow checker issues and remove obsolete BoxFieldLoad
- Extract string literal helper supports both direct literals and StringBox wrappers
- Note: isType call generation still has issues (undefined SSA value in print)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-24 00:05:12 +09:00
2949648e71 fix: MIR builder me resolution for static box methods
- Fixed me ValueId inconsistency in static box methods
- Previously, each me reference generated a new const __me__ ValueId
- Now caches the first me ValueId in variable_map for reuse
- This ensures RefSet and RefGet operate on the same object
- ArrayBox get/set/push now working correctly in VM mode
- Test results: 1, 42, 3 (as expected)

🔧 Technical Details:
- build_me_expression() now stores fallback ValueId in variable_map
- Subsequent me references reuse the same ValueId
- VM BoxCall debug logs confirm ArrayBox methods dispatch correctly

Co-Authored-By: ChatGPT5
Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 21:13:02 +09:00
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
98fd6a1e3e docs: Update CURRENT_TASK with VM enhancements and test results
- Document dynamic type conversion implementations
- Add test results for Integer non-zero conditions
- Update ArrayBox/MapBox VM method support status
- Record SocketBox timeout method implementations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:52:18 +09:00
ff14d489d3 feat: Enhance VM with dynamic type conversion and comprehensive method support
- Add dynamic bool conversion for BoxRef(BoolBox)→bool and BoxRef(VoidBox)→false
- Implement String concatenation with Bool and BoxRef types via toString()
- Add Void/Bool comparison support (Eq/Ne only) to prevent VM crashes
- Implement comprehensive ArrayBox methods in VM:
  - push/pop/length/get/set/remove
  - contains/indexOf/clear/join/sort/reverse/slice
- Implement comprehensive MapBox methods in VM:
  - set/get/has/delete/keys/values/size/clear
- Add SocketBox timeout methods (acceptTimeout/recvTimeout)
- Update VM documentation with all new operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:37:38 +09:00
70af0fe566 feat: Add HTTP status tests and dynamic plugin documentation
- Add e2e_vm_http_status_404/500 tests to verify HTTP status handling
- ResultBox properly returns Ok(Response) for HTTP errors, Err for connection failures
- Create dynamic-plugin-flow.md documenting MIR→VM→Registry→Plugin flow
- Add vm-stats test files for HTTP 404/500 status codes
- Update net-plugin.md with HTTP error handling clarification
- Create E2E_TESTS.md documenting all E2E test behaviors
- Add mir-26-instruction-diet.md for MIR optimization plans
- Add vm-stats-cookbook.md for VM statistics usage guide
- Update MIR verifier to properly track self-assignment patterns

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 16:33:32 +09:00
3b03d001ba feat: Complete VM plugin E2E tests with ResultBox support
 All E2E tests passing:
- e2e_vm_plugin_filebox_copy_from_handle: Handle arguments (tag=8) working
- e2e_vm_http_get_basic: GET with ResultBox.get_value() working
- e2e_vm_http_post_and_headers: POST with status/headers/body verified (201:V:R)

Key achievement:
- VM already had ResultBox methods (is_ok/get_value/get_error) implemented
- HTTP plugin methods now correctly return values through ResultBox
- Full VM×Plugin integration verified

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 05:27:18 +09:00
63749b683e feat: Add VM statistics and fix compilation errors for plugin tests
- Add VM instruction statistics (--vm-stats, --vm-stats-json)
- Fix missing fields in ast.rs test code (public_fields, private_fields)
- Add CliConfig fields for VM statistics
- Enable TLV debug logging in plugin_loader_v2
- Successfully test FileBox handle passing and HTTP plugin creation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 04:51:24 +09:00
dd09e81018 feat: Add VM instruction statistics and fix plugin TLV debugging
Major changes:
- Add --vm-stats and --vm-stats-json CLI flags for VM instruction profiling
- Implement instruction counting by opcode type with JSON output support
- Add enhanced TLV debug logging with NYASH_DEBUG_PLUGIN=1 environment variable
- Fix missing fields in CliConfig and ASTNode::BoxDeclaration for test compatibility
- Improve plugin method call error messages with argument count/type details

This enables MIR→VM conversion health checks and supports the Phase 8.6 VM optimization goals.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 03:40:17 +09:00
4760921e91 feat: Add enhanced debug logging for plugin VM communication
- Add VM→Plugin and Plugin→VM boundary logging for method calls
- Enhanced debug output for tracking plugin invocation flow
- Added return value type/instance logging for better debugging
- Improved plugin communication traceability

This helps debug issues like the recent 45-day HTTP response debugging saga.
All logging is controlled by NYASH_DEBUG_PLUGIN=1 environment variable.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 12:36:14 +09:00
080458d4d4 fix: Correct HttpRequestBox method_id mapping in nyash.toml
Fixed the method ID order in HttpRequestBox configuration to match plugin implementation:
- path: method_id 1 (was incorrectly 2)
- readBody: method_id 2 (was incorrectly 3)
- respond: method_id 3 (was incorrectly 1)

This resolves the 45-day debugging issue where req.respond(resp) was calling
the wrong plugin method, causing HTTP responses to have empty bodies.

All E2E tests now pass:
- e2e_http_stub_end_to_end 
- e2e_http_multiple_requests_order 
- e2e_http_post_and_headers 
- e2e_http_server_restart 
- e2e_http_server_shutdown_and_restart 

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 12:09:06 +09:00
ce9e60972a feat: Add returns_result support and when pattern-matching design
- Add returns_result.md documenting Result正規化 (returns_result = true)
- Add when-pattern-matching.md with future pattern matching syntax design
- Update E2E tests to use get_value() for HTTP responses
- Update plugin system README with B案 (Result-based) support
- Remove singleton from HttpServerBox and SocketServerBox for stability

This prepares for gradual migration to Result-based error handling,
starting with Net plugin methods, as agreed with ChatGPT5's design.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 06:05:58 +09:00
f2761004d3 feat: Add parallel HTTP server E2E tests and enhance plugin system
- Add e2e_plugin_net_additional.rs with parallel server tests
- Fix test to properly handle request objects (no double accept)
- Add comprehensive net-plugin documentation
- Implement debug tracing for method calls
- Enhance plugin lifecycle documentation
- Improve error handling in plugin loader
- Add leak tracking infrastructure (for future use)
- Update language spec with latest plugin features

This enhances test coverage for concurrent HTTP servers and improves
the overall plugin system documentation and debugging capabilities.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 05:01:11 +09:00
eae7f54b13 feat: Add HTTP server/client E2E test for net plugin
- Implement full HTTP flow test: server → client → accept → respond → readBody
- All HTTP Box types working correctly (HttpServerBox, HttpClientBox, HttpRequestBox, HttpResponseBox)
- Handle type encoding for plugin method arguments working properly
- Test validates complete HTTP request/response cycle
- Net plugin E2E test passing 

HTTPネットワークプラグインのE2Eテスト追加
- サーバー起動からレスポンス読み取りまでの完全なフロー検証
- Handle型引数のTLVエンコーディングも正常動作
- 非同期HTTPフローの完全動作確認

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 22:25:42 +09:00
da716addc8 feat: Implement plugin singleton pattern with shutdown support
- Add singleton support for plugin boxes (e.g., CounterBox)
- Implement shutdown_plugins_v2() for controlled plugin lifecycle
- Plugin instances now shared across multiple new() calls
- Shutdown properly releases and allows re-initialization
- All singleton E2E tests passing 

ChatGPT5による高度なプラグインライフサイクル管理実装
- シングルトンパターンでプラグインインスタンス共有
- 明示的なshutdownでリソース解放と再初期化対応
- Nyashの統一ライフサイクルポリシー維持

Note: ast.rs test failures are due to rapid development pace -
tests need updating for new BoxDeclaration fields (private_fields, public_fields)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 21:35:17 +09:00
11c8672252 feat: Complete internal field access identification for visibility system
- Add internal access tracking to distinguish me.field from external.field access
- Interpreter correctly allows methods to access their own private fields
- VM tracks object class context during method calls for visibility checks
- Fix VM nested box declaration collection in collect_box_declarations
- Both interpreter and VM now pass all visibility tests consistently

Test results:
- visibility_ok.nyash:  Internal private access allowed in methods
- visibility_error.nyash:  External private access correctly blocked
- All private fields accessible from within their own methods
- Public fields remain accessible from anywhere

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 03:42:20 +09:00
55777a0735 feat: Implement field visibility (public/private) system
## Major Features Added

### Field Visibility System
- Added `private { ... }` and `public { ... }` blocks in box declarations
- Default visibility is now handled explicitly (fields must be in either block)
- Visibility checks enforced at both interpreter and VM levels

### Parser Enhancements
- Extended AST with public_fields and private_fields vectors
- Added parsing for visibility blocks in box definitions
- Maintained backward compatibility with existing `init { ... }` syntax

### Interpreter Implementation
- Added visibility checks in field access (get_field/set_field)
- External access to private fields now throws appropriate errors
- Internal access (within methods) always allowed

### VM Implementation
- Extended VM with object_class tracking for visibility checks
- RefGet/RefSet instructions now enforce field visibility
- Fixed nested box declaration collection (boxes defined inside methods)

### Test Examples Added
- docs/examples/visibility_ok.nyash - demonstrates correct usage
- docs/examples/visibility_error.nyash - tests private field access errors

## Technical Details

### Error Messages
- Interpreter: "Field 'X' is private in Y"
- VM: Same error message for consistency

### Current Limitations
- All RefGet/RefSet treated as external access in VM (internal flag future work)
- Legacy `init { ... }` fields treated as having unspecified visibility

## Test Results
 Interpreter: Both test cases pass correctly
 VM: Both test cases pass correctly after nested declaration fix

This implements the foundation for proper encapsulation in Nyash,
following the "explicit is better than implicit" philosophy.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 03:08:13 +09:00
2200312f09 docs: Add field visibility analysis and MIR BoxCall documentation
## Field Visibility Analysis Results
- Confirmed init{} fields are **public** in current Nyash implementation
- No access modifier (private/public) system currently implemented
- All fields accessible via me.fieldname syntax
- Documented findings for future reference

## MIR Documentation Enhancements
- Created comprehensive mir-dumper-guide.md for reading MIR dumps
- Enhanced mir-26-specification.md with BoxCall vs regular Call examples
- Added clear identification patterns:
  * BoxCall: `call %value.method(args)` (plugins/builtins)
  * Regular Call: `call %func(%me, args)` (user-defined boxes)

## VM Backend BoxRef Handling Improvements
- Fixed BoxRef method dispatch using share_box() instead of clone_box()
- Prevents unintended constructor calls during method resolution
- Maintains proper instance identity throughout VM execution

## MIR Builder User-Defined Box Tracking
- Added user_defined_boxes HashSet to track declared user boxes
- Improved method lowering decisions for user-defined vs builtin boxes
- Enhanced AST→MIR conversion accuracy for method calls

## Plugin Tester Lifecycle Enhancements
- Added comprehensive FileBox lifecycle testing (open/write/close)
- Enhanced cloneSelf() and copyFrom() testing with proper Handle parsing
- Added TLV encoding helpers for strings and bytes
- Improved error reporting and step-by-step validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 01:18:25 +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
dce53bf683 feat(phase-9.78b): Complete plugin Box inheritance and argument support
ChatGPT5による大規模改善:
-  プラグインBox継承サポート完成
-  from Parent.method()でプラグインメソッド呼び出し
-  引数・戻り値のTLVエンコード/デコード
-  借用チェッカーエラー全解決
-  MIRビルダーのクローン修正

次期作業:
- Phase 9.78b Step 3: BoxFactory dyn化
- アーキテクチャ改善継続

Co-authored-by: ChatGPT5 <noreply@openai.com>
2025-08-20 20:56:08 +09:00
8aef29eaef 🎉 feat: MIRパラメータ解決完全修正 + VM E2Eテスト成功!
Phase 9.78b関連修正:
- MirBuilder::lower_method_as_function でValueIdリセット実装
  - me → %0, 引数 → %1... の正しいマッピング
- build_me_expression() で変数テーブル優先解決
- VM E2Eテスト test_vm_user_box_birth_and_method 成功
  - new Person("Alice").greet() → "Hello, Alice"

ドキュメント:
- mir-unified-reference.md を正式MIRドキュメントとして配置
  - 現在の35命令実装状態を正確に記載
  - RefGet/RefSet仕様含む

ChatGPT5によるMIRビルダー修正で、VMバックエンドでのユーザー定義Box完全動作!
2025-08-20 19:34:09 +09:00
41361a2f50 🚀 feat: Phase 9.78b Step 1&2完了 - ChatGPT5による実装
ChatGPT5が実装したPhase 9.78b Step 1&2の統合

## 🎯 実装内容
1. Phase 9.78b Step 1: BoxDeclarationをcore::modelへ移動
   - src/core/mod.rs, model.rs 新規作成
   - BoxDeclarationを純粋データモデルとして分離

2. Phase 9.78b Step 2: NyashRuntime骨組み作成
   - src/runtime/nyash_runtime.rs 追加
   - 統一Box管理の基盤

3. ビルドエラー修正
   - Arc重複インポート修正
   - as_str() → as_ref() 変更
   - parent_name.to_string() 型変換
   - インポートパス調整

## 📊 ビルド結果
-  フルビルド成功 (47.34秒)
-  ユニットテスト: 145/145成功
-  統合テスト: 16/16成功
-  WASMビルド成功 (1.9MB)
-  MIRテスト: 1失敗 (ref_new命令)

## 🚀 次のステップ
- Phase 9.78b Step 3: BoxFactory dyn化
- Codexの設計に基づく段階的実装継続
2025-08-20 18:57:10 +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