feat(origin): offline mode with operation queuing #393

Open
opened 2026-03-03 23:04:27 +00:00 by forbes · 0 comments
Owner

Summary

PLM origins should degrade gracefully when the server is unreachable, queuing operations for later replay.

Current state (MISSING)

FileOrigin defines the ConnectionState enum (Disconnected, Connecting, Connected, Error) and signalConnectionStateChanged. LocalFileOrigin defaults to Connected. SiloOrigin does not implement connection state tracking. No operation queue, retry logic, or flush mechanism exists.

Proposed design

import kindred_sdk as sdk

# Automatic: when origin.connectionState != Connected, operations are queued
sdk.queue_operation("silo", "commitDocument", {"doc": doc})

# Manual flush when connection restores
sdk.flush_queue("silo")
  • SDK emits origin.connection_changed on the event bus (depends on #382)
  • Queue persists across connection drops (in-memory, not on disk)
  • flush_queue() replays operations in order when connection restores
  • Automatic flush option: flush on reconnect if origin opts in

Implementation notes

  • SiloOrigin needs to implement connectionState() and emit signalConnectionStateChanged
  • Add OperationQueue class to kindred_sdk/origin.py — stores (origin_id, method, args) tuples
  • SDK intercepts origin calls when disconnected and enqueues instead of failing
  • flush_queue() iterates the queue and calls each operation, removing on success
  • Emit events on the event bus for queue state changes

Dependencies

  • #382 (event bus) for origin.connection_changed events

Roadmap

v0.2.0 — Origin System

## Summary PLM origins should degrade gracefully when the server is unreachable, queuing operations for later replay. ## Current state (MISSING) `FileOrigin` defines the `ConnectionState` enum (Disconnected, Connecting, Connected, Error) and `signalConnectionStateChanged`. `LocalFileOrigin` defaults to Connected. SiloOrigin does not implement connection state tracking. No operation queue, retry logic, or flush mechanism exists. ## Proposed design ```python import kindred_sdk as sdk # Automatic: when origin.connectionState != Connected, operations are queued sdk.queue_operation("silo", "commitDocument", {"doc": doc}) # Manual flush when connection restores sdk.flush_queue("silo") ``` - SDK emits `origin.connection_changed` on the event bus (depends on #382) - Queue persists across connection drops (in-memory, not on disk) - `flush_queue()` replays operations in order when connection restores - Automatic flush option: flush on reconnect if origin opts in ## Implementation notes - SiloOrigin needs to implement `connectionState()` and emit `signalConnectionStateChanged` - Add `OperationQueue` class to `kindred_sdk/origin.py` — stores (origin_id, method, args) tuples - SDK intercepts origin calls when disconnected and enqueues instead of failing - `flush_queue()` iterates the queue and calls each operation, removing on success - Emit events on the event bus for queue state changes ## Dependencies - #382 (event bus) for `origin.connection_changed` events ## Roadmap v0.2.0 — Origin System
forbes added the enhancement label 2026-03-03 23:04:27 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#393