fix(device-pool): scope primary key by host and thread through capability_tags

- pooled_devices primary key changed from device_id alone to
  (host_id, device_id), so two hosts reporting the same local
  device_id no longer crash sync_host_devices() with an uncaught
  sqlite3.IntegrityError.
- Device gained a capability_tags field so DevicePool.sync_host_devices()
  can actually populate PooledDevice.capability_tags from a real host
  sync instead of always falling back to an empty list.

openspec: device-pool capability, archived change cloud-runtime
This commit is contained in:
2026-07-07 08:30:47 +08:00
parent a15756835c
commit 1bdc3784dc
7 changed files with 93 additions and 5 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ class DevicePool:
synced_at: datetime,
) -> PooledDevice:
raw_status = device.status if device.status in _HOST_REPORTED_STATUSES else "idle"
tags = list(getattr(device, "capability_tags", []) or [])
tags = list(device.capability_tags or [])
return PooledDevice(
device_id=device.id,
host_id=host_id,
+3 -2
View File
@@ -301,12 +301,13 @@ class CloudStore:
connection.execute(
"""
create table if not exists pooled_devices (
device_id text primary key,
device_id text not null,
host_id text not null,
driver_type text not null,
status text not null,
capability_tags_json text not null,
synced_at text
synced_at text,
primary key (host_id, device_id)
)
"""
)