Repository navigation
drive-foundation-followups: レビュー nit 8 件の集約是正 (バリデーション・競合安全・キャッシュ・文書化) - #5
Merged
Merged
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/ohmy-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
issue #4 (PR #2 レビュー nit 8 件の集約) を実装。バリデーション・競合安全・キャッシュ・文書化を 1 実行単位で是正する。issue #3 は本 PR で superseded として扱う。
変更内容 (8 項目)
fix(drive)):UploadQuery.nameにフォルダ名と同一規約 (空白のみ拒否・Unicode 文字数 255 上限) を適用。drive::validate_nameとして共通化。fix(drive)): Body 直接抽出ハンドラでは no-op だったDefaultBodyLimitレイヤを撤去し、CountingBodyに一本化。413 (max 超過) / 400 (宣言超過) を結合テストで固定。feat(billing)): in-memory TTL キャッシュ (既定 60 秒、BOOSKIFF_BILLING_CACHE_TTL_SECS、0 で無効) を導入し、管理者書き込み (ルール upsert/delete、プラン set/delete) で即時無効化。世代トークンで「読み込み中の無効化後に古い値が再登録される」競合も防止。分散共有キャッシュは導入しない (scope 外)。docs): プロセス内メモリ (レプリカ非共有)、rpm 変更時の limiter 再生成による burst リセットは意図的制約として docs/operations.md に明記 (コード変更なし・現行挙動維持)。fix(billing)): 2 段 upsert を単一INSERT ... ON CONFLICT ((COALESCE(owner_type,'')), (COALESCE(owner_id,'')), key) DO UPDATEに置換。同時 INSERT 競合で unique violation 500 を返さない。fix(drive)): files INSERT の 23503 (ensure_owned_folder 通過後にフォルダが削除された競合) をNotFound(404) にマップ。feat(public)+ docs): 無認証・帯域計量初動外を文書化。DoS 緩和として per-IP レート制限 (既定 300 req/min、BOOSKIFF_PUBLIC_RATE_LIMIT_RPM) を付与。ConnectInfo 非提供環境では fail-open でスキップ。docs): unpublish/削除後も外部キャッシュが残り得ること (即時失効非保証)、publish ごとの public_key 再生成による緩和を docs/operations.md に明記。検証
cargo fmt --check/cargo clippy --all-targets -- -D warnings/cargo test(113 passed) /cargo test -p core -- --include-ignored(130 passed、e2e_suite 含む) /just openapiドリフトなし /git diff --checkクリーン。BOOSKIFF_PUBLIC_RATE_LIMIT_RPM=2で 404 → 404 → 429 (rate_limited) を確認。スコープ外 (packet 準拠で未実施)
Redis 等の分散共有キャッシュ/レート制限、複数レプリカ対応、課金規定値の変更、帯域計量、公開制御の仕様変更、Misskey Drive API 互換、8 件以外のリファクタ、Web UI 変更。
前提確認メモ
各 nit は実施前に最新コードで成立を確認済み (例: upsert_rule の 2 段 upsert と誤ったコメント、DefaultBodyLimit no-op、/public 無制限は main 時点で現存)。既に解消済みでスキップした項目はなし。
Closes #4
前提確認で変質が判明した項目 (nit 6)
packet は「ensure_owned_folder の原子化 (同時フォルダ生成競合)」を想定していたが、最新コードでは
ensure_owned_folderは read-only (SELECT EXISTS + 404) でフォルダ生成は行わない (生成は folders.rs 側で 23505→409 済み)。実在する競合は「存在チェック通過後のフォルダ削除 × files INSERT」の FK 23503 で、これを 404 にマップ (837c6d5) し、同時競合テストpg_concurrent_folder_delete_and_upload_never_500(8 ラウンドの join! で削除×persist を並行実行、Internal/500 を返さないことを固定) と静的テストpg_upload_into_vanished_folder_is_not_foundで担保した。レビュー駆動の追加是正 (5 レーン並行レビューの blocker 対応)
fix(billing): BillingCache の owner キーを(owner_type, owner_id)の構造化キーに変更。従来の"{type}:{id}"連結では("a:b","c")と("a","b:c")が衝突し、テナント間でキャッシュ済み課金制限が混同し得た (衝突回帰テスト付き)。fix(admin): 空/空白の owner_type・owner_id を持つ owner scope を 400 で拒否。expression index 上で global ルール行と衝突し、ON CONFLICT が global 行を更新しつつ global キャッシュが無効化されない経路を塞いだ (global 行・キャッシュ不変の HTTP 回帰テスト付き)。feat(public):BOOSKIFF_TRUST_PROXY_HEADERS(既定 false) 追加。同梱 Caddy 等の信頼プロキシ背後でのみ X-Forwarded-For 最左 IP を制限キーに使用 (無効時は XFF を完全に無視し peer IP のみ。偽装耐性はテストで固定)。セルフホスト compose では core 非公開・Caddy のみ公開のため compose 側では既定 true でパススルー。test(public): 既定値 300 rpm をConfig::default()と limiter 実挙動 (300 許可・301 拒否) の双方で固定。既知の非ブロッキング事項 (別 packet 候補)
RateLimiters(owner レート制限) もOwner::key()文字列連結キーで同一の衝突可能性を持つ。drive-foundation 既存コードのため今回の scope 外。pub→pub(crate)絞り込み、limiter sweep の専用テストは未実施 (挙動はコードコメントと実 HTTP 検証で確認)。CI インフラ修正 (スコープ外の既存障害)
初回 CI で e2e ジョブが
minio/minioの Docker Hub pull 拒否で失敗 (main の最後の成功 CI 以降に MinIO が Docker Hub 公開を停止した既存障害。ローカルはキャッシュ済みで検出不能だった)。compose.ymlの minio/mc イメージをquay.io/minio/*に切り替えて解消 (1372b30)。8 項目の nit 是正とは独立した変更だが、完了条件の CI green に必要だったため含めた。