phasegate 0.183.0 → 0.212.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.ja.md +52 -15
  3. package/README.md +39 -11
  4. package/docs/ADR/030-injection-threat-model-and-trust-root.md +145 -0
  5. package/docs/guide/hooks-integration.md +50 -1
  6. package/docs/guide/installation.md +1 -1
  7. package/docs/guide/quick-vs-full-mode.md +1 -1
  8. package/docs/guide/skills-overview.md +17 -17
  9. package/package.json +1 -1
  10. package/scripts/harness/agent-integration/presentation/phasegate-status-context.ts +131 -63
  11. package/scripts/harness/agent-integration/presentation/session-start-hook.ts +31 -4
  12. package/scripts/harness/agent-integration/presentation/spotlight.ts +65 -0
  13. package/scripts/harness/biome-ast-engine/infrastructure/parsers/comment-density-parser.ts +51 -10
  14. package/scripts/harness/ci-governance/application/dto/pin-integrity-input.ts +8 -0
  15. package/scripts/harness/ci-governance/application/dto/pin-integrity-output.ts +9 -0
  16. package/scripts/harness/ci-governance/application/dto/verify-integrity-input.ts +7 -0
  17. package/scripts/harness/ci-governance/application/dto/verify-integrity-output.ts +10 -0
  18. package/scripts/harness/ci-governance/application/usecases/pin-integrity-usecase.ts +60 -0
  19. package/scripts/harness/ci-governance/application/usecases/verify-integrity-usecase.ts +46 -0
  20. package/scripts/harness/ci-governance/composition-root.ts +68 -65
  21. package/scripts/harness/ci-governance/domain/ports/integrity-manifest-repository-port.ts +14 -0
  22. package/scripts/harness/ci-governance/domain/ports/sha256-hasher-port.ts +10 -0
  23. package/scripts/harness/ci-governance/domain/services/integrity-checker.ts +42 -0
  24. package/scripts/harness/ci-governance/domain/value-objects/integrity-drift.ts +16 -0
  25. package/scripts/harness/ci-governance/domain/value-objects/integrity-manifest.ts +49 -0
  26. package/scripts/harness/ci-governance/domain/value-objects/integrity-target.ts +40 -0
  27. package/scripts/harness/ci-governance/infrastructure/adapters/adr-foundation-existence-adapter.ts +26 -2
  28. package/scripts/harness/ci-governance/infrastructure/adapters/file-system-sha256-hasher-adapter.ts +17 -0
  29. package/scripts/harness/ci-governance/infrastructure/adapters/harness-api-command-existence-adapter.ts +8 -1
  30. package/scripts/harness/ci-governance/infrastructure/adapters/integrity-manifest-json-repository-adapter.ts +83 -0
  31. package/scripts/harness/ci-governance/presentation/handlers/integrity-handler.ts +76 -0
  32. package/scripts/harness/config-foundation/application/mappers/validator-system-config-mapper.ts +53 -28
  33. package/scripts/harness/harness-api/domain/value-objects/ci-check-result.ts +33 -8
  34. package/scripts/harness/harness-api/domain/value-objects/known-harness-commands.ts +90 -0
  35. package/scripts/harness/installation/application/bundled-skill-selection.ts +2 -5
  36. package/scripts/harness/main.ts +257 -105
  37. package/scripts/harness/phase-dependency-model/domain/ports/story-reflection-file-system-port.ts +2 -0
  38. package/scripts/harness/phase-dependency-model/domain/services/story-reflection-checker.ts +8 -0
  39. package/scripts/harness/phase-dependency-model/infrastructure/filesystem/file-system-story-reflection-adapter.ts +137 -2
  40. package/scripts/harness/quick-mode/domain/services/quick-mode-judgment-engine.ts +44 -40
  41. package/scripts/harness/setup/skill-deployer.ts +8 -10
  42. package/scripts/harness/skill-quality/domain/services/skill-structure-validator.ts +13 -2
  43. package/scripts/harness/skill-quality/domain/types/skill-kind.ts +6 -0
  44. package/scripts/harness/skill-quality/domain/value-objects/skill-structure.ts +24 -8
  45. package/scripts/harness/validator-system/application/use-cases/run-l2-validators-usecase.ts +82 -49
  46. package/scripts/harness/validator-system/application/use-cases/run-l3-validators-usecase.ts +87 -58
  47. package/scripts/harness/validator-system/composition-root.ts +141 -99
  48. package/scripts/harness/validator-system/domain/ports/coverage-attestation-gating-policy-port.ts +14 -0
  49. package/scripts/harness/validator-system/domain/ports/injection-scan-policy-port.ts +14 -0
  50. package/scripts/harness/validator-system/domain/services/coverage-attestation-gating-service.ts +56 -0
  51. package/scripts/harness/validator-system/domain/services/injection-pattern-scan-service.ts +118 -0
  52. package/scripts/harness/validator-system/domain/value-objects/coverage-gating-report.ts +67 -0
  53. package/scripts/harness/validator-system/domain/value-objects/injection-scan-report.ts +55 -0
  54. package/scripts/harness/validator-system/domain/value-objects/validator-id.ts +35 -31
  55. package/scripts/harness/validator-system/infrastructure/adapters/adr-foundation-reference-adapter.ts +13 -7
  56. package/scripts/harness/validator-system/infrastructure/adapters/file-system-coverage-attestation-gating-adapter.ts +87 -0
  57. package/scripts/harness/validator-system/infrastructure/adapters/file-system-injection-scan-adapter.ts +82 -0
  58. package/skills/README.md +1 -1
  59. package/skills/cascade-updater/SKILL.md +3 -3
  60. package/skills/codebase-mapper/SKILL.md +6 -6
  61. package/skills/codex-delegator/SKILL.md +4 -3
  62. package/skills/codex-delegator/references/prompt-patterns.md +3 -3
  63. package/skills/codex-delegator/references/review-dimensions.md +1 -1
  64. package/skills/consistency-checker/SKILL.md +1 -1
  65. package/skills/consistency-checker/references//343/203/201/343/202/247/343/203/203/343/202/257/343/203/252/343/202/271/343/203/210.md +1 -1
  66. package/skills/doc-health-checker/SKILL.md +148 -0
  67. package/skills/domain-designer/SKILL.md +4 -2
  68. package/skills/engineering-perspective/SKILL.md +1 -0
  69. package/skills/environment-designer/SKILL.md +8 -6
  70. package/skills/implementation-readiness-checker/SKILL.md +2 -1
  71. package/skills/it-test-designer/SKILL.md +10 -8
  72. package/skills/it-test-logic-designer/SKILL.md +11 -9
  73. package/skills/it-test-logic-designer/references/repository-test-patterns.md +8 -1
  74. package/skills/logical-designer/SKILL.md +5 -3
  75. package/skills/mock-designer/SKILL.md +10 -6
  76. package/skills/phasegate-config-doctor/SKILL.md +3 -2
  77. package/skills/phasegate-toolkit-guide/SKILL.md +1 -0
  78. package/skills/quick-implementor/SKILL.md +1 -1
  79. package/skills/release-publisher/SKILL.md +101 -0
  80. package/skills/scenario-test-designer/SKILL.md +27 -14
  81. package/skills/scenario-test-logic-designer/SKILL.md +10 -8
  82. package/skills/scenario-test-logic-designer/references/msw-patterns.md +3 -1
  83. package/skills/scenario-test-logic-designer/references/playwright-patterns.md +3 -1
  84. package/skills/skill-creator/SKILL.md +75 -332
  85. package/skills/story-implementor/SKILL.md +54 -0
  86. package/skills/story-mapper/SKILL.md +8 -4
  87. package/skills/story-writer/SKILL.md +14 -5
  88. package/skills/test-coverage-checker/SKILL.md +4 -6
  89. package/skills/uiux-designer/SKILL.md +4 -2
  90. package/skills/uiux-designer/references/uiux-design-template.md +4 -4
  91. package/skills/unit-designer/SKILL.md +11 -7
  92. package/skills/unit-test-designer/SKILL.md +25 -11
  93. package/skills/unit-test-logic-designer/SKILL.md +10 -8
  94. package/skills/unit-test-logic-designer/references/test-patterns.md +7 -1
  95. package/skills/doc-freshness-checker/SKILL.md +0 -140
  96. package/skills/implementation-planner/SKILL.md +0 -167
  97. package/skills/implementation-planner/references/document-structure.md +0 -116
  98. package/skills/implementation-planner/references/plan-template.md +0 -177
  99. package/skills/implementation-planner/references/workflow.md +0 -164
  100. package/skills/pointer-validator/SKILL.md +0 -104
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - **WI-256 — skill catalog 30 → 29 (BREAKING for skill consumers)** — the bundled skill catalog is reshaped. **Removed** `implementation-planner`, `doc-freshness-checker`, and `pointer-validator`. **Added** `doc-health-checker` (core / Verification, `kind: advisory`) and `release-publisher` (guidance / Operations, `kind: advisory`). Net advisory count 7 → 8, lifecycle 23 → 21, total 30 → 29. Both catalog sources (`skill-deployer.ts` `SKILL_CATEGORIES`, `bundled-skill-selection.ts`) and all count phrases / category headings were updated in the same batch.
13
+ - `implementation-planner` functionality (Unit identification, domain-model review, existing-implementation review, API-inclusive planning, and the Phase 2 minimum-output criteria) is now absorbed into **`story-implementor` Phase 1**.
14
+ - Doc-quality checks are now driven by **`doc-health-checker`**, which wraps the correct `p2:`-prefixed CLI commands: `npx phasegate p2:check-freshness` (freshness / code-design drift, L4-004) and `npx phasegate p2:validate-pointers` (broken file-path pointers, L4-005; supported flags are `--pattern` / `--include-urls` / `--format` — there is no auto-fix flag). The removed skills documented the wrong unprefixed command names (`phasegate check-freshness` / `phasegate validate-pointers`); those are corrected here.
15
+ - **Note**: `doc-freshness-checker` and `pointer-validator` also exist as **L4 validator IDs** (config presets, `validator-id.ts`, `ci-governance`). Those are a different concept and are **not** affected by this change — only the `skills/` directories were removed.
16
+
17
+ #### Migration (manual removal required in consumer repos)
18
+
19
+ `reconcile` does **not** prune skills that have left the bundle, so the three removed skill directories will remain as orphans in already-installed projects. Remove them manually:
20
+
21
+ ```bash
22
+ rm -r skills/implementation-planner skills/doc-freshness-checker skills/pointer-validator
23
+ # If personal-mode per-agent copies exist:
24
+ rm -r .claude/skills/{implementation-planner,doc-freshness-checker,pointer-validator}
25
+ rm -r .codex/skills/{implementation-planner,doc-freshness-checker,pointer-validator}
26
+ ```
27
+
28
+ A permanent `reconcile`-based prune is deferred to a follow-up WI.
29
+
10
30
  ## [0.171.0] - 2026-07-05
11
31
 
12
32
  ### Added
package/README.ja.md CHANGED
@@ -59,6 +59,8 @@ Claude Code / Codex はこのメッセージを読んで `/story-implementor`
59
59
 
60
60
  ## クイックスタート
61
61
 
62
+ まず [Getting Started](docs/guide/getting-started.md) から始めると、新規リポジトリ / 既存リポジトリ / CI 専用 / agent hook / strict 導入の各パスを、次に打つコマンドと成功状態に対応づけて案内します。
63
+
62
64
  ### 前提
63
65
 
64
66
  Node.js >= 18, npm >= 9, TypeScript 5.x
@@ -80,7 +82,7 @@ claude
80
82
  `init` は初期 bootstrap として以下を生成します:
81
83
 
82
84
  - `phasegate.config.json` — 品質設定の Single Source of Truth
83
- - `skills/` — 30 の AIDLC スキル一式
85
+ - `skills/` — 29 の AIDLC スキル一式
84
86
  - `.claude/skills/` ・ `.codex/skills/` — agent 向けの skill symlink
85
87
  - `.claude/settings.json` — PreToolUse / PostToolUse / Stop hook
86
88
  - `.codex/hooks.json` — Codex CLI hooks 設定(`--agent codex|both` 時)
@@ -129,11 +131,12 @@ npx phasegate install --personal --agent claude --apply
129
131
  | 項目 | personal install の挙動 |
130
132
  |---|---|
131
133
  | **触らないファイル** | `package.json` / `AGENTS.md` / `CLAUDE.md` / `.husky/*` / `.github/workflows/*` / `.gitignore` / GitHub CLI 設定 / repo secrets / CI 設定 |
132
- | **作るファイル** | `.phasegate-local/phasegate.config.json`(ローカル専用 config)/ `.claude/CLAUDE.local.md` または `.codex/AGENTS.local.md`(agent context)/ `.claude/settings.json` + `.claude/skills/` または `.codex/hooks.json` + `.codex/skills/`(選択した agent の runtime artifact)/ `.git/hooks/pre-commit` + `.git/hooks/commit-msg`(ローカル git hook)/ `.phasegate-local/docs/`(設計原則文書コピー)/ `.phasegate/manifest.json` |
134
+ | **作るファイル** | `.phasegate-local/phasegate.config.json`(ローカル専用 config)/ runtime から見えるローカル agent context(Claude は `.claude/CLAUDE.md`、Codex は root の `AGENTS.md` が不在または既に PhaseGate 管理下のときのみ `AGENTS.md`)/ `.claude/settings.json` + `.claude/skills/` または `.codex/hooks.json` + `.codex/skills/`(選択した agent の runtime artifact)/ `.git/hooks/pre-commit` + `.git/hooks/commit-msg`(ローカル git hook)/ `.phasegate-local/docs/`(設計原則文書コピー)/ `.phasegate/manifest.json` |
135
+ | **既存 skills の扱い** | 個人用 skills directory がある場合は merge — bundled skills を refresh し、user 所有の skill は保持する |
133
136
  | **コミット漏れ対策** | `.git/info/exclude` にローカル専用 block を管理して、個人用ファイルが誤ってチームの commit に混ざらないようにする。commit 時の L2 防御は `.git/hooks/` で発火する |
134
137
  | **Codex hook flag** | user-level feature flag の有効化は手動アクションとして残る(`codex features enable hooks`) |
135
138
 
136
- Codex を併用する場合は `--agent codex` または `--agent both` を指定します。アンインストールは team install と同様に `npx phasegate uninstall --apply` を使えば manifest 経由でローカル成果物のみが除去されます。<!-- @work-item-id WI-207 --> <!-- @work-item-id WI-208 --> <!-- @work-item-id WI-209 --> <!-- @work-item-id WI-213 -->
139
+ チーム所有の `AGENTS.md` が既に存在する場合、Codex の personal install はそれを変更せず、`doctor --personal --agent codex` が残りの context ステップを(`AGENTS.override.md` に隠すのではなく)報告します。Codex を併用する場合は `--agent codex` または `--agent both` を指定します。アンインストールは team install と同様に `npx phasegate uninstall --apply` を使えば manifest 経由でローカル成果物のみが除去されます。<!-- @work-item-id WI-207 --> <!-- @work-item-id WI-208 --> <!-- @work-item-id WI-209 --> <!-- @work-item-id WI-213 --> <!-- @work-item-id WI-215 -->
137
140
 
