fix(daemons): block owner transfer while assigned
This commit is contained in:
+10
-1
@@ -325,6 +325,15 @@
|
||||
4. `repo.revoke_tokens_by_daemon_id(daemon_id)` — 바인딩된 모든 active service token에 `revoked_at=NOW()` 설정.
|
||||
5. Console에 revoked count 출력.
|
||||
|
||||
## Flow: `PATCH /v1/admin/daemons/{daemon_id}` — Owner Transfer
|
||||
|
||||
1. Admin authentication is required; an unknown daemon returns HTTP 404.
|
||||
2. For an effective `owner_user_id` change, `update_daemon_owner()` starts one transaction and locks the daemon row `FOR UPDATE`.
|
||||
3. It checks `portfolios.managed_by_daemon_id` while holding that lock.
|
||||
- A reference exists: raise the dedicated conflict and return HTTP 409. Daemon owner, portfolio assignment, and broker credentials remain unchanged.
|
||||
- No reference exists: delete credentials, update the daemon owner, and commit the existing atomic credential-invalidation flow.
|
||||
4. Portfolio assignment uses `FOR SHARE` on the same daemon row before INSERT/UPDATE. Thus transfer-first makes the old owner's pending assignment fail as foreign; assignment-first makes the transfer fail HTTP 409. No automatic unassignment, portfolio owner migration, or alternate-daemon reassignment occurs.
|
||||
|
||||
## Flow: `Service-Token Rotate — daemon_id Invariant`
|
||||
|
||||
1. Operator calls `pfhub service-token rotate <name> --force`.
|
||||
@@ -492,4 +501,4 @@
|
||||
- 2026-05-11 KST: bat-007 — Added "Local DB Initialization and Validation" flow (Scenario A/B, repeatable run criteria); added "Alembic vs ensure_schema() Schema Ownership Boundary" flow.
|
||||
- 2026-05-11 KST: bat-006 — Added CLI portfolio name+user resolution flow; updated GET /v1/assets flow to note asset_id is UUID after BAT-006 migration.
|
||||
- 2026-05-01 KST: bat-001 — Added v1 API flows (service-token auth, GET /v1/assets, GET /v1/user_info, POST ledger/trades, POST /auth/service-tokens), startup validation flow.
|
||||
- 2026-04-30 KST: Bootstrap baseline created from repository observation for initial StagePilot adoption.
|
||||
- 2026-04-30 KST: Bootstrap baseline created from repository observation for initial StagePilot adoption.
|
||||
|
||||
Reference in New Issue
Block a user