Repository navigation
Safely remove registered gateways from CLI - #14
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Lock scope and partial-failure handling can block unrelated gateways or delete configuration before registry persistence succeeds.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds CLI support for removing registered gateway configurations while preserving runtime history and state.
Changes:
- Adds preview, confirmation, stop, and automation options.
- Serializes removal with background startup.
- Adds safety tests and documentation.
| File | Description |
|---|---|
pi_gateway/cli.py |
Implements removal and startup locking. |
tests/test_remove.py |
Tests removal safety behavior. |
README.md |
Documents removal usage. |
docs/02-startup-and-cli-flow.md |
Describes removal flow. |
docs/06-configuration-and-deployment.md |
Documents deployment implications. |
AGENTS.md |
Adds removal guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| raise SystemExit("Specify a gateway name, -c <config-file>, or -i <instance>.") | ||
| config = resolve_config(args) if not args.target else None | ||
| registry = InstanceRegistry(expand_path(REGISTRY_PATH)) | ||
| with registry.locked(): |
Comment on lines
+172
to
+173
| path.unlink(missing_ok=True) | ||
| registry.save([entry for entry in entries if entry is not match]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

$## Summary\n- Add
pi-gateway remove <name>(or-c <config> remove) with status/path preview, confirmation, automation--yes, and non-mutating--dry-run.\n- Refuse running background bots unless--stopsucceeds; serialize removal with background startup.\n- Delete only the selected config and registry entry, preserving database, logs, directories, and Pi sessions.\n- Document limitations for foreground/systemd bots and add removal safety tests.\n\n## Verification\n- Python 3.11 and 3.14: ruff, mypy, pytest (27 passed, 7 subtests),uv build.\n- compileall, CLI help,git diff --check.