Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneesstack72

Relationships

#2515 definitions: delete() silently leaves an auto-definition file unless an earlier lookup cached its path

Opened by stack72 · 9/25/2026· Shipped 9/29/2026

Description

YamlDefinitionRepository.delete(type, id) (src/infrastructure/persistence/yaml_definition_repository.ts) silently does nothing for a definition in the secondary auto-definitions directory unless an earlier lookup cached that file's path in idToActualPath.

delete() tries three paths: the primary directory's id-based path, the primary directory's name-based path, and idToActualPath.get(id). It swallows NotFound for each. Lookups differ in whether they cache a secondary file's path:

  • findByNameGlobal (via searchDefinitionByName) records idToActualPath for secondary matches, so swamp model delete <name> works on an auto-definition.
  • The type-scoped findByName secondary branch only records a nameToActualPath hint, not idToActualPath, and neither does its hinted-secondary branch.
  • findById's secondary fallback (findByIdInDir), which delete() itself calls first, records nothing either.

So findByName(type, name) followed by delete(type, definition.id) on the shared repository (secondary search enabled, the default) reports success and leaves the auto-definition file on disk. Whether it works depends on what else touched that id earlier in the process: a model method run on the same definition happens to cache the path.

This surfaced while fixing swamp-club#2413. The server token GC first looked tokens up with the type-scoped findByName and then deleted through the shared repository. The token's data and secret were removed, but .swamp/auto-definitions/swamp/server-token/<name>.yaml stayed behind unless the token had been revoked in the same process. The #2413 fix works around it the way the admin grant store and access.reload already do: it looks up and deletes through a repository rooted at repoContext.autoDefinitionsDir with secondary search off.

Steps to reproduce

  1. Save a definition into the auto-definitions directory through an auto-definitions-rooted repository (as the token mint does).
  2. In a fresh YamlDefinitionRepository(repoDir) (secondary search on), call findByName(type, name) and then delete(type, definition.id).
  3. The file is still in .swamp/auto-definitions/..., and no error is raised.

Expected

delete() removes the definition wherever it lives, primary or secondary, independent of cache state. That could mean findByIdInDir and the secondary branches of findByName recording idToActualPath as searchDefinitionByName already does, or delete() trying the secondary directory's id and name paths itself. Either way a delete that removed nothing arguably should not report success silently.

02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 11 MOREREVIEW+ 14 MOREPR_MERGED+ 2 MORESESSION_SUMMARIZED

Shipped

9/29/2026, 10:22:42 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack729/29/2026, 8:46:10 PM

Sign in to post a ripple.