creatortrack-dev-slot-lifecycle-and-teardown-button — Handoff¶
URL: https://mkdocs.justinsforge.com/memory/handoffs/creatortrack-dev-slot-lifecycle-and-teardown-button-2026-07-05/
Date: 2026-07-05 Owner: the agent that owns chat.justin (the CreatorTrack session launcher UI) Parent session: feat/shared-week-nav build session (wrote the teardown script + this handoff)
The Goal¶
chat.justin already spawns CreatorTrack parallel-dev slots. Close the loop by letting it tear one down from the same UI: a per-session "Tear down slot" button that kills the dev server, removes the git worktree, and drops the clone DB. This kills the slot-leak problem (there are already ~20+ orphaned ct_* DBs, each a full lifeos-sized copy). Optional stretch: a "Fresh data" toggle on spawn.
Current State¶
- Teardown script is DONE and tested:
~/forge/scripts/forge_creatortrack_agent_teardown.sh <branch> [--keep-db]. Idempotent, faithful end-state reporting, guards refusemain/masterand only ever dropct_*. Verified: main-guard rejects, no-op branch is safe, summary reportsabsent/dropped/removedaccurately. - What it does NOT yet have: a safety refusal on a dirty or unmerged worktree. It currently uses
git worktree remove --force, which discards uncommitted changes. For a one-click button this MUST be gated (see Likely Approach). Recommend adding a default guard to the script (refuse if the worktree has uncommitted/unpushed work;--forceto override) so the button is safe by construction. - Dev-data pipeline context (already fixed this session): slots clone
creatortrack_dev_base, which is a snapshot of livelifeos(prod DB). The base was stale; refreshed it withforge_creatortrack_dev_base.sh --force. That script had a real bug (pg_dump aborted onapp.api_connections— FORCE RLS + real OAuth creds); fixed by--exclude-table-data='app.api_connections'(also correct security: don't clone OAuth tokens into dev). Full detail in scratchpadFINDING-clone-prod-db-into-dev-slot.md.
Files You'll Work With¶
| File | Purpose |
|---|---|
~/forge/scripts/forge_creatortrack_agent_teardown.sh |
The teardown action the button calls (kill server + rm worktree + drop DB) |
~/forge/scripts/forge_creatortrack_agent_bootstrap.sh |
The spawn counterpart (branch → worktree + DB + server). Note: hard-codes ~/forge-suite; repo is now ~/creatortrack (compat symlink added). Slashed-branch names break its dev-server log path. |
~/forge/scripts/forge_creatortrack_dev_base.sh |
Refreshes the template DB from lifeos (for a "Fresh data" toggle) |
| chat.justin launcher backend (you own this) | New endpoint that shells out to the teardown script with the session's branch |
| chat.justin launcher UI (you own this) | The per-session "Tear down slot" button + confirm + optional "keep DB" checkbox |
Likely Approach¶
- Backend endpoint (e.g.
POST /api/slots/teardown{ branch, keepDb }): shells out toforge_creatortrack_agent_teardown.sh <branch> [--keep-db], returns its stdout. chat.justin already tracks each session's branch/port, so the button passes the branch it already knows. - Safety gate BEFORE running (either in the endpoint or, better, add to the script as a default guard):
- Refuse if
git -C <worktree> status --porcelainis non-empty (uncommitted work). - Warn/refuse if the branch has commits not merged into
mainand not pushed to the backup remote (unmerged work would be lost with the worktree). --force/ a UI "I know, delete anyway" to override.- UI: a "Tear down" button per active slot, a confirm dialog showing exactly what will be removed (server :PORT, worktree path, DB name), and a small "Keep DB" checkbox (maps to
--keep-db) for when Justin wants to inspect data after. - Optional stretch — "Fresh data" toggle on spawn: since clones go stale, either (a) a nightly
forge_creatortrack_dev_base.sh --forcetimer so every new slot starts ≤24h fresh, or (b) a per-spawn "refresh base first" checkbox. (a) is the higher-value, ~10-line systemd timer.
Don't Do¶
- Don't reimplement teardown logic in JS — call the script; it owns the correct DB-name derivation and guards.
- Don't tear down a slot with uncommitted/unmerged work without an explicit force + confirm.
--forceworktree removal is irreversible. - Don't let the button drop anything but
ct_*(the script already guards this; don't bypass it). - Don't auto-deploy from chat.justin. Teardown ≠ deploy; keep deploy separate and manual.
- Don't clone OAuth creds back into dev: leave the
app.api_connectionsexclusion inforge_creatortrack_dev_base.sh.
Deliverables¶
- A working per-session "Tear down slot" button in chat.justin wired to the teardown script (with confirm + keep-DB option).
- A safety gate so the button can't silently destroy uncommitted/unmerged work.
- (Optional) Nightly base-refresh timer so new slots carry real, current data.
Done When¶
- Clicking "Tear down" on a slot in chat.justin stops its server, removes its worktree, and drops its
ct_*DB, and the UI reflects the slot as gone. - The button refuses (or hard-confirms) when the worktree is dirty or unmerged.
- "Keep DB" leaves the
ct_*DB in place while removing server + worktree. - No new orphaned
ct_*DBs accumulate from normal spawn/teardown cycles.