同じ画像内の複数の秘密を、位置と対応付いたハンドルとして使えるようにする
- Dominant language
- Rust
- Stars
- 26
- Forks
- 6
- Avg merge
- 1h 13m
- Merged PRs (30d)
- 384
Description
## 解決したい利用場面
ブラウザの管理画面に「本番」と「検証」の API key が並び、ユーザーが「検証用のキーで疎通確認して」と依頼する。
秘密の画素を隠すだけでなく、エージェントが **どの黒塗り領域にどのハンドルが対応するか** 分からなければ、正しいキーを選択できない。これは「秘密をモデルに見せず、必要な操作には使える」という Pentect の中心機能に関わる。
## 現状の根拠
確認対象: `31c515a7cfe6de6e7909c3c7a420385079d85050` / `0.0.81`。コード・既存仕様に基づく機能改善提案。
- [ImageSecretFinding](https://github.com/EdamAme-x/pentect/blob/31c515a7cfe6de6e7909c3c7a420385079d85050/crates/pentect-runtime/src/image_ocr.rs#L98) には各検出結果の `rect` と `secrets` の対応がある。
- [redact_image_bytes](https://github.com/EdamAme-x/pentect/blob/31c515a7cfe6de6e7909c3c7a420385079d85050/crates/pentect-runtime/src/image_ocr.rs#L654) は画像内のハンドルを重複排除した flat list にまとめる。
- [image_note_summary](https://github.com/EdamAme-x/pentect/blob/31c515a7cfe6de6e7909c3c7a420385079d85050/crates/pentect-runtime/src/image_ocr.rs#L692) が返すのはハンドルのカンマ区切り。付与される `[index]` は画像単位で、領域単位の対応ではない。
- [apply_local_redaction](https://github.com/EdamAme-x/pentect/blob/31c515a7cfe6de6e7909c3c7a420385079d85050/crates/pentect-runtime/src/image_ocr.rs#L2063) は黒塗り / blur を描画し、領域ごとの参照記号を描画しない。
したがって同じ label の異なる秘密が一枚に複数あると、provider に渡る note に元の位置関係が残らない。配列順だけに頼る選択には、OCR backend や検出順をまたぐ対応契約がない。
画像からハンドルを返すこと自体は実装済み。#345 はその note の HTTP 経路への伝達を扱った issue で、本件は **画像内の領域と参照の対応を保つ** 後続改善。
## 望む動作
保護後の画像上の領域記号、または構造化された領域参照と、隣接するハンドル情報が一意に対応する。ユーザーが指定した欄を、ハンドルの値を知らないエージェントが選べる。
最初の対象は、既存の inline image / screenshot 経路と、検出位置が得られた領域。全 OCR テキストや秘密の断片を補足情報として送信しない。位置が取れない場合は対応不明を明示し、位置を推測して作らない。
## 完了条件
- [ ] 同じ label の合成キーを本番 / 検証の二つの領域に置き、保護後の画像・note だけから対象領域のハンドルを区別できる。
- [ ] 検出結果の順番を入れ替えても、位置とハンドルの対応が壊れない。
- [ ] 同じ値が二箇所にある場合、ハンドルの同一性と領域の複数性を両立する。
- [ ] 複数画像、resize、重複矩形、QR/barcode、位置不明の場合の対応を定義する。metadata の秘密は画素内の秘密と混同しない。
- [ ] 既存の OpenAI / Anthropic の画像・computer-use 経路が同じ対応情報を保持する。
- [ ] localhost の二つの fixture service を使い、選んだ領域のハンドルが正しい合成値に復元されることを確認する。provider 側の画像・note・診断には元の値が含まれない。
実モデルが誤ったキーを選択した実測報告ではない。現在の表現が領域との対応を失うことをソースで確認し、それを解消する機能要件を定義している。
Contributor guide
Research direction
Start in crates/pentect-runtime/src/image_ocr.rs, reading ImageSecretFinding, redact_image_bytes, image_note_summary, and apply_local_redaction, then trace the existing inline-image and screenshot provider paths. Define and test a stable region-to-handle contract across detection-order changes, resizing, duplicate values, and unknown positions; completion includes the two localhost fixture services and both OpenAI and Anthropic paths without exposing original values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100