Repository navigation
Closed
Labels
phase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "VC preflight の pnpm package-script 実行を、exact argv・trusted executable・manifest integrity・共有 gate descriptor で fail-closed にする"
change_kind: codeParent Issue
none
Parent Goal Ref
- Goal: Issue contract から実行する pnpm package script の認可対象と実行対象を一致させる。
- Desired Destination: N/A(単独改善)
Current Validated Scope
baseline_vc_preflight.pyの pnpm 実行境界と、triage_contract_blockers.pyの pnpm evidence consumer- typecheck:e2e / lint:docs の exact request argv、root manifest、pre/post hook、承認済み closure、validator digest の integrity 検証
- producer と consumer が同じ descriptor を使用する共有 registry と、その security-boundary regression test
Remaining Parent Gaps
なし(単独改善 Issue)。
Runtime Verification Applicability
- decision: not_applicable
- reason: subprocess の引数・manifest integrity・evidence schema は pytest の mock で決定論的に検証でき、外部サービスや実ブラウザの動作検証を必要としない。
Outcome
typecheck:e2e と lint:docs は、shared descriptor が exact request argv、trusted absolute pnpm、root manifest の script/hook/closure/digest を実行前に検証した場合だけ pnpm run <exact-name> として起動され、producer と triage consumer が同じ gate evidence を fail-closed に消費する状態。
In Scope
.claude/skills/issue-contract-review/scripts/pnpm_gate_registry.pyを追加し、二つの gate の gate ID、exact request argv、固定 env delta、package manager、承認済み script closure、hook policy、validator digest を唯一の authority として定義する。baseline_vc_preflight.pyを shared registry の consumer に変更し、大小文字を保持した exact argv だけを認可する。trusted pnpm executable を一度 realpath へ解決し、trusted な regular executable でない候補、repo/worktree/tmp 配下、または group/world writable な候補を reject する。- producer は実行前に root
package.jsonの packageManager、対象 script、closure の script body、pre/post hook 不在、lint:docsvalidator digest を照合し、成功時だけ[trusted_absolute_pnpm, "run", exact_script_name]を{"CI": "true"}だけの env delta で起動する。 - producer result に schema version、gate ID、exact request argv、launch argv、manifest/closure integrity digest、runner env delta を含める。
triage_contract_blockers.pyを shared registry と producer gate evidence の consumer に変更する。raw command を別 allowlist で再解釈せず、evidence 欠落・schema 不正・gate ID/argv/hash 不一致では retry action を返さない。.claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.pyを追加し、trusted launch argv、env delta、拒否 argv、manifest/hook/closure/digest drift、producer-to-triage E2E、非 pnpm regression を検証する。- 既存の
.claude/skills/issue-contract-review/tests/test_pnpm_allowlist_expansion.pyと.claude/skills/impl-review-loop/tests/test_triage_contract_blockers_typecheck_lint_docs_gate.pyを、shared descriptor と producer evidence の契約に合わせて回帰検証する。 - 既存の
.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.pyと.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_pnpm_no_tty.pyを、trusted absolute pnpm、root manifest integrity、追加引数の事前 block を期待する回帰テストへ更新する。 - PR 実装: baseline_vc_preflight.py の pnpm allowlist に typecheck:e2e / lint:docs を追加する #1529 の指定レビューコメントを修正根拠として扱う。実装: baseline_vc_preflight.py の _canonical_pnpm_gate() を大文字小文字区別ありの exact-match に是正する #1524 / 実装: pnpm canonical gate 一覧を共有モジュールへ一本化する #1525 の open scope を自動変更・close しない。
Out of Scope
package.json、pnpm-lock.yaml、Node dependency、CI workflow の変更- pnpm 以外の command family の共通化または allowlist 拡張
- 任意の package script を動的に許可する仕組み
- trusted executable policy を緩める fallback(repo/worktree/tmp または user/group/world writable path の許可)
- 実装: baseline_vc_preflight.py の _canonical_pnpm_gate() を大文字小文字区別ありの exact-match に是正する #1524 / 実装: pnpm canonical gate 一覧を共有モジュールへ一本化する #1525 の本文・状態・依存関係の変更
Acceptance Criteria
- AC1:
pnpm_gate_registry.pyが typecheck:e2e / lint:docs の唯一の authority となり、producer と triage consumer の両方が gate ID、exact request argv、{"CI": "true"}、manifest/closure/hook/digest policy を同じ descriptor から取得する。 - AC2:
./pnpm lint:docs、/tmp/pnpm typecheck:e2e、node_modules/.bin/pnpm lint:docs、pnpm TYPECHECK:E2E、pnpm LINT:DOCS、追加引数付きpnpm lint:docsはすべて実行前に blocked となり、script subprocess を起動しない。 - AC3: trusted runner は realpath の absolute pnpm を使って
pnpm run <exact-name>だけを起動し、root manifest の packageManager/script/closure、pre/post hook 不在、validator digest を実行前に照合する。欠落・hook・drift では起動せず blocked となる。 - AC4: producer は gate evidence を出力し、triage consumer は raw command を独自 canonicalize せずその evidence と shared registry を検証する。二 gate の producer-to-triage E2E と全拒否 argv で accept/reject 集合が一致し、不整合時には retry action を返さない。
- AC5: security-boundary test は return code、classification、decision、scope class、runner env delta、script subprocess call count を明示 assert し、非 pnpm VC の既存分類も regression しない。
Verification Commands
# AC1
$ uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py::test_registry_is_the_only_pnpm_gate_authority
# AC2
$ uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py::test_noncanonical_pnpm_requests_are_blocked_without_launch
# AC3
$ uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py::test_manifest_hook_and_closure_drift_blocks_before_launch
# AC4
$ uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py::test_producer_evidence_round_trips_to_triage
# AC5
$ uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.pyAllowed Paths
.claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py.claude/skills/impl-review-loop/scripts/triage_contract_blockers.py.claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py.claude/skills/issue-contract-review/tests/test_pnpm_allowlist_expansion.py.claude/skills/impl-review-loop/tests/test_triage_contract_blockers_typecheck_lint_docs_gate.py.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py.claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_pnpm_no_tty.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- trusted pnpm executable を repo/worktree/tmp または user/group/world writable path から許可する必要が生じた場合
- manifest/hook/closure/validator digest を検証せずに package script を許可する必要が生じた場合
- 実装: baseline_vc_preflight.py の _canonical_pnpm_gate() を大文字小文字区別ありの exact-match に是正する #1524 / 実装: pnpm canonical gate 一覧を共有モジュールへ一本化する #1525 と同一 shared registry / canonicalization surface の C3 scope collision を解消できない場合
- gate ID、trusted executable policy、manifest integrity policy の変更が必要になった場合
Required Skills
なし
Required Design References
- docs/dev/workflow.md#Issue contract を作業計画の正本として扱う条件
- docs/dev/agent-skill-boundaries.md
Scope Delta
- 追加: exact argv、trusted executable、manifest/hook/closure/digest integrity、producer-to-triage evidence を含む pnpm package-script security boundary
- 削除: 単なる allowlist リテラル追加だけで実行対象を許可する方針
- 変更: producer と consumer の別々の canonical gate list を shared descriptor と evidence validation に置換
Metadata
Metadata
Assignees
Labels
phase/implementationImplementation phase
Activity
squne121 commentedon Jul 14, 2026
判定
REQUEST CHANGES / BLOCK。現状の契約では実装開始しない方がよいです。
typecheck:e2eとlint:docsが現在のpackage.jsonに存在する点と、毎回pr_review_onlyへ逃がす運用を減らしたい意図は妥当です。実際、両スクリプトは定義されています。しかし #1511 は、これらを「文字列を2件allowlistへ追加するだけの変更」と扱っています。実際には以下を同時に変更します。
CI=true注入Issue本文はこれらを契約しておらず、記載済みのStop Conditionsである「Allowed Paths外の変更」「下流への波及」「判定ロジック変更」が、すでに発生しています。
Blocker 1 — 下流consumerが新しいgateを拒否する
最も具体的な機能破綻です。
baseline_vc_preflight.py側で2件をcanonical gateに追加すると、no-TTYエラーもpackage_manager_no_tty_promptとして分類されます。しかし、後段のtriage_contract_blockers.pyはcanonical pnpm gateを以下の4件に固定しています。それ以外は
non_canonical_pnpm_gateとしてfail-closedで拒否します。したがって、新しい2件がno-TTY blockerになった場合、preflightでは正規gate、triageでは非正規gateというcontract splitが発生します。これは #994 / PR #1001 で、failing gateに対応した正確なargvを返すために意図的に導入された安全境界です。#1511のAllowed Pathsには、このconsumerとそのテストが入っていません。
必須修正
canonical gate一覧を共有モジュールへ一本化する。
少なくとも以下をAllowed Pathsへ追加する。
.claude/skills/impl-review-loop/scripts/triage_contract_blockers.py.claude/skills/impl-review-loop/tests/test_triage_contract_blockers_pnpm_gate.py新2gateについて、no-TTY payloadがconsumerでrejectされず、元のargvを保持するテストを追加する。
Blocker 2 —
pnpm <name>は固定された安全コマンドではないpnpm公式仕様では、
[pnpm](https://pnpm.io/pnpm-cli) lint:docsのような形式はpnpm run lint:docsの短縮形です。また、該当scriptが存在しなければ、pnpmは同名コマンドをshell commandとして実行します。つまり「現在のpackage.jsonにscriptが存在する」ことを静的に確認しただけでは、実行時の安全性は保証されません。([pnpm]1) (pnpm)さらに
enablePrePostScriptsの既定値はtrueなので、将来prelint:docsやpostlint:docsが追加されると、それらも自動実行されます。(pnpm)現在の
lint:docs自体も単一のread-only commandではなく、3つのpackage scriptを&&で連鎖実行する複合gateです。validate-roadmap-refs.mjsは現状ではファイル読取・YAML解析・stat検査を行う非変更型validatorですが、その実装内容はallowlist側で固定も検証もされていません。必須修正
安全側の実装は次のいずれかです。
typecheck:e2eだけを今回追加し、複合scriptであるlint:docsは引き続きpr_review_onlyにする。package script専用runnerを設け、実行前に以下を検証する。
package.jsonにscript keyが完全一致で存在する。pre<name>/post<name>が存在しない、または明示的に承認されている。lint:docsの推移的script closureが承認済み定義と一致する。pnpm run <exact-name>を固定argvで実行し、未知コマンドfallbackを使わない。Blocker 3 — 実行ファイルの同一性を検証していない
現在のcanonical判定は、実行ファイルのbasenameだけを見ています。またscript名を小文字化して認可しています。
このため、少なくとも静的判定上は次がcanonical gateとして通ります。
実際に実行されるargvは元の文字列なので、認可した名前と実行対象が一致しません。
Python公式ドキュメントも、最大限の信頼性を得るには実行ファイルの完全パスを使用するよう推奨しており、POSIXでは
cwdとenv["PATH"]が実行ファイル解決に影響するとしています。([Python documentation]3)必須修正
argv[0] == "pnpm"の完全一致にする。shutil.which("pnpm")で一度解決し、解決済み絶対パスを使用する。pnpm、symlink、想定外PATH解決をどう扱うかcontract化する。[ ["./pnpm", "typecheck:e2e"], ["/tmp/pnpm", "lint:docs"], ["pnpm", "TYPECHECK:E2E"], ["pnpm", "lint:docs", "--if-present"], ]Blocker 4 — ACとVerification Commandsがfalse-greenになる
現在のAC1~AC3は単なる文字列検索です。
typecheck:e2eの出現数しか検査せず、lint:docsのenv entryを検査しない。rg -cを契約検証に使うのは不適切です。直接Pythonオブジェクトをimportして完全一致をassertする必要があります。さらに以下が必要です。
expected_pass / regression_gate / goblocked / regression_gatepackage_manager_no_tty_promptbaseline-expect: passがno-TTY分類を上書きしないMajor 5 — 2つのgateを同じ扱いにする根拠がない
typecheck:e2eは現在、tsc -p ... --noEmitだけの比較的単純な静的gateです。一方、lint:docsは複数script、複数Nodeツール、repository-local validatorを経由します。両者は実行面も変更リスクも異なります。また、起票理由となった #1283 はすでに
# preflight-scope: pr_review_onlyで解決済みであることを、#1511自身が明記しています。したがって、「baseline preflightで必ず実行できなければならない」という緊急性はありません。推奨分割
typecheck:e2eをcanonical baseline gateへ追加するIssue。lint:docsのscript closureとpre/post policyを設計した上で追加可否を判断するIssue。修正後に最低限必要なAC
{"CI": "true"}のみ。rgの出現数ではなく、pytestによる構造・動作検証をVerification Commandsにする。結論として、#1511は単純なallowlist拡張Issueではありません。現在のStop Conditionsに従って一度停止し、少なくともconsumer同期と実行対象同一性を契約へ追加してから実装すべきです。
squne121 commentedon Jul 14, 2026
OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/1511#issuecomment-4968662574)を反映して本 Issue 本文を更新しました。
主な変更点:
.claude/skills/impl-review-loop/scripts/triage_contract_blockers.pyと対応するテストファイルを追加し、_CANONICAL_PNPM_GATESの drift 防止を Scope に含めましたtriage_contract_blockers.py側の canonical gate 追加と no-TTY blocker 側の挙動検証を明示的な AC として追加しました_canonical_pnpm_gate()の大文字小文字非区別(.lower())の是正と、allowlist の共有 canonical gate モジュールへの一本化は判定ロジック変更に該当するため、本 Issue の Stop Conditions に抵触すると判断し Out of Scope とし、follow-up Issue での対応を推奨する記載を追加しましたsqune121 commentedon Jul 14, 2026
issue-refinement-loop 完了報告
判定: approve(deterministic checker
check_issue_contract.pyC1〜C11 全て PASS/NA、Runtime Verification Applicability: not_applicable)OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/1511#issuecomment-4968662574)を反映した本文更新は完了済みです。
Follow-up Issue 起票
anchor comment で指摘されたアルゴリズム変更・アーキテクチャ変更に該当する2項目は、本 Issue の Stop Conditions に抵触するため follow-up Issue へ分離しました。
_canonical_pnpm_gate()の大文字小文字非区別を exact-match に是正するsqune121 commentedon Jul 14, 2026
Contract Review Result
squne121 commentedon Jul 15, 2026
Contract Review Result
fix: pnpm package-script gate の実行境界を検証する (#1511)
squne121 commentedon Jul 15, 2026
Contract Review Result
fix: pnpm gate security test の静的検証を通す (#1511)
squne121 commentedon Jul 15, 2026
implement-issue: 実装完了 (2026-07-15T17:10:00Z)
.claude/worktrees/issue-1511-pnpm-allowlist-expansionworktree-issue-1511-pnpm-allowlist-expansion4f7df17b549611d5ec5770637fbe55172826a2c3squne121 commentedon Jul 15, 2026
implement-issue: 実装完了(訂正)
.claude/worktrees/issue-1511-pnpm-allowlist-expansionworktree-issue-1511-pnpm-allowlist-expansion4f7df17b549611d5ec5770637fbe55172826a2c3ok(6 files、violations 0)squne121 commentedon Jul 15, 2026
Contract Review Result
test: pnpm gate 境界の既存回帰を更新する (#1511)
squne121 commentedon Jul 15, 2026
PR #1529 レビュー指摘の修正結果
scripts/tests/test_baseline_vc_preflight.pyとscripts/tests/test_baseline_vc_preflight_pnpm_no_tty.pyの既存回帰期待を、trusted absolute pnpm、root manifest integrity、追加引数の事前 block に合わせて更新した。検証結果:
status: ok、violations 0(fresh snapshot #4983417768、HEAD61f49cf824aa22fcb3ed7d6bde7efd1797ecaa2d)PR HEAD:
61f49cf824aa22fcb3ed7d6bde7efd1797ecaa2d実装: baseline_vc_preflight.py の pnpm allowlist に typecheck:e2e / lint:…