cdk-preflight 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: add-preflight-rule
3
+ description: cdk-preflight に新しいルールを追加する半自動パイプライン。制約の抽出(ドキュメント/エラーメッセージ)→ rule.rego と fail/pass テンプレート生成 → 重複ガードテスト → 実機再現ゲート → meta.yaml 記録 → PR 準備までを 1 セッションで行う。
4
+ ---
5
+
6
+ # add-preflight-rule
7
+
8
+ cdk-preflight のルール追加パイプライン。AGENTS.md の設計原則(重複禁止・証拠必須・上流昇格)を機械的に踏む。
9
+
10
+ ## 手順
11
+
12
+ 1. **入力の確定**: 追加したい制約を 1 文で書く(対象リソース型、プロパティ、条件、出典 URL または実際に観測したデプロイエラーメッセージ)。
13
+ 2. **重複チェック(先にやる)**: 違反最小テンプレートを書き、エンジンに直接かける:
14
+ ```bash
15
+ npx ts-node --project test/tsconfig.json -e "
16
+ import { loadEngine } from './src/private/enforce';
17
+ const e = loadEngine();
18
+ const r = new e.RegoEngine({}).validateDetailed(new e.TemplateFile('<template>'), {});
19
+ console.log(JSON.stringify(r.diagnostics, null, 2));"
20
+ ```
21
+ ERROR/FATAL(source: SCHEMA / CFN_LINT)が既に出るなら**ルールは書かない**。終了し、その旨を報告する。
22
+ 3. **ルール作成**: `rules/<service>/<rule-id>/` に 4 ファイル。規約:
23
+ - `package cdk_preflight` + `import rego.v1`、診断は `make_diag_full("<rule-id>", "ERROR", name, path, msg, fix, url)`
24
+ - ヘルパーは `_pf_<短縮名>_` プレフィックスで一意に
25
+ - `walk` ビルトインは無い。`to_number`/`object.get`/`flatten_list`/`resolve` で明示的に書く
26
+ - fail テンプレートはこのルール**だけ**に違反、pass テンプレートは完全クリーン
27
+ 4. **ローカルゲート**: `npx projen bundle-rules && npx jest test/rules.test.ts test/structure.test.ts` が全緑になるまで直す。
28
+ 5. **実機再現ゲート**: `bash bench/verify-rule.sh <rule-id>`(要 AWS 認証)。観測したエラーメッセージと日付を `meta.yaml#repro.evidence` に記録。実機不能な制約のみ `doc-only` + 理由。
29
+ 6. **仕上げ**: `npx projen build` 全緑 → ブランチ作成 → conventional commit(`feat(rules): add <rule-id>`)→ PR 本文に: 制約の出典 / 重複チェック結果 / 実機再現ログ。