Files
hakorune/CODEX_QUESTION.md
nyash-codex 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

4.5 KiB
Raw Blame History

Codex向け質問 - Phase 15.5後のテスト戦略

📋 背景

Phase 15.5でCore Box完全削除を実施し、すべてのBoxをプラグイン化しました。その結果

  • nyash.tomlのパス修正完了13箇所
  • プラグインは正常にロード(.soファイル20個存在
  • 基本的な算術演算・制御構文は動作
  • StringBox/IntegerBoxのメソッドが動作しない

🔍 現在の問題

StringBoxプラグインの状況

local s = new StringBox("Hello")  # ← オブジェクト生成OKハンドル返却
print(s)                          # ← 空文字列toString失敗
s.length()                        # ← 0を返す内部データなし
s.toString()                      # ← 空文字列を返す
s.get()                          # ← 空文字列を返す

調査済み事項

  1. プラグインは正常にロードplugin-testerで確認
  2. nyash_plugin_invokeは実装済みlegacy v1 ABI
  3. method_id衝突を修正済み0-3 → 4+に変更)
  4. 通常の文字列リテラルは動作する
  5. 算術演算は問題なし

🔬 根本原因Codex調査結果 - 2025-09-24

実装レベルの具体的問題箇所を特定済み:

  1. string_invoke_idM_BIRTH分岐がない

    • plugins/nyash-string-plugin/src/lib.rsstring_invoke_idにM_BIRTH分岐が無く
    • new StringBox("test")で生成されたIDがINSTマップに登録されない
    • .length()呼び出しでE_HANDLEが返る
  2. string_resolveがtoStringを未マッピング

    • 同ファイルのstring_resolve"toString"M_TO_UTF8にマッピングしていない
    • .toString()は未知メソッド扱いになり空文字列/エラーでフォールバック
  3. IntegerBoxも同様の問題

    • plugins/nyash-integer-plugin/src/lib.rsでもM_BIRTH/M_FINIが未実装
    • 値を保持できず.get()/.set()が失敗

🎯 質問

1. 実装修正の優先度は?

  • string_invoke_idinteger_invoke_idM_BIRTH/M_FINI分岐を復元するのが最優先か?
  • それともTypeBox共通レイヤーでフォールバック処理を追加すべきか

2. toStringメソッドの実装方針

  • .toString()toUtf8のエイリアスにすべきか?
  • 新たなメソッドIDをnyash_box.tomlへ追加してVMに通知すべきか

3. テスト戦略の方向性

現状でStringBox/IntegerBoxが動作しない中で

  • A案: プラグインメソッド修正を優先M_BIRTH実装
  • B案: 基本機能(算術・制御)のテストを先に充実
  • C案: 別のBoxプラグインFileBox等でテスト

どの方向性が効率的でしょうか?

4. 既存テストの扱い

  • tools/smokes/v2/profiles/quick/boxesのStringBoxケースを一時的に外すか
  • 失敗を許容したまま調査用に残すか?

🔄 再現手順

最小再現コード

# test_stringbox.hako
local s = new StringBox("Hello World")
print("StringBox created")
print(s)  # 期待: "Hello World", 実際: ""
local len = s.length()
print("Length: " + len)  # 期待: 11, 実際: 0

実行コマンド

# プラグインロード確認
./tools/plugin-tester/target/release/plugin-tester check --config nyash.toml

# テスト実行
NYASH_ENTRY_ALLOW_TOPLEVEL_MAIN=1 ./target/release/hakorune test_stringbox.hako

デバッグ情報収集

# 詳細ログ
NYASH_CLI_VERBOSE=1 ./target/release/hakorune test_stringbox.hako

# MIRダンプ確認
./target/release/hakorune --dump-mir test_stringbox.hako

# 具体的な問題箇所の確認
rg "M_BIRTH" plugins/nyash-string-plugin/src/lib.rs  # 該当箇所を特定

📁 関連ファイル

  • nyash.toml - プラグイン設定method_id修正済み
  • plugins/nyash-string-plugin/src/lib.rs - StringBoxプラグイン実装L23-L113, L205-L280
  • plugins/nyash-integer-plugin/src/lib.rs - IntegerBoxプラグイン実装
  • tools/smokes/v2/ - 新スモークテストシステム
  • src/box_factory/plugin.rs - プラグインロード実装
  • src/runtime/plugin_loader_v2/enabled/loader.rs - create_box → nyash_plugin_invoke_v2_shim
  • src/mir/builder/builder_calls.rs - TypeBox v2 resolve実装問題箇所

🚀 期待する回答

  1. M_BIRTH/M_FINI実装の具体的な修正方法
  2. 効率的なテスト戦略の提案
  3. プラグインメソッド呼び出しのデバッグ手法

よろしくお願いします!