feat(phase12.7): 糖衣構文Phase 12.7-B完了 + 自律型AI開発システム制御機能

🚀 Phase 12.7-B: ChatGPT5糖衣構文(基本実装完了)
- パイプライン演算子(|>)実装
- セーフアクセス(?.)とデフォルト値(??)実装
- sugar gateによる段階的有効化機能
- 糖衣構文テストスイート追加

🤖 自律型AI開発システム改善
- codex-async-notify.sh: タスク制御指示追加
  - "下の箱を積み過ぎないように先に進んでください"
  - "フェーズが終わったと判断したら止まってください"
- プロセス数表示機能の改善(count_running_codex_display)
- 自動停止機能が正常動作(Phase 12.7-C前で停止確認)

📚 ドキュメント更新
- Paper 13: 自律型AI協調開発システムの革新性を文書化
- ANCP可逆マッピング仕様追加
- nyfmt PoC(フォーマッター)計画追加

🧱 箱理論の体現
- 74k行のコードベース(Phase 15で20k行を目指す)
- ANCP適用で最終的に6k行相当を狙う
- 世界最小の実用コンパイラへの道

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-09-05 05:16:21 +09:00
parent c45866073d
commit 19f775c34d
47 changed files with 2171 additions and 163 deletions

View File

@ -14,14 +14,16 @@ Phase 12.7は3つの革命的な改革の段階的実装です
- Lambda式fn文法
- フィールド型アテーションfield: TypeBox
### Phase 12.7-B: ChatGPT5糖衣構文🔄 実装中
- パイプライン演算子(|>
- セーフアクセス(?.)とデフォルト値(??
- デストラクチャリング({x,y}, [a,b,...]
- 増分代入(+=, -=, *=, /=
- 範囲演算子0..n
- 高階関数演算子(/:map, \:filter, //:reduce
- ラベル付き引数key:value
### Phase 12.7-B: ChatGPT5糖衣構文✅ 基本完了/拡張はゲート計画
- 基本P0・実装済み、ゲート可
- パイプライン演算子(`|>`
- セーフアクセス(`?.`)とデフォルト値(`??`
- 拡張P1・段階適用、設計/ドキュメント整備済み
- デストラクチャリング(`{x,y}`, `[a,b,...]`
- 増分代入(`+=, -=, *=, /=`
- 範囲演算子(`a .. b``Range(a,b)`
- 高階関数演算子(`/:` map, `\:` filter, `//` reduce
- ラベル付き引数(`key: value`
**🎯 重要な設計方針:**
- **使いたい人が使いたい糖衣構文を選択可能**
@ -33,6 +35,8 @@ Phase 12.7は3つの革命的な改革の段階的実装です
- 極限糖衣構文75%削減)
- 融合記法90%削減)
- 可逆フォーマッター完備
- 参考: `ancp-specs/ANCP-Reversible-Mapping-v1.md`12.7B subset の可逆化)
- nyfmt PoC: `docs/tools/nyfmt/NYFMT_POC_ROADMAP.md` / `tools/nyfmt_smoke.sh`
## 🎯 なぜPhase 12.7なのか?
@ -77,7 +81,7 @@ local double = fn(x) { x * 2 }
array.map(fn(x) { x * x })
```
### Phase 12.7-B: ChatGPT5糖衣構文実装予定
### Phase 12.7-B: ChatGPT5糖衣構文実装済みの例/拡張の草案
```nyash
# パイプライン演算子(|>
local result = data
@ -181,7 +185,7 @@ $NyashCompiler{compile(s){r s|>m.parse|>m.lower|>m.codegen}}
- ✅ Lambda式fn構文実装完了
- ✅ フィールド型アノテーション実装完了
### Phase 12.7-B: ChatGPT5糖衣構文🔄 実装中
### Phase 12.7-B: ChatGPT5糖衣構文✅ 基本完了/拡張はゲート計画
- 📅 パイプライン演算子(|>
- 📅 セーフアクセス(?.)とデフォルト値(??
- 📅 デストラクチャリング(パターン束縛)
@ -309,8 +313,9 @@ pub struct AncpTranscoder {
### Phase 12.7-B🔄 実装中)
#### Week 1-2: 基本演算子
- パイプライン演算子(|>
- セーフアクセス(?.)とデフォルト値(??
- 基本P0・実装済み、ゲート可
- パイプライン演算子(`|>`
- セーフアクセス(`?.`)とデフォルト値(`??`
- 増分代入演算子(+=, -=等)
#### Week 3-4: 高度な構文
@ -444,4 +449,4 @@ evens = numbers \: {$_%2==0} /: {$_*$_}
---
Phase 12.7は、Nyashを真のAI時代のプログラミング言語にする重要な一歩です。
Phase 12.7は、Nyashを真のAI時代のプログラミング言語にする重要な一歩です。

View File

@ -0,0 +1,61 @@
# ANCP v1 Reversible Mapping (P0 subset)
Status: Preview (12.7C P0). Scope is the sugar subset already implemented and gated in 12.7B.
Goals
- Provide a clear, reversible mapping between Nyash sugar and canonical forms.
- Make roundtrip (original → canonical → ANCP → canonical → original) predictable for the subset.
Gating
- Runtime sugar is gated by `NYASH_SYNTAX_SUGAR_LEVEL=basic|full`.
- ANCP tools/nyfmt remain PoC/docs only at this stage.
Subset Mappings
- Pipeline `|>`
- Nyash: `lhs |> f(a,b)` → Canonical: `f(lhs, a, b)`
- Nyash: `lhs |> obj.m(a)` → Canonical: `obj.m(lhs, a)`
- Roundtrip invariant: No change of call order or arity.
- Safe Access `?.`
- Nyash: `a?.b` → Canonical (peek): `peek a { null => null, else => a.b }`
- Nyash: `a?.m(x)` → Canonical: `peek a { null => null, else => a.m(x) }`
- Roundtrip invariant: No change of receivers/args; only the null guard appears.
- Default `??`
- Nyash: `a ?? b` → Canonical (peek): `peek a { null => b, else => a }`
- Roundtrip invariant: Both branches preserved asis.
- Range `..`
- Nyash: `a .. b` → Canonical: `Range(a, b)`
- Roundtrip invariant: Closed form preserved; no inclusive/exclusive change.
- Compound Assign `+=, -=, *=, /=`
- Nyash: `x += y` → Canonical: `x = x + y``x` は変数/フィールド)
- Roundtrip invariant: Operator identity preserved; left target identical.
Examples (Before / Canonical / RoundTrip)
1) Pipeline + Default
```
Before: data |> normalize() |> transform() ?? fallback
Canonical: peek transform(normalize(data)) { null => fallback, else => transform(normalize(data)) }
RoundTrip: data |> normalize() |> transform() ?? fallback
```
2) Safe Access Chain
```
Before: user?.profile?.name
Canonical: peek user { null => null, else => peek user.profile { null => null, else => user.profile.name } }
RoundTrip: user?.profile?.name
```
3) Range + Compound Assign
```
Before: i += 1; r = 1 .. 5
Canonical: i = i + 1; r = Range(1, 5)
RoundTrip: i += 1; r = 1 .. 5
```
Notes
- Precise precedence handling is left to the parser; mappings assume already parsed trees.
- Full ANCP compact tokens will be documented in a separate spec revision.

View File

@ -0,0 +1,43 @@
Phase 12.7-B 基本糖衣構文・最小導入 予定
目的
- セルフホスティング前に、安全な最小糖衣basicを段階導入。
- 挙動は正規ASTへ正規化してから既存パイプラインに渡す可逆前提
範囲basic 初期スコープ)
- 追加トークン: `|>`, `?.`, `??`, `+=`, `-=`, `*=`, `/=`, `..`
- 正規化ルール:
- `x |> f` → `f(x)`
- `x?.y` → `tmp=x; tmp!=null ? tmp.y : null`
- `x ?? y` → `x!=null ? x : y`
- `a += b` 等 → `a = a + b` 等
- `a..b` → RangeArrayBox生成に正規化最小仕様
- 高階演算子(`/:`, `\:`, `//`)は衝突回避のため当面見送り
実装タスクWeek 1
1) tokenizer: 2文字演算子を長い順優先で追加`??`, `?.`, `|>`, `+=`, …, `..`
2) parser/sugar.rs: `apply_sugar(ast, &SugarConfig)` の骨組み上記4種の正規化
3) config: `nyash.toml [syntax] sugar_level=none|basic|full` 読み込み→`SugarConfig`
4) パーサ統合: `NyashParser` → 生成後に `apply_sugar` を呼ぶbasicのみON
5) テスト: `tests/sugar_basic_test.rs` と `tools/smoke_vm_jit.sh` に `NYASH_SYNTAX_SUGAR_LEVEL=basic`
6) ドキュメント: phase-12.7 README に basic 実装済みの注記
実装タスクWeek 2
7) 分割代入(最小): Map/Array への展開のみ、正規ASTへ分解
8) ラベル付き引数: ひとまず MapBox 経由へ正規化(将来のキーワード引数に備える)
9) ANCP トランスコーダ(別ツール)雛形: encode/decode、文字列/コメント保護、位置マッピング
安全策
- 既定: `sugar_level=none`(明示のみ)。開発では `basic` を個別ON。
- 可逆性: `SpanMapping` を保持(エラー位置を元コードへ戻す)
- E2E 影響なし: 正規ASTに落としてから既存実装へ渡す
完了条件basic
- `|>`, `?.`, `??`, 複合代入、`..` の正規化が安定
- ON/OFF で `tools/smoke_vm_jit.sh` が通過
- sugar 基本テストが通る(正規実行結果が一致)
注意
- `//` はコメントと衝突するため、初期スコープでは採用しない
- パイプラインのメソッド呼出し規約(`data |> me.f` など)はドキュメントで明示