✨ Redesign REST API with namespaced routing and integrated account resource - #12
Merged
Conversation
…source
- Split routes into /api/v1 (client), /api/v1/admin (moderation),
/internal/v1 (service-to-service), /ap (federation); the actor
endpoint now always serves activity+json (Accept-negotiation 404 hack
removed), and webfinger links point at /ap/...
- Integrate Account/Profile/Metadata into a single client-facing
account resource: GET /api/v1/accounts/{id}, PUT->PATCH with
absent/null/value tri-state semantics applied in one DB transaction,
fields full-replacement via index-based event diff; remove the
profile/metadata REST endpoints (4 endpoints dropped); public_key
removed from client responses
- Centralize federation URL construction in kernel ActorUrlBuilder
(single ACTORS_PATH const) and fix stale UUIDv7 doc in CLAUDE.md
- Complete signing_keys migration: drop accounts.private_key/public_key
columns and entity/event fields, eliminating the structural
private-key leak risk
- Add length limits to value objects (ProfileDisplayName 100,
ProfileSummary 2000, MetadataLabel 255, MetadataContent 1000,
ModerationReason 500, ImageUrl 2048) mapped to HTTP 400 via new
KernelError::Validation
- Single-source ActivityPub OpenAPI schemas from kernel types behind an
openapi cargo feature; resolves the Actor.url doc drift
- Fix FieldAction::Clear deserializing as Unchanged (cleared profile
fields were silently persisted)
- Fix account creation generating two different keypairs (accounts
columns vs signing_keys); key material now lives only in signing_keys
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
==========================================
- Coverage 65.06% 64.76% -0.31%
==========================================
Files 111 116 +5
Lines 14662 15203 +541
==========================================
+ Hits 9540 9846 +306
- Misses 5122 5357 +235 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 18, 2026
turtton
added a commit
that referenced
this pull request
Jul 19, 2026
## Summary Stacked PR — base は #12 (`feat/api-redesign`)。#12 マージ後に base を `main` へ retarget してください。 #12 で報告した oversized file 問題のうち、Oracle 協議で「即分割有効」と判定された4ファイルを、**純粋な機械的移動**(振る舞い変更ゼロ・公開APIパス不変・pub 拡大なし)で directory module 化します。レビューはコミット単位でどうぞ。 | Commit | 対象 | Before | After (最大) | |---|---|---|---| | `9c1de30` | `application/src/service/activitypub.rs` | 1344 prod LOC | directory 化: actor / collections / outbox / outbound_follow / inbox(mod+handlers) / remote_actor / delivery / fetch — 最大 301 | | `9404377` | `driver/src/http_signing.rs` | 893 prod LOC | directory 化: signer / verifier / cavage(mod+parser) / actor_key / fetch / ssrf + tests.rs — 最大 164、23テスト全維持 | | `a48b60d` | `application/src/service/account.rs` | 509 prod LOC | use case 別: read / create / update / deactivate / moderation / rehydrate — 最大 192 | | `e9bc3eb` | `server/src/route/account.rs` | 403 prod LOC | API 面別: client / admin / follow — 最大 208 | ## 方針(Oracle 協議結果) - 分割は本PRの4ファイルのみ。`route/activitypub.rs`・`adapter/processor/account.rs`・`oauth2.rs`・`metadata/profile` 各 service・`driver/postgres/*` は着手トリガー付きで延期(follow-up issue を作成済み) - `handler.rs`(DI registry)と `kernel/entity/account.rs`(単一集約)は「分割しない」判断をサイズ例外として記録 - activitypub と http_signing の SSRF 類似コードの共通化は architecture change のため今回スコープ外 ## Verification(全コミットで実施) - `cargo build --all-targets`: 警告ゼロ、`cargo test`: **248 passed / 0 failed**(baseline と完全一致) - `openapi_spec_matches_committed_file` 通過、openapi.json **差分ゼロ**(再生成なし) - http_signing ユニットテスト 23件 全維持 - `e2e/run-ap-e2e.sh` 全スイート: **21 passed / 0 failed**(FF1+FF2 後・FF3 後の2回実施)
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.
Summary
.review/api-redesign.mdの設計書に基づく REST API 再設計の実装。4フェーズ+仕上げ3タスクを1コミットに集約。/api/v1(クライアント, JWT) //api/v1/admin(モデレーション, JWT+Keto) //internal/v1(サービス間, JWT) //ap(連合, 公開)。Actor endpoint は Accept 交渉を廃止し常時application/activity+json。webfinger links も/ap/...へGET /api/v1/accounts/{id}新設、PUT→PATCH化(absent/null/value 三値を単一DBトランザクションで適用)、fields は index-based diff でイベント生成。profile/metadata REST エンドポイント廃止(4削減)、クライアント応答からpublic_key除去ACTORS_PATH1行で将来のパス変更が完結)accounts.private_key/public_key列を DROP(マイグレーション同梱)。Entity/Event から鍵フィールドを削除し、秘密鍵漏洩の構造的リスクを解消KernelError::Validation→ HTTP 400utoipa::ToSchemaを derive し server 重複型を削除。Actor.urlのドリフトを構造的に解消Breaking changes
/accounts/**等は 404)PUT /accounts/{id}はPATCH /api/v1/accounts/{id}に、profile/metadata 個別エンドポイントは統合PATCHへ吸収GET /internal/v1/accounts/{id}/public-keyが JWT 必須に変更(設計どおり)accountsの鍵列 DROP マイグレーション適用。既存 dev アカウントは署名鍵再生成のため再作成推奨設計中に発見し修正したバグ
FieldAction::ClearがイベントJSONのnullをUnchangedとして復元し、profile クリアが永続化されない問題Verification
cargo test: 248 passed / 0 failed(kernel 84 / application 26 / driver 104 / server 34)、ビルド警告ゼロe2e/run-ap-e2e.sh全スイート: 21 passed / 0 failed(basic flow 4 / mock AP 9 / Iceshrimp 4 / Mastodon 4)Follow-up
oversized file(250+ pure LOC)の整理は Oracle 協議のうえ、レビュー容易性のため本PRには含めず、stacked PR で別途実施します(activitypub service / http_signing / account service+route の directory module 化)。