Repository navigation
Conversation
ロールの API(U-5)のテストでも、既存スキーマの再現・migration の再生・ 部員の作成を使うため、migration.integration.test.ts から core/testing/migrations.ts に移した。中身は変えていない(移動先の 階層に合わせて相対パスだけ直した)。全 migration を流す replayThroughLatest を足した。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7
FR-5.1。ロールの表は member の持ち物なので、member サービスに置いた
(/api/v0/role)。どの API も role.manage を持つ人だけが使える。
- GET /role 選べるロールの一覧
- GET /role/members/{memberId} 部員のロールと変更履歴(新しい順)
- POST /role/members/{memberId} ロールを付ける(同じロールなら何もしない)
- DELETE /role/members/{memberId}/{key} ロールを外す
在籍中でない部員には付けない(409 member_not_active。退部でロールが
外れる U-6 と食い違わないため)。最後の管理者を外そうとすると 409
last_role_manager を返す。履歴はトリガーが書く。
community にあった、固定の値を返すだけの PUT /user/{id}/role の仮実装は
紛らわしいので削除した(Discord のロールを読む GET は残す)。
テスト:本物の RLS 付きデータベースで、権限のない人は 403、付与・剥奪と
履歴、最後の管理者、在籍中でない部員・存在しないロール・存在しない部員・
持っていないロールの各エラー。在籍中の確認を外すと失敗することを
確かめてある。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7
yufoxda
commented
Nov 11, 2026
| } | ||
| }); | ||
|
|
||
| export const updateUserRolesRoute = createRoute({ |
Contributor
Author
There was a problem hiding this comment.
なんで消すんですか?
アップデートはしたくないですか?
Contributor
Author
There was a problem hiding this comment.
消した理由は 2 つあります。
- 中身がなかった:この
PUTは、何もせずに固定の値({ roleId: "r-123", roleName: "admin" })を返すだけの仮実装でした。呼び出すと「更新できた」ように見えますが、実際には何も変わりません。使う人を誤解させるので、残しておくと危ないと考えました。 - V1 では更新しないと決めている:このエンドポイントは、システムのロールではなく Discord のロールを扱うものです(同じフォルダの
GETは Discord のロールを読んでいます)。intent.md6.4 では「システム側のロールは Discord のロールから独立して持つ。V1 では同期しない」と決めています。システムのロールの付与・剥奪は、この PR の member の API(/api/v0/role)が担います。
Discord のロールもこのシステムから更新したい場合は、新しい要件として追加する必要があります。そのときは、仮実装ではなく、Discord の API を実際に呼ぶ形で作り直すことを勧めます。仮実装のまま残しておくか、今回の方針どおり削除するかは、判断してください。
Generated by Claude Code
レビューで、仮実装は本実装までの置き場所として残す意図だったと分かった。 この PR はシステムのロールの API に絞り、Discord のロールの更新は別の PR で本実装する。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7
Discord のロールを変更する機能は作らないと決めた(2026-11-14。
intent.md 6.4「V1 では同期しない」のとおり)。置き場所として残していた
仮実装の PUT /user/{id}/role は、呼ぶと更新できたように見えて何も
変わらないので削除する。Discord のロールを読む GET は残す。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7
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.
U-5・U-6 を 4 つに分けた PR の 3 つ目です。FR-5.1(権限を持つ人が、他の部員に同じ権限を渡せる)に対応します。
**この PR は #84(U-6)の上に重ねています。**最後の管理者を外そうとしたときのエラー変換を #84 から使うためです。#84 がマージされたら、マージ先を
developに切り替えます。変更
1. ロールの API(member サービス、
/api/v0/role)ロールの表は member の持ち物なので、member サービスに置きました(
components.md1 章)。どの API も、role.manageを持つ人だけが使えます。GET /roleGET /role/members/{memberId}POST /role/members/{memberId}DELETE /role/members/{memberId}/{roleKey}付与・剥奪の後には、更新後のロールと履歴を返します。履歴は #83 のトリガーが書きます。
断る場合
role.manageがない403 forbidden404 member_not_found409 member_not_active(退部でロールが外れる U-6 と食い違わないため)400 unknown_role404 role_not_held409 last_role_manager2. テストの準備処理を共通化(別コミット
d18fe2d、中身は変えていない)migration を流すテストの準備処理(既存スキーマの再現・migration の再生・部員の作成)を、
migration.integration.test.tsからcore/testing/migrations.tsに移しました。ロールの API のテストでも使うためです。3. Discord ロールの更新の仮実装を削除(
e7e58ef)Discord のロールを変更する機能は作らないことにしました(2026-11-14 決定。
intent.md6.4「V1 では同期しない」のとおり)。置き場所として残していた community のPUT /user/{id}/roleは、固定の値を返すだけで、呼ぶと更新できたように見えて何も変わらないので削除しました。Discord のロールを読むGETは残しています。検証
role.manageを持たない人は、4 つの API すべてで 403wrangler deploy --dry-run(member・community)も OKこの後の PR
🤖 Generated with Claude Code
https://claude.ai/code/session_01Vm1iXpgdwQfcWuyNzX9KF7