mystack-rig 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. mystack_rig-1.1.0/GLOSSARY.md +21 -0
  2. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/Makefile +28 -19
  3. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/PKG-INFO +31 -13
  4. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/README.md +30 -12
  5. mystack_rig-1.1.0/docs/adr/0001-per-profile-generated-state-bucket.md +21 -0
  6. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/main.py +68 -18
  7. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/remote_dev.py +408 -69
  8. mystack_rig-1.1.0/src/cli/state_bucket.py +118 -0
  9. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/storage.py +21 -2
  10. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/PKG-INFO +31 -13
  11. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/SOURCES.txt +4 -0
  12. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/scm_file_list.json +4 -0
  13. mystack_rig-1.1.0/src/mystack_rig.egg-info/scm_version.json +8 -0
  14. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/conftest.py +11 -0
  15. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_attach_command.py +1 -1
  16. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_destroy_command.py +22 -7
  17. mystack_rig-1.1.0/tests/test_firewall_client_ip.py +492 -0
  18. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_init_command.py +72 -1
  19. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_main_coverage.py +5 -5
  20. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_remote_dev.py +0 -18
  21. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_remote_dev_coverage_extensions.py +44 -2
  22. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_rig_ansible_vars.py +8 -0
  23. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_setup_provision.py +79 -1
  24. mystack_rig-1.1.0/tests/test_state_bucket.py +309 -0
  25. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_storage_basic.py +42 -0
  26. mystack_rig-1.0.0/src/mystack_rig.egg-info/scm_version.json +0 -8
  27. mystack_rig-1.0.0/tests/test_firewall_client_ip.py +0 -259
  28. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.coveragerc +0 -0
  29. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.flake8 +0 -0
  30. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.github/workflows/release.yml +0 -0
  31. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.github/workflows/tests.yml +0 -0
  32. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.gitignore +0 -0
  33. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.rig/playbooks/README.md +0 -0
  34. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/.rig/playbooks/vpn-gateway.yml +0 -0
  35. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/CLI_STORAGE_SUMMARY.md +0 -0
  36. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/Dockerfile +0 -0
  37. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/GIT_CLONE_FEATURE.md +0 -0
  38. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/HETZNER_STORAGE_GUIDE.md +0 -0
  39. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/HETZNER_STORAGE_SECURITY_GUIDE.md +0 -0
  40. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/LICENSE +0 -0
  41. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/README_REAL_E2E.md +0 -0
  42. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/STORAGE_CLI_GUIDE.md +0 -0
  43. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/docs/architecture.md +0 -0
  44. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/docs/architecture.png +0 -0
  45. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/docs/architecture.svg +0 -0
  46. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/forged-idea.md +0 -0
  47. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/pyproject.toml +0 -0
  48. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/pytest.ini +0 -0
  49. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/requirements.txt +0 -0
  50. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/sample.env +0 -0
  51. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/scripts/coverage_badge.py +0 -0
  52. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/scripts/pypi_version.py +0 -0
  53. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/setup.cfg +0 -0
  54. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/__init__.py +0 -0
  55. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/__init__.py +0 -0
  56. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/__main__.py +0 -0
  57. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/agents.py +0 -0
  58. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/config.py +0 -0
  59. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/encrypt.py +0 -0
  60. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/git.py +0 -0
  61. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/last_env.py +0 -0
  62. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/last_session.py +0 -0
  63. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/log.py +0 -0
  64. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/requirements.txt +0 -0
  65. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/snapshots.py +0 -0
  66. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/vault_keys.py +0 -0
  67. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/cli/vpn.py +0 -0
  68. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/dependency_links.txt +0 -0
  69. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/entry_points.txt +0 -0
  70. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/requires.txt +0 -0
  71. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/src/mystack_rig.egg-info/top_level.txt +0 -0
  72. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/test_hetzner_integration.py +0 -0
  73. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_agents.py +0 -0
  74. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_ansible_galaxy.py +0 -0
  75. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_credential_security.py +0 -0
  76. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_dev_command.py +0 -0
  77. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_encrypt_command.py +0 -0
  78. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_encrypt_coverage.py +0 -0
  79. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_git_clone_unit.py +0 -0
  80. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_git_manager.py +0 -0
  81. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_gitignore_init.py +0 -0
  82. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_hetzner_storage.py +0 -0
  83. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_last_env.py +0 -0
  84. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_last_session.py +0 -0
  85. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_log.py +0 -0
  86. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_pypi_version.py +0 -0
  87. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_real_e2e_integration.py +0 -0
  88. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_real_e2e_storage.py +0 -0
  89. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_real_e2e_vpn.py +0 -0
  90. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_real_e2e_vpn_tunnel.py +0 -0
  91. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_rig_config.py +0 -0
  92. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_simulation_storage.py +0 -0
  93. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_small_module_coverage.py +0 -0
  94. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_snapshots.py +0 -0
  95. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_vault_keys.py +0 -0
  96. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_vpn_optional.py +0 -0
  97. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_vpn_unit.py +0 -0
  98. {mystack_rig-1.0.0 → mystack_rig-1.1.0}/tests/test_workspace_git_clone.py +0 -0
