Commit Graph

56 Commits

Author SHA1 Message Date
65763c1ed6 feat(llvm): Phase 97 - Call/PHI/Plugin強化 + リファクタリング準備
## 概要
LLVM backend のCall処理、PHI wiring、Plugin loader を強化。
次のリファクタリング(箱化モジュール化)のための準備も含む。

## 変更内容

### LLVM Call処理強化
- `mir_call/__init__.py`: Call ルーティングロジック改善
- `mir_call/global_call.py`: print処理の marshal強化
- `mir_call/method_call.py`: メソッド呼び出し処理改善
- `boxcall.py`: BoxCall処理改善

### PHI処理強化
- `phi_manager.py`: PHI管理改善
- `phi_wiring/wiring.py`: PHI配線ロジック強化(+17行)
- `phi_wiring/tagging.py`: Type tagging改善
- `resolver.py`: Value解決ロジック強化(+34行)

### Copy伝播
- `copy.py`: Copy命令のType tag伝播追加(+10行)

### Plugin loader強化
- `library.rs`: エラー出力改善、[plugin/missing]ログ追加(+34行)
- fail-fast強化

### テスト
- `phase97_json_loader_escape_llvm_exe.sh`: Phase 97 E2Eテスト追加
- `phase97_next_non_ws_llvm_exe.sh`: Phase 97 E2Eテスト追加

### その他
- `nyash_kernel/lib.rs`: Kernel側の改善(+23行)

## 統計
- 14ファイル変更
- +256行 / -53行 = +203 net

## 次のリファクタリング準備
以下の箇所がリファクタリング対象として識別済み:
1. Call ルーティング箱の明文化
2. print の marshal 箱
3. TypeFacts/Tagging 箱の一本化
4. PHI Snapshot 契約のSSOT
5. Plugin loader のエラー出力統合

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-17 03:51:03 +09:00
a955dd6b18 feat(llvm): Phase 131-15 - print/concat segfault 根治修正
## P1-1/P1-2: TypeFacts 優先化
- binop.py: operand facts が dst_type ヒントより優先
- mir_json_emit.rs: Unknown 時に dst_type を出さない
- function_lower.py: value_types を metadata から読み込み

## P2: handle concat 統一(根治)
- print シグネチャ修正: i64(i64) → void(i8*)
- Mixed concat を handle ベースに統一:
  - concat_si/concat_is → concat_hh
  - box.from_i64 で integer を handle 化
  - Everything is Box 哲学に統一
- legacy 関数は互換性のために保持

## 結果
-  print("Result: " + 3) → Result: 3
-  segfault 解消
-  Everything is Box 統一

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 01:36:34 +09:00
18bf35e6d4 fix(llvm): Phase 131-10 - Smart console.log routing(Segfault修正)
## 問題
- Integer値をi8*ポインタに変換 → Segfault(Exit 139)

## 解決策
- String literal → nyash.console.log(i8*)
- Integer/Handle → nyash.console.log_handle(i64)

## 結果
- Case B (loop_min_while): LLVM outputs `0,1,2` 
- VM/LLVM完全パリティ達成

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 09:19:00 +09:00
8a8c90fc74 docs(joinir): Phase 86 SSOT 追記完了 + Phase 88 準備
Phase 86 SSOT 追記(P0 完了):
- 10-Now.md: carrier_init_builder / error_tags 確立を追記
- CURRENT_TASK.md: P0→P1 繰り上げ、Done 節追加

Phase 88 準備:
- nyash_kernel/lib.rs: AOT 実行器で Ring0Context 初期化
- nyash.toml: プラグインパス正規化(plugins/...)
- auto_detect.conf: integration タイムアウト 120秒に延長

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 00:05:16 +09:00
d7805e5974 feat(joinir): Phase 213-2 Step 2-2 & 2-3 Data structure extensions
Extended PatternPipelineContext and CarrierUpdateInfo for Pattern 3 AST-based generalization.

Changes:
1. PatternPipelineContext:
   - Added loop_condition: Option<ASTNode>
   - Added loop_body: Option<Vec<ASTNode>>
   - Added loop_update_summary: Option<LoopUpdateSummary>
   - Updated build_pattern_context() for Pattern 3

2. CarrierUpdateInfo:
   - Added then_expr: Option<ASTNode>
   - Added else_expr: Option<ASTNode>
   - Updated analyze_loop_updates() with None defaults

