Files
clawmates/.sqlx/query-3d25bfd48bf920da8db9ced892ff99bac77372aeed3e69b32cf52d0100ba2771.json
T
Omar Sobh 806ba869e5
ci / gates (push) Successful in 6s
ci / frontend (push) Successful in 38s
ci / rust (push) Successful in 3m6s
ci / e2e (push) Has been skipped
ci / publish (push) Successful in 2m23s
teams: ephemeral lifecycle for Scheduled + Triggered planner modes
Migration 0033: adds teams.lifecycle ('permanent' | 'ephemeral') and a
topology_runs.team_id back-ref with a partial index for the sibling-in-
flight check.

cm-db repo:
- teams::insert_team_with_lifecycle (insert_team keeps the permanent default)
- topology_runs::enqueue_run_for_team (populates team_id)
- topology_runs::check_ephemeral_teardown — atomic SELECT that only
  returns Some when the team is ephemeral AND no siblings are still
  queued/running; carries the workspace + bound claw ids for cleanup.

cm-api:
- topology_worker post-terminal hook maybe_teardown_ephemeral_team
  runs deprovision_claw on each bound claw (best-effort; failures log
  but don't block Postgres deletion), then hard_purge each agent row,
  then delete_team.
- routes::teams::build_team_with_lifecycle (build_team keeps default);
  run_team enqueues with team_id.
- planner ScaffoldRequest gains mode; lifecycle_for(mode) sets the team
  to ephemeral for scheduled + triggered, permanent otherwise.

Frontend MasterPlannerModal passes mode in the scaffold payload so the
backend can derive lifecycle without duplicating the mode taxonomy.

Tests: 3 new (returns claws when no siblings, holds when siblings queued,
ignores permanent teams). 10/10 topology_jobs green; workspace clippy
--tests clean.
2026-07-07 04:30:07 -07:00

29 lines
917 B
JSON

{
"db_name": "PostgreSQL",
"query": "SELECT t.id AS team_id, t.workspace_id\n FROM topology_runs r\n JOIN teams t ON t.id = r.team_id\n WHERE r.id = $1\n AND t.lifecycle = 'ephemeral'\n AND NOT EXISTS (\n SELECT 1 FROM topology_runs sib\n WHERE sib.team_id = t.id\n AND sib.id <> r.id\n AND sib.status IN ('queued', 'running')\n )",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "team_id",
"type_info": "Uuid"
},
{
"ordinal": 1,
"name": "workspace_id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"Uuid"
]
},
"nullable": [
false,
false
]
},
"hash": "3d25bfd48bf920da8db9ced892ff99bac77372aeed3e69b32cf52d0100ba2771"
}