@@ -0,0 +1,21 @@
1
+ # Rig
2
+
3
+ Rig provisions and tracks remote development environments on Hetzner Cloud for a team.
4
+
5
+ ## Language
6
+
7
+ **Profile**:
8
+ A named set of credentials for one Hetzner Cloud project, stored in the developer's personal rig config.
9
+ _Avoid_: Installation, account
10
+
11
+ **State bucket**:
12
+ The storage bucket holding environment state for one Profile within one workspace, shared by everyone working in that workspace.
13
+ _Avoid_: Production bucket, installation bucket
14
+
15
+ **Workspace**:
16
+ A project repository containing a `.rig/` directory, which owns its own State buckets.
17
+ _Avoid_: Project (ambiguous with a Hetzner Cloud project)
18
+
19
+ **Test bucket**:
20
+ A throwaway state bucket used only by automated test runs.
21
+ _Avoid_: Dev bucket
@@ -1,44 +1,53 @@
1
- .PHONY: install test test-e2e test-remote-dev test-remote-dev-e2e coverage run lint clean
1
+ VENV := .venv
2
+ PY := $(VENV)/bin/python3
3
+
4
+ .PHONY: venv install test test-e2e test-remote-dev test-remote-dev-e2e coverage run lint clean
5
+
6
+ # Create local venv (avoids PEP 668 on Homebrew/system Python)
7
+ venv: $(PY)
8
+
9
+ $(PY):
10
+ python3 -m venv $(VENV)
2
11
 
3
12
  # Install dependencies
4
- install:
5
- pip install -r requirements.txt
6
- pip install -e .
13
+ install: venv
14
+ $(PY) -m pip install -r requirements.txt
15
+ $(PY) -m pip install -e .
7
16
 
8
17
  # Run the CLI
9
- run:
10
- python3 -m cli.main
18
+ run: venv
19
+ $(PY) -m cli.main
11
20
 
12
21
  # Run tests
13
- test:
14
- python3 -m pytest tests/
22
+ test: venv
23
+ $(PY) -m pytest tests/
15
24
 
16
25
  # Measure src coverage and refresh the README badge
17
- coverage:
18
- python3 -m pytest tests/ --cov=src --cov-report=term-missing --cov-report=xml \
26
+ coverage: venv
27
+ $(PY) -m pytest tests/ --cov=src --cov-report=term-missing --cov-report=xml \
19
28
  --ignore=tests/test_real_e2e_integration.py \
20
29
  --ignore=tests/test_real_e2e_storage.py \
21
30
  --ignore=tests/test_hetzner_storage.py \
22
31
  --ignore=tests/test_workspace_git_clone.py \
23
32
  --ignore=tests/test_real_e2e_vpn.py \
24
33
  --ignore=tests/test_real_e2e_vpn_tunnel.py
25
- python3 scripts/coverage_badge.py --write
34
+ $(PY) scripts/coverage_badge.py --write
26
35
 
27
36
  # Run E2E tests with Hetzner integration
28
- test-e2e:
29
- python3 test_hetzner_integration.py
37
+ test-e2e: venv
38
+ $(PY) test_hetzner_integration.py
30
39
 
31
40
  # Run remote dev unit tests
32
- test-remote-dev:
33
- python3 -m pytest tests/test_remote_dev.py -v
41
+ test-remote-dev: venv
42
+ $(PY) -m pytest tests/test_remote_dev.py -v
34
43
 
35
44
  # Run remote dev E2E tests
36
- test-remote-dev-e2e:
37
- python3 -m pytest tests/test_workspace_git_clone.py -v -m e2e
45
+ test-remote-dev-e2e: venv
46
+ $(PY) -m pytest tests/test_workspace_git_clone.py -v -m e2e
38
47
 
39
48
  # Run linting
40
- lint:
41
- pylint src/
49
+ lint: venv
50
+ $(PY) -m pylint src/
42
51
 
