Skip to content

fix(telemetry,client): report background sync ping and use dynamic test timestamps - #128

Open
markusbrand wants to merge 1 commit into
masterfrom
fix/background-sync-ping-and-telemetry-test
Open

markusbrand wants to merge 1 commit into
masterfrom
fix/background-sync-ping-and-telemetry-test

Conversation

@markusbrand

Copy link
Copy Markdown
Owner

Summary

This PR addresses two concrete bugs identified in BrandyBox's telemetry and testing systems:

  1. Missing client_ping telemetry in desktop client background sync loop:

    • In client-tauri/src-tauri/src/lib.rs, spawn_background_sync_loop executed periodic background sync passes but omitted the client.client_ping(Some(sync_ok), Some(last_sync_at)) call present in manual sync (run_sync).
    • Consequently, running desktop background sync never refreshed client connection presence or last sync status on the server (GET /api/admin/clients and brandybox-doctor --summary).
    • Fixed by capturing sync_ok and last_sync_at and dispatching client.client_ping upon concluding each background sync loop cycle.
  2. Backend telemetry test failure due to 30-day retention pruning:

    • In backend/tests/test_telemetry.py, test_telemetry_api_routes used hardcoded static timestamps (2026-09-16T21:00:00Z).
    • The ingestion route invokes prune_telemetry_records which purges records older than now - 30 days. When executed >30 days after September 16, 2026, the newly ingested summary was immediately pruned on insertion, failing assert any(s["trace_id"] == "sync-api-test-01" for s in summaries).
    • Fixed by computing dynamic UTC timestamps relative to datetime.now(timezone.utc).

OpenSpec Change

Tracked under openspec/changes/fix-background-sync-ping-and-telemetry-test:

  • proposal.md
  • specs/central-telemetry/spec.md (added requirements for client ping upon cycle completion)
  • design.md
  • tasks.md

Verification

  • cargo test --manifest-path client-tauri/src-tauri/Cargo.toml: 21 passed, 0 failed
  • pytest backend/tests/test_telemetry.py: 2 passed, 0 failed
  • pytest backend: 108 passed, 0 failed
  • pytest tests/e2e/test_run_autonomous_sync.py: 13 passed, 0 failed
  • ./scripts/run-qa.sh: full QA passed (client-tauri, web, backend, docs)

…st timestamps

- Report client_ping telemetry upon background sync loop completion in client-tauri spawn_background_sync_loop.
- Use dynamic UTC timestamps in backend test_telemetry_api_routes to prevent premature retention pruning.
- Add OpenSpec change tracking proposal, delta specs, technical design, and verified tasks.
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