feat(tasks): persist encrypted result handoff and recover received tasks

Add signed device-scoped task state/result endpoints and AES-GCM result outbox. Atomically claim original-message replies, reject cross-user/stale/expired tasks, preserve unknown platform receipts without blind replay, and retain ambiguous ciphertext for at most seven days. Maintain legacy synchronous compatibility and clarify stale deployment-plan diagnostics. Validation: ECS suite 227 passed/2 skipped, later outbox guards 12 passed, deployment diagnostics 54 passed. Real ECS/PostgreSQL/platform failure acceptance remains pending.
This commit is contained in:
ex_tianzy
2026-11-05 10:24:55 +08:00
parent db116284b1
commit e4c3a8ad4e
6 changed files with 325 additions and 4 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ class BindingState:
(self.environment, self.app_id, device["host_id"], generation))
self.db.execute("""UPDATE work_tasks_v2 SET status=?,updated_at=?
WHERE environment=? AND app_id=? AND host_id=? AND binding_generation<=?
AND status IN ('inflight','completed','replying')""",
AND status IN ('inflight','completed','replying','delivery_ready')""",
("revoked" if reason == "revoke" else "unbound", time.time(), self.environment,
self.app_id, device["host_id"], generation))
event = uuid.uuid4().hex