NEPLg2.0 self-host 実行計画

最終更新: 2026-04-26


1. 目的

この文書は self_host_plan.md の実装を進めるための運用計画である。
仕様・構造・成功条件は self_host_plan.md を正とし、この文書では branch、commit、merge、検証、Issue 更新の単位を固定する。

NEPLg2.0 self-host は長期作業になるため、作業途中の大きな branch を持たない。
main を常に統合済みの基準点にし、1 branch は 1 checkpoint に対応させる。


2. 基本規則

  • 作業開始時は必ず main に戻り、直前作業 branch がある場合は main へ fast-forward merge してから新しい branch を作る。
  • main へ直接 commit しない。例外は fast-forward merge のみ。
  • 1 branch は 1 つの主目的と 1 つ以上の明示 Issue に対応させる。
  • branch 内の一時的なテスト悪化は許容するが、commit と main merge は green checkpoint のみとする。
  • 各 commit 後に doc/progress_report_template.md の形式で Discord へ報告する。
  • plan.md は変更しない。計画との差異、作業結果、保留判断は note.n.md に書く。
  • 未着手作業は todo.md に残し、完了したら削除または次の未着手に置き換える。
  • Issue の正は issues/items/*.md とし、旧 doc/review20260425/ は更新しない。
  • Rust 側コンパイラ修正と self-host 実装は同じ main を基準に統合する。
  • self-host 実装中に Rust 側の不具合を見つけた場合は、self-host 側の回避実装で隠さず Issue として提出する。

3. Branch 命名

種別形式用途
self-host compilerselfhost/s<stage>-<topic>selfhost/s0-source-treestdlib/neplg2/ 本体
stdlib interfacestdlib/<issue-topic>stdlib/fs-write-apistd/fsstd/stdiostd/env など
test / harnessnodesrc/<topic>nodesrc/selfhost-parity-runnerNode.js 側の検証支援
CI / workflowci/<topic>ci/selfhost-smokeGitHub Actions や test job
docs onlydocs/<topic>docs/neplg2-selfhost-workflow計画、README、記録
regression fixfix/<issue-id-short>-<topic>fix/rv-core-007-codegen-diagnostic既存不具合の修正
Rust compilerrust/<issue-id-short>-<topic>rust/iss-core-parser-spannepl-core / nepl-cli 側の修正

<topic> は 2-5 語の kebab-case にする。
stage をまたぐ branch 名にしない。たとえば lexer と module loader を同時に進める branch は作らず、selfhost/s1-lexerselfhost/s2-module-vfs に分ける。


4. Branch 手順

  1. git switch main
  2. 直前作業 branch が未 merge なら git merge --ff-only <branch>
  3. git status --short --branch で clean を確認する
  4. git switch -c <branch>
  5. 実装、doc、Issue、todo、note を更新する
  6. focused test を先に通し、最後に共通検証を通す
  7. commit する
  8. commit ごとに Discord へ報告する
  9. git switch main
  10. git merge --ff-only <branch>

branch は merge 後に再利用しない。
同じ領域の続きでも、次の checkpoint は新しい branch にする。


5. Rust 側 main 変更の取り込み

Rust 側コンパイラの修正は self-host の参照実装を変えるため、常に main を経由して取り込む。
self-host branch から Rust 側修正 branch へ直接 merge しない。

5.1 原則

  • Rust 側修正は rust/<issue-id-short>-<topic> または fix/<issue-id-short>-<topic> branch で行う。
  • Rust 側修正 branch は検証後に main へ merge する。
  • self-host branch は main に入った Rust 側修正だけを取り込む。
  • self-host branch が参照する Rust 挙動は、commit 時点の main の挙動として note.n.md に記録する。
  • Rust 側修正により self-host parity fixture の期待値が変わる場合は、Rust 修正 commit 側で fixture と doc を更新する。

5.2 self-host branch が未 commit の場合

  1. 変更中ファイルを確認する。
  2. 未完了作業が小さければ一度 commit 可能な checkpoint へ縮める。
  3. checkpoint にできない場合は作業を継続せず、必要に応じて note.n.md に中断理由を残す。
  4. main へ戻り、Rust 側修正を merge する。
  5. 新しい self-host branch を main から作り直す。

未 commit の大きな作業に Rust 側変更を重ねない。

5.3 self-host branch に commit がある場合

  1. self-host branch の worktree を clean にする。
  2. main に Rust 側修正を merge する。
  3. self-host branch に戻る。
  4. git rebase main で self-host commit を新しい main の上へ移す。
  5. conflict が出た場合は、Rust 側の修正意図を優先して self-host 側の fixture / doc / implementation を合わせる。
  6. rebase 後に focused test と共通検証をすべて再実行する。
  7. main へは git merge --ff-only <selfhost-branch> で入れる。

git merge main による merge commit は使わない。
長期 branch を避け、rebase conflict が大きくなる前に checkpoint を切る。

5.4 Rust 側修正が self-host を壊した場合

Rust 側修正後に self-host fixture が失敗した場合は、次の順で判断する。

判定対応
Rust 側の挙動修正が正しいself-host 側の期待値と実装を更新する
Rust 側の修正が regressionRust 側 Issue を open に戻す、または新 Issue を作り、self-host branch は merge しない
仕様が未確定doc/neplg2/ に決定待ちを記録し、self-host 実装を進めない
self-host 側の仮実装が古いself-host branch 内で修正し、note に Rust 側 commit との差異を記録する

6. Rust 側 Issue 提出規則

self-host 実装中に見つかった問題は、Rust 側へ提出する前に分類する。

分類Issue areaBranch進め方
Rust compiler の明確な bugcore または clirust/<issue-id-short>-<topic>Rust 側を先に直して main へ merge
Rust compiler の panic / diagnostic 不備corerust/<issue-id-short>-diagnosticdiagnostic 化と regression test を追加
Rust 挙動が仕様未記載core または docdocs/<topic>rust/<topic>仕様決定を doc に残してから実装
self-host だけの実装不足selfhostselfhost/s<stage>-<topic>Rust 側へ提出しない
stdlib interface 不足stdlib または selfhoststdlib/<topic>public API と doctest を先に整備
test harness 不足cli または selfhostnodesrc/<topic>fixture / JSON / runner を追加

6.1 提出に必須の情報

Rust 側 Issue を作る場合は、issues/items/*.md に次を必ず書く。

  • self-host の stage
  • 最小再現 .nepl または .n.md
  • Rust 側の実際の結果
  • 期待する結果
  • 影響する parity 条件
  • suspect file が分かる場合は nepl-core/src/... または nepl-cli/src/...
  • self-host 側で回避しない理由
  • 検証予定

node nodesrc/issues.js new で作成し、手で本文を補足する。
作成後は node nodesrc/issues.js indexnode nodesrc/issues.js check を通す。

6.2 blocker の扱い

Rust 側 bug が self-host の stage 完了条件を阻害する場合、self-host branch は次のどちらかにする。

  • commit 可能な doc / fixture / Issue 提出だけを commit し、実装 commit は作らない。
  • 実装途中なら checkpoint にせず中断し、Rust 修正 branch を先に作る。

blocker を避けるための self-host 限定 workaround は作らない。
workaround が必要に見える場合は、Rust 側の仕様または diagnostic を先に決める。

6.3 Rust 修正 commit の条件

Rust 側修正 commit は次を満たす。

  • 既存 Rust compiler test、nodesrc test、または .n.md doctest のいずれかに regression test がある。
  • self-host parity に関係する場合は、期待 JSON または fixture を同じ commit で更新する。
  • Issue の statusresolvedupdated を更新する。
  • note.n.md に self-host への影響を書く。
  • 共通検証を通す。

Rust 側修正が大きい場合は、原因特定 commit、regression test commit、実装修正 commit に分ける。
ただし、main へ merge する時点では全 commit が green checkpoint でなければならない。

6.4 self-host branch への復帰

Rust 修正を main に merge した後、self-host 作業へ戻る手順は次の通り。

  1. git switch main
  2. git merge --ff-only <rust-branch>
  3. git switch -c selfhost/s<stage>-<topic> または既存 branch を rebase
  4. Rust 修正で変わった fixture を確認する
  5. focused self-host test を実行する
  6. self-host commit を続行する

7. Commit 単位

commit は「review 可能で、単独で検証でき、戻す場合も意味が明確な単位」にする。
作業量ではなく、境界と検証可能性で切る。

種別1 commit に含めるもの含めないもの
docs checkpoint計画、README、note、todo、Issue metadata実装コード
source tree scaffold空でない module skeleton、実行可能な最小 doctest、READMEparser や backend の実装
stdlib interfacepublic API、target 実装、doctest、関連 Issue 更新compiler core の移植
harnessnodesrc tool、fixture、JSON 出力、doc言語仕様変更
compiler data model型・AST・HIR などの表現と unit doctestparser/checker の広範囲実装
compiler pass slice1 pass の小さな機能、parity fixture、diagnostic次 stage の実装
Rust compiler fix原因を示す regression test、nepl-core / nepl-cli 修正、self-host parity への影響記録self-host 側 workaround
issue close修正、回帰テスト、Issue status/resolved/updated 更新、note未検証の追加修正

1 commit が 500 行を超える場合でも、生成 index や Issue 移行のように機械的で意味が 1 つなら許容する。
手書き実装が 500 行を超える場合は、まず data model、pure helper、public API、integration の単位へ分割できないか確認する。


8. Commit Message

基本形は次の通りにする。

<scope>: <summary>

推奨 scope:

scope対象
docs(neplg2)NEPLg2.0 self-host 計画
selfhost(s0)stdlib/neplg2/ S0
selfhost(s1)lexer / parser
selfhost(s2)module loader
selfhost(s3)type / check
selfhost(s4)HIR / resource / mono
selfhost(s5)WASM backend
selfhost(s6)CLI
selfhost(s7)bootstrap comparison
stdlib(fs)filesystem interface
stdlib(stdio)stdio / stderr interface
nodesrc(selfhost)self-host test harness
ci(selfhost)self-host CI
rust(core)nepl-core の参照実装修正
rust(cli)nepl-cli の参照実装修正

例:

selfhost(s0): add compiler source tree skeleton
stdlib(fs): add result-returning write APIs
nodesrc(selfhost): add lexer parity runner
rust(core): fix parser span parity diagnostic

commit 本文が必要な場合は、主 Issue と検証を短く書く。

Issue: ISS-20260426T010001Z-STDFS-WRITE-B7C4D923
Verify: node nodesrc/issues.js check; trunk build; playground editor 13/13

9. 共通検証

commit 前の共通検証は次を必須にする。

node nodesrc/issues.js check
git diff --cached --check
trunk build
node nodesrc/cli.js -i tests/playground_editor --playground-editor-tests -o json=tmp/playground-editor-selfhost.json

JSON 出力は caseCountpassedCountfailedCount を確認する。
trunk build の既存 warning は記録のみとし、この作業で増えた warning は原因を確認する。

docs only の場合も、web/compiler artifact と Node CLI の前提を崩していない確認として trunk build と playground editor test を実行する。


10. 追加検証

作業種別追加検証
issues/ 更新node nodesrc/issues.js indexnode nodesrc/issues.js check
Markdown link 更新関連 doc の link existence check
stdlib/neplg2/ 更新node nodesrc/tests.js -i stdlib/neplg2 --no-tree -o tmp/selfhost-stdlib.json -j 2
std/fs 更新read/write/invalid path の doctest または integration test
std/stdio 更新stdout/stderr split と error propagation の test
lexer/parser 更新Rust 実装との token / AST JSON parity
module loader 更新import alias、open import、cycle、missing file
WASM backend 更新binary section unit test と smoke execution
CLI 更新argv table test、exit code、diagnostic JSON、artifact output

追加検証で失敗を見つけた場合は、原因が今回の作業範囲にあるかを切り分ける。
今回の範囲外の既存不具合なら Issue を作り、今回の commit へ混ぜない。


11. Stage 別 checkpoint

S0: Source tree

順序Branch主 IssueCommit 単位完了条件
1selfhost/s0-source-treeISS-20260426T010000Z-SELFHOST-SOURCE-TREE-A1E5F24Cstdlib/neplg2/ root、README、top-level module skeletonfocused doctest が収集される
2selfhost/s0-infra-span-diag同上infra/span.nepldiag.neploutcome.neplspan / diagnostic doctest
3nodesrc/selfhost-focused-tests同上self-host focused test command の補助stdlib/neplg2 の test 結果 JSON

S1: Lexer / parser

順序BranchCommit 単位完了条件
1selfhost/s1-source-textbyte offset、line map、UTF-8 前提の source textline/column doctest
2selfhost/s1-token-modelToken / TokenKind / keyword tabletoken model doctest
3selfhost/s1-lexer-basicliteral、identifier、operator、commentsimple token parity
4selfhost/s1-lexer-indent#indent と offside ruleindent fixture parity
5selfhost/s1-ast-modelmodule / item / expr / typeexpr / pattern ASTAST construction doctest
6selfhost/s1-parser-itemsimport / fn / let / struct / enumitem parser parity
7selfhost/s1-parser-exprcall、match、if、block、type annotationexpr parser parity

S2: Module loader

順序BranchCommit 単位完了条件
1selfhost/s2-vfs-modelVirtualFileSystem と logical pathpure VFS doctest
2selfhost/s2-import-specimport spec 表現と parser 接続import clause fixture
3selfhost/s2-module-graphgraph、cycle detection、missing module diagnosticcycle / missing test
4selfhost/s2-stdlib-mapstdlib root と user root の解決stdlib import fixture

S3: Type / check

順序BranchCommit 単位完了条件
1selfhost/s3-type-arenaTypeId、TypeKind、arena、substtype arena doctest
2selfhost/s3-unifyunify、occurs check、rollback 境界unify fixture
3selfhost/s3-resolve-scopeDefId、scope、hoist、name resolverscope parity
4selfhost/s3-expr-reduceNEPLg2.0 reduce_calls の移植call reduction parity
5selfhost/s3-overloadoverload candidate と checkpointoverload fixture
6selfhost/s3-traits-effectstrait capability、Copy/Clone/Drop、effectfocused compiler fixture

S4: HIR / resource / mono

順序BranchCommit 単位完了条件
1selfhost/s4-hir-modelHIR data model と lower skeletonHIR construction doctest
2selfhost/s4-hir-walkiterative traversal helperdeep HIR traversal test
3selfhost/s4-move-statemove state machinemove fixture parity
4selfhost/s4-borrow-dropborrow / drop plan / branch mergeborrow/drop fixture parity
5selfhost/s4-mono-instanceinstance cache と name manglingmono fixture

S5: WASM backend

順序BranchCommit 単位完了条件
1selfhost/s5-byte-builderByteBuilder API 使用方針byte builder doctest
2selfhost/s5-leb128-sectionLEB128 と section writerknown byte output
3selfhost/s5-wasm-layoutvalue layout、locals、function typelayout fixture
4selfhost/s5-wasm-smoke-i32println_i32 / function callwasm smoke
5selfhost/s5-wasm-aggregatestruct / enum / ResultRust backend parity

S6: CLI

順序BranchCommit 単位完了条件
1selfhost/s6-argspure argv parserargv table test
2selfhost/s6-file-iofs read/write bridgeartifact output test
3selfhost/s6-reporterstderr human diagnostic と JSONstdout/stderr split
4selfhost/s6-drivercompile result、exit code、artifact writeCLI smoke

S7: Bootstrap comparison

順序BranchCommit 単位完了条件
1nodesrc/selfhost-bootstrap-runnerPass A / Pass B 実行 toolcomparison JSON
2selfhost/s7-trace-jsonstage trace JSON差分切り分け可能
3ci/selfhost-bootstrap-smokeCI smoke jobbootstrap smoke green
4ci/selfhost-bootstrap-finalfinal comparison jobartifact / diagnostic / exit code parity

12. Issue 更新ルール

  • 実装 branch の開始時点で主 Issue を決める。
  • 作業中に不足 interface や別原因を見つけた場合は、実装前に node nodesrc/issues.js new で Issue を作る。
  • Issue を修正した commit では、同じ commit に statusresolvedupdated、検証結果を含める。
  • Issue を完全に閉じない準備 commit では status: investigating までに留める。
  • RV-... を参照する場合は、新 ID と legacy_id の両方を commit 本文か note に残す。

13. Discord 報告

各 commit 後に次を必ず含める。

  • commit hash
  • branch 名
  • 主 Issue
  • 直近の改良
  • これからする内容
  • 検証結果

複数 commit を同じ branch に作る場合も、commit ごとに報告する。
報告後に main へ merge した場合、merge が fast-forward なら追加報告は不要とする。


14. 次の着手順

  1. selfhost/s0-source-tree
  2. selfhost/s0-infra-span-diag
  3. nodesrc/selfhost-focused-tests
  4. stdlib/fs-write-api
  5. stdlib/fs-dirlist-api
  6. stdlib/stdio-result-stderr
  7. stdlib/text-utf8-validation
  8. selfhost/s1-source-text
  9. selfhost/s1-token-model
  10. selfhost/s1-lexer-basic

I/O interface は lexer/parser と並行したい誘惑があるが、CLI と bootstrap comparison の根になるため、S1 の途中までに必ず片付ける。

On this page