Status: Phase 213-2 Steps 2-2 & 2-3 complete
Next: Create Pattern3IfAnalyzer to extract if statement and populate update summary
2025-12-10 00:01:53 +09:00
8750186e55 chore: Phase 26-H セッション完了 - 全ドキュメント更新
Phase 26-H 完了内容:
 JoinIR 型定義実装(src/mir/join_ir.rs)
 MIR → JoinIR 自動変換実装(lower_min_loop_to_joinir)
 自動変換テスト実装(mir_joinir_min_auto_lowering)
 PHI/Loop箱 → JoinIR 移行対応表追加(loopform_ssot.md)

ドキュメント更新:
- Phase 27 JoinIR タスク計画追加
- Phase 26-H タスク完了記録
- 各種 README 更新(進捗反映)
- CURRENT_TASK.md 更新

コミット統計: $(git status --short | wc -l) files changed

次のステップ: Phase 27 一般化 MIR → JoinIR 変換
2025-11-23 05:53:27 +09:00
6856922374 Phase 25.1a: selfhost builder hotfix (fn rename, docs) 2025-11-15 05:42:32 +09:00
864a94d013 feat(phase-21.8+25): Complete imports resolution + Ring0/Ring1 numeric ABI design
Phase 21.8 完了 (imports resolution):
-  using nyash.core.numeric.matrix_i64 as MatI64 完全対応
-  hakorune_emit_mir.sh で imports 抽出・MirBuilder に配線
-  MatI64/IntArrayCore の静的参照解決が安定動作
-  matmul_core ベンチ MIR 生成成功 (VM/LLVM 両対応)

Phase 25 設計完了 (Ring0/Ring1 + numeric ABI):
- 🎯 Ring0/Ring1 責務分離を明文化 (Rust Freeze Policy 具体化)
- 🎯 Call/ExternCall 明確な分離設計
  - Call: Ring1 Hako 関数 (numeric core 等)
  - ExternCall: Ring0 intrinsic (rt_mem_* 等の FFI のみ)
- 🎯 BoxCall → Call 変換方針確定 (AotPrep で実施)
- 🎯 MatI64.mul_naive を NyNumericMatI64.mul_naive に分離
  (System Hakorune subset で完全実装済み)

実装:
-  AotPrepNumericCoreBox 診断パス実装 (NYASH_AOT_NUMERIC_CORE=1)
-  numeric ABI ドキュメント整備 (NUMERIC_ABI.md)
-  System Hakorune subset 定義 (system-hakorune-subset.md)
-  IntArrayCore/MatI64 仕様固定 (lang/src/runtime/numeric/README.md)
-  ENV_VARS.md に NYASH_AOT_NUMERIC_CORE トグル追記

今後のタスク:
- BoxCall(MatI64) → Call(NyNumericMatI64) 変換実装 (opt-in)
- IntArrayCore の numeric core 整備
- matmul_core スモークテスト (NYASH_AOT_NUMERIC_CORE=0/1 両対応)

🎉 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 20:19:00 +09:00
8214176814 feat(perf): add Phase 21.8 foundation for IntArrayCore/MatI64 numeric boxes
Prepare infrastructure for specialized numeric array benchmarking:
- Add IntArrayCore plugin stub (crates/nyash_kernel/src/plugin/intarray.rs)
- Add IntArrayCore/MatI64 box definitions (lang/src/runtime/numeric/)
- Add Phase 21.8 documentation and task tracking
- Update nyash.toml/hako.toml with numeric library configuration
- Extend microbench.sh for matmul_core benchmark case

Next: Resolve Stage-B MirBuilder to recognize MatI64/IntArrayCore as boxes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 15:18:14 +09:00
dda65b94b7 Phase 21.7 normalization: optimization pre-work + bench harness expansion
- Add opt-in optimizations (defaults OFF)
  - Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
  - strlen FAST enhancement for const handles
  - FAST_INT gate for same-BB SSA optimization
  - length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
  - Add branch/call/stringchain/arraymap/chip8/kilo cases
  - Auto-calculate ratio vs C reference
  - Document in benchmarks/README.md
- Compiler health improvements
  - Unify PHI insertion to insert_phi_at_head()
  - Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
  - Clarify Rust/Hako ownership boundaries
  - Strengthen receiver localization (LocalSSA/pin/after-PHIs)
  - Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 16:40:58 +09:00
52b62c5772 feat(phase21.5): Stage-B parser loop fix + delegate path stabilization
## 修正内容

### 1. Stage-B パーサー修正(偶然の回避)
- **ファイル**:
  - `lang/src/compiler/parser/expr/parser_expr_box.hako`
  - `lang/src/compiler/parser/stmt/parser_control_box.hako`
- **問題**: ネストループで gpos が正しく進まず、loop の cond/body が壊れる
- **回避策**: new 式のメソッドチェーン処理追加で別ループを導入
- **結果**: MIR 生成が変わって VM gpos バグを回避

### 2. delegate パス動作確認
- **テスト**: `/tmp/loop_min.hako` → rc=10 
- **MIR構造**: 正しい PHI/compare/binop を生成
- **チェーン**: hakorune parser → Rust delegate → LLVM EXE 完動

### 3. ドキュメント追加
- `docs/development/analysis/` - delegate 分析
- `docs/development/guides/` - ループテストガイド
- `docs/development/testing/` - Stage-B 検証報告

### 4. カナリーテスト追加
- `tools/smokes/v2/profiles/quick/core/phase2100/` 配下に複数追加
- emit_boxcall_length_canary_vm.sh
- stageb_parser_loop_json_canary_vm.sh
- 他

### 受け入れ基準
-  delegate パス: rc=10 返す
-  FORCE パス: rc=10 返す(既存)
-  MIR 構造: 正しい PHI incoming と compare
-  既定挙動: 不変(dev トグルのみ)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 21:24:51 +09:00
6055d53eff feat(phase21.5/22.1): MirBuilder JsonFrag refactor + FileBox ring-1 + registry tests
Phase 21.5 (AOT/LLVM Optimization Prep)
- FileBox ring-1 (core-ro) provider: priority=-100, always available, no panic path
  - src/runner/modes/common_util/provider_registry.rs: CoreRoFileProviderFactory
  - Auto-registers at startup, eliminates fallback panic structurally
- StringBox fast path prototypes (length/size optimization)
- Performance benchmarks (C/Python/Hako comparison baseline)

Phase 22.1 (JsonFrag Unification)
- JsonFrag.last_index_of_from() for backward search (VM fallback)
- Replace hand-written lastIndexOf in lower_loop_sum_bc_box.hako
- SentinelExtractorBox for Break/Continue pattern extraction

MirBuilder Refactor (Box → JsonFrag Migration)
- 20+ lower_*_box.hako: Box-heavy → JsonFrag text assembly
- MirBuilderMinBox: lightweight using set for dev env
- Registry-only fast path with [registry:*] tag observation
- pattern_util_box.hako: enhanced pattern matching

Dev Environment & Testing
- Dev toggles: SMOKES_DEV_PREINCLUDE=1 (point-enable), HAKO_MIR_BUILDER_SKIP_LOOPS=1
- phase2160: registry opt-in tests (array/map get/set/push/len) - content verification
- phase2034: rc-dependent → token grep (grep -F based validation)
- run_quick.sh: fast smoke testing harness
- ENV documentation: docs/ENV_VARS.md

Test Results
 quick phase2034: ALL GREEN (MirBuilder internal patterns)
 registry phase2160: ALL GREEN (array/map get/set/push/len)
 rc-dependent tests → content token verification complete
 PREINCLUDE policy: default OFF, point-enable only where needed

Technical Notes
- No INCLUDE by default (maintain minimalism)
- FAIL_FAST=0 in Bring-up contexts only (explicit dev toggles)
- Tag-based route observation ([mirbuilder/min:*], [registry:*])
- MIR structure validation (not just rc parity)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 19:42:42 +09:00
f6c5dc9e43 Phase 22.x WIP: LLVM backend improvements + MIR builder enhancements
LLVM backend improvements:
- Add native LLVM backend support (NYASH_LLVM_BACKEND=native)
- Add crate backend selector with priority (crate > llvmlite)
- Add native_llvm_builder.py for native IR generation
- Add NYASH_LLVM_NATIVE_TRACE=1 for IR dump

MIR builder enhancements:
- Refactor lower_if_compare_* boxes for better code generation
- Refactor lower_return_* boxes for optimized returns
- Refactor lower_loop_* boxes for loop handling
- Refactor lower_method_* boxes for method calls
- Update pattern_util_box for better pattern matching

Smoke tests:
- Add phase2100 S3 backend selector tests (17 new tests)
- Add phase2120 native backend tests (4 new tests)
- Add phase2034 MIR builder internal tests (2 new tests)
- Add phase2211 TLV shim parity test

Documentation:
- Update ENV_VARS.md with LLVM backend variables
- Update CURRENT_TASK.md with progress
- Update README.md and CHANGELOG.md

Config:
- Add NYASH_LLVM_BACKEND env support in src/config/env.rs
- Update ny_mir_builder.sh for backend selection
- Update dispatch.rs for backend routing

Tools:
- Add tools/native_llvm_builder.py
- Update smokes/v2/profiles/quick/core/phase2100/run_all.sh

Known: Many Hako builder internal files modified for optimization
2025-11-09 23:40:36 +09:00
981ddd890c Phase 22.1 WIP: SSOT resolver + TLV infrastructure + Hako MIR builder setup
Setup infrastructure for Phase 22.1 (TLV C shim & Resolver SSOT):

Core changes:
- Add nyash_tlv, nyash_c_core, nyash_kernel_min_c crates (opt-in)
- Implement SSOT resolver bridge (src/using/ssot_bridge.rs)
- Add HAKO_USING_SSOT=1 / HAKO_USING_SSOT_HAKO=1 env support
- Add HAKO_TLV_SHIM=1 infrastructure (requires --features tlv-shim)

MIR builder improvements:
- Fix using/alias consistency in Hako MIR builder
- Add hako.mir.builder.internal.{prog_scan,pattern_util} to nyash.toml
- Normalize LLVM extern calls: nyash.console.* → nyash_console_*

Smoke tests:
- Add phase2211 tests (using_ssot_hako_parity_canary_vm.sh)
- Add phase2220, phase2230, phase2231 test structure
- Add phase2100 S3 backend selector tests
- Improve test_runner.sh with quiet/timeout controls

Documentation:
- Add docs/ENV_VARS.md (Phase 22.1 env vars reference)
- Add docs/development/runtime/C_CORE_ABI.md
- Update de-rust-roadmap.md with Phase 22.x details

Tools:
- Add tools/hakorune_emit_mir.sh (Hako-first MIR emission wrapper)
- Add tools/tlv_roundtrip_smoke.sh placeholder
- Improve ny_mir_builder.sh with better backend selection

Known issues (to be fixed):
- Parser infinite loop in static method parameter parsing
- Stage-B output contamination with "RC: 0" (needs NYASH_JSON_ONLY=1)
- phase2211/using_ssot_hako_parity_canary_vm.sh fork bomb (needs recursion guard)

