Skip to content

Commit d1ba099

Browse files
makinzmclaude
andauthored
feat: allow_call_patterns 全レイヤー開放 + multi-file main fixture (#78)
* [test] multi-file main layer + allow_call_patterns on non-main layer because of 現実のプロジェクトパターン不足 - rust_multifile_main fixture: src/main.rs + src/runner.rs を main レイヤーに含む - 正常系: 両ファイルが main レイヤーとして認識される - 失敗系: runner.rs の dependency violation 検出 - 失敗系: runner.rs への allow_call_patterns 適用 - 失敗系: usecase レイヤーでの allow_call_patterns 違反検出 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * [refactor] allow_call_patterns 全レイヤー開放 + CI dogfooding + docs更新 because of main限定の制約が不要 - spec.md: main限定の記述を削除、全レイヤーで定義可能と明記 - website docs (ja/en): Aside caution を削除、全レイヤー対応の説明に変更 - AGENTS.md: 同上 - README.md: allow_call_patterns の説明を更新 - docs/TODO.md: 実装状況サマリー更新 - ci.yml: rust_multifile_main fixture の dogfooding ステップ追加 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * [refactor] timeline 更新 because of PR レビュー用タイムライン Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e421ff7 commit d1ba099

File tree

20 files changed

+494
-17
lines changed

20 files changed

+494
-17
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ jobs:
150150
- name: Self-check — YAML fixture (tests/fixtures/yaml_sample)
151151
working-directory: tests/fixtures/yaml_sample
152152
run: ${{ github.workspace }}/target/release/mille check
153+
- name: Self-check — Rust multi-file main fixture (tests/fixtures/rust_multifile_main)
154+
working-directory: tests/fixtures/rust_multifile_main
155+
run: ${{ github.workspace }}/target/release/mille check
153156

154157
# ------------------------------------------------------------------ #
155158
# 3b. Dogfooding-python — maturin build → pytest + mille check #

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TODO.md を書く段階でこの 4 点を明示的にタスクとして含める
4949

5050
**パブリック API 変更時**: `packages/` 以下の全ラッパーも同コミットまたは直後に更新。`grep -r "変更した関数名"` で全呼び出し箇所を確認してから push。
5151

52-
**allow_call_patterns**: `main` レイヤーにのみ定義可。他レイヤーに書くと設定エラー
52+
**allow_call_patterns**: 任意のレイヤーに定義可。依存先レイヤーのメソッド呼び出しを制限する
5353

5454
**実装漏れ確認**: PR完成前に spec.md の全フィールドが動作しているか確認。「構造体にフィールドはあるが動作していない」漏れは PR 説明の注意事項に明記し TODO 番号を記録。
5555

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ One TOML config. Rust-powered. CI-ready. Supports multiple languages from a sing
1919
|---|---|
2020
| `dependency_mode` | Layer dependency rules — control which layers can import from which |
2121
| `external_mode` | External library rules — restrict third-party package usage per layer |
22-
| `allow_call_patterns` | DI method call rules — limit which methods may be called on injected types |
22+
| `allow_call_patterns` | Method call rules — limit which methods may be called on any layer's types |
2323
| `name_deny` | Naming convention rules — forbid infrastructure keywords in domain/usecase |
2424

2525
## Install
@@ -476,7 +476,7 @@ name_deny_ignore = ["**/test_*.rs", "tests/**"] # exclude test files from namin
476476

477477
### `[[layers.allow_call_patterns]]`
478478

479-
Restricts which methods may be called on a given layer's types. Only valid on the `main` layer (or equivalent DI entrypoint).
479+
Restricts which methods may be called on a given layer's types. Can be defined on any layer.
480480

481481
| Key | Description |
482482
|---|---|

docs/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
現在の `mille check` は以下を正常に動作させています:
1111
- ✅ 内部レイヤー依存チェック (`dependency_mode`)
1212
- ✅ 外部ライブラリ依存チェック (`external_mode`)
13-
-DIエントリーポイントのメソッド呼び出しチェック (`allow_call_patterns`)
13+
-メソッド呼び出しチェック (`allow_call_patterns`) — 全レイヤーで定義可能
1414
- ✅ Rust / Go / TypeScript / JavaScript / Python / Java / Kotlin / PHP サポート
1515
-`[resolve.typescript]` tsconfig.json paths エイリアス解決
1616
- ✅ cargo / npm(WASM) / go install / pip パッケージ配布

spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ opt-in / opt-outモデルの詳細は [セクション3](#3-opt-in--opt-out-モ
5050

5151
### 2-3. メソッド呼び出しチェック
5252

53-
DI組み立て以外の目的でinfrastructureのメソッドを直接呼び出すことを禁止する
54-
55-
`allow_call_patterns` は他のレイヤーに記述した場合は設定エラーとなる
53+
任意のレイヤーにおいて、依存先レイヤーのメソッド呼び出しを制限する
54+
典型的な用途は DI 組み立てレイヤー(main 等)で infrastructure のファクトリメソッドだけを許可するケースだが、
55+
usecase から domain のメソッドを制限するなど、どのレイヤーにも設定できる
5656

5757
```toml
5858
[[layers]]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# PR#78: allow_call_patterns 全レイヤー開放 + multi-file main fixture
2+
3+
## 背景
4+
5+
1. `allow_call_patterns` が spec/docs で「mainレイヤーのみ」と記載されているが、コード上は制約なし → ドキュメントを実態に合わせて全レイヤー開放を明示
6+
2. 現状の fixture は main レイヤーがディレクトリ (`main/**`) or 単一ファイル (`src/main.rs`) のみ。現実には `src/main.rs`(薄い)+ `src/runner.rs`(実質エントリ)のようなパターンが多い → fixture とテストを追加
7+
3. 失敗ケースの CLI レベル Large Test が不足 → 違反検出を検証するテストを追加
8+
9+
## タスク
10+
11+
### ドキュメント修正(allow_call_patterns 全レイヤー開放)
12+
- [ ] spec.md: main限定の記述を削除、全レイヤーで使える旨に変更
13+
- [ ] website/src/content/docs/configuration/layers.mdx(ja): 同上
14+
- [ ] website/src/content/docs/en/configuration/layers.mdx(en): 同上
15+
- [ ] AGENTS.md: main限定の記述を削除
16+
17+
### E2E テスト: allow_call_patterns を main 以外で使うケース
18+
- [ ] テスト設計をユーザーに提示・承認
19+
- [ ] テスト作成(RED: --no-verify)
20+
- [ ] 実装確認(GREEN: 既にコードは対応済みなのでテストが通るはず)
21+
22+
### multi-file main fixture + 失敗ケース Large Test
23+
- [ ] `tests/fixtures/rust_multifile_main/` 作成(main.rs + runner.rs パターン)
24+
- [ ] テスト設計をユーザーに提示・承認
25+
- [ ] 正常系テスト: 両ファイルが main レイヤーとして認識される
26+
- [ ] 失敗テスト: runner.rs が禁止レイヤーを import → 違反検出
27+
- [ ] 失敗テスト: allow_call_patterns が runner.rs にも適用される
28+
29+
### 仕上げ
30+
- [ ] CI dogfooding: 必要があれば ci.yml に追加
31+
- [ ] docs/TODO.md 更新
32+
- [ ] README.md 更新(allow_call_patterns の説明修正)
33+
- [ ] 全テスト通過確認
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Timeline: PR#78
2+
3+
## 2026-03-25
4+
5+
### 調査フェーズ
6+
- allow_call_patterns のmain限定制約を調査 → spec/docs にのみ記載、コードには制約なし
7+
- E2E テスト構造を調査 → 失敗ケースは存在するが inline TOML パターン、multi-file main の fixture なし
8+
- ブランチ `feat/pr78-allow-call-patterns-all-layers-and-multifile-main` 作成
9+
- TODO.md 作成
10+
11+
### テストフェーズ (RED→GREEN)
12+
- `tests/fixtures/rust_multifile_main/` fixture 作成(main.rs + runner.rs パターン)
13+
- `tests/e2e_multifile_main.rs` に 8 テスト作成
14+
- 正常系: clean exits zero, both files in main layer
15+
- 失敗系 (dep): runner.rs が infrastructure を import → 違反検出
16+
- 失敗系 (call pattern on main): runner.rs の禁止メソッド呼び出し検出
17+
- 失敗系 (call pattern on non-main): usecase の禁止メソッド呼び出し検出
18+
- 初回: TempConfig が fixture の mille.toml を上書きする方式 → 並列テストで競合、リストア失敗のリスク
19+
- 修正: fixture dir に一意な名前の temp TOML を書いて --config で指定する方式に変更
20+
- greet.rs が struct literal を使っていたため call pattern 検出されず → User::new() に変更
21+
- 全 8 テスト通過
22+
23+
### ドキュメント・CI フェーズ
24+
- spec.md, website docs (ja/en), AGENTS.md から main 限定記述を削除
25+
- README.md の allow_call_patterns 説明を更新
26+
- ci.yml に rust_multifile_main の dogfooding ステップ追加
27+
- docs/TODO.md 更新
28+
- 全テスト通過確認(397 unit + 207 E2E)

0 commit comments

Comments
 (0)