Skip to content

Delete a project: admins delete from Settings, hidden at once, purged after 7 days - #177

Merged
ndbroadbent merged 1 commit into
mainfrom
delete-project
Dec 4, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
delete-project

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Project deletion: there was none in the UI, API or MCP.

What it does

  • Settings tab, bottom: a danger zone (org admins only; members don't see it). "Delete project" opens a <dialog> where you type the project's name; then the org page with a toast ("Deleted "). The API is DELETE /api/ui/orgs/{org}/projects/{project} with {"confirm": "<name>"}: 403 for members, 404 for outsiders, 400 when the name doesn't match.

  • Soft delete at once (projects.deleted_at, deleted_by, migration 2026_12_06_000000_project_deletion). The project leaves every list, its URLs are 404s, its project tokens stop authenticating (so uploads and build creation are refused), and webhooks, the forge sync, the membership sync and the open source recheck ignore it.

  • Its slug and repository are free at once. The UNIQUE (organization_id, slug) constraint becomes a partial unique index WHERE deleted_at IS NULL. I chose that over renaming the slug on delete: the deleted row keeps its real slug, so restore_project finds it by org/slug and nothing has to be un-renamed. The repository indexes weren't unique, so they needed no change. The picker and import only count live projects as "linked", so picking the repository again makes a fresh project.

  • Open check runs: check_state completes a deleted project's check as neutral, "Project deleted", whenever the check would otherwise stay in progress. On delete, every CI build with a forge_check_id whose check is still in progress gets a queued forge.check job (the existing ReportCheck). Any later post for its builds says the same thing. Its gallery's cached URLs are purged too (gallery::purge_project).

  • Purge after 7 days: projects.purge (PurgeProject) is dispatched with a 7-day delay, and a daily projects-purge sweep (02:00, clear of retention's 03:00) catches any job that was lost. Both check that the project is still deleted and at least 7 days old, so a restored project is never purged. The purge:

    1. deletes the downloads' archives;
    2. deletes the builds, newest first in batches (a build's groups only name older builds);
    3. deletes the project row, which cascades to baselines, variants, tokens, threads and the rest;
    4. deletes the renders and diffs that no other project uses;
    5. deletes the blobs nothing names any more, rows and R2/S3 objects. Blobs are shared by hash across projects, so it marks them and deletes each one under its row's lock, the way retention does (retention::delete_marked, now pub(crate) and also checking variants), and skips blobs registered in the last 24 hours.

    Page texts nothing names go with the next retention:prune.

  • Health check: /status has a new figure, oldest_deleted_project_unpurged_seconds. It stays under 8 days (691,200 s) while the job or the sweep is running. The Gatus threshold needs adding in talira-ai/infra.

  • Restore: the admin MCP server has a new restore_project tool (org/project plus a reason; audited like every admin call). It's refused with a clear message while a live project has the slug, or while another organization has linked the repository. get_org now lists deleted projects with deleted_at.

  • Billing: usage is computed from credit_transactions by organization, and those rows lose only their project (ON DELETE SET NULL), so neither deleting nor purging lowers this month's usage (tested). The Usage tab keeps listing a deleted project, marked "deleted", while it has credits this month.

  • There's no delete_project tool on /mcp.

Queries changed (central Project::live() / Project::find_live() in models/projects.rs, plus deleted_at IS NULL in the raw SQL)

  • http/ui/mod.rs project_in (every UI project page, builds, snapshots, comments, settings, tokens tab)
  • http/api/mod.rs the ApiProject extractor (find_live) and project_by_slugs (the API, the MCP project lookup, the live streams, admin tools)
  • http/live.rs build_for_cli (find_live)
  • auth/mod.rs Principal::from_token (project tokens of deleted projects authenticate nothing) and project_ids_visible
  • auth/tokens.rs admin_project
  • auth/orgs.rs the org page's project list; usage_by_project (keeps deleted projects that have credits, flagged)
  • mcp/mod.rs projects_of (whoami, list_organizations, get_organization)
  • domain/gallery.rs project_by_slugs (public gallery)
  • domain/projects.rs slug-taken checks in create and change_settings
  • domain/credits.rs open_source_projects
  • forge/installations.rs picker project, import linked, linked_here
  • forge/link.rs linked_elsewhere
  • forge/webhooks.rs linked (UPDATE and SELECT), AccessAll, reach
  • forge/sync.rs backfill_ids, recheck_links, close_deleted_branches
  • auth/memberships.rs linked_projects
  • forge/open_source.rs recheck_due
  • mcp/admin.rs find_org count (live only); get_org shows deleted_at

Left as they are, on purpose:

  • Project::find/find_or_fail by a build's id in processing, reports, checks and the PR comment. These are reached from builds already in flight, and the check must see the deleted project to say "Project deleted".
  • Retention's keep sets, which the purge covers.
  • auth/setup.rs checklist history.
  • console/staff.rs org:delete, which still counts deleted-but-unpurged projects and refuses while data remains.
  • recent_failures, the demo.

Tests

  • app/tests/project_deletion.rs:
    • permissions: outsider 404, member 403, wrong name 400;
    • hidden everywhere: UI page and builds 404, the org list, project_ids_visible, /status;
    • the token refused, and uploads refused by token and by a personal token naming the project;
    • the slug is free and a new project takes it; restore is refused while the slug is taken and works after a rename; a restored project isn't purged;
    • the purge removes the rows, tokens, the blob row and its object, and keeps a blob another project uses;
    • usage stays the same through delete and purge;
    • a check in progress becomes neutral "Project deleted".
  • app/tests/installations.rs: a deleted project's repository can be picked again and makes a fresh project with the same slug.
  • scripts/screenshots/journeys.mjs, journey delete-a-project: the danger zone and the dialog (light and dark), the toast, the project's 404, and the repository pickable again.
  • Docs: reference/access.md ("Deleting a project"); docs/design.md.

Left out

  • No delete_project over MCP, as the brief asked.
  • No separate heartbeat URL for the sweep: /status covers both the job and the sweep, and the config schema doesn't change.
  • The PR comment on open pull requests is left as it is.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@visualci-com

visualci-com Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #587 · 8 changed, 406 unchanged · approved by visualci features agent for Nathan Broadbent

visualci subdomains: #177 rebased. The project Settings tab gains its danger zone (1440 and 390, light and dark), now in the same .danger-zone style as the org Settings page's. The admin MCP goldens match main's after the rebase.

This PR vs base: 26 changed, 22 added since #432, across 4 builds

Snapshot Before After
screenshots/app/project/settings/1440-dark (changed)
screenshots/app/project/settings/1440-dark-2x (changed)
screenshots/app/project/settings/1440-light (changed)
screenshots/app/project/settings/1440-light-2x (changed)
screenshots/app/project/settings/390-dark (changed)
screenshots/app/project/settings/390-dark-2x (changed)
screenshots/app/project/settings/390-light (changed)
screenshots/app/project/settings/390-light-2x (changed)

docspring/visualci · journeys · build #576 · 1 changed, 8 added, 41 unchanged · approved by visualci features agent for Nathan Broadbent

visualci subdomains: #177 rebased onto #172 and #185. delete-a-project journey: 8 added (danger zone, viewport dialog shots with the note and the filled red confirm, deleted toast, 404, pickable again). 02-dashboard's head is the settled checklist approved in #185's build 539 (the same image); the base is an older main build.

This PR vs base: 5 changed, 12 added since #430, across 4 builds

Snapshot Before After
journeys/sign-in-from-the-site/02-dashboard (changed)
journeys/delete-a-project/01-site (added) –
journeys/delete-a-project/02-danger-zone (added) –
journeys/delete-a-project/03-danger-zone-dark (added) –
journeys/delete-a-project/04-dialog (added) –
journeys/delete-a-project/05-dialog-dark (added) –
journeys/delete-a-project/06-deleted (added) –
journeys/delete-a-project/07-project-404 (added) –
and 1 more in the build

Updated as builds change. Agents can review with VisualCI's MCP tools.

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.

1 participant