Skip to content

実装: root temporary residue cleanup classifier を構造化する #1417

Closed

Description

@squne121

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: workflow

Parent Issue

#1404

Parent Goal Ref

Current Validated Scope

  • .tmp/ / .temp/ / .tmp-* と approved temporary root の residue を read-only scan し、temp_residue_classification/v1 として構造化出力する。
  • temp_residue_owner/v1 marker schema を定義するが、marker は deletion authority ではなく eligible_for_delete advisory の補助情報に限定する。
  • 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

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/v1 marker 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/v1 schema は top-level scan_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/v1 schema は 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 に基づく。single reason_code だけに依存しない。
  • AC9: post-merge-cleanup skill の classify-git-state.py --format json または同等 entrypoint は temp_residue_classification field を出力でき、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_artifact lane 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 json

Allowed Paths

  • scripts/agent-ops/temp_residue_classifier.py
  • scripts/agent-ops/temp_residue_marker.py
  • .claude/skills/post-merge-cleanup/scripts/classify-git-state.py
  • tests/agent_ops/test_temp_residue_classifier.py
  • schemas/temp_residue_classification_v1.schema.json
  • schemas/temp_residue_owner_v1.schema.json
  • schemas/catalog.yaml
  • schemas/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.md
  • docs/dev/repository-folder-policy.md
  • docs/dev/agent-skill-boundaries.md
  • docs/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.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/schema-governance.md
  • docs/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(任意)

