Skip to content

fix(cli): kg rename-project cannot remove a project by accident - #546

Open
kevintseng wants to merge 2 commits into
mainfrom
fix/rename-project-same-name
Open

kevintseng wants to merge 2 commits into
mainfrom
fix/rename-project-same-name

Conversation

@kevintseng

@kevintseng kevintseng commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #519.

  • kg rename-project --from X --to X is refused with a one-line error (dry run and --apply). Before, --apply removed the project tag from every memory of X.
  • --apply backs up to backups/ beside the database (not ./data/backups/ under the current directory). The backup is a consistent copy that includes changes still in the write-ahead log, it is owner-only, and the printed restore command is quoted for any path.
  • The dry run counts the message rows the apply would leave in place (the destination already holds an equivalent row) without writing, so it also works on a read-only database, and prints that count. During --apply, only a unique-key collision counts as left in place; any other write error rolls the whole rename back with a one-line message.

Tests

New tests in tests/core/project-tags.test.ts and tests/cli-agent-message-ingress.test.ts cover each point; they fail on the previous code. npm run verify: green.

Renaming a project to itself is refused; before, --apply removed the
project from every memory. The --apply backup is written beside the
database, includes changes still in the write-ahead log, and the dry run
reports the same blocked message rows as the apply.

Closes #519
…isions

The dry run counts the message rows the apply would leave in place with
a query instead of trying the writes, so it also works on a read-only
database. Only a unique-key collision counts as left in place; any other
write error aborts the whole rename with a one-line message. The dry run
prints the count, and the restore command is quoted for any path.

This branch has not been deployed

No deployments
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