Repository navigation
Delete a project: admins delete from Settings, hidden at once, purged after 7 days - #177
Conversation
d7d6ccd to
04682a8
Compare
VisualCIdocspring/visualci · build #587 · 8 changed, 406 unchanged · approved by visualci features agent for Nathan Broadbent
This PR vs base: 26 changed, 22 added since #432, across 4 builds docspring/visualci · journeys · build #576 · 1 changed, 8 added, 41 unchanged · approved by visualci features agent for Nathan Broadbent
This PR vs base: 5 changed, 12 added since #430, across 4 builds
Updated as builds change. Agents can review with VisualCI's MCP tools. |
9fec9c7 to
607d788
Compare
… after 7 days, staff restore before then
8e7bc6c to
ff8b80c
Compare
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 isDELETE /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, migration2026_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 indexWHERE deleted_at IS NULL. I chose that over renaming the slug on delete: the deleted row keeps its real slug, sorestore_projectfinds it byorg/slugand nothing has to be un-renamed. The repository indexes weren't unique, so they needed no change. The picker andimportonly count live projects as "linked", so picking the repository again makes a fresh project.Open check runs:
check_statecompletes a deleted project's check asneutral, "Project deleted", whenever the check would otherwise stay in progress. On delete, every CI build with aforge_check_idwhose check is still in progress gets a queuedforge.checkjob (the existingReportCheck). 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 dailyprojects-purgesweep (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:retention::delete_marked, nowpub(crate)and also checkingvariants), and skips blobs registered in the last 24 hours.Page texts nothing names go with the next
retention:prune.Health check:
/statushas 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_projecttool (org/projectplus 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_orgnow lists deleted projects withdeleted_at.Billing: usage is computed from
credit_transactionsby 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_projecttool on/mcp.Queries changed (central
Project::live()/Project::find_live()in models/projects.rs, plusdeleted_at IS NULLin the raw SQL)http/ui/mod.rsproject_in(every UI project page, builds, snapshots, comments, settings, tokens tab)http/api/mod.rstheApiProjectextractor (find_live) andproject_by_slugs(the API, the MCP project lookup, the live streams, admin tools)http/live.rsbuild_for_cli(find_live)auth/mod.rsPrincipal::from_token(project tokens of deleted projects authenticate nothing) andproject_ids_visibleauth/tokens.rsadmin_projectauth/orgs.rsthe org page's project list;usage_by_project(keeps deleted projects that have credits, flagged)mcp/mod.rsprojects_of(whoami, list_organizations, get_organization)domain/gallery.rsproject_by_slugs(public gallery)domain/projects.rsslug-taken checks increateandchange_settingsdomain/credits.rsopen_source_projectsforge/installations.rspickerproject,importlinked,linked_hereforge/link.rslinked_elsewhereforge/webhooks.rslinked(UPDATE and SELECT),AccessAll,reachforge/sync.rsbackfill_ids,recheck_links,close_deleted_branchesauth/memberships.rslinked_projectsforge/open_source.rsrecheck_duemcp/admin.rsfind_orgcount (live only);get_orgshowsdeleted_atLeft as they are, on purpose:
Project::find/find_or_failby 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".auth/setup.rschecklist history.console/staff.rsorg:delete, which still counts deleted-but-unpurged projects and refuses while data remains.recent_failures, the demo.Tests
app/tests/project_deletion.rs:project_ids_visible,/status;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, journeydelete-a-project: the danger zone and the dialog (light and dark), the toast, the project's 404, and the repository pickable again.reference/access.md("Deleting a project");docs/design.md.Left out
delete_projectover MCP, as the brief asked./statuscovers both the job and the sweep, and the config schema doesn't change.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.