Skip to content

Add iOS background propagation sync - #154

Merged
torlando-tech merged 26 commits into
mainfrom
feat/ios-background-propagation-sync
Aug 7, 2026
Merged

Add iOS background propagation sync#154
torlando-tech merged 26 commits into
mainfrom
feat/ios-background-propagation-sync

Conversation

@torlando-tech

@torlando-tech torlando-tech commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • add application-owned BGAppRefreshTask registration, retention, scheduling reconciliation, and exactly-once completion for iOS propagation synchronization
  • initialize the embedded Python/Reticulum service graph independently of SwiftUI view lifecycle and require a live backend plus persisted propagation-node restoration before reporting readiness
  • serialize ordinary and background event processing around one bounded propagation transaction, including callback drain and durable message classification after unsuccessful transfers
  • submit eligible local notifications for newly inserted synchronized messages and derive badges from canonical durable unread state
  • use an app-owned monotonic insertion ledger so classification remains correct after SQLite row deletion and row-ID reuse
  • remove the competing iOS periodic timer while retaining timer behavior for other runtime flavors
  • add actionable scheduler, startup, propagation, persistence, notification, and completion diagnostics

Verification

  • exact feature head: 2a68ef5a980c310e1a710ac92debd9e8f32d6db6
  • static/Python suite: 261 tests, 260 passed, 1 skipped
  • focused background wiring contracts: 11/11 passed
  • full iOS simulator suite: 298/298 passed
  • Python py_compile: passed
  • git diff --check: passed
  • independent immutable exact-head review: approved
  • signed physical iPhone build, signature verification, install without data deletion, and launch: passed
  • effective Info.plist contains fetch and network.columba.Columba.sync
  • genuine cold background delivery on the physically validated production tree completed the full initialization and propagation path successfully with initialized=false at entry
  • genuine background retrieval also produced a successful local notification request with a canonical durable badge

Scheduling and presentation limitations

  • earliestBeginDate is a not-before date, not a deadline or guaranteed cadence; iOS retains control over whether and when the task runs
  • BGAppRefreshTask exposes no public priority, urgency, QoS, or deadline control
  • local notification submission does not guarantee visible presentation; authorization, Focus, foreground policy, and system presentation rules still apply
  • this remains a Reticulum propagation workflow and does not introduce an APNs dependency

Risk / rollback

  • primary risk is lifecycle behavior under discretionary iOS scheduling and bounded embedded-runtime teardown
  • diagnostics distinguish scheduler withholding from registration, startup, propagation, persistence, notification submission, and presentation failures
  • rollback is a normal revert of this branch; no remote schema or service migration is required

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds iOS background propagation-node synchronization and hardens the previously reported cancellation lifecycle.

  • Registers and schedules background refresh work independently of the SwiftUI scene lifecycle.
  • Restores persisted propagation-node configuration before enabling synchronization services.
  • Serializes cancellation teardown and scopes Swift cancellation to the active operation.
  • Drains synchronized messages and reconciles notifications, badges, and persisted settings.

Confidence Score: 5/5

The PR appears safe to merge because the previously reported cancellation races are addressed and no blocking failure remains.

The operation ID prevents stale Swift cancellation from targeting a later sync, while the Python condition-protected operation slot remains occupied until router-wide cancellation finishes, preventing late teardown from reaching a successor request.

Important Files Changed

Filename Overview
app/rns_bridge.py Replaces global stale cancellation state with a condition-protected per-operation event and keeps the operation slot occupied through router teardown.
Sources/ColumbaApp/Services/PropagationNodeManager.swift Adds single-flight synchronization, operation-scoped cancellation, bounded background timeouts, and synchronous event processing.
Sources/ColumbaApp/App/ColumbaApp.swift Introduces a launch-safe shared runtime and connects background refresh expiration to operation-scoped cancellation.
Sources/ColumbaApp/Services/BackgroundPropagationSync.swift Implements iOS background refresh registration, scheduling, execution coordination, and completion handling.
Tests/static/test_propagation_sync_cancellation.py Exercises late cancellation, active cancellation, timeout teardown, and successor exclusion around the Python synchronization slot.

Sequence Diagram

sequenceDiagram
    participant iOS as BGTaskScheduler
    participant Runtime as ColumbaApplicationRuntime
    participant Manager as PropagationNodeManager
    participant Bridge as PythonBridge
    participant Router as Python LXMRouter
    iOS->>Runtime: Deliver background refresh
    Runtime->>Runtime: Ensure shared services initialized
    Runtime->>Manager: syncNow(operationID)
    Manager->>Bridge: propagationSyncAndDrain(timeout)
    Bridge->>Router: Start propagation request
    alt Refresh expires
        iOS-->>Runtime: Expiration handler
        Runtime->>Manager: cancelActiveSync(operationID)
        Manager->>Bridge: cancelPropagationSync()
        Bridge->>Router: Cancel active request
        Router-->>Bridge: Teardown complete
    else Sync completes
        Router-->>Bridge: Result and queued events
        Bridge-->>Manager: Transaction
        Manager-->>Runtime: Success
    end
    Runtime-->>iOS: Complete refresh task
Loading

Reviews (4): Last reviewed commit: "test: handle escaped Swift multiline del..." | Re-trigger Greptile

Comment thread app/rns_bridge.py Outdated
Comment thread app/rns_bridge.py Outdated
@torlando-tech
torlando-tech merged commit 988da07 into main Aug 7, 2026
4 checks passed
@torlando-tech
torlando-tech deleted the feat/ios-background-propagation-sync branch August 7, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant