lockbot 2.12.0__tar.gz → 2.14.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.
- {lockbot-2.12.0/python/lockbot.egg-info → lockbot-2.14.0}/PKG-INFO +27 -46
- {lockbot-2.12.0 → lockbot-2.14.0}/README.md +26 -44
- {lockbot-2.12.0 → lockbot-2.14.0}/pyproject.toml +2 -3
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/agent_skill/SKILL.md +293 -8
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/backup/service.py +1 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/manager.py +1 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/router.py +44 -12
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/schemas.py +8 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/managed_paths.py +1 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/op_skill/SKILL.md +11 -6
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/commands.py +20 -12
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/discovery.py +5 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/event_log.py +1 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/operator.py +16 -6
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/resources.py +9 -4
- lockbot-2.14.0/python/lockbot/backend/app/resource_api/rules.py +85 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/snapshot.py +25 -4
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/usage.py +25 -6
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/view_links.py +20 -9
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/views.py +6 -1
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/base_bot.py +33 -3
- lockbot-2.14.0/python/lockbot/core/bot_instance.py +50 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/config.py +28 -152
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/device_bot.py +14 -4
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/handler.py +2 -69
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/i18n/en.py +5 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/i18n/zh.py +5 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/io.py +3 -3
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/node_bot.py +29 -14
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/platforms/infoflow.py +3 -3
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/queue_bot.py +63 -27
- lockbot-2.14.0/python/lockbot/core/queue_device_bot.py +105 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/request.py +2 -2
- lockbot-2.14.0/python/lockbot/core/resource_policy.py +40 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/scheduler.py +9 -26
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/utils.py +1 -1
- {lockbot-2.12.0 → lockbot-2.14.0/python/lockbot.egg-info}/PKG-INFO +27 -46
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot.egg-info/SOURCES.txt +3 -2
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot.egg-info/requires.txt +0 -1
- lockbot-2.12.0/python/lockbot/core/bot_instance.py +0 -79
- lockbot-2.12.0/python/lockbot/core/entry.py +0 -81
- lockbot-2.12.0/python/lockbot/core/env.py +0 -11
- {lockbot-2.12.0 → lockbot-2.14.0}/LICENSE +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/MANIFEST.in +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/admin/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/admin/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/audit/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/audit/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/audit/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/audit/service.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/auth/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/auth/dependencies.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/auth/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/auth/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/auth/schemas.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/backup/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/backup/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/backup/scheduler.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bot_audit/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bot_audit/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bot_audit/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bot_audit/service.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/encryption.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/bots/webhook_handler.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/broadcast/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/broadcast/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/broadcast/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/broadcast/service.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/config.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/database.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/deployment.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/logs/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/main.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/rate_limit.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/activity.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/errors.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/ingress.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/notifications.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/observability.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/op_skill.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/skill.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/sources.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/traffic.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/usage_cleanup.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_api/versioning.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/authority.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/credentials.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/dependencies.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/http_errors.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/pending.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/resource_auth/service.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/service_traffic.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/settings/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/settings/models.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/settings/router.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/sqlite_paths.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/state_migration.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/state_ownership.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/backend/app/static.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/command_context.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/device_usage_alert.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/device_usage_utils.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/i18n/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/message_adapter.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/msg_utils.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/platforms/__init__.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot/core/platforms/registry.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot.egg-info/dependency_links.txt +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/python/lockbot.egg-info/top_level.txt +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/setup.cfg +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/tools/create_super_admin.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/tools/gen_keys.py +0 -0
- {lockbot-2.12.0 → lockbot-2.14.0}/tools/reset_super_admin_password.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lockbot
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.14.0
|
|
4
4
|
Summary: Cluster resource management bot for IM platforms
|
|
5
5
|
Author-email: Jianbang Yang <yangjianbang112@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -23,7 +23,6 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: pycryptodome
|
|
25
25
|
Requires-Dist: requests
|
|
26
|
-
Requires-Dist: flask
|
|
27
26
|
Requires-Dist: six
|
|
28
27
|
Requires-Dist: fastapi
|
|
29
28
|
Requires-Dist: uvicorn[standard]
|
|
@@ -47,7 +46,7 @@ Dynamic: license-file
|
|
|
47
46
|
Cluster resource management bot for IM platforms (e.g., Baidu InfoFlow).
|
|
48
47
|
|
|
49
48
|
Lock and unlock GPU devices, cluster nodes, and queue slots via chat commands.
|
|
50
|
-
|
|
49
|
+
Runs as a multi-bot platform with FastAPI and a Vue.js frontend.
|
|
51
50
|
|
|
52
51
|
[中文文档](README_CN.md) | [Live Demo](https://dynamicheart.github.io/lockbot/)
|
|
53
52
|
|
|
@@ -128,10 +127,11 @@ docker exec -it lockbot python tools/create_super_admin.py --username admin --em
|
|
|
128
127
|
| `TOKEN` | Bot signature verification token | `""` |
|
|
129
128
|
| `AESKEY` | Message decryption AES key | `""` |
|
|
130
129
|
| `WEBHOOK_URL` | Message webhook URL | `""` |
|
|
131
|
-
| `PORT` | Server listen port | `8090` |
|
|
132
130
|
| `DEFAULT_DURATION` | Default lock duration (seconds) | `7200` (2h) |
|
|
133
131
|
| `MAX_LOCK_DURATION` | Max lock duration (seconds) | `-1` (unlimited) |
|
|
134
132
|
| `EARLY_NOTIFY` | Notify before lock expiry | `false` |
|
|
133
|
+
| `FORBID_RELOCK` | Reject renewal and longer booking claims when explicitly enabled per bot | `false` |
|
|
134
|
+
| `MAX_RESOURCES_PER_USER` | Held + booked resources per user/bot; nodes for NODE/QUEUE, cards for DEVICE/QUEUE_DEVICE | `-1` (unlimited) |
|
|
135
135
|
|
|
136
136
|
See `python/lockbot/core/config.py` for the full configuration reference.
|
|
137
137
|
|
|
@@ -178,48 +178,29 @@ ruff check python/ tests/
|
|
|
178
178
|
ruff format --check python/ tests/
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
##
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
**Node Lock Bot / Queue Bot** (per-node locking or queue scheduling):
|
|
207
|
-
|
|
208
|
-
```python
|
|
209
|
-
from lockbot.core.bot_instance import BotInstance
|
|
210
|
-
from lockbot.core.entry import create_app
|
|
211
|
-
|
|
212
|
-
instance = BotInstance("NODE", { # or "QUEUE" for queue scheduling
|
|
213
|
-
"BOT_NAME": "my-node-bot",
|
|
214
|
-
"WEBHOOK_URL": "https://your-webhook-url",
|
|
215
|
-
"TOKEN": "your-bot-token",
|
|
216
|
-
"AESKEY": "your-aes-key",
|
|
217
|
-
"CLUSTER_CONFIGS": ["node0", "node1", "node2", "node3"],
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
app = create_app(bot=instance.bot, bot_name="my-node-bot", port=8000)
|
|
221
|
-
app.run(host="0.0.0.0", port=8000)
|
|
222
|
-
```
|
|
181
|
+
## Migrating an older standalone deployment
|
|
182
|
+
|
|
183
|
+
The deprecated Flask entry (`lockbot.core.entry.create_app` / `run_bot`) and process-global
|
|
184
|
+
`Config.get/set/load_from_file/load_from_env` API have been removed. Bot construction no
|
|
185
|
+
longer starts a private scheduler. The supported deployment is the FastAPI platform above,
|
|
186
|
+
including when managing only one bot. Existing platform Docker deployments keep the same
|
|
187
|
+
startup command, ports and persistent data layout; no database reset is required.
|
|
188
|
+
|
|
189
|
+
For an old standalone deployment:
|
|
190
|
+
|
|
191
|
+
1. Keep a backup of its configuration and JSON state before stopping its old webhook server.
|
|
192
|
+
2. Start the platform, create the matching bot type, and copy its cluster, messaging
|
|
193
|
+
credentials and runtime rules into the bot editor. Do not publish credentials in logs.
|
|
194
|
+
3. Restore the saved cluster state through the platform's existing cluster-state import
|
|
195
|
+
while the bot is stopped. Verify resource names, holders, expiry and queues before start.
|
|
196
|
+
Do not copy old state over an unrelated bot's directory or remove the old data volume.
|
|
197
|
+
4. Point the messaging platform callback at `/api/bots/webhook/{bot_id}` and start the bot.
|
|
198
|
+
Keep the previous image and backup until the new callback and expiry checks work.
|
|
199
|
+
|
|
200
|
+
The core bot classes remain independently constructible for tests, with per-instance
|
|
201
|
+
`Config` objects. Platform scheduling, persisted state formats and legacy state migrations
|
|
202
|
+
remain supported. The external XPU monitoring example under `docs/examples/xpu_monitor`
|
|
203
|
+
is a separate program; its optional Flask webhook still uses its documented own dependencies.
|
|
223
204
|
|
|
224
205
|
## License
|
|
225
206
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Cluster resource management bot for IM platforms (e.g., Baidu InfoFlow).
|
|
4
4
|
|
|
5
5
|
Lock and unlock GPU devices, cluster nodes, and queue slots via chat commands.
|
|
6
|
-
|
|
6
|
+
Runs as a multi-bot platform with FastAPI and a Vue.js frontend.
|
|
7
7
|
|
|
8
8
|
[中文文档](README_CN.md) | [Live Demo](https://dynamicheart.github.io/lockbot/)
|
|
9
9
|
|
|
@@ -84,10 +84,11 @@ docker exec -it lockbot python tools/create_super_admin.py --username admin --em
|
|
|
84
84
|
| `TOKEN` | Bot signature verification token | `""` |
|
|
85
85
|
| `AESKEY` | Message decryption AES key | `""` |
|
|
86
86
|
| `WEBHOOK_URL` | Message webhook URL | `""` |
|
|
87
|
-
| `PORT` | Server listen port | `8090` |
|
|
88
87
|
| `DEFAULT_DURATION` | Default lock duration (seconds) | `7200` (2h) |
|
|
89
88
|
| `MAX_LOCK_DURATION` | Max lock duration (seconds) | `-1` (unlimited) |
|
|
90
89
|
| `EARLY_NOTIFY` | Notify before lock expiry | `false` |
|
|
90
|
+
| `FORBID_RELOCK` | Reject renewal and longer booking claims when explicitly enabled per bot | `false` |
|
|
91
|
+
| `MAX_RESOURCES_PER_USER` | Held + booked resources per user/bot; nodes for NODE/QUEUE, cards for DEVICE/QUEUE_DEVICE | `-1` (unlimited) |
|
|
91
92
|
|
|
92
93
|
See `python/lockbot/core/config.py` for the full configuration reference.
|
|
93
94
|
|
|
@@ -134,48 +135,29 @@ ruff check python/ tests/
|
|
|
134
135
|
ruff format --check python/ tests/
|
|
135
136
|
```
|
|
136
137
|
|
|
137
|
-
##
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**Node Lock Bot / Queue Bot** (per-node locking or queue scheduling):
|
|
163
|
-
|
|
164
|
-
```python
|
|
165
|
-
from lockbot.core.bot_instance import BotInstance
|
|
166
|
-
from lockbot.core.entry import create_app
|
|
167
|
-
|
|
168
|
-
instance = BotInstance("NODE", { # or "QUEUE" for queue scheduling
|
|
169
|
-
"BOT_NAME": "my-node-bot",
|
|
170
|
-
"WEBHOOK_URL": "https://your-webhook-url",
|
|
171
|
-
"TOKEN": "your-bot-token",
|
|
172
|
-
"AESKEY": "your-aes-key",
|
|
173
|
-
"CLUSTER_CONFIGS": ["node0", "node1", "node2", "node3"],
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
app = create_app(bot=instance.bot, bot_name="my-node-bot", port=8000)
|
|
177
|
-
app.run(host="0.0.0.0", port=8000)
|
|
178
|
-
```
|
|
138
|
+
## Migrating an older standalone deployment
|
|
139
|
+
|
|
140
|
+
The deprecated Flask entry (`lockbot.core.entry.create_app` / `run_bot`) and process-global
|
|
141
|
+
`Config.get/set/load_from_file/load_from_env` API have been removed. Bot construction no
|
|
142
|
+
longer starts a private scheduler. The supported deployment is the FastAPI platform above,
|
|
143
|
+
including when managing only one bot. Existing platform Docker deployments keep the same
|
|
144
|
+
startup command, ports and persistent data layout; no database reset is required.
|
|
145
|
+
|
|
146
|
+
For an old standalone deployment:
|
|
147
|
+
|
|
148
|
+
1. Keep a backup of its configuration and JSON state before stopping its old webhook server.
|
|
149
|
+
2. Start the platform, create the matching bot type, and copy its cluster, messaging
|
|
150
|
+
credentials and runtime rules into the bot editor. Do not publish credentials in logs.
|
|
151
|
+
3. Restore the saved cluster state through the platform's existing cluster-state import
|
|
152
|
+
while the bot is stopped. Verify resource names, holders, expiry and queues before start.
|
|
153
|
+
Do not copy old state over an unrelated bot's directory or remove the old data volume.
|
|
154
|
+
4. Point the messaging platform callback at `/api/bots/webhook/{bot_id}` and start the bot.
|
|
155
|
+
Keep the previous image and backup until the new callback and expiry checks work.
|
|
156
|
+
|
|
157
|
+
The core bot classes remain independently constructible for tests, with per-instance
|
|
158
|
+
`Config` objects. Platform scheduling, persisted state formats and legacy state migrations
|
|
159
|
+
remain supported. The external XPU monitoring example under `docs/examples/xpu_monitor`
|
|
160
|
+
is a separate program; its optional Flask webhook still uses its documented own dependencies.
|
|
179
161
|
|
|
180
162
|
## License
|
|
181
163
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lockbot"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.14.0"
|
|
8
8
|
description = "Cluster resource management bot for IM platforms"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -27,10 +27,9 @@ classifiers = [
|
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
dependencies = [
|
|
30
|
-
# Core
|
|
30
|
+
# Core
|
|
31
31
|
"pycryptodome",
|
|
32
32
|
"requests",
|
|
33
|
-
"flask",
|
|
34
33
|
"six",
|
|
35
34
|
# Backend (platform mode)
|
|
36
35
|
"fastapi",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: lockbot-resource-agent
|
|
3
3
|
description: >
|
|
4
4
|
Use Lockbot Resource API (lockbot.resource-api) with lbr_ credentials.
|
|
5
|
-
|
|
5
|
+
Credentials from other Lockbot implementations are not interchangeable. Use when an agent
|
|
6
6
|
must lock, unlock, book or query shared compute resources through a bot it has been enrolled
|
|
7
7
|
on. Enrollment requires human confirmation in chat; resource operations use HTTP.
|
|
8
8
|
---
|
|
@@ -29,9 +29,9 @@ credentials belong in its private credential store, never in `SKILL.md` or a dow
|
|
|
29
29
|
This skill is for **Lockbot Resource API**, identified by
|
|
30
30
|
`service_id: lockbot.resource-api`, API version `1`, and personal `lbr_` keys.
|
|
31
31
|
A similarly named Lockbot skill, matching command URL, or remembered token is not proof
|
|
32
|
-
that it belongs here.
|
|
33
|
-
and
|
|
34
|
-
|
|
32
|
+
that it belongs here. Another Lockbot implementation can have a different authentication
|
|
33
|
+
protocol and permission scope. Check the advertised service identity and API version;
|
|
34
|
+
never transfer credentials or assumptions such as one token authorizing every bot.
|
|
35
35
|
|
|
36
36
|
1. Start with the server/skill URL explicitly supplied or approved by the user. Without
|
|
37
37
|
a trusted server address, ask for that address once; never guess a host or bot ID.
|
|
@@ -58,11 +58,96 @@ user-approved origin (and HTTPS where available) remains the credential destinat
|
|
|
58
58
|
The server cannot erase an Agent's earlier memories: keep the scope explicit in its private
|
|
59
59
|
configuration and use this namespaced skill for requests to this implementation.
|
|
60
60
|
|
|
61
|
+
## Keep credentials and resource assignments scoped
|
|
62
|
+
|
|
63
|
+
Manage several Lockbot connections with this skill. Keep a private connection record for
|
|
64
|
+
**approved origin + instance_id + bot UUID + verified user**, with a friendly name and a
|
|
65
|
+
reference to its securely stored key. Learn the bot UUID/user from `/api/agent/context`;
|
|
66
|
+
people do not need to manage these identifiers. Keep the last verified skill revision per
|
|
67
|
+
service instance. Never put keys in this skill, public notes, or task-purpose text.
|
|
68
|
+
|
|
69
|
+
For example, **service A / bot A / node1** and **service B / bot B / node1** are different
|
|
70
|
+
resources, even though both are called `node1`. Different bots on the same service are also
|
|
71
|
+
separate scopes. Select the intended connection first, load only its key, and verify its
|
|
72
|
+
context before use. If several connections could match the task, ask which bot/group the
|
|
73
|
+
user means; do not cycle through keys or try remembered keys against other servers.
|
|
74
|
+
|
|
75
|
+
A key authorizes **one user on one bot**, not one resource or one Agent. The user's Agents
|
|
76
|
+
share that key but track their own tasks separately:
|
|
77
|
+
|
|
78
|
+
- Associate each task allocation with **origin + instance_id + bot UUID + resource ID**,
|
|
79
|
+
its Agent name/purpose, and the last verified holding/booking (`start_time` and
|
|
80
|
+
`expires_at` when present). For card queues use the
|
|
81
|
+
returned card `resource_id`, such as `node1:dev0`, in this private record; command syntax
|
|
82
|
+
remains `lock node1 dev0`, not `lock node1:dev0`.
|
|
83
|
+
- Choose the credential by that bot scope, never by a bare machine/card name. Record which
|
|
84
|
+
exact machines/cards this task acquired or booked; another Agent sharing the key may be
|
|
85
|
+
working on other resources.
|
|
86
|
+
- A saved key/resource association is not proof of a current lease. Read `/resources` to
|
|
87
|
+
confirm ownership and queue state before starting/resuming work and during long tasks.
|
|
88
|
+
The same user may have released and reacquired a card through another Agent: if the
|
|
89
|
+
saved lease/task no longer matches, pause and coordinate rather than assuming it is still
|
|
90
|
+
this task's resource or releasing it just because the user identity matches.
|
|
91
|
+
- At task completion, release/cancel only this task's explicit resources/cards, then verify
|
|
92
|
+
the result. Avoid bare `free`/`unlock`, which affects the user's other Agents too. Retain
|
|
93
|
+
the shared key; do not unbind it merely because one task has finished.
|
|
94
|
+
|
|
95
|
+
### Store the relationship; choose your own format
|
|
96
|
+
|
|
97
|
+
Reuse the Agent's existing private credential/configuration store. Do not require the
|
|
98
|
+
user to install a new memory system or maintain a particular JSON file. Each saved
|
|
99
|
+
connection needs a friendly name, approved origin, verified instance/bot/user identity,
|
|
100
|
+
and the reference to its securely stored key. Keep the last verified skill revision too.
|
|
101
|
+
No resource directory needs to be stored permanently: discover it from the live API.
|
|
102
|
+
|
|
103
|
+
If no suitable store exists, this optional flat JSON example is sufficient:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"schema_version": 1,
|
|
108
|
+
"connections": [
|
|
109
|
+
{
|
|
110
|
+
"label": "Development group",
|
|
111
|
+
"origin": "https://service-a.example.invalid",
|
|
112
|
+
"instance_id": "<server.instance_id>",
|
|
113
|
+
"bot_uuid": "<bot.uuid>",
|
|
114
|
+
"bot_id": 1,
|
|
115
|
+
"actor": {"platform": "Infoflow", "external_user_id": "<actor.external_user_id>"},
|
|
116
|
+
"credential_ref": "<private-store reference for bot A>",
|
|
117
|
+
"skill_revision": "<verified revision>"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"label": "Testing group",
|
|
121
|
+
"origin": "https://service-a.example.invalid",
|
|
122
|
+
"instance_id": "<server.instance_id>",
|
|
123
|
+
"bot_uuid": "<another bot.uuid>",
|
|
124
|
+
"bot_id": 2,
|
|
125
|
+
"actor": {"platform": "Infoflow", "external_user_id": "<actor.external_user_id>"},
|
|
126
|
+
"credential_ref": "<private-store reference for bot B>",
|
|
127
|
+
"skill_revision": "<verified revision>"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`schema_version` versions this optional local format, not the server API or Skill.
|
|
134
|
+
Populate identities from confirmed context; the numeric bot ID and friendly name alone
|
|
135
|
+
are not enough to identify a credential scope. Both bots may contain `node1`: select the
|
|
136
|
+
bot connection first, then load its key. Another service gets a separate connection.
|
|
137
|
+
`credential_ref` is a reference, never a raw key; no particular credential-store product
|
|
138
|
+
or URI syntax is required. Keep configuration private and out of Git and shared notes.
|
|
139
|
+
|
|
140
|
+
Track task allocations separately as described above; update only the current task's
|
|
141
|
+
records after verified changes, coordinating concurrent writers to avoid lost updates.
|
|
142
|
+
On resume, recheck context and live resources. Do not move a key after a redirect, origin
|
|
143
|
+
change or instance replacement, and do not try other connections' keys after a failure.
|
|
144
|
+
|
|
61
145
|
## Share a resource/queue page with the user
|
|
62
146
|
|
|
63
147
|
When the user wants to view resources or queue order in a browser, use `view_url` and
|
|
64
148
|
`view_expires_at` returned by `/api/agent/context`. Share that read-only URL; never put your
|
|
65
|
-
personal key into a browser URL.
|
|
149
|
+
personal key into a browser URL. Treat `view_url` as opaque: current short links and older
|
|
150
|
+
long links are compatible; do not parse or reconstruct a code from the URL. No separate web command or link-creation endpoint is needed.
|
|
66
151
|
The server lazily creates one link per bot, reuses it for 24 hours from creation, and only
|
|
67
152
|
replaces it when a subsequent authorized request arrives after expiry. Page refreshes do not
|
|
68
153
|
renew it. Ordinary group queries also return the current link. If the link expires, request
|
|
@@ -128,12 +213,31 @@ fields. They never select your identity, authorize an operation, or give another
|
|
|
128
213
|
(`bind`/`unbind`/`bindings`) are refused. The response `reply` is the bot's text, **not** a
|
|
129
214
|
structured outcome — always confirm effect by reading `/resources`.
|
|
130
215
|
|
|
131
|
-
###
|
|
216
|
+
### QUEUE_DEVICE: individual-card queues
|
|
217
|
+
|
|
218
|
+
`QUEUE_DEVICE` combines DEVICE card syntax with a separate FIFO queue for every card.
|
|
219
|
+
Read `bot_type`, `supported_operations` and `command_examples`; do not guess support from
|
|
220
|
+
another bot's remembered commands. For example:
|
|
221
|
+
|
|
222
|
+
- `lock node1 dev0 2h` acquires card 0; `book node1 dev0 30m` queues for that card.
|
|
223
|
+
- `free node1 dev0` releases/cancels only your card-0 work. Sibling cards and their queues remain.
|
|
224
|
+
- `lock node1 dev0,2 1h` or `dev0-3` selects several cards atomically. Omitting `dev...`
|
|
225
|
+
selects every card on the listed nodes. Prefer exact cards so another Agent's work is preserved.
|
|
226
|
+
- Shared `slock` is unavailable. Personal keys still cannot `take`, `kickout` or `kicklock`.
|
|
227
|
+
|
|
228
|
+
Per-card state appears in `resources[].devices[]`. Each device has its own `booking_list`,
|
|
229
|
+
`claimable_by_you`, and `claim_command`. Follow that device's claim command after booking;
|
|
230
|
+
never treat a queued card as already acquired. Task metadata on `lock`/`book` is saved
|
|
231
|
+
per card, so the same person's different Agents can use different cards for different purposes.
|
|
232
|
+
For optional PUT/DELETE usage updates, use the device's exact `resource_id` (e.g. `node1:dev0`),
|
|
233
|
+
not its display label. Ordinary DEVICE bots retain their existing node-scoped declarations.
|
|
234
|
+
|
|
235
|
+
### QUEUE / QUEUE_DEVICE: booking is not task completion
|
|
132
236
|
|
|
133
237
|
If the user asks you to acquire/use a resource, do **not** finish after `book`. Booking only
|
|
134
238
|
reserves a queue position. Keep monitoring `/resources` yourself; do not wait for the human
|
|
135
239
|
or a group @mention to make the next API call. The `book` response's `next_step` repeats this.
|
|
136
|
-
When `resources[].claimable_by_you` is true, POST that resource's `claim_command` (e.g.
|
|
240
|
+
When `resources[].claimable_by_you` (or a QUEUE_DEVICE device’s flag) is true, POST that resource's `claim_command` (e.g.
|
|
137
241
|
`lock node1`) within `queue_claim_window_seconds`, then read again to verify a live holding
|
|
138
242
|
for your actor. Only then start the workload. If another holder remains, keep waiting with
|
|
139
243
|
backoff. If you cannot keep monitoring, tell the user that you are **only queued**, not holding.
|
|
@@ -150,6 +254,83 @@ repeat, respecting polling intervals and Retry-After:
|
|
|
150
254
|
An existing task registered during booking is carried forward when you claim with `lock`
|
|
151
255
|
without new metadata. `free <resource>` cancels your booking or releases your lock.
|
|
152
256
|
|
|
257
|
+
## Read current bot rules and manage the lease lifecycle
|
|
258
|
+
|
|
259
|
+
Each successful `GET /api/agent/context` includes `bot_rules`, read from the bot's current
|
|
260
|
+
persisted configuration even when the bot is stopped. Refresh your private rule cache at
|
|
261
|
+
connection/resume and before renewal, and after a policy rejection or configuration change.
|
|
262
|
+
Do not fetch context alongside every resource poll: it consumes the shared read budget.
|
|
263
|
+
These rules can change; `/resources` and the actual command result remain authoritative.
|
|
264
|
+
|
|
265
|
+
| `bot_rules` field | Meaning |
|
|
266
|
+
|---|---|
|
|
267
|
+
| `forbid_relock` | Defaults to false for every bot type. When true, do not renew lock/slock or book a resource you currently hold. |
|
|
268
|
+
| `max_resources_per_user`, `resource_unit` | Combined distinct held/booked resources per user and bot; `-1` means no bot-specific cap. Unit is `node` for NODE/QUEUE, `card` for DEVICE/QUEUE_DEVICE. |
|
|
269
|
+
| `default_duration_seconds` | Duration used when a command omits it; a booking claim without a duration uses its booked duration. |
|
|
270
|
+
| `max_lock_duration_seconds` | Configured maximum remaining lease duration after acquisition/renewal; `-1` means unlimited. |
|
|
271
|
+
| `duration_limit_exempt`, `effective_max_lock_duration_seconds` | Caller-specific duration exemption and effective ceiling (`-1` unlimited). This exempts neither renewal restrictions nor resource-count limits; the exemption list is never disclosed. |
|
|
272
|
+
| `queue_claim_window_seconds` | Time to claim when it is your turn; null for non-queue types. |
|
|
273
|
+
| `supported_operations`, `allow_user_alias` | Operations supported by the type and whether alias editing is enabled. A listed operation does not bypass `agent_access_enabled` or other policy checks. |
|
|
274
|
+
| `request_budget.read_per_minute`, `request_budget.write_per_minute` | Actual deployed per-key read/write budgets shared by all the user's Agents. Other endpoint/IP limits can also apply. |
|
|
275
|
+
| `poll_minimum_seconds.active`, `.booking`, `.discovery` | Actual deployed minimum resource-poll intervals in seconds; these override the suggested 15/30/60-second schedule below. |
|
|
276
|
+
| `api_max_machines_per_user` | The separate existing API machine-count ceiling, including held/booked machines; several cards on one machine count once here. A card quota does not redefine this machine limit. |
|
|
277
|
+
|
|
278
|
+
`resource_policy` on `/resources` repeats the live acquisition switches and includes the
|
|
279
|
+
caller's `claimed_resource_count`. All of the user's Agents and group commands share the
|
|
280
|
+
same bot allowance. Claiming an existing booking adds no allocation; lowering a cap does
|
|
281
|
+
not evict existing holdings/bookings, but can prevent new acquisitions. When renewal is
|
|
282
|
+
forbidden, claiming cannot exceed the original booked duration. Releasing does not let you
|
|
283
|
+
jump ahead of other bookers. If an older service omits these new rule fields, do not assume
|
|
284
|
+
the restrictions exist; follow its actual replies, timing fields and verified holdings.
|
|
285
|
+
The `2h` values in command examples are examples, not a recommendation: use the actual
|
|
286
|
+
caller-effective maximum, defaults, booked duration and task need. If the configured default
|
|
287
|
+
exceeds the effective ceiling, request a valid explicit shorter duration.
|
|
288
|
+
|
|
289
|
+
### Keep a conservative local stop deadline
|
|
290
|
+
|
|
291
|
+
Record a local monotonic timestamp just before each GET and after receiving it. Use the
|
|
292
|
+
verified lease's server `expires_at`, snapshot `captured_at` and `age_seconds` to estimate
|
|
293
|
+
remaining time without trusting the Agent computer's UTC clock. A conservative calculation
|
|
294
|
+
is `remaining = max(0, expires_at - captured_at - age_seconds - request_elapsed)` and
|
|
295
|
+
`stop_deadline = received_monotonic + remaining`. Subtracting the full request elapsed time
|
|
296
|
+
is deliberately conservative. `/resources` does not provide a `server_time` field; do not
|
|
297
|
+
invent one. Missing or unusable timing/ownership data is not permission to extend a deadline.
|
|
298
|
+
|
|
299
|
+
Maintain both periodic ownership checks and a local deadline timer. A later poll can reveal
|
|
300
|
+
manual release, preemption, earlier expiry or another Agent's reacquisition; stop this task's
|
|
301
|
+
resource use if the lease/owner no longer matches. Do not postpone the known deadline merely
|
|
302
|
+
because a query failed, a queue estimate changed, or a cached record still says held.
|
|
303
|
+
|
|
304
|
+
### Renew only for necessary active work, and verify the result
|
|
305
|
+
|
|
306
|
+
Before the stop deadline, refresh context once and verify current ownership and this task's
|
|
307
|
+
lease. Renew only if renewal is allowed and active work actually needs more time; never renew
|
|
308
|
+
indefinitely just to retain capacity. Leave enough margin for the advertised poll floor,
|
|
309
|
+
request latency, shared read/write budgets and possible `Retry-After` before the old deadline.
|
|
310
|
+
A permitted verification read after a mutation still obeys actual server retry instructions.
|
|
311
|
+
|
|
312
|
+
Choose an explicit added duration: repeated lock adds time rather than setting a new total.
|
|
313
|
+
Keep remaining time plus the increment within the caller-effective ceiling. Attempt one bounded
|
|
314
|
+
renewal. Then GET `/resources` and confirm the same resource/actor/lease
|
|
315
|
+
has a genuinely later `expires_at`; HTTP 200 or a reply alone does not prove renewal. If POST
|
|
316
|
+
has an unknown outcome, GET first instead of blindly repeating the non-idempotent lock.
|
|
317
|
+
Retrying a status check cannot move the old stop deadline. Adopt a new deadline only from a
|
|
318
|
+
verified renewed lease, not from the requested extra duration or the POST's success status.
|
|
319
|
+
|
|
320
|
+
If renewal is forbidden, refused, uncertain or cannot be verified in time, stop/pause this
|
|
321
|
+
task's GPU workload no later than the previously known deadline. Confirm the workload has
|
|
322
|
+
stopped, release only this task's still-owned resources where appropriate, and reapply through
|
|
323
|
+
the normal fair queue if more work remains. Never continue through expiry while retrying.
|
|
324
|
+
If ownership cannot be confirmed because reads fail or are too stale, pause until verified.
|
|
325
|
+
|
|
326
|
+
On Agent exit, cancellation or a long pause, clean up this task's workload and allocations.
|
|
327
|
+
A timer in a sleeping or exited Agent cannot reliably stop a remote GPU job: arrange deadline
|
|
328
|
+
enforcement in the task's runner, or stop work before becoming unavailable.
|
|
329
|
+
After sleep/restart, refresh context and live state before resuming; saved memory is not a
|
|
330
|
+
lease. If you cannot run timers, keep polling or stop your workload reliably, say so before
|
|
331
|
+
starting and do not promise unattended acquisition/renewal. Lockbot records leases and queues;
|
|
332
|
+
it does not kill or pause GPU processes. Workload shutdown is the Agent/runner's responsibility.
|
|
333
|
+
|
|
153
334
|
## Resource command reference
|
|
154
335
|
|
|
155
336
|
Send JSON to `POST /api/bots/{bot_id}/commands` using the personal Bearer key. Obtain the
|
|
@@ -196,7 +377,7 @@ The examples below use placeholder resources; replace them with those returned b
|
|
|
196
377
|
contiguous card indexes for multi-resource tasks. Do not reserve extra machines merely
|
|
197
378
|
to obtain a consecutive block, or assume consecutive names imply hardware locality.
|
|
198
379
|
- Set an explicit lease duration that fits the work. Avoid unnecessarily long locks or
|
|
199
|
-
reserving capacity "just in case".
|
|
380
|
+
reserving capacity "just in case". Only when renewal is permitted, renew long-running tasks in bounded increments
|
|
200
381
|
while actively using the resources, after verifying current ownership and remaining time.
|
|
201
382
|
Repeated `lock` adds time; never renew on every poll or blindly retry a renewal.
|
|
202
383
|
- On completion, cancellation, failure that stops resource use, or a long pause, promptly
|
|
@@ -283,6 +464,43 @@ a string-only 401 has no machine code: do not interpret it as permission to scan
|
|
|
283
464
|
- A repeated `lock` **adds** duration (not idempotent). After any mutation, read `/resources` to
|
|
284
465
|
verify; never assume a `reply` means success.
|
|
285
466
|
|
|
467
|
+
### Polling schedule
|
|
468
|
+
|
|
469
|
+
Use one coordinated `/resources` poller per shared key where possible; distribute its
|
|
470
|
+
snapshot to the user's Agents instead of starting one independent loop per task. The
|
|
471
|
+
defaults below are starting points, not promises about a deployment's configured limits:
|
|
472
|
+
|
|
473
|
+
| Caller state | Suggested interval | Default minimum interval |
|
|
474
|
+
|---|---|---|
|
|
475
|
+
| Holding a lease, first in queue, or in the claim window | 15 seconds | 10 seconds |
|
|
476
|
+
| Queued behind another booker | 30 seconds | 20 seconds |
|
|
477
|
+
| Discovering resources, with no holding or booking | 60 seconds | 40 seconds |
|
|
478
|
+
|
|
479
|
+
Add a small positive jitter to avoid synchronized traffic. Always obey `Retry-After` on
|
|
480
|
+
429/503, whether seconds or an HTTP date; never retry before it. With no retry hint on a
|
|
481
|
+
transient failure, use bounded exponential backoff. Do not repeatedly retry authentication
|
|
482
|
+
failures, or switch credentials to bypass a budget. Server retry hints and any advertised
|
|
483
|
+
limits override these defaults. A successful mutation permits a verification read in the
|
|
484
|
+
current implementation; if that read is rate-limited, wait as instructed rather than looping.
|
|
485
|
+
|
|
486
|
+
Do not sleep until `next_event_at` without periodic checks: a holder may release early or
|
|
487
|
+
extend their lease. Treat queue estimates as estimates and recalculate from each snapshot;
|
|
488
|
+
`expires_at` is authoritative for the observed lease, not a guarantee of when you can work.
|
|
489
|
+
Use the earlier of the regular check and an upcoming event as the desired next check, but
|
|
490
|
+
never earlier than the server's polling floor or retry deadline. An event does not exempt
|
|
491
|
+
the caller from rate limits. Observe `captured_at` / `age_seconds` before acting.
|
|
492
|
+
|
|
493
|
+
When claimable, claim within `queue_claim_window_seconds` and verify ownership; never wait
|
|
494
|
+
for the predicted expiry or a human to relay a group message. While working, keep checking
|
|
495
|
+
ownership, including before critical operations and after resuming. Polling is not a push
|
|
496
|
+
subscription and cannot detect every change instantly. If ownership or lease identity no
|
|
497
|
+
longer matches, pause the workload; do not continue based on a saved registry entry.
|
|
498
|
+
|
|
499
|
+
Keep mutations separate from polling: do not repeat lock/book to check status. On completion
|
|
500
|
+
or cancellation, release/cancel only this task's resources and stop its monitoring when no
|
|
501
|
+
other task needs it. A background Agent unable to keep monitoring must tell the user it
|
|
502
|
+
cannot automatically claim a booking or continuously verify ownership.
|
|
503
|
+
|
|
286
504
|
## Typical flow
|
|
287
505
|
|
|
288
506
|
1. Identify the approved origin/instance using the steps above, then reuse only its securely stored key if already authorized. Otherwise `POST /api/resource-auth/bindings` with optional `{"label":"task runner"}` returns a credential, binding ID and one-use code. Store the credential privately; it is inactive until confirmation. Ask the human to send `@bot bind <code>` within 10 minutes, then check `GET /api/resource-auth/bindings/{binding_id}` for `confirmed`. No bot ID is needed for this request: the verified group confirmation chooses it. After confirmation, GET `/api/agent/context` with the issued key to learn the bot and operation URLs. Never simulate the human confirmation. If already bound, reuse the existing saved key; a duplicate request does not replace it. If the key is lost, ask the user to unbind and enroll again.
|
|
@@ -297,6 +515,73 @@ Keep checks running throughout long tasks, not only at acquisition. Honour the a
|
|
|
297
515
|
|
|
298
516
|
## Declare work and see others' purposes
|
|
299
517
|
|
|
518
|
+
Treat `agent_label` and `purpose` as shared display text, not private task notes. They
|
|
519
|
+
may appear in group notifications, resource webpages, other authorized users' API
|
|
520
|
+
responses, and operational logs. Turning off group notifications does not make them private.
|
|
521
|
+
|
|
522
|
+
Before sending either field, summarize the work for this audience automatically; do not
|
|
523
|
+
copy the user's prompt, internal task title, or detailed experiment plan verbatim. Use a
|
|
524
|
+
useful public summary: task category + a non-sensitive subject + the objective or current
|
|
525
|
+
phase. For lock/book, explain enough for others to understand why resources are needed;
|
|
526
|
+
a bare “testing”, “development”, or “review” usually does not suffice. Keep internal project
|
|
527
|
+
codenames, customer/personal data, paths, private URLs, exact experimental configurations,
|
|
528
|
+
and trace/debug details in your local task records. Use a neutral Agent label such as
|
|
529
|
+
`codex-test` or `claude-review`; an optional neutral suffix can distinguish concurrent
|
|
530
|
+
Agents (for example `codex-test-2`). Do not copy internal task identifiers into the label.
|
|
531
|
+
A label can disclose sensitive information too. Never include credentials.
|
|
532
|
+
Do not replace useful context with an uninformative “working” or invent a sanitized objective.
|
|
533
|
+
When details are uncertain, use the known task category or omit the optional fields; do not
|
|
534
|
+
interrupt every operation to ask the user. An explicit request to keep the task private
|
|
535
|
+
means omit both optional fields, not publish a guessed summary. For release/cancel commands,
|
|
536
|
+
omit metadata or use a brief completion summary such as “Regression testing complete”.
|
|
537
|
+
The server does not automatically redact arbitrary sensitive task text. These rules apply
|
|
538
|
+
also when updating a declaration; review existing declarations if detailed notes were
|
|
539
|
+
already published. Updating/removing one cannot retract earlier group messages or logs.
|
|
540
|
+
|
|
541
|
+
Suggested task categories and public summaries (examples, not an exhaustive enum):
|
|
542
|
+
|
|
543
|
+
| Category | Useful public purpose |
|
|
544
|
+
| --- | --- |
|
|
545
|
+
| Operator development | 算子开发:调试矩阵运算精度与边界条件 |
|
|
546
|
+
| Operator testing | 算子测试:验证不同形状和数据类型的正确性与性能 |
|
|
547
|
+
| Communication-library testing | 通信库测试:验证多卡集合通信的正确性与性能回归 |
|
|
548
|
+
| Unit testing | 单测:补充资源释放边界用例并运行回归验证 |
|
|
549
|
+
| Code review | 代码 review:检查并发资源分配逻辑,复现疑似竞态 |
|
|
550
|
+
| PR review | PR review:验证兼容性修改,运行相关回归用例 |
|
|
551
|
+
| Model development | 模型开发:调试训练流程,验证检查点恢复 |
|
|
552
|
+
| Model accuracy validation | 模型精度验证:对比修改前后的输出精度与数值稳定性 |
|
|
553
|
+
| Model performance testing | 模型性能测试:对比推理吞吐与延迟,排查性能回退 |
|
|
554
|
+
| Model load testing | 模型压测:验证高并发下的容量与稳定性 |
|
|
555
|
+
| Distributed training testing | 分布式训练测试:验证多机训练与故障恢复 |
|
|
556
|
+
| Troubleshooting | 故障排查:复现运行异常,定位显存或通信问题 |
|
|
557
|
+
|
|
558
|
+
Choose or combine categories to reflect the actual work, and respond in the group's language.
|
|
559
|
+
These examples describe an appropriate level of detail, not permission to reveal that subject:
|
|
560
|
+
generalize further when the subject itself is confidential. Do not invent a hardware need for
|
|
561
|
+
review work that does not use resources. Keep a label stable for its concurrent Agent task;
|
|
562
|
+
update the public purpose when the work changes. No fixed word count is required: prefer
|
|
563
|
+
one clear sentence, preserving useful context rather than simply truncating detailed notes.
|
|
564
|
+
Add non-sensitive scope, current phase, or why resources are needed when that helps others
|
|
565
|
+
understand the task; do not mechanically include every detail or all three template parts
|
|
566
|
+
in every operation. A simple task can have a short purpose. For performance tests, describe
|
|
567
|
+
the comparison objective; for load tests, describe capacity or stability under load.
|
|
568
|
+
|
|
569
|
+
Examples of choosing the right amount of public detail:
|
|
570
|
+
|
|
571
|
+
- Simple task: “单测:验证资源释放修复”. No extra description is necessary.
|
|
572
|
+
- Broader test: “算子测试:验证多种数据类型的精度,当前排查边界用例”.
|
|
573
|
+
- Resource-intensive task: “通信库测试:验证跨机器通信稳定性,需要同时使用多台机器”.
|
|
574
|
+
- Load test: “模型压测:逐步增加并发,观察吞吐和长时间运行稳定性”.
|
|
575
|
+
- Review with resource use: “PR review:在设备上复现疑似精度问题,验证修复”.
|
|
576
|
+
- Completion: “通信稳定性测试完成” (or omit optional metadata on release).
|
|
577
|
+
|
|
578
|
+
Use these as writing guidance, not fixed values. Include scope, phase, metrics, or the
|
|
579
|
+
reason for using several resources only when useful, non-sensitive, and actually known.
|
|
580
|
+
Do not disclose detailed workloads just to justify a reservation, add urgency/priority
|
|
581
|
+
claims the user did not make, or guess a completion time. Duration and ownership come
|
|
582
|
+
from the resource API, not from the purpose text. Keep summaries current when the task
|
|
583
|
+
meaningfully changes; do not issue extra updates for every minor step.
|
|
584
|
+
|
|
300
585
|
Normally include `agent_label` and `purpose` in the successful lock/book command; the same
|
|
301
586
|
request saves the task automatically for 24 hours, while the matching holding/booking remains
|
|
302
587
|
valid. A queue claim without new metadata carries your own booked task forward. A renewal
|
|
@@ -660,7 +660,7 @@ def restore_apply(
|
|
|
660
660
|
if not isinstance(raw_state, dict):
|
|
661
661
|
raise ValueError("Archived state is missing its state object")
|
|
662
662
|
for node in raw_state.values():
|
|
663
|
-
entries = node if bot_type
|
|
663
|
+
entries = node if bot_type in {"DEVICE", "QUEUE_DEVICE"} else [node]
|
|
664
664
|
if not isinstance(entries, list) or any(not isinstance(e, dict) for e in entries):
|
|
665
665
|
raise ValueError("Archived resource state does not match bot type")
|
|
666
666
|
for entry in entries:
|
|
@@ -113,7 +113,7 @@ class BotManager:
|
|
|
113
113
|
self._bots: dict[int, BotInstance] = {}
|
|
114
114
|
self._lock = threading.Lock()
|
|
115
115
|
self._drained = threading.Condition(self._lock)
|
|
116
|
-
self._scheduler = BotScheduler(
|
|
116
|
+
self._scheduler = BotScheduler()
|
|
117
117
|
# Admission bookkeeping, all guarded by self._lock.
|
|
118
118
|
self._retiring: set[int] = set()
|
|
119
119
|
self._inflight: dict[int, int] = {}
|