43
52
  # Clean build artifacts
44
53
  clean:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mystack-rig
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Ephemeral remotes with full local parity for coding agents
5
5
  Author: mystack-cloud
6
6
  License-Expression: MIT
@@ -21,6 +21,7 @@ Requires-Dist: cryptography>=41.0.0
21
21
  Requires-Dist: importlib-metadata>=4.0; python_version < "3.8"
22
22
  Dynamic: license-file
23
23
 
24
+ [![PyPI](https://img.shields.io/pypi/v/mystack-rig)](https://pypi.org/project/mystack-rig/)
24
25
  [![Tests](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml/badge.svg)](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml)
25
26
  [![codecov](https://codecov.io/gh/mystack-cloud/rig/graph/badge.svg)](https://codecov.io/gh/mystack-cloud/rig)
26
27
 
@@ -34,8 +35,6 @@ rig init
34
35
  rig create
35
36
  ```
36
37
 
37
- The published project name is `mystack-rig` (the PyPI name `rig` belongs to another project). The command is still `rig`. From a checkout, `pip install .` installs the same command.
38
-
39
38
  ## Architecture
40
39
 
41
40
  Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs you can create and dispose anytime, and you work on `/workspace` via agent TTY or editor. SSH/HTTPS reaches VMs through the firewall; HTTPS reaches the provider. The CLI stores env state in S3-compatible object storage.
@@ -113,7 +112,7 @@ host:
113
112
  firewall:
114
113
  mode: dynamic_add # open | static | dynamic_replace | dynamic_add
115
114
  allowed_ips: [] # static allow-list; also merged into dynamic modes
116
- ports: [] # extra inbound ports, e.g. [8080, "3000-3001", {port: 53, protocol: udp}]
115
+ ports: [] # extra inbound ports; each may set mode and allowed_ips
117
116
  agent:
118
117
  default: opencode # default for `rig attach`; or claude | cursor
119
118
  enabled: [opencode] # agents installed on the VM
@@ -138,16 +137,26 @@ Firewall modes:
138
137
  | `dynamic_replace` | Set allow-list to current CLI public IP (+ `allowed_ips`); drops previous IPs |
139
138
  | `dynamic_add` (default) | Keep existing allow-list entries; add current CLI public IP if missing |
140
139
 
141
- Attach / apply / dev / destroy refresh the firewall for dynamic modes when the client IP changes, and keep `ports` in sync.
140
+ Attach / apply / dev / delete refresh the firewall for dynamic modes when the client IP changes, and keep `ports` in sync.
142
141
 
143
- `firewall.ports` opens extra inbound listeners with the same source-IP policy as SSH (TCP by default; use `{port, protocol}` for UDP).
142
+ `firewall.ports` opens extra inbound listeners. A bare port or a mapping with no `mode` uses `firewall.mode` and `firewall.allowed_ips`, same as SSH (TCP by default; use `{port, protocol}` for UDP). Set `mode` to `open`, `static`, `dynamic_replace`, or `dynamic_add` for that port only. Set `allowed_ips` to replace the firewall list for that port; omit it to inherit. `allowed_ips: []` on a `static` port does not fall back to world access. SSH (22) and ICMP stay on `firewall.mode`.
143
+
144
+ ```yaml
145
+ ports:
146
+ - 8080 # firewall.mode + firewall.allowed_ips
147
+ - port: 443
148
+ mode: open # 0.0.0.0/0 and ::/0
149
+ - port: 9090
150
+ mode: static
151
+ allowed_ips: ["198.51.100.10/32"]
152
+ ```
144
153
 
145
154
  Remote project files live under `/workspace` (not `/root`).
146
155
 
147
156
  ## Lifecycle
148
157
 
149
158
  ```text
150
- init → create → attach | dev | apply → destroy
159
+ init → create → attach | dev | apply → delete
151
160
  ↓
152
161
  snapshots (reuse on next create)
153
162
 
@@ -171,10 +180,10 @@ destroy playbooks:
171
180
  | --- | --- |
172
181
  | **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
173
182
  | **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
174
- | **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize`. |
183
+ | **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
175
184
  | **attach** | SSH TTY into `opencode` / `claude` / Cursor `agent` on `/workspace`. `--agent` picks among installed agents. |
176
185
  | **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
177
- | **destroy** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. |
186
+ | **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
178
187
 
179
188
  Put secret-free installs in `configure.yml` (cached). Put clone/setup that needs credentials in `materialize.yml`.
180
189
 
@@ -213,12 +222,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
213
222
  | --- | --- | --- |
214
223
  | `init` | | Interactive scaffold |
215
224
  | `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
216
- | `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize]` | Default: authorize then materialize |
225
+ | `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
217
226
  | `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` | Reopens last remembered session by default; `--agent` picks which installed agent |
218
227
  | `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
219
228
  | `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
220
229
  | `list` | | Lists envs, or `No remote environments` |
221
- | `destroy` | `[name …]` | Runs finalize then destroy playbooks first; multi-name OK |
230
+ | `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
222
231
  | `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
223
232
  | `vars encrypt` | `[--stdin-name VAR]` `[--personal]` | Vault into shared or identity vars (after master-key unlock) |
224
233
  | `vars decrypt` | `[VAR]` | Decrypt from shared or identity vars |
@@ -245,7 +254,7 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
245
254
  | `rig_workspace_root` | `/workspace` |
246
255
  | `rig_version` | Installed `rig` package version |
247
256
  | `rig_boot_source` | `base` \| `system` \| `workspace` |
248
- | `rig_action` | `create` \| `apply` \| `destroy` |
257
+ | `rig_action` | `create` \| `apply` \| `destroy` (`rig delete` still sets `destroy`) |
249
258
  | `rig_project_dir` | Local project path |
250
259
  | `rig_ssh_key_name` / `rig_ssh_key_path` | Local key under `/tmp` |
251
260
  | `rig_firewall_name` | Firewall resource name |
@@ -264,12 +273,21 @@ Also available from vars files (defaults): `workspace_root`, `coding_agent_type`
264
273
  | Personal master key | Prompted on init/unlock; **never stored**. Unwraps data keys from `vars.{identity}.yml`. |
265
274
  | `rig_identity_data_key` / `rig_shared_data_key` | Master-key wraps inside `vars.{identity}.yml` (committed). |
266
275
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
267
- | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / destroy finalizers). |
276
+ | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
268
277
 
269
278
  `RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
270
279
 
271
280
  OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
272
281
 
282
+ ## Development
283
+
284
+ From a checkout, `pip install .` installs the same `rig` command. Use an editable install so the command keeps using this tree while you change it:
285
+
286
+ ```bash
287
+ pip install -e .
288
+ rig --version
289
+ ```
290
+
273
291
  ## Tests
274
292
 
275
293
  ```bash
@@ -1,3 +1,4 @@
1
+ [![PyPI](https://img.shields.io/pypi/v/mystack-rig)](https://pypi.org/project/mystack-rig/)
1
2
  [![Tests](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml/badge.svg)](https://github.com/mystack-cloud/rig/actions/workflows/tests.yml)
2
3
  [![codecov](https://codecov.io/gh/mystack-cloud/rig/graph/badge.svg)](https://codecov.io/gh/mystack-cloud/rig)
3
4
 
@@ -11,8 +12,6 @@ rig init
11
12
  rig create
12
13
  ```
13
14
 
14
- The published project name is `mystack-rig` (the PyPI name `rig` belongs to another project). The command is still `rig`. From a checkout, `pip install .` installs the same command.
15
-
16
15
  ## Architecture
17
16
 
18
17
  Run `rig` from your machine, CI/CD, or a control plane: it provisions cloud VMs you can create and dispose anytime, and you work on `/workspace` via agent TTY or editor. SSH/HTTPS reaches VMs through the firewall; HTTPS reaches the provider. The CLI stores env state in S3-compatible object storage.
@@ -90,7 +89,7 @@ host:
90
89
  firewall:
91
90
  mode: dynamic_add # open | static | dynamic_replace | dynamic_add
92
91
  allowed_ips: [] # static allow-list; also merged into dynamic modes
93
- ports: [] # extra inbound ports, e.g. [8080, "3000-3001", {port: 53, protocol: udp}]
92
+ ports: [] # extra inbound ports; each may set mode and allowed_ips
94
93
  agent:
95
94
  default: opencode # default for `rig attach`; or claude | cursor
96
95
  enabled: [opencode] # agents installed on the VM
@@ -115,16 +114,26 @@ Firewall modes:
115
114
  | `dynamic_replace` | Set allow-list to current CLI public IP (+ `allowed_ips`); drops previous IPs |
116
115
  | `dynamic_add` (default) | Keep existing allow-list entries; add current CLI public IP if missing |
117
116
 
118
- Attach / apply / dev / destroy refresh the firewall for dynamic modes when the client IP changes, and keep `ports` in sync.
117
+ Attach / apply / dev / delete refresh the firewall for dynamic modes when the client IP changes, and keep `ports` in sync.
119
118
 
120
- `firewall.ports` opens extra inbound listeners with the same source-IP policy as SSH (TCP by default; use `{port, protocol}` for UDP).
119
+ `firewall.ports` opens extra inbound listeners. A bare port or a mapping with no `mode` uses `firewall.mode` and `firewall.allowed_ips`, same as SSH (TCP by default; use `{port, protocol}` for UDP). Set `mode` to `open`, `static`, `dynamic_replace`, or `dynamic_add` for that port only. Set `allowed_ips` to replace the firewall list for that port; omit it to inherit. `allowed_ips: []` on a `static` port does not fall back to world access. SSH (22) and ICMP stay on `firewall.mode`.
120
+
121
+ ```yaml
122
+ ports:
123
+ - 8080 # firewall.mode + firewall.allowed_ips
124
+ - port: 443
125
+ mode: open # 0.0.0.0/0 and ::/0
126
+ - port: 9090
127
+ mode: static
128
+ allowed_ips: ["198.51.100.10/32"]
129
+ ```
121
130
 
122
131
  Remote project files live under `/workspace` (not `/root`).
123
132
 
124
133
  ## Lifecycle
125
134
 
126
135
  ```text
127
- init → create → attach | dev | apply → destroy
136
+ init → create → attach | dev | apply → delete
128
137
  ↓
129
138
  snapshots (reuse on next create)
130
139
 
@@ -148,10 +157,10 @@ destroy playbooks:
148
157
  | --- | --- |
149
158
  | **init** | Scaffold `rig.yml` + `.rig/`. Collect Hetzner creds, repo PATs, agent choices and a key per agent. |
150
159
  | **create** | Boot VM (base/system snapshot). Run provision → configure → authorize → materialize. Snapshot after **configure** only. |
151
- | **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize`. |
160
+ | **apply** | Default: authorize → materialize. Flags: `--provision` / `--configure` / `--authorize` / `--materialize` / `--finalize` / `--destroy` (playbooks only; the VM stays). `--tags` is passed to every playbook in the run. |
152
161
  | **attach** | SSH TTY into `opencode` / `claude` / Cursor `agent` on `/workspace`. `--agent` picks among installed agents. |
153
162
  | **dev** | Open VS Code/Cursor via Remote-SSH on `/workspace` (or `--browser` for code-server). |
154
- | **destroy** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. |
163
+ | **delete** | Run finalize → destroy playbooks, then delete VM / firewall / SSH key. `--tags` is passed to both playbooks. |
155
164
 
156
165
  Put secret-free installs in `configure.yml` (cached). Put clone/setup that needs credentials in `materialize.yml`.
157
166
 
@@ -190,12 +199,12 @@ Global: `-v` playbook tasks and debug · `-vv`/`-vvv`/`-vvvv` ansible verbosity
190
199
  | --- | --- | --- |
191
200
  | `init` | | Interactive scaffold |
192
201
  | `create` | `[--name]` `[--provider]` `[--type]` `[--availability-zone]` `[--image]` `[--no-attach]` `[--force-playbooks\|--force-system\|--force-workspace]` | Host defaults from `rig.yml`. `--provider` defaults to `hetzner`. `--type` sets `host.server_type`. `host.type` defaults to `vm`. `--region` aliases `--availability-zone`. |
193
- | `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize]` | Default: authorize then materialize |
202
+ | `apply` | `[name]` `[--provision\|--configure\|--authorize\|--materialize\|--finalize\|--destroy]` `[--tags TAGS]` | Default: authorize then materialize. Each flag runs that playbook (`--provision` also runs configure and authorize; `--materialize` also runs authorize). `--finalize` and `--destroy` do not delete the VM. `--tags` limits every playbook in the run |
194
203
  | `attach` | `[name]` `[-c\|--continue]` `[-s\|--session ID]` `[--resume [ID]]` `[--agent opencode\|claude\|cursor]` `[-- …agent args]` | Reopens last remembered session by default; `--agent` picks which installed agent |
195
204
  | `ssh` | `[name]` `[-- command]` | Shell on the VM in `/workspace`. A command after `--` runs instead of a login shell |
196
205
  | `dev` | `[name]` `[--path /workspace]` `[--browser]` `[--editor code\|cursor\|…]` | Remote-SSH by default; `--editor` opens another IDE from `editor.enabled`. Defaults to `editor.default` |
197
206
  | `list` | | Lists envs, or `No remote environments` |
198
- | `destroy` | `[name …]` | Runs finalize then destroy playbooks first; multi-name OK |
207
+ | `delete` | `[name …]` `[--tags TAGS]` | Runs finalize then destroy playbooks, then deletes the VM; multi-name OK. `--tags` limits both playbooks |
199
208
  | `cache` | `list\|clear` `[--system\|--workspace] [--all] [-y]` | List or clear; unused by default, `--all` includes current |
200
209
  | `vars encrypt` | `[--stdin-name VAR]` `[--personal]` | Vault into shared or identity vars (after master-key unlock) |
201
210
  | `vars decrypt` | `[VAR]` | Decrypt from shared or identity vars |
@@ -222,7 +231,7 @@ Playbooks load `.rig/vars.yml` then `.rig/vars.{identity}.yml` (personal wins),
222
231
  | `rig_workspace_root` | `/workspace` |
223
232
  | `rig_version` | Installed `rig` package version |
224
233
  | `rig_boot_source` | `base` \| `system` \| `workspace` |
225
- | `rig_action` | `create` \| `apply` \| `destroy` |
234
+ | `rig_action` | `create` \| `apply` \| `destroy` (`rig delete` still sets `destroy`) |
226
235
  | `rig_project_dir` | Local project path |
227
236
  | `rig_ssh_key_name` / `rig_ssh_key_path` | Local key under `/tmp` |
228
237
  | `rig_firewall_name` | Firewall resource name |
@@ -241,12 +250,21 @@ Also available from vars files (defaults): `workspace_root`, `coding_agent_type`
241
250
  | Personal master key | Prompted on init/unlock; **never stored**. Unwraps data keys from `vars.{identity}.yml`. |
242
251
  | `rig_identity_data_key` / `rig_shared_data_key` | Master-key wraps inside `vars.{identity}.yml` (committed). |
243
252
  | `/tmp/.rig/.personal-data-key` / `.shared-data-key` | Materialized Ansible vault passwords after unlock (tmpfs). |
244
- | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / destroy finalizers). |
253
+ | `/tmp/<env>-key` | Per-env SSH private key (attach / apply / delete finalizers). |
245
254
 
246
255
  `RIG_IDENTITY` overrides the configured identity. Teammates joining an existing workspace paste the shared data key once (`rig vars export-shared-key` from an unlocked machine).
247
256
 
248
257
  OpenCode without an API key uses free Zen models. With a key, config switches to the paid provider path. When several agents are selected, keys are `opencode_api_key`, `claude_api_key`, and `cursor_api_key` (`RIG_OPENCODE_API_KEY`, `RIG_ANTHROPIC_API_KEY`, `RIG_CURSOR_API_KEY`). A single agent still uses `coding_agent_api_key` (`RIG_CODING_AGENT_API_KEY`).
249
258
 
259
+ ## Development
260
+
261
+ From a checkout, `pip install .` installs the same `rig` command. Use an editable install so the command keeps using this tree while you change it:
262
+
263
+ ```bash
264
+ pip install -e .
265
+ rig --version
266
+ ```
267
+
250
268
  ## Tests
251
269
 
252
270
  ```bash
@@ -0,0 +1,21 @@
1
+ # Per-workspace, per-Profile generated state bucket in vars.yml
2
+
3
+ The fixed default bucket name `rig` collided with other Hetzner customers, because bucket names are unique across the whole location. Each Profile (one Hetzner Cloud project) in each Workspace now gets a generated `rig-{8 hex}` State bucket. The name is recorded in `.rig/vars.yml` under `rig_state_buckets`, keyed by Profile name, so the whole team shares it. It is not stored in the developer's `~/.rig/config`.
4
+
5
+ ## Considered Options
6
+
7
+ - **Fixed name `rig`**: rejected, since it collides across customers.
8
+ - **Per-machine name in `~/.rig/config`**: rejected, since teammates would each get a different bucket and lose shared state.
9
+ - **Name derived from the account or token**: rejected, since a Hetzner token doesn't reveal its project id.
10
+
11
+ ## Consequences
12
+
13
+ - The bucket is scoped to Workspace and Profile. Two Workspaces using the same Profile get different buckets, and each only sees environments created from itself. Sharing one bucket across Workspaces was considered and rejected; it could be added later as an opt-in "adopt existing bucket" at init.
14
+
15
+ - Teammates must use the same Profile names for the same Hetzner project, and Rig can't verify this.
16
+ - Resolution order is `STATE_BUCKET` env var, then `vars.yml`, then generate. Only provisioning commands generate and write a name. `list`, `status` and `destroy` fail with "no state bucket configured" if none exists.
17
+ - A generated name is retried on a name-taken error. A configured name (from `vars.yml` or `STATE_BUCKET`) never is, and fails hard with a message pointing at a likely Profile mismatch.
18
+ - If `vars.yml` can't be written, the command fails. There is no ephemeral fallback bucket.
19
+ - Generating a name edits `vars.yml`, so init prints a reminder to commit it.
20
+ - There is no migration from the legacy `rig` bucket. Existing environments there must be cleaned up manually.
21
+ - Test mode (`is_test`) uses its own Test bucket and never reads or writes `vars.yml` or `~/.rig/config`.
@@ -363,7 +363,8 @@ def _cmd_apply(args: argparse.Namespace) -> int:
363
363
  log.error("Environment name is required (no last environment remembered)")
364
364
  log.info(
365
365
  "Usage: rig apply [name] "
366
- "[--provision|--configure|--authorize|--materialize]"
366
+ "[--provision|--configure|--authorize|--materialize|--finalize|--destroy] "
367
+ "[--tags TAGS]"
367
368
  )
368
369
  return 1
369
370
 
@@ -372,13 +373,23 @@ def _cmd_apply(args: argparse.Namespace) -> int:
372
373
  want_configure = getattr(args, "configure", False)
373
374
  want_authorize = getattr(args, "authorize", False) or getattr(args, "authnz", False)
374
375
  want_materialize = getattr(args, "materialize", False)
376
+ want_finalize = getattr(args, "finalize", False)
377
+ want_destroy_playbook = getattr(args, "destroy", False)
375
378
 
376
379
  selected = []
377
380
  if want_provision:
378
381
  selected.extend(["provision", "configure", "authorize"])
379
382
  if want_configure and "configure" not in selected:
380
383
  selected.append("configure")
381
- if want_authorize and not want_provision and not want_configure and not want_materialize:
384
+ authorize_only = (
385
+ want_authorize
386
+ and not want_provision
387
+ and not want_configure
388
+ and not want_materialize
389
+ and not want_finalize
390
+ and not want_destroy_playbook
391
+ )
392
+ if authorize_only:
382
393
  selected = ["authorize"]
383
394
  elif want_authorize and "authorize" not in selected:
384
395
  selected.append("authorize")
@@ -387,12 +398,17 @@ def _cmd_apply(args: argparse.Namespace) -> int:
387
398
  selected.append("authorize")
388
399
  if "materialize" not in selected:
389
400
  selected.append("materialize")
401
+ if want_finalize and "finalize" not in selected:
402
+ selected.append("finalize")
403
+ if want_destroy_playbook and "destroy" not in selected:
404
+ selected.append("destroy")
390
405
  if not selected:
391
406
  # Default apply: re-authorize then materialize.
392
407
  selected = ["authorize", "materialize"]
393
408
 
394
- # Preserve lifecycle order.
395
- order = ("provision", "configure", "authorize", "materialize")
409
+ # Preserve lifecycle order. finalize/destroy run the playbooks only;
410
+ # deleting the VM is ``rig delete``.
411
+ order = ("provision", "configure", "authorize", "materialize", "finalize", "destroy")
396
412
  playbooks = tuple(stage for stage in order if stage in selected)
397
413
 
398
414
  storage_manager = None
@@ -421,6 +437,7 @@ def _cmd_apply(args: argparse.Namespace) -> int:
421
437
  playbooks=playbooks,
422
438
  soft_fail_materialize=False,
423
439
  action="apply",
440
+ ansible_tags=getattr(args, "tags", None),
424
441
  )
425
442
  return 0 if ok else 1
426
443
  except Exception as e:
@@ -529,7 +546,7 @@ def _cmd_list(_args: argparse.Namespace) -> int:
529
546
  return 1
530
547
 
531
548
 
532
- def _cmd_destroy(args: argparse.Namespace) -> int:
549
+ def _cmd_delete(args: argparse.Namespace) -> int:
533
550
  _load_credentials()
534
551
  hetzner_token = os.getenv('HETZNER_CLOUD_API_TOKEN')
535
552
  if not hetzner_token:
@@ -555,7 +572,7 @@ def _cmd_destroy(args: argparse.Namespace) -> int:
555
572
  log.info("Using last environment '%s'", last)
556
573
  else:
557
574
  log.error("At least one environment name is required (no last environment remembered)")
558
- log.info("Usage: rig destroy [name ...] or rig destroy --name <name>")
575
+ log.info("Usage: rig delete [name ...] [--tags TAGS] or rig delete --name <name>")
559
576
  return 1
560
577
 
561
578
  storage_manager = None
@@ -568,16 +585,19 @@ def _cmd_destroy(args: argparse.Namespace) -> int:
568
585
  for name in names:
569
586
  try:
570
587
  env = RemoteDevEnvironment(name=name, storage_manager=storage_manager)
571
- env.cleanup(project_dir=os.getcwd())
588
+ env.cleanup(
589
+ project_dir=os.getcwd(),
590
+ ansible_tags=getattr(args, "tags", None),
591
+ )
572
592
  clear_last_env(name)
573
593
  clear_last_session(name)
574
- log.info("Environment '%s' destroyed", name)
594
+ log.info("Environment '%s' deleted", name)
575
595
  except Exception as e:
576
- log.error("Error destroying environment '%s': %s", name, e)
596
+ log.error("Error deleting environment '%s': %s", name, e)
577
597
  failures.append(name)
578
598
 
579
599
  if failures:
580
- log.error("Failed to destroy: %s", ", ".join(failures))
600
+ log.error("Failed to delete: %s", ", ".join(failures))
581
601
  return 1
582
602
  return 0
583
603
 
@@ -964,6 +984,26 @@ def main(argv=None):
964
984
  action="store_true",
965
985
  help="Run authorize then materialize (or materialize with other flags)",
966
986
  )
987
+ apply_parser.add_argument(
988
+ "--finalize",
989
+ action="store_true",
990
+ help="Run finalize.yml (does not delete the VM)",
991
+ )
992
+ apply_parser.add_argument(
993
+ "--destroy",
994
+ action="store_true",
995
+ help="Run destroy.yml (does not delete the VM)",
996
+ )
997
+ apply_parser.add_argument(
998
+ "--tags",
999
+ action="append",
1000
+ default=None,
1001
+ metavar="TAGS",
1002
+ help=(
1003
+ "Ansible --tags for every playbook in this run "
1004
+ "(comma-separated; may be repeated)."
1005
+ ),
1006
+ )
967
1007
  # Legacy aliases
968
1008
  apply_parser.add_argument(
969
1009
  "--system",
@@ -1124,25 +1164,35 @@ def main(argv=None):
1124
1164
  help="list = show only; clear = list, confirm, delete (default: clear)",
1125
1165
  )
1126
1166
 
1127
- destroy_parser = subparsers.add_parser(
1128
- "destroy",
1167
+ delete_parser = subparsers.add_parser(
1168
+ "delete",
1129
1169
  help=(
1130
- "Destroy remote environments (runs finalize then destroy playbooks first; "
1170
+ "Delete remote environments (runs finalize then destroy playbooks first; "
1131
1171
  "uses last env if name omitted)"
1132
1172
  ),
1133
1173
  )
1134
- destroy_parser.add_argument(
1174
+ delete_parser.add_argument(
1135
1175
  "names",
1136
1176
  nargs="*",
1137
1177
  metavar="name",
1138
- help="Environment name(s) to destroy (defaults to last handled env in /tmp/.rig/last-env)",
1178
+ help="Environment name(s) to delete (defaults to last handled env in /tmp/.rig/last-env)",
1139
1179
  )
1140
- destroy_parser.add_argument(
1180
+ delete_parser.add_argument(
1141
1181
  "--name",
1142
1182
  action="append",
1143
1183
  dest="name_flags",
1144
1184
  help="Environment name (repeatable; kept for compatibility)",
1145
1185
  )
1186
+ delete_parser.add_argument(
1187
+ "--tags",
1188
+ action="append",
1189
+ default=None,
1190
+ metavar="TAGS",
1191
+ help=(
1192
+ "Ansible --tags for the finalize and destroy playbooks "
1193
+ "(comma-separated; may be repeated)"
1194
+ ),
1195
+ )
1146
1196
 
1147
1197
  vars_parser = subparsers.add_parser(
1148
1198
  "vars",
@@ -1212,8 +1262,8 @@ def main(argv=None):
1212
1262
  return _cmd_list(args)
1213
1263
  if args.command == "cache":
1214
1264
  return _cmd_cache(args)
1215
- if args.command == "destroy":
1216
- return _cmd_destroy(args)
1265
+ if args.command == "delete":
1266
+ return _cmd_delete(args)
1217
1267
  if args.command == "vars":
1218
1268
  if args.vars_command == "encrypt":
1219
1269
  return _cmd_encrypt(args)