138
141
  後で PhaseGate を外す場合は、manifest ベースの uninstall を使います。
139
142
 
@@ -157,7 +160,7 @@ npx phasegate reconcile --apply
157
160
 
158
161
  ```bash
159
162
  npx phasegate init --name my-project --agent codex --with-husky
160
- codex features enable codex_hooks # Codex 本体の feature flag を手動で有効化
163
+ codex features enable hooks # Codex 本体の feature flag を手動で有効化
161
164
  ```
162
165
 
163
166
  両方使う場合は `--agent both`。Codex のネイティブ `apply_patch` は現時点で事前 hook を発火しないため、pre-commit (L2) で commit 時にブロックします。Bash 経由の書き込みは実行前に止まります。詳細は [Codex Integration Guide](docs/guide/codex-integration.md) を参照。
@@ -180,7 +183,7 @@ npx phasegate reconcile --apply
180
183
  |---|---|
181
184
  | **フェーズゲート** | 設計文書がないと実装ファイルへの Write/Edit/Bash をブロック。AIDLC 準拠 / カスタム gate の両方をサポート |
182
185
  | **5 層バリデーション (L0-L4)** | エディタ保存 → pre-commit → CI → 週次まで段階的に品質チェック |
183
- | **30 AIDLC スキル** | 要求定義 → ドメイン設計 → テスト設計 → TDD 実装をスキルとして提供 |
186
+ | **29 AIDLC スキル** | 要求定義 → ドメイン設計 → テスト設計 → TDD 実装をスキルとして提供 |
184
187
  | **Quick Mode** | バグ修正・docs・テスト追加など軽微変更ではゲートを緩和して高速化 |
185
188
  | **Claude Code / Codex Hooks** | Write/Edit/Bash 時に自動でゲートチェック・lint を実行 |
186
189
  | **HarnessError 形式** | 全エラーに ADR 参照 + 修正例が含まれ、AI が自己修正できる |
@@ -201,10 +204,12 @@ npx phasegate reconcile --apply
201
204
  | @unit / @layer メタデータ, レイヤー違反, AI アンチパターン |
202
205
  +------------------------------------------------------------------+
203
206
  | L2 pre-commit |
204
- | phase-gate, story-reflection, テスト品質 (semantic AAA) |
207
+ | phase-gate, story-reflection, テスト品質 (semantic AAA), |
208
+ | coverage-attestation-gating (L2-016, fail-closed) |
205
209
  +------------------------------------------------------------------+
206
210
  | L3 CI/CD |
207
- | security, performance, coverage 90%/95%, 要件カバレッジ |
211
+ | security, performance, coverage 90%/95%, 要件カバレッジ, |
212
+ | injection-scan (L3-006, advisory) |
208
213
  +------------------------------------------------------------------+
209
214
  | L4 週次 (default off) |
210
215
  | 設計-コード乖離, 文書整合性, デッドコード, |
@@ -222,26 +227,50 @@ npx phasegate reconcile --apply
222
227
 
223
228
  エラーは `HarnessError` 形式(理由 / ADR 参照 / 修正例)で返されるため、AI agent が自己修正できます。
224
229
 
230
+ **L2 の追加ゲート**: `L2-STORY-REFLECTION` は git の source-touch により layer-aware になり、複数 WI を含む commit では file-tag scoped の attribution で反映元を判定します。`L2-016 coverage-attestation-gating` は fail-closed で、`✅` を主張するには attestation ID が必須です(ID なしの ✅ はブロック)。既存の非ゲート行は `ungated-legacy` マーカーで可視化したまま段階返済します。
231
+
232
+ **L3 の追加ゲート**: `L3-006 injection-scan` は指示搭載ファイルに対する advisory(**warning-only、非 blocking**)なインジェクションスキャナで、人間レビューへの注意喚起に留めます。
233
+
225
234
  詳細: [5-Layer Defense Model](docs/guide/layer-model.md)
226
235
 
227
236
  ---
228
237
 
229
- ## 30 AIDLC スキル
238
+ ## セキュリティ姿勢
239
+
240
+ Phasegate はプロンプトインジェクションを独立した新規脅威として扱いません。[ADR-030](docs/ADR/030-injection-threat-model-and-trust-root.md) の通り、インジェクションに成功したエージェントは、phasegate が元々仮定してきた **「洗浄を試みるエージェント」と同一の脅威** — すなわち正規の権限(Bash / ファイル書き込み / commit)で品質防御を回避しようとする悪意ある内部者 — として振る舞います。したがって対策は「穴を塞ぐ」「コンテンツが指示になる経路を減らす」の 2 軸に還元され、専用の別枠防御ではなく既存の L0-L4 モデルの延長で扱います。
241
+
242
+ **信頼のルート**: L0-L2 はローカルで実行される以上、Bash を持つエージェントには原理的に偽造・迂回可能です。これらは **fast-path**(正直なエージェントの事故防止 / 騙されかけたエージェントの早期停止)として正直に位置づけます。**信頼のルート(authoritative)は L3 CI の再検証**で、攻撃者が制御できない環境で evidence を独立に再計算します。「ローカルが緑なら安全」は明示的に保証しません。
243
+
244
+ この姿勢を 5 コンポーネントで実装します:
245
+
246
+ | コンポーネント | 役割 | 正直な位置づけ |
247
+ |---|---|---|
248
+ | **指示ファイル整合性 pin** | 指示搭載ファイル(SKILL.md / `CLAUDE.md`・`AGENTS.md` テンプレート / hook 定義 / `.husky/*`)の SHA-256 manifest(`phasegate.integrity.json`)。`integrity:pin` で意図的変更を記録、SessionStart hook が drift を警告、CI が再計算して authoritative に照合 | ローカル照合は warn-only の fast-path、CI が authoritative |
249
+ | **coverage attestation ゲート (L2-016)** | fail-closed の参照形式ゲート。`✅` の主張には attestation ID が必須で、bare ✅ はブロック。既存行は `ungated-legacy` で可視化し段階返済 | L2 は参照形式をゲートする。evidence の独立再実行は L3 側の将来分 |
250
+ | **hook 出力の spotlighting** | hook が中継するリポジトリ由来の自由文字列を固定のデータ境界フェンスで包み、「データであって指示ではない」ことを明示 | リポジトリ由来テキストが指示に昇格する経路を減らす |
251
+ | **advisory インジェクションスキャナ (L3-006)** | 指示搭載ファイルの既知インジェクションパターンを検査。**advisory / warning-only** で非 blocking のため「すり抜け=安全」という誤った信頼を生まない | パターン検査は回避可能。finding は警告のみ、最終判断は人間レビュー |
252
+ | **エージェント権限 allowlist** | エージェント操作を allowlist(明示的に許されたものだけ実行)に反転。網羅漏れのある deny 列挙(`git merge`/`checkout`/`reset` は deny 済みなのに `git switch` が漏れていた等)を是正 | 未知の危険操作を既定で拒否 |
253
+
254
+ **ADR-030 が明記する残存リスク**: ローカル層(L0-L2)は偽造可能なので L3 が信頼のルート/スキャナは回避可能なので advisory に留める/CI を持たない PJ には信頼のルートが不在(`phasegate doctor` が警告)/red・警告付き PR を人間が手動 merge する経路は機械防御の対象外。
255
+
256
+ ---
257
+
258
+ ## 29 スキル
230
259
 
231
260
  AIDLC (AI-Driven Development Life Cycle) は **要求定義 → 設計 → テスト設計 → TDD 実装** の順序を強制するプロセスです。各スキルは前のレベルの成果物を入力にします。
232
261
 
