Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1404"
origin_issue: "#1395"
derived_from_pr: "#1407"
anchor_review_comment: "https://github.com/squne121/loop-protocol/issues/1417#issuecomment-4935423235"
goal_ref: "root temporary residue を削除権限へ昇格せず、post-merge-cleanup が read-only で機械可読に分類できる contract を実装する"
change_kind: workflowParent Issue
Parent Goal Ref
- Immediate Parent: 実装: agent の root temporary residue を hook と docs で防止する #1404 / PR feat: add root temporary residue advisory (#1404) #1407 の Not controlled follow-up。
- Origin: 実装: issue-refinement-loop canonical runtime の hook allowlist を整備する #1395 は root temporary residue cleanup family の origin provenance として扱う。
- Owner Decision: 実装: root temporary residue cleanup classifier を構造化する #1417 は削除 executor ではなく read-only classifier に限定する。classification result は deletion authorization ではない。
Current Validated Scope
.tmp//.temp//.tmp-*と approved temporary root の residue を read-only scan し、temp_residue_classification/v1として構造化出力する。temp_residue_owner/v1marker schema を定義するが、marker は deletion authority ではなくeligible_for_deleteadvisory の補助情報に限定する。- schema catalog / consumer inventory / post-merge-cleanup integration point を同一 PR で更新する。
- Git tracked / ignored / unknown / mixed state、scan failure、symlink、special file、malformed marker、duplicate JSON key、path containment failure は fail-closed に
report_onlyとして分類する。
Remaining Parent Gaps
- Issue 実装: agent の root temporary residue を hook と docs で防止する #1404 は advisory hook と folder policy を導入済みだが、root temporary residue 専用の structured classifier と ownership marker parser は未実装。
- PR feat: add root temporary residue advisory (#1404) #1407 は cleanup classifier を follow-up として 実装: root temporary residue cleanup classifier を構造化する #1417 に残している。
- 実削除 executor は本 Issue の scope 外であり、必要なら別 Issue で削除直前再検査・authorization source・dir-fd I/O・postcondition を設計する。
Outcome
post-merge-cleanup が root temporary residue を temp_residue_classification/v1 として read-only 分類できる。classifier は filesystem mutation を行わず、各 entry に recommendation: report_only | eligible_for_delete を返す。serialized classification result は deletion authorization ではなく、実削除 executor へそのまま渡してはならない。
In Scope
scripts/agent-ops/temp_residue_classifier.pyによる root temporary residue の read-only scan / classification。scripts/agent-ops/temp_residue_marker.pyによるtemp_residue_owner/v1marker parse / validation helper。schemas/temp_residue_classification_v1.schema.jsonとschemas/temp_residue_owner_v1.schema.jsonの追加。schemas/catalog.yamlと schema catalog tests の更新。- approved root / denied alias / marker state matrix の実装と docs 更新。
tracked_state/ignored_stateをnone | some | all | unknownで表現する Git state integration。- bounded scan、partial result、scan errors、stable ordering、secret-safe output の実装。
- post-merge-cleanup の classification script / skill / folder policy / agent boundary docs への read-only result integration。
- classifier が
os.unlink/os.rmdir/shutil.rmtree/ destructive subprocess を呼ばないことの regression test。 - CI/test lane 変更として
CI_TEST_PERFORMANCE_DECISION_V1を PR 証跡に残す。
Out of Scope
- filesystem deletion、
cleanup_exec.pyの destructive grammar 拡張、shutil.rmtree/ unlink / rmdir の導入。 - classification result を authorization token として利用すること。
- root temporary alias の作成 block / deny hook 変更。
- deployment / distribution / publish pipeline の変更。
- repo-wide untracked file sweep。
- Issue 実装: agent の root temporary residue を hook と docs で防止する #1404 の advisory payload schema 変更。
Acceptance Criteria
- AC1:
temp_residue_classification/v1schema は top-levelscan_status,generated_at,project_root,entries,errorsを定義し、entry はpath,folder_class,entry_type,tracked_state,ignored_state,ownership_marker,recommendation,primary_reason_code,reason_codes,observationを持つ。 - AC2:
temp_residue_owner/v1schema はmarker_id,repository,session_id,target_relpath,created_at,expires_at,nonce,producerを定義し、duplicate JSON key、NaN / Infinity、oversized marker、symlink marker、group / other writable marker を invalid として扱う。 - AC3: classifier は read-only であり、
os.unlink、os.rmdir、shutil.rmtree、mutation subprocess、cleanup_exec.pyの destructive operation を呼ばない。 - AC4: approved roots と denied aliases の matrix は、root 自体・marker 不明 child・malformed marker・foreign session・target mismatch・symlink・special file・tracked content present を
report_onlyに分類する。denied alias 配下は valid marker があっても初期実装ではreport_onlyとする。 - AC5: approved root 配下の valid marker / current session / target match / untracked / non-symlink / bounded scan success の session subdirectory だけ
eligible_for_deleteになり得る。ただしこれは advisory であり、削除権限ではない。 - AC6: directory tree の Git state は boolean ではなく
tracked_state: none | some | all | unknownとignored_state: none | some | all | unknownで表現し、Git command failure / timeout / undecodable path はunknown+report_onlyになる。 - AC7: scan は
max_entries,max_depth,max_marker_bytes,deadline_secondsを持ち、permission denied / timeout / partial traversal / invalid filename ではscan_status: partial | errorとerrors[]を返し、該当 entry はreport_onlyになる。 - AC8:
reason_codesは複数理由を deterministic order で保持し、primary_reason_codeは priority table に基づく。singlereason_codeだけに依存しない。 - AC9: post-merge-cleanup skill の
classify-git-state.py --format jsonまたは同等 entrypoint はtemp_residue_classificationfield を出力でき、empty result と classifier failure を区別する。 - AC10: schema catalog / consumer inventory は
temp_residue_classification/v1とtemp_residue_owner/v1の producer / consumer / compatibility / required tests を登録する。 - AC11: docs は
tmp/,.claude/tmp/,.tmp/,.temp/,.tmp-*,.claude/worktrees/の folder class / lifecycle / cleanup authority / publication rule を read-only classifier の実装済み挙動と一致させる。 - AC12: PR は
CI_TEST_PERFORMANCE_DECISION_V1を含み、schemas/**と.github/ci/python-test-plan.jsonの変更に対するpython_unit/contract_artifactlane evidence を提示する。
Verification Commands
# AC1
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "classification_schema"
# AC2
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "owner_marker_schema"
# AC3
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "read_only_no_mutation"
# AC4
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "report_only_matrix"
# AC5
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "eligible_for_delete_advisory"
# AC6
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "git_state_mixed_unknown"
# AC7
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "scan_limits_partial"
# AC8
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "reason_codes_priority"
# AC9
# preflight-scope: runtime_only
$ uv run --locked pytest tests/agent_ops/test_temp_residue_classifier.py -q -k "post_merge_cleanup_integration"
# AC10
# preflight-scope: runtime_only
$ uv run --locked pytest schemas/tests/test_catalog.py .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py -q
# AC11
# preflight-scope: runtime_only
$ rg -n "temp_residue_classification" .claude/skills/post-merge-cleanup/SKILL.md docs/dev/repository-folder-policy.md docs/dev/agent-skill-boundaries.md
# AC12
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/ci/python_test_plan.py --emit scope-argv --format jsonAllowed Paths
scripts/agent-ops/temp_residue_classifier.pyscripts/agent-ops/temp_residue_marker.py.claude/skills/post-merge-cleanup/scripts/classify-git-state.pytests/agent_ops/test_temp_residue_classifier.pyschemas/temp_residue_classification_v1.schema.jsonschemas/temp_residue_owner_v1.schema.jsonschemas/catalog.yamlschemas/tests/test_catalog.py.claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py.github/ci/python-test-plan.json.claude/skills/post-merge-cleanup/SKILL.mddocs/dev/repository-folder-policy.mddocs/dev/agent-skill-boundaries.mddocs/dev/schema-governance.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- deletion / destructive authorization が AC 達成に必要と判明した場合
cleanup_exec.pyの destructive grammar 拡張が必要と判明した場合- marker を deletion authority として扱う必要が出た場合
- trusted session identity source / local ledger / nonce consume を同一 Issue で設計する必要が出た場合
- distribution / publish pipeline 変更が必要と判明した場合
- 新規 Issue の起票が必要と判断した場合
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
ci-test-performance
Required Design References
docs/dev/repository-folder-policy.md.claude/skills/post-merge-cleanup/SKILL.mddocs/dev/agent-skill-boundaries.mddocs/dev/schema-governance.mddocs/dev/test-lane-policy.md
Runtime Verification Applicability
decision: immediate
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC7
- AC8
- AC9
- AC10
- AC11
- AC12
execution_environment:
cli_tools:
- python3
- uv
- rg
auth_required: false
network_required: false
skip_conditions:
- "local repository checkout が存在しない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由の成功を PASS に変換しない"
artifact_requirements:
- "pytest output"
- "schema catalog test output"
- "python_test_plan.py JSON output"
- "CI_TEST_PERFORMANCE_DECISION_V1"Scope Delta(任意)
parent_issueは 実装: issue-refinement-loop canonical runtime の hook allowlist を整備する #1395 から 実装: agent の root temporary residue を hook と docs で防止する #1404 に変更する。実装: issue-refinement-loop canonical runtime の hook allowlist を整備する #1395 は origin provenance としてorigin_issueに残す。action: delete_owned_subdirectoryは削除し、recommendation: report_only | eligible_for_deleteに置き換える。cleanup_exec.py/materialize_cleanup_contract.py/worktree_catalog.py/tests/codex/test_cleanup_exec_branch_only.pyは destructive cleanup / worktree cleanup 責務のため Allowed Paths から外す。schemas/**、schema catalog、dedicated classifier tests、post-merge-cleanup classify integration を Allowed Paths に追加する。
Delivery Rule
- 1 Issue = 1 PR
- Issue 実装: agent の root temporary residue を hook と docs で防止する #1404 / PR feat: add root temporary residue advisory (#1404) #1407 の Not controlled follow-up として扱う。
- classifier は read-only observation と recommendation だけを返す。
eligible_for_deleteは「別 executor が削除直前に再検査する候補」を意味し、削除権限ではない。- PR 本文には schema consumer inventory と
CI_TEST_PERFORMANCE_DECISION_V1を含める。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 10, 2026
判定: REQUEST_CHANGES
Issue #1417 の方向性、すなわち「advisory 文書しか存在しない root temporary residue の判定を、機械可読な read-only classifier に昇格する」こと自体は妥当です。PR #1407 も、ownership marker に基づく classifier を未実装の follow-up として #1417 に明示的に残しています。
ただし、現行契約のまま実装すると、自己申告可能な marker と観測時点の path containment を、削除権限に事実上昇格させることになります。これは、現在の
cleanup_exec.py/cleanup_contract_v3.pyが持つ narrow executor、nonce、TTL、one-shot claim、dir-fd、O_NOFOLLOWという安全水準を下回ります。現時点では実装開始不可です。少なくとも以下の P0 を Issue 本文で解消してください。
P0 / approval blocker
P0-1.
TEMP_RESIDUE_CLASSIFICATION_V1が「schema」として定義されていない#1417 は
TEMP_RESIDUE_CLASSIFICATION_V1として以下の field を挙げています。しかし、型、必須性、enum、nullability、配列の envelope、互換性、複数理由の優先順位、scan failure の表現、consumer が未定義です。さらに Stop Conditions は「固定契約のキー集合・スキーマ・型定義を変更する必要が出たら停止」としていますが、そもそもその固定定義が本文に存在しません。
このリポジトリでは producer / consumer 境界を越える machine-readable contract は schema と定義され、新規 schema には consumer inventory が必須です。inventory 欠落や未更新 consumer は明示的な approval blocker です。
加えて、今回導入するものは一つではありません。
classification output schema
ownership marker schema
の最低二 schemaです。
Issue #1418 は
repo_temp_folder_advice/v1の catalog 登録だけを扱い、cleanup classifier は明示的に Out of Scope です。したがって、#1418 が #1417 の schema governance を処理することはありません。必須修正
Allowed Paths に少なくとも以下を追加してください。
また、PR の Schema Consumer Inventory 対象を Issue 本文で先に固定すべきです。
P0-2. read-only classification と destructive authorization が混同されている
Issue は goal を「read-only classification contract」と呼ぶ一方、AC3 では
delete_owned_subdirectoryをactionとして出力し、Delivery Rule では cleanup executor の削除範囲拡大にも言及しています。この命名では、consumer が classifier の出力をそのまま deletion authorization と解釈できます。
現在の
cleanup_exec.pyは、worktree と branch の削除だけを行う single narrow authorization boundary です。root branch、worktree catalog、clean state、PR merged、head branch、linked issue を毎回検査し、正確なgit worktree removeとgit branch -dだけを内部実行します。ここへ temporary directory deletion を追加するのは単なる classifier 追加ではありません。少なくとも以下が変わります。
destructive operation grammar
guard の exact command class
authorization source
postcondition
replay / race model
result schema
failure recovery
platform capability boundary
推奨する分離
#1417 は分類だけにしてください。
action: delete_owned_subdirectoryは使用しない方が安全です。classifier は次を保証します。
実削除は別 executor が、削除直前に同じ検査をすべて再実行してから行う必要があります。
同一 Issue に削除まで含めるなら、現在の Allowed Paths と Out of Scope は全面的な再設計が必要です。現 Issue の Stop Conditions に従えば、その場合は現在の contract を停止・再 refinement するのが正しい処理です。
P0-3. ownership marker の真正性と threat model が未定義
現行 AC3 は、marker の
session idとtarget relative pathが一致すれば削除候補になり得るとしています。しかし、誰が marker を作成できるのか、session id の正本が何か、marker の replay や後付け作成をどう扱うかが定義されていません。既存の
agent_session_manifest/v1では、actor.session_idは optional / nullable です。またproducer.kindは self-claim であり、schema だけでは真正性を証明しないと明記されています。したがって、単に次が一致しても、
「その session がその directory を作成した」ことの証明にはなりません。同じ OS user で動く別 agent は marker を後から作成できます。
既存 cleanup V3 はこの問題に対して、nonce、短い TTL、command hash、atomic rename による one-shot consume、symlink-safe dir-fd I/O を使っています。
Issue 本文で固定すべき threat model
次のどちらかを明記してください。
A. accidental isolation model
この場合でも、marker は deletion authority ではなく
eligible_for_deleteの補助情報に留めるべきです。B. authorization model
この場合は dedicated materializer と executor が必要です。
marker の最低要件
ファイル側の検査も必要です。
Python の標準
json.loads()は duplicate key を拒否せず、最後の値だけを採用します。そのまま marker parser に使うと、レビュー時に見た値と consumer が採用する値が異なる marker を許容します。object_pairs_hookで重複を明示的に拒否すべきです。(Python documentation)P0-4.
Path.resolve(strict=False)は削除時の containment 保証ではない現在の skill は temporary cleanup の required check として次を記載しています。
同時に、専用 classifier / marker parser は未実装だと明記しています。
Path.resolve()は観測時点の pathname を解決するだけです。classification 後、削除前に directory が symlink、bind mount、別 inode へ交換されれば、古い classification は削除対象の identity を保証しません。現在の cleanup contract が、platform capability を検査したうえで
O_DIRECTORY、O_NOFOLLOW、dir-fd rename / unlink を要求し、未対応 platform では fail-closed にするのは、この種の問題を避けるためです。Python の
shutil.rmtree()は fd-based API を利用できる platform では symlink attack resistant な実装を使えますが、対応状況は platform 依存です。またdir_fdを受け取れるからといって、classification 時の path が同一 inode のままとは限りません。(Python documentation)Linux では
openat2()のRESOLVE_BENEATHが dir-fd 外への escape を拒否し、RESOLVE_NO_SYMLINKSが全 path component の symlink 解決を拒否します。RESOLVE_NO_XDEVは mount point 越えも拒否できます。(man7.org)必須境界
classifier が read-only なら、次だけで構いません。
実削除 executor では最低限、削除直前に以下を行う必要があります。
classification result に
st_dev/st_ino/mtime_nsを含めることは再検証の補助になりますが、それ自体を権限証明にはしてはいけません。P0-5.
tracked/ignoredの boolean は directory tree を正しく表現できないdirectory には、次のような混在があり得ます。
この directory に対して、
としても、何を意味するか決まりません。
最低でも以下の state が必要です。
また、Git の ignore 判定は repository の
.gitignoreだけではありません。.git/info/excludeと user-levelcore.excludesFileも有効です。したがってignoredは「repo policy 上の分類」ではなく、その checkout での effective Git ignore decision として定義する必要があります。(Git)現在の
classify-git-state.pyはgit status --shortをsplitlines()で解析しており、ignored files を取得せず、newline 等を含む pathname の機械解析にも適していません。Git は
-z使用時に pathname を quote せず NUL terminate します。逆に-zなしでは unusual characters が quote されます。(Git)推奨 command boundary
注意点:
argv 配列形式を使う
pathspec と option の境界に
--を置くwildcard を literal pathspec として扱う
stdin / stdout とも NUL 区切り
Git failure は
unknown+report_onlyGit command が空出力でも、失敗と「該当なし」を区別する
reason_codeも単数では不十分です。tracked_mixedとnested_symlinkが同時に成立する場合があるため、次のようにしてください。P0-6. post-merge-cleanup への統合点が Allowed Paths にない
現在の skill は Git state の正本 classifier として、次だけを実行します。
そして「git 状態の分類は必ずこの script 経由」と明記しています。
しかし #1417 の Allowed Paths には、この script が含まれていません。
また、
POST_MERGE_CLEANUP_REPORT_V1に temporary residue classification の field はありません。現在の report は cleaned branches/worktrees、unresolved items、parent issue、superseded PR、follow-up、stash、warnings/errors だけです。したがって、classifier を作っても、
誰が呼ぶのか
scan failure をどう伝えるのか
final report のどこへ格納するのか
empty result と classifier failure をどう区別するのか
が未解決です。
さらに唯一指定されたテストファイルは、branch-only worktree cleanup と squash-merge equivalence 専用です。temporary residue classifier をここへ追加すると責務が混在します。
必須修正
Allowed Paths を次の方向へ変更してください。
tests/codex/test_cleanup_exec_branch_only.py
cleanup_contract_v3.pyも、generic safe-filesystem helper を再利用するだけなら直接変更しない方が安全です。必要なら安全な I/O primitive を独立 module に抽出し、既存 V3 と新 classifier の双方から利用する方が責務が明確です。P1 / contract ambiguity
P1-1. approved root と denied alias で marker の効力が一致していない
folder policy は以下を定義しています。
tmp/,.claude/tmp/: owned session subdirectory だけ削除可能.tmp/,.temp/,.tmp-/:report_only_without_owned_marker後者は「marker があれば削除候補になり得る」と読めます。
一方、
TEMP_CLEANUP_SAFETY_RULES_V1のmay_delete_without_humanはtmp/または.claude/tmp/配下だけに限定しています。#1417 は root temporary alias と approved temporary root の両方を scan し、generic な「valid marker の session subdirectory」を
delete_owned_subdirectoryにできるとしています。次の matrix を明示してください。
Root class | Root 自体 | valid marker child | marker 不明 child
-- | -- | -- | --
tmp/ | report only | eligible | report only
.claude/tmp/ | report only | eligible | report only
.tmp/ | report only | 要決定 | report only
.temp/ | report only | 要決定 | report only
.tmp-/ | report only | 要決定 | report only
.claude/worktrees/ | cleanup_exec only | classifier 対象外 | classifier 対象外
read-only の証明には、
os.unlink、os.rmdir、shutil.rmtree、mutation subprocess を spy / monkeypatch し、呼び出しゼロを assert するテストも必要です。推奨する output contract
Issue の現行 field をそのまま固定せず、次の程度まで定義してから実装に入るべきです。
重要な invariant:
配布物の確認結果
現行 Pages pipeline は
pnpm build後のdist/を gh-pages へrsyncし、artifact もpath: dist/だけを upload しています。PR preview もpublish_dir: ./distとpath: dist/です。root.tmp/を checkout 全体から直接配布する経路は確認できません。Vite の標準挙動でも、project root 全体ではなく、import された asset と
public/配下が build 対象です。public/の内容はdist/root へコピーされます。したがって、root.tmp/が現在の通常 build で直接入る可能性は低い一方、public/.tmp/や明示的 copy plugin は別問題です。(vitejs)ただし、folder policy の
never_publishは classifier では強制できません。これは #1417 の Safety Claim で Not controlled として残すべきです。さらに現在の main deployment には、軽微ですが provenance 上の不整合候補があります。
rsync -a dist/ ...はdist/の内容を再帰的に deploy するactions/upload-artifact@v7はinclude-hidden-files未指定upload-artifact は hidden files をデフォルトで除外する
したがって、将来
dist/.well-known/や別の dotfile が生成された場合、deployed gh-pages と保存された dist artifact が一致しない可能性があります。(Samba Downloads)これは #1417 のスコープへ混ぜるべきではありませんが、distribution follow-up として次を検討すべきです。
最小の Issue 修正方針
Outcome
In Scope
no-mutation regression tests
Out of Scope
distribution pipeline の変更
Stop Conditions
platform が安全な dir-fd I/O を提供しないのに deletion が必要な場合
最終評価
required_before_go:
integrate_scan_status_into_post_merge_cleanup_report
distribution_assessment:
current_root_temp_direct_publication: not_observed
classifier_enforces_never_publish: false
follow_up_recommended: true
この修正後であれば、#1417 は安全な read-only classifier の Issue として成立します。現行のまま
## 判定: **REQUEST_CHANGES**cleanup_exec.pyに実装を詰め込む案は、既存の narrow cleanup authorization boundary を弱めるため採用すべきではありません。Issue #1417 の方向性、すなわち「advisory 文書しか存在しない root temporary residue の判定を、機械可読な read-only classifier に昇格する」こと自体は妥当です。PR #1407 も、ownership marker に基づく classifier を未実装の follow-up として #1417 に明示的に残しています。
ただし、現行契約のまま実装すると、自己申告可能な marker と観測時点の path containment を、削除権限に事実上昇格させることになります。これは、現在の
cleanup_exec.py/cleanup_contract_v3.pyが持つ narrow executor、nonce、TTL、one-shot claim、dir-fd、O_NOFOLLOWという安全水準を下回ります。現時点では実装開始不可です。少なくとも以下の P0 を Issue 本文で解消してください。
P0 / approval blocker
P0-1.
TEMP_RESIDUE_CLASSIFICATION_V1が「schema」として定義されていない#1417 は
TEMP_RESIDUE_CLASSIFICATION_V1として以下の field を挙げています。しかし、型、必須性、enum、nullability、配列の envelope、互換性、複数理由の優先順位、scan failure の表現、consumer が未定義です。さらに Stop Conditions は「固定契約のキー集合・スキーマ・型定義を変更する必要が出たら停止」としていますが、そもそもその固定定義が本文に存在しません。
このリポジトリでは producer / consumer 境界を越える machine-readable contract は schema と定義され、新規 schema には consumer inventory が必須です。inventory 欠落や未更新 consumer は明示的な approval blocker です。
加えて、今回導入するものは一つではありません。
の最低二 schemaです。
Issue #1418 は
repo_temp_folder_advice/v1の catalog 登録だけを扱い、cleanup classifier は明示的に Out of Scope です。したがって、#1418 が #1417 の schema governance を処理することはありません。必須修正
Allowed Paths に少なくとも以下を追加してください。
また、PR の Schema Consumer Inventory 対象を Issue 本文で先に固定すべきです。
P0-2. read-only classification と destructive authorization が混同されている
Issue は goal を「read-only classification contract」と呼ぶ一方、AC3 では
delete_owned_subdirectoryをactionとして出力し、Delivery Rule では cleanup executor の削除範囲拡大にも言及しています。この命名では、consumer が classifier の出力をそのまま deletion authorization と解釈できます。
現在の
cleanup_exec.pyは、worktree と branch の削除だけを行う single narrow authorization boundary です。root branch、worktree catalog、clean state、PR merged、head branch、linked issue を毎回検査し、正確なgit worktree removeとgit branch -dだけを内部実行します。ここへ temporary directory deletion を追加するのは単なる classifier 追加ではありません。少なくとも以下が変わります。
推奨する分離
#1417 は分類だけにしてください。
action: delete_owned_subdirectoryは使用しない方が安全です。classifier は次を保証します。
実削除は別 executor が、削除直前に同じ検査をすべて再実行してから行う必要があります。
同一 Issue に削除まで含めるなら、現在の Allowed Paths と Out of Scope は全面的な再設計が必要です。現 Issue の Stop Conditions に従えば、その場合は現在の contract を停止・再 refinement するのが正しい処理です。
P0-3. ownership marker の真正性と threat model が未定義
現行 AC3 は、marker の
session idとtarget relative pathが一致すれば削除候補になり得るとしています。しかし、誰が marker を作成できるのか、session id の正本が何か、marker の replay や後付け作成をどう扱うかが定義されていません。既存の
agent_session_manifest/v1では、actor.session_idは optional / nullable です。またproducer.kindは self-claim であり、schema だけでは真正性を証明しないと明記されています。したがって、単に次が一致しても、
{ "session_id": "current-session", "target_relative_path": ".tmp/session-1" }「その session がその directory を作成した」ことの証明にはなりません。同じ OS user で動く別 agent は marker を後から作成できます。
既存 cleanup V3 はこの問題に対して、nonce、短い TTL、command hash、atomic rename による one-shot consume、symlink-safe dir-fd I/O を使っています。
Issue 本文で固定すべき threat model
次のどちらかを明記してください。
A. accidental isolation model
この場合でも、marker は deletion authority ではなく
eligible_for_deleteの補助情報に留めるべきです。B. authorization model
この場合は dedicated materializer と executor が必要です。
marker の最低要件
ファイル側の検査も必要です。
Python の標準
json.loads()は duplicate key を拒否せず、最後の値だけを採用します。そのまま marker parser に使うと、レビュー時に見た値と consumer が採用する値が異なる marker を許容します。object_pairs_hookで重複を明示的に拒否すべきです。([Python documentation]1)P0-4.
Path.resolve(strict=False)は削除時の containment 保証ではない現在の skill は temporary cleanup の required check として次を記載しています。
同時に、専用 classifier / marker parser は未実装だと明記しています。
Path.resolve()は観測時点の pathname を解決するだけです。classification 後、削除前に directory が symlink、bind mount、別 inode へ交換されれば、古い classification は削除対象の identity を保証しません。現在の cleanup contract が、platform capability を検査したうえで
O_DIRECTORY、O_NOFOLLOW、dir-fd rename / unlink を要求し、未対応 platform では fail-closed にするのは、この種の問題を避けるためです。Python の
shutil.rmtree()は fd-based API を利用できる platform では symlink attack resistant な実装を使えますが、対応状況は platform 依存です。またdir_fdを受け取れるからといって、classification 時の path が同一 inode のままとは限りません。([Python documentation]2)Linux では
openat2()のRESOLVE_BENEATHが dir-fd 外への escape を拒否し、RESOLVE_NO_SYMLINKSが全 path component の symlink 解決を拒否します。RESOLVE_NO_XDEVは mount point 越えも拒否できます。([man7.org]3)必須境界
classifier が read-only なら、次だけで構いません。
実削除 executor では最低限、削除直前に以下を行う必要があります。
classification result に
st_dev/st_ino/mtime_nsを含めることは再検証の補助になりますが、それ自体を権限証明にはしてはいけません。P0-5.
tracked/ignoredの boolean は directory tree を正しく表現できないdirectory には、次のような混在があり得ます。
この directory に対して、
{"tracked": true, "ignored": true}としても、何を意味するか決まりません。
最低でも以下の state が必要です。
また、Git の ignore 判定は repository の
.gitignoreだけではありません。.git/info/excludeと user-levelcore.excludesFileも有効です。したがってignoredは「repo policy 上の分類」ではなく、その checkout での effective Git ignore decision として定義する必要があります。(Git)現在の
classify-git-state.pyはgit status --shortをsplitlines()で解析しており、ignored files を取得せず、newline 等を含む pathname の機械解析にも適していません。Git は
-z使用時に pathname を quote せず NUL terminate します。逆に-zなしでは unusual characters が quote されます。([Git]5)推奨 command boundary
注意点:
--を置くunknown+report_onlyreason_codeも単数では不十分です。tracked_mixedとnested_symlinkが同時に成立する場合があるため、次のようにしてください。P0-6. post-merge-cleanup への統合点が Allowed Paths にない
現在の skill は Git state の正本 classifier として、次だけを実行します。
そして「git 状態の分類は必ずこの script 経由」と明記しています。
しかし #1417 の Allowed Paths には、この script が含まれていません。
また、
POST_MERGE_CLEANUP_REPORT_V1に temporary residue classification の field はありません。現在の report は cleaned branches/worktrees、unresolved items、parent issue、superseded PR、follow-up、stash、warnings/errors だけです。したがって、classifier を作っても、
が未解決です。
さらに唯一指定されたテストファイルは、branch-only worktree cleanup と squash-merge equivalence 専用です。temporary residue classifier をここへ追加すると責務が混在します。
必須修正
Allowed Paths を次の方向へ変更してください。
cleanup_contract_v3.pyも、generic safe-filesystem helper を再利用するだけなら直接変更しない方が安全です。必要なら安全な I/O primitive を独立 module に抽出し、既存 V3 と新 classifier の双方から利用する方が責務が明確です。P1 / contract ambiguity
P1-1. approved root と denied alias で marker の効力が一致していない
folder policy は以下を定義しています。
tmp/,.claude/tmp/: owned session subdirectory だけ削除可能.tmp/,.temp/,.tmp-*/:report_only_without_owned_marker後者は「marker があれば削除候補になり得る」と読めます。
一方、
TEMP_CLEANUP_SAFETY_RULES_V1のmay_delete_without_humanはtmp/または.claude/tmp/配下だけに限定しています。#1417 は root temporary alias と approved temporary root の両方を scan し、generic な「valid marker の session subdirectory」を
delete_owned_subdirectoryにできるとしています。次の matrix を明示してください。
tmp/.claude/tmp/.tmp/.temp/.tmp-*/.claude/worktrees/私の推奨は、第一段階では denied alias 配下を marker の有無にかかわらず
report_onlyとすることです。自動削除は approved roots の明示的な session directory layout に限定した方が安全です。P1-2. issue hierarchy が provenance と delivery parent を混同している
Machine-Readable Contract は
parent_issue: "#1395"ですが、同じ本文の Remaining Parent Gaps と Delivery Rule は #1404 / PR #1407 の follow-up としています。少なくとも次のように分けるべきです。
#1395 は origin provenance としては理解できますが、#1417 の immediate contract parent は #1404 です。issue traversal や child completion 判定が
parent_issueに意味を持つリポジトリでは、この違いは単なる文言ではありません。P1-3. scan budget と partial result がない
root temp directory は大容量、深い tree、permission error、FIFO、socket、device、mount point、invalid UTF-8 filename を含み得ます。
次を契約化してください。
entries: []だけでは、「何もなかった」と「scan が失敗して何も見えなかった」を区別できません。また、classifier は file 内容を出力してはいけません。temporary area には credentials、issue body、review material、ローカルパス等が置かれ得るためです。
P1-4. alias matching の正規形が未定義
.tmp-*について、少なくとも次を固定する必要があります。推奨する検出は recursive glob ではなく、trusted repo root を
os.scandir()して direct entry の bytes name を exact classifier に通す方式です。例:
.tmp-*を Git pathspec や shell glob に直接渡す実装は避けてください。Verification Commands は現状 false-green
現在の AC1–AC3 はほぼ
rgで文字列の存在を確認するだけです。これは schema や safety behavior を検証しません。最低限、次を verification にしてください。
テスト matrix は少なくとも以下を必要とします。
report_onlyreport_onlyeligible_for_deleteまたは policy に従うreport_onlyreport_onlyreport_onlyreport_onlyreport_onlyreport_onlyst_devreport_onlyreport_onlytracked_state: some,report_onlyignored_state: someunknown,report_onlyscan_status: partial,report_onlyread-only の証明には、
os.unlink、os.rmdir、shutil.rmtree、mutation subprocess を spy / monkeypatch し、呼び出しゼロを assert するテストも必要です。推奨する output contract
Issue の現行 field をそのまま固定せず、次の程度まで定義してから実装に入るべきです。
重要な invariant:
配布物の確認結果
現行 Pages pipeline は
pnpm build後のdist/を gh-pages へrsyncし、artifact もpath: dist/だけを upload しています。PR preview もpublish_dir: ./distとpath: dist/です。root.tmp/を checkout 全体から直接配布する経路は確認できません。Vite の標準挙動でも、project root 全体ではなく、import された asset と
public/配下が build 対象です。public/の内容はdist/root へコピーされます。したがって、root.tmp/が現在の通常 build で直接入る可能性は低い一方、public/.tmp/や明示的 copy plugin は別問題です。([vitejs]6)ただし、folder policy の
never_publishは classifier では強制できません。これは #1417 の Safety Claim で Not controlled として残すべきです。さらに現在の main deployment には、軽微ですが provenance 上の不整合候補があります。
rsync -a dist/ ...はdist/の内容を再帰的に deploy するactions/upload-artifact@v7はinclude-hidden-files未指定したがって、将来
dist/.well-known/や別の dotfile が生成された場合、deployed gh-pages と保存された dist artifact が一致しない可能性があります。([Samba Downloads]7)これは #1417 のスコープへ混ぜるべきではありませんが、distribution follow-up として次を検討すべきです。
最小の Issue 修正方針
Outcome
In Scope
Out of Scope
Stop Conditions
最終評価
この修正後であれば、#1417 は安全な read-only classifier の Issue として成立します。現行のまま
cleanup_exec.pyに実装を詰め込む案は、既存の narrow cleanup authorization boundary を弱めるため採用すべきではありません。squne121 commentedon Jul 10, 2026
Contract Review Result
squne121 commentedon Jul 10, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 10, 2026
implement-issue: 実装完了 (2026-07-10T13:50:00Z)
.claude/worktrees/issue-1417-temp-residue-classifierworktree-issue-1417-temp-residue-classifierpnpm typecheck/pnpm lint/pnpm test96 files 1543 tests /pnpm build)に加え、tests/agent_ops/test_temp_residue_classifier.py(38 pass)、schemas/tests/test_catalog.py+test_validate_schema_catalog.py(107 pass)、gemini-cli-headless-delegation/tests/test_model_routing.py(21 pass)も green。fix: Japanese Content Check fail block を日本語併記で解消する (#1417)
fix: repository-folder-policy.md の Japanese Content Check fail を見出し併記…
fix: E501 wrap + revert unregistered catalog command_id (#1417)
feat: root temporary residue cleanup classifier を構造化する (#1427)