Delivery Rule

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 10, 2026
  2. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    判定: 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 を挙げています。

    path / folder_class / file_type / tracked / ignored /
    ownership_marker / action / reason_code
    

    しかし、型、必須性、enum、nullability、配列の envelope、互換性、複数理由の優先順位、scan failure の表現、consumer が未定義です。さらに Stop Conditions は「固定契約のキー集合・スキーマ・型定義を変更する必要が出たら停止」としていますが、そもそもその固定定義が本文に存在しません。

    このリポジトリでは producer / consumer 境界を越える machine-readable contract は schema と定義され、新規 schema には consumer inventory が必須です。inventory 欠落や未更新 consumer は明示的な approval blocker です。

    加えて、今回導入するものは一つではありません。

    1. classification output schema

    2. ownership marker schema

    の最低二 schemaです。

    Issue #1418 は repo_temp_folder_advice/v1 の catalog 登録だけを扱い、cleanup classifier は明示的に Out of Scope です。したがって、#1418 が #1417 の schema governance を処理することはありません。

    必須修正

    Allowed Paths に少なくとも以下を追加してください。

    schemas/temp_residue_classification_v1.schema.json
    schemas/temp_residue_owner_v1.schema.json
    schemas/catalog.yaml
    schemas/tests/test_catalog.py
    docs/dev/schema-governance.md
    

    また、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 は分類だけにしてください。

    recommendation:
      enum:
        - report_only
        - eligible_for_delete
    

    action: delete_owned_subdirectory は使用しない方が安全です。

    classifier は次を保証します。

    - unlink / rmdir / shutil.rmtree を一切呼ばない
    - serialized classification は削除権限ではない
    - eligible_for_delete は「再検査対象になり得る」という advisory
    

    実削除は別 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 は同一 OS user 内の悪意ある process には耐えない。agent 間の誤削除防止だけを目的とする。

    この場合でも、marker は deletion authority ではなく eligible_for_delete の補助情報に留めるべきです。

    B. authorization model

    marker は trusted materializer が生成し、local ledger / nonce / expiry と照合できた場合だけ deletion authorization に利用できる。

    この場合は dedicated materializer と executor が必要です。

    marker の最低要件

    schema: temp_residue_owner/v1
    marker_id: tro-<uuid>
    repository: squne121/loop-protocol
    session_id: <opaque non-empty id>
    target_relpath: <normalized repo-relative POSIX path>
    created_at: <timezone-aware ISO 8601>
    expires_at: <timezone-aware ISO 8601>
    nonce: <random value>
    producer:
      kind: trusted_materializer
      version: <version>
    

    ファイル側の検査も必要です。

    - marker filename は固定
    - regular file のみ
    - symlink 不可
    - owner uid が現在 user と一致
    - group / other writable 不可
    - hardlink 数の検査
    - 最大 byte 数
    - duplicate JSON key 不可
    - NaN / Infinity 不可
    - target_relpath の canonical equality
    - repository / worktree binding
    - expiry と replay 検査
    

    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 として次を記載しています。

    relative path only
    Path.resolve(strict=False) under approved root
    git ls-files confirms untracked before deletion
    

    同時に、専用 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 なら、次だけで構いません。

    - observation を出力する
    - recommendation は advisory
    - serialized result を authorization token にしない
    

    実削除 executor では最低限、削除直前に以下を行う必要があります。

    1. approved root を dir-fd で open
    2. 全 component を no-follow で再走査
    3. marker を同じ dir-fd tree から再読込
    4. tracked / session / target / expiry を再検査
    5. st_dev / st_ino が想定対象と一致することを確認
    6. mount boundary、nested symlink、special file を拒否
    7. fd-relative deletion
    8. 削除後 postcondition を確認
    

    classification result に st_dev / st_ino / mtime_ns を含めることは再検証の補助になりますが、それ自体を権限証明にはしてはいけません。


    P0-5. tracked / ignored の boolean は directory tree を正しく表現できない

    directory には、次のような混在があり得ます。

    .tmp/session/
    ├── ignored.log
    ├── untracked.txt
    └── tracked-config.json
    

    この directory に対して、

    {"tracked": true, "ignored": true}
    

    としても、何を意味するか決まりません。

    最低でも以下の state が必要です。

    tracked_state: none | some | all | unknown
    ignored_state: none | some | all | unknown
    

    また、Git の ignore 判定は repository の .gitignore だけではありません。.git/info/exclude と user-level core.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

    git ls-files -z --cached -- ':(literal)<path>'
    git check-ignore --no-index -z --stdin
    git status --porcelain=v1 -z --untracked-files=all --ignored=matching
    

    注意点:

    • argv 配列形式を使う

    • pathspec と option の境界に -- を置く

    • wildcard を literal pathspec として扱う

    • stdin / stdout とも NUL 区切り

    • Git failure は unknown + report_only

    • Git command が空出力でも、失敗と「該当なし」を区別する

    reason_code も単数では不十分です。tracked_mixed と nested_symlink が同時に成立する場合があるため、次のようにしてください。

    primary_reason_code: tracked_content_present
    reason_codes:
      - tracked_content_present
      - nested_symlink_present
      - marker_mismatch
    

    P0-6. post-merge-cleanup への統合点が Allowed Paths にない

    現在の skill は Git state の正本 classifier として、次だけを実行します。

    uv run --locked python3 \
      .claude/skills/post-merge-cleanup/scripts/classify-git-state.py \
      --format yaml
    

    そして「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 を次の方向へ変更してください。

    + scripts/agent-ops/temp_residue_classifier.py
    + scripts/agent-ops/temp_residue_marker.py
    + tests/agent-ops/test_temp_residue_classifier.py
    + .claude/skills/post-merge-cleanup/scripts/classify-git-state.py
    + schemas/temp_residue_classification_v1.schema.json
    + schemas/temp_residue_owner_v1.schema.json
    + schemas/catalog.yaml
    + schemas/tests/test_catalog.py
    + .github/ci/python-test-plan.json
      .claude/skills/post-merge-cleanup/SKILL.md
      docs/dev/repository-folder-policy.md
      docs/dev/agent-skill-boundaries.md
    
    • scripts/agent-ops/cleanup_exec.py
    • scripts/agent-ops/materialize_cleanup_contract.py
    • scripts/agent-ops/worktree_catalog.py
    • 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 をそのまま固定せず、次の程度まで定義してから実装に入るべきです。

    TEMP_RESIDUE_CLASSIFICATION_V1:
      schema: temp_residue_classification/v1
      scan_status: ok | partial | error
      generated_at: "<timezone-aware ISO 8601>"
      project_root:
        source: claude_project_dir | git_toplevel | script_location
        validated: true
      entries:
        - path: ".tmp/session-123"
          folder_class: root_temporary_alias
          entry_type: directory | regular_file | symlink | special | unknown
          tracked_state: none | some | all | unknown
          ignored_state: none | some | all | unknown
          ownership_marker:
            state: absent | valid | malformed | mismatch | untrusted | unreadable
            schema: temp_residue_owner/v1 | null
            session_match: true | false | null
            target_match: true | false | null
            expired: true | false | null
          recommendation: report_only | eligible_for_delete
          primary_reason_code: marker_session_mismatch
          reason_codes:
            - marker_session_mismatch
            - nested_symlink_present
          observation:
            device: 123
            inode: 456
            mtime_ns: 123456789
      errors: []
    

    重要な invariant:

    invariants:
      - recommendation は実行済み action を意味しない
      - classifier は filesystem mutation を行わない
      - scan_status != ok の entry は必ず report_only
      - unknown state が一つでもあれば report_only
      - serialized result 単体は deletion authorization にならない
      - reason_codes は deterministic な順序
      - path は repo-relative POSIX form
      - absolute local path と file content は出力しない
    

    配布物の確認結果

    現行 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 として次を検討すべきです。

    - final dist manifest を生成
    - deploy 対象と artifact 対象を同一 manifest から作る
    - hidden file の明示 allowlist
    - .tmp / .temp / ownership marker / local artifact の deny assertion
    - deployed bundle digest と evidence artifact digest の同一性検証
    

    最小の Issue 修正方針

    Outcome

    post-merge-cleanup が root temporary residue を
    `temp_residue_classification/v1` として read-only 分類できる。
    

    classifier は削除を実行せず、report_only または
    eligible_for_delete という recommendation だけを返す。

    serialized classification は deletion authorization ではない。
    実削除を行う executor は別 scope とし、削除直前に marker、
    Git state、path containment、inode、symlink / mount boundary を再検証する。

    In Scope

    - dedicated read-only classifier

    • classification schema と ownership marker schema
    • schema catalog / consumer inventory
    • approved roots / denied aliases の明示 matrix
    • Git tracked / ignored の tri-state または mixed-state 判定
    • bounded scan / partial failure contract
    • post-merge-cleanup report への統合
    • no-mutation regression tests

    Out of Scope

    - filesystem deletion
    
  3. cleanup_exec の destructive grammar 拡張
  4. classification result を authorization token として利用すること
  5. distribution pipeline の変更
  6. Stop Conditions

    - deletion が AC 達成に必要と判明した場合
    
  7. trusted session identity source が得られない場合
  8. schema catalog / report consumer 更新が Allowed Paths 外の場合
  9. platform が安全な dir-fd I/O を提供しないのに deletion が必要な場合

  10. 最終評価

    CONTRACT_REVIEW_RESULT_V1:
    issue_number: 1417
    status: request_changes
    implementation_ready: false
    blockers:
    • classification_schema_undefined
    • ownership_marker_schema_and_trust_model_undefined
    • read_only_and_deletion_authorization_conflated
    • classification_to_deletion_toctou_uncontrolled
    • tracked_and_ignored_directory_semantics_undefined
    • post_merge_cleanup_integration_path_missing
    • allowed_paths_and_test_surface_incoherent
      required_before_go:
    • define_and_register_both_schemas
    • split_classifier_from_deletion_executor
    • define_session_identity_and_marker_provenance
    • define_approved_root_vs_alias_matrix
    • add_bounded_nul_safe_git_and_filesystem_tests
    • 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 として成立します。現行のまま cleanup_exec.py に実装を詰め込む案は、既存の narrow cleanup authorization boundary を弱めるため採用すべきではありません。

    ## 判定: **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 を挙げています。

    path / folder_class / file_type / tracked / ignored /
    ownership_marker / action / reason_code
    

    しかし、型、必須性、enum、nullability、配列の envelope、互換性、複数理由の優先順位、scan failure の表現、consumer が未定義です。さらに Stop Conditions は「固定契約のキー集合・スキーマ・型定義を変更する必要が出たら停止」としていますが、そもそもその固定定義が本文に存在しません。

    このリポジトリでは producer / consumer 境界を越える machine-readable contract は schema と定義され、新規 schema には consumer inventory が必須です。inventory 欠落や未更新 consumer は明示的な approval blocker です。

    加えて、今回導入するものは一つではありません。

    1. classification output schema
    2. ownership marker schema

    の最低二 schemaです。

    Issue #1418 は repo_temp_folder_advice/v1 の catalog 登録だけを扱い、cleanup classifier は明示的に Out of Scope です。したがって、#1418 が #1417 の schema governance を処理することはありません。

    必須修正

    Allowed Paths に少なくとも以下を追加してください。

    schemas/temp_residue_classification_v1.schema.json
    schemas/temp_residue_owner_v1.schema.json
    schemas/catalog.yaml
    schemas/tests/test_catalog.py
    docs/dev/schema-governance.md
    

    また、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 は分類だけにしてください。

    recommendation:
      enum:
        - report_only
        - eligible_for_delete

    action: delete_owned_subdirectory は使用しない方が安全です。

    classifier は次を保証します。

    - unlink / rmdir / shutil.rmtree を一切呼ばない
    - serialized classification は削除権限ではない
    - eligible_for_delete は「再検査対象になり得る」という advisory
    

    実削除は別 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 は同一 OS user 内の悪意ある process には耐えない。agent 間の誤削除防止だけを目的とする。

    この場合でも、marker は deletion authority ではなく eligible_for_delete の補助情報に留めるべきです。

    B. authorization model

    marker は trusted materializer が生成し、local ledger / nonce / expiry と照合できた場合だけ deletion authorization に利用できる。

    この場合は dedicated materializer と executor が必要です。

    marker の最低要件

    schema: temp_residue_owner/v1
    marker_id: tro-<uuid>
    repository: squne121/loop-protocol
    session_id: <opaque non-empty id>
    target_relpath: <normalized repo-relative POSIX path>
    created_at: <timezone-aware ISO 8601>
    expires_at: <timezone-aware ISO 8601>
    nonce: <random value>
    producer:
      kind: trusted_materializer
      version: <version>

    ファイル側の検査も必要です。

    - marker filename は固定
    - regular file のみ
    - symlink 不可
    - owner uid が現在 user と一致
    - group / other writable 不可
    - hardlink 数の検査
    - 最大 byte 数
    - duplicate JSON key 不可
    - NaN / Infinity 不可
    - target_relpath の canonical equality
    - repository / worktree binding
    - expiry と replay 検査
    

    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 として次を記載しています。

    relative path only
    Path.resolve(strict=False) under approved root
    git ls-files confirms untracked before deletion
    

    同時に、専用 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 なら、次だけで構いません。

    - observation を出力する
    - recommendation は advisory
    - serialized result を authorization token にしない
    

    実削除 executor では最低限、削除直前に以下を行う必要があります。

    1. approved root を dir-fd で open
    2. 全 component を no-follow で再走査
    3. marker を同じ dir-fd tree から再読込
    4. tracked / session / target / expiry を再検査
    5. st_dev / st_ino が想定対象と一致することを確認
    6. mount boundary、nested symlink、special file を拒否
    7. fd-relative deletion
    8. 削除後 postcondition を確認
    

    classification result に st_dev / st_ino / mtime_ns を含めることは再検証の補助になりますが、それ自体を権限証明にはしてはいけません。


    P0-5. tracked / ignored の boolean は directory tree を正しく表現できない

    directory には、次のような混在があり得ます。

    .tmp/session/
    ├── ignored.log
    ├── untracked.txt
    └── tracked-config.json
    

    この directory に対して、

    {"tracked": true, "ignored": true}

    としても、何を意味するか決まりません。

    最低でも以下の state が必要です。

    tracked_state: none | some | all | unknown
    ignored_state: none | some | all | unknown

    また、Git の ignore 判定は repository の .gitignore だけではありません。.git/info/exclude と user-level core.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

    git ls-files -z --cached -- ':(literal)<path>'
    git check-ignore --no-index -z --stdin
    git status --porcelain=v1 -z --untracked-files=all --ignored=matching
    

    注意点:

    • argv 配列形式を使う
    • pathspec と option の境界に -- を置く
    • wildcard を literal pathspec として扱う
    • stdin / stdout とも NUL 区切り
    • Git failure は unknown + report_only
    • Git command が空出力でも、失敗と「該当なし」を区別する

    reason_code も単数では不十分です。tracked_mixed と nested_symlink が同時に成立する場合があるため、次のようにしてください。

    primary_reason_code: tracked_content_present
    reason_codes:
      - tracked_content_present
      - nested_symlink_present
      - marker_mismatch

    P0-6. post-merge-cleanup への統合点が Allowed Paths にない

    現在の skill は Git state の正本 classifier として、次だけを実行します。

    uv run --locked python3 \
      .claude/skills/post-merge-cleanup/scripts/classify-git-state.py \
      --format yaml

    そして「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 を次の方向へ変更してください。

    + scripts/agent-ops/temp_residue_classifier.py
    + scripts/agent-ops/temp_residue_marker.py
    + tests/agent-ops/test_temp_residue_classifier.py
    + .claude/skills/post-merge-cleanup/scripts/classify-git-state.py
    + schemas/temp_residue_classification_v1.schema.json
    + schemas/temp_residue_owner_v1.schema.json
    + schemas/catalog.yaml
    + schemas/tests/test_catalog.py
    + .github/ci/python-test-plan.json
      .claude/skills/post-merge-cleanup/SKILL.md
      docs/dev/repository-folder-policy.md
      docs/dev/agent-skill-boundaries.md
    
    - scripts/agent-ops/cleanup_exec.py
    - scripts/agent-ops/materialize_cleanup_contract.py
    - scripts/agent-ops/worktree_catalog.py
    - 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 対象外

    私の推奨は、第一段階では 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 としています。

    少なくとも次のように分けるべきです。

    parent_issue: "#1404"
    origin_issue: "#1395"
    derived_from_pr: "#1407"
    anchor_review_comment: "<owner REQUEST_CHANGES comment>"

    #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 を含み得ます。

    次を契約化してください。

    scan_limits:
      max_entries: 10000
      max_depth: 32
      max_marker_bytes: 4096
      deadline_seconds: 5
    
    scan_status:
      enum:
        - ok
        - partial
        - error

    entries: [] だけでは、「何もなかった」と「scan が失敗して何も見えなかった」を区別できません。

    また、classifier は file 内容を出力してはいけません。temporary area には credentials、issue body、review material、ローカルパス等が置かれ得るためです。


    P1-4. alias matching の正規形が未定義

    .tmp-* について、少なくとも次を固定する必要があります。

    - repo root の direct child のみ
    - case-sensitive
    - slash を含まない
    - `.tmp-` 単体を含むか
    - Unicode normalization を行うか
    - Windows path separator を受理するか
    - bytes filename をどう JSON 化するか
    

    推奨する検出は recursive glob ではなく、trusted repo root を os.scandir() して direct entry の bytes name を exact classifier に通す方式です。

    例:

    ^\.tmp-[^/]+$

    .tmp-* を Git pathspec や shell glob に直接渡す実装は避けてください。


    Verification Commands は現状 false-green

    現在の AC1–AC3 はほぼ rg で文字列の存在を確認するだけです。これは schema や safety behavior を検証しません。

    最低限、次を verification にしてください。

    uv run --locked pytest tests/agent-ops/test_temp_residue_classifier.py -q
    
    uv run --locked pytest \
      schemas/tests/test_catalog.py \
      .claude/skills/open-pr/scripts/tests/test_validate_schema_catalog.py \
      -q
    
    uv run --locked python3 scripts/ci/python_test_plan.py \
      --emit scope-argv --format json
    
    uv run --locked python3 scripts/agent-ops/temp_residue_classifier.py \
      --project-root "$PWD" --format json \
      | uv run --locked python3 -m json.tool

    テスト matrix は少なくとも以下を必要とします。

    Case Expected
    approved root 自体 report_only
    root alias 自体 report_only
    valid marker / current session / target match eligible_for_delete または policy に従う
    foreign session report_only
    marker target mismatch report_only
    malformed / oversized marker report_only
    duplicate JSON key report_only
    top-level symlink report_only
    nested symlink / dangling symlink report_only
    mount point / different st_dev report_only
    FIFO / socket / device report_only
    nested tracked file tracked_state: some, report_only
    ignored / unignored mix ignored_state: some
    Git unavailable / timeout unknown, report_only
    permission denied scan_status: partial, report_only
    filename with newline lossless classification
    deterministic repeated run stable sort / equivalent output
    classifier execution unlink/rmdir/rmtree が一度も呼ばれない

    read-only の証明には、os.unlink、os.rmdir、shutil.rmtree、mutation subprocess を spy / monkeypatch し、呼び出しゼロを assert するテストも必要です。


    推奨する output contract

    Issue の現行 field をそのまま固定せず、次の程度まで定義してから実装に入るべきです。

    TEMP_RESIDUE_CLASSIFICATION_V1:
      schema: temp_residue_classification/v1
      scan_status: ok | partial | error
      generated_at: "<timezone-aware ISO 8601>"
      project_root:
        source: claude_project_dir | git_toplevel | script_location
        validated: true
      entries:
        - path: ".tmp/session-123"
          folder_class: root_temporary_alias
          entry_type: directory | regular_file | symlink | special | unknown
          tracked_state: none | some | all | unknown
          ignored_state: none | some | all | unknown
          ownership_marker:
            state: absent | valid | malformed | mismatch | untrusted | unreadable
            schema: temp_residue_owner/v1 | null
            session_match: true | false | null
            target_match: true | false | null
            expired: true | false | null
          recommendation: report_only | eligible_for_delete
          primary_reason_code: marker_session_mismatch
          reason_codes:
            - marker_session_mismatch
            - nested_symlink_present
          observation:
            device: 123
            inode: 456
            mtime_ns: 123456789
      errors: []

    重要な invariant:

    invariants:
      - recommendation は実行済み action を意味しない
      - classifier は filesystem mutation を行わない
      - scan_status != ok の entry は必ず report_only
      - unknown state が一つでもあれば report_only
      - serialized result 単体は deletion authorization にならない
      - reason_codes は deterministic な順序
      - path は repo-relative POSIX form
      - absolute local path と file content は出力しない

    配布物の確認結果

    現行 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 未指定
    • upload-artifact は hidden files をデフォルトで除外する

    したがって、将来 dist/.well-known/ や別の dotfile が生成された場合、deployed gh-pages と保存された dist artifact が一致しない可能性があります。([Samba Downloads]7)

    これは #1417 のスコープへ混ぜるべきではありませんが、distribution follow-up として次を検討すべきです。

    - final dist manifest を生成
    - deploy 対象と artifact 対象を同一 manifest から作る
    - hidden file の明示 allowlist
    - .tmp / .temp / ownership marker / local artifact の deny assertion
    - deployed bundle digest と evidence artifact digest の同一性検証
    

    最小の Issue 修正方針

    Outcome

    post-merge-cleanup が root temporary residue を
    `temp_residue_classification/v1` として read-only 分類できる。
    
    classifier は削除を実行せず、`report_only` または
    `eligible_for_delete` という recommendation だけを返す。
    
    serialized classification は deletion authorization ではない。
    実削除を行う executor は別 scope とし、削除直前に marker、
    Git state、path containment、inode、symlink / mount boundary を再検証する。

    In Scope

    - dedicated read-only classifier
    - classification schema と ownership marker schema
    - schema catalog / consumer inventory
    - approved roots / denied aliases の明示 matrix
    - Git tracked / ignored の tri-state または mixed-state 判定
    - bounded scan / partial failure contract
    - post-merge-cleanup report への統合
    - no-mutation regression tests

    Out of Scope

    - filesystem deletion
    - cleanup_exec の destructive grammar 拡張
    - classification result を authorization token として利用すること
    - distribution pipeline の変更

    Stop Conditions

    - deletion が AC 達成に必要と判明した場合
    - trusted session identity source が得られない場合
    - schema catalog / report consumer 更新が Allowed Paths 外の場合
    - platform が安全な dir-fd I/O を提供しないのに deletion が必要な場合

    最終評価

    CONTRACT_REVIEW_RESULT_V1:
      issue_number: 1417
      status: request_changes
      implementation_ready: false
      blockers:
        - classification_schema_undefined
        - ownership_marker_schema_and_trust_model_undefined
        - read_only_and_deletion_authorization_conflated
        - classification_to_deletion_toctou_uncontrolled
        - tracked_and_ignored_directory_semantics_undefined
        - post_merge_cleanup_integration_path_missing
        - allowed_paths_and_test_surface_incoherent
      required_before_go:
        - define_and_register_both_schemas
        - split_classifier_from_deletion_executor
        - define_session_identity_and_marker_provenance
        - define_approved_root_vs_alias_matrix
        - add_bounded_nul_safe_git_and_filesystem_tests
        - 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 として成立します。現行のまま cleanup_exec.py に実装を詰め込む案は、既存の narrow cleanup authorization boundary を弱めるため採用すべきではありません。

  11. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-10T12:56:03Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1417
      body_sha256: "sha256:47250b959aa21217281c03f623ba4de610c9a480d6c19a2fb74af11dc025b11b"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  12. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1417#issuecomment-4935510588
        generated_at: '2026-07-10T12:56:18Z'
        body_sha256: sha256:47250b959aa21217281c03f623ba4de610c9a480d6c19a2fb74af11dc025b11b
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: '2026-07-10T12:56:18Z'
      checked_body_sha256: sha256:47250b959aa21217281c03f623ba4de610c9a480d6c19a2fb74af11dc025b11b
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  13. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-07-10T13:50:00Z)

    • PR: feat: root temporary residue cleanup classifier を構造化する #1427
    • Worktree: .claude/worktrees/issue-1417-temp-residue-classifier
    • Branch: worktree-issue-1417-temp-residue-classifier
    • Verification: 4/4 PASS(pnpm typecheck / pnpm lint / pnpm test 96 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。
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions