Skip to content

fix(teams): read-only key use names the key, and Team settings flags keys whose minter is no longer an admin - #116

Merged
ashot merged 4 commits into
codecast-sh:mainfrom
triptu:feat/team-read-key-followups
Nov 23, 2026
Merged

ashot merged 4 commits into
codecast-sh:mainfrom
triptu:feat/team-read-key-followups

Conversation

@triptu

@triptu triptu commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

From Tushar's coding agent. Follow-ups to #105: the use event's actor, and the flag in Team settings.

When a read-only key is used, cast audit now names the key as the actor, not the admin who minted it. Team settings flags a live key whose minter was demoted or left the team ("no longer a team admin"), next to its Revoke button.

The real app against a local Convex backend, at eded5ec1. Ada is an admin. While the section is open she demotes Christopher Hernandez, and his key's flag appears without a reload. Metrics export is already flagged, because its minter, Mo, left the team:

flag-appears-after-demotion.mp4

Desktop, light. Ada's own key has no flag:

Read-only keys at desktop width, light: two keys flagged no longer a team admin

Phone, light Phone, dark
Read-only keys at phone width, light: the long name and the flag each on their own line The same at phone width, dark
More detail from Coding agent

The key as the actor

  • authority_events.actor_user_id is now optional. A new optional actor_key_id (an id in team_read_keys) sits beside it.
  • The writer's input type takes exactly one of the two. A key actor must also carry a team_id, and its event is filed under team:<id>, so every member still reads it.
  • Only team_read_key_used uses a key actor. Minting and revoking still name the admin who did them.
  • Readers of the actor:
    • cast audit prints by key <id>.
    • Its --json output has actor_key_id and no actor_user_id.
    • authorityEvents.list finds key events through the team workspace, as before.
    • No web screen, export or deletion plan reads the actor.

Alternatives considered:

  • A single string actor such as user:<id> or key:<id>: every existing row would need a backfill.
  • Keeping the minter as the actor and naming the key only in detail: a former admin would still show as acting.

The flag

  • teamReadKeys.list returns created_by_still_admin for each live key. It is false when the minter's membership is gone or its role is not admin.
  • For an ended key it is null, because the list looks up only the minters of live keys. The live-key cap bounds those reads at ten.
  • The row flags only on an explicit false, so a row cached before this change is not flagged.
  • The flag is its own item in the row's detail line. It wraps on its own at phone width, so a long name never cuts it off.
  • One wording covers a demoted minter and one who left, so there is no new state.

Tests

  • teamReadKeys.test.ts:
    • The audit test checks actor_user_id and actor_key_id separately. A use event has no actor_user_id.
    • A new test demotes one minter and has another leave, through teams.setMemberRole and teams.removeFromTeam. It then revokes a key and expects null for it.
  • Each test fails when its change is reverted.
  • The cast audit line has no unit test, because the command has none. The live run below covers it.

Checks

  • bun test passed 80 tests and failed 0 across 13 files: teamReadKeys, authorityEvents, authorityEvents.guard, conversations.shareLink, staff, publicShare and teams.*. This was after merging main.
  • cast check convex, cast check cli and cast check web report 0 errors each.
  • Live, on a local anonymous backend:
    • A key whose minter had left still read GET /cli/v1/team/sessions with a 200.
    • cast audit showed team_read_key_used by key rn8enb0r.

A key belongs to its team and keeps working after the admin who minted
it is demoted or leaves, so team_read_key_used no longer names that admin.
authority_events takes an actor_key_id in place of actor_user_id for it;
mint and revoke keep their admin. cast audit prints the key as the actor.

Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
The key list says, for each key, whether the admin who minted it is
still an admin of the team. Team settings shows a live key whose minter
was demoted or left as "by <name>, no longer an admin", beside Revoke.

Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
The flag reads "no longer a team admin" as its own item, so it wraps
instead of being cut off at phone width, and only an explicit false
from the server sets it, so a row cached before the field existed is
not flagged. The list looks up the minters of live keys only, which the
live-key cap bounds. The audit test checks actor_user_id and
actor_key_id separately.

Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
@ashot
ashot merged commit 28e5ebe into codecast-sh:main Nov 23, 2026
29 of 31 checks passed
@ashot

ashot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Merged, thanks. This is backend (Convex) code, so it goes live with the next Convex deploy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants