Deleting an agent looked like a no-op: it disappeared from the workforce but
stayed on the Team board, and deleting it again did nothing because the row was
already marked. Two queries selected from `agents` without `deleted_at IS NULL`:
routes/team.rs the leaderboard — the surface still showing them
routes/world.rs the "working" set — a deleted agent holding a stale
agent_containers row rendered as live
Observed on this deployment: /api/workforce correctly returned nothing while
/api/team/leaderboard returned two agents soft-deleted back in June.
NOT changed: those rows still exist. Making delete permanent means hard_purge,
which also deletes usage_events — billing history, 6 credits on one of these
two. Discarding that as a side effect of tidying a roster is an explicit
decision, not something a display fix should smuggle in.
.sqlx regenerated: team.rs uses the compile-time-checked query! macro, so the
cached entry no longer matched.
Co-Authored-By: Claude Opus 5 <[email protected]>
53 lines
1.6 KiB
JSON
53 lines
1.6 KiB
JSON
{
|
|
"db_name": "PostgreSQL",
|
|
"query": "SELECT a.id, a.name, a.accent,\n COALESCE(SUM(u.credits), 0)::BIGINT AS \"credits!\",\n COALESCE(SUM(u.tokens_in + u.tokens_out), 0)::BIGINT AS \"tokens!\",\n COUNT(u.id)::BIGINT AS \"runs!\"\n FROM agents a\n LEFT JOIN usage_events u ON u.agent_id = a.id\n -- deleted_at: a soft-deleted agent is gone everywhere else, so\n -- listing it here made deletion look like a no-op — the operator\n -- deletes it, the board still shows it, and deleting again does\n -- nothing because the row is already marked.\n WHERE a.workspace_id = $1 AND a.deleted_at IS NULL\n GROUP BY a.id, a.name, a.accent\n ORDER BY \"credits!\" DESC, \"tokens!\" DESC, a.name",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"ordinal": 0,
|
|
"name": "id",
|
|
"type_info": "Uuid"
|
|
},
|
|
{
|
|
"ordinal": 1,
|
|
"name": "name",
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"ordinal": 2,
|
|
"name": "accent",
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"ordinal": 3,
|
|
"name": "credits!",
|
|
"type_info": "Int8"
|
|
},
|
|
{
|
|
"ordinal": 4,
|
|
"name": "tokens!",
|
|
"type_info": "Int8"
|
|
},
|
|
{
|
|
"ordinal": 5,
|
|
"name": "runs!",
|
|
"type_info": "Int8"
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Left": [
|
|
"Uuid"
|
|
]
|
|
},
|
|
"nullable": [
|
|
false,
|
|
false,
|
|
false,
|
|
null,
|
|
null,
|
|
null
|
|
]
|
|
},
|
|
"hash": "d5bc028ca030daed4e6111990945d8d7011414d830f7d6d0a04980efb79af2a6"
|
|
}
|