Let a person belong to many places, or to none
A person was in exactly one project, chosen at approval, and could not use the gateway before that. People belong to several teams and to none, so: - memberships: a person is a member of any number of organizations, teams and projects, or of none; a member of a team or organization may use every project in it. users join/leave, and the people page adds and takes out from either side. Approval no longer needs a project. - personal keys: a key may have an owner and no project. /profile asks what a new key spends against; keys create --for does the same. auth.personal sets default limits for personal use or turns it off. - limits for people: --scope user holds a person across every key, project and the chat page; --per-member on an org, team or project gives each member their own share there. Resolution folds the tree, each per-member limit for the key's owner, and the owner's own, each in its own pool; the quotas page shows and sets both. - the chat page asks what to spend against and checks it per message. - usage records who spent it, so a person's budget survives a restart, personal use and chat included; restore no longer drops rows with no project. Leaving a project revokes the keys made there unless another membership still reaches it. A personal key keeps no threads or notes, which are per project, and is refused rather than dropped into the anonymous pool. Migration 0010 turns each person's project into a membership, adds usage.user_id and backfills it, and makes api_keys.project_id nullable. SQLite cannot drop NOT NULL, so the table is rebuilt; that needs foreign keys off, which only works outside a transaction, so migrations marked for it run on one connection with foreign_key_check before commit. Tested on a populated SQLite store with claims, and on a copy of the cluster's PostgreSQL store: 5 people became members, 17 keys and 3 claims intact, 145 of 577 usage rows and all 69 chat rows attributed. The PostgreSQL store tests, including new membership cases, pass on 16. users move is gone; join and leave replace it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
429c05a319
commit
098886e0e4
46 files changed
+2372
-468
No files matched your search
@@ -430,3 +430,17 @@ table.quota-tree tr.q-depth-0 .q-name { font-weight: 600; }
|
||||
details.explain { margin-top: 1.5rem; font-size: .88rem; color: var(--muted); }
|
||||
details.explain > summary { cursor: pointer; color: var(--accent); }
|
||||
details.explain p { max-width: 48rem; }
|
||||
|
||||
/* Memberships as removable chips. */
|
||||
.chip-m { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem;
|
||||
border: 1px solid var(--line); border-radius: 999px; padding: .05rem .15rem .05rem .55rem;
|
||||
margin: .1rem .25rem .1rem 0; background: var(--card); white-space: nowrap; }
|
||||
.chip-m form.inline { display: inline; }
|
||||
.chip-x { background: none; color: var(--muted); padding: 0 .35rem; font-weight: 400; line-height: 1.2; }
|
||||
.chip-x:hover { color: var(--bad); filter: none; }
|
||||
td.where { max-width: 26rem; }
|
||||
.scope-members { background: var(--card); border: 1px solid var(--line); border-radius: 6px;
|
||||
padding: .5rem .6rem; margin: .4rem 0; min-width: 24rem; }
|
||||
h3.limits-for { font-size: .92rem; margin: 1rem 0 .4rem; }
|
||||
table.narrow-table { max-width: 30rem; }
|
||||
.q-act a + a { margin-left: .8rem; }
|
||||
Reference in new issue
Block a user