Next steps: Fix parser infinite loop + Stage-B quiet mode for green tests
2025-11-09 15:11:18 +09:00
301b1d212a Phase 21.2 Complete: VM Adapter正規実装 + devブリッジ完全撤去
## 🎉 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>
2025-11-07 19:32:44 +09:00
77d4fd72b3 phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0 2025-11-06 15:41:52 +09:00
30aa39f50b hv1 verify: add direct route (env JSON) and clean inline path; fix v1 phi incoming order; make test_runner use hv1 direct; add phase2037 phi canaries; load modules.workspace exports for alias; update docs (phase-20.38, source extensions) and CURRENT_TASK 2025-11-04 16:33:04 +09:00
8b71f25dd4 Stage-A selfhost emitter fixes and LLVM opt toggle 2025-10-31 23:16:27 +09:00
5e3d9e7ae4 restore(lang/compiler): bring back lang/src/compiler from e917d400; add Hako index canaries and docs; implement Rust-side index operator (Array/Map get/set) with Fail‑Fast diagnostics
- restore: lang/src/compiler/** (parser/emit/builder/pipeline_v2) from e917d400
- docs: docs/development/selfhosting/index-operator-hako.md
- smokes(hako): tools/smokes/v2/profiles/quick/core/index_operator_hako.sh (opt-in)
- smokes(vm): adjust index_operator_vm.sh for semicolon gate + stable error text
- rust/parser: allow IndexExpr and assignment LHS=Index; postfix parse LBRACK chain
- rust/builder: lower arr/map index to BoxCall get/set; annotate array/map literals; Fail‑Fast for unsupported types
- CURRENT_TASK: mark Rust side done; add Hako tasks checklist

Note: files disappeared likely due to branch FF to a lineage without lang/src/compiler; no explicit delete commit found. Added anchor checks and suggested CI guard in follow-up.
2025-10-31 20:18:39 +09:00
712b370013 aot(core): EXE path green (return 7); migrate NyRT jit handles → runtime::host_handles; fix mir_call.py indent; workspace excludes for missing plugins; docs(phase-33) status update 2025-10-31 18:30:50 +09:00
824ca600ea refactor: 大規模ファイル分割とプラグインリファクタリング
## 🎯 プラグイン整理
-  **nyash-json-plugin**: プロバイダー抽象化、NodeRep統一
-  **nyash-string-plugin**: TLVヘルパー整理
-  **nyash-net-plugin**: HTTPヘルパー分離、ソケット管理改善
-  **nyash-counter-plugin/fixture-plugin**: 基本構造整理

## 📂 mir_interpreter分割
-  **mir_interpreter.rs → mir_interpreter/ディレクトリ**
  - mod.rs: メイン構造体定義
  - execution.rs: 実行エンジン
  - memory.rs: メモリ管理
  - instructions/: 命令別実装

## 🔧 その他の改善
- テストファイル群の最適化
- LLVMコンパイラのメイン関数整理
- 不要なインポート削除

1000行超のファイルを適切なモジュール構造に分割完了!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 01:09:48 +09:00
f0608e9bb1 feat: Phase 2.4 レガシーアーカイブ整理完了(151MB削減)
## 🎉 完了項目
-  plugin_box_legacy.rs削除(7.7KB、参照ゼロ確認済み)
-  REMOVEDコメント整理(encode.rs簡潔化)
-  venv削除(143MB節約、.gitignoreは既存)
-  llvm_legacyスタブ化(8KB、compile_error!による安全化)

## 🏆 成果
- **リポジトリサイズ改善**: 151MB削減
- **コード整理**: レガシーコード安全にアーカイブ
- **プラグインファースト**: StrictPluginFirst継続動作

##  検証完了
- cargo build --release --features llvm (警告のみ、エラーなし)
- LLVMハーネス実行: print出力正常
- プラグイン動作: StringBox等正常動作

codex先生の戦略に従った安全な段階的削除を実行

Co-Authored-By: codex <noreply@anthropic.com>
2025-09-24 14:13:15 +09:00
f4fe548787 feat: Phase 2.4 NyRT→NyKernel Architecture Revolution 100%完了!
ChatGPT5 Pro設計分析による42%コード削減の完全実現:
- crates/nyrt → crates/nyash_kernel 完全移行
- with_legacy_vm_args系統11箇所削除(encode/birth/future/invoke系)
- Plugin-First Architecture統一(VM依存根絶)
- libnyash_kernel.a生成成功(0エラー・0警告)
- LLVM統合更新(build_llvm.sh, ny-llvmc対応)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 12:57:33 +09:00
95382bcaab feat: Phase 2.2 LLVM静的プラグイン検証完了!nyrt設計真実解明
 **Phase 2.2達成項目**:
- LLVMスモークテスト完全成功(1648バイト生成)
- プラグイン統合動作確認(StringBox/IntegerBox@LLVM)
- 静的コンパイル核心技術実証(MIR→LLVM→オブジェクト)
- Everything is Plugin革命のLLVM対応確認

🔍 **Task先生nyrt調査成果**:
- nyrt正体解明:AOT/LLVMランタイム必須インフラ
- 機能分類:58%必須(ハンドル・GC・エントリー)42%代替可能
- 設計一貫性:75%達成(Box操作完全プラグイン化)
- 削減戦略:Phase A実装で26個関数→プラグイン統合(42%削減)

🎯 **Everything is Plugin完全実現への道筋**:
- 現状:プラグインファクトリー(StrictPluginFirst)完全動作
- 課題:nyrt中央集権 vs プラグイン哲学の矛盾
- 解決:Hybrid Plugin Architecture推進
- 目標:String/Box API→プラグイン統合で設計一貫性完成

📊 **技術的成果**:
- LLVM static plugin integration:  完全動作
- Plugin priority system:  完全動作
- Object code generation:  実証済み
- nyrt architectural analysis:  完全解明

🚀 **Phase 15.5革命基盤確立**: プラグイン優先アーキテクチャ実用化完了
次段階Phase 2.3でビルトインBox段階削除+nyrt Plugin統合推進へ

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 12:22:08 +09:00
951a050592 selfhost: introduce using-based imports for compiler/parser/tools; keep includes temporarily. llvm: add PHI wiring JSON trace + unit/integration tests; fast test suite extended. runner: split selfhost helpers, small cleanups. 2025-09-18 13:35:38 +09:00
3fe908eb0d docs/runtime: externcall + println normalization; NyRT silent result flag; PyVM console warn/error/trace routing\nselfhost(M2): add MirEmitterBox (Return(Int)->const+ret) and --emit-mir switch; initial selfhost smoke\nrunner: child args/env hardening for selfhost (NYASH_NY_COMPILER_CHILD_ARGS under --; NYASH_JSON_ONLY=1, NYASH_VM_USE_PY=1, NYASH_DISABLE_PLUGINS=1); VM path strips using lines when NYASH_ENABLE_USING=1\nmeta: clarify PyVM/llvmlite as primary (vm/interpreter legacy OFF) in CURRENT_TASK.md; README links to externcall docs 2025-09-18 06:35:49 +09:00
5d51086530 python-plugin: RAII (PyOwned/PyBorrowed) + autodecode enum; crate: ny-llvmc --emit exe with NyRT link; tools: build_llvm.sh crate-exe path + crate_exe_smoke; CURRENT_TASK update 2025-09-18 03:57:25 +09:00
d992fa1d2d feat(llvm): wire nyash --emit-mir-json into build_llvm.sh crate path; add NYASH_LLVM_ONLY_OBJ gate; fix ny-llvmc bin name 2025-09-17 22:11:59 +09:00
4ea3ca2685 docs/ci: selfhost bootstrap/exe-first workflows; add ny-llvmc scaffolding + JSON v0 schema validation; plan: unify to Nyash ABI v2 (no backwards compat) 2025-09-17 20:33:19 +09:00
5c9213cd03 smokes: add curated LLVM runner; archive legacy smokes; PHI-off unified across Bridge/Builder; LLVM resolver tracing; minimal Throw lowering; config env getters; dev profile and root cleaner; docs updated; CI workflow runs curated LLVM (PHI-on/off) 2025-09-16 23:49:36 +09:00
63c8fda808 🔍 Research: GPT-5-Codex capabilities and GitHub PR integration
## Summary
Investigated OpenAI's new GPT-5-Codex model and Codex GitHub PR review integration capabilities.

## GPT-5-Codex Analysis

### Benchmark Performance (Good)
- SWE-bench Verified: 74.5% (vs GPT-5's 72.8%)
- Refactoring tasks: 51.3% (vs GPT-5's 33.9%)
- Code review: Higher developer ratings

### Real-World Issues (Concerning)
- Users report degraded coding performance
- Scripts that previously worked now fail
- Less consistent than GPT-4.5
- Longer response times (minutes vs instant)
- "Creatively and emotionally flat"
- Basic errors (e.g., counting letters incorrectly)

### Key Finding
Classic case of "optimizing for benchmarks vs real usability" - scores well on tests but performs poorly in practice.

## Codex GitHub PR Integration

### Setup Process
1. Enable MFA and connect GitHub account
2. Authorize Codex GitHub app for repos
3. Enable "Code review" in repository settings

### Usage Methods
- **Manual**: Comment '@codex review' in PR
- **Automatic**: Triggers when PR moves from draft to ready

### Current Limitations
- One-way communication (doesn't respond to review comments)
- Prefers creating new PRs over updating existing ones
- Better for single-pass reviews than iterative feedback

## 'codex resume' Feature
New session management capability:
- Resume previous codex exec sessions
- Useful for continuing long tasks across days
- Maintains context from interrupted work

🐱 The investigation reveals that while GPT-5-Codex shows benchmark improvements, practical developer experience has declined - a reminder that metrics don't always reflect real-world utility\!
2025-09-16 16:28:25 +09:00
3e07763af8 docs: update CURRENT_TASK with Box Theory PHI plan (defer/finalize) and MIR v0.5 type meta; add parity tooling and PyVM scaffolding
impl(pyvm/llvmlite):
- add tools/parity.sh; tools/pyvm_runner.py; src/llvm_py/pyvm/*
- emit string const as handle type in MIR JSON; add dst_type hints
- unify '+' to concat_hh with from_i64/from_i8_string bridges; console print via to_i8p_h
- add runtime bridges: nyash.box.from_i64, nyash.string.to_i8p_h

tests:
- add apps/tests/min_str_cat_loop (minimal repro for string cat loop)
2025-09-14 04:51:33 +09:00
2a9aa5368d harness(llvm/py): fix PHI/dominance via Resolver-only; per-pred localization and constant GEPs; stabilize Main.esc_json/1, dirname/1, node_json/3; docs: add NYASH_LLVM_TRACE_FINAL and Resolver-only invariants
- Resolver-only reads across BBs; remove vmap fallbacks
- Create PHIs at block start; insert casts in preds before terminators
- Re-materialize int in preds to satisfy dominance (add/zext/trunc)
- Use constant GEP for method strings to avoid order dependency
- Order non-PHI lowering to preserve producer→consumer dominance
- Update docs: RESOLVER_API.md, LLVM_HARNESS.md
- compare_harness_on_off: ON/OFF exits match; linking green
2025-09-13 19:49:03 +09:00
4fe1212d36 🚀 Major LLVM breakthrough by ChatGPT5\!
PHI type coercion and core-first routing fixes:
- Auto type conversion for PHI nodes (i64↔i8*↔i1↔f64)
- Fixed ArrayBox.get misrouting to Map path
- Core-first strategy for Array/Map creation
- Added comprehensive debug logging ([PHI], [ARR], [MAP])

Results:
 Array smoke test: 'Result: 3'
 Map smoke test: 'Map: v=42, size=1'

After 34+ minutes of battling Rust lifetime errors,
ChatGPT5 achieved a major breakthrough\!

Key insight: The bug wasn't in PHI/SSA logic but in
Box type routing - ArrayBox.get was incorrectly caught
by Map fallback due to missing annotations.

We're SO CLOSE to Nyash self-hosting paradise\! 🌟
Once this stabilizes, everything can be written in
simple, beautiful Nyash code instead of Rust complexity.
2025-09-12 12:07:07 +09:00
40d0cac0f1 feat(llvm): Complete function call system implementation by ChatGPT5
Major improvements to LLVM backend function call infrastructure:

## Key Changes

### Function Call System Complete
- All MIR functions now properly lowered to LLVM (not just entry)
- Function parameter binding to LLVM arguments implemented
- ny_main() wrapper added for proper entry point handling
- Callee resolution from ValueId to function symbols working

### Call Instruction Analysis
- MirInstruction::Call was implemented but system was incomplete
- Fixed "rhs missing" errors caused by undefined Call return values
- Function calls now properly return values through the system

### Code Modularization (Ongoing)
- BoxCall → instructions/boxcall.rs ✓
- ExternCall → instructions/externcall.rs ✓
- Call remains in mod.rs (to be refactored)

### Phase 21 Documentation
- Added comprehensive AI evaluation from Gemini and Codex
- Both AIs confirm academic paper potential for self-parsing AST DB approach
- "Code as Database" concept validated as novel contribution

Co-authored-by: ChatGPT5 <noreply@openai.com>

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-12 01:45:00 +09:00
13298126c8 fix(llvm): MapBox core-first implementation with plugin fallback by ChatGPT
Implemented elegant solution for MapBox as core box with plugin fallback:

1. Core-first Strategy:
   - Removed MapBox type_id from nyash_box.toml
   - MapBox now uses env.box.new fallback (core implementation)
   - Consistent with self-hosting goals

2. Plugin Fallback Option:
   - Added NYASH_LLVM_FORCE_PLUGIN_MAP=1 environment variable
   - Allows forcing MapBox to plugin path when needed
   - Preserves flexibility during transition

3. MIR Type Inference:
   - Added MapBox method type inference (size/has/get)
   - Ensures proper return type handling

4. Documentation:
   - Added core vs plugin box explanation in nyrt
   - Clarified the transition strategy

This aligns with Phase 15 goals where basic boxes will eventually
be implemented in Nyash itself for true self-hosting.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 23:09:16 +09:00
e7ad2191de fix(llvm): String/Plugin return value handling improvements by ChatGPT
Major fixes for LLVM backend string and plugin return value handling:

1. MIR Type Annotations:
   - Added StringBox method return types (substring/concat/replace/trim/toUpper/toLower)
   - Enhanced type inference for BoxCall operations

2. LLVM BinOp String Concatenation:
   - Added safe handle-to-pointer conversion paths
   - Support for ptr+i64 and i64+ptr concatenation patterns
   - Uses nyash.string.concat_hh for handle-based concatenation

3. ExternCall Selection:
   - Smart selection between C string (i8*) and handle (i64) variants
   - Improved print/log function selection based on argument types

4. StringBox Fast-path Optimization:
   - Direct AOT concatenation for StringBox.concat
   - Bypasses plugin path for better performance

5. Consistent String Representation:
   - AOT uses i8* (C string) as primary representation
   - Handles used for print/concat auxiliary paths

6. Build Fix:
   - Removed duplicate plugin.rs to resolve nyrt build conflicts

Results: LLVM plugin return smoke tests now pass (NYASH_LLVM_PLUGIN_RET_SMOKE=1)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 20:18:53 +09:00
a762a3535e nyrt: split plugin module (#139) 2025-09-11 11:19:55 +09:00
f441d84578 nyrt: split lib into modules (#138) 2025-09-11 06:35:36 +09:00
40489a3c97 feat(debug): Add debug logging to console.log_handle for plugin investigation
- Added eprintln! debug messages to trace handle values
- Helps investigate why plugin return values display as blank
- Part of ongoing LLVM backend plugin return value investigation

Related to issue where print(c.get()) shows blank output

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 06:03:21 +09:00
f124731764 runtime: print raw values for console handle shims (#135) 2025-09-11 03:54:35 +09:00
e114f9bfe3 fix(llvm): Implement handle-based console.log functions for plugin return values
- Add nyash.console.log_handle(i64) -> i64 family functions to nyrt
- Replace invalid int-to-pointer conversion with proper handle-based calls
- Fix bool(i1) -> i64 type conversion in LLVM compiler
- Resolve LLVM function verification errors
- Enable plugin method execution without NYASH_LLVM_ALLOW_BY_NAME
- Merge codex TLV fixes for plugin return value handling (2000+ lines)

Technical Details:
- Root cause: build_int_to_ptr(handle_value, i8*, "arg_i2p") treated
  handle IDs as memory addresses (invalid operation)
- Solution: Direct i64 handle passing to nyrt functions with proper
  handle registry lookup and to_string_box() conversion
- Type safety: Added proper i1/i32/i64 -> i64 conversion handling

Status: Console.log type errors resolved, plugin return value display
still under investigation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 00:21:11 +09:00
5dd3227a1a nyrt: handle plugin return primitives 2025-09-10 23:46:53 +09:00
d62114c705 Core-13 pure: add CI workflows, VM e2e tests, LLVM parity bridge (minimal); do not touch private docs 2025-09-07 07:28:53 +09:00
d631beba37 dev: add selfhosting/cranelift workspaces; jit: add return materialization, ret_slot, hostcall arity pad, and dbg imports for diagnosis 2025-09-06 10:59:33 +09:00
7d88c04c0e wip(phase15): AOT修正作業中 - Nyプラグインと標準ライブラリ実装
Phase 15のAOT/ネイティブビルド修正作業を継続中。
ChatGPTによるstd実装とプラグインシステムの改修を含む。

主な変更点:
- apps/std/: string.nyashとarray.nyashの標準ライブラリ追加
- apps/smokes/: stdライブラリのスモークテスト追加
- プラグインローダーv2の実装改修
- BoxCallのハンドル管理改善
- JIT hostcall registryの更新
- ビルドスクリプト(build_aot.sh, build_llvm.sh)の調整

まだ修正作業中のため、一部の機能は不完全な状態。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 06:24:08 +09:00
a2b89fae7e phase15: update CLAUDE.md and sync with current progress
- Update phase indicator to Phase 15 (Self-Hosting)
- Update documentation links to Phase 15 resources
- Reflect completion of R1-R5 tasks and ongoing work
- Fix CURRENT_TASK.md location to root directory

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 13:29:17 +09:00
c9366d5c54 Phase 11.8/12: MIR Core-13 roadmap, Nyash ABI design, async/await enhancements with TaskGroupBox foundation
Major additions:
- Phase 11.8 MIR cleanup specification (Core-15→14→13 roadmap)
- Nyash ABI unified design document (3×u64 structure)
- TaskGroupBox foundation with cancelAll/joinAll methods
- Enhanced async/await with checkpoint auto-insertion
- Structured concurrency preparation (parent-child task relationships)

Documentation:
- docs/development/roadmap/phases/phase-11.8_mir_cleanup/: Complete Core-13 path
- docs/development/roadmap/phases/phase-12/NYASH-ABI-DESIGN.md: Unified ABI spec
- Updated Phase 12 README with AOT/JIT explanation for script performance
- Added async_task_system/ design docs

Implementation progress:
- FutureBox spawn tracking with weak/strong reference management
- VM checkpoint integration before/after await
- LLVM backend async support preparation
- Verifier rules for await-checkpoint enforcement
- Result<T,E> normalization for timeout/cancellation

Technical insights:
- MIR as 'atomic instructions', Box as 'molecules' philosophy
- 'Everything is Box' enables full-stack with minimal instructions
- Unified BoxCall for array/plugin/async operations future consolidation

Next steps:
- Complete TaskGroupBox implementation
- Migrate from global to scoped task management
- Implement LIFO cleanup on scope exit
- Continue Core-13 instruction consolidation

🚀 'From 15 atoms to infinite programs: The Nyash Box Theory'
2025-09-02 03:41:51 +09:00
11506cee3b Phase 11-12: LLVM backend initial, semantics layer, plugin unification
Major changes:
- LLVM backend initial implementation (compiler.rs, llvm mode)
- Semantics layer integration in interpreter (operators.rs)
- Phase 12 plugin architecture revision (3-layer system)
- Builtin box removal preparation
- MIR instruction set documentation (26→Core-15 migration)
- Cross-backend testing infrastructure
- Await/nowait syntax support

New features:
- LLVM AOT compilation support (--backend llvm)
- Semantics layer for interpreter→VM flow
- Tri-backend smoke tests
- Plugin-only registry mode

Bug fixes:
- Interpreter plugin box arithmetic operations
- Branch test returns incorrect values

Documentation:
- Phase 12 README.md updated with new plugin architecture
- Removed obsolete NYIR proposals
- Added LLVM test programs documentation

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 23:44:34 +09:00
fff9749f47 📚 Reorganize CLAUDE.md: slim down from 916 to 395 lines with proper doc links
- Keep essential information within 500 lines (now 395 lines)
- Maintain important syntax examples and development principles
- Move detailed information to appropriate docs files:
  - Development practices → docs/guides/development-practices.md
  - Testing guide → docs/guides/testing-guide.md
  - Claude issues → docs/tools/claude-issues.md
- Add proper links to all referenced documentation
- Balance between minimal entry point and practical usability
2025-08-31 06:22:48 +09:00