233
262
  **最初の一歩**: Claude Code / Codex 内で `/product-architect` を実行。
234
263
 
235
- ### 6 グループ(30 スキル)
264
+ ### 6 グループ(29 スキル)
236
265
 
237
266
  | グループ | スキル |
238
267
  |---|---|
239
268
  | **Foundation (4)** | `/product-architect` `/story-writer` `/story-mapper` `/unit-designer` |
240
269
  | **Design (5)** | `/domain-designer` `/logical-designer` `/mock-designer` `/uiux-designer` `/environment-designer` |
241
270
  | **Test Engineering (7)** | `/unit-test-designer` `/it-test-designer` `/scenario-test-designer` `/unit-test-logic-designer` `/it-test-logic-designer` `/scenario-test-logic-designer` `/test-coverage-checker` |
242
- | **Implementation (4)** | `/story-implementor` `/quick-implementor` `/implementation-planner` `/implementation-readiness-checker` |
243
- | **Verification (8)** | `/consistency-checker` `/cascade-updater` `/codex-delegator` `/codebase-mapper` `/doc-freshness-checker` `/pointer-validator` `/engineering-perspective` `/skill-creator` |
244
- | **Operations (2)** | `/phasegate-config-doctor` `/phasegate-toolkit-guide` |
271
+ | **Implementation (3)** | `/story-implementor` `/quick-implementor` `/implementation-readiness-checker` |
272
+ | **Verification (7)** | `/consistency-checker` `/cascade-updater` `/codex-delegator` `/codebase-mapper` `/doc-health-checker` `/engineering-perspective` `/skill-creator` |
273
+ | **Operations (3)** | `/phasegate-config-doctor` `/phasegate-toolkit-guide` `/release-publisher` |
245
274
 
246
275
  各スキルの詳細・成果物・前提条件: [Skills Overview](docs/guide/skills-overview.md)
247
276
 
@@ -357,12 +386,17 @@ npx phasegate <command> [options]
357
386
  | `uninstall --dry-run` / `--apply` | manifest に基づいて PhaseGate 管理ファイル・管理 block を削除し、ユーザー設定は保持 |
358
387
  | `reconcile --dry-run` / `--apply` | 現在の package template に PhaseGate 管理ファイルを追従し、manifest hash を更新 |
359
388
  | `update-skills` | `reconcile` の互換 alias |
389
+ | `setup:agent --dry-run` / `--apply` | リポジトリの setup 状態を診断し、質問 / risk / rollback / validation 付きの agent-readable な setup plan を生成・適用 |
390
+ | `config:plan --intent <intent>` | 安全な設定変更 intent を対象ファイル / コマンド / risk / rollback / validation にマップ |
391
+ | `integrity:pin` | 指示搭載ファイルの SHA-256 manifest(`phasegate.integrity.json`)を生成 / 更新(意図的変更を記録。`--dry-run`, `--json`) |
392
+ | `integrity:verify` | manifest と実ファイルを照合。drift 検出時は exit 2、クリーン時は exit 0(`--json`)。ローカルは advisory、CI が authoritative |
360
393
  | `lint` | L1 Biome AST チェック |
361
394
  | `validate --layer <L1\|L2\|L3\|L4\|all>` | 指定レイヤーのバリデータ実行(`--format human\|agent\|ci`) |
362
395
  | `ci-check` | CI フルチェック(L2-L4)。`--quick` で Quick Mode |
363
396
  | `check-change-category --paths <csv>` | 変更ファイルを Quick Mode カテゴリに分類、Full Mode 強制が必要かを返す |
364
397
  | `baseline` | retrofit grandfather snapshot 生成(`--dry-run`, `--force`, `--paths <glob>`, `--json`) |
365
398
  | `scaffold-design --unit <id> --phase <logical\|domain\|uiux\|unit-test\|it-test>` | 最小構成の設計文書を `templates/` から生成 |
399
+ | `scaffold-wi <unit> <type>` | 次の空き WI 番号で `docs/inception/{unit}/WI-XXX/description.md` を生成 |
366
400
  | `phasegate:status` | 全体の健全性サマリ |
367
401
  | `work-items:status --dry-run` / `--apply` | 成果物から WI status を導出し、必要に応じて `description.md` frontmatter を更新。`--apply` は既定で downgrade を拒否し、必要時のみ `--allow-downgrade` を指定 |
368
402
  | `phasegate:check-phase --unit <id>` | 指定 Unit の現在フェーズ |
@@ -374,7 +408,7 @@ npx phasegate <command> [options]
374
408
  | `refresh-claude-md --dry-run` / `--apply` | user section を保持して CLAUDE.md だけを更新 |
375
409
  | `p2:check-agent-context` | AGENTS.md / CLAUDE.md の鮮度を検査 |
376
410
  | `list-errors --layer <L0-L4>` | エラー定義一覧 |
