feat(database): add Manager followers
Merged
DA
3d ago+24913+24913+01234567890123456789012345678901234567890123456789-0-0-0123456789
PR 1 of the Manager settings plan (STAG-4014): a Manager gets followers of its own, with the per-person machines switch a task's followers have, so later PRs can send its Mac calls to a follower's Mac.
What changes
agent_followertable:agent_id,user_id,machines,created_at. Keyed by agent and member, both cascading on delete, with an index on the member. It mirrorstask_follower.- Backfill: every member who sent a line to an agent on no task follows it with machines off, so they turn it on themselves. This matches how
task_follower's backfill treated senders. The owner is left out, and so is anyone no longer a member of the agent's workspace. The insert is idempotent. agent-follower-store.ts:listAgentFollowers,followAgent,unfollowAgent,setAgentFollowerMachines.- Every call is gated on the account reaching the agent (
agentVisibleTo) and on the agent standing on no task. An agent on a task reads as no agent, because its task holds its followers. - A follower must be a member of the agent's workspace, and one who leaves reads as no follower.
- Only a follower flips their own
machines. Following again keeps the switch as it is. - The owner always counts. They hold no row and are read from
agent.user_id, listed first with machines on. Unfollowing them, or the owner switching their own machines, fails withAgentFollowerIsOwner.
- Every call is gated on the account reaching the agent (
No service, wire, sync, or UI changes. The hosted procedures, live read, routing and follow-on-message come in PR 2.
Tests
- I ran
packages/database/src/models/__tests__/agent-follower-store.test.ts(new, 4 cases). It covers: the owner always follows and can't be unfollowed or switched; following again keeps a follower's switch, and a member can remove another follower; an account in another workspace can't read, add, remove or switch followers, and a member who leaves drops out; an agent on a task reads as no agent. - I ran
apps/web/tests/storage-schema.test.ts, which now declaresagent_follower. drizzle-kit check,repository-checks.shand the database package typecheck pass. CI runs the rest.
š¤ Generated with Claude Code