🚀 Phase 10.11: Everything is Plugin革命完了!
主な変更: - ConsoleBox/MathBoxプラグイン実装・登録完了 - nyash_box.toml 2ファイルシステム設計(中央レジストリ+個別仕様書) - 全プラグインにnyash_box.tomlテンプレート追加 - プラグイン優先機能(NYASH_USE_PLUGIN_BUILTINS=1)文書化 - ビルトインBox削除準備(ChatGPT5実装中) - ネイティブビルドデモ追加(Linux/Windows動作確認済み) Everything is Box → Everything is Plugin への歴史的転換! 開発20日目にしてビルトインBox全削除という革命的決定。 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -397,3 +397,16 @@ bash tools/build_aot.sh examples/aot_min_string_len.nyash -o app
|
||||
- 状態確認: `git status` / `git log --oneline -3` / `cargo check`
|
||||
- スモーク: `bash tools/smoke_phase_10_10.sh`
|
||||
- 次の一手: core_hostcall → core_ops の順に分割、毎回ビルド/スモークで確認
|
||||
|
||||
---
|
||||
|
||||
### 新規フェーズ(提案): Phase 10.11 Builtins → Plugins 移行
|
||||
- 目的: 内蔵Box経路を段階的に廃止し、プラグイン/ユーザーBoxに一本化する(不具合の温床を解消)
|
||||
- 現在の足場(済):
|
||||
- ConsoleBox コンストラクタをレジストリ委譲(プラグイン優先)に変更
|
||||
- `NYASH_DISABLE_BUILTINS=1` でビルトインFactory登録を抑止可能
|
||||
- 設計ドキュメント: docs/development/roadmap/phases/phase-10.11-builtins-to-plugins.md
|
||||
- 次ステップ:
|
||||
- 非基本コンストラクタの委譲徹底(Math/Random/Sound/Debugなど)
|
||||
- 主要ビルトインの plugin 化(nyash_box.toml 整備)
|
||||
- CIに `NYASH_USE_PLUGIN_BUILTINS=1` / `NYASH_PLUGIN_OVERRIDE_TYPES` のスモークを追加
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
# Phase 10.11: Builtins → Plugins Migration
|
||||
|
||||
## Goals
|
||||
- Remove builtin Box implementations from execution paths (Interpreter/VM/JIT) to avoid divergence and double sources of truth.
|
||||
- Provide all functionality via plugins (BID-FFI v1) and/or user-defined boxes.
|
||||
- Keep backward compatibility guarded behind env flags until migration completes.
|
||||
|
||||
## Rationale
|
||||
- Conflicts like ConsoleBox builtin vs plugin cause unexpected behavior.
|
||||
- Native build (AOT/EXE) path benefits from uniform plugin boundary.
|
||||
- One registry, one implementation per Box: simpler, safer.
|
||||
|
||||
## Plan (Incremental)
|
||||
1) Disable Switch (Now)
|
||||
- Add `NYASH_DISABLE_BUILTINS=1` to skip registering builtin box factory.
|
||||
- Keep off by default; use in CI lanes and targeted tests.
|
||||
|
||||
2) Constructor Delegation (Now → Next)
|
||||
- Ensure all constructors go through the unified registry, not direct builtin instantiation.
|
||||
- Done: ConsoleBox; Next: remaining non-basic constructors.
|
||||
|
||||
3) Override Policy (Ongoing)
|
||||
- Use `NYASH_USE_PLUGIN_BUILTINS=1` + `NYASH_PLUGIN_OVERRIDE_TYPES` to prefer plugins for selected types.
|
||||
- Grow the allowlist as plugins become available.
|
||||
|
||||
4) Plugin Coverage (Milestones)
|
||||
- ConsoleBox (stdout) — done
|
||||
- Array/Map/String/Integer — in place
|
||||
- File/Net/Python — in place
|
||||
- Math/Time/etc. — add `nyash_box.toml` and minimal plugins
|
||||
|
||||
5) Remove Builtins (Final)
|
||||
- Remove builtin factory or move into separate optional crate for legacy runs.
|
||||
- Update docs, examples, and CI to plugin-only.
|
||||
|
||||
## Acceptance Criteria
|
||||
- `NYASH_DISABLE_BUILTINS=1` + plugin set → examples run green (VM path).
|
||||
- No direct builtins in interpreter constructors (registry only).
|
||||
- JIT/AOT compile from MIR uses only plugin invoke shims for Box methods.
|
||||
|
||||
## How to Test
|
||||
```bash
|
||||
# Strict plugin preference + disable builtins
|
||||
export NYASH_USE_PLUGIN_BUILTINS=1
|
||||
export NYASH_PLUGIN_OVERRIDE_TYPES="ArrayBox,MapBox,ConsoleBox,StringBox,IntegerBox"
|
||||
export NYASH_DISABLE_BUILTINS=1
|
||||
|
||||
cargo build --release --features cranelift-jit
|
||||
./target/release/nyash --backend vm examples/console_demo.nyash
|
||||
```
|
||||
|
||||
## Notes
|
||||
- Temporary breakages expected when some builtin-only boxes remain. Use the override allowlist tactically.
|
||||
- Keep `[libraries]` and `[plugins]` configured to ensure provider discovery.
|
||||
@ -125,6 +125,25 @@ cargo build --release
|
||||
./target/release/plugin-tester check path/to/your/plugin.so
|
||||
```
|
||||
|
||||
### 5. **nyash_box.toml テンプレ & スモーク** 🆕
|
||||
- テンプレート: `docs/reference/plugin-system/nyash_box.toml.template`
|
||||
- スモーク実行(VM・厳格チェックON):
|
||||
```bash
|
||||
bash tools/smoke_plugins.sh
|
||||
```
|
||||
- 実行内容: Python デモと Integer デモを `NYASH_PLUGIN_STRICT=1` で起動し、nyash_box.toml 経路のロードと実行を確認
|
||||
- 事前条件: `cargo build --release --features cranelift-jit` 済み、各プラグインも release ビルド済み
|
||||
|
||||
### 6. **プラグイン優先(ビルトイン上書き)設定** 🆕
|
||||
- 既定では、ビルトインの実装が優先されます(安全第一)。
|
||||
- プラグインで置き換えたい型(ConsoleBox など)がある場合は環境変数で上書き可能:
|
||||
```bash
|
||||
export NYASH_USE_PLUGIN_BUILTINS=1
|
||||
export NYASH_PLUGIN_OVERRIDE_TYPES="ArrayBox,MapBox,ConsoleBox"
|
||||
```
|
||||
- 上記により、`new ConsoleBox()` などの生成がプラグイン経路に切替わります。
|
||||
- 後方互換のため `[libraries]` にも対象プラグインを登録しておくと、解決の一貫性が高まります。
|
||||
|
||||
## 🔧 For Nyash Core Developers
|
||||
|
||||
### Implementation Files
|
||||
|
||||
31
docs/reference/plugin-system/nyash_box.toml.template
Normal file
31
docs/reference/plugin-system/nyash_box.toml.template
Normal file
@ -0,0 +1,31 @@
|
||||
[box]
|
||||
name = "<Your Plugin Name>"
|
||||
version = "0.1.0"
|
||||
description = "<Short description>"
|
||||
author = "<Your Name>"
|
||||
|
||||
[provides]
|
||||
boxes = ["<BoxTypeA>", "<BoxTypeB>"]
|
||||
|
||||
[<BoxTypeA>]
|
||||
type_id = <u32>
|
||||
|
||||
[<BoxTypeA>.lifecycle]
|
||||
birth = { id = 0 }
|
||||
fini = { id = 4294967295 } # optional
|
||||
|
||||
[<BoxTypeA>.methods.<methodName>]
|
||||
id = <u32>
|
||||
args = [ { name = "<arg>", type = "<string|i64|box|varargs|dict>" } ] # optional
|
||||
returns = { type = "<void|string|i64|box>", error = "string" } # optional
|
||||
returns_result = <true|false> # optional: Ok/Err(ResultBox)に正規化
|
||||
|
||||
[implementation]
|
||||
ffi_version = 1
|
||||
thread_safe = <true|false>
|
||||
|
||||
[artifacts]
|
||||
windows = "target/x86_64-pc-windows-msvc/release/<your>.dll"
|
||||
linux = "target/release/lib<your>.so"
|
||||
macos = "target/release/lib<your>.dylib"
|
||||
|
||||
Reference in New Issue
Block a user