377
- | `hook <pre-tool-use\|post-tool-use\|stop>` | agent hook を起動(stdin から JSON |
411
+ | `hook <pre-tool-use\|post-tool-use\|stop\|session-start\|user-prompt-submit>` | agent hook を起動(stdin から JSON を読む。session-start / user-prompt-submit は JSON context を出力) |
378
412
  | `pre-commit` | L2 pre-commit バリデータをステージファイルに適用 |
379
413
  | `bypass:audit --base <ref> [--head <ref>]` | push/CI range に pre-commit validation を再適用し、gate failure に structured bypass evidence を要求 |
380
414
 
@@ -393,6 +427,8 @@ npx phasegate <command> [options]
393
427
  | **PreToolUse** | Write/Edit/Bash の実行前 | フェーズゲート違反 / 保護ファイル / Bash 経由迂回をブロック。Quick→Full 強制条件のチェックも実行 |
394
428
  | **PostToolUse** | Write/Edit の実行後 | Biome AST ルールを自動実行、違反を即時フィードバック |
395
429
  | **Stop** | セッション終了前 | L2-L4 全チェックを実行、グリーンでないと終了を保留 |
430
+ | **SessionStart** | セッション開始時 | harness status context を注入。指示ファイル整合性 pin を in-process で照合し、drift 時のみ **warn-only / fail-open** で警告(authoritative な照合は CI) |
431
+ | **UserPromptSubmit** | プロンプト送信時 | リポジトリ由来 context を注入。中継するリポジトリ由来テキストを固定のデータ境界フェンスで包み(spotlighting)、指示ではなくデータとして扱わせる |
396
432
 
397
433
  ### Codex CLI
398
434
 
@@ -540,9 +576,10 @@ L3 Nyquist Validation の `requirement-test-matrix.json` は `phasegate:generate
540
576
  ## ドキュメント
541
577
 
542
578
  - [Installation](docs/guide/installation.md) — 詳細インストール手順
579
+ - [Getting Started](docs/guide/getting-started.md) — 初回 / 日常 / CI / agent 利用の各パス
543
580
  - [Configuration](docs/guide/configuration.md) — `phasegate.config.json` 完全リファレンス
544
581
  - [CLI Reference](docs/guide/cli-reference.md) — 全 CLI コマンド・オプション
545
- - [Skills Overview](docs/guide/skills-overview.md) — 30 スキルの実行順序と成果物
582
+ - [Skills Overview](docs/guide/skills-overview.md) — 29 スキルの実行順序と成果物
546
583
  - [5-Layer Defense Model](docs/guide/layer-model.md) — L0-L4 詳細・HarnessError 形式
547
584
  - [Hooks Integration](docs/guide/hooks-integration.md) — Claude Code Hooks 設定
548
585
  - [Codex Integration](docs/guide/codex-integration.md) — Codex CLI セットアップ・カバレッジ
@@ -560,4 +597,4 @@ phasegate 自体の開発: [DEVELOPMENT.ja.md](DEVELOPMENT.ja.md)
560
597
 
561
598
  ---
562
599
 
563
- *Last updated: 2026-04-25 — v0.110.0*
600
+ *Last updated: 2026-07-15 — v0.211.0*
package/README.md CHANGED
@@ -83,7 +83,7 @@ claude
83
83
  `init` creates the initial project-local harness files:
84
84
 
85
85
  - `phasegate.config.json` as the quality settings source of truth
86
- - `skills/` with 30 AIDLC skills
86
+ - `skills/` with 29 AIDLC skills
87
87
  - `.claude/skills` and/or `.codex/skills` links for agent use
88
88
  - `.claude/settings.json` and/or `.codex/hooks.json` hook configuration
89
89
  - `docs/principles/*.md` and `docs/folder_management_rules.md`
@@ -167,7 +167,7 @@ npx phasegate reconcile --apply
167
167
  |---|---|
168
168
  | **Phase gates** | Blocks implementation writes until required design documents exist and have been reflected into product docs |
169
169
  | **5-layer validation** | Runs checks from agent runtime and editor time through pre-commit, CI, and scheduled audits |
170
- | **30 AIDLC skills** | Guides AI agents through product architecture, story writing, domain design, test design, and TDD implementation |
170
+ | **29 AIDLC skills** | Guides AI agents through product architecture, story writing, domain design, test design, and TDD implementation |
171
171
  | **Quick Mode** | Keeps bugfixes, docs, test-only changes, and config changes lightweight while preserving traceability |
172
172
  | **Claude Code / Codex hooks** | Runs checks around Write/Edit/Bash operations and session boundaries |
173
173
  | **Agent-readable HarnessError output** | Gives AI agents the reason, missing artifacts, references, and examples needed to self-correct |
@@ -192,10 +192,12 @@ npx phasegate reconcile --apply
192
192
  +------------------------------------------------------------------+
193
193
  | L2 PRE-COMMIT Validators |
194
194
  | phase-gate, metadata completeness, story-reflection, |
195
- | test-quality (semantic AAA + assertion strength) |
195
+ | test-quality (semantic AAA + assertion strength), |
196
+ | coverage-attestation-gating (L2-016, fail-closed) |
196
197
  +------------------------------------------------------------------+
197
198
  | L3 CI/CD Validators |
198
- | security, performance, coverage threshold, nyquist traceability |
199
+ | security, performance, coverage threshold, nyquist |
200
+ | traceability, injection-scan (L3-006, advisory) |
199
201
  +------------------------------------------------------------------+
200
202
  | L4 SCHEDULED Validators (default off) |
201
203
  | drift-detection, consistency-check, dead-code analysis, |
@@ -207,13 +209,33 @@ npx phasegate reconcile --apply
207
209
  |---|---|---|
208
210
  | L0 | AI agent runtime (`.claude/settings.json` / `.codex/hooks.json`) + Husky git hooks | PreToolUse blocks Write/Edit/Bash that violate gates; PostToolUse runs lint/format; Stop enforces ReentryGuard + `complete-check`; `.husky/pre-commit` runs `phasegate pre-commit`; `.husky/commit-msg` enforces `Work-Item: WI-XXX` and bypass trailers; `.husky/pre-push` runs `phasegate bypass:audit` |
209
211
  | L1 | Editor save / `phasegate lint` | `@unit` / `@layer` metadata, layer violations, AI anti-patterns, dead code |
210
- | L2 | Pre-commit (also evaluated inside PreToolUse at L0) | Phase gate, metadata completeness, `@work-item-id` reflection (`L2-STORY-REFLECTION`), test quality |
211
- | L3 | CI/CD pipeline | Security, performance, coverage (90%/95%), requirements traceability |
212
+ | L2 | Pre-commit (also evaluated inside PreToolUse at L0) | Phase gate, metadata completeness, `@work-item-id` reflection (`L2-STORY-REFLECTION`, now layer-aware with git source-touch + file-tag-scoped attribution for multi-WI commits), test quality, coverage-report attestation gate (`L2-016`, fail-closed: a bare ✅ without an attestation ID is blocked; pre-existing rows stay visible via the `ungated-legacy` marker) |
213
+ | L3 | CI/CD pipeline | Security, performance, coverage (90%/95%), requirements traceability, advisory injection scan (`L3-006`, **warning-only**) over instruction-carrying files |
212
214
  | L4 | Scheduled (weekly). Currently `layers.L4.enabled: false` by default — opt-in per project | Design-code drift, cross-document consistency, dead code, doc freshness, and pointer validation. `p2:*` standalone commands remain available as compatibility entry points. |
213
215
 
214
216
  ---
215
217
 
216
- ## 30 Skills
218
+ ## Security Posture
219
+
220
+ Phasegate does not treat prompt injection as a separate threat. Per [ADR-030](docs/ADR/030-injection-threat-model-and-trust-root.md), a successfully injected agent behaves exactly like the "laundering agent" the toolkit already assumes: a malicious insider that uses its legitimate permissions (Bash, file writes, commits) to evade the quality defenses. The countermeasures therefore reduce to two axes — close the holes an agent can slip through, and reduce the paths by which external content becomes agent instructions — handled along the existing L0-L4 model rather than in a separate defense layer.
221
+
222
+ **Trust root.** Because L0-L2 run locally, an agent with Bash can in principle forge or bypass them. They are positioned honestly as a **fast-path** (early accident detection for honest agents, early stop for misled ones). The **authoritative trust root is the L3 CI re-check**, which runs where an attacker cannot control the environment and recomputes evidence independently. "Local is green" is explicitly not a safety guarantee.
223
+
224
+ Five components implement this posture:
225
+
226
+ | Component | Role | Honest framing |
227
+ |---|---|---|
228
+ | **Instruction-file integrity pin** | SHA-256 manifest (`phasegate.integrity.json`) over instruction-carrying files (SKILL.md, `CLAUDE.md` / `AGENTS.md` templates, hook definitions, `.husky/*`). `integrity:pin` records intentional changes; the SessionStart hook warns on drift; CI recomputes as the authority. | Local check is a warn-only fast-path; CI is authoritative. |
229
+ | **Coverage attestation gate (L2-016)** | Fail-closed reference-style gate: a `✅` coverage claim requires an attestation ID; bare ✅ is blocked. Pre-existing rows are surfaced via `ungated-legacy` and repaid gradually. | L2 gates on reference shape; independent evidence re-execution is L3's future scope. |
230
+ | **Hook-output spotlighting** | Repo-derived free text relayed in hook output is wrapped in fixed data-boundary fences so it reads as data, not instructions. | Reduces the path by which repo content is promoted to the harness voice. |
231
+ | **Advisory injection scanner (L3-006)** | Scans instruction-carrying files for known injection patterns. **Advisory / warning-only** — never blocking, so no "slipped past the scanner = safe" false confidence is created. It is a signal for human review. | Pattern checks are inherently evadable; findings are warnings only. |
232
+ | **Agent-permission allowlist** | Agent operations are an allowlist (only explicitly permitted operations run), inverted from the previous deny-list that had gaps (e.g. `git switch` was missing while `git merge`/`checkout`/`reset` were denied). | Unknown dangerous operations are denied by default. |
233
+
234
+ **Residual risks ADR-030 states plainly**: local layers (L0-L2) are forgeable, so L3 is the trust root; the scanner is evadable, so it stays advisory; a project without CI has no trust root (`phasegate doctor` warns); and a human manually merging a red/warned PR is outside machine defense.
235
+
236
+ ---
237
+
238
+ ## 29 Skills
217
239
 
218
240
  Skills cover the full **AIDLC (AI-Driven Development Life Cycle)**: product definition, design, test design, and TDD implementation. Each skill consumes the artifacts from the previous phase.
219
241
 
@@ -224,9 +246,9 @@ Skills cover the full **AIDLC (AI-Driven Development Life Cycle)**: product defi
224
246
  | **Foundation (4)** | `/product-architect` `/story-writer` `/story-mapper` `/unit-designer` |
225
247
  | **Design (5)** | `/domain-designer` `/logical-designer` `/mock-designer` `/uiux-designer` `/environment-designer` |
226
248
  | **Test Engineering (7)** | `/unit-test-designer` `/it-test-designer` `/scenario-test-designer` `/unit-test-logic-designer` `/it-test-logic-designer` `/scenario-test-logic-designer` `/test-coverage-checker` |
227
- | **Implementation (4)** | `/story-implementor` `/quick-implementor` `/implementation-planner` `/implementation-readiness-checker` |
228
- | **Verification (8)** | `/consistency-checker` `/cascade-updater` `/codex-delegator` `/codebase-mapper` `/doc-freshness-checker` `/pointer-validator` `/engineering-perspective` `/skill-creator` |
229
- | **Operations (2)** | `/phasegate-config-doctor` `/phasegate-toolkit-guide` |
249
+ | **Implementation (3)** | `/story-implementor` `/quick-implementor` `/implementation-readiness-checker` |
250
+ | **Verification (7)** | `/consistency-checker` `/cascade-updater` `/codex-delegator` `/codebase-mapper` `/doc-health-checker` `/engineering-perspective` `/skill-creator` |
251
+ | **Operations (3)** | `/phasegate-config-doctor` `/phasegate-toolkit-guide` `/release-publisher` |
230
252
 
231
253
  Details, prerequisites, and generated artifacts: [Skills Overview](docs/guide/skills-overview.md)
232
254
 
@@ -488,6 +510,8 @@ Phasegate integrates natively with Claude Code via hooks in `.claude/settings.js
488
510
  | `PreToolUse` | `Write`, `Edit`, or `Bash` (write operations detected) | Blocks writes to source files without design docs; enforces `quickMode.fullModeRequiredWhen` (escalates Quick Mode → Full when triggered); skips files captured in the `.phasegate/baseline.json` snapshot until they are modified; protects configured files; detects Bash write operations (`sed -i`, `tee`, `cp`, etc.) |
489
511
  | `PostToolUse` | `Write` or `Edit` | Auto-formats and validates metadata |
490
512
  | `Stop` | Session end | Runs full test suite to ensure all tests pass |
513
+ | `SessionStart` | Session start | Injects harness status context; verifies the instruction-file integrity pin in-process and warns (**warn-only, fail-open**) if drift is detected — CI remains the authoritative check |
514
+ | `UserPromptSubmit` | Prompt submitted | Injects repo-derived context, wrapping relayed repo text in fixed data-boundary fences (spotlighting) so it reads as data, not instructions |
491
515
 
492
516
  All hook errors use the `HarnessError` format with ADR references and fix examples, enabling AI agents to self-correct without human intervention.
493
517
 
@@ -544,6 +568,10 @@ README keeps only the entry points most users need. The full public/compatibilit
544
568
  | `reconcile --dry-run` / `--apply` | Update PhaseGate-managed files to the current package templates and refresh manifest hashes. |
545
569
  | `setup:agent --dry-run` / `--apply` | Diagnose repository setup and produce or apply an agent-readable setup plan with questions, risks, rollback, and validation. |
546
570
  | `config:plan --intent <intent>` | Map a safe configuration-change intent to target files, commands, risks, rollback, and validation. |
571
+ | `integrity:pin` | Generate/update the SHA-256 manifest (`phasegate.integrity.json`) over instruction-carrying files. Records intentional edits (`--dry-run`, `--json`). |
572
+ | `integrity:verify` | Recompute and compare against the manifest. Exit 2 on drift (mismatch/added/missing/manifest-absent), exit 0 when clean (`--json`). Locally advisory; CI is authoritative. |
573
+ | `list-adrs` | List ADRs, optionally filtered by `--status <Proposed\|Accepted\|...>`. |
574
+ | `validate-adr` | Validate ADR structure (`--all` or a single `<adrRef>`). |
547
575
  | `lint` / `phasegate:lint` | Run L1 Biome AST checks. The `phasegate:*` form is a binary subcommand, not an npm script unless `package.json` defines it locally. |
548
576
  | `validate --layer <L1-L4\|all>` | Run validators for the specified layer (`--layer L0` prints runtime hook guidance). `--fail-on-warning` / `--no-fail-on-warning` override config. |
549
577
  | `ci-check` | Full CI check (L2-L4; disabled L4 is reported as skipped). Supports `--quick`, `--fail-on-reject`, `--dry-run`, and `--files`. |
@@ -589,7 +617,7 @@ Detailed guides are available under `docs/guide/`:
589
617
  - [Troubleshooting](docs/guide/troubleshooting.md) -- Doctor finding, repairHint, suggestedSkill, and setup recovery guide
590
618
  - [Configuration](docs/guide/configuration.md) -- `phasegate.config.json` full reference
591
619
  - [CLI Reference](docs/guide/cli-reference.md) -- All CLI commands and options
592
- - [Skills Overview](docs/guide/skills-overview.md) -- 30 skills with AIDLC execution order
620
+ - [Skills Overview](docs/guide/skills-overview.md) -- 29 skills with AIDLC execution order
593
621
  - [5-Layer Defense Model](docs/guide/layer-model.md) -- L0-L4 layer details and HarnessError format
594
622
  - [Contract Traceability](docs/guide/contract-traceability.md) -- `L2-015` public contract, boundary, error, state, and observation annotations
595
623
  - [Hooks Integration](docs/guide/hooks-integration.md) -- Claude Code Hooks setup and behavior
@@ -0,0 +1,145 @@
1
+ ---
2
+ adr_id: "030"
3
+ title: "プロンプトインジェクション脅威モデルと信頼のルート宣言"
4
+ status: Accepted
5
+ date: 2026-07-10
6
+ ---
7
+
8
+ # プロンプトインジェクション脅威モデルと信頼のルート宣言
9
+
10
+ ## Context
11
+
12
+ phasegate は「設計意図とコードの構造的整合性を機械的に保証する」ことを目的とし、その前提として **「品質防御を回避(洗浄)しようとするエージェント」を脅威として仮定** してきた(ADR-006 エージェント非依存設計、ADR-013 storyReflection ゲート、coverage_report の attestation 化に関する既存の議論など)。
13
+
14
+ 一方で、AI エージェントを用いた開発フローが普及するにつれ、**プロンプトインジェクション**が新たな懸念として浮上した。しかし phasegate はこれを独立した新規脅威としては扱わない。理由を明文化するのが本 ADR の第一の目的である。
15
+
16
+ ### プロンプトインジェクションの作用機序
17
+
18
+ インジェクションは、外部発コンテンツが「信頼できないテキストとしてエージェントの文脈に入る箇所」から作用する。phasegate の文脈で該当する主な経路は以下:
19
+
20
+ - **npm 依存**(インストールされるパッケージの README・ソース・postinstall 出力等)
21
+ - **PR 由来ファイル**(レビュー対象の diff、コミットされたドキュメント・コメント)
22
+ - **エージェントが読む Web コンテンツ**(fetch した外部ページ・issue 本文・リンク先)
23
+
24
+ これらのコンテンツがエージェントの指示として解釈されて成功すると、エージェントは **「悪意ある内部者」** として振る舞う。すなわち、正規の権限(Bash、ファイル書き込み、コミット)を用いて品質防御を回避しようとする。
25
+
26
+ ### 既存脅威モデルとの同一性
27
+
28
+ この「悪意ある内部者と化したエージェント」は、phasegate が元々仮定してきた **「洗浄を試みるエージェント」と同一の脅威モデル** である。インジェクションは新しい攻撃の入口を増やすが、防御対象となる振る舞い(防御の偽装・迂回)は変わらない。
29
+
30
+ したがって対策は 2 軸に還元される:
31
+
32
+ 1. **洗浄可能な残り穴を塞ぐ** — エージェントが権限で防御をすり抜けられる隙間を減らす。
33
+ 2. **コンテンツが指示になる経路を減らす** — 外部発テキストがエージェントの指示に昇格しにくくする。
34
+
35
+ この整理により、phasegate は「インジェクション専用の別枠防御」を作らず、既存の 5 層防御モデル(L0–L4)の延長線上で一貫して対処する。本 ADR はその方針と、その前提となる **信頼のルート(trust root)** を宣言する。
36
+
37
+ ## Decision
38
+
39
+ ### 1. 信頼のルート(authoritative)は L3 CI の再検証である
40
+
41
+ phasegate の防御層のうち、**L0–L2(ローカル hook / pre-commit)は Bash を持つエージェントには原理的に偽造・迂回可能** である。ローカルで実行される以上、同一プロセス権限を持つエージェントは hook の入出力・終了コード・pin ファイルを書き換えられる。したがって L0–L2 を「信頼のルート」と位置づけることはできない。
42
+
43
+ L0–L2 は **fast-path** として正直に位置づける。fast-path の価値は次の 2 点に限定される:
44
+
45
+ - **正直なエージェントの事故防止** — 意図せぬ規約違反をローカルで早期に検出し、無駄な往復を減らす。
46
+ - **騙されかけたエージェントの早期停止** — インジェクションで逸脱し始めたエージェントを、ローカルの明示的なブロックで踏みとどまらせる。
47
+
48
+ **信頼のルート(authoritative)は L3 CI の再検証** とする。CI は攻撃者(あるいは騙されたエージェント)が制御できない環境で:
49
+
50
+ - 指示ファイルの **SHA-256 ハッシュを再計算** して pin と照合する。
51
+ - coverage_report 等の **evidence を再実行** して主張の真偽を独立に確かめる。
52
+
53
+ ローカルが何を主張しようと、最終的な合否は CI の再検証が決める。
54
+
55
+ ### 2. ローカル秘密鍵 / HMAC 方式は不採用
56
+
57
+ 「ローカル成果物を秘密鍵で署名し改竄を検出する」案は **採用しない**。理由:
58
+
59
+ - **同一マシンの Bash からは鍵を隔離できない** — エージェントが鍵にアクセスできる以上、署名も偽造でき、見せかけの安全にしかならない。
60
+ - **UX コストに見合わない** — 導入 PJ の全マシンで鍵を配布・ローテーション・保護する運用負担は、得られる(見せかけの)保証に釣り合わない。
61
+
62
+ 改竄検出は「秘密に依存しない再計算(ハッシュ)を、攻撃者が制御できない場所(CI)で行う」方式に統一する。
63
+
64
+ ### 3. 5 コンポーネント構成(実装順に記録)
65
+
66
+ 上記 2 軸(穴を塞ぐ / 指示経路を減らす)を、以下の 5 コンポーネントで実装する。番号は実装順を兼ねる。
67
+
68
+ #### ① 指示ファイルの整合性 pin(穴を塞ぐ)
69
+
70
+ 指示を搭載するファイル群の SHA-256 を `phasegate.integrity.json` に pin する。対象:
71
+
72
+ - SKILL.md × 30
73
+ - `CLAUDE.md` / `AGENTS.md` テンプレート
74
+ - hook 定義
75
+ - `deny-check.sh`
76
+ - `.husky/*`
77
+
78
+ 照合と更新のフロー:
79
+
80
+ - **session-start hook** が起動時に pin と実ファイルを照合する(fast-path の改竄検出)。
81
+ - **`phasegate integrity:pin`** コマンドで pin を正規に更新する(意図的な変更の記録手段)。
82
+ - **CI が再計算** して照合する(authoritative)。ローカルの照合結果は信頼せず、CI が独立に確かめる。
83
+
84
+ #### ② coverage_report の attestation ゲート(穴を塞ぐ)
85
+
86
+ `phasegate:attest` を拡張し、coverage_report の主張を attestation で裏付ける。
87
+
88
+ - **L2 で fail-closed** — `✅` を主張するには attestation ID が必須。ID なしの ✅ はブロックする。
89
+ - **L3 が evidence を再実行** — attestation が指す証跡を CI が独立に再実行し、主張の真偽を確かめる(authoritative)。
90
+ - **既存の非ゲート 72 件** は `ungated-legacy` マーカーで可視化し、段階的に返済する(一括ブロックによる運用停止を避けつつ、負債を隠さない)。
91
+
92
+ #### ③ hook 出力の spotlighting(指示経路を減らす)
93
+
94
+ hook がエージェントに返す出力を **固定テンプレート + データ境界マーカー** で構造化する。外部発コンテンツを hook が中継する際、それがデータであって指示ではないことをマーカーで明示し、コンテンツが指示に昇格する経路を減らす。
95
+
96
+ #### ④ L3 advisory インジェクションスキャナ(指示経路を減らす)
97
+
98
+ 指示搭載ファイルの PR diff に対し、既知のインジェクションパターンを検査する L3 スキャナを追加する。
99
+
100
+ - **advisory(非 blocking)とする** — パターン検査は本質的に回避可能であり、blocking にすると「検出をすり抜けた=安全」という誤った信頼を生む。あくまで人間レビューへの注意喚起に留める。
101
+
102
+ #### ⑤ エージェント権限の deny 列挙 → allowlist 反転(穴を塞ぐ)
103
+
104
+ エージェントに許す操作を deny 列挙(ブラックリスト)から allowlist(ホワイトリスト)へ反転する。
105
+
106
+ - deny 列挙は網羅漏れが原理的に避けられない。実例として、`git merge` / `git checkout` / `git reset` が deny 済みであるにもかかわらず、等価な危険操作である **`git switch` が漏れていた**。
107
+ - allowlist 反転により「明示的に許されたものだけを実行できる」状態にし、未知の危険操作を既定で拒否する。
108
+
109
+ ### 4. 残存リスクの明記
110
+
111
+ 本設計は脅威を完全には消せない。以下を残存リスクとして明記し、隠さない:
112
+
113
+ - **(a) ローカル層は偽造可能** — L0–L2 は原理的に迂回できる。だから L3 が信頼のルートである(本 ADR §Decision.1)。
114
+ - **(b) ④ のスキャナは回避可能** — パターン検査はすり抜けられる。だから advisory であり blocking にしない(§Decision.3.④)。
115
+ - **(c) CI を持たない利用側 PJ では信頼のルートが不在** — L3 再検証が動かない環境では authoritative な保証が得られない。**`phasegate doctor` で警告する** 方針とする。
116
+ - **(d) 人間による手動 merge 経路は防げない** — red / 警告付きの PR を人間が手動で merge する経路は、機械防御の対象外である。
117
+
118
+ ## Consequences
119
+
120
+ ### Positive
121
+
122
+ - インジェクションを既存脅威モデルに還元することで、専用の別枠防御を作らず一貫した設計を維持できる。
123
+ - 信頼のルートを L3 CI に明示的に置くことで、「ローカルが緑なら安全」という誤った信頼を排除できる。
124
+ - 秘密鍵運用を避けることで、導入 PJ の UX コストを増やさない。
125
+ - 残存リスクを明文化することで、利用者が防御の限界を正しく理解できる。
126
+
127
+ ### Negative / Trade-off
128
+
129
+ - **CI を持たない PJ は authoritative な保証を得られない** — fast-path のみとなる(`phasegate doctor` の警告で緩和)。
130
+ - **integrity pin の運用負担** — 指示ファイルを正規に変更するたびに `phasegate integrity:pin` が必要になる。
131
+ - **④ が advisory であるため誤検知・見逃しの両方が起こりうる** — 最終判断は人間レビューに委ねられる。
132
+ - **既存 72 件の `ungated-legacy`** は段階返済の間、attestation ゲートの外に残る。
133
+
134
+ ## Alternatives
135
+
136
+ - **ローカル秘密鍵 / HMAC 署名方式** — 同一マシンの Bash から鍵を隔離できず見せかけの安全にしかならず、全マシンでの鍵運用コストにも見合わないため不採用(§Decision.2)。
137
+ - **④ を blocking にする案** — パターン検査は回避可能であり、blocking 化は「すり抜け=安全」という誤った信頼を生むため advisory に留めた(§Decision.3.④)。
138
+ - **インジェクション専用の独立防御層を新設する案** — インジェクションは既存の「洗浄を試みるエージェント」脅威モデルに還元できるため、別枠を設けず 5 層防御の延長で対処する方針を採った(§Context)。
139
+
140
+ ## 関連要件・文書
141
+
142
+ - ADR-006(エージェント非依存設計原則)— 本 ADR の脅威モデルの基礎
143
+ - ADR-013(storyReflection ゲート)— ローカル fast-path と CI 再検証の関係の先行例
144
+ - `docs/guide/layer-model.md` §L0 — L0 の実体(hook / husky)
145
+ - `phasegate.config.json` — 品質設定の Single Source of Truth
@@ -111,7 +111,7 @@ Additional hooks can be placed in `.claude/scripts/`:
111
111
 
112
112
  | Script | Behavior |
113
113
  |--------|----------|
114
- | deny-check.sh | Block dangerous git/bash commands (git reset --hard, rm -rf, etc.) |
114
+ | deny-check.sh | Enforce the agent command policy: git subcommands are default-deny (allowlist), plus explicit bash deny patterns (rm -rf, sudo, etc.). See [Agent git command allowlist](#agent-git-command-allowlist). |
115
115
  | format-settings-hook.sh | Auto-format settings.json on edit |
116
116
  | format-typescript-hook.sh | Auto-format TypeScript files (Biome / ESLint+Prettier) |
117
117
  | analyze-errors-hook.sh | Detect tsc/lint errors on TypeScript edit |
@@ -135,3 +135,52 @@ Additional hooks can be placed in `.claude/scripts/`:
135
135
  | formatterArgs | Arguments passed to formatter | ["check", "--write"] |
136
136
 
137
137
  Legacy `.harness-hooks.yml` and old Fuse hook files are not part of the current install lifecycle. Keep them only for archived integrations; new setup should use `install`, `doctor`, `reconcile`, `lint`, and `validate`. <!-- @work-item-id WI-157 -->
138
+
139
+ ## Agent git command allowlist
140
+
141
+ <!-- @work-item-id WI-253 -->
142
+
143
+ `deny-check.sh` runs as a `PreToolUse` hook on every `Bash` tool call and blocks disallowed commands by exiting with code 2. For git it uses a **default-deny allowlist** rather than an enumerated deny list.
144
+
145
+ ### Why allowlist instead of deny list
146
+
147
+ An enumerated deny list always leaks. The original policy denied `git checkout*`, `git reset*`, `git merge*`, `git rebase*`, `git cherry-pick*`, `git revert*`, `git clean*`, and `git stash*`, but `git switch` was never listed — so an agent could change the working-tree/branch state through `git switch`, defeating the intent of the deny rules (no history or working-tree mutation). Overly broad globs also caused false positives: `git merge*` blocked the read-only `git merge-base`.
148
+
149
+ Inverting to an allowlist makes the policy fail closed: any git subcommand not explicitly permitted is denied, including future subcommands the deny list would not have known about.
150
+
151
+ ### Allowed git subcommands
152
+
153
+ The permitted set lives in `GIT_ALLOWED_SUBCOMMANDS` in `.claude/scripts/deny-check.sh`. It covers read-only inspection, staging/commit/tag creation, and worktree/fetch operations:
154
+
155
+ ```
156
+ status log show diff add commit tag restore rev-parse rev-list
157
+ merge-base branch worktree fetch grep cat-file ls-files ls-tree
158
+ ls-remote config init remote describe blame shortlog
159
+ symbolic-ref for-each-ref name-rev check-ignore check-attr
160
+ stripspace var help version whatchanged push
161
+ ```
162
+
163
+ History- and working-tree-mutating subcommands are intentionally **absent** so they fail closed, including: `checkout`, `switch`, `reset`, `rebase`, `merge`, `cherry-pick`, `revert`, `stash`, `clean`, `update-ref`, `reflog`, `filter-branch`, `replace`, and `am`.
164
+
165
+ ### How the subcommand is extracted
166
+
167
+ The check tolerates global options placed before the subcommand, so evasion via flag stuffing does not bypass it. All of the following resolve to their real subcommand (`merge`, denied):
168
+
169
+ ```
170
+ git merge x
171
+ git -C /repo merge x
172
+ git --no-pager merge x
173
+ git -c core.pager=cat merge x
174
+ ```
175
+
176
+ Denied commands smuggled behind chaining/substitution operators (`&&`, `|`, `;`, `$( )`, subshells) are also caught, because the hook inspects each command segment independently.
177
+
178
+ ### Adding a subcommand
179
+
180
+ Default-deny means a genuinely needed subcommand must be added by a human. Edit `GIT_ALLOWED_SUBCOMMANDS` in `.claude/scripts/deny-check.sh` and add the subcommand name. The block message names the rejected subcommand and points here, e.g.:
181
+
182
+ ```
183
+ Security policy violation: git subcommand 'switch' is not in the agent allowlist (default-deny for git). ...
184
+ ```
185
+
186
+ Note: `git push` is on the allowlist so user-directed pushes are not hard-blocked by this hook; gating pushes further (e.g. an interactive confirmation) is handled by the harness permission layer, not by `deny-check.sh`.
@@ -36,7 +36,7 @@ npm install
36
36
  npx phasegate init --name <project-name>
37
37
  ```
38
38
 
39
- This deploys 30 skills to `skills/`, creates the agent-facing skill links (for example `.claude/skills/` or `.codex/skills/`), and generates `phasegate.config.json`.
39
+ This deploys 29 skills to `skills/`, creates the agent-facing skill links (for example `.claude/skills/` or `.codex/skills/`), and generates `phasegate.config.json`.
40
40
 
41
41
  `init` is the legacy-compatible bootstrap path for new projects. It also runs the structured install path for the selected agent target so `CLAUDE.md` and/or `AGENTS.md` receive a PhaseGate managed section. Use `install` when the project may already have hooks, package scripts, or CI files that should be preserved. <!-- @work-item-id WI-174 -->
42
42
 
@@ -174,7 +174,7 @@ No. `allowedCategories` is a fixed enum (`bugfix`, `docs`, `test`, `config`). If
174
174
 
175
175
  ## Related
176
176
 
177
- - [Skills Overview](skills-overview.md) — full catalogue of 30 skills
177
+ - [Skills Overview](skills-overview.md) — full catalogue of 29 skills
178
178
  - [Layer Model](layer-model.md) — L0 through L4 defence layers
179
179
  - [Configuration](configuration.md) — `quickMode` configuration reference
180
180
  - `skills/quick-implementor/SKILL.md` — the Quick Mode skill definition