Skip to content

fix(cleanup): never delete resources matched by .vapi-ignore - #73

Open
scott-lowe-vapi wants to merge 1 commit into
docs/agent-instructionsfrom
fix/cleanup-honor-vapi-ignore
Open

scott-lowe-vapi wants to merge 1 commit into
docs/agent-instructionsfrom
fix/cleanup-honor-vapi-ignore

Conversation

@scott-lowe-vapi

@scott-lowe-vapi scott-lowe-vapi commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Value

V.A.L.U.E. tier: small — a behavior change in a destructive command (npm run cleanup). Not micro: it changes what the command deletes.

  • Problem: npm run cleanup -- <org> --force --confirm <org> deletes every platform resource that isn't in .vapi-state.<org>.json. That included resources matched by resources/<org>/.vapi-ignore, which is how users tell this repo "don't manage these". push already respected the ignore file; cleanup didn't. So the file you write to protect a resource was the one way to get it deleted (improvements.md refactor(push): extract reconcileStateKeyForResource — fold two ensure-fns into one generic helper #36).
  • Who it affects: anyone who runs cleanup in an org that also holds resources managed outside this repo (dashboard-owned assistants, legacy tools, another team's squad).
  • What changes:
    • Cleanup loads .vapi-ignore and checks each orphan against it, using the file IDs pull would give it (<slug>-<uuid8>, and the bare slug), so a pattern written against your files matches the platform resource too.
    • Matched resources are listed as 🚫 <name> retained (matched .vapi-ignore: <pattern>) and never deleted, in dry runs and destructive runs. The summary counts them.
    • AGENTS.md, the workflows guide and .vapi-ignore.example say that neither push nor cleanup touches ignored resources. improvements.md refactor(push): extract reconcileStateKeyForResource — fold two ensure-fns into one generic helper #36 is marked resolved.

Evidence of value

New tests/cleanup-ignore.test.ts runs the real src/cleanup.ts against a stub API holding a tracked assistant, an ignored assistant (assistants/legacy-*), an ignored tool (tools/legacy-*) and one genuine orphan.

Run Before this PR After
Destructive cleanup: DELETE requests 3 — the orphan plus the ignored assistant and tool 1 — the orphan only
Dry run output Lists the ignored resources as "would delete" Lists them as retained, naming the matching pattern

The test was run against the old cleanup.ts first and failed on the extra deletes, then passed with the fix.

Testing plan

  • npm test and npx tsc --noEmit pass.
  • Not tested: a live cleanup against a real org. The stub mirrors the list and delete endpoints cleanup calls; no live run was needed to show the bug or the fix.

Refs TEST-141

🤖 Generated with Claude Code

.vapi-ignore marks platform resources a repository must not manage, and
pull never writes them to state. cleanup treats every platform resource
missing from state as an orphan and didn't read .vapi-ignore, so a
destructive cleanup deleted exactly the resources a team had excluded,
such as another team's assistants in a shared org. Push already
orphan-protects them.

cleanup now loads the org's ignore patterns and keeps every orphan that
matches, checking the IDs pull would give the resource (its name slug,
with and without the UUID suffix). Kept resources are listed as retained
in both dry and destructive runs.

tests/cleanup-ignore.test.ts runs the real cleanup command against a stub
API: before this change a destructive run deleted an ignored assistant
and tool along with the true orphan; now only the orphan.

Docs: AGENTS.md, the workflows guide and .vapi-ignore.example describe
the fixed behaviour; improvements.md #36 is resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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